@staix/agent-hub 0.39.0 → 0.40.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.
Files changed (110) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +12 -6
  3. package/docs/adding-an-ai-tool.md +1 -1
  4. package/docs/agent-notes/README.md +7 -0
  5. package/docs/agent-notes/adapters.md +5 -3
  6. package/docs/agent-notes/benchmarks.md +2 -0
  7. package/docs/agent-notes/budget.md +1 -0
  8. package/docs/agent-notes/bus.md +1 -0
  9. package/docs/agent-notes/daemon.md +8 -3
  10. package/docs/agent-notes/local-worker.md +3 -1
  11. package/docs/agent-notes/security-review.md +1 -0
  12. package/docs/agent-notes/tasks.md +7 -2
  13. package/docs/agent-notes/tests.md +7 -7
  14. package/docs/contracts/companion-cli-v1.json +4 -0
  15. package/docs/design/adapters.md +91 -0
  16. package/docs/design/agent-hub-architecture.md +17 -0
  17. package/docs/design/agent-hub.md +10 -0
  18. package/docs/design/bus.md +7 -0
  19. package/docs/design/cli-output.md +183 -0
  20. package/docs/design/execution-reference.md +6 -1
  21. package/docs/design/roadmap.md +191 -0
  22. package/docs/design/task-board.md +34 -0
  23. package/docs/dogfood.md +11 -4
  24. package/docs/events.md +4 -4
  25. package/docs/memory.md +3 -3
  26. package/docs/operations.md +153 -41
  27. package/docs/profiles.md +1 -0
  28. package/docs/quickstart.md +17 -4
  29. package/docs/sdlc.md +3 -1
  30. package/docs/security.md +40 -4
  31. package/docs/verification/2026-11-14-codex-0169-reviewer-isolation.md +70 -0
  32. package/docs/verification/2026-11-14-codex-0169-reviewer-tool-call.md +48 -0
  33. package/docs/verification/2026-11-14-pi-152-compat.md +45 -0
  34. package/docs/verification/2026-11-15-0.40.0.md +39 -0
  35. package/docs/verification/2026-11-16-pi-loopback-1447.md +39 -0
  36. package/docs/verification/pi-152-model-free.ts +57 -0
  37. package/docs/verification/pi-152-native.mjs +21 -0
  38. package/docs/verified.json +22 -22
  39. package/package.json +3 -3
  40. package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
  41. package/plugins/agent-hub/kimi-hook.js +332 -89
  42. package/plugins/agent-hub/kimi-review-policy-worker.js +16 -11
  43. package/plugins/agent-hub/server.js +417 -160
  44. package/src/adapters/agy/definition.ts +1 -1
  45. package/src/adapters/claude-channel.ts +1 -1
  46. package/src/adapters/codex-review-isolation.ts +61 -17
  47. package/src/adapters/compat.ts +7 -7
  48. package/src/adapters/definitions/builtin-metadata.ts +6 -6
  49. package/src/adapters/definitions/native-config-defaults.ts +1 -1
  50. package/src/adapters/definitions/native-config-policy.ts +1 -1
  51. package/src/adapters/definitions/qwen.ts +1 -1
  52. package/src/adapters/local-worker.ts +5 -3
  53. package/src/adapters/pi.ts +54 -11
  54. package/src/adapters/registry-types.ts +2 -1
  55. package/src/adapters/reviewer-print.ts +2 -1
  56. package/src/cli/answer-args.ts +11 -3
  57. package/src/cli/console-question.ts +1 -1
  58. package/src/cli/console-state.ts +95 -10
  59. package/src/cli/console.ts +6 -2
  60. package/src/cli/error-format.ts +19 -0
  61. package/src/cli/help.ts +290 -25
  62. package/src/cli/identity-audit.ts +8 -7
  63. package/src/cli/identity.ts +17 -0
  64. package/src/cli/init.ts +102 -9
  65. package/src/cli/main.js +2 -2
  66. package/src/cli/main.ts +57 -21
  67. package/src/cli/output-standard.ts +56 -0
  68. package/src/cli/output.ts +143 -8
  69. package/src/cli/roadmap.ts +215 -0
  70. package/src/cli/smoke-pty-bridge.ts +7 -24
  71. package/src/cli/task-output.ts +3 -1
  72. package/src/cli/upgrade-presentation-flags.ts +2 -2
  73. package/src/hub/board.ts +200 -3
  74. package/src/hub/bus.ts +9 -0
  75. package/src/hub/check-runner.ts +3 -4
  76. package/src/hub/ci-watch.ts +19 -4
  77. package/src/hub/control-client.ts +1 -1
  78. package/src/hub/daemon.ts +245 -43
  79. package/src/hub/events.ts +2 -2
  80. package/src/hub/execution-reference.ts +1 -1
  81. package/src/hub/github-import.ts +81 -0
  82. package/src/hub/hub-tools.ts +34 -9
  83. package/src/hub/install-policy.ts +23 -0
  84. package/src/hub/lifecycle-schema.ts +2 -2
  85. package/src/hub/no-writes.ts +3 -0
  86. package/src/hub/operational-authority.ts +3 -1
  87. package/src/hub/operational-view.ts +1 -1
  88. package/src/hub/pi-failure.ts +7 -0
  89. package/src/hub/question-desk.ts +26 -7
  90. package/src/hub/questions.ts +33 -5
  91. package/src/hub/restart.ts +7 -0
  92. package/src/hub/roadmap-triage.ts +86 -0
  93. package/src/hub/roadmap-unplaced.ts +169 -0
  94. package/src/hub/roadmap-view.ts +83 -0
  95. package/src/hub/roadmap.ts +127 -0
  96. package/src/hub/sdlc-merge.ts +5 -4
  97. package/src/hub/sdlc-queue.ts +3 -3
  98. package/src/hub/sdlc.ts +37 -2
  99. package/src/hub/specs-task.ts +7 -0
  100. package/src/hub/task-sweep.ts +29 -2
  101. package/src/hub/task-worktree.ts +37 -0
  102. package/src/hub/tasks.ts +381 -7
  103. package/src/pi/dependency-publish.ts +50 -0
  104. package/src/pi/extension.ts +1 -1
  105. package/src/pi/launch.ts +1 -1
  106. package/src/pi/task-dependencies.ts +249 -0
  107. package/src/ui/index.html +53 -13
  108. package/src/ui/plugin-questions.ts +5 -0
  109. package/src/ui/plugin.ts +6 -1
  110. package/templates/config.json +1 -1
@@ -52,7 +52,7 @@ export const AGY_DEFINITION: AdapterDefinition = {
52
52
  recoveryRefusal: () => "Antigravity session continuity and resume are unavailable until native behavior is verified",
53
53
  },
54
54
  turnEnd: "native-hook",
55
- cli: { command: "agy", entry: { lifecycleAdmission: true, execute: runAgyEntry }, usage: [["ahub agy [--print-command | --dry-run] [args...]", "optional Antigravity CLI 1.4.x TUI (1.4.2 verified) in this terminal (roster.agy, default off): pull-only via hub_inbox, implementer/verifier only; native permissions unmanaged, no hub sandbox"]], authority: "person", startWords: () => ["agy"] },
55
+ cli: { command: "agy", entry: { lifecycleAdmission: true, execute: runAgyEntry }, usage: [["ahub agy [--print-command | --dry-run] [args...]", "optional Antigravity CLI 1.4.x TUI (1.4.2 verified) in this terminal (roster.agy, default off): pull-only via hub_inbox, implementer/verifier only; native permissions unmanaged, no hub sandbox", "start optional Antigravity CLI in this terminal"]], authority: "person", startWords: () => ["agy"] },
56
56
  display: DISPLAY,
57
57
  routing: { allowedRoles: ["implementer", "verifier"] },
58
58
  reviewer: { defaultPool: false, declaration: "automatic", unavailable: "agy is an implementer peer (#485)" },
@@ -433,7 +433,7 @@ function toolListFor(lifecycle: Awaited<ReturnType<typeof activeLifecycle>>) {
433
433
  ]
434
434
  : []),
435
435
  ]),
436
- ...profileTaskTools(profile, lifecycle?.stages, lifecycle?.criteria, lifecycle?.audit, lifecycle?.survey).filter(tool => (lifecycle !== undefined || tool.name !== "hub_sdlc_record") && (!deliveryOnly || tool.name !== "hub_delivery_retry")),
436
+ ...profileTaskTools(profile, lifecycle?.stages, lifecycle?.criteria, lifecycle?.audit, lifecycle?.survey, lifecycle?.wait).filter(tool => (lifecycle !== undefined || tool.name !== "hub_sdlc_record") && (!deliveryOnly || tool.name !== "hub_delivery_retry")),
437
437
  ...projectConductorTools(lifecycle?.startPeers),
438
438
  ], lifecycle?.readOnly).filter(tool => !permissionTool || IMPLEMENTER_HUB_TOOL_NAMES.includes(tool.name)),
439
439
  };
@@ -9,7 +9,7 @@ import { createRequire } from "node:module";
9
9
  import { homedir, tmpdir } from "node:os";
10
10
  import { basename, delimiter, dirname, isAbsolute, join, relative, resolve } from "node:path";
11
11
  import { peerChildEnv, stopOwnedProcess, trackGroup } from "../hub/child-process.ts";
12
- import { realPath } from "../hub/project.ts";
12
+ import { hubHome, realPath } from "../hub/project.ts";
13
13
  import type { ReviewerBackend, ReviewerCauseClass, ReviewerLaunch, ReviewerPrepareContext } from "./reviewer-print.ts";
14
14
 
15
15
  const TOOLS = ["hub_review", "hub_task_show"];
@@ -49,6 +49,58 @@ export function codexCoreDenyGlobs(names: readonly string[] = DENY_NAMES, segmen
49
49
  }
50
50
 
51
51
  const inside = (file: string, root: string) => { const part = relative(root, file); return part === "" || part !== ".." && !part.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) && !isAbsolute(part); };
52
+ /**
53
+ * #1493: the proof's public canary lives in a fresh fixture root. A deny entry that contains the directory the root is made in puts the canary under
54
+ * a denied tree, the proof's own read fails, and the leg reads as `sandbox_proof` with nothing naming the entry. This asks the same question the
55
+ * sandbox will: does any deny pattern match a directory on the chain from `/` to the candidate base (a match denies everything below it)?
56
+ * `*` stays inside one path segment, `**` crosses segments, `?` is one non-separator character, and a closed `[...]` class is kept.
57
+ */
58
+ function globRegExp(pattern: string): RegExp {
59
+ let source = "";
60
+ for (let i = 0; i < pattern.length; i++) {
61
+ const char = pattern[i]!;
62
+ if (char === "*") { if (pattern[i + 1] === "*") { source += ".*"; i++; } else source += "[^/]*"; }
63
+ else if (char === "?") source += "[^/]";
64
+ else if (char === "[" && pattern.indexOf("]", i + 2) > 0) { const close = pattern.indexOf("]", i + 2); source += pattern.slice(i, close + 1); i = close; }
65
+ else source += char.replace(/[\\^$.|+(){}\[\]]/g, "\\$&");
66
+ }
67
+ return new RegExp(`^${source}$`);
68
+ }
69
+ export function denyCoversDirectory(patterns: readonly string[], directory: string): boolean {
70
+ const chain: string[] = [];
71
+ for (let current = directory; ; current = dirname(current)) { chain.push(current); if (dirname(current) === current) break; }
72
+ return patterns.some(pattern => { let matcher: RegExp; try { matcher = globRegExp(pattern); } catch { return true; } return chain.some(part => matcher.test(part)); });
73
+ }
74
+ /** A fixture base no deny pattern covers: the system temp directory, else the hub's own per-user directory, else a refusal that names no entry. */
75
+ class FixtureRootError extends Error { constructor() { super("fixture root denied"); } }
76
+ function fixtureBase(patterns: readonly string[]): string {
77
+ const temp = realPath(tmpdir());
78
+ if (!denyCoversDirectory(patterns, temp)) return temp;
79
+ const own = join(hubHome(), "reviewer-proof");
80
+ mkdirSync(own, { recursive: true, mode: 0o700 });
81
+ const canonical = realPath(own);
82
+ if (denyCoversDirectory(patterns, canonical)) throw new FixtureRootError();
83
+ return canonical;
84
+ }
85
+ /** The expanded deny patterns for `ctx.privatePaths`, exactly as the proof's filesystem policy names them (with and without a resolved form). */
86
+ function privatePathPatterns(entries: readonly string[], cwd: string): string[] {
87
+ const out = new Set<string>();
88
+ for (const entry of entries) {
89
+ if (typeof entry !== "string" || !entry || Buffer.byteLength(entry) > 4096 || /\p{Cc}/u.test(entry)) throw new Error("invalid private path policy");
90
+ // Native Seatbelt supports *, ?, and closed character classes, not brace alternatives.
91
+ if (/[{}]/.test(entry)) throw new Error("unverified private path pattern");
92
+ const homePath = entry === "~" || entry.startsWith("~/");
93
+ const absolute = homePath ? resolve(homedir(), entry.slice(2)) : isAbsolute(entry) ? entry : resolve(cwd, entry);
94
+ out.add(absolute);
95
+ if (!/[?*\[\]]/.test(absolute) && existsSync(absolute)) out.add(realPath(absolute));
96
+ if (!isAbsolute(entry) && !homePath && entry !== "." && entry !== "..") {
97
+ out.add(join(cwd, "**", entry));
98
+ // ctx combines PII path patterns and local substring denies: broadening is safer than omission.
99
+ if (!/[?*\[\]]/.test(entry)) out.add(join(cwd, "**", `*${entry.replace(/^\.\//, "").replace(/\/$/, "")}*`));
100
+ }
101
+ }
102
+ return [...out];
103
+ }
52
104
  const object = (value: unknown): Record<string, unknown> => {
53
105
  if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("invalid metadata");
54
106
  return value as Record<string, unknown>;
@@ -243,7 +295,11 @@ async function prepare(ctx: ReviewerPrepareContext): Promise<ReviewerLaunch | {
243
295
  if (observedTransport.type !== "stdio" || observedTransport.command !== hub.command || JSON.stringify(observedTransport.args ?? []) !== JSON.stringify(hub.args) || Object.keys(observedEnv).length !== Object.keys(intendedEnv).length || Object.entries(intendedEnv).some(([key, value]) => observedEnv[key] !== value)) throw new Error("hub transport changed");
244
296
  // A real native sandbox probes a fresh private fixture: the model never sees these files.
245
297
  leg = "sandbox_proof";
246
- root = realPath(mkdtempSync(join(tmpdir(), "ahub-codex-review-isolation-")));
298
+ const privatePatterns = privatePathPatterns(ctx.privatePaths, cwd);
299
+ // The credential roots are checked again, strictly, below; a root that cannot be resolved here is left to that check and its own cause class.
300
+ const credentialPatterns: string[] = [];
301
+ try { for (const { path, label } of hostCredentialRoots(env, cwd)) credentialPatterns.push(path, canonicalLabelled(path, label)); } catch { /* reported by denyCredentialRoots below */ }
302
+ root = realPath(mkdtempSync(join(fixtureBase([...privatePatterns, ...codexCoreDenyGlobs(), ...credentialPatterns]), "ahub-codex-review-isolation-")));
247
303
  const privateFile = join(root, "private.env"), publicFile = join(root, "public.txt"), writeFile = join(root, "write-proof");
248
304
  const coreName = join(root, ".env"), coreStateDir = join(root, ".agenthub", "state"), coreState = join(coreStateDir, "private.txt");
249
305
  const fixtureHome = join(root, "host-home"), hostConfig = join(fixtureHome, ".config", "gh", "hosts.yml"), hostKube = join(fixtureHome, ".kube", "config"), hostDocker = join(fixtureHome, ".docker", "config.json"), hostAlias = join(root, "host-alias.yml");
@@ -260,21 +316,7 @@ async function prepare(ctx: ReviewerPrepareContext): Promise<ReviewerLaunch | {
260
316
  for (const glob of codexCoreDenyGlobs()) filesystem[glob] = "deny";
261
317
  denyCredentialRoots(filesystem, [...hostCredentialRoots(env, cwd), ...hostCredentialRoots({ HOME: fixtureHome }, cwd)], cwd);
262
318
  leg = "sandbox_proof";
263
- for (const entry of ctx.privatePaths) {
264
- if (typeof entry !== "string" || !entry || Buffer.byteLength(entry) > 4096 || /\p{Cc}/u.test(entry)) throw new Error("invalid private path policy");
265
- // Native Seatbelt supports *, ?, and closed character classes, not brace alternatives.
266
- if (/[{}]/.test(entry)) throw new Error("unverified private path pattern");
267
- const homePath = entry === "~" || entry.startsWith("~/");
268
- const absolute = homePath ? resolve(homedir(), entry.slice(2)) : isAbsolute(entry) ? entry : resolve(cwd, entry);
269
- const patterns = new Set([absolute]);
270
- if (!/[?*\[\]]/.test(absolute) && existsSync(absolute)) patterns.add(realPath(absolute));
271
- if (!isAbsolute(entry) && !homePath && entry !== "." && entry !== "..") {
272
- patterns.add(join(cwd, "**", entry));
273
- // ctx combines PII path patterns and local substring denies: broadening is safer than omission.
274
- if (!/[?*\[\]]/.test(entry)) patterns.add(join(cwd, "**", `*${entry.replace(/^\.\//, "").replace(/\/$/, "")}*`));
275
- }
276
- for (const pattern of patterns) { filesystem[pattern] = "deny"; filesystem[`${pattern.replace(/\/$/, "")}/**`] = "deny"; }
277
- }
319
+ for (const pattern of privatePatterns) { filesystem[pattern] = "deny"; filesystem[`${pattern.replace(/\/$/, "")}/**`] = "deny"; }
278
320
  const profile = { filesystem, network: { enabled: false } }, permissions = ["-c", `permissions=${toml({ "ahub-review": profile })}`, "-c", 'default_permissions="ahub-review"'];
279
321
  // ponytail: drain the pinned catalog without retaining it, capped at 4 MiB; replace with quiet config validation when the native CLI provides it.
280
322
  await run(["debug", "models", "--bundled", ...policy, ...permissions], false, 4 * 1024 * 1024);
@@ -294,6 +336,8 @@ async function prepare(ctx: ReviewerPrepareContext): Promise<ReviewerLaunch | {
294
336
  if (root) { try { rmSync(root, { recursive: true, force: true }); } catch { /* unavailable remains refused */ } }
295
337
  // Name only the path class of an unusable credential root so a stale ~/.docker link is fixable; never a path or contents.
296
338
  if (error instanceof VersionRefusal) return { unavailable: error.message, causeClass: "version" };
339
+ // #1493: no directory the proof could use for its fixture is outside every deny pattern. The entry is never echoed; the person narrows it or moves TMPDIR.
340
+ if (error instanceof FixtureRootError) return { unavailable: "Codex reviewer isolation receipt unavailable (a local.deny or pii.paths entry contains the system temp directory and the hub directory; move TMPDIR or narrow the entry)", causeClass: "fixture_root_denied" };
297
341
  if (error instanceof CredentialRootError) {
298
342
  const why = { dangling: "a dangling link", unreadable: "an unreadable path", unsupported: "unsupported syntax or overlapping the checkout" }[error.kind];
299
343
  return { unavailable: `Codex reviewer isolation receipt unavailable (credential root ${error.label} is ${why}; remove or repair it)`, causeClass: "credential_root", detail: `${error.label}: ${why}` };
@@ -29,21 +29,21 @@ export interface CompatPolicy {
29
29
 
30
30
  const plain = (text: string) => text.length <= 64 && /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(text) ? text : undefined;
31
31
  export const COMPAT = {
32
- // Receipts: docs/verification/2026-10-26-pi-140-compat.md (1.4.0); docs/verification/2026-11-03-pi-150-compat.md (1.5.0)
33
- pi: { label: "Pi", verified: ["1.4.0", "1.5.0"], gate: "contract", probe: ["pi", "--version"], config: "pi.cmd",
32
+ // Receipts: docs/verification/2026-10-26-pi-140-compat.md (1.4.0); docs/verification/2026-11-03-pi-150-compat.md (1.5.0); docs/verification/2026-11-14-pi-152-compat.md (1.5.2)
33
+ pi: { label: "Pi", verified: ["1.4.0", "1.5.0", "1.5.2"], gate: "contract", probe: ["pi", "--version"], config: "pi.cmd",
34
34
  parse: out => plain(out.trim()),
35
- trustNote: "The model-free extension load, RPC session identity and managed tool receipt path were checked on 1.4.0 and 1.5.0. Permissions remain host-owned; account-backed inference and another version's extension contract are unverified.",
36
- receipt: "docs/verification/2026-11-03-pi-150-compat.md" },
35
+ trustNote: "The model-free extension load, RPC session identity and managed tool receipt path were checked on 1.4.0, 1.5.0 and 1.5.2. Permissions remain host-owned; account-backed inference and another version's extension contract are unverified.",
36
+ receipt: "docs/verification/2026-11-14-pi-152-compat.md" },
37
37
  // Transport receipts: docs/verification/2026-10-23-headless-claude-permissions.md; 2.1.310: docs/verification/2026-10-26-claude-implementer-2.1.310.md; 2.1.314 (transport and wrapper): docs/verification/2026-10-31-claude-implementer-2.1.314.md; 2.1.316: docs/verification/2026-10-31-claude-implementer-2.1.316.md; 2.1.318: docs/verification/2026-11-05-claude-implementer-2.1.318.md; 2.1.319: docs/verification/2026-11-06-claude-implementer-2.1.319.md; 2.1.322: docs/verification/2026-11-10-claude-implementer-2.1.322.md; 2.1.323: docs/verification/2026-11-13-claude-implementer-2.1.323.md; host-wrapper receipt below repeats with them.
38
38
  "claude-implementer": { label: "Claude headless implementer", verified: ["2.1.309", "2.1.310", "2.1.314", "2.1.316", "2.1.318", "2.1.319", "2.1.322", "2.1.323"], gate: "contract", probe: ["claude", "--version"],
39
39
  parse: out => plain(out.trim().replace(/ \(Claude Code\)$/, "")),
40
40
  trustNote: "The native prompt-tool transport and host-wrapper rewrite, environment isolation and replay contract have isolated receipts. No dontAsk/bypass fallback exists; another version's permission or rewrite behavior is unverified.",
41
41
  receipt: "docs/verification/2026-11-13-claude-implementer-2.1.323.md" },
42
- // 0.163.0 receipt: docs/verification/2026-10-22-codex-reviewer-isolation.md; 0.164.0 receipt: docs/verification/2026-10-24-codex-0164-reviewer-isolation.md; 0.166.0: docs/verification/2026-10-31-codex-0166-reviewer-isolation.md; 0.167.0 model-free only, not verified until its model-backed run: docs/verification/2026-11-06-codex-0167-reviewer-isolation.md; 0.167.2 model-free only, not verified until its model-backed run: docs/verification/2026-11-13-codex-01672-reviewer-isolation.md
43
- "codex-review": { label: "Codex reviewer (codex-cli)", verified: ["0.146.0", "0.163.0", "0.164.0", "0.166.0"], gate: "isolation", probe: ["codex", "--version"], config: "codex_bin",
42
+ // 0.163.0 receipt: docs/verification/2026-10-22-codex-reviewer-isolation.md; 0.164.0 receipt: docs/verification/2026-10-24-codex-0164-reviewer-isolation.md; 0.166.0: docs/verification/2026-10-31-codex-0166-reviewer-isolation.md; 0.167.0 model-free only, not verified until its model-backed run: docs/verification/2026-11-06-codex-0167-reviewer-isolation.md; 0.167.2 model-free only, not verified until its model-backed run: docs/verification/2026-11-13-codex-01672-reviewer-isolation.md; 0.169.0 (model-free and one model-backed review): docs/verification/2026-11-14-codex-0169-reviewer-isolation.md and docs/verification/2026-11-14-codex-0169-reviewer-tool-call.md
43
+ "codex-review": { label: "Codex reviewer (codex-cli)", verified: ["0.146.0", "0.163.0", "0.164.0", "0.166.0", "0.169.0"], gate: "isolation", probe: ["codex", "--version"], config: "codex_bin",
44
44
  parse: out => plain(out.trim().replace(/^codex-cli /, "")),
45
45
  trustNote: "Every launch still proves the MCP inventory, Apps/plugins/hooks disabled, sandbox read/write denial and the binary fence; a failed leg still refuses. Trust covers only the source-level claims those probes cannot see (docs/verification/2026-10-19-reviewer-isolation.md).",
46
- receipt: "docs/verification/2026-11-06-codex-0167-reviewer-isolation.md" },
46
+ receipt: "docs/verification/2026-11-14-codex-0169-reviewer-isolation.md" },
47
47
  // Kimi 2.3.0 / Qwen 0.26.0 receipt: docs/verification/2026-10-22-kimi-qwen-compat.md; Kimi 2.3.1: docs/verification/2026-10-25-kimi-231-reviewer-compat.md; Kimi 2.3.2: docs/verification/2026-10-26-kimi-232-reviewer-compat.md; Kimi 2.4.1: docs/verification/2026-10-31-kimi-241-reviewer-compat.md; Kimi 2.5.1: docs/verification/2026-11-06-kimi-251-reviewer-compat.md
48
48
  "kimi-review": { label: "Kimi reviewer (kimi-code)", verified: ["2.2.0", "2.3.0", "2.3.1", "2.3.2", "2.4.1", "2.5.1"], gate: "isolation", probe: ["kimi", "--version"],
49
49
  parse: out => plain(out.trim()),
@@ -87,7 +87,7 @@ export const NATIVE_BUILTIN_DEFINITIONS_WITHOUT_QWEN: readonly AdapterDefinition
87
87
  "never-ask": "every tool runs without asking" } },
88
88
  session: { idField: "sessionId", currentId: sessionId("sessionId"), configDirEnv: "CLAUDE_CONFIG_DIR", zeroTurnFresh: true, launchKind: "claude-channel", launchRecord: true, ...CLAUDE_RECOVERY_SESSION, crashPlan: claudeCrashPlan, unrecordedTerminal: "always" },
89
89
  turnEnd: "native-hook", settle: { signal: "native-stop" }, budget: { account: "claude", checkpoint: true, reader: { source: "claude status line", read: claudeWindows }, context: { source: "claude_statusline", read: claudeContext } },
90
- cli: { command: "claude", entry: { lifecycleAdmission: true, execute: runClaudeEntry }, preview: previewClaude, usage: [["ahub claude [--print-command] [--unattended] [args...]", "launch Claude Code with the hub channel"]], retainedTerminalNotice: claudeRetainedTerminalNotice, stopNotice: () => "this peer belongs to a native terminal; end it in its terminal", startWords: () => ["claude"] }, display: CLAUDE_DISPLAY, hooks: { recallPlatform: "claude", recallSource: "claude", recallInjected: true, pluginInventory: claudePluginInventory },
90
+ cli: { command: "claude", entry: { lifecycleAdmission: true, execute: runClaudeEntry }, preview: previewClaude, usage: [["ahub claude [--print-command] [--unattended] [args...]", "launch Claude Code with the hub channel", "launch Claude Code with the hub channel"]], retainedTerminalNotice: claudeRetainedTerminalNotice, stopNotice: () => "this peer belongs to a native terminal; end it in its terminal", startWords: () => ["claude"] }, display: CLAUDE_DISPLAY, hooks: { recallPlatform: "claude", recallSource: "claude", recallInjected: true, pluginInventory: claudePluginInventory },
91
91
  reviewerVariant: CLAUDE_REVIEWER_VARIANT, headlessVariant: CLAUDE_IMPLEMENTER_VARIANT,
92
92
  },
93
93
  {
@@ -102,7 +102,7 @@ export const NATIVE_BUILTIN_DEFINITIONS_WITHOUT_QWEN: readonly AdapterDefinition
102
102
  permission: { trackUnattended: true, grants: { ask: "the session's own approval policy applies again", "ask-when-needed": "approval policy on-request on every turn", "never-ask": "approval policy never on every turn: nothing asks" } },
103
103
  session: { nativeRevert: true, idField: "threadId", currentId: sessionId("threadId"), configDirEnv: "CODEX_HOME", zeroTurnFresh: true, launchKind: "codex", launchRecord: true, ...CODEX_RECOVERY_SESSION, crashPlan: codexCrashPlan, unrecordedTerminal: "always" },
104
104
  turnEnd: "adapter", settle: { signal: "turn-completed" }, budget: { account: "codex", checkpoint: true, reader: { source: "codex rateLimits", read: codexWindows }, context: { source: "codex_token_usage", read: codexContext } },
105
- cli: { command: "codex", entry: { lifecycleAdmission: true, execute: runCodexEntry }, preview: previewCodex, usage: [["ahub codex [--print-command] [--unattended] [args...]", "start the Codex adapter and attach the TUI"]], launchConfigKeys: ["codex_bin"], retainedTerminalNotice: codexRetainedTerminalNotice, rosterReturnNotice: codexRosterReturnNotice, stopNotice: () => "this peer belongs to a native terminal; end it in its terminal", startWords: () => ["codex"] }, display: CODEX_DISPLAY, hooks: { recallPlatform: "codex", recallSource: "codex", recallInjected: true, pluginInventory: codexPluginInventory, classifyTool: codexToolSemantic },
105
+ cli: { command: "codex", entry: { lifecycleAdmission: true, execute: runCodexEntry }, preview: previewCodex, usage: [["ahub codex [--print-command] [--unattended] [args...]", "start the Codex adapter and attach the TUI", "start the Codex adapter and attach the TUI"]], launchConfigKeys: ["codex_bin"], retainedTerminalNotice: codexRetainedTerminalNotice, rosterReturnNotice: codexRosterReturnNotice, stopNotice: () => "this peer belongs to a native terminal; end it in its terminal", startWords: () => ["codex"] }, display: CODEX_DISPLAY, hooks: { recallPlatform: "codex", recallSource: "codex", recallInjected: true, pluginInventory: codexPluginInventory, classifyTool: codexToolSemantic },
106
106
  },
107
107
  {
108
108
  reviewerVariant: KIMI_REVIEWER_VARIANT,
@@ -120,7 +120,7 @@ export const NATIVE_BUILTIN_DEFINITIONS_WITHOUT_QWEN: readonly AdapterDefinition
120
120
  unmanagedForms: Object.freeze(["tui"] as const), unmanagedStatusNote: "Kimi approves tools in its own TUI; no hub permission mode", unmanagedNote: "Kimi approves tools and selects its permission mode in its own TUI; no hub permission mode" },
121
121
  session: { idField: "sessionId", currentId: sessionId("sessionId"), freshOnRestore: true, launchKind: "acp", ...KIMI_RECOVERY_SESSION, crashPlan: kimiCrashPlan },
122
122
  turnEnd: "adapter", settle: { signal: "prompt-response" }, budget: { account: "kimi", resetSoftTokensOnResume: true, context: { source: "acp_usage_update", read: acpContextValue } }, capabilities: { watch: true }, hooks: { factsHook: KIMI_TUI_FACTS_HOOK, recallPlatform: "kimi", recallSource: "kimi" },
123
- cli: { command: "kimi", entry: { lifecycleAdmission: true, execute: runKimiEntry }, preview: previewKimi, usage: [["ahub kimi [--print-command] [--mode tui|headless] [--model <alias>]", "default: Kimi's own TUI, pull-only via hub_inbox; no push, steer, watchdog, console approvals or automatic quota handoff. Select headless for ACP"]], launchConfigKeys: ["kimi_cmd", "peers.kimi.start_mode"], stopNotice: form => form === "tui" ? "Kimi belongs to its own TUI terminal; end it in that terminal" : "", startWords: form => ["kimi", "--mode", form] }, display: KIMI_DISPLAY,
123
+ cli: { command: "kimi", entry: { lifecycleAdmission: true, execute: runKimiEntry }, preview: previewKimi, usage: [["ahub kimi [--print-command] [--mode tui|headless] [--model <alias>]", "default: Kimi's own TUI, pull-only via hub_inbox; no push, steer, watchdog, console approvals or automatic quota handoff. Select headless for ACP", "start Kimi in its own TUI, or headless over ACP"]], launchConfigKeys: ["kimi_cmd", "peers.kimi.start_mode"], stopNotice: form => form === "tui" ? "Kimi belongs to its own TUI terminal; end it in that terminal" : "", startWords: form => ["kimi", "--mode", form] }, display: KIMI_DISPLAY,
124
124
  },
125
125
  {
126
126
  projection: { roleRank: 4, startRank: 0, helpRank: 6, plannerEligible: false, conductorEligible: true, reviewerEligible: true },
@@ -134,7 +134,7 @@ export const NATIVE_BUILTIN_DEFINITIONS_WITHOUT_QWEN: readonly AdapterDefinition
134
134
  session: { idField: "sessionId", currentId: sessionId("sessionId"), restoreOnStart: true, launchKind: "pi", launchRecord: true, ...PI_RECOVERY_SESSION, crashPlan: piCrashPlan, unrecordedTerminal: "tui", continuityBookmark: piRecoveryContinuity, continuity: { key: "pi", parse: parsePiContinuity } },
135
135
  turnEnd: "adapter", settle: { signal: "agent-settled" }, budget: { account: "pi", instrumented: true, noQuotaReason: "on-prem backends have no provider quota" }, reporting: { tokensNotReported: true }, configuration: { schema: piConfigSchema, routingSchema: piRoutingSchema, settings: PI_SETTINGS, restartReasons: PI_RESTART_REASONS, validateEffective: piEffectiveConfig },
136
136
  routing: { localAllowedRefusal: "local_allowed = false also excludes pi for this class", longContext: "backend-limit", preferredTier: true, handoffPriority: 0, trace: "backend", backendLabel: "pi" },
137
- cli: { command: "pi", entry: { lifecycleAdmission: false, execute: runPiEntry }, preview: previewPi, usage: [["ahub pi [--print-command] [--mode headless|tui | --headless] [--backend auto|dgx|mlx] [--model <alias>] [--session-id <id>] [--session-file <path>] [--replace-session]", "start Pi: its TUI in this terminal unless --headless or the start mode setting (peers.pi.start_mode) says headless; without a terminal the hub opens one or says how"]], launchConfigKeys: ["pi.cmd", "pi.backend", "pi.dgx_coding", "pi.dgx_fast", "pi.max_steps", "routing.pi", "peers.pi.start_mode"], previewArgs: ["--mode", "tui"], retainedTerminalNotice: piRetainedTerminalNotice, personOnlyFlags: ["--replace-session"], startWords: form => ["pi", "--mode", form] }, display: PI_DISPLAY,
137
+ cli: { command: "pi", entry: { lifecycleAdmission: false, execute: runPiEntry }, preview: previewPi, usage: [["ahub pi [--print-command] [--mode headless|tui | --headless] [--backend auto|dgx|mlx] [--model <alias>] [--session-id <id>] [--session-file <path>] [--replace-session]", "start Pi: its TUI in this terminal unless --headless or the start mode setting (peers.pi.start_mode) says headless; without a terminal the hub opens one or says how", "start Pi in a terminal, or headless"]], launchConfigKeys: ["pi.cmd", "pi.backend", "pi.dgx_coding", "pi.dgx_fast", "pi.max_steps", "routing.pi", "peers.pi.start_mode"], previewArgs: ["--mode", "tui"], retainedTerminalNotice: piRetainedTerminalNotice, personOnlyFlags: ["--replace-session"], startWords: form => ["pi", "--mode", form] }, display: PI_DISPLAY,
138
138
  },
139
139
  {
140
140
  projection: { roleRank: 3, helpRank: 7, plannerEligible: false, conductorEligible: false, reviewerEligible: true },
@@ -148,7 +148,7 @@ export const NATIVE_BUILTIN_DEFINITIONS_WITHOUT_QWEN: readonly AdapterDefinition
148
148
  session: { idField: "sessionId", currentId: sessionId("sessionId"), freshOnRestore: true, launchKind: "local", ...LOCAL_RECOVERY_SESSION, crashPlan: localCrashPlan },
149
149
  turnEnd: "adapter", settle: { signal: "route-outcome" }, budget: { account: "local", quotaExempt: true, instrumented: true, noQuotaReason: "on-prem gateway has no provider quota" }, configuration: { schema: localConfigSchema, routingSchema: localRoutingSchema, restartReasons: LOCAL_RESTART_REASONS },
150
150
  routing: { localAllowedRefusal: "local_allowed = false for this class", longContext: "skip-owner", preferredTier: true, handoffPriority: 1, trace: "route" },
151
- cli: { command: "local", entry: { lifecycleAdmission: false, execute: runLocalEntry }, usage: [["ahub local [--route <id> | --model <id>]", "start the hub-native worker on the self-hosted models (routing.toml)"]], launchConfigKeys: ["local.deny", "local.bash_network", "local.network_allow", "local.max_steps", "local.read_allow", "routing.local"], startWords: () => ["local"] }, display: LOCAL_DISPLAY,
151
+ cli: { command: "local", entry: { lifecycleAdmission: false, execute: runLocalEntry }, usage: [["ahub local [--route <id> | --model <id>]", "start the hub-native worker on the self-hosted models (routing.toml)", "start the hub-native worker on self-hosted models"]], launchConfigKeys: ["local.deny", "local.bash_network", "local.network_allow", "local.max_steps", "local.read_allow", "routing.local"], startWords: () => ["local"] }, display: LOCAL_DISPLAY,
152
152
  },
153
153
  {
154
154
  projection: { roleRank: 6, startRank: 3, helpRank: 3, plannerEligible: true, conductorEligible: true, reviewerEligible: true },
@@ -161,6 +161,6 @@ export const NATIVE_BUILTIN_DEFINITIONS_WITHOUT_QWEN: readonly AdapterDefinition
161
161
  ask: "no verified hub mode mapping; native policy only", "ask-when-needed": "no verified hub mode mapping; native policy only", "never-ask": "no verified hub mode mapping; native policy only" } },
162
162
  session: { idField: "sessionId", currentId: sessionId("sessionId"), launchKind: "jcode", ...JCODE_RECOVERY_SESSION, crashPlan: jcodeCrashPlan }, turnEnd: "adapter", settle: { signal: "prompt-response" }, budget: { account: "jcode", context: { source: "jcode_usage_update", read: jcodeContextValue } },
163
163
  // Jcode has no dedicated CSS swatch today: retain peer-palette.ts's existing 'other' fallback.
164
- cli: { command: "jcode", entry: { lifecycleAdmission: true, execute: runJcodeEntry }, preview: previewJcode, usage: [["ahub jcode [--mode tui|headless] [--model <alias>] [--provider-profile <name>] [--session-id <id>] [--print-command]", "optional Jcode (roster.jcode, default off): its TUI on the hub-owned ACP session, opened once that session is saved; --mode headless for ACP only; native policy unmanaged, no hub sandbox"]], authority: "person", launchConfigKeys: ["jcode_cmd", "jcode_home", "jcode_provider_profile"], startWords: mode => ["jcode", "--mode", mode] }, display: JCODE_DISPLAY, hooks: { recallPlatform: "jcode" },
164
+ cli: { command: "jcode", entry: { lifecycleAdmission: true, execute: runJcodeEntry }, preview: previewJcode, usage: [["ahub jcode [--mode tui|headless] [--model <alias>] [--provider-profile <name>] [--session-id <id>] [--print-command]", "optional Jcode (roster.jcode, default off): its TUI on the hub-owned ACP session, opened once that session is saved; --mode headless for ACP only; native policy unmanaged, no hub sandbox", "start optional Jcode, in its TUI or headless"]], authority: "person", launchConfigKeys: ["jcode_cmd", "jcode_home", "jcode_provider_profile"], startWords: mode => ["jcode", "--mode", mode] }, display: JCODE_DISPLAY, hooks: { recallPlatform: "jcode" },
165
165
  },
166
166
  ] satisfies AdapterDefinition[]);
@@ -8,7 +8,7 @@ export function nativeConfigurationDefaults(ctx: { home: string; env: Readonly<R
8
8
  return {
9
9
  commands: { kimi_cmd: ["kimi", "acp"], qwen_cmd: ["qwen", "--acp"], jcode_cmd: ["jcode"], jcode_home: ctx.env.JCODE_HOME ?? join(ctx.home, ".jcode"), jcode_provider_profile: "" },
10
10
  proxy: { codex_bin: "codex" },
11
- rpc: { pi: { enabled: false, auto_start: false, cmd: ["pi"], backend: "auto" as const, dgx_coding: "coding", dgx_fast: "fast", max_steps: 30 } },
11
+ rpc: { pi: { enabled: false, auto_start: false, cmd: ["pi"], backend: "auto" as const, dgx_coding: "coding", dgx_fast: "fast", max_steps: 100, max_continuations: 2 } },
12
12
  sandbox: { local: { deny: [] as string[], bash_network: false, network_allow: ctx.networkAllow, max_steps: 30, read_allow: [] as string[], doc_read: false, web_fetch: { allow: [] as string[] } } },
13
13
  };
14
14
  }
@@ -4,7 +4,7 @@ import { webFetchAllow } from "../../local/web-fetch-config.ts";
4
4
 
5
5
  /** Native config uses the host's checked schema vocabulary, retaining its shape/path introspection. */
6
6
  export function piConfigSchema(v: NativeConfigValidators): Record<string, NativeConfigCheck> {
7
- return { pi: v.block({ enabled: v.bool, auto_start: v.bool, cmd: v.argv, backend: v.words(["auto", "dgx", "mlx"]), dgx_coding: v.text, dgx_fast: v.text, max_steps: v.number(1, 1_000_000, true) }) };
7
+ return { pi: v.block({ enabled: v.bool, auto_start: v.bool, cmd: v.argv, backend: v.words(["auto", "dgx", "mlx"]), dgx_coding: v.text, dgx_fast: v.text, max_steps: v.number(1, 1_000_000, true), max_continuations: v.number(0, 10, true) }) };
8
8
  }
9
9
  export function localConfigSchema(v: NativeConfigValidators): Record<string, NativeConfigCheck> {
10
10
  return { local: v.block({ deny: v.strings, bash_network: (value, key) => { if (value !== "direct") v.bool(value, key); }, network_allow: v.strings, max_steps: v.number(1, 1_000_000, true), read_allow: v.strings, doc_read: v.bool, web_fetch: v.block({ allow: (value, key) => { webFetchAllow(value); void key; } }) }) };
@@ -74,7 +74,7 @@ export const QWEN_DEFINITION: AdapterDefinition = {
74
74
  settle: { signal: "message-stop" },
75
75
  budget: { account: "qwen" },
76
76
  capabilities: { watch: true },
77
- cli: { command: "qwen", entry: { lifecycleAdmission: true, execute: runQwenEntry }, preview: previewQwen, usage: [["ahub qwen [--mode headless|tui] [--model <alias>] [--session-id <id>] [--print-command]", `start optional Qwen Code ACP (${describe("qwen")}; roster.qwen, default off); --mode tui runs Qwen's own TUI in this terminal, driven through its dual-output files (${describe("qwen-dual")}); a hub deny ends the turn without an answer and a stalled turn is stopped with Esc in the Qwen terminal`]], launchConfigKeys: ["qwen_cmd"], startWords: () => ["qwen"] },
77
+ cli: { command: "qwen", entry: { lifecycleAdmission: true, execute: runQwenEntry }, preview: previewQwen, usage: [["ahub qwen [--mode headless|tui] [--model <alias>] [--session-id <id>] [--print-command]", `start optional Qwen Code ACP (${describe("qwen")}; roster.qwen, default off); --mode tui runs Qwen's own TUI in this terminal, driven through its dual-output files (${describe("qwen-dual")}); a hub deny ends the turn without an answer and a stalled turn is stopped with Esc in the Qwen terminal`, "start optional Qwen Code, headless or in its TUI"]], launchConfigKeys: ["qwen_cmd"], startWords: () => ["qwen"] },
78
78
  display: QWEN_DISPLAY,
79
79
  hooks: { recallPlatform: "qwen" },
80
80
  };
@@ -41,6 +41,8 @@ export interface LocalOptions {
41
41
  /** #1403 A4: the lifecycle is on and `[security]` is configured, so `hub_audit_report` is listed. */
42
42
  sdlcAudit?: boolean;
43
43
  sdlcSurvey?: boolean;
44
+ /** #1454: the idle sweep is on, so `hub_task_wait` is published. */
45
+ taskWait?: boolean;
44
46
  /** Host-owned conditional instruction, sampled once per delivered turn. */
45
47
  titlePreface?: () => string | undefined;
46
48
  cwd: string;
@@ -246,7 +248,7 @@ export class LocalPeer extends BasePeer {
246
248
  await this.requireBudget(envs, "model_calls");
247
249
  if (generation !== this.turn) throw new Error("route belongs to an ended turn");
248
250
  if (signal.aborted) throw new Error("turn cancelled before model request");
249
- const tools = judge ? undefined : [...this.toolSchemas(), ...(this.opts.taskTool ? [...profileTaskTools(this.opts.profile, this.opts.sdlcStages, this.opts.sdlcCriteria, this.opts.sdlcAudit, this.opts.sdlcSurvey).filter(tool => tool.name !== "hub_delivery_retry"), ...CONDUCTOR_TOOLS].concat(SESSION_TITLE_TOOL).map(asFunction) : [])];
251
+ const tools = judge ? undefined : [...this.toolSchemas(), ...(this.opts.taskTool ? [...profileTaskTools(this.opts.profile, this.opts.sdlcStages, this.opts.sdlcCriteria, this.opts.sdlcAudit, this.opts.sdlcSurvey, this.opts.taskWait).filter(tool => tool.name !== "hub_delivery_retry"), ...CONDUCTOR_TOOLS].concat(SESSION_TITLE_TOOL).map(asFunction) : [])];
250
252
  this.releaseObserverInput(this.currentObserverInputContext, envs);
251
253
  const result = await this.opts.omni.chat({ model, messages, ...(tools ? { tools } : {}), ...(judge ? { max_tokens: maxTokens ?? 2048 } : {}) }, { signal, ...(pii ? { onCampusOnly: true } : {}) });
252
254
  this.recordUsage(result, model, task);
@@ -538,7 +540,7 @@ export class LocalPeer extends BasePeer {
538
540
  const result: ChatMessage = { role: "tool", tool_call_id: call.id, content: output, is_error: toolResultFailed(name, output) };
539
541
  msgs.push(result); results.push(result);
540
542
  if (this.approvalStopReason) { this.abort?.abort(); throw new ApprovalWaitStop(this.approvalStopReason); }
541
- if (!remoteTurn && !reviewScope.excluded && name !== "hub_set_title" && name !== "hub_ask" && !reviewCaptureExcluded(name, call.function.arguments)) this.observeTool(call, output, policy, `${this.sessionId}.${turn}.${step}`);
543
+ if (!remoteTurn && !reviewScope.excluded && name !== "hub_set_title" && name !== "hub_ask" && name !== "hub_ask_answer" && !reviewCaptureExcluded(name, call.function.arguments)) this.observeTool(call, output, policy, `${this.sessionId}.${turn}.${step}`);
542
544
  // Hub tool arguments/results are not capture evidence; Tasks owns its screened memory writes.
543
545
  // doc_read text is converted document content (a converter can surface hidden text), never memory evidence: not captured, whatever the turn.
544
546
  // web_fetch text is a third party's page and its URL is the model's own request: neither is memory evidence either (#515b).
@@ -670,7 +672,7 @@ export class LocalPeer extends BasePeer {
670
672
  }
671
673
  const fixedModel = selection?.model ?? policy?.fixedModel ?? this.opts.fixedModel;
672
674
  const task = policy?.task === undefined ? undefined : Number(policy.task);
673
- const tools = [...this.toolSchemas(), ...(this.opts.taskTool ? [...profileTaskTools(this.opts.profile, this.opts.sdlcStages, this.opts.sdlcCriteria, this.opts.sdlcAudit, this.opts.sdlcSurvey).filter(tool => tool.name !== "hub_delivery_retry"), ...CONDUCTOR_TOOLS].concat(SESSION_TITLE_TOOL).map(asFunction) : [])];
675
+ const tools = [...this.toolSchemas(), ...(this.opts.taskTool ? [...profileTaskTools(this.opts.profile, this.opts.sdlcStages, this.opts.sdlcCriteria, this.opts.sdlcAudit, this.opts.sdlcSurvey, this.opts.taskWait).filter(tool => tool.name !== "hub_delivery_retry"), ...CONDUCTOR_TOOLS].concat(SESSION_TITLE_TOOL).map(asFunction) : [])];
674
676
  const signal = this.abort!.signal;
675
677
  const messages: ChatMessage[] = [{ role: "system", content: fixedPrompt }, ...this.history, ...turnMsgs];
676
678
  const routed = await this.hubCall(route, messages, policy, signal);
@@ -57,7 +57,11 @@ export interface PiOptions {
57
57
  /** Reported message usage as increments, before agent_settled releases the turn. */
58
58
  onTokens?: (added: number) => void;
59
59
  /** `ceiling` is the validated, session/turn-bound tool-step ceiling signal (#179), present only when the trusted extension emitted one for this turn. */
60
- onTurnFailure?: (envs: Envelope[], reason: string, ceiling?: PiToolStepCeiling) => Promise<void>;
60
+ onTurnFailure?: (envs: Envelope[], reason: string, ceiling?: PiToolStepCeiling, settledCeiling?: boolean) => Promise<void>;
61
+ /** Observation only: cancelled/stopped logical turns never request failure handoff. */
62
+ onTurnAborted?: (envs: Envelope[]) => void;
63
+ /** Observation only: a real successful turn resets the host's continuation count. */
64
+ onTurnSuccess?: (envs: Envelope[]) => void;
61
65
  watchdogMs?: number; log?: (line: string) => void;
62
66
  /** Once per owner, after it is offline; a TUI owner may have unknown OS exit status. */
63
67
  onExit?: (exit: PiExit) => void;
@@ -187,8 +191,11 @@ export class PiPeer extends BasePeer {
187
191
  private executionAbort?: AbortController;
188
192
  private readonly budgetStops = new Map<number, string>();
189
193
  private readonly ceilingStops = new Map<number, PiToolStepCeiling>();
194
+ private ceilingUnsafe = false;
195
+ private turnObserved = false;
190
196
  private readonly idleBashReservations = new Map<string, { generation: number; expiresAt: number; deadlineAt?: number }>();
191
197
  private budgetGeneration = 0;
198
+ private settledGeneration: number | undefined;
192
199
  private modelStep = 0;
193
200
  private readonly observationScope = randomUUID();
194
201
  private emptyResumeVerified = false;
@@ -208,6 +215,7 @@ export class PiPeer extends BasePeer {
208
215
  private approvalAbortSent = false;
209
216
  private approvalStopReason = "";
210
217
  private requestedStopReason: string | undefined;
218
+ private stopCause: "aborted" | "failure" | undefined;
211
219
  private owner = randomUUID();
212
220
  private _tuiLaunch?: PiTuiLaunch;
213
221
  private requestedModel = "";
@@ -250,6 +258,11 @@ export class PiPeer extends BasePeer {
250
258
  return { sessionId: this.opts.sessionId, sessionFile: this.opts.sessionFile };
251
259
  }
252
260
  get acceptingTools(): boolean { return !this.stopping && !this.rosterDetached && !this.rosterUnownedRun; }
261
+ /** Failure handoff may follow a verified internal teardown; it never grants tool execution. */
262
+ get failureHandoffAllowed(): boolean {
263
+ return !this.rosterDetached && !this.rosterUnownedRun && this.stopCause !== "aborted"
264
+ && (!this.stopping || this.state === "offline" && this.stopCause === "failure");
265
+ }
253
266
  /** Idle verified owners can be stopped; uncertain live owners and pending launches stay fenced. */
254
267
  get recoveryReady(): boolean {
255
268
  if (this.state === "busy" || this.starting || this.activeTools) return false;
@@ -496,6 +509,8 @@ export class PiPeer extends BasePeer {
496
509
  this.observedTitle = undefined; this.titleRevision = -1; this.nativeTitleEpoch = undefined; this.onDoing?.("reset");
497
510
  this.rosterDetached = false; this.rosterUnownedRun = false;
498
511
  this.requestedStopReason = undefined;
512
+ this.stopCause = undefined;
513
+ this.settledGeneration = undefined;
499
514
  this.approvalTurnAbort = false;
500
515
  this.fencedPrompt = false; this.hubPromptId = undefined; this.hubPromptGeneration = undefined; this.pendingPromptId = undefined;
501
516
  this.exitReported = false; this.started = false; this.lastToolName = undefined; this.shutdownExit = undefined;
@@ -629,9 +644,19 @@ export class PiPeer extends BasePeer {
629
644
  get mode(): "headless" | "tui" { return this.opts.mode; }
630
645
  get form(): StartForm { return this.opts.mode; }
631
646
 
647
+ private observeTurn(outcome: "aborted" | "success"): void {
648
+ if (this.turnObserved || !this.agentRunning && !this.activeEnvs.length) return;
649
+ this.turnObserved = true;
650
+ try {
651
+ if (outcome === "aborted") this.opts.onTurnAborted?.(this.activeEnvs.slice());
652
+ else this.opts.onTurnSuccess?.(this.activeEnvs.slice());
653
+ } catch { /* observation cannot change delivery settlement */ }
654
+ }
655
+
632
656
  /** Withdraw hub admission without shutting down a person's Pi TUI or its bridge. */
633
657
  async detachForRoster(): Promise<void> {
634
658
  if (this.opts.mode !== "tui") throw new Error("Pi roster detach requires a personal TUI");
659
+ this.observeTurn("aborted");
635
660
  this.terminalOwnerObservation = undefined;
636
661
  this.rosterDetached = true; this.rosterEpoch++;
637
662
  this.setState("offline");
@@ -673,7 +698,9 @@ export class PiPeer extends BasePeer {
673
698
  if (!snapshot.idle) this.clearWatchdog();
674
699
  }
675
700
 
676
- async stop(reason?: string, failureCause?: DeliveryFailureCause): Promise<void> {
701
+ async stop(reason?: string, failureCause?: DeliveryFailureCause, cause: "aborted" | "failure" = "aborted"): Promise<void> {
702
+ if (cause === "aborted" || this.stopCause === undefined) this.stopCause = cause;
703
+ if (cause === "aborted") this.observeTurn("aborted");
677
704
  if (reason !== undefined) this.requestedStopReason = reason;
678
705
  this.rosterEpoch++;
679
706
  this.terminalOwnerObservation = undefined;
@@ -759,6 +786,9 @@ export class PiPeer extends BasePeer {
759
786
  if (deliveryId) this.delivery({ id: deliveryId, state: "failed_safe", reason });
760
787
  throw new Error(reason);
761
788
  }
789
+ // ponytail: host turn starts at busy before async model preflight. Later workflow
790
+ // notices wait for the following turn; closing that window needs an ACK-safe prepare/commit port.
791
+ this.turnObserved = false;
762
792
  this.setState("busy"); this.activeEnvs = envs; this.currentReply = replyParent(envs); this.settledText = "";
763
793
  const rosterEpoch = this.rosterEpoch;
764
794
  let attempted = false;
@@ -896,6 +926,7 @@ export class PiPeer extends BasePeer {
896
926
  else {
897
927
  if (this.pendingPromptId || this.activeEnvs.length) {
898
928
  // Await the prompt's exact ACK before deciding whether its effect was absent or uncertain.
929
+ this.observeTurn("aborted");
899
930
  this.rosterDetached = true; this.rosterEpoch++; this.clearWatchdog();
900
931
  this.activeEnvs = []; this.currentReply = undefined; this.settledText = ""; this.settledError = "";
901
932
  this.abortTools();
@@ -929,6 +960,8 @@ export class PiPeer extends BasePeer {
929
960
  return;
930
961
  }
931
962
  if (this.stopping && ["agent_start", "agent_end", "agent_settled"].includes(event.type)) return;
963
+ // Settled generation replay cannot become a failure of the next delivered prompt.
964
+ if (["agent_end", "agent_settled"].includes(event.type) && Number.isSafeInteger(event.generation) && event.generation === this.settledGeneration) return;
932
965
  if (event.type === "session_start") {
933
966
  if (!this.ownerClaimed) { this.ownerClaimed = true; this.ownerToken = String(event.ownerToken ?? ""); }
934
967
  this.approvalTurnAbort = event.approvalTurnAbort === true;
@@ -945,6 +978,7 @@ export class PiPeer extends BasePeer {
945
978
  if ((event.type === "session_title" || event.type === "agent_start" && Object.hasOwn(event, "sessionName")) && event.sessionId === this.sessionId && this.verifiedOwner()) this.observeTitle(event.sessionName, event.titleRevision, event.titleEpoch);
946
979
  if (event.type === "session_shutdown") {
947
980
  this.observedTitle = undefined; this.titleRevision = -1; this.nativeTitleEpoch = undefined; this.onDoing?.("reset");
981
+ if (this.stopCause === undefined) this.stopCause = "failure";
948
982
  const exit = this.exitMetadata("session_shutdown");
949
983
  this.shutdownExit ??= exit; // headless waits for the OS exit, retaining the pre-cleanup turn and stop facts
950
984
  this.stopping = true; this.ownerClaimed = false; this.clearOwnerMonitor(); this.resolveTuiExit?.(); this.resolveTuiExit = undefined;
@@ -967,6 +1001,7 @@ export class PiPeer extends BasePeer {
967
1001
  const generation = Number.isSafeInteger(event.generation) ? event.generation : this.budgetGeneration + 1;
968
1002
  if (generation <= this.budgetGeneration) return;
969
1003
  this.modelStep = 0;
1004
+ this.ceilingUnsafe = false; this.turnObserved = false;
970
1005
  this.approvalExpiries = 0; this.approvalAnswerEpoch = undefined; this.approvalStopReason = ""; this.approvalAbortSent = false; this.abortedToolIds.clear(); this.abortIdsOverflow = false;
971
1006
  this.usageSeen.clear(); this.ceilingStops.clear(); this.abortTools(); this.executionAbort = new AbortController(); this.budgetGeneration = generation; this.noteActivity(); this.agentRunning = true; this.setState("busy");
972
1007
  }
@@ -977,6 +1012,8 @@ export class PiPeer extends BasePeer {
977
1012
  const ceiling = piToolStepCeiling(event);
978
1013
  if (ceiling && ceiling.sessionId === this.sessionId && ceiling.generation === this.budgetGeneration && this.agentRunning && this.state === "busy" && !this.ceilingStops.has(ceiling.generation)) {
979
1014
  this.ceilingStops.set(ceiling.generation, ceiling);
1015
+ // Tools may settle before agent_settled; that cannot erase uncertainty at the ceiling.
1016
+ this.ceilingUnsafe = this.activeTools > 0 || this.pendingToolGenerations.size > 0;
980
1017
  for (const old of this.ceilingStops.keys()) if (old < ceiling.generation - 8) this.ceilingStops.delete(old);
981
1018
  }
982
1019
  }
@@ -998,25 +1035,30 @@ export class PiPeer extends BasePeer {
998
1035
  }
999
1036
  if (event.type === "agent_settled") {
1000
1037
  if (Number.isSafeInteger(event.generation) && event.generation !== this.budgetGeneration) return;
1038
+ this.settledGeneration = this.budgetGeneration;
1001
1039
  clearTimeout(this.executionBudgetTimer); this.executionBudgetTimer = undefined;
1002
1040
  this.agentRunning = false;
1003
1041
  if (typeof event.text === "string" && event.text.trim()) this.settledText = event.text;
1004
1042
  const generation = Number.isSafeInteger(event.generation) ? event.generation : this.budgetGeneration;
1005
1043
  const approvalStopReason = this.approvalStopReason;
1006
- const text = this.settledText.trim(); const error = approvalStopReason || this.budgetStops.get(generation) || this.settledError; const cancelled = !error && this.settledCancelled;
1044
+ const text = this.settledText.trim(); const error = approvalStopReason || this.budgetStops.get(generation) || this.settledError; const cancelled = this.settledCancelled;
1007
1045
  const ceiling = this.ceilingStops.get(generation);
1046
+ const settledCeiling = !!ceiling && !!error && !cancelled && !approvalStopReason && !this.budgetStops.has(generation)
1047
+ && !this.ceilingUnsafe && !this.activeTools && !this.pendingToolGenerations.size && this.acceptingTools;
1048
+ const ceilingReason = settledCeiling && ceiling ? `ceiling steps ${ceiling.count}/${ceiling.limit}` : undefined;
1008
1049
  this.budgetStops.delete(generation);
1009
1050
  this.ceilingStops.delete(generation);
1010
1051
  this.settledText = ""; this.settledError = ""; this.settledCancelled = false;
1011
1052
  // Answer the peers this turn was for, not every peer on the bus (issue #29). activeEnvs still holds the
1012
1053
  // whole delivery here, steered additions included.
1013
1054
  const reply = { inReplyTo: this.currentReply, to: replyAudience(this.activeEnvs) };
1014
- if (cancelled) this.onMessage?.("Pi turn cancelled; inspect any partial effects before continuing.", reply);
1015
- else if (error?.startsWith("execution budget")) this.onMessage?.(`Pi stopped at the execution budget: ${error}. Inspect partial work before continuing.`, reply);
1016
- else if (approvalStopReason) this.onMessage?.(approvalStopReason, reply);
1017
- else if (error) void this.opts.onTurnFailure?.(this.activeEnvs, error, ceiling);
1018
- else if (text) this.finalAnswer(text, reply);
1019
- for (const id of this.activeDeliveryIds) this.delivery({ id, state: approvalStopReason ? "completed" : error || cancelled ? "needs_review" : "completed", ...(error || cancelled ? { reason: error || "Pi turn cancelled; partial effects are possible" } : {}) });
1055
+ if (cancelled) { this.observeTurn("aborted"); this.onMessage?.("Pi turn cancelled; inspect any partial effects before continuing.", reply); }
1056
+ else if (error?.startsWith("execution budget")) { this.observeTurn("aborted"); this.onMessage?.(`Pi stopped at the execution budget: ${error}. Inspect partial work before continuing.`, reply); }
1057
+ else if (approvalStopReason) { this.observeTurn("aborted"); this.onMessage?.(approvalStopReason, reply); }
1058
+ else if (error && !this.turnObserved) { this.turnObserved = true; void this.opts.onTurnFailure?.(this.activeEnvs, error, ceiling, settledCeiling); }
1059
+ else if (error) { /* This logical turn was already observed, including legacy unnumbered replays. */ }
1060
+ else { this.observeTurn("success"); if (text) this.finalAnswer(text, reply); }
1061
+ for (const id of this.activeDeliveryIds) this.delivery({ id, state: approvalStopReason || settledCeiling ? "completed" : error || cancelled ? "needs_review" : "completed", ...(ceilingReason ? { reason: ceilingReason } : error || cancelled ? { reason: error || "Pi turn cancelled; partial effects are possible" } : {}) });
1020
1062
  this.activeDeliveryIds.clear();
1021
1063
  this.currentReply = undefined; this.activeEnvs = [];
1022
1064
  this.hubPromptId = undefined; this.hubPromptGeneration = undefined;
@@ -1093,7 +1135,8 @@ export class PiPeer extends BasePeer {
1093
1135
  const envs = this.activeEnvs; this.activeEnvs = [];
1094
1136
  for (const id of this.activeDeliveryIds) this.delivery({ id, state: "needs_review", reason: error.message });
1095
1137
  this.activeDeliveryIds.clear();
1096
- if (envs.length && !this.requestedStopReason && !this.rosterDetached) {
1138
+ if (envs.length && !this.requestedStopReason && !this.rosterDetached && !this.turnObserved) {
1139
+ this.turnObserved = true;
1097
1140
  this.onMessage?.(approvalStopReason ? `${approvalStopReason} Pi is offline because its extension could not abort the turn; restart with ahub pi and settle the held delivery after inspecting prior work.` : "Pi turn failed; inspect its session and any partial effects before continuing.", { inReplyTo: this.currentReply });
1098
1141
  if (!approvalStopReason && !(error instanceof ApprovalWaitStop)) void this.opts.onTurnFailure?.(envs, error.message).catch(() => this.opts.log?.("Pi failure handoff could not be completed"));
1099
1142
  }
@@ -1137,7 +1180,7 @@ export class PiPeer extends BasePeer {
1137
1180
  const envs = this.activeEnvs.slice(), reply = this.currentReply;
1138
1181
  this.stopping = true;
1139
1182
  try {
1140
- await this.stop(undefined, failureCause);
1183
+ await this.stop(undefined, failureCause, "failure");
1141
1184
  // The process exit handler may already have reported this failure.
1142
1185
  if (this.activeEnvs.length) this.fail(error);
1143
1186
  } catch (stopError) {
@@ -347,7 +347,8 @@ export interface AdapterDefinition {
347
347
  /** Fixed builtin CLI ports; project definitions cannot supply these callbacks. */
348
348
  entry?: Readonly<Omit<BuiltinCliEntry, "command">>;
349
349
  preview?: NativePreviewBuilder;
350
- usage?: readonly (readonly [usage: string, description: string])[];
350
+ /** `[usage, description, summary?]`: the optional third element is the one-line row of `ahub help` for this form (#1504; three or more words, at most 56 cells). It rides this field's fixed-builtin restriction. */
351
+ usage?: readonly (readonly [usage: string, description: string, summary?: string])[];
351
352
  /** Configuration leaves that select this peer's next native launch command or provider profile. */
352
353
  launchConfigKeys?: readonly string[];
353
354
  /** Restrictions only; core identity remains authoritative. */
@@ -14,7 +14,7 @@ import { nativeReviewerQuota, type NativeReviewerQuota } from "./definitions/nat
14
14
 
15
15
  /** #722: the closed list of legs a reviewer's per-review start can fail on. A class names a leg, never a path, content or token. */
16
16
  class ReviewerUsageCleanupError extends PrintChildCleanupError {}
17
- export const REVIEWER_CAUSE_CLASSES = ["version", "binary", "mcp_inventory", "plugins_hooks_apps", "sandbox_proof", "credential_root", "timeout", "unknown"] as const;
17
+ export const REVIEWER_CAUSE_CLASSES = ["version", "binary", "mcp_inventory", "plugins_hooks_apps", "sandbox_proof", "credential_root", "fixture_root_denied", "timeout", "unknown"] as const;
18
18
  export type ReviewerCauseClass = typeof REVIEWER_CAUSE_CLASSES[number];
19
19
  const REVIEWER_CAUSE_HINT: Record<ReviewerCauseClass, string> = {
20
20
  version: "the CLI version is neither verified nor trusted; see ahub agents",
@@ -23,6 +23,7 @@ const REVIEWER_CAUSE_HINT: Record<ReviewerCauseClass, string> = {
23
23
  plugins_hooks_apps: "plugins, hooks or apps could not be proven disabled",
24
24
  sandbox_proof: "the native sandbox proof did not pass",
25
25
  credential_root: "a host credential root is unusable; remove or repair it",
26
+ fixture_root_denied: "a deny entry contains every directory the proof could use for its fixture; move TMPDIR or narrow the entry",
26
27
  timeout: "a proof command timed out",
27
28
  unknown: "unclassified; inspect hub.log",
28
29
  };
@@ -1,4 +1,4 @@
1
- import { QUESTION_SET } from "../hub/questions.ts";
1
+ import { parseAnswerInstruction, QUESTION_SET } from "../hub/questions.ts";
2
2
 
3
3
  /**
4
4
  * #1053 T4: `ahub answer <set> <question>=<option>[,<option>]... [--other <text>]...`. Pure: it turns argv into the `answers` list the hub validates
@@ -9,7 +9,7 @@ import { QUESTION_SET } from "../hub/questions.ts";
9
9
  */
10
10
 
11
11
  const ID = /^[A-Za-z0-9_.-]{1,64}$/;
12
- export interface ParsedAnswer { set: string; answers: { questionId: string; optionIds: string[]; other?: string }[] }
12
+ export interface ParsedAnswer { set: string; instruction?: string; answers: { questionId: string; optionIds: string[]; other?: string }[] }
13
13
  export type AnswerArgs = { ok: true; value: ParsedAnswer } | { ok: false; error: string };
14
14
  export const ANSWER_USAGE = "usage: ahub answer <set> <question>=<option>[,<option>] [--other <text>] (ahub answer lists the open questions)";
15
15
 
@@ -17,9 +17,17 @@ export function parseAnswerArgs(args: readonly string[]): AnswerArgs {
17
17
  const fail = (error: string): { ok: false; error: string } => ({ ok: false, error });
18
18
  const [set, ...rest] = args;
19
19
  if (!set || !QUESTION_SET.test(set)) return fail(`${ANSWER_USAGE}; the set looks like qs-0123456789ab`);
20
+ let instruction: string | undefined;
20
21
  const picks = new Map<string, string[]>(), others: string[] = [];
21
22
  for (let index = 0; index < rest.length; index++) {
22
23
  const word = rest[index]!;
24
+ if (word === "--instructed") {
25
+ if (instruction !== undefined) return fail("--instructed may appear once; correct it or use ahub console");
26
+ const parsed = parseAnswerInstruction(rest[++index]);
27
+ if (!parsed.ok) return fail(`${parsed.error}; supply --instructed with the person's quote, or use ahub console`);
28
+ instruction = parsed.value;
29
+ continue;
30
+ }
23
31
  if (word === "--other" || word.startsWith("--other=")) {
24
32
  const value = word === "--other" ? rest[++index] : word.slice("--other=".length);
25
33
  if (value === undefined || value === "") return fail("--other needs the text to give");
@@ -46,5 +54,5 @@ export function parseAnswerArgs(args: readonly string[]): AnswerArgs {
46
54
  if (other.has(target)) return fail(`question ${target} has two --other texts`);
47
55
  other.set(target, named ? text.slice(at + 1) : text);
48
56
  }
49
- return { ok: true, value: { set, answers: [...picks].map(([questionId, optionIds]) => ({ questionId, optionIds, ...(other.has(questionId) ? { other: other.get(questionId)! } : {}) })) } };
57
+ return { ok: true, value: { set, ...(instruction === undefined ? {} : { instruction }), answers: [...picks].map(([questionId, optionIds]) => ({ questionId, optionIds, ...(other.has(questionId) ? { other: other.get(questionId)! } : {}) })) } };
50
58
  }
@@ -18,7 +18,7 @@ export interface FlowStep { flow?: QuestionFlow; answers?: FlowAnswer[]; notice?
18
18
  export function questionRows(raw: unknown): QuestionView[] {
19
19
  if (!Array.isArray(raw)) return [];
20
20
  return raw.flatMap<QuestionView>(row => {
21
- if (!row || typeof row !== "object" || typeof row.set !== "string" || typeof row.peer !== "string" || !Array.isArray(row.questions) || !row.questions.length) return [];
21
+ if (!row || typeof row !== "object" || (row.state !== undefined && row.state !== "open") || typeof row.set !== "string" || typeof row.peer !== "string" || !Array.isArray(row.questions) || !row.questions.length) return [];
22
22
  return [{ set: row.set, peer: row.peer, created: Number.isSafeInteger(row.created) ? row.created : 0, ...(row.private === true ? { private: true } : {}), questions: row.questions as AskQuestion[] }];
23
23
  }).sort((a, b) => a.created - b.created || a.set.localeCompare(b.set));
24
24
  }