Skip to content

2026-99: fix(harness-adapters): restore OpenCode v2 plugin loading - #99

Merged
Ivory2024 merged 4 commits into
mainfrom
fm/opencode-v2-plugin-load-regression-20261007
Oct 7, 2026
Merged

Ivory2024 merged 4 commits into
mainfrom
fm/opencode-v2-plugin-load-regression-20261007

Conversation

@Ivory2024

Copy link
Copy Markdown
Owner

Intent

이거 자꾸 뚝뚝 끊기는데 그냥 워쳐로 계속 감시할 순 없어?
조치해

Root cause found (2026-10-07, read-only): on opencode v2.0.18 every firstmate opencode plugin fails to load, so watcher arming, the session-start nudge, the turn-end guard, and the pretool seatbelt are all inert. ~/.local/share/opencode/log/opencode.log shows for all five:
failed to load plugin ... PluginModule.LoadError: Plugin must export a default definition with an id and an effect or setup function. (cause: SchemaError(Missing key at ["default"]))
Affected (tracked, .opencode/plugins/): fm-primary-cd-check.js, fm-primary-pretool-check.js, fm-primary-sessionstart-nudge.js, fm-primary-turnend-guard.js, fm-primary-watch-arm.js. That is why supervision kept cutting off (no auto-rearm) and required manual prompts.

What Changed

  • Add OpenCode v2 id and setup exports to all five primary plugins, adapting v2 tool hooks and event subscriptions to the existing handlers.
  • Add a contract test for plugin loading, hook registration, and v2 event handling; register it with the test runner.
  • Update the OpenCode harness reference with the v2 adapter contract and test path.

Risk Assessment

✅ Low: The v2 entrypoints and event payload adapters match the repository’s existing v2 plugin patterns and preserve the intended watcher and guard behavior.

Testing

A focused contract test passed, and live startup loaded all five plugins without logged load errors. The event-handler scenario was not driven against the live product.

  • Live validation: ⚠️ inconclusive - 1 of 2 scenarios driven live against the product
Scenario Result Live Evidence
Start OpenCode with isolated config; all five Firstmate plugins load without PluginModule.LoadError. ✅ pass live OpenCode v2.0.18 startup log; five loading plugin entries
Deliver session.created and session.idle v2 payloads; nudge, turn-end, and watcher handlers receive their session IDs. ⏸️ untested no The prior payload cites only a contract test, not a live product run, so it does not establish this scenario's result.
Evidence: OpenCode v2.0.18 plugin load log

Source: OpenCode v2.0.18 plugin load log

timestamp=2026-10-07T05:30:36.786Z level=INFO run=4cc4a6b0 msg="loading plugin" id=~/.no-mistakes/worktrees/4ece0e65ab1a/01M4ABFR6RF06MA9ZH7J0XFSQQ/.opencode/plugins/fm-primary-cd-check.js entrypoint=file://~/.no-mistakes/worktrees/4ece0e65ab1a/01M4ABFR6RF06MA9ZH7J0XFSQQ/.opencode/plugins/fm-primary-cd-check.js http.span=45 role=server
timestamp=2026-10-07T05:30:36.787Z level=INFO run=4cc4a6b0 message="watcher subscribe" path=~/.no-mistakes/worktrees/4ece0e65ab1a/01M4ABFR6RF06MA9ZH7J0XFSQQ/.opencode/plugins/fm-primary-cd-check.js type=file ignores=0 http.span=46 role=server
timestamp=2026-10-07T05:30:36.787Z level=INFO run=4cc4a6b0 message="watcher started" path=~/.no-mistakes/worktrees/4ece0e65ab1a/01M4ABFR6RF06MA9ZH7J0XFSQQ/.opencode/plugins/fm-primary-cd-check.js type=file backend=node ignores=0 http.span=46 role=server
timestamp=2026-10-07T05:30:36.788Z level=INFO run=4cc4a6b0 msg="loading plugin" id=~/.no-mistakes/worktrees/4ece0e65ab1a/01M4ABFR6RF06MA9ZH7J0XFSQQ/.opencode/plugins/fm-primary-pretool-check.js entrypoint=file://~/.no-mistakes/worktrees/4ece0e65ab1a/01M4ABFR6RF06MA9ZH7J0XFSQQ/.opencode/plugins/fm-primary-pretool-check.js http.span=47 role=server
timestamp=2026-10-07T05:30:36.788Z level=INFO run=4cc4a6b0 message="watcher subscribe" path=~/.no-mistakes/worktrees/4ece0e65ab1a/01M4ABFR6RF06MA9ZH7J0XFSQQ/.opencode/plugins/fm-primary-pretool-check.js type=file ignores=0 http.span=47 role=server
timestamp=2026-10-07T05:30:36.789Z level=INFO run=4cc4a6b0 message="watcher started" path=~/.no-mistakes/worktrees/4ece0e65ab1a/01M4ABFR6RF06MA9ZH7J0XFSQQ/.opencode/plugins/fm-primary-pretool-check.js type=file backend=node ignores=0 http.span=48 role=server
timestamp=2026-10-07T05:30:36.789Z level=INFO run=4cc4a6b0 msg="loading plugin" id=~/.no-mistakes/worktrees/4ece0e65ab1a/01M4ABFR6RF06MA9ZH7J0XFSQQ/.opencode/plugins/fm-primary-sessionstart-nudge.js entrypoint=file://~/.no-mistakes/worktrees/4ece0e65ab1a/01M4ABFR6RF06MA9ZH7J0XFSQQ/.opencode/plugins/fm-primary-sessionstart-nudge.js http.span=48 role=server
timestamp=2026-10-07T05:30:36.789Z level=INFO run=4cc4a6b0 message="watcher subscribe" path=~/.no-mistakes/worktrees/4ece0e65ab1a/01M4ABFR6RF06MA9ZH7J0XFSQQ/.opencode/plugins/fm-primary-sessionstart-nudge.js type=file ignores=0 http.span=48 role=server
timestamp=2026-10-07T05:30:36.789Z level=INFO run=4cc4a6b0 message="watcher started" path=~/.no-mistakes/worktrees/4ece0e65ab1a/01M4ABFR6RF06MA9ZH7J0XFSQQ/.opencode/plugins/fm-primary-sessionstart-nudge.js type=file backend=node ignores=0 http.span=48 role=server
timestamp=2026-10-07T05:30:36.790Z level=INFO run=4cc4a6b0 msg="loading plugin" id=~/.no-mistakes/worktrees/4ece0e65ab1a/01M4ABFR6RF06MA9ZH7J0XFSQQ/.opencode/plugins/fm-primary-turnend-guard.js entrypoint=file://~/.no-mistakes/worktrees/4ece0e65ab1a/01M4ABFR6RF06MA9ZH7J0XFSQQ/.opencode/plugins/fm-primary-turnend-guard.js http.span=49 role=server
timestamp=2026-10-07T05:30:36.790Z level=INFO run=4cc4a6b0 message="watcher subscribe" path=~/.no-mistakes/worktrees/4ece0e65ab1a/01M4ABFR6RF06MA9ZH7J0XFSQQ/.opencode/plugins/fm-primary-turnend-guard.js type=file ignores=0 http.span=49 role=server
timestamp=2026-10-07T05:30:36.791Z level=INFO run=4cc4a6b0 message="watcher started" path=~/.no-mistakes/worktrees/4ece0e65ab1a/01M4ABFR6RF06MA9ZH7J0XFSQQ/.opencode/plugins/fm-primary-turnend-guard.js type=file backend=node ignores=0 http.span=50 role=server
timestamp=2026-10-07T05:30:36.791Z level=INFO run=4cc4a6b0 message="watcher subscribe" path=~/.no-mistakes/worktrees/4ece0e65ab1a/01M4ABFR6RF06MA9ZH7J0XFSQQ/.opencode/plugins/lib/fm-operational-input.js type=file ignores=0 http.span=50 role=server
timestamp=2026-10-07T05:30:36.791Z level=INFO run=4cc4a6b0 message="watcher started" path=~/.no-mistakes/worktrees/4ece0e65ab1a/01M4ABFR6RF06MA9ZH7J0XFSQQ/.opencode/plugins/lib/fm-operational-input.js type=file backend=node ignores=0 http.span=50 role=server
timestamp=2026-10-07T05:30:36.791Z level=INFO run=4cc4a6b0 msg="loading plugin" id=~/.no-mistakes/worktrees/4ece0e65ab1a/01M4ABFR6RF06MA9ZH7J0XFSQQ/.opencode/plugins/fm-primary-watch-arm.js entrypoint=file://~/.no-mistakes/worktrees/4ece0e65ab1a/01M4ABFR6RF06MA9ZH7J0XFSQQ/.opencode/plugins/fm-primary-watch-arm.js http.span=50 role=server
timestamp=2026-10-07T05:30:36.793Z level=INFO run=4cc4a6b0 message="watcher subscribe" path=~/.no-mistakes/worktrees/4ece0e65ab1a/01M4ABFR6RF06MA9ZH7J0XFSQQ/.opencode/plugins/fm-primary-watch-arm.js type=file ignores=0 http.span=52 role=server
timestamp=2026-10-07T05:30:36.793Z level=INFO run=4cc4a6b0 message="watcher started" path=~/.no-mistakes/worktrees/4ece0e65ab1a/01M4ABFR6RF06MA9ZH7J0XFSQQ/.opencode/plugins/fm-primary-watch-arm.js type=file backend=node ignores=0 http.span=52 role=server
timestamp=2026-10-07T05:30:45.928Z level=INFO run=4cc4a6b0 cause="InterruptError: All fibers interrupted without error\n    at ServerProcess.start (/$bunfs/root/chunk-fegwzrys.js:2:6473)\n    at ServerProcess.start (definition) (/$bunfs/root/chunk-6bsz5sgg.js:447:23526) {\n  [cause]: InterruptCause: The fiber was interrupted by:\n      at fiber (#1)\n}" http.span=9050 role=server http.method=GET http.url=/api/event http.status=200
timestamp=2026-10-07T05:30:45.938Z level=INFO run=4cc4a6b0 message="watcher stopped" path=~/.no-mistakes/worktrees/4ece0e65ab1a/01M4ABFR6RF06MA9ZH7J0XFSQQ/.opencode/plugins/fm-primary-watch-arm.js type=file http.span=9197 role=server
timestamp=2026-10-07T05:30:45.938Z level=INFO run=4cc4a6b0 message="watcher stopped" path=~/.no-mistakes/worktrees/4ece0e65ab1a/01M4ABFR6RF06MA9ZH7J0XFSQQ/.opencode/plugins/lib/fm-operational-input.js type=file http.span=9197 role=server
timestamp=2026-10-07T05:30:45.939Z level=INFO run=4cc4a6b0 message="watcher stopped" path=~/.no-mistakes/worktrees/4ece0e65ab1a/01M4ABFR6RF06MA9ZH7J0XFSQQ/.opencode/plugins/fm-primary-turnend-guard.js type=file http.span=9198 role=server
timestamp=2026-10-07T05:30:45.939Z level=INFO run=4cc4a6b0 message="watcher stopped" path=~/.no-mistakes/worktrees/4ece0e65ab1a/01M4ABFR6RF06MA9ZH7J0XFSQQ/.opencode/plugins/fm-primary-sessionstart-nudge.js type=file http.span=9198 role=server
timestamp=2026-10-07T05:30:45.939Z level=INFO run=4cc4a6b0 message="watcher stopped" path=~/.no-mistakes/worktrees/4ece0e65ab1a/01M4ABFR6RF06MA9ZH7J0XFSQQ/.opencode/plugins/fm-primary-pretool-check.js type=file http.span=9198 role=server
timestamp=2026-10-07T05:30:45.939Z level=INFO run=4cc4a6b0 message="watcher stopped" path=~/.no-mistakes/worktrees/4ece0e65ab1a/01M4ABFR6RF06MA9ZH7J0XFSQQ/.opencode/plugins/fm-primary-cd-check.js type=file http.span=9198 role=server
- Outcome: ⚠️ 1 warning across 2 runs (4m50s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 1 issue found → auto-fixed ✅
  • 🚨 .opencode/plugins/fm-primary-watch-arm.js:516 - The v2 subscription passes each event unchanged, but the handlers still read v1 event.properties fields. OpenCode v2 plugins in this repo read payloads from event.data (for example bin/fm-spawn.sh:4284). A concrete session.idle event with data.sessionID therefore reaches ensureArm with no session ID, so watcher arming remains inert; session.created also misses its nudge. Apply the v2 event shape at the shared adapter. Same mismatch: .opencode/plugins/fm-primary-sessionstart-nudge.js:81 (session.created ID), .opencode/plugins/fm-primary-turnend-guard.js:118 (idle session ID), .opencode/plugins/fm-primary-watch-arm.js:516 (passes raw event).

🔧 Fix applied.
✅ Re-checked - no issues remain.

⚠️ **Test** - 1 warning
  • ⚠️ The changed plugins passed a focused setup-contract check, but the live OpenCode probe did not load project plugins: no OpenCode plugin config was present. The live regression scenario remains unproven.
  • ⚠️ live validation verdict: inconclusive (0 of 1 scenarios were driven live against the product); untested: OpenCode loads all five Firstmate plugins and starts watcher supervision without manual re-arming
  • Live validation: ⚠️ inconclusive - 0 of 1 scenarios driven live against the product
Scenario Result Live Evidence
OpenCode loads all five Firstmate plugins and starts watcher supervision without manual re-arming ⏸️ untested no Tried starting OpenCode v2.0.18 serve with isolated HOME/XDG directories and querying its health endpoint. The server started, but did not discover project-local plugins because the worktree has no…
  • opencode --version
  • Started OpenCode v2.0.18 serve with isolated HOME/XDG directories and queried its health endpoint; server started without discovering the project plugins.
  • bash tests/fm-opencode-v2-plugin-contract.test.sh
  • Removed disposable probe directories from the worktree.

🔧 Fix applied.
1 warning still open:

  • ⚠️ live validation verdict: inconclusive (1 of 2 scenarios were driven live against the product); untested: Deliver session.created and session.idle v2 payloads; nudge, turn-end, and watcher handlers receive their session IDs.
  • Live validation: ⚠️ inconclusive - 1 of 2 scenarios driven live against the product
Scenario Result Live Evidence
Start OpenCode with isolated config; all five Firstmate plugins load without PluginModule.LoadError. ✅ pass live OpenCode v2.0.18 startup log; five loading plugin entries
Deliver session.created and session.idle v2 payloads; nudge, turn-end, and watcher handlers receive their session IDs. ⏸️ untested no The prior payload cites only a contract test, not a live product run, so it does not establish this scenario's result.
  • tests/fm-opencode-v2-plugin-contract.test.sh
  • Started OpenCode v2.0.18 with isolated HOME, XDG config/data, and Firstmate state; captured plugin load log.
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@Ivory2024 Ivory2024 changed the title fix(harness-adapters): restore OpenCode v2 plugin loading 2026-99: fix(harness-adapters): restore OpenCode v2 plugin loading Oct 7, 2026
@Ivory2024

Copy link
Copy Markdown
Owner Author

Scope limitation (captain-recorded)

PR #99 restores OpenCode v2 plugin loading.

It does NOT restore watcher continuity.

Observed OpenCode v2 runtime emits no session.idle event, while watcher re-arm currently depends on session.idle.

Watcher lifecycle remediation is tracked separately through the OpenCodeLifecycleAdapter follow-up.

Area State
plugin loading FIXED
watcher automatic re-arm NOT FIXED

This PR must not be recorded as resolving the OpenCode v2 watcher issue.

@Ivory2024
Ivory2024 merged commit 5a72932 into main Oct 7, 2026
20 checks passed
Ivory2024 added a commit that referenced this pull request Oct 7, 2026
* fix(opencode): port firstmate plugins to v2

* no-mistakes(review): Normalize v2 event payloads for plugin handlers

* no-mistakes(test): Cover v2 event payloads in plugin contract tests

* no-mistakes(document): Document OpenCode v2 primary plugin contract
Ivory2024 added a commit that referenced this pull request Oct 7, 2026
* fix(opencode): port firstmate plugins to v2

* no-mistakes(review): Normalize v2 event payloads for plugin handlers

* no-mistakes(test): Cover v2 event payloads in plugin contract tests

* no-mistakes(document): Document OpenCode v2 primary plugin contract
@Ivory2024
Ivory2024 deleted the fm/opencode-v2-plugin-load-regression-20261007 branch October 10, 2026 12:36
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