opencode-model-router 2.9.0 → 2.10.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.
@@ -421,7 +421,12 @@ export const PENDING_LIST_LIMIT = 5;
421
421
  export const FOOTER_MAX_REASONS = 3;
422
422
  export const LATE_NOTICE_MAX_IDS = 10;
423
423
 
424
- export const UNKNOWN_HANDLE_TEXT = "unknown handle";
424
+ /**
425
+ * Terminal and cause-neutral (R6): the registry cannot tell a handle that was never issued here, one issued to another
426
+ * session, and one lost to a restart or an eviction. Re-asking cannot change the answer, and the text says so.
427
+ */
428
+ export const UNKNOWN_HANDLE_TEXT =
429
+ "unknown handle: this session has no record of it (never issued here, issued to another session, or no longer tracked after a restart, eviction or a failed background run); retrying will not change the answer";
425
430
  export const EXPIRED_HANDLE_TEXT = "expired handle: older than pendingTtlMs or evicted; it can no longer be verified";
426
431
  export const VERIFYING_ELSEWHERE_TEXT =
427
432
  "still being verified by another router_verify call; call again for its verdict";
@@ -803,6 +808,11 @@ export interface PendingRegistry {
803
808
  reserveHandle(sessionID: string): string | undefined;
804
809
  /** Gives a reserved handle back (the ack failed, or the dispatch is not held after all). */
805
810
  releaseHandle(handle: string): void;
811
+ /**
812
+ * The session a handle is reserved for (drawn by `reserveHandle`, not yet registered or released), else undefined. Callers
813
+ * must compare it with the calling session: another session's reservation is never revealed (R6).
814
+ */
815
+ reservedBy(handle: string): string | undefined;
806
816
  /** The entry registered under `dispatchID` (callID), if still stored. */
807
817
  findByDispatch(dispatchID: string): PendingEntry | undefined;
808
818
  /** The session's "held" entries, newest first (they are never listed by listPending). */
@@ -2983,6 +2993,9 @@ export function createPendingRegistry(options: PendingRegistryOptions): PendingR
2983
2993
  releaseHandle(handle) {
2984
2994
  unreserve(handle);
2985
2995
  },
2996
+ reservedBy(handle) {
2997
+ return reserved.get(handle);
2998
+ },
2986
2999
  hasSlot,
2987
3000
  findByDispatch(dispatchID) {
2988
3001
  const rec = byDispatch.get(dispatchID);
@@ -142,7 +142,15 @@
142
142
  // AbortSignal.any([signal, AbortSignal.timeout(remaining)]).
143
143
  // Every git call in this module runs as `git --no-optional-locks ...`
144
144
  // (QA-1.5-2), so a read-only call never refreshes, and so never rewrites,
145
- // the user's index.
145
+ // the user's index. Right after that flag comes git-tools workRootReadArgs()
146
+ // (no fsmonitor, null-device hooksPath, no ssh key command, no transport);
147
+ // a later `-c core.hooksPath=` (D9's worktree add) still wins. Capture and
148
+ // materialize also blank the filter/merge drivers only the repository's own
149
+ // configuration names, include targets of any condition too, with
150
+ // filter.<name>.required=true so a blanked filter makes git refuse instead of
151
+ // writing unfiltered content (git-tools collectRepositoryDriverArgs); every
152
+ // call runs with GIT_NO_LAZY_FETCH=1. A configuration that cannot be read
153
+ // means no reference.
146
154
  // 1. `git rev-parse --show-toplevel` (cwd: the dispatch cwd) -> root. A
147
155
  // non-zero exit (outside a repository, or a bare repository) returns
148
156
  // undefined.
@@ -735,6 +743,7 @@ import { gitTopOf, perimeterKey } from "./git-top";
735
743
  // Type-only: pin.ts imports perimeter.ts, which imports this module; samePin is loaded lazily in step 7.
736
744
  import type { LinkPin, PinWhy } from "./pin";
737
745
  import type { PluginLogger } from "../router/logger";
746
+ import { collectRepositoryDriverArgs, gitExecutable, workRootGuards, workRootReadArgs } from "../router/git-tools";
738
747
 
739
748
  // --- Seams --------------------------------------------------------------------
740
749
 
@@ -1308,6 +1317,8 @@ interface GitRun {
1308
1317
  readonly signal?: AbortSignal;
1309
1318
  /** Merged over process.env by the seam. */
1310
1319
  readonly env?: Record<string, string>;
1320
+ /** `-c` pairs placed after the work-root read prefix and before `args`: the repository-only driver blanking. */
1321
+ readonly config?: readonly string[];
1311
1322
  }
1312
1323
 
1313
1324
  /** Overrides for the pathspec environment switches git would otherwise inherit (QA-1.5-18). */
@@ -1349,6 +1360,9 @@ function stdoutTruncated(result: ExecResult): boolean {
1349
1360
  * A truncated stdout (QA-1.5-21) comes back as a failed call (code -1): the
1350
1361
  * seam's trailing stdout note in stderr (stdoutTruncated), or a non-empty
1351
1362
  * `-z` output that does not end in NUL. Every caller parses stdout only after `code === 0`.
1363
+ * #141 (#77 G4): git by absolute path from outside the work-root guards of `run.cwd`, never a
1364
+ * bare `git` that Windows may resolve from the (model-writable) cwd; a refused or missing
1365
+ * executable is a failed call (code -1), with nothing spawned.
1352
1366
  */
1353
1367
  async function runGit(argv: ArgvSeam, args: readonly string[], run: GitRun): Promise<ExecResult | undefined> {
1354
1368
  if (run.timeoutMs <= 0 || run.signal?.aborted) return undefined;
@@ -1356,9 +1370,11 @@ async function runGit(argv: ArgvSeam, args: readonly string[], run: GitRun): Pro
1356
1370
  if (run.signal) opts.signal = run.signal;
1357
1371
  // QA-1.5-18: pathspec env switches (literal/glob/noglob/icase) change what every pathspec
1358
1372
  // means; git reads them as booleans, so "0" neutralises them whatever the plugin inherited.
1359
- opts.env = { ...PATHSPEC_ENV_RESET, ...run.env };
1373
+ // GIT_NO_LAZY_FETCH (git >= 2.44): a partial clone's missing object fails the call instead of fetching it.
1374
+ opts.env = { ...PATHSPEC_ENV_RESET, GIT_NO_LAZY_FETCH: "1", ...run.env };
1360
1375
  try {
1361
- const result = await argv("git", ["--no-optional-locks", ...args], opts);
1376
+ // workRootReadArgs() before the caller's args, so a later `-c core.hooksPath=<noHooks>` (D9) wins over its null device.
1377
+ const result = await argv(gitExecutable(workRootGuards(run.cwd)), ["--no-optional-locks", ...workRootReadArgs(), ...(run.config ?? []), ...args], opts);
1362
1378
  if (result.timedOut || run.signal?.aborted) return undefined;
1363
1379
  // QA-1.5-21: the p12 seam keeps exit code 0 when it cuts stdout at maxBuffer.
1364
1380
  const cut =
@@ -1374,6 +1390,29 @@ async function runGit(argv: ArgvSeam, args: readonly string[], run: GitRun): Pro
1374
1390
  }
1375
1391
  }
1376
1392
 
1393
+ /**
1394
+ * The `-c` pairs that blank the filter/merge drivers (and set the protocols to `never`) only `root`'s own configuration names,
1395
+ * include targets of any condition too (git-tools collectRepositoryDriverArgs), read through the seam, in the environment of
1396
+ * the reference's own git calls, which reads the user's system/global configuration as plain git does: a global LFS filter
1397
+ * and its `git lfs install --local` copy are kept. `required=true`: the reference writes (stash create, the checkout), so a
1398
+ * blanked filter makes git refuse instead of storing or checking out unfiltered content. Undefined when the configuration
1399
+ * cannot be read, the budget is spent, a key cannot be blanked, or the environment carries the legacy GIT_CONFIG (which would
1400
+ * replace the repository's configuration in the listing alone): the caller has no reference (fail closed).
1401
+ */
1402
+ async function repositoryDrivers(argv: ArgvSeam, root: string, budget: Budget): Promise<readonly string[] | undefined> {
1403
+ if (budget.spent() || Object.keys(process.env).some((key) => key.toUpperCase() === "GIT_CONFIG")) return undefined;
1404
+ const query = async (args: readonly string[]) => {
1405
+ const result = budget.spent() ? undefined : await runGit(argv, args, { cwd: root, timeoutMs: budget.remaining(), signal: budget.signal });
1406
+ if (!result || budget.spent()) throw new Error("the driver configuration could not be read in time");
1407
+ return result;
1408
+ };
1409
+ try {
1410
+ return await collectRepositoryDriverArgs(query, root, { required: true });
1411
+ } catch {
1412
+ return undefined;
1413
+ }
1414
+ }
1415
+
1377
1416
  function isAliveDefault(pid: number): boolean {
1378
1417
  try {
1379
1418
  process.kill(pid, 0);
@@ -1585,15 +1624,20 @@ async function captureInner(cwd: string, signal: AbortSignal, deps: CaptureDeps)
1585
1624
  const platform = process.platform;
1586
1625
  const p = pathFor(platform);
1587
1626
  const budget = makeBudget(signal, deps.timeoutMs ?? DEFAULT_CAPTURE_TIMEOUT_MS);
1627
+ let config: readonly string[] = [];
1588
1628
  const git = async (args: readonly string[], at: string) => {
1589
1629
  if (budget.spent()) return undefined;
1590
- const result = await runGit(deps.argv, args, { cwd: at, timeoutMs: budget.remaining(), signal: budget.signal });
1630
+ const result = await runGit(deps.argv, args, { cwd: at, timeoutMs: budget.remaining(), signal: budget.signal, config });
1591
1631
  return result && result.code === 0 && !budget.spent() ? result : undefined;
1592
1632
  };
1593
1633
 
1594
1634
  const top = await git(["rev-parse", "--show-toplevel"], cwd);
1595
1635
  if (!top) return undefined;
1596
1636
  const root = p.resolve(stripNewline(top.stdout));
1637
+ // `stash create` hashes the working tree through the clean filters: blank the repository-only ones first.
1638
+ const drivers = await repositoryDrivers(deps.argv, root, budget);
1639
+ if (drivers === undefined) return undefined;
1640
+ config = drivers;
1597
1641
  const stage = await git(["ls-files", "--stage"], root);
1598
1642
  if (!stage || /^160000 /m.test(stage.stdout)) return undefined;
1599
1643
  // Section 2f (QA-1.5-6): neither stash create nor the drift diff sees an edit to an
@@ -1619,6 +1663,7 @@ async function captureInner(cwd: string, signal: AbortSignal, deps: CaptureDeps)
1619
1663
  cwd: root,
1620
1664
  timeoutMs: budget.remaining(),
1621
1665
  env: { GIT_INDEX_FILE: copy },
1666
+ config,
1622
1667
  });
1623
1668
  return stash && stash.code === 0 && !budget.spent() ? stash.stdout.trim() : undefined;
1624
1669
  });
@@ -1807,8 +1852,9 @@ export async function materialize(
1807
1852
  await cleanup();
1808
1853
  return fail(reason, detail);
1809
1854
  };
1855
+ let config: readonly string[] = [];
1810
1856
  const git = async (args: readonly string[]) =>
1811
- budget.spent() ? undefined : runGit(deps.argv, args, { cwd: root, timeoutMs: budget.remaining(), signal: budget.signal });
1857
+ budget.spent() ? undefined : runGit(deps.argv, args, { cwd: root, timeoutMs: budget.remaining(), signal: budget.signal, config });
1812
1858
 
1813
1859
  try {
1814
1860
  // 0. Same-repository guard.
@@ -1819,6 +1865,12 @@ export async function materialize(
1819
1865
  return fail("error", "currentTree is not inside the reference repository");
1820
1866
  }
1821
1867
  }
1868
+ // 0b. The checkout (smudge) and the drift diff (clean) run filters: blank the repository-only ones for every call, in the
1869
+ // live repository and in the reference worktree (which shares its configuration).
1870
+ const drivers = await repositoryDrivers(deps.argv, root, budget);
1871
+ if (budget.spent()) return fail("aborted", "aborted before the worktree was created");
1872
+ if (drivers === undefined) return fail("error", "the repository's filter/merge driver configuration cannot be read");
1873
+ config = drivers;
1822
1874
  // 1. The unreferenced stash commit may have been pruned (section 8).
1823
1875
  const exists = await git(["cat-file", "-e", `${ref.commit}^{commit}`]);
1824
1876
  if (budget.spent()) return fail("aborted", "aborted before the worktree was created");
@@ -1869,7 +1921,7 @@ export async function materialize(
1869
1921
  "-c", `core.hooksPath=${noHooks}`,
1870
1922
  "-c", "advice.detachedHead=false",
1871
1923
  "worktree", "add", "--detach", ...lock, candidate, ref.commit,
1872
- ], { cwd: root, timeoutMs: budget.remaining(), signal: budget.signal, env: { LC_ALL: "C" } });
1924
+ ], { cwd: root, timeoutMs: budget.remaining(), signal: budget.signal, env: { LC_ALL: "C" }, config });
1873
1925
  let added = await add(["--lock", "--reason", referenceLockReason(deps.pid ?? process.pid)]);
1874
1926
  if (added && added.code !== 0 && !budget.spent() && ADD_LOCK_UNSUPPORTED.test(added.stderr)) {
1875
1927
  // git < 2.33: the option parser failed before anything was written; the dir must still be empty.
@@ -2014,7 +2066,7 @@ export async function materialize(
2014
2066
  ...(only.length > 0 ? ["--literal-pathspecs"] : []),
2015
2067
  "-c", "core.splitIndex=false", "diff", "--name-only", "-z", "--no-renames", "--no-ext-diff", ref.commit, "--", ...only,
2016
2068
  ], {
2017
- cwd: root, timeoutMs: budget.remaining(), signal: budget.signal, env: { GIT_INDEX_FILE: copy },
2069
+ cwd: root, timeoutMs: budget.remaining(), signal: budget.signal, env: { GIT_INDEX_FILE: copy }, config,
2018
2070
  }));
2019
2071
  const diff = await driftDiff();
2020
2072
  const nowUntracked = await git(["ls-files", "--others", "--exclude-standard", "-z"]);
@@ -2124,6 +2176,7 @@ export async function materialize(
2124
2176
  cwd,
2125
2177
  timeoutMs: budget.remaining(),
2126
2178
  signal,
2179
+ config,
2127
2180
  });
2128
2181
  return listed && listed.code === 0 ? parseEolList(listed.stdout) : undefined;
2129
2182
  };
@@ -23,7 +23,10 @@ export interface SnapshotGitOptions {
23
23
  readonly lowPriority: boolean;
24
24
  /** Cross-repo QA-1 F4 (SnapshotOptions.hardened): the environment git runs with. Absent: the process's own (unchanged). */
25
25
  readonly env?: NodeJS.ProcessEnv;
26
- /** Cross-repo QA-1 F4: the git executable, by absolute path. Absent: `git`, looked up as before. */
26
+ /**
27
+ * Cross-repo QA-1 F4: the git executable, by absolute path. Absent (#141, #77 G4): the router's git outside the work-root
28
+ * guards of `cwd` (`gitExecutable(workRootGuards(cwd))`), never a bare `git` that Windows may resolve from `cwd`.
29
+ */
27
30
  readonly executable?: string;
28
31
  }
29
32
 
@@ -98,12 +101,14 @@ export const execGit: SnapshotGit = (args, opts) => new Promise<string>((ok, fai
98
101
  return;
99
102
  }
100
103
  const nice = opts.lowPriority && !isWin;
101
- const git = opts.executable ?? "git";
102
104
  let child: ChildProcess;
103
105
  try {
106
+ // #141: a refused or missing executable throws here and rejects like a spawn error, with nothing spawned.
107
+ const git = opts.executable ?? tools.gitExecutable(tools.workRootGuards(opts.cwd));
108
+ // GIT_NO_LAZY_FETCH (git >= 2.44): a partial clone's missing object fails the read instead of fetching it.
104
109
  child = spawn(nice ? "nice" : git, nice ? ["-n", "10", "--", git, ...args] : [...args], {
105
110
  cwd: opts.cwd, windowsHide: true, detached: !isWin, stdio: ["ignore", "pipe", "ignore"],
106
- ...(opts.env !== undefined ? { env: opts.env } : {}),
111
+ env: { ...(opts.env ?? process.env), GIT_NO_LAZY_FETCH: "1" },
107
112
  });
108
113
  } catch (e) {
109
114
  fail(e);
@@ -169,7 +174,9 @@ export interface SnapshotOptions {
169
174
  * Cross-repo QA-1 F4 (I11): run every git process of the snapshot hardened, as the router's other git calls in a repository
170
175
  * it does not own (git-tools.ts): `hardeningArgs()` (no fsmonitor, no hooks, no pager, no external diff, no optional locks),
171
176
  * the user's `safe.directory` values and inherited line-ending settings (`core.autocrlf` …), `gitEnvironment()` (no inherited GIT_*, no system or global config) and git by absolute
172
- * path outside the snapshotted tree. The perimeter's extra roots use it. Default false: the snapshot of W is unchanged.
177
+ * path outside the snapshotted tree. The perimeter's extra roots use it. Default false: the snapshot of W runs with
178
+ * `workRootReadArgs()` (no fsmonitor, no hooks, no transport) and keeps git's index refresh. Both modes blank the filter and
179
+ * merge drivers only the repository's own configuration names (`repositoryDriverArgs`).
173
180
  */
174
181
  hardened?: boolean;
175
182
  /** The git process seam (tests). Default execGit. */
@@ -510,9 +517,11 @@ export async function snapshotTree(cwd: string, signal: AbortSignal, options: Sn
510
517
  let gitCwd = cwd;
511
518
  const run = options.git ?? execGit;
512
519
  const lowPriority = options.lowPriority === true;
513
- let prefix: readonly string[] = ["--no-pager"];
520
+ // The default snapshot (W) keeps git's index refresh (no `hardeningArgs()`: diff.autoRefreshIndex=false would change the
521
+ // fingerprint) but never runs a repository-configured fsmonitor, hook, ssh key command or transport (`workRootReadArgs()`).
522
+ let prefix: readonly string[] = ["--no-pager", ...tools.workRootReadArgs()];
514
523
  let hardening: Pick<SnapshotGitOptions, "env" | "executable"> = {};
515
- type Stage = "root" | "head" | "status" | "diff-worktree" | "diff-index" | "index" | "untracked-list" | "hash" | "index-tags" | "ignored-list";
524
+ type Stage = "root" | "drivers" | "head" | "status" | "diff-worktree" | "diff-index" | "index" | "untracked-list" | "hash" | "index-tags" | "ignored-list";
516
525
  let stage: Stage = "root";
517
526
  const git = (label: Stage, args: string[]) => {
518
527
  stage = label;
@@ -530,11 +539,25 @@ export async function snapshotTree(cwd: string, signal: AbortSignal, options: Sn
530
539
  // ls-files otherwise scopes untracked contents to a subdirectory cwd,
531
540
  // missing same-path edits in sibling packages that tests may import.
532
541
  gitCwd = root;
542
+ // Status and diff run clean filters: a filter (or merge driver) only the repository's own configuration names is blanked,
543
+ // in both modes (required=false: a read never stores content); a system/global one and its identical repository copy
544
+ // (`git lfs install --local`) are kept. The listing runs in the environment of the snapshot's own processes. A
545
+ // configuration that cannot be read leaves no snapshot.
546
+ stage = "drivers";
547
+ prefix = [...prefix, ...await tools.repositoryDriverArgs(root, {
548
+ ...(hardening.executable !== undefined ? { executable: hardening.executable } : {}),
549
+ ...(hardening.env !== undefined ? { env: hardening.env } : {}), signal, timeoutMs: SNAPSHOT_GIT_TIMEOUT_MS,
550
+ })];
533
551
  // One process, so HEAD and its branch describe the same checkout.
534
552
  const [headLine, refLine] = (await git("head", ["rev-parse", "HEAD", "--symbolic-full-name", "HEAD"])).split(/\r?\n/);
535
553
  const head = (headLine ?? "").trim();
536
554
  const branch = parseBranchLine(refLine);
537
- const status = await git("status", ["status", "--porcelain=v1", "-z", "--untracked-files=all"]);
555
+ // A submodule's dirty marker does not describe its content. Refuse rather than cache a fingerprint that would excuse
556
+ // unmeasured changes there, and before `status`/`diff`, which would run git inside a populated submodule with its own
557
+ // configuration. The listing is not hashed.
558
+ if (/^160000 /m.test(await git("index", ["ls-files", "--stage"]))) return undefined;
559
+ // --no-optional-locks: the default snapshot's status never rewrites the user's index (output unchanged).
560
+ const status = await git("status", ["--no-optional-locks", "status", "--porcelain=v1", "-z", "--untracked-files=all"]);
538
561
  const files: ChangedFile[] = [];
539
562
  const records = status.split("\0");
540
563
  for (let i = 0; i < records.length; i++) {
@@ -551,9 +574,6 @@ export async function snapshotTree(cwd: string, signal: AbortSignal, options: Sn
551
574
  const hash = createHash("sha256").update(status);
552
575
  hash.update(await git("diff-worktree", ["diff", "HEAD", "--binary", "--no-ext-diff", "--no-textconv"]));
553
576
  hash.update(await git("diff-index", ["diff", "--cached", "--binary", "--no-ext-diff", "--no-textconv"]));
554
- // A submodule's dirty marker does not describe its content. Refuse rather
555
- // than cache a fingerprint that would excuse unmeasured changes there.
556
- if (/^160000 /m.test(await git("index", ["ls-files", "--stage"]))) return undefined;
557
577
  const untracked = (await git("untracked-list", ["ls-files", "--others", "--exclude-standard", "--full-name", "-z"]))
558
578
  .split("\0").filter(Boolean).sort();
559
579
  stage = "hash";
@@ -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,
@@ -654,8 +655,13 @@ export type HandleReport =
654
655
  | { readonly kind: "expired"; readonly handle: string }
655
656
  /** Joined another call's run, which outlived this call's deadline (R8). */
656
657
  | { readonly kind: "elsewhere"; readonly handle: string; readonly description: string }
657
- /** QA-2.1-9 (phase 2.1): a held background result; its own gate posts the verdict to the session, so nothing ran here. */
658
- | { readonly kind: "held"; readonly handle: string; readonly description: string };
658
+ /**
659
+ * QA-2.1-9 (phase 2.1): a held background result; its own gate posts the verdict to the session, so nothing ran here.
660
+ * No `description` for a handle that is reserved but not yet registered (the child is still running): nothing is stored yet.
661
+ */
662
+ | { readonly kind: "held"; readonly handle: string; readonly description?: string }
663
+ /** The call carried no session id, so no handle can be resolved (R6). `input` is the handle, or "pending: true". */
664
+ | { readonly kind: "no-session"; readonly input: string };
659
665
 
660
666
  export interface VerifyReport {
661
667
  readonly items: readonly HandleReport[];
@@ -667,6 +673,9 @@ export interface VerifyReport {
667
673
  export const ROUTER_VERIFY_ARGS_TEXT =
668
674
  "[router] router_verify: pass exactly one of `handles` (a non-empty list of vrf_ handles) or `pending: true`; nothing was run.";
669
675
  export const ROUTER_VERIFY_NO_PENDING_TEXT = "[router] router_verify: no unverified delegations in this session; nothing was run.";
676
+ /** R6: handles and the pending list are scoped by the calling session; a call without one can resolve nothing. */
677
+ export const NO_SESSION_TEXT =
678
+ "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
679
  export const ROUTER_VERIFY_NO_RETRY_TEXT = "[router] Nothing was retried or escalated; whether to re-dispatch is your call.";
671
680
  /** Section 1.5-18. The run always uses the current tree. */
672
681
  export const DRIFT_NOTICE = "tree drifted since delegation; verdict reflects current state";
@@ -815,8 +824,12 @@ export function formatVerifyReport(
815
824
  blocks.push(`- ${item.handle} \u00b7 ${item.description} \u00b7 ${VERIFYING_ELSEWHERE_TEXT}`);
816
825
  continue;
817
826
  }
827
+ if (item.kind === "no-session") {
828
+ blocks.push(`- ${sanitizeDescription(item.input)} \u00b7 ${NO_SESSION_TEXT}`);
829
+ continue;
830
+ }
818
831
  if (item.kind === "held") {
819
- blocks.push(`- ${item.handle} \u00b7 ${item.description} \u00b7 ${HELD_RESULT_TEXT}`);
832
+ blocks.push(`- ${item.handle} \u00b7 ${item.description !== undefined ? `${item.description} \u00b7 ` : ""}${HELD_RESULT_TEXT}`);
820
833
  continue;
821
834
  }
822
835
  const { result } = item;
@@ -872,7 +885,7 @@ export function backgroundOutcomes(items: readonly HandleReport[]): BackgroundOu
872
885
  : { kind: "reported", handle: item.handle };
873
886
  }
874
887
  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 };
888
+ return { kind: "gone", handle: item.kind === "unknown" || item.kind === "no-session" ? item.input : item.handle };
876
889
  });
877
890
  }
878
891
 
@@ -1060,7 +1073,7 @@ export interface VerificationWiring {
1060
1073
  applyLineage(res: GateResult, ctx: LineageContext): GateResult;
1061
1074
  /**
1062
1075
  * 2.4.3a, section 1.5-18: router_verify for `sessionID` (the calling orchestrator; "" = none, so
1063
- * every handle is unknown). Never rejects; never retries or escalates.
1076
+ * every handle and `pending` is answered "no session"). Never rejects; never retries or escalates.
1064
1077
  * - Handles are normalized, deduped and capped at MAX_HANDLES_PER_CALL; `pending` is listOpen, so
1065
1078
  * runs already in flight are joined (R8). Lookups are scoped by session (R6).
1066
1079
  * - ONE Deadline of gateBudgetMs per call, created before any preparation (section 1.5-13) and
@@ -1382,7 +1395,9 @@ export function createVerificationWiring(deps: {
1382
1395
  const timeoutMs = deadline ? deadline.bound(COMMIT_DIFF_TIMEOUT_MS) : COMMIT_DIFF_TIMEOUT_MS;
1383
1396
  if (timeoutMs <= 0 || deadline?.signal.aborted) return "unavailable";
1384
1397
  try {
1385
- const r = await argvSeam("git", ["--no-optional-locks", "-C", root, "diff", "--name-status", "-z", "-M", before.head, "HEAD"], {
1398
+ // #141 (#77 G4): git by absolute path from outside the work root, never looked up in it; hardeningArgs() carries
1399
+ // --no-optional-locks. A refused or missing executable throws here: "unavailable", as a failed spawn.
1400
+ const r = await argvSeam(gitExecutable(workRootGuards(root)), [...hardeningArgs(), "-C", root, "diff", "--name-status", "-z", "-M", before.head, "HEAD"], {
1386
1401
  cwd: root,
1387
1402
  timeoutMs,
1388
1403
  lowPriority: resolveVerifyBudget(getConfig()).lowPriority,
@@ -1395,13 +1410,16 @@ export function createVerificationWiring(deps: {
1395
1410
  }
1396
1411
  };
1397
1412
 
1398
- /** T9 1.3: the planners' git searches through the argv seam; no shell, no optional locks. */
1413
+ /**
1414
+ * T9 1.3: the planners' git searches through the argv seam; no shell, no optional locks. #141: git by absolute path from
1415
+ * outside the work root (`gitExecutable(workRootGuards(root))`) with `hardeningArgs()`, as the router's git tools.
1416
+ */
1399
1417
  const testSearch = (budget: VerifyBudget, deadline: Deadline | undefined): TestSearchSeam => {
1400
1418
  const git = async (root: string, args: readonly string[]): Promise<SeamResult | undefined> => {
1401
1419
  const timeoutMs = deadline ? deadline.bound(TEST_SEARCH_TIMEOUT_MS) : TEST_SEARCH_TIMEOUT_MS;
1402
1420
  if (timeoutMs <= 0 || deadline?.signal.aborted) return undefined;
1403
1421
  try {
1404
- const r = await argvSeam("git", ["--no-optional-locks", "-C", root, ...args], {
1422
+ const r = await argvSeam(gitExecutable(workRootGuards(root)), [...hardeningArgs(), "-C", root, ...args], {
1405
1423
  cwd: root,
1406
1424
  timeoutMs,
1407
1425
  lowPriority: budget.lowPriority,
@@ -3475,7 +3493,12 @@ export function createVerificationWiring(deps: {
3475
3493
  let targets: Array<{ readonly input: string; readonly handle: string | undefined }> = [];
3476
3494
  if (target.kind === "pending") {
3477
3495
  // QA-2.4-3: listPending adds the background verdicts not yet replayed (a cached replay, no run).
3478
- if (sessionID !== "") targets = pending.listPending(sessionID, { verifying: true }).map(e => ({ input: e.handle, handle: e.handle }));
3496
+ // R6: without a session there is nothing to list; "no unverified delegations in this session" would read as "not yet".
3497
+ if (sessionID === "") {
3498
+ const item: HandleReport = { kind: "no-session", input: "pending: true" };
3499
+ return { items: [item], excess: 0, text: formatVerifyReport([item], 0, false) };
3500
+ }
3501
+ targets = pending.listPending(sessionID, { verifying: true }).map(e => ({ input: e.handle, handle: e.handle }));
3479
3502
  if (targets.length === 0) return { items: [], excess: 0, text: ROUTER_VERIFY_NO_PENDING_TEXT };
3480
3503
  } else {
3481
3504
  const seen = new Set<string>();
@@ -3488,7 +3511,8 @@ export function createVerificationWiring(deps: {
3488
3511
  targets.push({ input, handle });
3489
3512
  }
3490
3513
  }
3491
- const excess = Math.max(0, targets.length - MAX_HANDLES_PER_CALL);
3514
+ // Without a session every handle gets the same terminal answer, so there is no "rest" to call again with.
3515
+ const excess = sessionID === "" ? 0 : Math.max(0, targets.length - MAX_HANDLES_PER_CALL);
3492
3516
  targets = targets.slice(0, MAX_HANDLES_PER_CALL);
3493
3517
 
3494
3518
  // 2. The call's one deadline (section 1.5-13), before any preparation.
@@ -3514,8 +3538,12 @@ export function createVerificationWiring(deps: {
3514
3538
  const cwds = new Map<string, string>();
3515
3539
  try {
3516
3540
  for (const t of targets) {
3517
- if (t.handle === undefined || sessionID === "") {
3518
- slots.push({ kind: "unknown", input: t.handle ?? t.input });
3541
+ if (sessionID === "") {
3542
+ slots.push({ kind: "no-session", input: t.handle ?? t.input });
3543
+ continue;
3544
+ }
3545
+ if (t.handle === undefined) {
3546
+ slots.push({ kind: "unknown", input: t.input });
3519
3547
  continue;
3520
3548
  }
3521
3549
  // 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 +3556,13 @@ export function createVerificationWiring(deps: {
3528
3556
  slots.push({ kind: "held", handle: looked.entry.handle, description: looked.entry.description });
3529
3557
  continue;
3530
3558
  }
3559
+ // A handle reserved at the background ack is shown to the orchestrator every turn but registered only when the child
3560
+ // finishes: until then it is held, not unknown. Only the session it was reserved for may see that (R6): another
3561
+ // session's reservation stays unknown. The verdict is replayed through the entry once it is registered and settled.
3562
+ if (looked.kind === "unknown" && pending.reservedBy(t.handle) === sessionID) {
3563
+ slots.push({ kind: "held", handle: t.handle });
3564
+ continue;
3565
+ }
3531
3566
  const c = pending.markVerifying(sessionID, t.handle);
3532
3567
  if (c.kind === "unknown") slots.push({ kind: "unknown", input: t.handle });
3533
3568
  else if (c.kind === "expired") slots.push({ kind: "expired", handle: c.handle });
package/tiers.json CHANGED
@@ -269,9 +269,9 @@
269
269
  },
270
270
  "medium": {
271
271
  "model": "openai/gpt-6.1-sol-fast",
272
- "variant": "xhigh",
272
+ "variant": "high",
273
273
  "costRatio": 5,
274
- "description": "GPT-6.1 Sol Fast (xhigh) for implementation and standard coding",
274
+ "description": "GPT-6.1 Sol Fast (high) for implementation and standard coding",
275
275
  "steps": 50,
276
276
  "whenToUse": [
277
277
  "Feature implementation",
@@ -282,10 +282,10 @@
282
282
  },
283
283
  "heavy": {
284
284
  "model": "anthropic/claude-opus-5-5",
285
- "variant": "xhigh",
286
- "effort": "xhigh",
285
+ "variant": "high",
286
+ "effort": "high",
287
287
  "costRatio": 20,
288
- "description": "Claude Opus 5.5 xhigh for architecture, complex debugging, and security",
288
+ "description": "Claude Opus 5.5 high for architecture, complex debugging, and security",
289
289
  "steps": 120,
290
290
  "whenToUse": [
291
291
  "Architecture decisions",