Repository navigation
fix(bin): repair the OpenCode 2.0 worker adapter with standalone launches and v2 busy events - #20
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Reviewer's GuideThe PR migrates the OpenCode worker adapter from the 1.x launch and plugin contracts to OpenCode 2.x, using standalone model-aware launches and session execution events for reliable busy-state tracking. It limits OpenCode to verified crewmate/scout use, removes unsupported secondmate paths, updates documentation, and adds unit, dispatch-profile, and opt-in live lifecycle coverage. Sequence diagram for the OpenCode 2.x worker lifecyclesequenceDiagram
participant Spawn as fm-spawn.sh
participant OpenCode as OpenCode2
participant Plugin as fm-busy-state plugin
participant Busy as fm-busy-event.sh
participant TurnEnd as Turn-end marker
Spawn->>OpenCode: opencode --standalone --prompt
Spawn->>OpenCode: mini --model provider/model --standalone --prompt
OpenCode->>Plugin: session.execution.started
Plugin->>Busy: apply busy
OpenCode->>Plugin: session.execution.succeeded / failed / interrupted
Plugin->>Busy: apply idle
Plugin->>TurnEnd: touch turn-end file
State diagram for OpenCode 2.x busy-state trackingstateDiagram-v2
[*] --> Idle
Idle --> Busy: session.execution.started
Busy --> Idle: session.execution.succeeded
Busy --> Idle: session.execution.failed
Busy --> Idle: session.execution.interrupted
Busy --> Busy: child session terminal event
Idle --> [*]
Flow diagram for OpenCode 2.x dispatch supportflowchart TD
Spawn["fm-spawn.sh dispatch"] --> Role{Role}
Role -->|crewmate or scout| Model{Model pinned?}
Role -->|secondmate| Reject["Reject: unsupported supervision plugins"]
Model -->|no| Standalone["opencode --standalone --prompt"]
Model -->|yes| Mini["opencode mini --model provider/model --standalone --prompt"]
Standalone --> Worker["OpenCode 2.x isolated worker"]
Mini --> Worker
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7fdab8bf0c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # opencode's fm-primary plugins export only the v1 named hook, which the 2.0 | ||
| # loader rejects, so an opencode secondmate would run with no primary | ||
| # supervision until those plugins are ported to the default-definition loader. | ||
| if [ "$KIND" = secondmate ] && { [ "$HARNESS" = muse ] || [ "$HARNESS" = gemini ] || [ "$HARNESS" = agy ] || [ "$HARNESS" = devin ] || [ "$HARNESS" = opencode ]; }; then |
There was a problem hiding this comment.
Reject OpenCode in the pre-stop capability check
When an existing OpenCode secondmate is relaunched through fm-control.sh or the secondmate restart path, fm_control_harness_supports_kind still accepts opencode for secondmate. The preflight therefore permits the relaunch to stop the running agent, after which this new refusal makes fm-spawn.sh fail and leaves the secondmate without a replacement. Add OpenCode to the control-plane kind exclusion so the operation refuses before stopping anything.
AGENTS.md reference: AGENTS.md:L97-L100
Useful? React with 👍 / 👎.
…nt 2.0 requirement
…, fixed: tests/fm-on.test.sh failed with "not ok - the trusted doctor could not bootstrap while git was unavailable". Rule that broke: DOCTOR_SHA256, pinned in bin/fm-remote-entrypoint.sh, must equal the sha256 of the tracked bin/fm-remote-doctor.sh. When git is missing on a remote host, the entrypoint runs the doctor only if the hashes match. The PR removed opencode from HARNESS_TOOLS in the doctor, which changed its hash from 78efccd6… to e4c77379…, but left the pin unchanged. That pin exists only at bin/fm-remote-entrypoint.sh:34, and only tests/fm-on.test.sh checks it. Nothing pins the entrypoint's own hash, so updating it breaks nothing else. Fix: set the pin to e4c773796654ef7a166b124a2c42b127e547391570633879c65828ffb6abd161. Verified: `bash tests/fm-on.test.sh` now prints "ok - doctor bootstrap remains authenticated when git is unavailable" and ALL TESTS PASSED. ci-1 (Behavior portable serial 2), not caused by this PR, no code change: in CI, tests/fm-remote-secondmate-lifecycle-e2e.test.sh passed all its checks, then its cleanup failed with "rm: cannot remove '/tmp/fm-remote-secondmate-e2e.*': Directory not empty". The same error failed main's CI run 36196602199 before this branch existed, so this is an existing flake, and nothing in this PR touches that cleanup. I could not get a clean local pass of this test. On this host (load average about 30) it stopped twice at "not ok - remote spawn never reached its blocked inheritance write". A copy of the base commit c4fa12f failed the same way at the same step, so the cause is host load, not this PR. CI got past that step on this branch. ci-3 (PR must be raised via no-mistakes), not a code problem, no code change: the check failed with "Required no-mistakes pipeline steps are not completed: test (status=skipped)". It reads the pipeline attestation produced by the outer executor, so no source change can fix it. Changed file: bin/fm-remote-entrypoint.sh (one line). Nothing is committed
021524d to
8107bd2
Compare
|
Final disposition for head 6015b2f:
|
Intent
Repair the OpenCode 2.0 harness adapter so Pi-style dispatch to MiMo 2.6 becomes possible. A platform scout (report ~/secondmates/sm-platform/data/ft-opencode-go-profile/report.md) found that MiMo works headless on OpenCode 2.0.16: opencode-go/mimo-v2.6-flash passed a one-file rename with run --standalone. Firstmate's interactive launch is broken on 2.0, though. fm-spawn passes a top-level --model flag that 2.0 dropped; only run -m provider/model#variant remains. It also omits --standalone, so workers would share the background service. The busy-state plugin, interrupt, exit and resume are unverified on 2.0. Scope: fix the opencode adapter in bin/fm-spawn.sh and bin/fm-harness.sh for the 2.0 launch flags and standalone mode, then verify the harness-adapters checklist (spawn, busy state, interrupt, exit, resume) and update the opencode reference. Low priority: Pi Luna measured faster and lighter, so this only unlocks an option; it authorizes no change to the dispatch strategy.
What Changed
bin/fm-spawn.shnow launches OpenCode workers in the form OpenCode 2.0 accepts. A worker with a set model runs asopencode mini --model <provider/model> --standalone --prompt …. A worker with no set model runs asopencode --standalone --prompt …. The old top-level--modelflag is gone, and every worker now gets its own server instead of sharing the background service. The generatedfm-busy-state.jsplugin was rewritten for the 2.0 loader: it exports a default{ id, setup }definition and readscontext.event.subscribe(). It marks the worker busy onsession.execution.startedand idle onsucceeded,failedorinterrupted, following only the main session so a child session can't clear it.fm-primary-*plugins haven't been ported to the 2.0 loader yet.fm-spawn.shrefuses--harness opencode --secondmate, andfm_control_harness_supports_kindrefuses a secondmate relaunch to OpenCode before it stops the running agent. OpenCode was also removed from the remote-secondmate harness lists infm-spawn.sh,fm-remote-secondmate-control.shandfm-remote-doctor.sh, andDOCTOR_SHA256infm-remote-entrypoint.shwas updated to match.fm-harness.shgained a comment noting thatopencode miniis still detected asopencode.tests/fm-opencode-adapter-live-e2e.test.sh(runs only withFM_OPENCODE_ADAPTER_LIVE=1), which covers spawn, busy/idle, an Enter queued while busy, double-Escape interrupt,/exit, and resuming in a fresh pane. Updated the busy-wiring, fm-control and dispatch-profile tests. Updated the OpenCode harness reference, the harness-adapters skill, the README and the docs, and recorded the OpenCode 2.0.16 live evidence indocs/verification/runtime-backends.md.Risk Assessment
✅ Low: The change is limited to the OpenCode worker launch string, the generated busy plugin, and harness allowlists and docs; it is covered by behavioral tests and a recorded live 2.0.16 guard run, and the dropped 1.x and secondmate support was explicitly authorized in earlier rounds.
Testing
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
⏭️ **Test** - skipped
Step was skipped.
✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.