opencode-model-router 1.13.0 → 1.14.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 +39 -0
- package/package.json +1 -1
- package/src/verify/dispatch.ts +6 -2
- package/src/verify/exec.ts +92 -0
- package/src/verify/wiring.ts +11 -30
- package/tiers.json +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,45 @@ 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.14.0] - 2026-09-26
|
|
9
|
+
|
|
10
|
+
Test baselines could saturate every core on a machine running several delegations: a
|
|
11
|
+
full test suite was started on every dispatch, and on Windows a timed-out suite kept
|
|
12
|
+
running as orphaned workers after the router had given up on it.
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- **The bundled `anthropic` preset moves heavy to Opus 5.5 and lowers medium's
|
|
17
|
+
effort.** `heavy` is now `anthropic/claude-opus-5-5` at `xhigh` effort (was
|
|
18
|
+
`anthropic/claude-fable-5-1` at `max`), and `medium` stays on Opus 5.5 with
|
|
19
|
+
`effort`/`variant` `low` (was `high`). Tier descriptions state the new settings.
|
|
20
|
+
Presets overridden in `opencode-model-router.overrides.jsonc` are unaffected.
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
|
|
24
|
+
- **A timed-out or aborted test baseline no longer leaves the suite running.**
|
|
25
|
+
Verification commands ran through `child_process.exec`, whose `timeout` and
|
|
26
|
+
`signal` only kill the shell it spawned. A test command is a process tree
|
|
27
|
+
(`cmd /c npm test` → npm → vitest → one worker per core), so on Windows the
|
|
28
|
+
60-second baseline budget expired, the shell died, and every worker kept running
|
|
29
|
+
until the suite finished on its own. Commands now run through a helper that kills
|
|
30
|
+
the whole tree on timeout or abort: `taskkill /T /F` on Windows, the process group
|
|
31
|
+
on POSIX. This also covers `testsPass`, `buildPasses`, `lintClean` and `run`
|
|
32
|
+
checks.
|
|
33
|
+
|
|
34
|
+
- **Read-only dispatches no longer run the test suite.** Every `task` or `delegate`
|
|
35
|
+
dispatch started a baseline capture of the default test command to warm the cache,
|
|
36
|
+
including exploration fan-outs that are never judged by `testsPass`. Those captures
|
|
37
|
+
were almost always discarded, because any shell or edit tool in the directory
|
|
38
|
+
contaminates them, so each dispatch paid for a full suite and gained nothing. A
|
|
39
|
+
baseline is now captured only when the dispatch's DoD carries a `testsPass` check.
|
|
40
|
+
|
|
41
|
+
- **At most one baseline capture runs per directory and command.** Captures are
|
|
42
|
+
cached by tree fingerprint, which changes with every edit, so dispatches landing
|
|
43
|
+
while a suite was already running each started another. A dispatch that finds a
|
|
44
|
+
capture in flight for the same directory and command now gets no baseline — the
|
|
45
|
+
same `unverifiable` outcome as a contaminated capture — instead of a second suite.
|
|
46
|
+
|
|
8
47
|
## [1.13.0] - 2026-09-24
|
|
9
48
|
|
|
10
49
|
A forced delegation of a request that carries no task produced a `task` call with no
|
package/package.json
CHANGED
package/src/verify/dispatch.ts
CHANGED
|
@@ -83,7 +83,7 @@ export function createChangedFileStore(options: ChangedFileStoreOptions = {}) {
|
|
|
83
83
|
baselines: Map<string, Promise<TestBaseline | undefined>>;
|
|
84
84
|
}>();
|
|
85
85
|
const cache = new Map<string, {
|
|
86
|
-
cwd: string; pending: boolean; contaminated: boolean; stamp: number;
|
|
86
|
+
cwd: string; command: string; pending: boolean; contaminated: boolean; stamp: number;
|
|
87
87
|
controller: AbortController; result: Promise<TestBaseline | undefined>;
|
|
88
88
|
}>();
|
|
89
89
|
|
|
@@ -124,9 +124,13 @@ export function createChangedFileStore(options: ChangedFileStoreOptions = {}) {
|
|
|
124
124
|
for (const command of new Set(commands)) {
|
|
125
125
|
const key = JSON.stringify([pathKey(snapshot.cwd), snapshot.head, snapshot.fingerprint, command]);
|
|
126
126
|
let entry = cache.get(key);
|
|
127
|
+
// A suite already running in this directory is not started again under a new
|
|
128
|
+
// fingerprint: concurrent full suites saturate every core, and the dispatch
|
|
129
|
+
// falls back to the same "no baseline" path as a contaminated capture.
|
|
130
|
+
if (!entry && [...cache.values()].some(c => c.pending && c.command === command && pathKey(c.cwd) === pathKey(cwd))) continue;
|
|
127
131
|
if (!entry) {
|
|
128
132
|
const capture = {
|
|
129
|
-
cwd, pending: true, contaminated: false, stamp: now(),
|
|
133
|
+
cwd, command, pending: true, contaminated: false, stamp: now(),
|
|
130
134
|
controller: new AbortController(), result: Promise.resolve<TestBaseline | undefined>(undefined),
|
|
131
135
|
};
|
|
132
136
|
cache.set(key, capture);
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run a shell command with a deadline that actually ends the work.
|
|
3
|
+
*
|
|
4
|
+
* `child_process.exec` with `timeout` (or `signal`) only signals the shell it
|
|
5
|
+
* spawned. Test commands are process trees — `cmd /c npm test` -> npm -> vitest
|
|
6
|
+
* -> one worker per core — so killing the shell orphans everything below it,
|
|
7
|
+
* and the "aborted" baseline keeps every core busy until the suite finishes on
|
|
8
|
+
* its own. On a timeout or abort this kills the whole tree instead: `taskkill
|
|
9
|
+
* /T` on Windows, the process group on POSIX.
|
|
10
|
+
*/
|
|
11
|
+
import { execFile, spawn, type ChildProcess } from "node:child_process";
|
|
12
|
+
|
|
13
|
+
export interface ShellResult {
|
|
14
|
+
code: number;
|
|
15
|
+
stdout: string;
|
|
16
|
+
stderr: string;
|
|
17
|
+
/** True when the deadline or the abort signal ended the command. */
|
|
18
|
+
timedOut: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function runShell(
|
|
22
|
+
command: string,
|
|
23
|
+
opts: { cwd: string; timeoutMs: number; signal?: AbortSignal; maxBuffer?: number },
|
|
24
|
+
): Promise<ShellResult> {
|
|
25
|
+
if (opts.signal?.aborted) return Promise.resolve({ code: 1, stdout: "", stderr: "", timedOut: true });
|
|
26
|
+
return new Promise((resolve) => {
|
|
27
|
+
const limit = opts.maxBuffer ?? 10 * 1024 * 1024;
|
|
28
|
+
let stdout = "";
|
|
29
|
+
let stderr = "";
|
|
30
|
+
let killed = false;
|
|
31
|
+
let settled = false;
|
|
32
|
+
let child: ChildProcess;
|
|
33
|
+
try {
|
|
34
|
+
child = spawn(command, {
|
|
35
|
+
cwd: opts.cwd,
|
|
36
|
+
shell: true,
|
|
37
|
+
windowsHide: true,
|
|
38
|
+
// Its own process group on POSIX, so the whole tree can be signalled at once.
|
|
39
|
+
detached: process.platform !== "win32",
|
|
40
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
41
|
+
});
|
|
42
|
+
} catch (err) {
|
|
43
|
+
resolve({ code: 1, stdout: "", stderr: `exec failed: ${String(err)}`, timedOut: false });
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
// Output past the cap is dropped rather than failing the run; the verdict
|
|
47
|
+
// is parsed from the summary lines, which runners print last only when the
|
|
48
|
+
// run completes, so truncation degrades to "unknown output", never a pass.
|
|
49
|
+
child.stdout?.on("data", (chunk) => { if (stdout.length < limit) stdout += String(chunk); });
|
|
50
|
+
child.stderr?.on("data", (chunk) => { if (stderr.length < limit) stderr += String(chunk); });
|
|
51
|
+
|
|
52
|
+
const kill = () => {
|
|
53
|
+
if (killed || settled) return;
|
|
54
|
+
killed = true;
|
|
55
|
+
killTree(child);
|
|
56
|
+
};
|
|
57
|
+
const timer = setTimeout(kill, opts.timeoutMs);
|
|
58
|
+
opts.signal?.addEventListener("abort", kill, { once: true });
|
|
59
|
+
|
|
60
|
+
const finish = (code: number | null, error?: unknown) => {
|
|
61
|
+
if (settled) return;
|
|
62
|
+
settled = true;
|
|
63
|
+
clearTimeout(timer);
|
|
64
|
+
opts.signal?.removeEventListener("abort", kill);
|
|
65
|
+
if (error) stderr += String(error);
|
|
66
|
+
resolve({ code: killed ? code || 1 : code ?? 1, stdout, stderr, timedOut: killed });
|
|
67
|
+
};
|
|
68
|
+
child.on("error", (err) => finish(1, err));
|
|
69
|
+
child.on("close", (code) => finish(code));
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function killTree(child: ChildProcess): void {
|
|
74
|
+
const pid = child.pid;
|
|
75
|
+
if (!pid) {
|
|
76
|
+
child.kill("SIGKILL");
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (process.platform === "win32") {
|
|
80
|
+
execFile("taskkill", ["/pid", String(pid), "/T", "/F"], { windowsHide: true }, (err) => {
|
|
81
|
+
// taskkill fails when the tree already exited; the direct kill is then a no-op.
|
|
82
|
+
if (err) child.kill();
|
|
83
|
+
});
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
process.kill(-pid, "SIGKILL");
|
|
88
|
+
} catch {
|
|
89
|
+
// No group (already reaped or never detached): fall back to the direct child.
|
|
90
|
+
child.kill("SIGKILL");
|
|
91
|
+
}
|
|
92
|
+
}
|
package/src/verify/wiring.ts
CHANGED
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
* settings that were active when the plugin loaded, and `/preset` would
|
|
14
14
|
* silently stop applying to graded work.
|
|
15
15
|
*/
|
|
16
|
-
import { exec as nodeExec } from "node:child_process";
|
|
17
16
|
import { access, readFile as fsReadFile } from "node:fs/promises";
|
|
18
17
|
import { isAbsolute, join, resolve } from "node:path";
|
|
19
18
|
import { createMutexRegistry, DEFAULT_ALLOWLIST, isCommandAllowed, resolveRepoCommand } from "./deterministic";
|
|
20
19
|
import { tierModel, type createChangedFileStore } from "./dispatch";
|
|
20
|
+
import { runShell } from "./exec";
|
|
21
21
|
import { snapshotTree } from "./tree";
|
|
22
22
|
import type { DoD } from "./dod";
|
|
23
23
|
import type { DeterministicDeps } from "./types";
|
|
@@ -107,32 +107,10 @@ export function createVerificationWiring(deps: {
|
|
|
107
107
|
command: string,
|
|
108
108
|
opts?: { cwd?: string; timeoutMs?: number; signal?: AbortSignal },
|
|
109
109
|
): Promise<ExecResult> =>
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
{
|
|
115
|
-
cwd: opts?.cwd ?? directory,
|
|
116
|
-
timeout: opts?.timeoutMs ?? 120000,
|
|
117
|
-
maxBuffer: 10 * 1024 * 1024,
|
|
118
|
-
windowsHide: true,
|
|
119
|
-
signal: opts?.signal,
|
|
120
|
-
},
|
|
121
|
-
(err: any, stdout: any, stderr: any) => {
|
|
122
|
-
const timedOut = !!(err && err.killed && err.signal === "SIGTERM");
|
|
123
|
-
const code =
|
|
124
|
-
err && typeof err.code === "number" ? err.code : err ? 1 : 0;
|
|
125
|
-
resolve({
|
|
126
|
-
code,
|
|
127
|
-
stdout: String(stdout ?? ""),
|
|
128
|
-
stderr: String(stderr ?? ""),
|
|
129
|
-
timedOut,
|
|
130
|
-
});
|
|
131
|
-
},
|
|
132
|
-
);
|
|
133
|
-
} catch {
|
|
134
|
-
resolve({ code: 1, stdout: "", stderr: "exec failed", timedOut: false });
|
|
135
|
-
}
|
|
110
|
+
runShell(command, {
|
|
111
|
+
cwd: opts?.cwd ?? directory,
|
|
112
|
+
timeoutMs: opts?.timeoutMs ?? 120000,
|
|
113
|
+
signal: opts?.signal,
|
|
136
114
|
});
|
|
137
115
|
|
|
138
116
|
const fsSeam = {
|
|
@@ -268,9 +246,12 @@ export function createVerificationWiring(deps: {
|
|
|
268
246
|
beginVerification(store, id, cwd, dod) {
|
|
269
247
|
const verify = getConfig().enforcement?.verify;
|
|
270
248
|
const base = resolve(directory, cwd || ".");
|
|
271
|
-
|
|
272
|
-
//
|
|
273
|
-
|
|
249
|
+
// Only a dispatch that will be judged by testsPass captures a baseline. Warming
|
|
250
|
+
// the cache from read-only dispatches ran the full suite on every exploration
|
|
251
|
+
// fan-out, and the capture was almost always discarded anyway: any shell or
|
|
252
|
+
// edit tool in the directory contaminates it.
|
|
253
|
+
const commands = dod.checks
|
|
254
|
+
.filter(c => c.kind === "testsPass")
|
|
274
255
|
.map(c => resolveRepoCommand(c, "testsPass", undefined))
|
|
275
256
|
.filter(c => isCommandAllowed(c, DEFAULT_ALLOWLIST));
|
|
276
257
|
const budget = verify?.baselineTimeoutMs ?? 60000;
|
package/tiers.json
CHANGED
|
@@ -59,10 +59,10 @@
|
|
|
59
59
|
},
|
|
60
60
|
"medium": {
|
|
61
61
|
"model": "anthropic/claude-opus-5-5",
|
|
62
|
-
"variant": "
|
|
63
|
-
"effort": "
|
|
62
|
+
"variant": "low",
|
|
63
|
+
"effort": "low",
|
|
64
64
|
"costRatio": 5,
|
|
65
|
-
"description": "Opus 5.5
|
|
65
|
+
"description": "Opus 5.5 low for implementation, refactoring, and tests",
|
|
66
66
|
"steps": 50,
|
|
67
67
|
"whenToUse": [
|
|
68
68
|
"Feature implementation",
|
|
@@ -73,10 +73,11 @@
|
|
|
73
73
|
]
|
|
74
74
|
},
|
|
75
75
|
"heavy": {
|
|
76
|
-
"model": "anthropic/claude-
|
|
77
|
-
"variant": "
|
|
76
|
+
"model": "anthropic/claude-opus-5-5",
|
|
77
|
+
"variant": "xhigh",
|
|
78
|
+
"effort": "xhigh",
|
|
78
79
|
"costRatio": 20,
|
|
79
|
-
"description": "
|
|
80
|
+
"description": "Opus 5.5 xhigh for architecture, complex debugging, and security",
|
|
80
81
|
"steps": 120,
|
|
81
82
|
"whenToUse": [
|
|
82
83
|
"Architecture decisions",
|