opencode-model-router 1.13.0 → 1.15.0
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.
- package/CHANGELOG.md +154 -0
- package/README.md +3 -3
- package/package.json +2 -1
- package/src/index.ts +377 -58
- package/src/router/config.ts +211 -12
- package/src/router/protocol.ts +11 -2
- package/src/verify/baseline.ts +143 -25
- package/src/verify/batch.ts +2226 -0
- package/src/verify/deterministic.ts +1378 -20
- package/src/verify/directives.ts +207 -0
- package/src/verify/dispatch.ts +387 -86
- package/src/verify/exec.ts +711 -0
- package/src/verify/pending.ts +1834 -0
- package/src/verify/reference.ts +2117 -0
- package/src/verify/risk.ts +271 -0
- package/src/verify/runner.ts +5315 -0
- package/src/verify/slot.ts +1603 -0
- package/src/verify/tree.ts +215 -11
- package/src/verify/types.ts +301 -4
- package/src/verify/wiring.ts +1884 -73
- package/tiers.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,160 @@ All notable changes to this project are documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.15.0] - 2026-09-28
|
|
9
|
+
|
|
10
|
+
The acceptance gate no longer runs a test suite per delegation. `testsPass` now runs only
|
|
11
|
+
the tests affected by the producer's changes, and the dispatch-time baseline is replaced
|
|
12
|
+
by a git reference captured in well under a second. **By default, delegations are no
|
|
13
|
+
longer verified unless the orchestrator asks for it**, either with `VERIFY:required` on
|
|
14
|
+
the dispatch or with a `router_verify` call on the returned handle, or unless
|
|
15
|
+
`enforcement.verify.background` is enabled. A deferred delegation is marked unverified,
|
|
16
|
+
carries a risk signal and stays in a pending list until it is checked. The full suite is
|
|
17
|
+
CI's job. See `docs/adr/0003-affected-test-verification.md`.
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- **New `enforcement.verify` keys.** These are `testScope` (`"affected"`, or `"full"`
|
|
22
|
+
as the explicit opt-in), `maxWorkers` (default 2), `lowPriority` (default `true`),
|
|
23
|
+
`maxConcurrentVerifications` (default `max(1, floor(cores / 8))`), `defaultVerify`
|
|
24
|
+
(default `"deferred"`), `captureWaitMs` (default 5 s, never more than
|
|
25
|
+
`baselineTimeoutMs`), `background` (default `false`), `pendingTtlMs` (default 1 h),
|
|
26
|
+
`slotWaitMs` (default 60 s), `batchWindowMs` (default 2 s), `failureRecheck` (default
|
|
27
|
+
`true`) and `recheckTimeoutMs` (default 60 s). See `docs/CONFIG_REFERENCE.md`.
|
|
28
|
+
|
|
29
|
+
- **`VERIFY:` and `VERIFY_WAIT:` dispatch directives.** `VERIFY:required` gates a
|
|
30
|
+
delegation synchronously and keeps the escalation ladder. `VERIFY:deferred`, the
|
|
31
|
+
default, returns at once. `VERIFY_WAIT:<n>s` sets how long the dispatch waits for the
|
|
32
|
+
reference capture before the producer starts. It never blocks beyond that.
|
|
33
|
+
|
|
34
|
+
- **`router_verify` tool.** A deferred delegation returns a `vrf_…` handle together with
|
|
35
|
+
an "unverified" disclaimer and a deterministic risk signal. `router_verify` runs the
|
|
36
|
+
verification for that handle on demand, within a deadline, and returns the verdict.
|
|
37
|
+
|
|
38
|
+
- **Pending list.** Unverified delegations are listed in the prompt until they are
|
|
39
|
+
verified or their handle expires (`pendingTtlMs`), so the orchestrator can see what it
|
|
40
|
+
is building on.
|
|
41
|
+
|
|
42
|
+
- **Opt-in background verification.** With `background: true`, deferred verifications
|
|
43
|
+
also run in the background through the verification slot at low priority, and failures
|
|
44
|
+
reach the orchestrator as late notices. It is off by default, so no CPU is spent on
|
|
45
|
+
verdicts nobody asked for.
|
|
46
|
+
|
|
47
|
+
- **pytest support.** `testsPass` scopes pytest runs by module mapping, and `pytest` and
|
|
48
|
+
`uv run pytest` are allowlisted. A green pytest scope passes. A failing one is always
|
|
49
|
+
`unverifiable`, because an editable install imports the live tree, which makes the
|
|
50
|
+
reference rerun impossible.
|
|
51
|
+
|
|
52
|
+
### Changed
|
|
53
|
+
|
|
54
|
+
- **Gate labels say what was verified.** A result the gate let through without verifying it
|
|
55
|
+
(unverifiable: gate timeout, slot busy, budget exhausted, no reference; or a pass carrying a
|
|
56
|
+
caveat) is headed `[router ⚠ UNVERIFIED: <method>]` above its `Verification caveats — NOT
|
|
57
|
+
verified` list, instead of `[router ✓ accepted: …]` (plan G2, QA-3.1-21). A clean pass,
|
|
58
|
+
which used to add no text on a native `Task()`, now ends with `[router ✓ verified: <method>]`,
|
|
59
|
+
and a pass with notes uses the same label (QA-3.1-18). Accept/reject policy is unchanged.
|
|
60
|
+
- **`testsPass` runs only the affected tests.** The runner adapter builds the command
|
|
61
|
+
(`vitest related`, `jest --findRelatedTests`, pytest module mapping) and spawns it
|
|
62
|
+
without a shell. When scoped tests fail, only those test files are rerun in an
|
|
63
|
+
ephemeral worktree at the dispatch reference. Failures that also fail there were
|
|
64
|
+
already present, so they are excused with a note rather than blamed on the producer.
|
|
65
|
+
The router never falls back to a full suite: when scoping is impossible (an unknown
|
|
66
|
+
runner, a composite script, a config-file change) the result is `unverifiable` with a
|
|
67
|
+
caveat, which is accepted unless `strictUnverifiable` is set.
|
|
68
|
+
|
|
69
|
+
- **Deferred verification is the default.** A delegation with no `VERIFY:` directive
|
|
70
|
+
returns immediately as unverified. The synchronous cost is up to `VERIFY_WAIT`
|
|
71
|
+
(default `captureWaitMs`, 5 s) at dispatch for the reference capture, paid in either
|
|
72
|
+
mode, plus at most 2 s at return for the git-only snapshot of the producer's changes
|
|
73
|
+
(measured at about 0.4–0.5 s).
|
|
74
|
+
|
|
75
|
+
- **`enforcement.verify.baselineTimeoutMs` now bounds the git-only reference capture.**
|
|
76
|
+
It used to bound the dispatch-time baseline test run. Its default changed from 60 s to
|
|
77
|
+
15 s.
|
|
78
|
+
|
|
79
|
+
- **The bundled `tiers.json` no longer sets `gateBudgetMs`.** The key is still supported;
|
|
80
|
+
its in-code default of 90 s (90000 ms) applies.
|
|
81
|
+
|
|
82
|
+
- **Verification runs at low priority, through a machine-wide slot, in batches.**
|
|
83
|
+
Commands run at below-normal OS priority with the runner's worker cap. A cross-process
|
|
84
|
+
semaphore in the OS temp directory limits concurrent verifications across every
|
|
85
|
+
opencode process on the machine. Requests for the same runner root that arrive within
|
|
86
|
+
`batchWindowMs` are merged into one scoped run, and failures are attributed back to
|
|
87
|
+
each request.
|
|
88
|
+
|
|
89
|
+
- **Deprecations.** `enforcement.verify.testBaseline` is deprecated in favour of
|
|
90
|
+
`failureRecheck`. Any value logs a once-per-process warning, and `testBaseline: false`
|
|
91
|
+
still turns the recheck off.
|
|
92
|
+
|
|
93
|
+
### Fixed
|
|
94
|
+
|
|
95
|
+
- **A gate that runs out of budget now kills the verification process tree.** The gate
|
|
96
|
+
budget's abort signal reaches the running command instead of abandoning it.
|
|
97
|
+
|
|
98
|
+
- **The native `task` path's required gate has a budget.** `accept(…)` there was not
|
|
99
|
+
wrapped in a timeout, so a slow check could hold the `task` result indefinitely. It is
|
|
100
|
+
now bounded by `gateBudgetMs`, like the `delegate` path.
|
|
101
|
+
|
|
102
|
+
- **pytest: a changed module no longer passes as "no affected tests".** A changed module
|
|
103
|
+
used to map only to test files named after it (`test_<stem>.py`, `<stem>_test.py`), so
|
|
104
|
+
a test such as `tests/test_mod02_1.py` that imports it was never run. It now maps to
|
|
105
|
+
the test files that name its stem as a whole word (`git grep -F -w`, which matches
|
|
106
|
+
every import spelling), plus the name-matched tests. When no test maps, or a
|
|
107
|
+
`conftest.py` names the module, the check is `unverifiable` (`unmapped-module`), never
|
|
108
|
+
a pass. When `testpaths` decides the collection, only tests under it are inputs.
|
|
109
|
+
Residual: only direct importers run. A test that reaches the module through another
|
|
110
|
+
source module or a dynamic import is not run, and a change to non-`.py` files alone
|
|
111
|
+
(for example a data file a module reads) still gives "no affected tests".
|
|
112
|
+
|
|
113
|
+
- **An unknown tool during the dispatch capture no longer seeds the baseline.** Only
|
|
114
|
+
tools known not to write (read, glob, grep, list, ls, codesearch, webfetch, websearch,
|
|
115
|
+
lsp, todoread, todowrite, question, skill, plan_enter, plan_exit, invalid, task, the MCP
|
|
116
|
+
resource readers, delegate and router_verify) leave an in-flight snapshot or capture
|
|
117
|
+
alone. Any other tool, MCP and custom tools included, that runs in that window makes
|
|
118
|
+
the dispatch's change set unavailable and its reference none, so that dispatch is
|
|
119
|
+
`unverifiable` instead of a possible clean pass. Residual: a write with no tool event
|
|
120
|
+
(an external editor, an MCP server writing after its call returned), or a tool that
|
|
121
|
+
writes under a non-writing name, is not seen.
|
|
122
|
+
|
|
123
|
+
## [1.14.0] - 2026-09-26
|
|
124
|
+
|
|
125
|
+
Test baselines could saturate every core on a machine running several delegations: a
|
|
126
|
+
full test suite was started on every dispatch, and on Windows a timed-out suite kept
|
|
127
|
+
running as orphaned workers after the router had given up on it.
|
|
128
|
+
|
|
129
|
+
### Changed
|
|
130
|
+
|
|
131
|
+
- **The bundled `anthropic` preset moves heavy to Opus 5.5 and lowers medium's
|
|
132
|
+
effort.** `heavy` is now `anthropic/claude-opus-5-5` at `xhigh` effort (was
|
|
133
|
+
`anthropic/claude-fable-5-1` at `max`), and `medium` stays on Opus 5.5 with
|
|
134
|
+
`effort`/`variant` `low` (was `high`). Tier descriptions state the new settings.
|
|
135
|
+
Presets overridden in `opencode-model-router.overrides.jsonc` are unaffected.
|
|
136
|
+
|
|
137
|
+
### Fixed
|
|
138
|
+
|
|
139
|
+
- **A timed-out or aborted test baseline no longer leaves the suite running.**
|
|
140
|
+
Verification commands ran through `child_process.exec`, whose `timeout` and
|
|
141
|
+
`signal` only kill the shell it spawned. A test command is a process tree
|
|
142
|
+
(`cmd /c npm test` → npm → vitest → one worker per core), so on Windows the
|
|
143
|
+
60-second baseline budget expired, the shell died, and every worker kept running
|
|
144
|
+
until the suite finished on its own. Commands now run through a helper that kills
|
|
145
|
+
the whole tree on timeout or abort: `taskkill /T /F` on Windows, the process group
|
|
146
|
+
on POSIX. This also covers `testsPass`, `buildPasses`, `lintClean` and `run`
|
|
147
|
+
checks.
|
|
148
|
+
|
|
149
|
+
- **Read-only dispatches no longer run the test suite.** Every `task` or `delegate`
|
|
150
|
+
dispatch started a baseline capture of the default test command to warm the cache,
|
|
151
|
+
including exploration fan-outs that are never judged by `testsPass`. Those captures
|
|
152
|
+
were almost always discarded, because any shell or edit tool in the directory
|
|
153
|
+
contaminates them, so each dispatch paid for a full suite and gained nothing. A
|
|
154
|
+
baseline is now captured only when the dispatch's DoD carries a `testsPass` check.
|
|
155
|
+
|
|
156
|
+
- **At most one baseline capture runs per directory and command.** Captures are
|
|
157
|
+
cached by tree fingerprint, which changes with every edit, so dispatches landing
|
|
158
|
+
while a suite was already running each started another. A dispatch that finds a
|
|
159
|
+
capture in flight for the same directory and command now gets no baseline — the
|
|
160
|
+
same `unverifiable` outcome as a contaminated capture — instead of a second suite.
|
|
161
|
+
|
|
8
162
|
## [1.13.0] - 2026-09-24
|
|
9
163
|
|
|
10
164
|
A forced delegation of a request that carries no task produced a `task` call with no
|
package/README.md
CHANGED
|
@@ -873,12 +873,12 @@ Defines provider fallback order when a delegated task fails:
|
|
|
873
873
|
|
|
874
874
|
## Delegation enforcement (advisory by default)
|
|
875
875
|
|
|
876
|
-
The read-only cap banners described above are advisory: a well-behaved subagent will respect them, but nothing prevents a model from making one more read after the `[⚠ CAP REACHED]` banner. The **enforcement layer** turns delegation into a produce → verify → accept/escalate loop with independent acceptance and quality escalation. As of v1.3.0 it runs in **`advisory` mode by default**:
|
|
876
|
+
The read-only cap banners described above are advisory: a well-behaved subagent will respect them, but nothing prevents a model from making one more read after the `[⚠ CAP REACHED]` banner. The **enforcement layer** turns delegation into a produce → verify → accept/escalate loop with independent acceptance and quality escalation. As of v1.3.0 it runs in **`advisory` mode by default**: non-trivial delegations are verified and any genuine failure surfaces a forcing-note, except that a DoD with `testsPass` is deferred by default and returns unverified with a `vrf_` handle until you call `router_verify`, use `VERIFY:required` or enable background verification; nothing is ever hard-blocked (the DoD/acceptance section adds 2,200 characters to the orchestrator system prompt, roughly 550–612 tokens at 3.6–4.0 characters per token, and subagents may receive non-blocking guard banners). Unavailable verification is accepted with explicit caveats by default; `enforcement.verify.strictUnverifiable: true` restores rejection without producer escalation. Set `"mode": "off"` — or run `/router enforce off` — to restore byte-for-byte-unchanged routing with zero added prompt tokens and zero new latency. Hard-blocks only activate in `"mode": "enforced"`.
|
|
877
877
|
|
|
878
878
|
### The three enforcement layers
|
|
879
879
|
|
|
880
880
|
- **Layer 1 — hard-block guard.** A `tool.execute.before` hook throws before a disallowed tool call executes, stopping budget overruns, redundant reads, and throwaway-script sidesteps in subagent sessions.
|
|
881
|
-
- **Layer 2 — independent acceptance gate.** A non-trivial delegation carries a Definition-of-Done (DoD) that is checked — deterministically or by an independent grader at ≥ the producer's tier — before the result is trusted. The producer never grades its own output. Two cases are skipped rather than checked: a trivial dispatch carrying only an inferred DoD, and a dispatch whose inferred DoD has no deterministic checks and which changed no files. An explicit `[acceptance]` block is
|
|
881
|
+
- **Layer 2 — independent acceptance gate.** A non-trivial delegation carries a Definition-of-Done (DoD) that is checked — deterministically or by an independent grader at ≥ the producer's tier — before the result is trusted. The producer never grades its own output. Two cases are skipped rather than checked: a trivial dispatch carrying only an inferred DoD, and a dispatch whose inferred DoD has no deterministic checks and which changed no files. An explicit `[acceptance]` block is verified, but one with `testsPass` is deferred by default as a whole: its build, lint, `run` and criteria checks are deferred too, even when the producer changed nothing. A block without `testsPass` is gated before return (see [Deferred verification](docs/CONFIG_REFERENCE.md#deferred-verification)). See [docs/VERIFICATION.md](docs/VERIFICATION.md).
|
|
882
882
|
- **Layer 3 — quality-escalation ladder.** On a failed check: retry once, then escalate fast → medium → heavy, bounded by attempt and cost ceilings. The loop ends in an honest `status: unmet` rather than a fabricated pass.
|
|
883
883
|
|
|
884
884
|
### Two operating modes
|
|
@@ -995,7 +995,7 @@ After `/annotate-plan`:
|
|
|
995
995
|
|
|
996
996
|
## Token overhead
|
|
997
997
|
|
|
998
|
-
Measured with the bundled Anthropic preset in normal mode (the shipped `activePreset`/`activeMode` defaults), the routing protocol is 3,238 characters for a non-Claude orchestrator. A Claude orchestrator receives 4,010 characters after its authority prefix, or
|
|
998
|
+
Measured with the bundled Anthropic preset in normal mode (the shipped `activePreset`/`activeMode` defaults), the routing protocol is 3,238 characters for a non-Claude orchestrator. A Claude orchestrator receives 4,010 characters after its authority prefix, or 6,210 characters when the 2,200-character DoD/enforcement section is enabled. That is roughly 810–1,725 tokens across the three paths at 3.6–4.0 characters per token. The optional anti-narration clause adds another 650 characters to the Claude path.
|
|
999
999
|
|
|
1000
1000
|
These are character counts of the prompts the shipped config actually produces, so they move whenever the protocol text does. `test/unit/docs-drift.test.ts` recomputes all three from `tiers.json` on every run and fails unless this section still quotes them, so a change that grows the protocol cannot land without updating these numbers.
|
|
1001
1001
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-model-router",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.0",
|
|
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",
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"@types/node": "^26.2.0",
|
|
53
53
|
"@vitest/coverage-v8": "^4.1.8",
|
|
54
54
|
"cross-env": "^10.1.0",
|
|
55
|
+
"istanbul-lib-coverage": "^3.2.2",
|
|
55
56
|
"typescript": "^7.0.2",
|
|
56
57
|
"vitest": "^4.1.8"
|
|
57
58
|
}
|