opencode-model-router 1.1.15 → 1.2.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/README.md +37 -0
- package/package.json +12 -2
- package/src/escalate/ladder.ts +201 -0
- package/src/guard/enforce.ts +135 -0
- package/src/guard/fingerprint.ts +16 -0
- package/src/guard/guards.ts +343 -0
- package/src/guard/narration.ts +34 -0
- package/src/guard/scrub.ts +26 -0
- package/src/guard/store.ts +39 -0
- package/src/index.ts +646 -749
- package/src/router/config.ts +478 -0
- package/src/router/enforcement.ts +53 -0
- package/src/router/protocol.ts +306 -0
- package/src/router/sessions.ts +268 -0
- package/src/telemetry/trajectory.ts +180 -0
- package/src/verify/checker.ts +224 -0
- package/src/verify/deterministic.ts +319 -0
- package/src/verify/dispatch.ts +153 -0
- package/src/verify/dod.ts +274 -0
- package/src/verify/gate.ts +166 -0
- package/src/verify/types.ts +49 -0
- package/tiers.json +14 -15
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
// src/verify/dod.ts
|
|
2
|
+
// Pure DoD (Definition of Done) schema, parser, and auto-inference.
|
|
3
|
+
// PURE: no imports from Node fs/os/path, no network, no SDK, no other project modules.
|
|
4
|
+
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
// Types
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
export type CheckKind = "run" | "fileExists" | "schemaMatch" | "testsPass" | "buildPasses" | "lintClean";
|
|
10
|
+
|
|
11
|
+
export interface Check {
|
|
12
|
+
kind: CheckKind;
|
|
13
|
+
command?: string; // run/testsPass/buildPasses/lintClean (optional; runner supplies a default later)
|
|
14
|
+
expect?: string; // run: expected substring in output (optional)
|
|
15
|
+
path?: string; // fileExists/schemaMatch
|
|
16
|
+
schema?: string; // schemaMatch: inline JSON or a path
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type DoDKind = "deterministic" | "checker" | "none";
|
|
20
|
+
export type DoDSource = "explicit" | "inferred" | "annotation" | "none";
|
|
21
|
+
|
|
22
|
+
export interface DoD {
|
|
23
|
+
kind: DoDKind;
|
|
24
|
+
checks: Check[]; // [] when none/checker-only
|
|
25
|
+
criteria: string[]; // [] when none
|
|
26
|
+
deliverable: string | null;
|
|
27
|
+
source: DoDSource;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface InferHints {
|
|
31
|
+
testCommand?: string | null;
|
|
32
|
+
buildCommand?: string | null;
|
|
33
|
+
lintCommand?: string | null;
|
|
34
|
+
declaredPath?: string | null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// ---------------------------------------------------------------------------
|
|
38
|
+
// Internal constants
|
|
39
|
+
// ---------------------------------------------------------------------------
|
|
40
|
+
|
|
41
|
+
const VALID_CHECK_KINDS: ReadonlySet<string> = new Set<string>([
|
|
42
|
+
"run", "fileExists", "schemaMatch", "testsPass", "buildPasses", "lintClean",
|
|
43
|
+
]);
|
|
44
|
+
|
|
45
|
+
const VALID_DOD_KINDS: ReadonlySet<string> = new Set<string>([
|
|
46
|
+
"deterministic", "checker", "none",
|
|
47
|
+
]);
|
|
48
|
+
|
|
49
|
+
const OPEN_TAG_RE = /^\s*\[(acceptance|dod)\]\s*$/i;
|
|
50
|
+
const CLOSE_TAG_RE = /^\s*\[\/(acceptance|dod)\]\s*$/i;
|
|
51
|
+
|
|
52
|
+
// ---------------------------------------------------------------------------
|
|
53
|
+
// summarizeDispatch
|
|
54
|
+
// ---------------------------------------------------------------------------
|
|
55
|
+
|
|
56
|
+
export function summarizeDispatch(text: string): string {
|
|
57
|
+
if (!text) return "";
|
|
58
|
+
const lines = text.split("\n");
|
|
59
|
+
for (const line of lines) {
|
|
60
|
+
const trimmed = line.trim().replace(/\s+/g, " ");
|
|
61
|
+
if (trimmed) return trimmed.slice(0, 120);
|
|
62
|
+
}
|
|
63
|
+
return "";
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// ---------------------------------------------------------------------------
|
|
67
|
+
// normalizeDoD
|
|
68
|
+
// ---------------------------------------------------------------------------
|
|
69
|
+
|
|
70
|
+
export function normalizeDoD(d: DoD): DoD {
|
|
71
|
+
const checks: Check[] = Array.isArray(d.checks) ? [...d.checks] : [];
|
|
72
|
+
const criteria: string[] = Array.isArray(d.criteria) ? [...d.criteria] : [];
|
|
73
|
+
|
|
74
|
+
let kind: DoDKind;
|
|
75
|
+
if (checks.length > 0) kind = "deterministic";
|
|
76
|
+
else if (criteria.length > 0) kind = "checker";
|
|
77
|
+
else kind = "none";
|
|
78
|
+
|
|
79
|
+
const rawDeliverable = typeof d.deliverable === "string" ? d.deliverable.trim() : "";
|
|
80
|
+
const deliverable: string | null = rawDeliverable.length > 0 ? rawDeliverable : null;
|
|
81
|
+
|
|
82
|
+
return { kind, checks, criteria, deliverable, source: d.source };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// ---------------------------------------------------------------------------
|
|
86
|
+
// parseKvPairs — internal helper
|
|
87
|
+
// ---------------------------------------------------------------------------
|
|
88
|
+
|
|
89
|
+
function parseKvPairs(s: string): Record<string, string> {
|
|
90
|
+
const result: Record<string, string> = {};
|
|
91
|
+
const re = /(\w+)=(?:"([^"]*)"|([\S]*))/g;
|
|
92
|
+
let m: RegExpExecArray | null;
|
|
93
|
+
while ((m = re.exec(s)) !== null) {
|
|
94
|
+
const key = m[1];
|
|
95
|
+
const value = m[2] !== undefined ? m[2] : (m[3] ?? "");
|
|
96
|
+
result[key] = value;
|
|
97
|
+
}
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// ---------------------------------------------------------------------------
|
|
102
|
+
// parseAcceptanceBlock
|
|
103
|
+
// ---------------------------------------------------------------------------
|
|
104
|
+
|
|
105
|
+
export function parseAcceptanceBlock(text: string, source: DoDSource = "explicit"): DoD | null {
|
|
106
|
+
const lines = text.split("\n");
|
|
107
|
+
|
|
108
|
+
let openIdx = -1;
|
|
109
|
+
let closeIdx = -1;
|
|
110
|
+
|
|
111
|
+
for (let i = 0; i < lines.length; i++) {
|
|
112
|
+
if (OPEN_TAG_RE.test(lines[i])) {
|
|
113
|
+
openIdx = i;
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (openIdx === -1) return null;
|
|
119
|
+
|
|
120
|
+
for (let i = openIdx + 1; i < lines.length; i++) {
|
|
121
|
+
if (CLOSE_TAG_RE.test(lines[i])) {
|
|
122
|
+
closeIdx = i;
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (closeIdx === -1) return null;
|
|
128
|
+
|
|
129
|
+
const innerLines = lines.slice(openIdx + 1, closeIdx);
|
|
130
|
+
const checks: Check[] = [];
|
|
131
|
+
const criteria: string[] = [];
|
|
132
|
+
let deliverable: string | null = null;
|
|
133
|
+
let kindHint: DoDKind | null = null;
|
|
134
|
+
|
|
135
|
+
for (const rawLine of innerLines) {
|
|
136
|
+
const line = rawLine.trim();
|
|
137
|
+
if (!line) continue;
|
|
138
|
+
|
|
139
|
+
const lline = line.toLowerCase();
|
|
140
|
+
|
|
141
|
+
if (lline.startsWith("check:")) {
|
|
142
|
+
const rest = line.slice("check:".length).trim();
|
|
143
|
+
const spaceIdx = rest.search(/\s/);
|
|
144
|
+
const kindStr = spaceIdx === -1 ? rest : rest.slice(0, spaceIdx);
|
|
145
|
+
const remainder = spaceIdx === -1 ? "" : rest.slice(spaceIdx + 1);
|
|
146
|
+
|
|
147
|
+
if (!VALID_CHECK_KINDS.has(kindStr)) continue;
|
|
148
|
+
|
|
149
|
+
const kvPairs = parseKvPairs(remainder);
|
|
150
|
+
const check: Check = { kind: kindStr as CheckKind };
|
|
151
|
+
if (kvPairs["command"] !== undefined) check.command = kvPairs["command"];
|
|
152
|
+
if (kvPairs["expect"] !== undefined) check.expect = kvPairs["expect"];
|
|
153
|
+
if (kvPairs["path"] !== undefined) check.path = kvPairs["path"];
|
|
154
|
+
if (kvPairs["schema"] !== undefined) check.schema = kvPairs["schema"];
|
|
155
|
+
checks.push(check);
|
|
156
|
+
} else if (lline.startsWith("criteria:")) {
|
|
157
|
+
const rest = line.slice("criteria:".length).trim();
|
|
158
|
+
if (rest) criteria.push(rest);
|
|
159
|
+
} else if (lline.startsWith("deliverable:")) {
|
|
160
|
+
const rest = line.slice("deliverable:".length).trim();
|
|
161
|
+
deliverable = rest.length > 0 ? rest : null;
|
|
162
|
+
} else if (lline.startsWith("kind:")) {
|
|
163
|
+
const rest = line.slice("kind:".length).trim().toLowerCase();
|
|
164
|
+
if (VALID_DOD_KINDS.has(rest)) {
|
|
165
|
+
kindHint = rest as DoDKind;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return normalizeDoD({
|
|
171
|
+
kind: kindHint !== null ? kindHint : "none",
|
|
172
|
+
checks,
|
|
173
|
+
criteria,
|
|
174
|
+
deliverable,
|
|
175
|
+
source,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// ---------------------------------------------------------------------------
|
|
180
|
+
// parseDoDFromDispatch / parseDoDFromAnnotation
|
|
181
|
+
// ---------------------------------------------------------------------------
|
|
182
|
+
|
|
183
|
+
export function parseDoDFromDispatch(dispatchText: string): DoD | null {
|
|
184
|
+
return parseAcceptanceBlock(dispatchText, "explicit");
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export function parseDoDFromAnnotation(annotationText: string): DoD | null {
|
|
188
|
+
return parseAcceptanceBlock(annotationText, "annotation");
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// ---------------------------------------------------------------------------
|
|
192
|
+
// inferDoD
|
|
193
|
+
// ---------------------------------------------------------------------------
|
|
194
|
+
|
|
195
|
+
export function inferDoD(dispatchText: string, tier: string, hints: InferHints): DoD {
|
|
196
|
+
// tier accepted for forward-compat; not used in phase 2.1
|
|
197
|
+
const lower = dispatchText.toLowerCase();
|
|
198
|
+
|
|
199
|
+
// Classify by FIRST matching pattern
|
|
200
|
+
let category: "bugfix" | "refactor" | "writeFile" | "impl" | "test" | "unknown";
|
|
201
|
+
|
|
202
|
+
if (/\b(bug|fix|broken|regression|failing)\b/.test(lower)) {
|
|
203
|
+
category = "bugfix";
|
|
204
|
+
} else if (/\b(refactor|rename|extract|restructure|cleanup|clean up)\b/.test(lower)) {
|
|
205
|
+
category = "refactor";
|
|
206
|
+
} else if (
|
|
207
|
+
/\b(write|generate|emit|scaffold)\b/.test(lower) &&
|
|
208
|
+
hints.declaredPath != null &&
|
|
209
|
+
hints.declaredPath.trim().length > 0
|
|
210
|
+
) {
|
|
211
|
+
category = "writeFile";
|
|
212
|
+
} else if (/\b(implement|add|feature|create|build|endpoint|function|component|fix)\b/.test(lower)) {
|
|
213
|
+
category = "impl";
|
|
214
|
+
} else if (/\b(test|spec|coverage)\b/.test(lower)) {
|
|
215
|
+
category = "test";
|
|
216
|
+
} else {
|
|
217
|
+
category = "unknown";
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const checks: Check[] = [];
|
|
221
|
+
|
|
222
|
+
if (category === "bugfix" || category === "impl") {
|
|
223
|
+
if (hints.buildCommand != null && hints.buildCommand.trim().length > 0) {
|
|
224
|
+
checks.push({ kind: "buildPasses", command: hints.buildCommand });
|
|
225
|
+
}
|
|
226
|
+
if (hints.testCommand != null && hints.testCommand.trim().length > 0) {
|
|
227
|
+
checks.push({ kind: "testsPass", command: hints.testCommand });
|
|
228
|
+
}
|
|
229
|
+
} else if (category === "refactor") {
|
|
230
|
+
if (hints.buildCommand != null && hints.buildCommand.trim().length > 0) {
|
|
231
|
+
checks.push({ kind: "buildPasses", command: hints.buildCommand });
|
|
232
|
+
}
|
|
233
|
+
if (hints.lintCommand != null && hints.lintCommand.trim().length > 0) {
|
|
234
|
+
checks.push({ kind: "lintClean", command: hints.lintCommand });
|
|
235
|
+
}
|
|
236
|
+
} else if (category === "writeFile") {
|
|
237
|
+
checks.push({ kind: "fileExists", path: hints.declaredPath!.trim() });
|
|
238
|
+
} else if (category === "test") {
|
|
239
|
+
if (hints.testCommand != null && hints.testCommand.trim().length > 0) {
|
|
240
|
+
checks.push({ kind: "testsPass", command: hints.testCommand });
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
// "unknown" and other fallthrough: checks stays empty
|
|
244
|
+
|
|
245
|
+
const criteria: string[] = [];
|
|
246
|
+
|
|
247
|
+
if (checks.length === 0) {
|
|
248
|
+
const summary = summarizeDispatch(dispatchText);
|
|
249
|
+
criteria.push(
|
|
250
|
+
summary.length > 0
|
|
251
|
+
? summary
|
|
252
|
+
: "the delegated task is completed as described in the dispatch",
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const rawPath = hints.declaredPath != null ? hints.declaredPath.trim() : "";
|
|
257
|
+
const deliverable: string | null = rawPath.length > 0 ? rawPath : null;
|
|
258
|
+
|
|
259
|
+
return normalizeDoD({
|
|
260
|
+
kind: checks.length > 0 ? "deterministic" : "checker",
|
|
261
|
+
checks,
|
|
262
|
+
criteria,
|
|
263
|
+
deliverable,
|
|
264
|
+
source: "inferred",
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// ---------------------------------------------------------------------------
|
|
269
|
+
// isCheckable
|
|
270
|
+
// ---------------------------------------------------------------------------
|
|
271
|
+
|
|
272
|
+
export function isCheckable(d: DoD): boolean {
|
|
273
|
+
return d.kind !== "none" && (d.checks.length > 0 || d.criteria.length > 0);
|
|
274
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/verify/gate.ts — Layer 2 acceptance gate (PURE orchestration core).
|
|
3
|
+
*
|
|
4
|
+
* The gate is the single decision point that turns "the producer says it
|
|
5
|
+
* finished" into "the producer's output was objectively accepted". It is
|
|
6
|
+
* shared by BOTH usage modes (Mode A on-the-fly dispatch and Mode B plan
|
|
7
|
+
* annotation) and by BOTH wirings (Option (i) verify-dispatch around the
|
|
8
|
+
* built-in `task` tool, and Option (ii) the plugin-owned `delegate` tool),
|
|
9
|
+
* so there is exactly ONE accept/verify code path (GA-5).
|
|
10
|
+
*
|
|
11
|
+
* Design invariants:
|
|
12
|
+
* - FAIL-CLOSED: a verification error never yields acceptance.
|
|
13
|
+
* - NEVER silently accept a non-trivial delegation that has no checkable DoD.
|
|
14
|
+
* - producer != grader and grader >= producer are enforced inside runChecker;
|
|
15
|
+
* the gate never grades anything itself.
|
|
16
|
+
* - PURE: all side-effecting work (exec/fs/grader dispatch) is injected via
|
|
17
|
+
* deps; this module imports no fs/network/SDK.
|
|
18
|
+
*/
|
|
19
|
+
import type { Verdict } from "./types";
|
|
20
|
+
import type { DeterministicDeps } from "./types";
|
|
21
|
+
import type { DoD } from "./dod";
|
|
22
|
+
import { isCheckable } from "./dod";
|
|
23
|
+
import { runDeterministic } from "./deterministic";
|
|
24
|
+
import { runChecker } from "./checker";
|
|
25
|
+
import type { ArtefactView, CheckerDeps } from "./checker";
|
|
26
|
+
|
|
27
|
+
/** The concrete, inspectable result of a delegation (artefact contract §3.3). */
|
|
28
|
+
export interface Artefact {
|
|
29
|
+
changedFiles: { path: string; status: string }[];
|
|
30
|
+
finalReturnText: string;
|
|
31
|
+
declaredOutputs: string[];
|
|
32
|
+
producerSessionID: string;
|
|
33
|
+
producerTier: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** The delegation being judged: its DoD plus dispatch-time classification. */
|
|
37
|
+
export interface Delegation {
|
|
38
|
+
dod: DoD;
|
|
39
|
+
/** Trivial dispatches (classified at dispatch, m2) bypass verification (GA-6). */
|
|
40
|
+
trivial?: boolean;
|
|
41
|
+
/** Mode A (on-the-fly) vs Mode B (plan annotation) — drives the no-DoD message. */
|
|
42
|
+
mode?: "modeA" | "modeB";
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface GateDeps {
|
|
46
|
+
deterministic: DeterministicDeps;
|
|
47
|
+
checker: CheckerDeps;
|
|
48
|
+
/**
|
|
49
|
+
* verify.require: "never" disables the gate (accept without verifying);
|
|
50
|
+
* "whenDoDPresent" (default) and "always" both verify when the DoD is
|
|
51
|
+
* checkable and apply the no-DoD policy otherwise.
|
|
52
|
+
*/
|
|
53
|
+
require?: "never" | "whenDoDPresent" | "always";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface GateResult {
|
|
57
|
+
accepted: boolean;
|
|
58
|
+
verdict: Verdict;
|
|
59
|
+
/** Convenience mirror of dod.source for the caller's trajectory record. */
|
|
60
|
+
dodSource: DoD["source"];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function view(artefact: Artefact): ArtefactView {
|
|
64
|
+
return {
|
|
65
|
+
finalReturnText: artefact.finalReturnText,
|
|
66
|
+
changedFiles: artefact.changedFiles,
|
|
67
|
+
declaredOutputs: artefact.declaredOutputs,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Decide whether a delegation's artefact meets its DoD.
|
|
73
|
+
* Returns { accepted, verdict, dodSource }; accepted is true ONLY when a
|
|
74
|
+
* verifier returned pass===true (or the gate is explicitly disabled).
|
|
75
|
+
*/
|
|
76
|
+
export async function accept(
|
|
77
|
+
delegation: Delegation,
|
|
78
|
+
artefact: Artefact,
|
|
79
|
+
deps: GateDeps,
|
|
80
|
+
): Promise<GateResult> {
|
|
81
|
+
const dod = delegation.dod;
|
|
82
|
+
const dodSource = dod.source;
|
|
83
|
+
const require = deps.require ?? "whenDoDPresent";
|
|
84
|
+
|
|
85
|
+
// verify.require === "never": Layer 2 is configured off; do not gate.
|
|
86
|
+
if (require === "never") {
|
|
87
|
+
return {
|
|
88
|
+
accepted: true,
|
|
89
|
+
verdict: {
|
|
90
|
+
pass: false,
|
|
91
|
+
method: "none",
|
|
92
|
+
skipped: true,
|
|
93
|
+
reasons: ["verification disabled (verify.require=never)"],
|
|
94
|
+
},
|
|
95
|
+
dodSource,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Trivial dispatch (classified at dispatch, m2) carrying only an AUTO-INFERRED
|
|
100
|
+
// DoD: bypass verification overhead (GA-6 proportional). An explicit author
|
|
101
|
+
// [acceptance] block (source "explicit"/"annotation") is a deliberate request
|
|
102
|
+
// to verify and is always honored, even for a trivially-classified dispatch.
|
|
103
|
+
if (delegation.trivial && dod.source === "inferred") {
|
|
104
|
+
return {
|
|
105
|
+
accepted: true,
|
|
106
|
+
verdict: {
|
|
107
|
+
pass: false,
|
|
108
|
+
method: "none",
|
|
109
|
+
skipped: true,
|
|
110
|
+
reasons: ["trivial dispatch; verification skipped (auto-inferred DoD)"],
|
|
111
|
+
},
|
|
112
|
+
dodSource,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// No checkable DoD: apply the proportional / never-silently-accept policy.
|
|
117
|
+
if (!isCheckable(dod)) {
|
|
118
|
+
if (delegation.trivial) {
|
|
119
|
+
return {
|
|
120
|
+
accepted: true,
|
|
121
|
+
verdict: {
|
|
122
|
+
pass: false,
|
|
123
|
+
method: "none",
|
|
124
|
+
skipped: true,
|
|
125
|
+
reasons: ["trivial dispatch; verification skipped"],
|
|
126
|
+
},
|
|
127
|
+
dodSource,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
const reason =
|
|
131
|
+
delegation.mode === "modeB"
|
|
132
|
+
? "no acceptance block on a non-trivial plan task (Mode B is strict): add an [acceptance] ... [/acceptance] block to this task"
|
|
133
|
+
: "no checkable DoD for a non-trivial dispatch (Mode A): provide an [acceptance] block or let auto-inference supply one";
|
|
134
|
+
return {
|
|
135
|
+
accepted: false,
|
|
136
|
+
verdict: { pass: false, method: "none", skipped: true, reasons: [reason] },
|
|
137
|
+
dodSource,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Checkable DoD: dispatch on the normalized kind. normalizeDoD() guarantees
|
|
142
|
+
// a checkable DoD is "deterministic" (when any checks exist) or "checker"
|
|
143
|
+
// (criteria only), which realises verify.preferDeterministic at
|
|
144
|
+
// DoD-construction time. Both verifiers are contractually FAIL-CLOSED: they
|
|
145
|
+
// catch their own errors and return a non-passing Verdict, never throwing.
|
|
146
|
+
// The two wirings (Option i verify-dispatch / Option ii delegate tool) still
|
|
147
|
+
// wrap accept() defensively so that any unexpected throw surfaces as a
|
|
148
|
+
// visible failure (forcing note / honest status), never a silent accept.
|
|
149
|
+
let verdict: Verdict;
|
|
150
|
+
if (dod.kind === "deterministic") {
|
|
151
|
+
verdict = await runDeterministic(dod, deps.deterministic);
|
|
152
|
+
} else {
|
|
153
|
+
// "checker" is the only remaining checkable kind.
|
|
154
|
+
verdict = await runChecker(
|
|
155
|
+
{
|
|
156
|
+
criteria: dod.criteria,
|
|
157
|
+
artefact: view(artefact),
|
|
158
|
+
producerTier: artefact.producerTier,
|
|
159
|
+
producerSessionID: artefact.producerSessionID,
|
|
160
|
+
},
|
|
161
|
+
deps.checker,
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return { accepted: verdict.pass === true, verdict, dodSource };
|
|
166
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// src/verify/types.ts
|
|
2
|
+
// Pure types for the deterministic verifier. No runtime code.
|
|
3
|
+
|
|
4
|
+
export type VerifyMethod = "deterministic" | "checker" | "none";
|
|
5
|
+
|
|
6
|
+
export interface Verdict {
|
|
7
|
+
pass: boolean;
|
|
8
|
+
method: VerifyMethod;
|
|
9
|
+
reasons: string[];
|
|
10
|
+
evidence?: string;
|
|
11
|
+
/** true when nothing was actually verified (SKIPPED != PASS) */
|
|
12
|
+
skipped?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface ExecResult {
|
|
16
|
+
code: number;
|
|
17
|
+
stdout: string;
|
|
18
|
+
stderr: string;
|
|
19
|
+
timedOut?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface ExecSeam {
|
|
23
|
+
(command: string, opts?: { cwd?: string; timeoutMs?: number }): Promise<ExecResult>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface FsSeam {
|
|
27
|
+
fileExists(path: string): Promise<boolean>;
|
|
28
|
+
readFile(path: string): Promise<string>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface MutexRegistry {
|
|
32
|
+
runExclusive<T>(key: string, fn: () => Promise<T>): Promise<T>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface DeterministicDeps {
|
|
36
|
+
exec: ExecSeam;
|
|
37
|
+
fs: FsSeam;
|
|
38
|
+
cwd: string;
|
|
39
|
+
mutex?: MutexRegistry;
|
|
40
|
+
/** per-check timeout in ms; default 120000 */
|
|
41
|
+
timeoutMs?: number;
|
|
42
|
+
/** permitted command first-token basenames; default DEFAULT_ALLOWLIST */
|
|
43
|
+
allowlist?: string[];
|
|
44
|
+
defaults?: {
|
|
45
|
+
testCommand?: string;
|
|
46
|
+
buildCommand?: string;
|
|
47
|
+
lintCommand?: string;
|
|
48
|
+
};
|
|
49
|
+
}
|
package/tiers.json
CHANGED
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
]
|
|
41
41
|
},
|
|
42
42
|
"heavy": {
|
|
43
|
-
"model": "anthropic/claude-opus-4-
|
|
44
|
-
"variant": "
|
|
43
|
+
"model": "anthropic/claude-opus-4-8",
|
|
44
|
+
"variant": "max",
|
|
45
45
|
"costRatio": 20,
|
|
46
|
-
"description": "Opus 4.
|
|
46
|
+
"description": "Opus 4.8 max for architecture, complex debugging, and security",
|
|
47
47
|
"steps": 120,
|
|
48
48
|
"whenToUse": [
|
|
49
49
|
"Architecture decisions",
|
|
@@ -66,10 +66,10 @@
|
|
|
66
66
|
]
|
|
67
67
|
},
|
|
68
68
|
"medium": {
|
|
69
|
-
"model": "openai/gpt-5.
|
|
69
|
+
"model": "openai/gpt-5.5-fast",
|
|
70
70
|
"variant": "high",
|
|
71
71
|
"costRatio": 5,
|
|
72
|
-
"description": "GPT-5.
|
|
72
|
+
"description": "GPT-5.5 fast default settings for implementation and standard coding",
|
|
73
73
|
"steps": 50,
|
|
74
74
|
"whenToUse": [
|
|
75
75
|
"Feature implementation",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
]
|
|
80
80
|
},
|
|
81
81
|
"heavy": {
|
|
82
|
-
"model": "openai/gpt-5.
|
|
82
|
+
"model": "openai/gpt-5.5-fast",
|
|
83
83
|
"variant": "xhigh",
|
|
84
84
|
"costRatio": 20,
|
|
85
85
|
"description": "GPT-5.4 xhigh for architecture and complex tasks",
|
|
@@ -173,9 +173,9 @@
|
|
|
173
173
|
},
|
|
174
174
|
"hybrid": {
|
|
175
175
|
"fast": {
|
|
176
|
-
"model": "
|
|
176
|
+
"model": "anthropic/claude-haiku-4-5",
|
|
177
177
|
"costRatio": 1,
|
|
178
|
-
"description": "
|
|
178
|
+
"description": "Haiku 4.5 for exploration, search, and simple reads",
|
|
179
179
|
"steps": 30,
|
|
180
180
|
"whenToUse": [
|
|
181
181
|
"Codebase exploration and search",
|
|
@@ -185,24 +185,23 @@
|
|
|
185
185
|
]
|
|
186
186
|
},
|
|
187
187
|
"medium": {
|
|
188
|
-
"model": "
|
|
189
|
-
"variant": "
|
|
188
|
+
"model": "openai/gpt-5.5-fast",
|
|
189
|
+
"variant": "high",
|
|
190
190
|
"costRatio": 5,
|
|
191
|
-
"description": "
|
|
191
|
+
"description": "GPT-5.5 fast default settings for implementation and standard coding",
|
|
192
192
|
"steps": 50,
|
|
193
193
|
"whenToUse": [
|
|
194
194
|
"Feature implementation",
|
|
195
195
|
"Refactoring",
|
|
196
196
|
"Writing tests",
|
|
197
|
-
"Code review",
|
|
198
197
|
"Bug fixes"
|
|
199
198
|
]
|
|
200
199
|
},
|
|
201
200
|
"heavy": {
|
|
202
|
-
"model": "anthropic/claude-opus-4-
|
|
203
|
-
"variant": "
|
|
201
|
+
"model": "anthropic/claude-opus-4-8",
|
|
202
|
+
"variant": "max",
|
|
204
203
|
"costRatio": 20,
|
|
205
|
-
"description": "Claude Opus 4.
|
|
204
|
+
"description": "Claude Opus 4.8 max for architecture, complex debugging, and security",
|
|
206
205
|
"steps": 120,
|
|
207
206
|
"whenToUse": [
|
|
208
207
|
"Architecture decisions",
|