opencode-model-router 1.14.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 CHANGED
@@ -5,6 +5,121 @@ 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
+
8
123
  ## [1.14.0] - 2026-09-26
9
124
 
10
125
  Test baselines could saturate every core on a machine running several delegations: a
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**: every non-trivial delegation is verified and any genuine failure surfaces a forcing-note, but nothing is ever hard-blocked (the DoD/acceptance section adds 1,219 characters to the orchestrator system prompt, roughly 305–340 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"`.
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 always verified. See [docs/VERIFICATION.md](docs/VERIFICATION.md).
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 5,229 characters when the 1,219-character DoD/enforcement section is enabled. That is roughly 810–1,450 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.
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.14.0",
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
  }