opencode-model-router 1.14.0 → 2.0.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 +173 -0
- package/README.md +80 -28
- package/package.json +8 -3
- package/server.ts +3 -0
- package/src/compat/child-session.ts +27 -0
- package/src/compat/v2-client.ts +183 -0
- package/src/compat/v2-hooks.ts +376 -0
- package/src/index.ts +427 -85
- package/src/router/config.ts +225 -15
- package/src/router/protocol.ts +12 -2
- package/src/v2.ts +24 -0
- package/src/verify/baseline.ts +143 -25
- package/src/verify/batch.ts +2226 -0
- package/src/verify/checker.ts +1 -1
- package/src/verify/deterministic.ts +1378 -20
- package/src/verify/directives.ts +207 -0
- package/src/verify/dispatch.ts +387 -90
- package/src/verify/dod.ts +8 -1
- package/src/verify/exec.ts +654 -35
- package/src/verify/gate.ts +16 -1
- package/src/verify/paths.ts +9 -1
- 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 +1959 -52
- package/tiers.json +21 -19
package/src/verify/gate.ts
CHANGED
|
@@ -24,7 +24,8 @@ import { isCheckable } from "./dod";
|
|
|
24
24
|
import { runDeterministic } from "./deterministic";
|
|
25
25
|
import { runChecker } from "./checker";
|
|
26
26
|
import type { ArtefactView, CheckerDeps } from "./checker";
|
|
27
|
-
import {
|
|
27
|
+
import { isAbsolute } from "node:path";
|
|
28
|
+
import { isWithinDir, resolveBaseDir } from "./paths";
|
|
28
29
|
|
|
29
30
|
/** The concrete, inspectable result of a delegation (artefact contract §3.3). */
|
|
30
31
|
export interface Artefact {
|
|
@@ -62,6 +63,12 @@ export interface GateDeps {
|
|
|
62
63
|
*/
|
|
63
64
|
require?: "never" | "whenDoDPresent" | "always";
|
|
64
65
|
strictUnverifiable?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Canonicalizes a path for the outside-the-base check: one directory can be spelled several
|
|
68
|
+
* ways (a Windows 8.3 short name, a symlink such as macOS /var -> /private/var), and a lexical
|
|
69
|
+
* comparison would call the producer's own files "outside". Absent means lexical comparison.
|
|
70
|
+
*/
|
|
71
|
+
canonicalPath?: (path: string) => string;
|
|
65
72
|
}
|
|
66
73
|
|
|
67
74
|
export interface GateResult {
|
|
@@ -187,6 +194,14 @@ export async function accept(
|
|
|
187
194
|
|
|
188
195
|
let verdict: Verdict;
|
|
189
196
|
if (dod.kind === "deterministic") {
|
|
197
|
+
const canonical = deps.canonicalPath ?? ((path: string) => path);
|
|
198
|
+
const canonicalBase = canonical(effectiveBaseDir);
|
|
199
|
+
if (artefact.changedFiles.length > 0 && artefact.changedFiles.every(
|
|
200
|
+
({ path }) => isAbsolute(path) && !isWithinDir(canonical(path), canonicalBase),
|
|
201
|
+
)) {
|
|
202
|
+
const reason = `the producer changed files only outside ${effectiveBaseDir} (e.g. ${artefact.changedFiles[0].path}); checks run there cannot see them. Add "cwd: <dir>" to the [acceptance] block to verify where the work landed.`;
|
|
203
|
+
return gateResult({ pass: false, outcome: "unverifiable", method: "none", reasons: [reason], caveats: [reason] }, dodSource, deps.strictUnverifiable);
|
|
204
|
+
}
|
|
190
205
|
verdict = await runDeterministic(dod, {
|
|
191
206
|
...deps.deterministic,
|
|
192
207
|
cwd: effectiveBaseDir,
|
package/src/verify/paths.ts
CHANGED
|
@@ -5,7 +5,15 @@
|
|
|
5
5
|
// resolve relative paths against an effective base dir instead of the router's
|
|
6
6
|
// own cwd.
|
|
7
7
|
|
|
8
|
-
import { isAbsolute, join } from "node:path";
|
|
8
|
+
import { isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
9
|
+
|
|
10
|
+
/** Lexical containment only: no filesystem or symlink resolution. */
|
|
11
|
+
export function isWithinDir(path: string, dir: string): boolean {
|
|
12
|
+
const key = (p: string) => process.platform === "win32" ? resolve(p).toLowerCase() : resolve(p);
|
|
13
|
+
const delta = relative(key(dir), key(path));
|
|
14
|
+
// Only a leading `..` SEGMENT leaves the dir: a child named `..cache` stays inside.
|
|
15
|
+
return delta !== ".." && !delta.startsWith(`..${sep}`) && !isAbsolute(delta);
|
|
16
|
+
}
|
|
9
17
|
|
|
10
18
|
/**
|
|
11
19
|
* Resolve the effective base directory for a delegation's verification.
|