opencode-model-router 2.9.1 → 2.11.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 +482 -0
- package/README.md +4 -2
- package/package.json +12 -5
- package/src/compat/background.ts +56 -19
- package/src/compat/child-history.ts +134 -0
- package/src/compat/child-report.ts +185 -0
- package/src/compat/child-session.ts +10 -0
- package/src/compat/session-lookup.ts +21 -0
- package/src/compat/v2-client.ts +124 -6
- package/src/compat/v2-hooks.ts +525 -203
- package/src/compat/v2-observations.ts +1 -0
- package/src/compat/v2-vocabulary.ts +14 -0
- package/src/executor/create.ts +47 -28
- package/src/executor/git.ts +226 -30
- package/src/executor/integrate/checks.ts +29 -11
- package/src/executor/integrate/land.ts +32 -2
- package/src/executor/integrate/queue.ts +95 -13
- package/src/executor/ledger.ts +16 -12
- package/src/executor/lfs-restore.ts +492 -0
- package/src/executor/paths.ts +7 -2
- package/src/executor/recovery.ts +2 -1
- package/src/executor/runtime.ts +1062 -243
- package/src/executor/slots/pool.ts +120 -19
- package/src/executor/slots/provision.ts +111 -23
- package/src/executor/slots/root.ts +81 -0
- package/src/executor/types.ts +28 -2
- package/src/executor/unattended.ts +6 -1
- package/src/executor/verify-trees.ts +507 -0
- package/src/guard/enforce.ts +2 -1
- package/src/guard/fingerprint.ts +9 -0
- package/src/guard/guards.ts +7 -1
- package/src/index.ts +191 -31
- package/src/router/answer-dedup.ts +198 -0
- package/src/router/common-dir.ts +241 -0
- package/src/router/config.ts +228 -40
- package/src/router/diff-handles.ts +322 -0
- package/src/router/diff-summary.ts +318 -0
- package/src/router/git-metadata-guard.ts +317 -0
- package/src/router/git-tools.ts +1136 -49
- package/src/router/read-only.ts +37 -13
- package/src/router/role-agents.ts +100 -36
- package/src/router/run-summary.ts +253 -0
- package/src/router/run-tools.ts +177 -25
- package/src/router/sessions.ts +23 -1
- package/src/router/tool-paths.ts +62 -4
- package/src/routing/classify/rules.ts +93 -14
- package/src/routing/roles/read-set.ts +10 -1
- package/src/routing/roles/work-root.ts +20 -3
- package/src/routing/wire/hint.ts +9 -2
- package/src/v2.ts +3 -1
- package/src/verify/exec.ts +454 -2
- package/src/verify/head.ts +6 -1
- package/src/verify/pending.ts +14 -1
- package/src/verify/plan-task.ts +86 -26
- package/src/verify/reference.ts +60 -7
- package/src/verify/runner.ts +14 -6
- package/src/verify/tree.ts +34 -10
- package/src/verify/types.ts +44 -0
- package/src/verify/wiring.ts +134 -22
package/src/verify/wiring.ts
CHANGED
|
@@ -64,6 +64,7 @@ import {
|
|
|
64
64
|
import { assessRisk, FULL_SCOPE_PLAN, type FullScopePlan, type RiskAssessment } from "./risk";
|
|
65
65
|
import { resolveBaseDir } from "./paths";
|
|
66
66
|
import { DEFAULT_IDLE_TTL_MS } from "../router/idle-sweep";
|
|
67
|
+
import { gitExecutable, hardeningArgs, workRootGuards } from "../router/git-tools";
|
|
67
68
|
import {
|
|
68
69
|
buildAcceptedSuffix,
|
|
69
70
|
buildForcingNote,
|
|
@@ -101,7 +102,7 @@ import { REFERENCE_NONE } from "./baseline";
|
|
|
101
102
|
import { scrubText } from "../guard/scrub";
|
|
102
103
|
import { displaySafe } from "../routing/roles/read-set";
|
|
103
104
|
import type { DoD } from "./dod";
|
|
104
|
-
import type { ArgvSeam, CheckPlacement, Deadline, ExecOptions, ExecResult as SeamResult, ExecSeam, ReferenceState, TestsPassHook, Verdict } from "./types";
|
|
105
|
+
import type { ArgvSeam, CheckPlacement, Deadline, ExecOptions, ExecResult as SeamResult, ExecSeam, ProcessJournal, ReferenceState, TestsPassHook, Verdict } from "./types";
|
|
105
106
|
import { planScopedRun, planStaticScoping, type ChangedPath, type RunnerFs, type StaticScoping, type StaticScopingInput, type TestSearchSeam } from "./runner";
|
|
106
107
|
import {
|
|
107
108
|
DEFAULT_GATE_BUDGET_MS,
|
|
@@ -180,6 +181,12 @@ export interface PreparedVerification {
|
|
|
180
181
|
service?: ServiceObservation;
|
|
181
182
|
/** Plan-task identity for v2 grader-dispatch failure logs, including when observations are off. */
|
|
182
183
|
graderDispatchLabel?: string;
|
|
184
|
+
/**
|
|
185
|
+
* Recovery-R1-m2 (#190): buildGateDeps links each grader dispatch to the gate's deadline (`dispatchGrader`'s `cancel`), so
|
|
186
|
+
* a cut or timed-out gate also cancels a grader still starting. Plan-task gates opt in; v2 host runner only (the v1
|
|
187
|
+
* `client.session` path ignores it).
|
|
188
|
+
*/
|
|
189
|
+
cancelGradersWithDeadline?: true;
|
|
183
190
|
/**
|
|
184
191
|
* The producer's changed files: the tool-observed paths of every attempt judged against this
|
|
185
192
|
* dispatch (QA-2.1-1), the paths the current snapshot added since dispatch, and the paths dirty
|
|
@@ -227,6 +234,44 @@ export interface PreparedVerification {
|
|
|
227
234
|
* (DeterministicDeps.dispatchStartedAt): only W's ignored modules modified since are cross-link inputs. Absent: none are.
|
|
228
235
|
*/
|
|
229
236
|
dispatchStartedAt?: number;
|
|
237
|
+
/**
|
|
238
|
+
* #189 R2-pre-2 (v2 plan tasks only): the attempt's process journal. With it, buildGateDeps records every root its check
|
|
239
|
+
* seams spawn (ExecOptions.onSpawn/onSettle), so a restart can end the trees a dead server left running. Absent (v1,
|
|
240
|
+
* dispatches): the seams are the plain ones.
|
|
241
|
+
*/
|
|
242
|
+
processJournal?: ProcessJournal;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/** #189 R2-pre-2: the spawn hooks of `opts`, forwarded only when set (the plain seams pass nothing new). */
|
|
246
|
+
function spawnHooksOf(opts: ExecOptions | undefined): Pick<ExecOptions, "onSpawn" | "onExit" | "onSettle"> {
|
|
247
|
+
return {
|
|
248
|
+
...(opts?.onSpawn === undefined ? {} : { onSpawn: opts.onSpawn }),
|
|
249
|
+
...(opts?.onExit === undefined ? {} : { onExit: opts.onExit }),
|
|
250
|
+
...(opts?.onSettle === undefined ? {} : { onSettle: opts.onSettle }),
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* #189 R2-pre-2: `opts` with spawn hooks that record each root in `journal` under `command` (text its command line
|
|
256
|
+
* contains), after any hooks `opts` already carries. A throwing hook never stops the other.
|
|
257
|
+
*/
|
|
258
|
+
export function journaledOptions(opts: ExecOptions | undefined, journal: ProcessJournal, command: string): ExecOptions {
|
|
259
|
+
const outer = spawnHooksOf(opts);
|
|
260
|
+
return {
|
|
261
|
+
...opts,
|
|
262
|
+
onSpawn: (root) => {
|
|
263
|
+
try { outer.onSpawn?.(root); } catch { /* the journal still records the root */ }
|
|
264
|
+
journal.spawned(root, command);
|
|
265
|
+
},
|
|
266
|
+
onExit: (root, exitedAtMs) => {
|
|
267
|
+
try { outer.onExit?.(root, exitedAtMs); } catch { /* the journal still records the exit */ }
|
|
268
|
+
journal.exited(root, exitedAtMs);
|
|
269
|
+
},
|
|
270
|
+
onSettle: (root) => {
|
|
271
|
+
try { outer.onSettle?.(root); } catch { /* the journal still drops the root */ }
|
|
272
|
+
journal.settled(root);
|
|
273
|
+
},
|
|
274
|
+
};
|
|
230
275
|
}
|
|
231
276
|
|
|
232
277
|
/**
|
|
@@ -654,8 +699,13 @@ export type HandleReport =
|
|
|
654
699
|
| { readonly kind: "expired"; readonly handle: string }
|
|
655
700
|
/** Joined another call's run, which outlived this call's deadline (R8). */
|
|
656
701
|
| { readonly kind: "elsewhere"; readonly handle: string; readonly description: string }
|
|
657
|
-
/**
|
|
658
|
-
|
|
702
|
+
/**
|
|
703
|
+
* QA-2.1-9 (phase 2.1): a held background result; its own gate posts the verdict to the session, so nothing ran here.
|
|
704
|
+
* No `description` for a handle that is reserved but not yet registered (the child is still running): nothing is stored yet.
|
|
705
|
+
*/
|
|
706
|
+
| { readonly kind: "held"; readonly handle: string; readonly description?: string }
|
|
707
|
+
/** The call carried no session id, so no handle can be resolved (R6). `input` is the handle, or "pending: true". */
|
|
708
|
+
| { readonly kind: "no-session"; readonly input: string };
|
|
659
709
|
|
|
660
710
|
export interface VerifyReport {
|
|
661
711
|
readonly items: readonly HandleReport[];
|
|
@@ -667,6 +717,9 @@ export interface VerifyReport {
|
|
|
667
717
|
export const ROUTER_VERIFY_ARGS_TEXT =
|
|
668
718
|
"[router] router_verify: pass exactly one of `handles` (a non-empty list of vrf_ handles) or `pending: true`; nothing was run.";
|
|
669
719
|
export const ROUTER_VERIFY_NO_PENDING_TEXT = "[router] router_verify: no unverified delegations in this session; nothing was run.";
|
|
720
|
+
/** R6: handles and the pending list are scoped by the calling session; a call without one can resolve nothing. */
|
|
721
|
+
export const NO_SESSION_TEXT =
|
|
722
|
+
"no session: this call carries no session id, so no handle can be resolved; nothing was run, and retrying will not change the answer";
|
|
670
723
|
export const ROUTER_VERIFY_NO_RETRY_TEXT = "[router] Nothing was retried or escalated; whether to re-dispatch is your call.";
|
|
671
724
|
/** Section 1.5-18. The run always uses the current tree. */
|
|
672
725
|
export const DRIFT_NOTICE = "tree drifted since delegation; verdict reflects current state";
|
|
@@ -815,8 +868,12 @@ export function formatVerifyReport(
|
|
|
815
868
|
blocks.push(`- ${item.handle} \u00b7 ${item.description} \u00b7 ${VERIFYING_ELSEWHERE_TEXT}`);
|
|
816
869
|
continue;
|
|
817
870
|
}
|
|
871
|
+
if (item.kind === "no-session") {
|
|
872
|
+
blocks.push(`- ${sanitizeDescription(item.input)} \u00b7 ${NO_SESSION_TEXT}`);
|
|
873
|
+
continue;
|
|
874
|
+
}
|
|
818
875
|
if (item.kind === "held") {
|
|
819
|
-
blocks.push(`- ${item.handle} \u00b7 ${item.description} \u00b7 ${HELD_RESULT_TEXT}`);
|
|
876
|
+
blocks.push(`- ${item.handle} \u00b7 ${item.description !== undefined ? `${item.description} \u00b7 ` : ""}${HELD_RESULT_TEXT}`);
|
|
820
877
|
continue;
|
|
821
878
|
}
|
|
822
879
|
const { result } = item;
|
|
@@ -872,13 +929,22 @@ export function backgroundOutcomes(items: readonly HandleReport[]): BackgroundOu
|
|
|
872
929
|
: { kind: "reported", handle: item.handle };
|
|
873
930
|
}
|
|
874
931
|
if (item.kind === "elsewhere" || item.kind === "held") return { kind: "reported", handle: item.handle };
|
|
875
|
-
return { kind: "gone", handle: item.kind === "unknown" ? item.input : item.handle };
|
|
932
|
+
return { kind: "gone", handle: item.kind === "unknown" || item.kind === "no-session" ? item.input : item.handle };
|
|
876
933
|
});
|
|
877
934
|
}
|
|
878
935
|
|
|
879
936
|
/** QA-2.1-11: how often a lease wait that ignores the producer's own holder probes the tree again. */
|
|
880
937
|
const LEASE_WAIT_POLL_MS = 100;
|
|
881
938
|
|
|
939
|
+
/**
|
|
940
|
+
* #191 (v2 only): whether a gate's check waits for the lease gate. A lease gate scoped to held results (`"held"`,
|
|
941
|
+
* `routing.background.mode: "off"`) is waited for by the gate of a background finish only, so a foreground check keeps the
|
|
942
|
+
* timing and result it had without one; unscoped, by every check. Pure.
|
|
943
|
+
*/
|
|
944
|
+
export function leaseWaitApplies(scope: "held" | undefined, backgroundFinish: boolean): boolean {
|
|
945
|
+
return scope !== "held" || backgroundFinish;
|
|
946
|
+
}
|
|
947
|
+
|
|
882
948
|
/**
|
|
883
949
|
* QA-2.1-11 (phase 2.1, v2 only): waits until no holder of `tree` other than the sessions in `exclude` edits it, or `deadlineMs`
|
|
884
950
|
* passes. The producer's own leases stay until its completion is processed, after this gate, so waiting for them only delays
|
|
@@ -1060,7 +1126,7 @@ export interface VerificationWiring {
|
|
|
1060
1126
|
applyLineage(res: GateResult, ctx: LineageContext): GateResult;
|
|
1061
1127
|
/**
|
|
1062
1128
|
* 2.4.3a, section 1.5-18: router_verify for `sessionID` (the calling orchestrator; "" = none, so
|
|
1063
|
-
* every handle is
|
|
1129
|
+
* every handle and `pending` is answered "no session"). Never rejects; never retries or escalates.
|
|
1064
1130
|
* - Handles are normalized, deduped and capped at MAX_HANDLES_PER_CALL; `pending` is listOpen, so
|
|
1065
1131
|
* runs already in flight are joined (R8). Lookups are scoped by session (R6).
|
|
1066
1132
|
* - ONE Deadline of gateBudgetMs per call, created before any preparation (section 1.5-13) and
|
|
@@ -1144,7 +1210,7 @@ export interface VerificationWiring {
|
|
|
1144
1210
|
* the changed files are "unavailable" and the reference is the untracked default. `deadline`
|
|
1145
1211
|
* bounds every testsPass step (T3); without it each testsPass check owns one of gateBudgetMs.
|
|
1146
1212
|
*/
|
|
1147
|
-
buildGateDeps(parentSessionID?: string, inFlight?: Set<string>, prepared?: PreparedVerification, deadline?: Deadline, forceLowPriority?: boolean, creatorSessionID?: string | null, serviceIdentity?: () => ServiceIdentity): GateDeps;
|
|
1213
|
+
buildGateDeps(parentSessionID?: string, inFlight?: Set<string>, prepared?: PreparedVerification, deadline?: Deadline, forceLowPriority?: boolean, creatorSessionID?: string | null, serviceIdentity?: () => ServiceIdentity, backgroundFinish?: boolean): GateDeps;
|
|
1148
1214
|
/**
|
|
1149
1215
|
* 2.2.3: the idle-TTL sweep's hook into the plugin's one S5 batch coordinator (batch.ts B11):
|
|
1150
1216
|
* evicts windows with no live member and batches whose seam hung past BATCH_STALE_GRACE_MS.
|
|
@@ -1216,6 +1282,11 @@ export function createVerificationWiring(deps: {
|
|
|
1216
1282
|
* Plugin verification runs in a tree wait for its holders first.
|
|
1217
1283
|
*/
|
|
1218
1284
|
leaseGate?: Pick<import("../compat/background").LeaseGuard, "waitTreeFree">;
|
|
1285
|
+
/**
|
|
1286
|
+
* #191 (v2 only): read per gate. `"held"` (`routing.background.mode: "off"`): only a background finish (`buildGateDeps`
|
|
1287
|
+
* `backgroundFinish`) waits for `leaseGate`; absent: every check does (`leaseWaitApplies`).
|
|
1288
|
+
*/
|
|
1289
|
+
leaseGateScope?: () => "held" | undefined;
|
|
1219
1290
|
/** Test seams of the 2.4.5 background queue; used only when `background` is true. */
|
|
1220
1291
|
background?: Pick<BackgroundQueueOptions, "now" | "timers" | "settleMs" | "retryBaseMs" | "maxAttempts" | "platform">;
|
|
1221
1292
|
}): VerificationWiring {
|
|
@@ -1314,6 +1385,7 @@ export function createVerificationWiring(deps: {
|
|
|
1314
1385
|
const abs = (p: string): string => (isAbsolute(p) ? p : join(directory, p));
|
|
1315
1386
|
|
|
1316
1387
|
// QA-1.2-13: lowPriority and env reach the process; no per-call maxBuffer (QA-1.5-25).
|
|
1388
|
+
// #189 R2-pre-2: the spawn hooks reach it too (set only by a plan-task gate's journaled seams, see buildGateDeps).
|
|
1317
1389
|
const execSeam: ExecSeam = (command: string, opts?: ExecOptions): Promise<ExecResult> =>
|
|
1318
1390
|
runShell(command, {
|
|
1319
1391
|
cwd: opts?.cwd ?? directory,
|
|
@@ -1322,6 +1394,7 @@ export function createVerificationWiring(deps: {
|
|
|
1322
1394
|
lowPriority: opts?.lowPriority,
|
|
1323
1395
|
env: opts?.env,
|
|
1324
1396
|
...(opts?.service === undefined ? {} : { service: opts.service }),
|
|
1397
|
+
...spawnHooksOf(opts),
|
|
1325
1398
|
});
|
|
1326
1399
|
|
|
1327
1400
|
const argvSeam: ArgvSeam = (file, args, opts) =>
|
|
@@ -1332,6 +1405,7 @@ export function createVerificationWiring(deps: {
|
|
|
1332
1405
|
lowPriority: opts?.lowPriority,
|
|
1333
1406
|
env: opts?.env,
|
|
1334
1407
|
...(opts?.service === undefined ? {} : { service: opts.service }),
|
|
1408
|
+
...spawnHooksOf(opts),
|
|
1335
1409
|
});
|
|
1336
1410
|
|
|
1337
1411
|
// T9 1.3: PlannerFs + unlink over fs.promises. realpath is the native one; fileExists accepts
|
|
@@ -1382,7 +1456,9 @@ export function createVerificationWiring(deps: {
|
|
|
1382
1456
|
const timeoutMs = deadline ? deadline.bound(COMMIT_DIFF_TIMEOUT_MS) : COMMIT_DIFF_TIMEOUT_MS;
|
|
1383
1457
|
if (timeoutMs <= 0 || deadline?.signal.aborted) return "unavailable";
|
|
1384
1458
|
try {
|
|
1385
|
-
|
|
1459
|
+
// #141 (#77 G4): git by absolute path from outside the work root, never looked up in it; hardeningArgs() carries
|
|
1460
|
+
// --no-optional-locks. A refused or missing executable throws here: "unavailable", as a failed spawn.
|
|
1461
|
+
const r = await argvSeam(gitExecutable(workRootGuards(root)), [...hardeningArgs(), "-C", root, "diff", "--name-status", "-z", "-M", before.head, "HEAD"], {
|
|
1386
1462
|
cwd: root,
|
|
1387
1463
|
timeoutMs,
|
|
1388
1464
|
lowPriority: resolveVerifyBudget(getConfig()).lowPriority,
|
|
@@ -1395,13 +1471,16 @@ export function createVerificationWiring(deps: {
|
|
|
1395
1471
|
}
|
|
1396
1472
|
};
|
|
1397
1473
|
|
|
1398
|
-
/**
|
|
1474
|
+
/**
|
|
1475
|
+
* T9 1.3: the planners' git searches through the argv seam; no shell, no optional locks. #141: git by absolute path from
|
|
1476
|
+
* outside the work root (`gitExecutable(workRootGuards(root))`) with `hardeningArgs()`, as the router's git tools.
|
|
1477
|
+
*/
|
|
1399
1478
|
const testSearch = (budget: VerifyBudget, deadline: Deadline | undefined): TestSearchSeam => {
|
|
1400
1479
|
const git = async (root: string, args: readonly string[]): Promise<SeamResult | undefined> => {
|
|
1401
1480
|
const timeoutMs = deadline ? deadline.bound(TEST_SEARCH_TIMEOUT_MS) : TEST_SEARCH_TIMEOUT_MS;
|
|
1402
1481
|
if (timeoutMs <= 0 || deadline?.signal.aborted) return undefined;
|
|
1403
1482
|
try {
|
|
1404
|
-
const r = await argvSeam(
|
|
1483
|
+
const r = await argvSeam(gitExecutable(workRootGuards(root)), [...hardeningArgs(), "-C", root, ...args], {
|
|
1405
1484
|
cwd: root,
|
|
1406
1485
|
timeoutMs,
|
|
1407
1486
|
lowPriority: budget.lowPriority,
|
|
@@ -1487,12 +1566,18 @@ export function createVerificationWiring(deps: {
|
|
|
1487
1566
|
creatorSessionID: string | null = parentSessionID ?? null,
|
|
1488
1567
|
service?: ServiceObservation,
|
|
1489
1568
|
graderDispatchLabel?: string,
|
|
1569
|
+
/**
|
|
1570
|
+
* Recovery-R1-m2 (#190): ends the dispatch with its caller's gate (buildGateDeps passes the deadline's signal when the
|
|
1571
|
+
* prepared verification opts in). Already aborted: no session is created. v2 host runner only; v1 ignores it.
|
|
1572
|
+
*/
|
|
1573
|
+
cancel?: AbortSignal,
|
|
1490
1574
|
): Promise<{ sessionID: string; text: string; model: string | null }> => {
|
|
1491
1575
|
// #84 P3.3 fix 2: the model the grader is dispatched on travels with its answer (checker.ts GraderResult.model → the
|
|
1492
1576
|
// verdict's `grader`), so the outcome signals can check its independence (plan §2.6). Null: the host's default model.
|
|
1493
1577
|
const modelRef = (model: { providerID: string; modelID: string } | null): string | null =>
|
|
1494
1578
|
model === null ? null : `${model.providerID}/${model.modelID}`;
|
|
1495
1579
|
if (deps.childRunner) {
|
|
1580
|
+
cancel?.throwIfAborted();
|
|
1496
1581
|
const cfg = getConfig();
|
|
1497
1582
|
const controller = new AbortController();
|
|
1498
1583
|
const model = tierModel(cfg, req.tier);
|
|
@@ -1505,7 +1590,7 @@ export function createVerificationWiring(deps: {
|
|
|
1505
1590
|
model: model ?? undefined,
|
|
1506
1591
|
system: req.system,
|
|
1507
1592
|
prompt: req.prompt,
|
|
1508
|
-
signal: controller.signal,
|
|
1593
|
+
signal: cancel === undefined ? controller.signal : AbortSignal.any([controller.signal, cancel]),
|
|
1509
1594
|
...(service === undefined ? {} : { service, onServiceStart: () => preparation?.end("completed") }),
|
|
1510
1595
|
async onCreated(sessionID) {
|
|
1511
1596
|
sid = sessionID;
|
|
@@ -1626,6 +1711,8 @@ export function createVerificationWiring(deps: {
|
|
|
1626
1711
|
forceLowPriority = false,
|
|
1627
1712
|
creatorSessionID: string | null = parentSessionID ?? null,
|
|
1628
1713
|
serviceIdentity?: () => ServiceIdentity,
|
|
1714
|
+
// #191: the gate of a background finish (held or not); see `leaseWaitApplies`.
|
|
1715
|
+
backgroundFinish = false,
|
|
1629
1716
|
): GateDeps => {
|
|
1630
1717
|
// A plan task's prepared verification already carries its service span; native dispatches carry none.
|
|
1631
1718
|
const service = serviceIdentity === undefined ? prepared?.service : serviceObservation(deps.observations, serviceIdentity);
|
|
@@ -1634,15 +1721,20 @@ export function createVerificationWiring(deps: {
|
|
|
1634
1721
|
// 2.4.5 (section 1.5-19): background runs are low priority whatever `lowPriority` says.
|
|
1635
1722
|
// QA-2.4-5: and they never wait for the slot (waitMs 0): busy means back off and retry later.
|
|
1636
1723
|
const budget: VerifyBudget = forceLowPriority ? { ...resolved, lowPriority: true, slotWaitMs: 0 } : resolved;
|
|
1724
|
+
// #189 R2-pre-2 (v2 plan tasks): with a process journal, every root the check seams spawn is recorded in it (the
|
|
1725
|
+
// shell command or the executable as the text its command line contains); without one, the plain seams.
|
|
1726
|
+
const journal = prepared?.processJournal;
|
|
1727
|
+
const gateExec: ExecSeam = journal === undefined ? execSeam : (command, opts) => execSeam(command, journaledOptions(opts, journal, command));
|
|
1728
|
+
const gateArgv: ArgvSeam = journal === undefined ? argvSeam : (file, args, opts) => argvSeam(file, args, journaledOptions(opts, journal, file));
|
|
1637
1729
|
// QA-2.1-5: the recheck's git processes (GC, materialize, dispose) run at the configured
|
|
1638
1730
|
// priority too, like the capture and the start-up GC (QA-1.2-13).
|
|
1639
|
-
const referenceArgv: ArgvSeam = (file, args, opts) =>
|
|
1731
|
+
const referenceArgv: ArgvSeam = (file, args, opts) => gateArgv(file, args, { ...opts, lowPriority: budget.lowPriority });
|
|
1640
1732
|
// QA-2 nit: materialize pins a link target as this gate's dispatch admitted it (its pins' admission); without pins, none.
|
|
1641
1733
|
const gatePins = prepared?.reference?.kind === "captured" ? prepared.reference.reference.pins : undefined;
|
|
1642
1734
|
const pinNow = pinNowFor(gatePins !== undefined ? pinAdmissions.get(gatePins) : undefined);
|
|
1643
1735
|
const openScope = createScopeOpener({
|
|
1644
1736
|
service,
|
|
1645
|
-
argv:
|
|
1737
|
+
argv: gateArgv, exec: gateExec, fs: fsSeam, budget, checkTimeoutMs: CHECK_TIMEOUT_MS,
|
|
1646
1738
|
reference: { argv: referenceArgv, pinNow },
|
|
1647
1739
|
});
|
|
1648
1740
|
const currentTree = prepared?.snapshot !== undefined ? { currentTree: prepared.snapshot } : {};
|
|
@@ -1694,8 +1786,9 @@ export function createVerificationWiring(deps: {
|
|
|
1694
1786
|
try {
|
|
1695
1787
|
void background?.preempt();
|
|
1696
1788
|
// Phase 2.1 (v2, leases on): wait for the holders of the tree, within a quarter of the gate budget; then run
|
|
1697
|
-
// anyway, with the concurrent-dispatches caveat for the holders that remain.
|
|
1698
|
-
|
|
1789
|
+
// anyway, with the concurrent-dispatches caveat for the holders that remain. #191: a lease gate scoped to held results
|
|
1790
|
+
// is waited for by a background finish only.
|
|
1791
|
+
if (deps.leaseGate !== undefined && leaseWaitApplies(deps.leaseGateScope?.(), backgroundFinish)) {
|
|
1699
1792
|
const leaseWait = service?.start("service-wait", "lease");
|
|
1700
1793
|
try {
|
|
1701
1794
|
// QA-2.1-11: the producer's own leases never delay its own check.
|
|
@@ -1725,11 +1818,11 @@ export function createVerificationWiring(deps: {
|
|
|
1725
1818
|
return {
|
|
1726
1819
|
deterministic: {
|
|
1727
1820
|
...(service === undefined ? {} : { service }),
|
|
1728
|
-
exec:
|
|
1821
|
+
exec: gateExec,
|
|
1729
1822
|
fs: fsSeam,
|
|
1730
1823
|
cwd: directory,
|
|
1731
1824
|
mutex,
|
|
1732
|
-
argv:
|
|
1825
|
+
argv: gateArgv,
|
|
1733
1826
|
budget,
|
|
1734
1827
|
openScope,
|
|
1735
1828
|
testsPass,
|
|
@@ -1741,8 +1834,10 @@ export function createVerificationWiring(deps: {
|
|
|
1741
1834
|
...(prepared?.dispatchStartedAt !== undefined ? { dispatchStartedAt: prepared.dispatchStartedAt } : {}),
|
|
1742
1835
|
},
|
|
1743
1836
|
checker: {
|
|
1837
|
+
// Recovery-R1-m2 (#190): an opted-in gate (plan-task) cancels its graders with its deadline (cut, timeout, expiry).
|
|
1744
1838
|
dispatchGrader: (req: GraderRequest) =>
|
|
1745
|
-
dispatchGrader(req, parentSessionID, inFlight, creatorSessionID, service, prepared?.graderDispatchLabel
|
|
1839
|
+
dispatchGrader(req, parentSessionID, inFlight, creatorSessionID, service, prepared?.graderDispatchLabel,
|
|
1840
|
+
prepared?.cancelGradersWithDeadline === true ? deadline?.signal : undefined),
|
|
1746
1841
|
ladder: ["fast", "medium", "heavy"],
|
|
1747
1842
|
minGraderTier: cfg.enforcement?.verify?.minGraderTier ?? null,
|
|
1748
1843
|
},
|
|
@@ -3475,7 +3570,12 @@ export function createVerificationWiring(deps: {
|
|
|
3475
3570
|
let targets: Array<{ readonly input: string; readonly handle: string | undefined }> = [];
|
|
3476
3571
|
if (target.kind === "pending") {
|
|
3477
3572
|
// QA-2.4-3: listPending adds the background verdicts not yet replayed (a cached replay, no run).
|
|
3478
|
-
|
|
3573
|
+
// R6: without a session there is nothing to list; "no unverified delegations in this session" would read as "not yet".
|
|
3574
|
+
if (sessionID === "") {
|
|
3575
|
+
const item: HandleReport = { kind: "no-session", input: "pending: true" };
|
|
3576
|
+
return { items: [item], excess: 0, text: formatVerifyReport([item], 0, false) };
|
|
3577
|
+
}
|
|
3578
|
+
targets = pending.listPending(sessionID, { verifying: true }).map(e => ({ input: e.handle, handle: e.handle }));
|
|
3479
3579
|
if (targets.length === 0) return { items: [], excess: 0, text: ROUTER_VERIFY_NO_PENDING_TEXT };
|
|
3480
3580
|
} else {
|
|
3481
3581
|
const seen = new Set<string>();
|
|
@@ -3488,7 +3588,8 @@ export function createVerificationWiring(deps: {
|
|
|
3488
3588
|
targets.push({ input, handle });
|
|
3489
3589
|
}
|
|
3490
3590
|
}
|
|
3491
|
-
|
|
3591
|
+
// Without a session every handle gets the same terminal answer, so there is no "rest" to call again with.
|
|
3592
|
+
const excess = sessionID === "" ? 0 : Math.max(0, targets.length - MAX_HANDLES_PER_CALL);
|
|
3492
3593
|
targets = targets.slice(0, MAX_HANDLES_PER_CALL);
|
|
3493
3594
|
|
|
3494
3595
|
// 2. The call's one deadline (section 1.5-13), before any preparation.
|
|
@@ -3514,8 +3615,12 @@ export function createVerificationWiring(deps: {
|
|
|
3514
3615
|
const cwds = new Map<string, string>();
|
|
3515
3616
|
try {
|
|
3516
3617
|
for (const t of targets) {
|
|
3517
|
-
if (
|
|
3518
|
-
slots.push({ kind: "
|
|
3618
|
+
if (sessionID === "") {
|
|
3619
|
+
slots.push({ kind: "no-session", input: t.handle ?? t.input });
|
|
3620
|
+
continue;
|
|
3621
|
+
}
|
|
3622
|
+
if (t.handle === undefined) {
|
|
3623
|
+
slots.push({ kind: "unknown", input: t.input });
|
|
3519
3624
|
continue;
|
|
3520
3625
|
}
|
|
3521
3626
|
// QA-2.1-9 (phase 2.1, v2 only): a held entry is verified by its background gate, which posts the verdict to the
|
|
@@ -3528,6 +3633,13 @@ export function createVerificationWiring(deps: {
|
|
|
3528
3633
|
slots.push({ kind: "held", handle: looked.entry.handle, description: looked.entry.description });
|
|
3529
3634
|
continue;
|
|
3530
3635
|
}
|
|
3636
|
+
// A handle reserved at the background ack is shown to the orchestrator every turn but registered only when the child
|
|
3637
|
+
// finishes: until then it is held, not unknown. Only the session it was reserved for may see that (R6): another
|
|
3638
|
+
// session's reservation stays unknown. The verdict is replayed through the entry once it is registered and settled.
|
|
3639
|
+
if (looked.kind === "unknown" && pending.reservedBy(t.handle) === sessionID) {
|
|
3640
|
+
slots.push({ kind: "held", handle: t.handle });
|
|
3641
|
+
continue;
|
|
3642
|
+
}
|
|
3531
3643
|
const c = pending.markVerifying(sessionID, t.handle);
|
|
3532
3644
|
if (c.kind === "unknown") slots.push({ kind: "unknown", input: t.handle });
|
|
3533
3645
|
else if (c.kind === "expired") slots.push({ kind: "expired", handle: c.handle });
|