Skip to content

[MC:   NN.1.S] Add OpenCode Go, endpoint plugins, and review fixes (Refs OPS-1122) - #556

Merged
jaywedgeworth22 merged 8 commits into
mainfrom
muse-code/opencode-go-plugins-review
Nov 26, 2026
Merged

jaywedgeworth22 merged 8 commits into
mainfrom
muse-code/opencode-go-plugins-review

Conversation

@jaywedgeworth22

@jaywedgeworth22 jaywedgeworth22 commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Refs OPS-1122. Refs CC-238 (already landed in #554/#555; verified here, not duplicated).

Summary

Adds built-in OpenCode Go quota monitoring and declarative endpoint plugins, plus review-driven UI, reliability, and accessibility fixes. Refs OPS-1122.

What changed

  • Added OpenCode Go as an optional built-in source under opencode-go with 5-hour, weekly, and monthly windows read from OpenCode's usage endpoint using the CLI's locally saved Go key. Missing sign-in reports no windows and no issue; 401/403 and service failures surface as provider issues. New Settings row enables toggling without an app update.
  • Added declarative endpoint plugins loaded from ~/Library/Application Support/CodeCaps/Plugins/*.json. Descriptors define one GET endpoint, auth as none or Bearer env-var name, and 1–10 windows via restricted JSON paths for remaining/used percent or absolute balances plus reset stamps. Validation refuses reserved provider keys, non-HTTPS endpoints except opted-in loopback, private/metadata literals, userinfo/query/fragment URLs, oversize/invalid files, and duplicates. Plugins register as optional readers with plugin:<slug> ids and flow through existing snapshots, ranking, and toggles.
  • Updated Settings Sources & Fleet and Logo Style lists to include OpenCode Go and current plugins, and fixed optional-reader disable to purge plugin windows by provider key. Added docs/ENDPOINT-PLUGINS.md and extended docs/TOKEN-PLAN-SOURCES.md.
  • Added bounded retry for v2 quota publish on 502/503/504 and timeouts, with no retry for generic webhooks. Added 10-second timeout for snapshot predecessor wait so one stuck disk write reports failure instead of stalling later writes.
  • Applied UI/accessibility fixes: menu tooltip hint, PiP and console keyboard support, VoiceOver handling for PiP controls and exhaustion popups, and text/contrast sizing updates. Runtime verification was not reported.

Tests added

  • Added EndpointPluginTests covering descriptor validation, SSRF matrix, loopback opt-in, JSON path grammar, generic reader mapping, missing-key behavior, loader fail-closed behavior, and disabled-plugin factory non-invocation.
  • Added OpenCodeGoQuotaReaderTests covering percent inversion, rate-limited exhaustion, absent-key behavior, auth wording, unparseable payloads, and auth-file extraction.
  • Extended QuotaPublisherTests with transient retry and no-retry webhook cases, and SnapshotWriteDrainTests with predecessor-timeout coverage. Test execution results were not reported, so passing status is unverified.

Open review findings / risks

Automated review reported 5 unresolved findings, described here as reported and unverified:

  • Critical: missing plugin token error omits the exact env variable name in GenericEndpointQuotaReader.swift:48.
  • Medium: optional reader toggle may scan disk on every toggle in MonitorModel.swift:1358.
  • Medium: out-of-range quota percent is clamped rather than rejected in GenericEndpointQuotaReader.swift:94.
  • Medium: unrestricted bearerEnv may allow reading any environment variable in GenericEndpointQuotaReader.swift:29.
  • Low: alert text rendering issue in ConsoleViews.swift:340.

DNS-rebinding residual risk for plugins is noted in code comments as trusted local configuration.


Summary

Fixes punctuation in the Console unavailable-source alert. Adds a period after the provider / window identifier before the Sources & Fleet guidance.

Impact

User-visible text correction only with no logic or flow change. Refs OPS-1122.

Verification

No test evidence is included in the provided changes; behavior is unverified.


Refs OPS-1122. Adds endpoint-plugin hardening and a cached loader for UI use.

Changes

  • Restricts plugin bearer auth to CODECAPS_PLUGIN_* environment names with defense-in-depth checks at validation and token read, and updates docs and messaging to reflect the namespaced variable requirement.
  • Tightens endpoint validation to keep HTTPS default-or-443 for external hosts even with loopback opt-in, and to refuse private literals and non-canonical numeric hosts such as hex, octal, bare-integer, or leading-zero forms.
  • Corrects window validation with a distinct display-name error and a rule allowing at most one percent path, requiring an absolute remaining/limit pair when no percent path is present.
  • Updates quota reading to drop windows with non-finite or out-of-range percentages as unreadable and to clarify the missing-variable sign-in message.
  • Adds a 60-second loadCached() plugin cache and switches MonitorModel and Settings status rows to it, while refresh continues to use direct load().

Tests

  • Adds tests for external-port refusal with loopback opt-in, dual percent-path refusal, distinct display-name error, namespaced env acceptance, and out-of-range percent handling; other coverage for loopback opt-in, loader filtering, and sign-in messaging was updated.
  • No test execution, deployment, or runtime verification is reported as completed in the provided changes.

Open risks

  • Automated review reported 3 unresolved findings that remain unverified: possible trailing-dot loopback SSRF bypass, transient load failures cached for full TTL, and out-of-range percent discarding a valid absolute-quota fallback. These behaviors are described as reported and have not been verified as fixed.

Summary

Refs OPS-1122. Adds review fixes for endpoint plugins: loopback validation, plugin cache handling, and quota percent fallback.

Changes

  • EndpointPluginDescriptor: strips trailing dot before loopback check so localhost. and 127.0.0.1. remain loopback-restricted and do not fall through to the public path. Port relaxation remains loopback-only.
  • EndpointPluginLoader.loadCached: returns empty without stamping cache when Plugins folder is missing, so a newly created folder is seen on next access. When directory listing fails, serves last good descriptors and retries on next access rather than caching the failure for TTL.
  • GenericEndpointQuotaReader: when reported percent is out-of-range or non-finite, falls back to absoluteRemaining / absoluteLimit * 100 when available. Drops window only when neither source yields an in-range value.

Tests

  • Added testTrailingDotLoopbackIsRefusedWithoutOptIn covering localhost. and 127.0.0.1. validation. Added testGenericReaderFallsBackToAbsolutesWhenPercentOutOfRange covering 140% percent with 30/100 absolutes yielding 30% remaining. Run results and runtime verification remain unverified in this description.

Risks / Open review finding

  • Medium (unresolved, unverified): Sources/QuotaCore/EndpointPluginLoader.swift:37 — cache lock held across disk scan, serializing callers.

Summary

Refs OPS-1122. Updates EndpointPluginLoader plugin descriptor caching to reduce lock contention during disk scans.

Changes

  • Snapshot cached descriptors under lock and release the lock before scanning defaultDirectory.
  • Serve last-good / stale descriptors when the directory cannot be listed, without caching the failure for the full TTL.
  • Re-acquire the lock only to publish the scan, and skip publishing if another caller already refreshed the cache.
  • Preserves existing TTL and missing-directory behavior while avoiding serializing Settings and toggle callers behind the full read.

Operational impact

  • Reduces blocking for concurrent callers when the cache is expired and a filesystem scan is required.
  • Transient list failures continue to serve prior rows and retry on next access.

Risks / Open review finding

  • Automated review reports 1 medium finding at Sources/QuotaCore/EndpointPluginLoader.swift:46: TTL-expired callers scan plugins concurrently. Behavior under concurrent expired-cache scans remains unverified.

Tests

  • No test evidence provided in the supplied changes. Scan, caching, and concurrency behavior is unverified.

Summary

Refs OPS-1122. This change adds single-flight coordination for EndpointPluginLoader cache refreshes on TTL expiry.

Changes

  • Adds a dedicated scanLock to serialize the off-lock directory scan.
  • Callers arriving during the same expiry wait on the scan lock, then re-check loadedAt before performing disk work.
  • Preserves existing transient-failure behavior of serving last-good descriptors when the folder cannot be listed.

Operational impact

Reduces redundant disk scans when concurrent accesses coincide with TTL expiry, returning one fresh descriptor set to all waiters. No API or behavior change beyond reduced concurrent scan work.

Verification

Automated code review reported no issues. No test evidence is included in the provided changes, and concurrent-refresh behavior remains unverified.

…iew fixes (Refs OPS-1122)

- OpenCode Go: documented usage endpoint via the CLI's local auth file
- Endpoint plugins: validated JSON descriptors in the Plugins folder,
  generic bounded reader, SSRF gate, Settings toggles without recompiling
- Alibaba/MiMo/Qwen verified against #554/#555 (already on main), docs updated
- UI: sentenceGap, accent-ink shortcut, logo fallback from reader list,
  PiP keyboard/VoiceOver access, larger tertiary labels, keyboard splitter,
  popup no longer auto-expires for VoiceOver/Reduce Motion, right-click hint
- Perf: snapshot-write chain predecessor deadline surfaces a stuck write
  instead of stalling silently; v2 publisher retries transient 502/503/504
@linear-code

linear-code Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

CC-238

OPS-1122

@kody-ai

kody-ai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ✅

Access your configuration settings here.

​

Comment thread Sources/CodeCaps/SettingsViews.swift Resolved
@kody-ai

kody-ai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Automatic approval held

Kody's assessment:

Risk was identified in this PR.

@kody-ai

This comment has been minimized.

Comment thread Sources/CodeCaps/ConsoleViews.swift Resolved
Comment thread Sources/CodeCaps/MonitorModel.swift Resolved
kody-ai[bot]
kody-ai Bot previously requested changes Nov 25, 2026

@kody-ai kody-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found critical issues please review the requested changes

Kody takes this request back once the findings above are resolved.

@kody-ai

This comment has been minimized.

- Restrict bearerEnv to CODECAPS_PLUGIN_-prefixed variables and name the
  missing variable in the plugin issue
- Refuse non-canonical IP literals (hex/octal/bare-integer/leading-zero)
  and scope the loopback port exception to loopback hosts only
- Reject descriptors with both percent paths; dedicated badDisplayName error
- Reject out-of-range percentages instead of clamping them
- Cache plugin loads for Settings rows and reader toggles
@kody-ai

This comment has been minimized.

@kody-ai
kody-ai Bot dismissed their stale review November 26, 2026 00:55

The critical findings behind this request are resolved.

@kody-ai

This comment has been minimized.

@kody-ai

This comment has been minimized.

@kody-ai

kody-ai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ✅

Access your configuration settings here.

​

@jaywedgeworth22
jaywedgeworth22 enabled auto-merge (squash) November 26, 2026 02:31
@jaywedgeworth22
jaywedgeworth22 merged commit fecfdb3 into main Nov 26, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant