opencode-model-router 2.8.0 → 2.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/CHANGELOG.md +372 -0
  2. package/README.md +22 -2
  3. package/package.json +5 -1
  4. package/src/commands/output.ts +23 -1
  5. package/src/compat/background.ts +2439 -0
  6. package/src/compat/child-session.ts +6 -0
  7. package/src/compat/turn-state.ts +215 -0
  8. package/src/compat/v2-client.ts +136 -17
  9. package/src/compat/v2-hooks.ts +2656 -114
  10. package/src/compat/v2-observations.ts +328 -0
  11. package/src/executor/capacity.ts +362 -0
  12. package/src/executor/child-guards.ts +40 -0
  13. package/src/executor/command.ts +265 -0
  14. package/src/executor/compile/edges.ts +809 -0
  15. package/src/executor/compile/estimate.ts +158 -0
  16. package/src/executor/compile/footprint.ts +829 -0
  17. package/src/executor/compile/index.ts +1080 -0
  18. package/src/executor/compile/parse.ts +1492 -0
  19. package/src/executor/compile/residue.ts +706 -0
  20. package/src/executor/compile/validate.ts +280 -0
  21. package/src/executor/create.ts +672 -0
  22. package/src/executor/expand.ts +551 -0
  23. package/src/executor/git.ts +1214 -0
  24. package/src/executor/host-preamble.ts +17 -0
  25. package/src/executor/instructions.ts +35 -0
  26. package/src/executor/integrate/bisect.ts +73 -0
  27. package/src/executor/integrate/checks.ts +1086 -0
  28. package/src/executor/integrate/land.ts +177 -0
  29. package/src/executor/integrate/phase-suite.ts +407 -0
  30. package/src/executor/integrate/queue.ts +3083 -0
  31. package/src/executor/integrate/run-resolver.ts +19 -0
  32. package/src/executor/launch.ts +652 -0
  33. package/src/executor/ledger.ts +2208 -0
  34. package/src/executor/observations.ts +212 -0
  35. package/src/executor/paths.ts +159 -0
  36. package/src/executor/platform.ts +39 -0
  37. package/src/executor/process-identity.ts +19 -0
  38. package/src/executor/qa-loop.ts +470 -0
  39. package/src/executor/recovery.ts +403 -0
  40. package/src/executor/runtime.ts +6233 -0
  41. package/src/executor/schedule.ts +246 -0
  42. package/src/executor/slots/env.ts +145 -0
  43. package/src/executor/slots/pool.ts +1564 -0
  44. package/src/executor/slots/provision.ts +853 -0
  45. package/src/executor/tool.ts +534 -0
  46. package/src/executor/types.ts +2064 -0
  47. package/src/executor/unattended.ts +488 -0
  48. package/src/guard/store.ts +3 -1
  49. package/src/index.ts +1498 -288
  50. package/src/router/config.ts +776 -25
  51. package/src/router/git-tools.ts +106 -15
  52. package/src/router/leases.ts +1469 -0
  53. package/src/router/logger.ts +44 -32
  54. package/src/router/protocol.ts +40 -10
  55. package/src/router/role-agents.ts +224 -17
  56. package/src/router/roles-config.ts +10 -1
  57. package/src/router/roles.ts +1 -1
  58. package/src/router/run-tools.ts +56 -4
  59. package/src/router/tool-paths.ts +308 -0
  60. package/src/router/work-roots.ts +86 -0
  61. package/src/routing/advisor/findings.ts +25 -5
  62. package/src/routing/classify/index.ts +7 -1
  63. package/src/routing/classify/rules.ts +11 -0
  64. package/src/routing/commands/stats.ts +2 -2
  65. package/src/routing/outcomes/durations.ts +225 -0
  66. package/src/routing/outcomes/index.ts +59 -2
  67. package/src/routing/outcomes/persist.ts +409 -0
  68. package/src/routing/outcomes/stats.ts +170 -11
  69. package/src/routing/outcomes/timings.ts +836 -0
  70. package/src/routing/outcomes/types.ts +98 -0
  71. package/src/routing/roles/approvals.ts +86 -5
  72. package/src/routing/roles/binding.ts +99 -9
  73. package/src/routing/roles/orphans.ts +68 -0
  74. package/src/routing/roles/policy.ts +21 -3
  75. package/src/routing/roles/work-root.ts +3 -1
  76. package/src/routing/wire/dispatch.ts +86 -12
  77. package/src/routing/wire/hint.ts +56 -8
  78. package/src/v2.ts +94 -49
  79. package/src/verify/branch.ts +8 -2
  80. package/src/verify/canonical-path.ts +35 -0
  81. package/src/verify/deterministic.ts +38 -9
  82. package/src/verify/dispatch.ts +64 -28
  83. package/src/verify/exec.ts +52 -9
  84. package/src/verify/pending.ts +1691 -10
  85. package/src/verify/perimeter.ts +12 -6
  86. package/src/verify/plan-task.ts +729 -0
  87. package/src/verify/reference.ts +216 -3
  88. package/src/verify/tree.ts +30 -13
  89. package/src/verify/types.ts +9 -2
  90. package/src/verify/wiring.ts +290 -31
  91. package/tiers.json +5 -5
package/CHANGELOG.md CHANGED
@@ -7,6 +7,378 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.9.1] - 2026-10-25
11
+
12
+ ### Changed
13
+
14
+ - **`hybrid` preset: `medium` and `heavy` run at `high` instead of `xhigh`.** `openai/gpt-6.1-sol-fast` (variant)
15
+ and `anthropic/claude-opus-5-5` (variant and effort) drop one reasoning level to cut cost; models and cost ratios are
16
+ unchanged.
17
+
18
+ ## [2.9.0] - 2026-10-25
19
+
20
+ ### Added
21
+
22
+ - **OpenCode v2: `routing.orphans.resume`**, `"refuse"` by default or `"allow"` to skip the early stale-role-resume check.
23
+ A bounded process-wide registry tracks refused resumes and lost role dispatches; the first refusal warns, later
24
+ ones log at debug. Binding-lookup failures share a separate process-once warning, then log at debug. Inert on v1,
25
+ where the existing v2-only-features notice also names orphan cleanup.
26
+ - **OpenCode v2: role-dispatch decision rows record where their risk came from.** `trace.riskSources` lists the class
27
+ base risk, the rules estimate, the route line's `risk=` claim, the merged facts, any inherited resume risk and the
28
+ effective risk, plus an optional bounded vocabulary label (a single word or a table id, never prompt text). Routing
29
+ is unchanged; older rows stay readable.
30
+ - **OpenCode v2: configurable `routing.roleFloor: "gated"`** (bundled `tiers.json` or global override, not project overrides;
31
+ code default `"strict"`). A role dispatch that may edit
32
+ and run commands, whose detection is `grader`, whose risk is not `high`, whose return gate runs and whose role can
33
+ be raised from `medium` straight to `heavy`, gets a `medium` authority floor instead of `heavy` (bounds reason
34
+ `gated:authority`, recorded only when gating lowers the final floor). A verification FAIL, and for gated children also
35
+ an UNVERIFIABLE return, raises the resumed child to `heavy`. Every other floor cell is unchanged; inert on OpenCode v1.
36
+ - **OpenCode v2: intrinsic service observations for the amended G8 oracle (A-6.1-1).** With the opt-in observations
37
+ below, verification checks/grading, integration rebase/checks/fast-forward and phase-suite commands emit paired
38
+ service spans that bracket only their execution; preparation, slot and lease waits, and retry backoff are recorded as
39
+ separate spans so they cannot inflate a bound term. Off by default and inert on OpenCode v1.
40
+ - **OpenCode v2: opt-in diagnostic observations.** Set `MODEL_ROUTER_V2_OBSERVATIONS=<directory>` to an existing
41
+ directory before setup to write bounded, sequence-numbered JSONL streams, sealed on adapter disposal. They
42
+ record dispatch native-argument fingerprints, completion effects, scheduler and physical-slot transitions,
43
+ without prompt or file content. Off by default and inert on OpenCode v1.
44
+ - **CPX e2e smoke diagnostics:** bounded wrapper/child-command timings and host/setup/launch checkpoints are
45
+ retained with failure evidence before scratch cleanup. These are diagnostic observations only; executor
46
+ behavior, offline checks and G1–G12 bounds are unchanged.
47
+ - **CPX soak: `npm run soak:analyze` offline soak analyzer (amendment A-6.1-3).** It reads retained soak evidence and
48
+ reports observations, violations and per-criterion and per-subcase status. Subcases the current logs cannot show
49
+ are reported as `not-observable` declared gaps, never as passes (A-6.1-6); an overall passing verdict requires at least
50
+ five working days and every required criterion to be `ok`. Absence of evidence is never a pass.
51
+ - **OpenCode v2: `/router stats` shows a "Dispatch durations" table and an "Orchestrator cache-read share" line** when
52
+ timing logs exist.
53
+ - **OpenCode v2: background dispatch.** A subagent dispatch whose predicted duration is long runs in the background
54
+ (`routing.background.mode`: `auto` decides from the predicted duration, `model` lets the orchestrating model decide,
55
+ `off` keeps every dispatch in the foreground as before; `routing.background.minPredictedMs` sets the `auto` threshold).
56
+ The router state lists the dispatches in flight and those completed since the last turn, and the router guarantees
57
+ apply when a background child completes.
58
+ - **OpenCode v2: held results with verdict delivery.** The result of a background dispatch that requires verification
59
+ is held: the orchestrator sees a placeholder until the verification gate settles, a resume of the held child is
60
+ refused, and the verdict is posted to the orchestrator's session. A held result whose gate gives no verdict (a
61
+ failed or interrupted child, no verification required, an error in the gate, a restart that lost the verification
62
+ data) is posted as `UNVERIFIABLE` with its reason, never as `PASS`. `router_verify` refuses a held handle: its own
63
+ gate posts the verdict.
64
+ - **OpenCode v2: work leases** (`routing.leases.mode`, `routing.leases.run`). A child session holds a lease on each
65
+ file it edits in its checkout; another child's edit of that file in the same checkout is refused until the lease is
66
+ released (a plan task's lease also refuses another plan task's edit of that path in any linked worktree), search
67
+ results under another holder's edit are omitted, and `router_run` annotates or refuses a run on a leased target.
68
+ - **OpenCode v2: restart recovery.** In-flight dispatches, held results and pending verifications are journaled in
69
+ `pending.jsonl` in the per-user state directory (`~/.local/state/opencode-model-router`, or
70
+ `$XDG_STATE_HOME/opencode-model-router` when set, outside Windows), never in the temp directory. `/router approve`
71
+ refuses that directory and any repository inside it (a protected location). After a restart the router recovers a
72
+ dispatch whose child finished, re-posts a verdict that was reached but not delivered, and keeps posted results
73
+ hidden. A restored pending verification keeps its cross-repo checks: the branch and HEAD recorded at return, the
74
+ unobservable writers and the check placements of a deferred dispatch are journaled and checked again, and a record
75
+ with a malformed one is dropped. A dispatch's perimeter is not journaled, so `router_verify` on a restored handle
76
+ whose dispatch had one reports `UNVERIFIABLE` (`perimeter lost in restart`), never `PASS`. A held result's
77
+ dispatch-time head is journaled and checked again: a held result whose head or perimeter was lost settles
78
+ `UNVERIFIABLE`, and a restored held result settles in place. A journal that vanishes under a running process is
79
+ rewritten from memory. OpenCode v1 ignores every `routing.background.*` and `routing.leases.*` key and logs one
80
+ notice per process that names them.
81
+ - **OpenCode v2: the plan executor is Windows only in this release.** Its execution slots need a drive-letter path
82
+ (`routing.executor.slotsDir`, default `<drive>:\.omr-slots\<planId>`). On platforms other than Windows it is inert:
83
+ `router_plan` and `/plan` are not registered, `/router` does not list `/plan`, role agents get no slots rule and no
84
+ executor-home lookup runs (`<git common dir>/omr-executor`, found on disk without running git, is still denied to
85
+ them whenever the common directory resolves, even before it exists), invalid `routing.executor.*` values are not reported, no executor discovery runs at start, and when
86
+ roles mode at start with enforced leases and verification not `never` would assemble it the router logs one notice
87
+ per process, `plan executor requires Windows; router_plan and /plan are not registered`.
88
+ - **OpenCode v2: plan executor registration.** `router_plan` and `/plan` are registered only in roles mode selected at
89
+ start, and `router_plan` resolves the executor at call time; `/router` lists `/plan` only when it is registered, not
90
+ user-defined, and the executor prerequisites hold (roles delegation, enforced leases, verification not `never`, a
91
+ location inside `routing.workRoots` when configured). State-changing and authority actions (`compile`, `residue`, `approve`, `adopt`, `abort`, `purge`, `land`,
92
+ `answer`, `pause`, `resume`, `add-tasks`, `done`, `gc`, and any other state-changing action) require a proven
93
+ depth-0 session with no parent, with no bound-plan-child exception; failed parent lookups refuse. Read-only
94
+ `status`, `ready`, `export` and `/plan inbox` allow roots or exactly bound plan children reading only their own
95
+ explicitly named plan, never another plan. The same rule guards the tool and command. An existing user-defined
96
+ `/plan` is preserved: v2 checks the host command registry, logs one conflict warning and keeps `router_plan` available;
97
+ v1 adds no `/plan` notice for that user command. Active plans add executor instructions to router state after the plan
98
+ section. Assembly requires a git repository, roles delegation, enforced leases and a plan-task verifier with
99
+ verification enabled; otherwise the tool and command report why the executor is unavailable. The keys, tool and
100
+ command have a user guide ([docs/EXECUTOR.md](docs/EXECUTOR.md)) and a design record
101
+ ([ADR 0007](docs/adr/0007-critical-path-execution.md)); `slotsDir`, `integrationChecks`, `phaseSuite`,
102
+ `provision` and `python` are trusted keys that only the global override sets. `/router approve` refuses a repository's
103
+ executor home (`<git common dir>\omr-executor`, with its plan and slot-marker directories) and any repository inside
104
+ it; that check runs git within one 15 s bound in all, and
105
+ refuses a candidate it could not finish in time. OpenCode v1 ignores every `routing.executor.*` key and logs one
106
+ notice per process that names them; a best-effort `/plan` use without a user-defined command shares that notice and
107
+ adds no output. The v1 tool, command and help maps are unchanged. Breaker answers and QA-cap `accept`/`fix` answers
108
+ that unpause a phase re-enqueue its verified tasks and wake the integration lanes, without duplicating queued entries
109
+ or bypassing task leases. Foreign plans attach read-only: startup and failed-adopt recovery check the ledger's
110
+ repository before opening a writer, so viewing a foreign plan takes no writer lock and changes no writer epoch or
111
+ journal. Status remains available; mutation requires that repository. The trusted slots root stays allowed after a
112
+ restart or `/router-reload` while slot and integration worktrees exist; roots inside or above a non-slot checkout are
113
+ refused, and the default slots drive comes from the location's repository toplevel; a registered worktree whose folder
114
+ is gone never blocks that allow. One executor runs per process: a plugin copy refused by the process claim waits and
115
+ assembles once the holder disposes, running recovery once, and is wired into the host exactly like an executor
116
+ assembled at start (plan state, executor instructions, host events, retry stop, ordered disposal). Plan-task
117
+ verification is cancelled first at disposal, a verdict decided before disposal is still journaled, manual `gc` of a
118
+ completed plan waits for pending phase tags, and `purge` creates no directories, removes the empty plan directory and
119
+ skips collection for an invalid `slotsDir` when the plan holds no slot markers. A `NEED MORE: budget` end resumes
120
+ the same child session as many times as the guard's cumulative call multiplier allows (`BUDGET_RESUMES`), then
121
+ parks as `budget-cap`; each budget resume starts a new guard round for that child across plugin locations (its per-dispatch budget and read
122
+ count restart, the cumulative ceiling stays). A superseded run's late rejection cannot interrupt or unregister its resumed round.
123
+ Plan children keep their resolved tier for both round budgets and cumulative ceilings. An editing task's
124
+ child gets the executor's `CAP:12` read cap (its `[cap: n/12]` and `CAP REACHED` banners, as a routed child's `CAP`)
125
+ and its route's `budget=` as its call budget; interrupted, parked or lost attempts keep
126
+ their uncommitted work on `omr/<plan>/wip/<task>` for the next attempt; WIP refs remain until purge, including after
127
+ abort. Unsaved-slot holds are rebuilt after restarts; gc and purge retry saving before collection. Purge waits up to
128
+ 30 seconds for abort cleanup and refuses if it is still pending. Successful clean or presaved releases clear rebuilt
129
+ holds too, preventing duplicate abort releases; retained gc predicates still refuse any remaining hold.
130
+ Metadata-less slot directories are quarantined,
131
+ not counted as clean, and pool gc preserves uncommitted work unless the caller explicitly marks it saved.
132
+ Orchestrator-shell filtering drops only the semicolon-delimited clause marked `(orchestrator shell)`, not its
133
+ neighbours, and compilation warns on mixed criteria lines. A block left with no criteria and no checks falls back to
134
+ the inferred DoD. A cap written in the plan is neutralised with the task's other directives, and shared-context
135
+ directives are neutralised at compile, keeping the stored text identical at launch; editing tasks receive the
136
+ executor's own `CAP:12`, placed first (right after `PLAN CONTEXT`, before the shared context and the task text), so
137
+ it is the first cap token in the child prompt even when a plan token split across lines survives neutralisation.
138
+ Compilation takes the base branch tip from the repository toplevel (detached HEAD is refused) using the
139
+ full branch ref, so a same-named tag cannot confuse it; approval reads the actual plan's ledger rather than deriving
140
+ its id from the slots directory and refuses a moved base with `E_STALE_BASE`. Integration/CI worktrees start from
141
+ the ledger's integration head. Disposal no longer waits on a launch begun after it started: once a plan is disposing,
142
+ the runtime hands the launcher no new child and no budget resume. A park whose slot work could not be saved keeps
143
+ the slot on the parked task (the ledger accepts a slot on a parked task for this), so the slot is never reset or
144
+ released while that work is unsaved. After an abort, slot collection (automatic or `gc`) waits until each cancelled
145
+ child's slot was saved and released, or held when its save failed, so a slot is never collected mid-save.
146
+
147
+ ### Changed
148
+
149
+ - **OpenCode v2: the cost doctor separates fresh unknown bindings from stale role resumes.**
150
+ `role-binding-unknown` warns only for fresh children; the new `role-child-stale-resume` info finding reports
151
+ resumed unknown-binding rows over 7 days and this process's refused resumes, without a notice. It suggests
152
+ `routing.orphans.resume: "refuse"` only when set to `"allow"`; role-stats totals are unchanged.
153
+ - **OpenCode v2: stale role-child resumes are refused before a new attempt starts.** An unregistered or retired
154
+ dispatch nonce would leave the child unbound (local actions only, no work root): dispatch a fresh task with the same
155
+ prompt and route line instead. Plan children, live/recovering attempts and other unknown-binding causes are unchanged.
156
+ A lost role-dispatch wake adds `Dispatch a fresh task: resuming it is refused.` only with live roles and resume mode
157
+ `"refuse"`. The refusal covers dispatches lost in a restart or already finished, and names the call's agent.
158
+ - **OpenCode v2: roles protocol teaches slicing for cost within its existing byte budget.** Non-design work is split
159
+ into edit-only implementer dispatches (`class=implement needs=edit d=deterministic` + `testsPass` acceptance), keeping
160
+ the authority floor at most `medium` even at high risk when verification is enabled; a slice that must run commands
161
+ gets a machine check and `VERIFY:required`, avoiding the `heavy` write + exec authority floor when the router gates
162
+ it. Routing is unchanged.
163
+ - **CI: pull requests are Linux-only; one Windows Node 22 typecheck + full-suite coverage job runs on master pushes
164
+ and manual runs.** Linux e2e and Bun smoke stay blocking. Without Windows coverage, only `src/verify/exec.ts`
165
+ and the `src/executor/` prefix are warn-only; with it, all coverage gates block (G-21).
166
+ - **OpenCode v2: register `router_plan` and `/plan` only in roles mode selected at start, like `router_run`.** Tiers
167
+ mode no longer carries the unusable plan-tool schema; switching to roles needs a restart. `/router` help never
168
+ advertises an unregistered or user-defined `/plan`. OpenCode v1's tool, command and help maps are unchanged.
169
+ - **OpenCode v2: shorter serial integration entries.** Integration checks on the slot the queue has just rebased to the
170
+ candidate no longer reset it a second time (clean and HEAD check only, falling back to the full prepare on a HEAD
171
+ mismatch or provisioning drift), and the check-selection reads overlap the clean. Bisect probes, reruns, reverts and
172
+ phase suites keep the full prepare.
173
+ - **CPX e2e smoke: the G8 makespan bound is recorded, not asserted (owner amendment A-6.1-2).** The throughput run
174
+ still reconstructs and records makespan, CP_eff, W_auth/p, ΣI_service, the bound, the ratio and whether it was met;
175
+ service-evidence integrity and the 10,000 ms idle-with-ready ceiling stay asserted. Delegated grading observed as
176
+ `service-unattributed` is recognized verification evidence credited at zero intrinsic cost, so the computed bound is
177
+ conservative.
178
+ - **CPX e2e smoke: amended G8 intrinsic-service oracle (A-6.1-1).** The bound uses the pre-run DAG, authored work,
179
+ attributable verification/integration/phase-suite service and configured parallelism, with fail-closed evidence
180
+ checks and raw CP/integration diagnostics retained. Throughput uses the default integration batching; resilience
181
+ keeps singleton batches.
182
+ - **OpenCode v2: declared plan writers must produce a diff in every verification mode.** The owner's 2026-10-14
183
+ amendment to M39 makes a nonempty write footprint with no changes a counted `commit-failed` (`no changes`) for
184
+ `VERIFY:required`, `deferred` and `none`: bounded retries, then park, never silent `done`. No idempotent exception
185
+ is allowed. Empty-write no-change success and its phase-gate reconciliation are preserved.
186
+ - **OpenCode v2: per-turn router state moves out of the system prompt.** The pending-verification list, late
187
+ verification notices and the route hint are delivered in a per-turn `<router-state>` message appended after the
188
+ conversation, so the system prompt stays byte-stable across turns. Late notices are repeated every turn until
189
+ `router_verify` reads them. OpenCode v1 is unchanged.
190
+
191
+ ### Fixed
192
+
193
+ - **OpenCode v2: `/router` lists `/plan` only when `/plan` is registered and the executor can assemble.** That is roles
194
+ mode selected at start and still configured, no user-defined `/plan`, enforced leases, verification not `never` and a location inside
195
+ `routing.workRoots` when configured. Without a routing block, help remains byte-identical to the legacy output;
196
+ OpenCode v1 is unchanged.
197
+ - **OpenCode v2: a task blocked by a reverted dependency keeps its unsaved work.** The integration queue no longer
198
+ gives such a task's slot back to the pool unsaved. The work is first saved at the task's WIP ref (a failed save keeps
199
+ the slot leased). A running task's slot is released once, by the executor, after its cancelled child has ended.
200
+ - **OpenCode v2: recovered plan work keeps interrupted-attempt safety.** Re-provisioning saves an owned slot before
201
+ releasing or resetting it and retains unsaved-work holds on failure. Recovered budget ends wait for root-context
202
+ admission before resuming the same child; launcher-liveness evidence follows the current resume round. Abort drains
203
+ attachment verification before saving/releasing its slots, and collection waits for those pipelines too.
204
+ - **OpenCode v2: executor recovery no longer deadlocks when a task was verifying at restart.** Recovered
205
+ re-verification (and a finished child's completion) no longer blocks the recovery barrier: it waits for the owning
206
+ root's next router call, then runs. An adopt cuts the old attachment's graders, and a cut observation is no longer graded as a counted
207
+ `unverifiable` by the next attachment.
208
+ - **OpenCode v2: plan slots are claimed in launch-priority order.** A slot acquisition took its place in the pool's
209
+ queue only after its own `git rev-parse` returned, so the highest-priority task could claim the last slot and wait
210
+ behind every other slot's provisioning. Claims now queue in call order and await their base lookup inside the claim.
211
+ - **OpenCode v2: after a host restart, the executor requeues a plan child at once when its launching process is
212
+ provably gone.** It records each child's launcher (pid, hostname, per-process token); recovery treats a child as lost
213
+ without the 60 s liveness probation only when that process is dead on this host and the child was not running a tool
214
+ when the host stopped (host contract C16). A child stopped inside a tool, whose processes (for example a `router_run`
215
+ test run) can outlive the host, keeps the probation, as does every other case.
216
+ - **OpenCode v2: diagnostic observations record a scheduler graph row for every committed ledger batch**, including
217
+ metric-only batches, so a runtime row never reports a ledger sequence that no graph row preceded.
218
+ - **OpenCode v2: a plan-task verification that cannot snapshot its slot says why.** The unverifiable result now
219
+ includes a bounded, scrubbed reason (for example a git timeout or a missing file) naming the git stage that failed;
220
+ it still fails closed. A grader that cannot start, and each transient verification rerun, log their reason.
221
+ - **OpenCode v2: integration check selection never treats a failed `git show` as a missing file.** Only git's explicit
222
+ "path does not exist" error means absent; any other read failure fails the check as `prepare`, never a `no-checks`
223
+ pass. A failed prepare now waits for its overlapped reads before the slot is retried.
224
+ - **OpenCode v2: integration-check pytest uses the slot's virtual environment again.** Since the guarded-executable
225
+ change, pytest checks ran the host interpreter without the slot's environment. They again run the slot's provisioned
226
+ `.venv` interpreter with `VIRTUAL_ENV` set, the virtual environment first on `PATH` and `PYTHONPATH`/`PYTHONHOME`
227
+ unset, as `router_run` does; credentials stay stripped and `ComSpec` is the validated system shell on Windows. The
228
+ `.venv` interpreter is accepted only when it matches the slot's post-provisioning snapshot (path, size and
229
+ modification time), the same trust rule as `router_run`. Otherwise the absolute host interpreter outside the slot runs.
230
+ A file planted in the slot root is never selected. As in `router_run`, a slot without a detected Python manager gets
231
+ no virtual environment (and unsets `PYTHONPATH`, `PYTHONHOME` and `VIRTUAL_ENV`); only outside a registered slot do
232
+ the host's values pass through. The interpreter is resolved again from the configuration for every slot a command
233
+ runs in, never reused from another slot.
234
+ - **OpenCode v2: QA fix tasks get a launchable route line for any repository path.** A repository or phase root that
235
+ cannot be written safely into a route line (brackets, quotes, separators) is omitted, since the slot root is always
236
+ appended at launch; fix tasks stored by the earlier build with an unbracketed line launch as well.
237
+ - **OpenCode v2: the executor's default QA fix task route line is now a well-formed `[route ...]` line**, so a fix task created at runtime without a phase `FIX` template launches instead of failing route rendering.
238
+ - **OpenCode v2: service observations exclude process preparation, mark native grading without provider-attempt events as insufficient evidence, and attribute plan-task checks and grading to the checked candidate.**
239
+ - **OpenCode v2: the executor admits tasks to physical slots in critical-path priority order.** A lower-priority
240
+ task no longer takes the only free slot ahead of a higher-priority ready task, and a durable slot release reschedules
241
+ slot-blocked tasks at once instead of waiting for their retry backoff.
242
+ - **OpenCode v2: reused executor slots no longer launch dirty or at the wrong base after dependency provisioning.** An
243
+ acquisition whose reset ran an installer afterwards gives no reset proof, so the launch resets the slot again.
244
+ - **OpenCode v2: executor children adopted after a launch-confirmation timeout get their timing row**, exactly once,
245
+ without reviving the launch's settled completion effects.
246
+ - **OpenCode v2: executor launches reuse acquisition's verified reset at the current integration head, avoiding a duplicate reset while retaining full preparation for moved heads and unproven leases.**
247
+ - **OpenCode v2: the executor's idle-with-ready metric reports a duration exactly equal to its endpoints.**
248
+ - **CPX e2e G8 idle checks reconstruct maximal episodes from committed v2 observations.** Failed slot/launch
249
+ reservations no longer hide stalls by fragmenting ledger metrics. The unchanged 10,000 ms ceiling applies to
250
+ whole episodes; every ledger fragment must be covered, and missing seals, sequence gaps or dropped events fail
251
+ closed. The asserted G8 idle predicate, confirmed by the owner on 2026-10-14, is **A: durable ready work with
252
+ provider capacity**, so time spent waiting for a physical slot counts as idle. The physical-slot-blocked/launchable
253
+ split (predicate B) is diagnostic only and cannot shorten an asserted episode; the 10,000 ms bound has not been
254
+ relaxed. Per-host streams are retained before scratch cleanup, including incomplete failure/restart diagnostics.
255
+ - **CPX e2e smoke throughput checks follow the strict G8 contract:** provider delays and the independent CP/W
256
+ oracle use authored fixture milliseconds, makespan has no additive slack, and idle with ready work is capped at
257
+ 10,000 ms. By owner amendment (2026-10-14) the fixed 90 s per-host watchdog, which cannot hold a complete run
258
+ (measured serial integration alone is ~75–85 s), is replaced by one derived from the contract: a 60 s setup
259
+ watchdog, then 1.3 × max(CP, W/p, entries × 5 s) plus a 60 s audit margin, capped at 300 s per host. The
260
+ per-entry allowance only sizes the watchdog; the G8 assertion keeps the measured serial integration.
261
+ - **OpenCode v2: malformed shared lease registry entries no longer disable enforcement.** Entries are validated
262
+ individually; an invalid entry is refused without replacing it or disturbing valid registries. If the registry cannot
263
+ start with leases enforced, lease-checked file, search, git and run tools are refused instead of bypassing enforcement.
264
+ - **OpenCode v2: plan checks re-resolve inherited router commands for the prepared execution slot.** Phase suites,
265
+ base checks, bisect probes and revert regressions refresh the command executable, environment and authorization
266
+ against the checkout under test rather than reusing the integration worktree's resolution. Explicit working-directory
267
+ and environment overrides are preserved. Configured commands and commands with explicit `cwd` or `env` overrides
268
+ execute unchanged in full instead of being replaced by scoped runs; ordinary equivalent package-script test scoping
269
+ is retained.
270
+ - **OpenCode v2: plan phase bisects distinguish actual file-scoped checks from full-command fallbacks.** A full or
271
+ mixed run cannot establish isolated-file evidence. With a failing base and no valid isolation, a regression remains
272
+ unattributed instead of blaming the wrong task; a file-scoped bisect also stops unattributed if a historical probe
273
+ falls back to full commands. Genuine file-scoped bisects are preserved.
274
+ - **OpenCode v2: explicit plan-writer routes are checked against the selected role's edit grant.** Compilation uses
275
+ the resolved role policy, including configured permission narrowing, rather than class/tier heuristics. A writer
276
+ routed to a general role without an `edit` grant is rejected with a task and line diagnostic; valid edit-capable routes
277
+ remain accepted.
278
+ - **OpenCode v2: failed rebase cleanup preserves the initiating Git error.** Cleanup checks the slot's rebase state
279
+ before aborting and retains the original failure alongside any cleanup error. Integration refusals persist bounded
280
+ diagnostic details in the journal with URL credentials redacted from keys and string values before clipping, with
281
+ bounded traversal and output handling.
282
+ - **OpenCode v2: inferred plan writers no longer launch as read-only explorers.** Before role selection, explicit
283
+ or ownership-inferred write footprints reconcile automatically inferred read-only classes and add the `edit` need,
284
+ keeping the tier, pin, risk and existing needs. Incompatible authored read-only routes fail compilation with a task
285
+ and line diagnostic instead of being silently overridden. Manual/preflight/QA tasks and `Writes: none` are excluded;
286
+ explorer permissions are unchanged.
287
+ - **OpenCode v2: plan phase suites and base checks run in the CI slot at the commit under test, not the integration worktree's current head.**
288
+ - **OpenCode v2: plan phases no longer stall after a no-change completion.** Tasks that finish without a commit and
289
+ manual/preflight tasks reported done reconcile their phase gates and dependent phases, so QA launches without another
290
+ orchestrator turn.
291
+ - **OpenCode v2: work leases no longer collide across linked worktrees.** Two child sessions that edit the same
292
+ repo-relative path in two worktrees of one repository (`git worktree add`) are both allowed: an ordinary write lease
293
+ is keyed by its checkout, not by the repository, and a write whose target the router cannot read is refused only while
294
+ another child holds a lease in the same checkout. The leases of plan tasks stay repository-wide among plan tasks, so
295
+ two plan tasks that edit one path in two slots still refuse each other, and a plan child's write whose target the
296
+ router cannot read is checked against the plan-task leases in the whole repository. A path spelling that may name
297
+ any file (a device path, an 8.3 short name, a drive-relative path) still fails closed against every holder anywhere.
298
+ A refusal names the file under edit and asks for the requester's own path in `NEED MORE: lease` (repo-relative for a
299
+ plan task). Reads were already keyed by the file on disk. OpenCode v1 is unchanged.
300
+ - **OpenCode v2: plugin module copies share one process-wide lease registry.** Snapshot restoration is attempted only
301
+ once when the registry is created, even if the snapshot is missing or invalid, so a later location cannot overwrite
302
+ live leases by restoring again.
303
+ - **OpenCode v2: a resumed background dispatch delivers its own answer.** It no longer takes an earlier turn's
304
+ completion as its own result, even when the earlier turn was still being processed when the parent saw it, nor the
305
+ child's earlier answer. Completions are told apart by the message that carries them rather than by their text, so two
306
+ turns with the same answer each get one verdict; a dispatch whose child ended before its answer could be read is
307
+ read again on the parent's next request instead of waiting for the 6 h sweep. Known limit: the set of completions
308
+ already taken lives in memory, so a resume right after a plugin restart can still mis-attribute.
309
+ - **OpenCode v2: background dispatches without a deterministic check are graded.** Their grader launches as the
310
+ orchestrator agent that made the call, also after a restart, never from a role child's context (which denies
311
+ `subagent`); an entry journaled by an older build falls back to the parent session's current agent and its latest
312
+ assistant message (looked up for at most 2 s, and not for a completion that did not succeed), and a result that
313
+ could not be verified is tagged `UNVERIFIABLE` instead of `PASS`. Acceptance is unchanged. OpenCode v1 is unchanged.
314
+ - **OpenCode v2: one plugin copy per process decides each background call.** Call claims are process-wide across the
315
+ plugin copies a host loads per location (bounded to 8000 claims in all, the oldest of any copy evicted first): a
316
+ call that reaches several copies is completed once, and the claiming copy's background decision stands. A copy that
317
+ lost the claim leaves the call's `background` flag as it found it and does not tell the orchestrator the result is
318
+ unverified. OpenCode v1 is unchanged.
319
+ - **OpenCode v2: an unrecorded child session never backgrounds a dispatch.** A child the plugin never recorded (after a
320
+ reload, or past the 1000-entry bound) no longer counts as a root parent in the background decision (root parents
321
+ only): its kind comes from the role decision's session read or from the host, and a failed lookup keeps the
322
+ foreground value. OpenCode v1 is unchanged.
323
+ - **OpenCode v2: background-first runs write `turns.jsonl` rows.** The end of a root session's run now closes its
324
+ orchestrator turn, so the kickoff and each wake-up (runs that no user prompt starts) get one row each, even while a
325
+ background dispatch is still open. OpenCode v1 is unchanged.
326
+ - **Role prompts: the dispatch's work root wins over the host's environment block.** The work-root rule of every role
327
+ prompt now says that the router's `Working directory:` line and the work root in the dispatch's ENVIRONMENT win over
328
+ the working directory in the host's environment block (role children get the task without the route line), so a role
329
+ no longer refuses its work root because the host named the parent's directory.
330
+ - **OpenCode v2: a second booted location no longer settles another location's running dispatch as `lost in
331
+ restart`.** When one host process loads a router instance per location, each instance now keeps a beat file in
332
+ `pending.instances` next to `pending.claims` while it holds a session claim. A new instance refuses to adopt a
333
+ session whose claim belongs to a live sibling instance, so that instance's records stay dormant and its verdict is
334
+ the only one delivered. A dead owner (stale beat, or dead pid) is still recovered as before. Journal and claim
335
+ records written by earlier builds read as before. OpenCode v1 is unchanged.
336
+ - **OpenCode v2: no start-up reference GC in a location outside `routing.workRoots`.** When `routing.workRoots` is
337
+ configured and non-empty, an instance loaded in a directory outside every entry skips the start-up reference GC and
338
+ logs one info line naming the skip. Role agent registration in roles mode still lists the repository's worktrees
339
+ there (`git worktree list`, read-only), so a `routing.workRoots` glob meant for later-created worktrees does not drop
340
+ the existing ones from the role agents' `external_directory` rules. With executor enforcement enabled, role agents
341
+ still deny the executor home there when worktrees were listed or their listing failed, and get no executor slots-root
342
+ allowance. The location check uses the documented
343
+ glob semantics (`*` crosses separators, as in the role agents' rules) and compares canonical paths. Without
344
+ `routing.workRoots` nothing changes. OpenCode v1 is unchanged.
345
+ - **OpenCode v2: `router_verify` on a held background handle reports the verdict its gate reached** (method, outcome,
346
+ reasons, caveats and notes). It used to settle every held gate verdict as a deterministic result with no caveats, so
347
+ a checker that could not verify showed "UNVERIFIED: deterministic" without the grader's reason and a pass with
348
+ caveats showed "✓ verified". The stored pass/outcome always match the posted tag (a trivial dispatch the gate accepts
349
+ unverified reads pass, a pass that `strictUnverifiable` rejects reads fail, also when re-posted after a restart). The
350
+ posted verdict is unchanged. OpenCode v1 is unchanged.
351
+ - **OpenCode v2: plugin copies loaded per booted location share the pending journal safely.** A fresh writer mark of
352
+ the same process under another module token counts as a live writer (start-up compaction is skipped), each copy
353
+ compacts through its own temp file, and a recreate merges the records of every copy. Beat files in
354
+ `pending.instances` are written atomically, a half-written beat counts as live while its modification time is
355
+ fresh, and stale beats are swept at start. When the host evicts a location while its child still runs, the adopting
356
+ instance keeps that dispatch dormant until its end event instead of reporting it `lost in restart`.
357
+ - **OpenCode v2: the background decision's parent lookup is bounded.** An unrecorded parent is looked up at most once
358
+ and for at most 1 s; on timeout the dispatch stays in the foreground.
359
+ - **OpenCode v2: plugin copies loaded per host location share one timing recorder.** When one host process loads the
360
+ plugin once per location, `turns.jsonl` no longer gets repeated rows and its turn numbers no longer restart, and the
361
+ `/router stats` orchestrator cache-read share is no longer over-counted. The recorder is shared per directory across
362
+ the copies of one build; a recorder registered by a build with another registry version is left alone. OpenCode v1 is
363
+ unchanged.
364
+ - **Plan executor: a child adopted after a restart no longer writes into a released slot.** When its task is blocked by
365
+ a reverted dependency or the plan is aborted, the child is interrupted and awaited before its slot is saved and
366
+ released. If it cannot be stopped, the slot stays held with one blocking inbox item.
367
+
368
+ ### Security
369
+
370
+ - **OpenCode v2: executor check discovery uses absolute, guarded executables.** Git searches use hardened arguments
371
+ and environment; pytest resolves its interpreter outside guarded checkouts, or takes the slot's provisioned
372
+ virtual-environment interpreter as `router_run` does. Both use a credential-stripped run
373
+ environment with explicit full-environment replacement and Windows current-directory search protection, so process
374
+ inheritance cannot restore provider credentials. Other process callers retain their default environment merging.
375
+ - **OpenCode v2 (v1 unchanged): an unbound plan child is refused every tool call.** A child session whose first message
376
+ is a plan launcher prompt (`PLAN CONTEXT` followed by the launch header at its grammar position) but that has no
377
+ matching plan binding is refused every tool call (fail closed). The prompt is recognized at the start of the message
378
+ or right after the one preamble line the host puts before a subagent's first message ("You are a subagent spawned by
379
+ another session."); any other leading text makes it an ordinary prompt. Parallel tool calls of such a session all
380
+ wait for the same check, and an ordinary prompt is never refused, even when the session's kind cannot be looked up.
381
+
10
382
  ## [2.8.0] - 2026-10-13
11
383
 
12
384
  ### Added
package/README.md CHANGED
@@ -466,8 +466,8 @@ The plugin ships with six presets (switch with `/preset <name>`):
466
466
  | Tier | Model | Cost ratio |
467
467
  |------|-------|-----------|
468
468
  | @fast | `anthropic/claude-haiku-5-5` (variant/effort: medium) | 1x |
469
- | @medium | `openai/gpt-6.1-sol-fast` (xhigh) | 5x |
470
- | @heavy | `anthropic/claude-opus-5-5` (variant/effort: xhigh) | 20x |
469
+ | @medium | `openai/gpt-6.1-sol-fast` (high) | 5x |
470
+ | @heavy | `anthropic/claude-opus-5-5` (variant/effort: high) | 20x |
471
471
 
472
472
  > **Removed in 2.6.0:** the bundled `hybrid-2` and `fable-effort` presets, and the
473
473
  > previous `hybrid` values (OpenAI `gpt-6-luna-fast` / `gpt-6-astra-fast` for `@fast` / `@medium`).
@@ -1232,6 +1232,26 @@ With `routing.delegation: "roles"` the orchestrator stops picking tiers: it disp
1232
1232
 
1233
1233
  Put `{ "routing": { "delegation": "roles" } }` in the global override file and **restart OpenCode** (roles mode is decided at plugin start); restore the previous file and restart to go back. OpenCode v1 keeps the tier model. Guide: [`docs/ROLES.md`](docs/ROLES.md); decision record: [`docs/adr/0006-role-tier-assurance-delegation.md`](docs/adr/0006-role-tier-assurance-delegation.md).
1234
1234
 
1235
+ ## Executing plans
1236
+
1237
+ On **OpenCode v2 in roles mode selected at start**, `/plan run <path>` asks the orchestrator to compile a Markdown plan into a durable task ledger and
1238
+ dependency graph through `router_plan`. It shows the task count, critical path, expected makespan and manual tasks.
1239
+ With the default `routing.executor.approve: "ask"`, compilation **does not start work**: review the summary, then use
1240
+ `/plan approve <planId>` or explicitly approve that plan after seeing its summary. A request to run it is not approval;
1241
+ the model never approves on its own. Global `approve: "auto"` is an explicit opt-in.
1242
+
1243
+ Ready tasks run in parallel in isolated git worktree slots, are verified there, then integrate serially through checks.
1244
+ `/plan status [planId]` shows progress, inbox and metrics; `/plan inbox` lists decisions and `/plan answer <id> <text>`
1245
+ answers one. Use `/plan pause <planId>` to stop new launches, `/plan resume <planId>` to continue, and `/plan land <planId>`
1246
+ to request fast-forward landing into a clean checkout. The ledger survives a restart; it is not conversation state.
1247
+
1248
+ The executor requires roles mode selected at start, enforced leases, a git repository and an available plan-task
1249
+ verifier (`enforcement.verify.require` must not be `"never"`). OpenCode v1 registers no executor tool or command.
1250
+ `router_plan` and `/plan` are registered only in roles mode at start, like `router_run`; tiers mode registers neither.
1251
+ See [the executor guide](docs/EXECUTOR.md) for setup, every command/action/config key, the safety model, Windows notes,
1252
+ recovery, troubleshooting, metrics and the owner checklist; [ADR 0007](docs/adr/0007-critical-path-execution.md) records
1253
+ the decisions. `/annotate-plan` below only annotates a plan; it does not execute it.
1254
+
1235
1255
  ## TUI status (OpenCode v2)
1236
1256
 
1237
1257
  On OpenCode v2 (2.0.24 or later) the package also ships a TUI entry, `tui.ts`, that shows which model and effort the router's sessions run with:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-model-router",
3
- "version": "2.8.0",
3
+ "version": "2.9.1",
4
4
  "description": "OpenCode plugin that routes tasks to tiered subagents (fast/medium/heavy) based on complexity",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -15,7 +15,11 @@
15
15
  "smoke:routing": "cross-env RUN_OC_SMOKE_ROUTING=1 vitest run --config vitest.smoke.config.ts test/smoke/routing-engine.smoke.test.ts",
16
16
  "smoke:v2:e2e": "cross-env RUN_OC_SMOKE_V2_E2E=1 vitest run --config vitest.smoke.config.ts test/smoke/v2-provider-e2e.smoke.test.ts",
17
17
  "smoke:tui": "cross-env RUN_OC_SMOKE_TUI=1 vitest run --config vitest.smoke.config.ts test/smoke/tui-status.smoke.test.ts",
18
+ "smoke:cpx": "cross-env RUN_OC_SMOKE_CPX=1 vitest run --config vitest.smoke.config.ts test/smoke/helpers/cpx-scripted-provider test/smoke/helpers/routing-host test/smoke/cpx-host-contract test/smoke/cpx-cache-prefix test/smoke/cpx-background",
19
+ "smoke:cpx:provision": "cross-env RUN_OC_SMOKE_CPX=1 vitest run --config vitest.smoke.config.ts test/smoke/cpx-provision",
20
+ "smoke:cpx:e2e": "cross-env RUN_OC_SMOKE_CPX=1 vitest run --config vitest.smoke.config.ts test/smoke/cpx-e2e",
18
21
  "routing:stats": "node scripts/routing-stats.ts",
22
+ "soak:analyze": "node scripts/soak-analyze.mjs",
19
23
  "typecheck": "tsc --noEmit"
20
24
  },
21
25
  "license": "GPL-3.0-only",
@@ -239,7 +239,10 @@ export const ROUTER_APPROVAL_HELP_LINES: readonly string[] = Object.freeze([
239
239
  ]);
240
240
 
241
241
  /** Bare `/router`. */
242
- export function buildRouterHelp(current: string, options: { stats?: boolean; roles?: Iterable<RoleSpec>; approvals?: boolean } = {}): string {
242
+ export function buildRouterHelp(
243
+ current: string,
244
+ options: { stats?: boolean; roles?: Iterable<RoleSpec>; approvals?: boolean; plan?: boolean } = {},
245
+ ): string {
243
246
  const roleLines = options.roles === undefined ? [] : buildRoleLines(options.roles);
244
247
  return [
245
248
  `# Model Router`,
@@ -254,10 +257,29 @@ export function buildRouterHelp(current: string, options: { stats?: boolean; rol
254
257
  : []),
255
258
  ...(options.approvals === true ? ROUTER_APPROVAL_HELP_LINES : []),
256
259
  "- `/tiers`, `/preset`, `/budget`, `/bypass`, `/annotate-plan`",
260
+ ...(options.plan === true ? ["", ...PLAN_HELP_LINES] : []),
257
261
  ...(roleLines.length > 0 ? ["", ...roleLines] : []),
258
262
  ].join("\n");
259
263
  }
260
264
 
265
+ /** `/plan` usage lines (v2 only): appended to `/router` help when `plan` is set and printed for an unknown `/plan` subcommand. */
266
+ export const PLAN_HELP_LINES: readonly string[] = [
267
+ "Plan executor (`/plan`):",
268
+ "- `/plan run <path> [--phases <id,id,...>] [--done-before <id>]` — compile a plan file (path absolute, or relative to the project directory) and show its summary; it does not start until approved",
269
+ "- `/plan approve <planId>` — approve a compiled plan and start it (not needed with `executor.approve: \"auto\"`)",
270
+ "- `/plan status [planId]` — show plan progress",
271
+ "- `/plan inbox [--plan <planId>]` — show the questions waiting for an answer",
272
+ "- `/plan answer [--plan <planId>] <id> <text>` — answer an inbox question (without `--plan`: this session's running plan)",
273
+ "- `/plan pause|resume|abort <planId>` — pause, resume or abort a plan",
274
+ "- `/plan land <planId>` — land a finished plan",
275
+ "- `/plan adopt <planId>` — adopt a plan whose owning session is gone",
276
+ ];
277
+
278
+ /** `/plan` with no or an unknown subcommand. */
279
+ export function buildPlanHelp(): string {
280
+ return ["# Plan executor", "", ...PLAN_HELP_LINES].join("\n");
281
+ }
282
+
261
283
  /**
262
284
  * `/router models [provider]`. Takes the catalog the caller fetched, so a
263
285
  * failed or unavailable fetch is a null here rather than an exception path.