@sema-agent/core 5.20.0 → 5.21.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 (312) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/agents/agent-definition.d.ts +7 -0
  3. package/dist/agents/agent-transcript-tool.d.ts +30 -0
  4. package/dist/agents/builtin-agents.d.ts +60 -0
  5. package/dist/agents/cascade.d.ts +107 -0
  6. package/dist/agents/cumulative-stats.d.ts +56 -0
  7. package/dist/agents/observer.d.ts +162 -0
  8. package/dist/agents/peer-admission.d.ts +95 -0
  9. package/dist/agents/repair-loop.d.ts +226 -0
  10. package/dist/agents/retain-ledger.d.ts +141 -0
  11. package/dist/agents/roster-store.d.ts +105 -0
  12. package/dist/agents/send-message-tool.d.ts +92 -0
  13. package/dist/agents/session-util.d.ts +5 -0
  14. package/dist/agents/subagent-steps.d.ts +66 -0
  15. package/dist/agents/subagent.d.ts +600 -0
  16. package/dist/agents/suspend-guard.d.ts +29 -0
  17. package/dist/agents/teacher.d.ts +75 -0
  18. package/dist/agents/team.d.ts +120 -1
  19. package/dist/agents/tool-filter.d.ts +34 -0
  20. package/dist/agents/verify.d.ts +198 -0
  21. package/dist/bench/metrics.d.ts +455 -0
  22. package/dist/brain/anthropic.d.ts +30 -0
  23. package/dist/brain/circuit-breaker.d.ts +33 -0
  24. package/dist/brain/context-overflow.d.ts +60 -3
  25. package/dist/brain/degrading.d.ts +67 -0
  26. package/dist/brain/errors.d.ts +42 -0
  27. package/dist/brain/failover.d.ts +15 -0
  28. package/dist/brain/media-degrade.d.ts +39 -0
  29. package/dist/brain/model-presets.d.ts +31 -0
  30. package/dist/brain/open-responses.d.ts +19 -0
  31. package/dist/brain/openai.d.ts +46 -0
  32. package/dist/brain/reasoning.d.ts +106 -1
  33. package/dist/brain/repetition.d.ts +83 -0
  34. package/dist/brain/request-params.d.ts +56 -0
  35. package/dist/brain/retry.d.ts +46 -0
  36. package/dist/brain/routing.d.ts +12 -0
  37. package/dist/brain/status-sink.d.ts +30 -1
  38. package/dist/brain/stream-engine.d.ts +147 -0
  39. package/dist/brain/stream-shared.d.ts +34 -0
  40. package/dist/brain/terminal-cause.d.ts +31 -0
  41. package/dist/brain/timeout.d.ts +107 -0
  42. package/dist/brain/tool-call-id.d.ts +20 -0
  43. package/dist/brain/tool-call-repair.d.ts +13 -0
  44. package/dist/config/catalog.d.ts +47 -0
  45. package/dist/config/defaults.d.ts +33 -0
  46. package/dist/core/a2a-task-state.d.ts +53 -0
  47. package/dist/core/a2a.d.ts +51 -0
  48. package/dist/core/arg-summary.d.ts +62 -0
  49. package/dist/core/ask-question.d.ts +272 -2
  50. package/dist/core/auto-compaction.d.ts +467 -0
  51. package/dist/core/auto-compaction.js +20 -6
  52. package/dist/core/auto-mode-prompt-assets.d.ts +8 -0
  53. package/dist/core/auto-mode-prompt.d.ts +27 -0
  54. package/dist/core/auto-mode.d.ts +54 -3
  55. package/dist/core/auto-promote.d.ts +100 -0
  56. package/dist/core/background-agent-store.d.ts +292 -0
  57. package/dist/core/background-shell.d.ts +110 -0
  58. package/dist/core/cache-break-detector.d.ts +34 -0
  59. package/dist/core/canonical-json.d.ts +57 -0
  60. package/dist/core/checkpoint-store.d.ts +1574 -16
  61. package/dist/core/compliance.d.ts +30 -0
  62. package/dist/core/consolidate-scope.d.ts +75 -0
  63. package/dist/core/context-edit.d.ts +99 -0
  64. package/dist/core/context-guard.d.ts +46 -0
  65. package/dist/core/exec-gate.d.ts +44 -0
  66. package/dist/core/exec-output-tail.d.ts +61 -0
  67. package/dist/core/file-snapshot-store.d.ts +104 -0
  68. package/dist/core/fs-write-gate-policy.d.ts +36 -0
  69. package/dist/core/git-worktree-env.d.ts +31 -0
  70. package/dist/core/governance-codes.d.ts +19 -0
  71. package/dist/core/hooks.d.ts +608 -1
  72. package/dist/core/human-input-projection.d.ts +37 -0
  73. package/dist/core/human-input-projection.js +13 -0
  74. package/dist/core/image-downsample.d.ts +74 -0
  75. package/dist/core/locked-config.d.ts +37 -0
  76. package/dist/core/lsp-diagnostics.d.ts +77 -0
  77. package/dist/core/lsp-protocol.d.ts +29 -0
  78. package/dist/core/lsp-session.d.ts +60 -1
  79. package/dist/core/lsp.d.ts +150 -1
  80. package/dist/core/mailbox-store.d.ts +57 -0
  81. package/dist/core/mcp.d.ts +381 -0
  82. package/dist/core/media-byte-cap.d.ts +21 -0
  83. package/dist/core/memory-admission.d.ts +71 -0
  84. package/dist/core/memory-engine/content-origin.d.ts +64 -0
  85. package/dist/core/memory-engine/data-plane.d.ts +43 -0
  86. package/dist/core/memory-engine/dual-root.d.ts +24 -0
  87. package/dist/core/memory-engine/engine.d.ts +230 -0
  88. package/dist/core/memory-engine/engine.js +103 -35
  89. package/dist/core/memory-engine/file-backend.d.ts +155 -0
  90. package/dist/core/memory-engine/frontmatter.d.ts +16 -0
  91. package/dist/core/memory-engine/layout.d.ts +217 -0
  92. package/dist/core/memory-engine/memory-backend-contract.d.ts +12 -0
  93. package/dist/core/memory-engine/migrate.d.ts +9 -0
  94. package/dist/core/memory-engine/scan.d.ts +12 -0
  95. package/dist/core/memory-engine/scope-contract.d.ts +61 -1
  96. package/dist/core/memory-engine/sync-client.d.ts +87 -0
  97. package/dist/core/memory-engine/sync.d.ts +60 -0
  98. package/dist/core/memory-engine/tools.d.ts +41 -0
  99. package/dist/core/memory-engine/types.d.ts +188 -0
  100. package/dist/core/memory-recall.d.ts +141 -0
  101. package/dist/core/memory-vector.d.ts +20 -0
  102. package/dist/core/memory.d.ts +458 -0
  103. package/dist/core/message-utils.d.ts +6 -0
  104. package/dist/core/oracle-isolation.d.ts +69 -0
  105. package/dist/core/permission-rule-consent.d.ts +138 -0
  106. package/dist/core/permission-rule-model.d.ts +122 -0
  107. package/dist/core/permission-rule-store.d.ts +119 -3
  108. package/dist/core/permission-rules.d.ts +87 -1
  109. package/dist/core/present-plan-tool.d.ts +20 -0
  110. package/dist/core/pricing.d.ts +26 -0
  111. package/dist/core/property-harness.d.ts +86 -0
  112. package/dist/core/protocol-naming.d.ts +38 -0
  113. package/dist/core/protocol-table.d.ts +61 -0
  114. package/dist/core/push-queue.d.ts +1 -0
  115. package/dist/core/remote-env.d.ts +383 -1
  116. package/dist/core/retention-policy.d.ts +33 -0
  117. package/dist/core/retention.d.ts +51 -0
  118. package/dist/core/roles.d.ts +59 -0
  119. package/dist/core/runner/active-skill-scope.d.ts +34 -0
  120. package/dist/core/runner/assemble-result.d.ts +134 -0
  121. package/dist/core/runner/compaction-call-options.d.ts +97 -1
  122. package/dist/core/runner/grounding-signal.d.ts +10 -0
  123. package/dist/core/runner/image.d.ts +17 -0
  124. package/dist/core/runner/image.js +29 -15
  125. package/dist/core/runner/memory-consolidation.d.ts +60 -0
  126. package/dist/core/runner/prepare-memory.d.ts +59 -0
  127. package/dist/core/runner/prepare-task.d.ts +1011 -2
  128. package/dist/core/runner/prepare-task.js +12 -11
  129. package/dist/core/runner/prompt-suggestions.d.ts +7 -0
  130. package/dist/core/runner/runtask.d.ts +304 -3
  131. package/dist/core/runner/session-file-state-replay.d.ts +49 -0
  132. package/dist/core/runner/session-rule-policy.d.ts +58 -0
  133. package/dist/core/runner/strict-output-schema.d.ts +18 -3
  134. package/dist/core/runner/synthetic-tools.d.ts +113 -0
  135. package/dist/core/runner/teardown-bounded.d.ts +34 -0
  136. package/dist/core/runner/tool-disclosure.d.ts +227 -0
  137. package/dist/core/runner/tool-output-projection.d.ts +6 -0
  138. package/dist/core/runner/turn-attachments.d.ts +634 -0
  139. package/dist/core/runner/usage-accounting.d.ts +32 -0
  140. package/dist/core/runtime.d.ts +9 -0
  141. package/dist/core/safe-notify.d.ts +64 -0
  142. package/dist/core/safety-axis-vocab.d.ts +23 -0
  143. package/dist/core/safety-merge-corpus.d.ts +37 -0
  144. package/dist/core/scheduler.d.ts +121 -0
  145. package/dist/core/secret-env.d.ts +32 -0
  146. package/dist/core/select-model.d.ts +15 -0
  147. package/dist/core/sensitive-path-policy.d.ts +42 -0
  148. package/dist/core/session-policy-store.d.ts +94 -0
  149. package/dist/core/session-reconcile.d.ts +80 -0
  150. package/dist/core/session-store.d.ts +85 -0
  151. package/dist/core/session.d.ts +153 -0
  152. package/dist/core/shared-memory/contract.d.ts +22 -0
  153. package/dist/core/shared-memory/normalize.d.ts +123 -2
  154. package/dist/core/shared-memory/tools.d.ts +14 -0
  155. package/dist/core/shared-memory/types.d.ts +105 -0
  156. package/dist/core/shutdown-debug.d.ts +6 -0
  157. package/dist/core/side-query.d.ts +38 -0
  158. package/dist/core/side-query.js +6 -1
  159. package/dist/core/skill-tool-specifier.d.ts +72 -0
  160. package/dist/core/skills-directory.d.ts +100 -1
  161. package/dist/core/spec-contract.d.ts +89 -0
  162. package/dist/core/store-contracts/background-agent-store-contract.d.ts +31 -0
  163. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +26 -0
  164. package/dist/core/store-contracts/contract-harness.d.ts +20 -0
  165. package/dist/core/store-contracts/contract-kit-version.d.ts +27 -0
  166. package/dist/core/store-contracts/file-snapshot-store-contract.d.ts +8 -0
  167. package/dist/core/store-contracts/mailbox-store-contract.d.ts +42 -0
  168. package/dist/core/store-contracts/tool-result-store-contract.d.ts +13 -0
  169. package/dist/core/strategy-store.d.ts +37 -0
  170. package/dist/core/stub-env.d.ts +7 -0
  171. package/dist/core/surrogate-safe-slice.d.ts +35 -0
  172. package/dist/core/task-notification.d.ts +202 -0
  173. package/dist/core/task-outcome.d.ts +53 -0
  174. package/dist/core/task-registry-agent.d.ts +337 -1
  175. package/dist/core/task-registry-monitor.d.ts +12 -0
  176. package/dist/core/task-registry-shared.d.ts +540 -0
  177. package/dist/core/task-registry.d.ts +343 -0
  178. package/dist/core/task-registry.js +13 -2
  179. package/dist/core/task-tool-shape.d.ts +44 -0
  180. package/dist/core/tighten-task-spec.d.ts +21 -0
  181. package/dist/core/tool-detach.d.ts +21 -0
  182. package/dist/core/tool-errors.d.ts +131 -0
  183. package/dist/core/tool-errors.js +4 -0
  184. package/dist/core/tool-name-aliases.d.ts +27 -0
  185. package/dist/core/tool-policy.d.ts +555 -0
  186. package/dist/core/tool-result-budget.d.ts +32 -0
  187. package/dist/core/tool-result-store.d.ts +174 -1
  188. package/dist/core/tools.d.ts +45 -0
  189. package/dist/core/trace.d.ts +323 -0
  190. package/dist/core/types.d.ts +3859 -2
  191. package/dist/core/untrusted-egress.d.ts +8 -0
  192. package/dist/core/untrusted-text.d.ts +156 -0
  193. package/dist/core/usage-window-store.d.ts +95 -0
  194. package/dist/core/version.d.ts +1 -0
  195. package/dist/core/warm-resume.d.ts +17 -0
  196. package/dist/core/wiring-manifest.d.ts +169 -0
  197. package/dist/core/with-retry.d.ts +24 -0
  198. package/dist/core/workflow-journal-store.d.ts +160 -0
  199. package/dist/core/workflow-run-store-contract.d.ts +25 -0
  200. package/dist/core/workflow-run-store.d.ts +119 -0
  201. package/dist/engine/compaction/compaction.d.ts +256 -1
  202. package/dist/engine/compaction/utils.d.ts +94 -0
  203. package/dist/engine/execution-env/kill-tree.d.ts +29 -0
  204. package/dist/engine/execution-env/node-execution-env.d.ts +94 -0
  205. package/dist/engine/harness/agent-harness.d.ts +116 -0
  206. package/dist/engine/harness/agent-harness.js +3 -14
  207. package/dist/engine/harness/messages.d.ts +15 -0
  208. package/dist/engine/harness/types.d.ts +464 -2
  209. package/dist/engine/llm/diagnostics.d.ts +4 -0
  210. package/dist/engine/llm/event-stream.d.ts +3 -0
  211. package/dist/engine/llm/index.d.ts +7 -0
  212. package/dist/engine/llm/types.d.ts +500 -3
  213. package/dist/engine/llm/validation.d.ts +3 -0
  214. package/dist/engine/loop/agent-loop.d.ts +87 -2
  215. package/dist/engine/loop/runtime-deps.d.ts +7 -0
  216. package/dist/engine/loop/types.d.ts +424 -0
  217. package/dist/engine/lsp/frame-decoder.d.ts +13 -0
  218. package/dist/engine/lsp/node-lsp-manager.d.ts +107 -0
  219. package/dist/engine/lsp/stdio-lsp-transport.d.ts +7 -0
  220. package/dist/engine/session/import-validate.d.ts +27 -0
  221. package/dist/engine/session/log-digest.d.ts +93 -0
  222. package/dist/engine/session/memory-repo.d.ts +6 -0
  223. package/dist/engine/session/memory-storage.d.ts +2 -0
  224. package/dist/engine/session/session.d.ts +75 -0
  225. package/dist/engine/session/storage-base.d.ts +8 -0
  226. package/dist/fixtures/index.d.ts +36 -0
  227. package/dist/index.d.ts +16 -1
  228. package/dist/index.js +0 -1
  229. package/dist/internal/harness-types.d.ts +6 -0
  230. package/dist/internal/harness.d.ts +11 -0
  231. package/dist/internal/llm.d.ts +6 -0
  232. package/dist/orchestration/builtin-workflows.d.ts +53 -0
  233. package/dist/orchestration/dev-vm-script-runner.d.ts +19 -0
  234. package/dist/orchestration/goal.d.ts +57 -0
  235. package/dist/orchestration/goal.js +3 -0
  236. package/dist/orchestration/run-spec.d.ts +42 -0
  237. package/dist/orchestration/run-workflow-tool.d.ts +169 -0
  238. package/dist/orchestration/workflow-governance.d.ts +61 -0
  239. package/dist/orchestration/workflow-meta.d.ts +28 -0
  240. package/dist/orchestration/workflow-observe.d.ts +60 -0
  241. package/dist/orchestration/workflow-primitives.d.ts +23 -1
  242. package/dist/orchestration/workflow-sandbox-conformance.d.ts +38 -0
  243. package/dist/orchestration/workflow-script-runner.d.ts +88 -0
  244. package/dist/orchestration/workflow-script-store.d.ts +98 -0
  245. package/dist/orchestration/workflow-size-guideline.d.ts +67 -0
  246. package/dist/orchestration/workflow-types.d.ts +169 -2
  247. package/dist/orchestration/workflow.d.ts +358 -0
  248. package/dist/prompt-assembly/artifact-store.d.ts +33 -0
  249. package/dist/prompt-assembly/artifact.d.ts +25 -0
  250. package/dist/prompt-assembly/assemble.d.ts +20 -0
  251. package/dist/prompt-assembly/composer.d.ts +29 -0
  252. package/dist/prompt-assembly/epoch.d.ts +55 -1
  253. package/dist/prompt-assembly/event-registry.d.ts +35 -0
  254. package/dist/prompt-assembly/explain.d.ts +12 -0
  255. package/dist/prompt-assembly/tool-catalog.d.ts +38 -0
  256. package/dist/prompt-assembly/turn-snapshot.d.ts +40 -0
  257. package/dist/prompt-assembly/types.d.ts +115 -0
  258. package/dist/prompts/coordinator.d.ts +27 -0
  259. package/dist/prompts/default.d.ts +539 -0
  260. package/dist/prompts/simple-sections.d.ts +45 -0
  261. package/dist/prompts/supervisor.d.ts +66 -0
  262. package/dist/scenarios/env.d.ts +28 -0
  263. package/dist/scenarios/full-body.d.ts +50 -0
  264. package/dist/scenarios/scenario-registry.d.ts +60 -0
  265. package/dist/scenarios/teacher-quickstart.d.ts +27 -0
  266. package/dist/server/http.d.ts +17 -0
  267. package/dist/stores/cc/lockfile.d.ts +6 -0
  268. package/dist/stores/cc/mailbox-store.d.ts +8 -0
  269. package/dist/stores/cc/roster-adapter.d.ts +4 -0
  270. package/dist/stores/cc/sidecar-transcript.d.ts +66 -0
  271. package/dist/stores/file/background-agent-store.d.ts +24 -0
  272. package/dist/stores/file/checkpoint-store.d.ts +38 -0
  273. package/dist/stores/file/file-snapshot-store.d.ts +25 -0
  274. package/dist/stores/file/fs-atomic.d.ts +155 -0
  275. package/dist/stores/file/index.d.ts +89 -0
  276. package/dist/stores/file/mailbox-store.d.ts +36 -0
  277. package/dist/stores/file/memory-store.d.ts +82 -0
  278. package/dist/stores/file/permission-rule-store.d.ts +79 -0
  279. package/dist/stores/file/session-policy-store.d.ts +28 -0
  280. package/dist/stores/file/session-store.d.ts +40 -0
  281. package/dist/stores/file/shared-ledger.d.ts +83 -0
  282. package/dist/stores/file/tool-result-store.d.ts +11 -0
  283. package/dist/stores/file/usage-window-store.d.ts +18 -0
  284. package/dist/stores/file/workflow-journal-store.d.ts +100 -0
  285. package/dist/stores/file/workflow-run-store.d.ts +11 -0
  286. package/dist/tools/fs/bash-readonly-classifier.d.ts +282 -0
  287. package/dist/tools/fs/encoding.d.ts +60 -0
  288. package/dist/tools/fs/fs-bash.d.ts +133 -0
  289. package/dist/tools/fs/fs-pdf.d.ts +28 -0
  290. package/dist/tools/fs/fs-search-tools.d.ts +5 -0
  291. package/dist/tools/fs/fs-shared.d.ts +360 -0
  292. package/dist/tools/fs/fs-write.d.ts +16 -0
  293. package/dist/tools/fs/gh-rate-limit.d.ts +22 -0
  294. package/dist/tools/fs/index.d.ts +79 -0
  295. package/dist/tools/fs/notebook.d.ts +56 -0
  296. package/dist/tools/fs/pdf.d.ts +70 -0
  297. package/dist/tools/fs/pdf.js +8 -2
  298. package/dist/tools/fs/repo-map.d.ts +10 -0
  299. package/dist/tools/fs/safety.d.ts +376 -0
  300. package/dist/tools/fs/search.d.ts +131 -0
  301. package/dist/tools/loop-tick.d.ts +24 -0
  302. package/dist/tools/monitor.d.ts +55 -0
  303. package/dist/tools/scheduler-tools.d.ts +51 -0
  304. package/dist/tools/sql-adapters.d.ts +18 -0
  305. package/dist/tools/sql.d.ts +25 -0
  306. package/dist/tools/task-list.d.ts +77 -0
  307. package/dist/tools/todo.d.ts +8 -0
  308. package/dist/tools/web.d.ts +184 -0
  309. package/dist/tools/worktree.d.ts +81 -0
  310. package/package.json +2 -2
  311. package/dist/tools/gitea-issue.d.ts +0 -13
  312. package/dist/tools/gitea-issue.js +0 -75
@@ -2,8 +2,49 @@ import { Type, type Static } from "typebox";
2
2
  import type { Runner, ResumeTaskConfig } from "../core/runner/runtask.js";
3
3
  import type { CheckpointGate, CheckpointToken, ResumeOutcome } from "../core/checkpoint-store.js";
4
4
  import type { ModelRef, TaskResult, TaskSpec, ToolSpec } from "../core/types.js";
5
+ /**
6
+ * Verification gate (developer mode, design/28 §4). An **independent adversarial verifier** runs after
7
+ * an implementation task and tries to BREAK it — read-only, evidence-required, returning a structured
8
+ * verdict — then the gate loops fix→re-verify until PASS or a round cap.
9
+ *
10
+ * PROVENANCE (2026-07-14; RB-306 ④ — re-verified and CORRECTED against CC 2.1.220): distilled and
11
+ * de-branded from the MIT-era upstream source's dedicated `verification` agent — which was an
12
+ * Anthropic-internal A/B experiment (third-party default OFF) and has since been RETIRED upstream:
13
+ * 2.1.207 through 2.1.220 ship NO verification agent. The current upstream completion-gate shape is
14
+ * (a) the Stop hook (`decision:"block"` + reason fed back — sema's Stop hook is at full parity) and
15
+ * (b) — corrected — NOT a bundled skill. There is no built-in `verify` skill in the 220 corpus. What
16
+ * 220 ships is an INSTRUCTION TO CREATE ONE PER PROJECT: its memory prompt (@190146) forbids creating
17
+ * project skills ("never create one — a new project skill silently shadows a same-named built-in
18
+ * skill") and makes exactly one exception — "The single exception is verify, because how a project
19
+ * verifies changes is project-specific: put a verify correction in the `.claude/skills/verify/
20
+ * SKILL.md` closest to the code it covers … and if that file does not exist, create it." So upstream's
21
+ * position is "verification is project-specific; teach the user's repo to describe its own", not "here
22
+ * is a verifier". This primitive is therefore a SUPERSET of what upstream ships in a different
23
+ * direction than the old note implied: a spawned adversarial verifier with a fix loop, bundled. It is
24
+ * orthogonal to and composable with the Stop hook (wire the verdict into a stop() hook to make it a
25
+ * hard completion gate).
26
+ *
27
+ * DEPLOYMENT POSTURE (clay 裁定 2026-07-14): opt-in library primitive ONLY — never a scenario default,
28
+ * never deployed implicitly. It is a **thin composition** over existing core seams — a verifier subtask
29
+ * (own model role), a read-only tool set (via tool `effect`), {@link TaskSpec.outputSchema} for the
30
+ * verdict, and the teacher-style fix loop — so it adds no Runner-core surface. Off by default; opt in
31
+ * per task via {@link runWithVerification} (or {@link runDeveloperTask}).
32
+ *
33
+ * Boundary vs teacher mode: teacher's Tier-1 is a *lenient* rubric verifier that triggers escalation to
34
+ * an advisor (stuck/wrong recovery); this is a *strict adversarial* completion gate with a fix loop.
35
+ * Orthogonal, composable, not merged.
36
+ */
5
37
  export declare const VERIFICATION_PROMPT = "You are a verification specialist. Your job is NOT to confirm the implementation works \u2014 it is to try to BREAK it.\n\nYou have two documented failure patterns. First, verification avoidance: faced with a check, you find reasons not to run it \u2014 you read code, narrate what you would test, declare \"PASS,\" and move on. Second, being seduced by the first 80%: a polished result or a passing test suite makes you inclined to pass it, not noticing the edge that crashes, the state that vanishes, the bad input that is unhandled. The first 80% is the easy part. Your entire value is in finding the last 20%.\n\n## Hard boundary \u2014 do not modify the project\nYou are STRICTLY a verifier. Do NOT create, modify, or delete project files; do NOT install packages; do NOT run version-control write operations. Use only the read/probe/execute tools available to you. (If you need a scratch file, use a temp directory, and clean up.)\n\n## Evidence is mandatory\nReading code is NOT verification. Every check must actually run something \u2014 execute the code, hit the endpoint, run the build/tests \u2014 and record the command and its real output. A \"PASS\" with no command output is a skip, not a pass.\n\n## Strategy (adapt to what changed)\n- Build/lib changes: build it, run the full test suite, exercise the public API as a consumer would.\n- Backend/API: start it, call endpoints, check response *shapes* (not just status codes), test error paths.\n- CLI/script: run with representative AND edge inputs (empty, malformed, boundary); check stdout/stderr/exit codes.\n- Bug fix: reproduce the original bug first, verify the fix, then check for regressions and side effects.\n- Refactor (no behavior change): the existing suite must pass unchanged; diff the public surface; same inputs \u2192 same outputs.\nRun the project's own build/tests/linters as a baseline, then apply the type-specific checks. Test results are context, not proof \u2014 the implementer is an LLM too; its tests may be happy-path or circular.\n\n## Adversarial probes (pick the ones that fit)\nBoundary values (0, -1, empty, very long, unicode, max), idempotency (same mutating call twice), orphan operations (ids that don't exist), concurrency (parallel create-if-not-exists). Your verdict must include at least one adversarial probe you actually ran and its result \u2014 even if it was handled correctly.\n\n## Before you FAIL\nCheck you haven't missed why it's actually fine: defensive code elsewhere, intentional behavior documented in comments/specs, or an unfixable external-contract limitation (note that as an observation, not a FAIL). Don't wave away real issues, but don't FAIL on intentional behavior.\n\n## Verdict\nSubmit exactly one verdict via the provided output tool:\n- PASS \u2014 you ran real checks (including \u22651 adversarial probe) and it holds up. Put the commands + observed output in `evidence`.\n- FAIL \u2014 something is broken. Put each concrete problem (with how to reproduce) in `findings`.\n- PARTIAL \u2014 environmental limitation only (no test framework, a tool/server unavailable). Not for \"I'm unsure\": if you can run the check, decide PASS or FAIL. Note what you couldn't verify and why in `findings`.";
38
+ /**
39
+ * The L3 **static-judge** prompt for the L2+L3 composition (design/54 §4): the mechanical L2 gate already
40
+ * ran the build/tests, so here the verifier is a **read-only judge** that scrutinizes the supplied diff +
41
+ * test results — it must NOT try to execute code (the verifier's tools are read-only by design, design/44
42
+ * §6; telling it to "run tests" makes it judge PARTIAL on every module when the sandbox blocks the runtime —
43
+ * service[36]/search[48] dogfood). {@link verifyCompleted} selects this automatically when `evidence` is set
44
+ * and no `verifierPrompt` override is given.
45
+ */
6
46
  export declare const STATIC_VERIFICATION_PROMPT = "You are a verification judge. Your job is NOT to confirm the change works \u2014 it is to find where it BREAKS.\n\nYou are READ-ONLY by design: the build and tests have ALREADY been run by a separate mechanical gate. Their results and the code change (a diff) are usually supplied to you as evidence; but if little or no diff/results are supplied this round (e.g. a re-verification AFTER a fix), judge the CURRENT working tree directly \u2014 do NOT return PARTIAL merely because a diff is absent. Do NOT try to execute code, run tests, or invoke a runtime \u2014 the environment will refuse it, and that is expected, not a limitation. Judge from any supplied diff/results plus read-only inspection of the working tree (read files, search, list).\n\nYou have two documented failure patterns. First, being seduced by the first 80%: a clean diff or a green test run makes you inclined to pass it, not noticing the edge that crashes, the state that vanishes, the bad input that is unhandled, the cross-module assumption that breaks. Second, hiding behind PARTIAL because you couldn't run something \u2014 that is NOT what PARTIAL is for here; execution was the mechanical gate's job. Your entire value is finding the last 20% by READING.\n\n## What to scrutinize (adapt to the diff)\n- Boundary/edge cases the tests likely miss: 0, -1, empty, very long, unicode, max, malformed input, idempotency, orphan ids, off-by-one, negative numbers, EOF/empty fields.\n- Semantic correctness vs the task spec: does the change actually do what was asked, including cases the tests don't cover (the title()/CSV/base62 class of defect)?\n- Cross-module/integration hazards in the diff: a changed signature/export/contract/default a caller elsewhere still assumes; a deleted helper something depends on.\n- If the provided test results show failures, that is a concrete FAIL with the failing output as evidence.\n\n## Verdict\nSubmit exactly one verdict via the provided output tool:\n- PASS \u2014 you read the diff + results, looked for the edges above, and it holds. Cite the specific things you checked in `evidence`.\n- FAIL \u2014 you found a concrete defect. Put each problem (with the diff location / input that breaks it) in `findings`.\n- PARTIAL \u2014 ONLY when the evidence itself is genuinely insufficient to judge (e.g. the diff is empty or unrelated to the task, no results supplied). NOT for \"I couldn't execute it.\" Say what's missing in `findings`.";
47
+ /** The verifier's structured verdict (delivered via {@link TaskSpec.outputSchema}). */
7
48
  export declare const VerdictSchema: Type.TObject<{
8
49
  verdict: Type.TUnion<[Type.TLiteral<"PASS">, Type.TLiteral<"FAIL">, Type.TLiteral<"PARTIAL">]>;
9
50
  findings: Type.TArray<Type.TString>;
@@ -11,20 +52,82 @@ export declare const VerdictSchema: Type.TObject<{
11
52
  }>;
12
53
  export type Verdict = Static<typeof VerdictSchema>;
13
54
  export interface VerifyConfig {
55
+ /** RB-473 — disclosure channel for CONTAINED host-callback failures in this scope (the RB-463
56
+ * isolation primitive's bounded first-failure per site). Absent ⇒ failures are counted only. */
14
57
  onNotifyError?: (failure: import("../core/safe-notify.js").SafeNotifyFailure) => void;
58
+ /**
59
+ * Verifier model (wins over the role). Default: resolve the `verifier` role (→ `default` fallback).
60
+ *
61
+ * 🔴 DECORRELATION (design/54 §3.1, [44]): the verifier MUST be a **different model than the implementer**
62
+ * — an LLM grading its own work confirms its own blind spots (service[33]: a strong heterogeneous judge
63
+ * reading the diff caught the title()/csv/base62 defects the implementer's own tests missed). The default
64
+ * `verifier` role falling back to `default` (= the implementer) DEFEATS this — pass an explicit
65
+ * heterogeneous `verifierModel`, or map a distinct `verifier` role. Decorrelation is a deployment contract,
66
+ * not something this layer can assert (role→model resolution lives in the Runner).
67
+ */
15
68
  verifierModel?: ModelRef;
69
+ /**
70
+ * Tools the verifier may use — should be read/probe tools that DON'T mutate the project.
71
+ * **Default**: the impl task's tools filtered to `effect: "read"` only (a true read-only boundary).
72
+ * A generic core can't know which of YOUR tools mutate "the project", so if the verifier needs to run a
73
+ * build/test runner, mark that tool `effect: "read"` (it doesn't persist project changes) or pass it here
74
+ * explicitly. Anything `idempotent`/`write` is dropped by default — pass `verifierTools` to widen.
75
+ */
16
76
  verifierTools?: ToolSpec[];
77
+ /** Verify→fix→re-verify rounds (each round = one verification; FAIL between rounds triggers a fix turn). Default 2. */
78
+ /** CLS-A-6: a non-finite value falls back to the default (2) — the gate always runs at least one round. */
17
79
  maxRounds?: number;
80
+ /**
81
+ * The concrete **change to scrutinize** (design/54 §3.1) — typically the integration `git diff` the
82
+ * orchestrator computes via {@link runExecGate}. Fed to the verifier as **untrusted, opaque-delimited
83
+ * data** so the judge reads the actual code change, not the implementer's prose self-report (which a
84
+ * compromised worker controls — threat BUG1). On a durable-HITL resume, the caller MUST recompute this
85
+ * from the **post-resume** working tree (don't reuse a pre-suspend diff — threat BUG5, design/53 §2.B).
86
+ */
18
87
  evidence?: string;
88
+ /** Stop the verify→fix loop once cumulative cost (verifier runs + impl fix turns) reaches this; return the
89
+ * current result. Matches `cascade`'s "all costs" sense. Optional (design/54 §3.4). HRD-AGO-8: checked both
90
+ * before issuing a fix round AND before the verifier of every round after the first (round 1 always runs —
91
+ * the ceilings bound the loop, they are not a way to skip verifying). */
19
92
  costCeilingMicroUsd?: number;
93
+ /** Overall wall-clock ceiling for the whole verify→fix loop. Optional (design/54 §3.4). Checked at the same
94
+ * two points as {@link costCeilingMicroUsd} (HRD-AGO-8). */
20
95
  totalTimeoutMs?: number;
96
+ /** Override the verifier system prompt ({@link VERIFICATION_PROMPT}). */
21
97
  verifierPrompt?: string;
98
+ /**
99
+ * Whether the verifier's execution-env hand band (design/44: `edit_file`/`write_file`/`bash` mounted by
100
+ * the Runner from `executionEnv`, BYPASSING the `verifierTools` effect filter) is forced READ-ONLY.
101
+ *
102
+ * **Default `true` — the independence argument:** the verifier's value rests on it judging work it
103
+ * cannot touch. A verifier that can mutate the project mid-judgment can "fix" what it is grading and
104
+ * then pass its own patch (self-confirmation — the exact blind-spot loop decorrelation exists to
105
+ * break), and a compromised implementer report (untrusted input, threat BUG1) could steer a write-
106
+ * capable judge into destructive edits instead of a wrong verdict. Read-only bounds the blast radius
107
+ * of a fooled verifier to a bad verdict.
108
+ *
109
+ * Set `false` ONLY when verification genuinely requires mutating commands — e.g. a verifier that must
110
+ * really run a build/test cycle that writes artifacts (node_modules, dist, coverage) where marking a
111
+ * runner tool `effect:"read"` / passing `verifierTools` doesn't apply because the commands go through
112
+ * the hand band's `bash`. You are then accepting that the verifier can write to the working tree:
113
+ * prefer a throwaway checkout/sandbox, and keep the implementer/verifier models decorrelated.
114
+ */
22
115
  verifierHandsReadOnly?: boolean;
116
+ /** Per-round callback (observability). */
23
117
  onRound?: (info: {
24
118
  round: number;
25
119
  verdict: VerificationOutcome["verdict"];
26
120
  findings: string[];
27
121
  }) => void;
122
+ /**
123
+ * HRD-AGO-3 — fired when the VERIFIER's own run durably paused (`suspended`/`needs_review`), carrying the
124
+ * resume capability for the checkpoint it minted. The pause is ALWAYS reported on
125
+ * {@link VerificationOutcome.verifierPause} as well; this callback exists so a deployment that owns the
126
+ * checkpoint lifecycle can act at once (decide it, or cancel + release the pinned verifier session) instead
127
+ * of waiting for the reaper. A throwing handler cannot strand the gate (it is swallowed, like `onRound`).
128
+ *
129
+ * ⚠️ `checkpointToken` is the resume CAPABILITY — never log it or put it in a URL (types.ts §6).
130
+ */
28
131
  onVerifierPause?: (info: {
29
132
  round: number;
30
133
  status: TaskResult["status"];
@@ -33,28 +136,123 @@ export interface VerifyConfig {
33
136
  checkpointGate?: CheckpointGate;
34
137
  }) => void;
35
138
  }
139
+ /**
140
+ * Why a {@link VerificationOutcome} is `"unverified"` (search [46] BUG7: `"unverified"` was overloaded across
141
+ * three distinct situations a consumer must tell apart to gate correctly):
142
+ * - `"suspended"` — the impl (or resumed impl) suspended on a durable HITL gate, so it isn't done yet; the
143
+ * result is failed-with-token and the caller should resume (NOT treat as a verification failure).
144
+ * - `"no_verdict"` — the verifier ran but never produced a structured verdict (a broken/flaky verifier); the
145
+ * work IS done but could not be gated — treat as a gate failure, not a pass.
146
+ * - `"could_not_verify"` — the verifier returned PARTIAL: it ran but could NOT verify due to an environmental
147
+ * limit (e.g. no test framework). The work IS done but was NOT gated — a careless `verdict !== "FAIL"`
148
+ * consumer must treat this as a non-verification, not a pass; `findings` carry what couldn't be checked.
149
+ * - `"needs_review"` — the impl/verifier paused on a non-durable human review and isn't gated yet.
150
+ * - `"impl_incomplete"` — the implementation itself didn't complete (failed/blocked/timeout) before verification.
151
+ * - `"opted_out"` — verification was explicitly disabled (`runDeveloperTask({ verify: false })`); not gated by design.
152
+ * - `"verifier_paused"` (HRD-AGO-3) — the VERIFIER's own run durably paused (suspended/needs_review) and minted
153
+ * a checkpoint of its own. DISJOINT from `"suspended"` (which is about the IMPLEMENTATION): the work IS done,
154
+ * it simply was not gated, and there is an outstanding verifier checkpoint the caller must decide or cancel —
155
+ * see {@link VerificationOutcome.verifierPause} for the token. Previously reported as `"no_verdict"`, which
156
+ * reads like a broken verifier and hid the fact that a live checkpoint was left pinned.
157
+ */
36
158
  export type UnverifiedReason = "suspended" | "needs_review" | "no_verdict" | "opted_out" | "impl_incomplete" | "could_not_verify" | "verifier_paused";
37
159
  export interface VerificationOutcome {
160
+ /** Final verdict. `"unverified"` = the work was not gated; see {@link unverifiedReason} for WHY (they differ). */
38
161
  verdict: "PASS" | "FAIL" | "PARTIAL" | "unverified";
162
+ /** Set iff `verdict === "unverified"` — disambiguates the three unverified situations (search [46] BUG7). */
39
163
  unverifiedReason?: UnverifiedReason;
164
+ /** How many verification rounds ran. */
40
165
  rounds: number;
166
+ /** Findings from the FINAL verification (problems on FAIL, caveats on PARTIAL). */
41
167
  findings: string[];
168
+ /** Evidence (commands + output) from the final verification, if the verifier supplied it. */
42
169
  evidence?: string;
170
+ /**
171
+ * Total cost (micro-USD) of the VERIFIER run(s) across all rounds — the verification OVERHEAD, separate from
172
+ * the implementation's own cost (which is the returned `TaskResult.stats`, as the verifier runs in its own
173
+ * session). Mirrors `runWithTeacher`'s `teacherStats` work-vs-overhead split. Σ of each verifier run's
174
+ * cost+nested. `result.stats.costMicroUsd + verification.verifierCost` is the EXACT operation total for the
175
+ * common single-pass case; in the rarer multi-round fix case `result.stats` is the FINAL impl attempt's cost
176
+ * (the returned `...current`) so an earlier failed attempt's impl cost is not separately surfaced. Omitted
177
+ * (undefined) when no verifier ran (e.g. an impl that suspended/was opted out before verification).
178
+ */
43
179
  verifierCost?: number;
180
+ /**
181
+ * HRD-AGO-3 — set iff `unverifiedReason === "verifier_paused"`: the VERIFIER's own durable pause. The
182
+ * verifier's session stays PINNED by its checkpoint (releasing it here would orphan the checkpoint), so the
183
+ * pause is handed back instead of being swallowed: resume/cancel the checkpoint with this token, and the
184
+ * session is reclaimed on that terminal. Without it the token died inside the gate and the checkpoint +
185
+ * pinned session survived only until the deadline reaper collected them, with nothing in the result saying so.
186
+ *
187
+ * ⚠️ `checkpointToken` is the resume CAPABILITY — never log it or put it in a URL (types.ts §6).
188
+ */
44
189
  verifierPause?: {
190
+ /** The verifier run's terminal pause status (`"suspended"` or `"needs_review"`). */
45
191
  status: TaskResult["status"];
192
+ /** The paused verifier's own session id (independent of the implementation's). */
46
193
  sessionId: string;
194
+ /** The resume capability for the verifier's checkpoint. Undefined only if the pause carried none. */
47
195
  checkpointToken?: CheckpointToken;
196
+ /** What the verifier's checkpoint is waiting on (which resume outcome it takes). */
48
197
  checkpointGate?: CheckpointGate;
49
198
  };
50
199
  }
51
200
  export interface VerificationResult extends TaskResult {
201
+ /** The verification outcome. The task `result`/`status` is the implementation's; consult `verdict` for quality. */
52
202
  verification: VerificationOutcome;
53
203
  }
204
+ /**
205
+ * Verify an already-**completed** implementation `result` behind the independent adversarial verifier,
206
+ * looping fix→re-verify until PASS (or a round cap) — **without re-running the implementation**. This is the
207
+ * L3 entry for the L2+L3 composition (design/54 §4): in a fan-out, a worker's module has already been
208
+ * produced, so the orchestrator runs the mechanical L2 gate ({@link runExecGate}), computes the diff, then
209
+ * calls this with `config.evidence = diff (+ L2 results)` to judge the finished work. The sibling of
210
+ * {@link runWithVerification} (fresh run + verify) and {@link resumeWithVerification} (resume + verify) for
211
+ * the "I already have the result, just verify it" case — all three share this gate so a task is judged
212
+ * identically however it reached completion (design/45 §11 Q6 + design/51 P1-b).
213
+ *
214
+ * `specBase` carries the impl's tools/roles/model/limits/signal/keys (everything but `objective`/`sessionId`)
215
+ * so the verifier inherits the right role map + read-only tool boundary; `objective` is the original task
216
+ * objective the verifier needs as context. When `config.evidence` is set and no `config.verifierPrompt`
217
+ * override is given, the verifier uses {@link STATIC_VERIFICATION_PROMPT} (read the diff/results; don't try
218
+ * to execute — that was L2's job), avoiding the "PARTIAL on everything" failure in a read-only sandbox.
219
+ */
54
220
  export declare function verifyCompleted(runner: Runner, result: TaskResult, specBase: ResumeTaskConfig, objective: string, config: VerifyConfig): Promise<VerificationResult>;
221
+ /**
222
+ * Run an implementation task, then gate it behind an independent adversarial verifier, looping
223
+ * fix→re-verify until PASS (or a round cap). Returns the implementation result plus the
224
+ * {@link VerificationOutcome}. The caller decides WHEN to use this (explicit opt-in) — it always
225
+ * verifies once invoked. If the impl **suspends on a durable HITL gate**, it is surfaced as
226
+ * failed-with-token (verdict `unverified`); the caller approves and calls {@link resumeWithVerification}
227
+ * to resume AND verify (design/51 P1-b: the durable + HITL + verify integration).
228
+ */
55
229
  export declare function runWithVerification(runner: Runner, implSpec: TaskSpec, config?: VerifyConfig): Promise<VerificationResult>;
230
+ /**
231
+ * Resume a durable-suspended implementation task (design/45 F4) **and** verify it on completion — the
232
+ * durable + HITL + verify integration (design/51 P1-b). The mirror of {@link runWithVerification} for the
233
+ * resume path: `runWithVerification` surfaces a HITL suspend as failed-with-token; once the human
234
+ * adjudicates, the caller calls this with the `token` + `outcome`, and it resumes the implementation and —
235
+ * **if it COMPLETES** — runs the identical adversarial verifier + fix loop. If the resumed run suspends
236
+ * AGAIN (a later durable gate), it is surfaced as failed-with-token (`unverified`) for the caller to resume
237
+ * once more. `objective` is the ORIGINAL task objective (the resume carries none of its own) — the verifier
238
+ * needs it as context; pass the same objective the original `runWithVerification` ran with.
239
+ *
240
+ * 🔴 Freshness (threat BUG5, design/53 §2.B): if you pass `config.evidence` (a diff), recompute it from the
241
+ * **post-resume** working tree — a worker can clean-report → suspend at a gated tool → plant a backdoor
242
+ * after approval, so a pre-suspend diff would grade stale code. The verifier already verifies the current working
243
+ * tree (verifierObjective), so dropping the stale diff closes the timing window.
244
+ */
56
245
  export declare function resumeWithVerification(runner: Runner, token: CheckpointToken, outcome: ResumeOutcome, taskConfig: ResumeTaskConfig, objective: string, config?: VerifyConfig): Promise<VerificationResult>;
57
246
  export interface DeveloperTaskConfig extends VerifyConfig {
247
+ /** Run the verification gate. Default `true` (that's the point of developer mode). Set `false` for prompt-only. */
58
248
  verify?: boolean;
59
249
  }
250
+ /**
251
+ * One-stop developer-mode convenience: applies {@link CODE_AGENT_PROMPT} (unless the task supplies its
252
+ * own `systemPrompt`) and, by default, runs the {@link runWithVerification} gate. Equivalent to wiring
253
+ * the building blocks by hand — use the building blocks directly when you want full control.
254
+ *
255
+ * Pair with a role map that gives a strong implementation model and cheaper helper/verifier models for
256
+ * "auto model selection" (design/28 §3.2): `roles: { default: strong, subagent: cheap, verifier: strong }`.
257
+ */
60
258
  export declare function runDeveloperTask(runner: Runner, spec: TaskSpec, config?: DeveloperTaskConfig): Promise<VerificationResult>;