@sema-agent/core 7.69.0 → 7.69.1

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 (309) hide show
  1. package/CHANGELOG.md +583 -0
  2. package/dist/agents/repair-loop.js +6 -14
  3. package/dist/agents/subagent.js +2 -1
  4. package/dist/agents/verify.d.ts +1 -1
  5. package/dist/agents/verify.js +7 -1
  6. package/dist/brain/reasoning-request.d.ts +7 -0
  7. package/dist/brain/reasoning-request.js +6 -0
  8. package/dist/core/agent-config-dir.d.ts +39 -3
  9. package/dist/core/agent-config-dir.js +67 -11
  10. package/dist/core/allow-entry.d.ts +5 -5
  11. package/dist/core/allow-entry.js +12 -6
  12. package/dist/core/ask-headline.d.ts +2 -2
  13. package/dist/core/ask-origin.d.ts +31 -31
  14. package/dist/core/ask-origin.js +20 -13
  15. package/dist/core/attachment-source.d.ts +1 -1
  16. package/dist/core/attachment-source.js +1 -0
  17. package/dist/core/auto-compaction.d.ts +44 -62
  18. package/dist/core/auto-compaction.js +44 -103
  19. package/dist/core/cache-break-detector.d.ts +23 -11
  20. package/dist/core/cache-break-detector.js +11 -5
  21. package/dist/core/checkpoint-features.d.ts +1 -1
  22. package/dist/core/checkpoint-features.js +1 -1
  23. package/dist/core/checkpoint-requirements.d.ts +19 -1
  24. package/dist/core/checkpoint-requirements.js +6 -0
  25. package/dist/core/checkpoint-row-verdict.js +3 -0
  26. package/dist/core/checkpoint-store.d.ts +13 -2
  27. package/dist/core/child-clamp-seats.d.ts +30 -3
  28. package/dist/core/child-clamp-seats.js +24 -0
  29. package/dist/core/compaction-retired-members.d.ts +12 -0
  30. package/dist/core/compaction-retired-members.js +22 -0
  31. package/dist/core/config-refusal-codes.d.ts +1 -1
  32. package/dist/core/config-refusal-codes.js +2 -0
  33. package/dist/core/context-edit.d.ts +32 -17
  34. package/dist/core/context-edit.js +28 -0
  35. package/dist/core/cron.d.ts +68 -0
  36. package/dist/core/cron.js +259 -0
  37. package/dist/core/engine-attestation.d.ts +16 -0
  38. package/dist/core/engine-attestation.js +2 -0
  39. package/dist/core/engine-capabilities.d.ts +14 -1
  40. package/dist/core/engine-capabilities.js +1 -1
  41. package/dist/core/engine-notice.d.ts +18 -7
  42. package/dist/core/engine-version.js +1 -1
  43. package/dist/core/gate-outcome.d.ts +29 -2
  44. package/dist/core/gate-outcome.js +6 -0
  45. package/dist/core/git-read-only.d.ts +10 -0
  46. package/dist/core/git-read-only.js +1 -0
  47. package/dist/core/git-worktree-env.js +9 -8
  48. package/dist/core/governance-codes.d.ts +9 -2
  49. package/dist/core/governance-codes.js +9 -0
  50. package/dist/core/locked-config.js +7 -3
  51. package/dist/core/lsp.d.ts +3 -0
  52. package/dist/core/lsp.js +3 -2
  53. package/dist/core/memory-engine/engine.d.ts +48 -12
  54. package/dist/core/memory-engine/engine.js +108 -46
  55. package/dist/core/memory-engine/file-backend.d.ts +2 -1
  56. package/dist/core/memory-engine/index-copies.d.ts +47 -0
  57. package/dist/core/memory-engine/index-copies.js +88 -0
  58. package/dist/core/memory-engine/layout.d.ts +20 -3
  59. package/dist/core/memory-engine/layout.js +39 -3
  60. package/dist/core/memory-engine/origin-clearance.d.ts +9 -7
  61. package/dist/core/memory-engine/origin-clearance.js +2 -4
  62. package/dist/core/memory-engine/types.d.ts +16 -3
  63. package/dist/core/mode-policy.d.ts +7 -1
  64. package/dist/core/mode-policy.js +9 -0
  65. package/dist/core/mods/session-compact.js +3 -3
  66. package/dist/core/mods/stations.d.ts +2 -0
  67. package/dist/core/mods/stations.js +2 -1
  68. package/dist/core/path-guard-rows.d.ts +8 -3
  69. package/dist/core/path-guard-rows.js +18 -5
  70. package/dist/core/peer-seat.d.ts +3 -0
  71. package/dist/core/peer-seat.js +3 -0
  72. package/dist/core/permission-rule-model.js +3 -2
  73. package/dist/core/process-identity.d.ts +11 -3
  74. package/dist/core/process-identity.js +26 -16
  75. package/dist/core/runner/assemble-result.d.ts +5 -0
  76. package/dist/core/runner/assemble-result.js +1 -1
  77. package/dist/core/runner/cleared-results-record.d.ts +33 -0
  78. package/dist/core/runner/cleared-results-record.js +56 -0
  79. package/dist/core/runner/compact-session.js +14 -9
  80. package/dist/core/runner/compaction-knobs.d.ts +1 -1
  81. package/dist/core/runner/continuation-gate.js +2 -1
  82. package/dist/core/runner/continues-from.d.ts +1 -1
  83. package/dist/core/runner/continues-from.js +1 -1
  84. package/dist/core/runner/contracts.d.ts +83 -31
  85. package/dist/core/runner/conversation-segment.d.ts +19 -12
  86. package/dist/core/runner/conversation-segment.js +27 -7
  87. package/dist/core/runner/derived-route-fallback.d.ts +2 -12
  88. package/dist/core/runner/derived-route-fallback.js +0 -6
  89. package/dist/core/runner/gate-exit.d.ts +2 -1
  90. package/dist/core/runner/gate-exit.js +4 -2
  91. package/dist/core/runner/git-status-frame.d.ts +2 -2
  92. package/dist/core/runner/git-status-frame.js +2 -1
  93. package/dist/core/runner/initial-run-state.js +1 -1
  94. package/dist/core/runner/leg-caller-places.d.ts +39 -0
  95. package/dist/core/runner/leg-caller-places.js +23 -0
  96. package/dist/core/runner/leg-frame.d.ts +8 -2
  97. package/dist/core/runner/leg-receipt.d.ts +29 -2
  98. package/dist/core/runner/leg-receipt.js +37 -6
  99. package/dist/core/runner/media-removed-seat.d.ts +10 -6
  100. package/dist/core/runner/media-removed-seat.js +6 -3
  101. package/dist/core/runner/messages-omitted-seat.d.ts +2 -1
  102. package/dist/core/runner/messages-omitted-seat.js +15 -5
  103. package/dist/core/runner/person-path-rows.d.ts +25 -7
  104. package/dist/core/runner/person-path-rows.js +16 -2
  105. package/dist/core/runner/prefix-ledger.d.ts +120 -0
  106. package/dist/core/runner/prefix-ledger.js +176 -0
  107. package/dist/core/runner/prepare-advisor.d.ts +2 -0
  108. package/dist/core/runner/prepare-advisor.js +2 -1
  109. package/dist/core/runner/prepare-artifact.d.ts +3 -0
  110. package/dist/core/runner/prepare-artifact.js +2 -2
  111. package/dist/core/runner/prepare-caps-and-workflow.d.ts +2 -0
  112. package/dist/core/runner/prepare-caps-and-workflow.js +4 -3
  113. package/dist/core/runner/prepare-config-doors.d.ts +9 -8
  114. package/dist/core/runner/prepare-config-doors.js +15 -12
  115. package/dist/core/runner/prepare-context-lane.d.ts +25 -6
  116. package/dist/core/runner/prepare-context-lane.js +82 -27
  117. package/dist/core/runner/prepare-gate-stations.d.ts +1 -2
  118. package/dist/core/runner/prepare-gate-stations.js +2 -4
  119. package/dist/core/runner/prepare-hands-readface.d.ts +18 -5
  120. package/dist/core/runner/prepare-hands-readface.js +41 -22
  121. package/dist/core/runner/prepare-inherited-gate.d.ts +5 -0
  122. package/dist/core/runner/prepare-inherited-gate.js +2 -0
  123. package/dist/core/runner/prepare-memory.d.ts +10 -2
  124. package/dist/core/runner/prepare-memory.js +51 -5
  125. package/dist/core/runner/prepare-policy-chain.d.ts +3 -0
  126. package/dist/core/runner/prepare-policy-chain.js +13 -2
  127. package/dist/core/runner/prepare-prompt-assembly.d.ts +12 -4
  128. package/dist/core/runner/prepare-prompt-assembly.js +10 -4
  129. package/dist/core/runner/prepare-prompt-inputs.d.ts +3 -7
  130. package/dist/core/runner/prepare-prompt-inputs.js +6 -7
  131. package/dist/core/runner/prepare-safety-scan.js +7 -0
  132. package/dist/core/runner/prepare-suspend-saga.d.ts +4 -0
  133. package/dist/core/runner/prepare-suspend-saga.js +3 -2
  134. package/dist/core/runner/prepare-task.js +59 -53
  135. package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +5 -11
  136. package/dist/core/runner/prepare-tool-disclosure-mount.js +7 -8
  137. package/dist/core/runner/prepare-turn-wiring.d.ts +16 -25
  138. package/dist/core/runner/prepare-turn-wiring.js +8 -18
  139. package/dist/core/runner/prepare-wiring-manifest.d.ts +1 -0
  140. package/dist/core/runner/prepare-wiring-manifest.js +3 -2
  141. package/dist/core/runner/prompt-suggestions.d.ts +3 -1
  142. package/dist/core/runner/prompt-suggestions.js +1 -1
  143. package/dist/core/runner/read-block-judge.d.ts +47 -0
  144. package/dist/core/runner/read-block-judge.js +33 -0
  145. package/dist/core/runner/role-resolution-table.d.ts +15 -10
  146. package/dist/core/runner/role-resolution-table.js +4 -5
  147. package/dist/core/runner/rule-store-unreadable-notice.d.ts +7 -4
  148. package/dist/core/runner/rule-store-unreadable-notice.js +4 -3
  149. package/dist/core/runner/run-compaction-machinery.d.ts +0 -10
  150. package/dist/core/runner/run-compaction-machinery.js +3 -39
  151. package/dist/core/runner/run-harness-handlers.js +4 -17
  152. package/dist/core/runner/run-identity-wiring.js +4 -1
  153. package/dist/core/runner/run-leg.js +11 -1
  154. package/dist/core/runner/run-recovery-lanes.d.ts +0 -4
  155. package/dist/core/runner/run-recovery-lanes.js +34 -18
  156. package/dist/core/runner/run-settle-and-teardown.d.ts +1 -3
  157. package/dist/core/runner/run-settle-and-teardown.js +14 -22
  158. package/dist/core/runner/run-telemetry-and-budget-seats.js +0 -1
  159. package/dist/core/runner/run-terminal-adoption.d.ts +11 -30
  160. package/dist/core/runner/run-terminal-adoption.js +5 -88
  161. package/dist/core/runner/run-tool-mount-facts.js +1 -5
  162. package/dist/core/runner/run-turn-boundary.js +56 -26
  163. package/dist/core/runner/runtask.js +7 -7
  164. package/dist/core/runner/session-hash-salt.d.ts +18 -0
  165. package/dist/core/runner/session-hash-salt.js +36 -0
  166. package/dist/core/runner/shell-env-withheld.d.ts +8 -5
  167. package/dist/core/runner/shell-env-withheld.js +3 -3
  168. package/dist/core/runner/side-call-account.d.ts +9 -1
  169. package/dist/core/runner/side-call-account.js +15 -4
  170. package/dist/core/runner/skill-mention.d.ts +12 -0
  171. package/dist/core/runner/skill-mention.js +50 -0
  172. package/dist/core/runner/stream-settle-backstop.js +1 -0
  173. package/dist/core/runner/synthetic-tools.js +2 -2
  174. package/dist/core/runner/tool-table-view.d.ts +5 -9
  175. package/dist/core/runner/tool-table-view.js +23 -21
  176. package/dist/core/runner/write-protection-station.d.ts +5 -2
  177. package/dist/core/runner/write-protection-station.js +1 -1
  178. package/dist/core/runner-deps.d.ts +25 -27
  179. package/dist/core/scheduler.d.ts +13 -3
  180. package/dist/core/scheduler.js +0 -12
  181. package/dist/core/secret-env.d.ts +47 -11
  182. package/dist/core/secret-env.js +65 -4
  183. package/dist/core/sensitive-path-policy.js +4 -0
  184. package/dist/core/session-checkout.js +10 -9
  185. package/dist/core/shell-read-silence.d.ts +2 -1
  186. package/dist/core/shell-run-candidates.d.ts +1 -1
  187. package/dist/core/shell-run-candidates.js +11 -3
  188. package/dist/core/task-event.d.ts +32 -10
  189. package/dist/core/task-intake.d.ts +5 -3
  190. package/dist/core/task-intake.js +6 -2
  191. package/dist/core/task-result.d.ts +39 -0
  192. package/dist/core/task-spec-members.d.ts +3 -0
  193. package/dist/core/task-spec-members.js +2 -2
  194. package/dist/core/task-spec.d.ts +37 -20
  195. package/dist/core/tool-policy.d.ts +30 -18
  196. package/dist/core/tool-policy.js +44 -32
  197. package/dist/core/tool-roster.d.ts +21 -7
  198. package/dist/core/tool-roster.js +34 -6
  199. package/dist/core/tool-spec-members.js +1 -1
  200. package/dist/core/tool-spec.d.ts +27 -0
  201. package/dist/core/tools.js +1 -0
  202. package/dist/core/trace.d.ts +42 -19
  203. package/dist/core/unc-spelling.d.ts +31 -0
  204. package/dist/core/unc-spelling.js +51 -0
  205. package/dist/core/wiring-manifest.d.ts +30 -3
  206. package/dist/core/wiring-manifest.js +10 -0
  207. package/dist/core/workflow-run-store-contract.js +22 -0
  208. package/dist/core/workflow-run-store.d.ts +17 -13
  209. package/dist/core/workflow-run-store.js +1 -1
  210. package/dist/core/write-protect.d.ts +4 -0
  211. package/dist/core/write-protect.js +17 -15
  212. package/dist/engine/compaction/compaction.d.ts +48 -98
  213. package/dist/engine/compaction/compaction.js +136 -216
  214. package/dist/engine/compaction/utils.d.ts +2 -11
  215. package/dist/engine/compaction/utils.js +4 -13
  216. package/dist/engine/execution-env/node-execution-env.js +17 -6
  217. package/dist/engine/harness/agent-harness.d.ts +19 -5
  218. package/dist/engine/harness/agent-harness.js +18 -7
  219. package/dist/engine/harness/types.d.ts +5 -7
  220. package/dist/engine/loop/agent-loop.d.ts +14 -1
  221. package/dist/engine/loop/agent-loop.js +31 -11
  222. package/dist/engine/loop/types.d.ts +8 -2
  223. package/dist/index.d.ts +9 -6
  224. package/dist/index.js +8 -6
  225. package/dist/internal/harness-types.d.ts +1 -1
  226. package/dist/internal/harness.d.ts +1 -1
  227. package/dist/internal/harness.js +1 -1
  228. package/dist/orchestration/run-spec.js +7 -2
  229. package/dist/orchestration/run-workflow-tool.js +5 -3
  230. package/dist/orchestration/workflow-park-adoption.d.ts +66 -8
  231. package/dist/orchestration/workflow-park-adoption.js +195 -45
  232. package/dist/orchestration/workflow-types.d.ts +20 -0
  233. package/dist/orchestration/workflow-types.js +1 -0
  234. package/dist/orchestration/workflow.d.ts +3 -2
  235. package/dist/orchestration/workflow.js +10 -4
  236. package/dist/prompt-assembly/catalog/core-behavior.js +6 -0
  237. package/dist/prompt-assembly/catalog/events.d.ts +8 -0
  238. package/dist/prompt-assembly/catalog/locales/zh-Hans/core-behavior.js +6 -0
  239. package/dist/prompt-assembly/catalog/locales/zh-Hans/mechanism.js +1 -0
  240. package/dist/prompt-assembly/catalog/mechanism.d.ts +8 -0
  241. package/dist/prompt-assembly/catalog/mechanism.js +1 -0
  242. package/dist/prompt-assembly/catalog/schema.d.ts +1 -1
  243. package/dist/prompt-assembly/catalog/schema.js +1 -0
  244. package/dist/prompt-assembly/catalog/sections.js +8 -0
  245. package/dist/prompt-assembly/event-registry.js +1 -0
  246. package/dist/prompt-assembly/select.js +1 -0
  247. package/dist/prompt-assembly/turn-snapshot.d.ts +14 -27
  248. package/dist/prompt-assembly/turn-snapshot.js +6 -18
  249. package/dist/prompt-assembly/types.d.ts +3 -0
  250. package/dist/prompts/default.d.ts +9 -0
  251. package/dist/prompts/default.js +4 -0
  252. package/dist/shell/lex.d.ts +75 -11
  253. package/dist/shell/lex.js +340 -76
  254. package/dist/tools/fs/bash-program-position.js +2 -6
  255. package/dist/tools/fs/bash-readonly-classifier.d.ts +18 -3
  256. package/dist/tools/fs/bash-readonly-classifier.js +19 -9
  257. package/dist/tools/fs/containment-face.d.ts +12 -3
  258. package/dist/tools/fs/containment-face.js +16 -7
  259. package/dist/tools/fs/file-read-check.d.ts +26 -1
  260. package/dist/tools/fs/file-read-check.js +20 -2
  261. package/dist/tools/fs/fs-bash.js +4 -4
  262. package/dist/tools/fs/fs-read.d.ts +3 -0
  263. package/dist/tools/fs/fs-read.js +2 -2
  264. package/dist/tools/fs/fs-search-tools.d.ts +2 -2
  265. package/dist/tools/fs/fs-search-tools.js +4 -4
  266. package/dist/tools/fs/index.js +5 -3
  267. package/dist/tools/fs/pdf.js +12 -4
  268. package/dist/tools/fs/read-deny-home.d.ts +13 -2
  269. package/dist/tools/fs/read-deny-home.js +26 -22
  270. package/dist/tools/fs/read-deny.js +15 -6
  271. package/dist/tools/fs/removal-targets.d.ts +33 -17
  272. package/dist/tools/fs/removal-targets.js +160 -61
  273. package/dist/tools/fs/repo-map.d.ts +1 -1
  274. package/dist/tools/fs/repo-map.js +2 -2
  275. package/dist/tools/fs/safety.d.ts +28 -5
  276. package/dist/tools/fs/safety.js +72 -8
  277. package/dist/tools/fs/shell-read-bindings.d.ts +8 -2
  278. package/dist/tools/fs/shell-read-bindings.js +25 -6
  279. package/dist/tools/fs/shell-read-check.d.ts +3 -0
  280. package/dist/tools/fs/shell-read-check.js +22 -4
  281. package/dist/tools/fs/shell-read-establish.js +73 -43
  282. package/dist/tools/fs/shell-read-judge.d.ts +32 -14
  283. package/dist/tools/fs/shell-read-judge.js +13 -5
  284. package/dist/tools/fs/shell-read-object-path.d.ts +5 -1
  285. package/dist/tools/fs/shell-read-object-path.js +17 -4
  286. package/dist/tools/fs/shell-read-plan.d.ts +8 -2
  287. package/dist/tools/fs/shell-read-plan.js +36 -22
  288. package/dist/tools/fs/shell-read-sourced.js +12 -4
  289. package/dist/tools/fs/shell-read-start.d.ts +4 -2
  290. package/dist/tools/fs/shell-read-start.js +3 -3
  291. package/dist/tools/fs/shell-read-workdir.d.ts +14 -6
  292. package/dist/tools/fs/shell-read-workdir.js +35 -17
  293. package/dist/tools/scheduler-tools.d.ts +7 -17
  294. package/dist/tools/scheduler-tools.js +9 -85
  295. package/dist/tools/worktree.js +5 -4
  296. package/package.json +3 -2
  297. package/test/export-surface.snapshot.json +47 -1
  298. package/wire-changes/core-stores-sql@7.68.6.json +39 -0
  299. package/wire-changes/core-stores-sql@7.69.1.json +39 -0
  300. package/wire-changes/core@7.68.6.json +125 -0
  301. package/wire-changes/core@7.69.1.json +2561 -0
  302. package/wire-changes/mods-kernel@7.68.6.json +39 -0
  303. package/wire-changes/mods-kernel@7.69.1.json +39 -0
  304. package/wire-changes/primitives@7.68.6.json +39 -0
  305. package/wire-changes/primitives@7.69.1.json +39 -0
  306. package/wire-changes/wiki-gate@7.68.6.json +39 -0
  307. package/wire-changes/wiki-gate@7.69.1.json +39 -0
  308. package/dist/core/runner/prompt-hash-salt.d.ts +0 -1
  309. package/dist/core/runner/prompt-hash-salt.js +0 -2
@@ -3,7 +3,7 @@ import { fastModeUnavailableFor } from "../../brain/fast-mode.js";
3
3
  import { assemblePrompt } from "../../prompt-assembly/assemble.js";
4
4
  import { buildTurnPromptSnapshot } from "../../prompt-assembly/turn-snapshot.js";
5
5
  import { adoptCenter } from "../../prompt-assembly/artifact.js";
6
- import { CacheBreakDetector, toolsToFingerprintInputs } from "../cache-break-detector.js";
6
+ import { toolsToFingerprintInputs } from "../cache-break-detector.js";
7
7
  import { defaultTaskRegistry } from "../task-registry.js";
8
8
  import { createSyntheticFetchJudge, createSyntheticReadJudge, createSyntheticServedReadJudge } from "../synthetic-read-verdict.js";
9
9
  import { createConsolidationWriteJudge } from "./memory-consolidation-write-judge.js";
@@ -12,7 +12,6 @@ import { ORG_ADJUDICATION_TIMEOUT_MS } from "../permission-rule-org.js";
12
12
  import { applyContextShrinkToReadFileState } from "../../tools/fs/index.js";
13
13
  import { resolveKey } from "../../tools/fs/safety.js";
14
14
  import { headSegmentsChanged } from "./conversation-segment.js";
15
- import { PROMPT_HASH_SALT } from "./prompt-hash-salt.js";
16
15
  import { CHANGED_FILES_MTIME_EPS_MS } from "./turn-attachments.js";
17
16
  import { isInstructionLaneEntry, readCompactionRestore } from "../user-attachment.js";
18
17
  import { createNestedMemoryLane } from "./nested-memory-lane.js";
@@ -23,12 +22,7 @@ export function declaringCallPolicy(turnSnapshotRef, stream) {
23
22
  };
24
23
  }
25
24
  export function prepareTurnWiring(input) {
26
- const { deps, dateAnchor, prefixHeadBlocks, systemPromptSeat, harnessTools, fpRef, model, promptIdentityDigest, systemBlocks, thinking, spec, sessionId, turnSnapshotRef, promptManifest, charsPerToken, handsEnabled, executionEnv, attachmentRootCanonical, readRoots, modelFileReader, existingTargetSeat, reminderMark, reminderDisclosureCounts, resolvedReadFace, handsCwdRef, readFileStateForCheckpoint, denyNarrowingPolicy, skillGrants, callerPolicy, inheritedPolicies, persistedRuleLane, ruleLaneFacts, personRowsBeyondRun, orgRuleLane, stampCallTarget, abortController, hostTaskId, taskScope, buildAssembleInputs, identityFor, adoptsCandidates, centerAdoptionRef, replacedTemplates, harnessRef, carrierReadFace, carrierWriteFace, readDenyAdditionsNormalized, preparedHolder, budgetSnapshot } = input;
27
- const cacheBreakDetector = deps.cacheBreakDetection === false ? undefined : new CacheBreakDetector();
28
- const cacheFingerprint = cacheBreakDetector
29
- ? { systemPrompt: systemPromptSeat.current, tools: toolsToFingerprintInputs(harnessTools) }
30
- : undefined;
31
- fpRef.current = cacheFingerprint;
25
+ const { deps, dateAnchor, memoryTailOwed, prefixHeadBlocks, systemPromptSeat, harnessTools, promptHashSalt, prefixLedger, model, promptIdentityDigest, systemBlocks, thinking, spec, sessionId, turnSnapshotRef, promptManifest, charsPerToken, handsEnabled, executionEnv, attachmentRootCanonical, readRoots, modelFileReader, existingTargetSeat, reminderMark, reminderDisclosureCounts, resolvedReadFace, handsCwdRef, readFileStateForCheckpoint, denyNarrowingPolicy, skillGrants, callerPolicy, inheritedPolicies, persistedRuleLane, ruleLaneFacts, personRowsBeyondRun, orgRuleLane, stampCallTarget, abortController, hostTaskId, taskScope, buildAssembleInputs, identityFor, adoptsCandidates, centerAdoptionRef, replacedTemplates, harnessRef, carrierReadFace, carrierWriteFace, readDenyAdditionsNormalized, preparedHolder, budgetSnapshot } = input;
32
26
  const turnSnapshot = buildTurnPromptSnapshot({
33
27
  provider: model.provider,
34
28
  modelId: model.id,
@@ -42,15 +36,13 @@ export function prepareTurnWiring(input) {
42
36
  cacheRetention: deps.cacheRetention,
43
37
  sessionId,
44
38
  taskId: spec.taskId,
45
- }, model.api, (text) => `salted:${createHash("sha256").update(PROMPT_HASH_SALT).update(text).digest("hex")}`);
46
- if (cacheBreakDetector !== undefined)
47
- turnSnapshot.onDeclared = (d) => cacheBreakDetector.declare(d);
48
- const anchoredHead = dateAnchor?.head;
39
+ }, model.api, (text) => `salted:${createHash("sha256").update(promptHashSalt).update(text).digest("hex")}`);
40
+ turnSnapshot.onDeclared = (d) => prefixLedger.declare(d.cause);
41
+ const anchoredHead = dateAnchor?.lastHead;
49
42
  const headNow = () => ({ blocks: prefixHeadBlocks, tools: turnSnapshot.mountedToolWireDigest });
50
43
  const segments = anchoredHead !== undefined ? headSegmentsChanged(anchoredHead, headNow()) : [];
51
- if (segments.length > 0)
52
- turnSnapshot.legStart = { cause: "leg_start_inputs", segments };
53
- const prefixAnchor = { read: dateAnchor, head: headNow };
44
+ prefixLedger.declare("leg_start_inputs", segments);
45
+ const prefixAnchor = { read: dateAnchor, head: headNow, ...(memoryTailOwed !== undefined ? { memory: memoryTailOwed } : {}) };
54
46
  turnSnapshotRef.current = turnSnapshot;
55
47
  promptManifest.snapshot = { cacheIdentity: turnSnapshot.cacheIdentity, elements: { ...turnSnapshot.elements } };
56
48
  promptManifest.lowering = turnSnapshot.lowering;
@@ -206,8 +198,6 @@ export function prepareTurnWiring(input) {
206
198
  apply: (committedIdentity) => {
207
199
  systemPromptSeat.current = a2.systemPrompt;
208
200
  harnessRef.current?.setSystemPrompt(a2.systemPrompt, a2.systemBlocks);
209
- if (fpRef.current)
210
- fpRef.current.systemPrompt = a2.systemPrompt;
211
201
  turnSnapshotRef.current?.refreshStableSystem(a2.systemPrompt, committedIdentity);
212
202
  preparedHolder.current.promptIdentity = promptIdentity;
213
203
  preparedHolder.current.promptOverheadTokens = overheadTokensAfter;
@@ -222,5 +212,5 @@ export function prepareTurnWiring(input) {
222
212
  const effectiveReadFaceObserved = carrierReadFace();
223
213
  const effectiveWriteFaceObserved = carrierWriteFace();
224
214
  const effectiveReadDenyObserved = readDenyAdditionsNormalized.length > 0 ? readDenyAdditionsNormalized.map((e) => ({ ...e })) : undefined;
225
- return { nestedMemory, cacheBreakDetector, cacheFingerprint, promptOverheadTokens, compactionRestore, normalizeAttachmentPath, recentlyReadFiles, onCompactionApplied, detectExternalChanges, syntheticReadVerdict, syntheticFetchVerdict, consolidationWriteJudge, listBackgroundTasks, taskReadHandleOf, centerCompactionCandidate, effectiveReadFaceObserved, effectiveWriteFaceObserved, effectiveReadDenyObserved, prefixAnchor };
215
+ return { nestedMemory, promptOverheadTokens, compactionRestore, normalizeAttachmentPath, recentlyReadFiles, onCompactionApplied, detectExternalChanges, syntheticReadVerdict, syntheticFetchVerdict, consolidationWriteJudge, listBackgroundTasks, taskReadHandleOf, centerCompactionCandidate, effectiveReadFaceObserved, effectiveWriteFaceObserved, effectiveReadDenyObserved, prefixAnchor };
226
216
  }
@@ -151,6 +151,7 @@ export interface PrepareWiringManifestInput {
151
151
  readonly state: "unavailable";
152
152
  readonly reason: string;
153
153
  };
154
+ /** borrowed-readonly — the leg's declared places (the driver's one mint): the write table's roots, and the manifest's count of each. */ callerPlaces: import("./leg-caller-places.js").LegCallerPlaces;
154
155
  /** borrowed-readonly — the advisor phase's answer, relayed. */ advisorFact?: WiringManifest["advisor"]; /** borrowed-readonly — the config doors' compiled host floor's posture, relayed (absent ⇒ none declared). */
155
156
  hostFloorPosture: WiringManifest["hostFloor"];
156
157
  /** borrowed-readonly — the arming outcome the caps phase reads live (the manifest's auto-mode face at this leg's start). */
@@ -161,7 +161,7 @@ export function durableSuspendInfraGaps(facts) {
161
161
  return gaps;
162
162
  }
163
163
  export function prepareWiringManifest(input) {
164
- const { spec, deps, internals, resume, sessionId, runId, hostTaskId, taskScope, modBus, standingModBus, checkpointScope, policyLayers, effectivePolicy, handsEnabled, skippedFactory, taskRootFinal, legWriteGuard, mcp, irreversibleTools, egressTools, toolEffects, ownedEnv, executionEnv, offloadStore, onceLedger, usageWindows, envLifetimeSuspendAt, runtimeCaps, resolvedInteractionPosture, durableQuestionFace, liveQuestionFace, checkpointStore, sessions, modelGateManifest, autoModeArmReason, permissionMode, fastMode, lockedPreflight, peerLaneRefs, frameSettlement, receiveSeat, sessionBox, sessionAddress, runEnd, harness, pausedRef, askSeat, liveInheritedGate, delegation, approvalParkNotResumable, forcedGateNotResumable, toolRoster, toolPlan, readDenyBuiltinTiersActive, readFloorUnkept, lspManagerWired, shellReadStationArmed, crossBoundaryStationEngaged, lspDiagnosticsLive, fileHistoryFact, projectMemoryFact, sessionRulesChildrenReadLive, memoryPollution, advisorFact, hostFloorPosture, runOrigin, commandSandboxFact } = input;
164
+ const { spec, deps, internals, resume, sessionId, runId, hostTaskId, taskScope, modBus, standingModBus, checkpointScope, policyLayers, effectivePolicy, handsEnabled, skippedFactory, taskRootFinal, legWriteGuard, mcp, irreversibleTools, egressTools, toolEffects, ownedEnv, executionEnv, offloadStore, onceLedger, usageWindows, envLifetimeSuspendAt, runtimeCaps, resolvedInteractionPosture, durableQuestionFace, liveQuestionFace, checkpointStore, sessions, modelGateManifest, autoModeArmReason, permissionMode, fastMode, lockedPreflight, peerLaneRefs, frameSettlement, receiveSeat, sessionBox, sessionAddress, runEnd, harness, pausedRef, askSeat, liveInheritedGate, delegation, approvalParkNotResumable, forcedGateNotResumable, toolRoster, toolPlan, readDenyBuiltinTiersActive, readFloorUnkept, lspManagerWired, shellReadStationArmed, crossBoundaryStationEngaged, lspDiagnosticsLive, fileHistoryFact, projectMemoryFact, sessionRulesChildrenReadLive, memoryPollution, advisorFact, hostFloorPosture, runOrigin, commandSandboxFact, callerPlaces } = input;
165
165
  const onAsk = askSeat.value;
166
166
  const handWriteTools = toolRoster.entries.filter((e) => e.mountedBy === "hands" && (e.effect === "write" || e.effect === "idempotent")).map((e) => e.name);
167
167
  const hasEffectAwareGate = policyLayers.length > 0 || chainJudges(standingModBus);
@@ -228,7 +228,7 @@ export function prepareWiringManifest(input) {
228
228
  const usageGovernance = buildUsageGovernance(usageWindows, deps, spec.principal, sessionId);
229
229
  const platformSuspendArmed = durableSuspendInfraReady && (spec.preemptSignal !== undefined || envLifetimeSuspendAt !== undefined || usageGovernance !== undefined);
230
230
  const durableApproval = effectiveDurableApprovalOf({ declared: spec.durableApproval, forceDurableGate: runtimeCaps?.forceDurableGate === true, approvalParkNotResumable, scope: checkpointScope });
231
- const writeProtection = mountWriteProtection({ deps, guard: legWriteGuard, spec, env: handsEnabled ? executionEnv : undefined, rootPath: taskRootFinal, roster: toolRoster, sessionId, runId });
231
+ const writeProtection = mountWriteProtection({ deps, configRoots: callerPlaces.configRoots.dirs, guard: legWriteGuard, spec, env: handsEnabled ? executionEnv : undefined, rootPath: taskRootFinal, roster: toolRoster, sessionId, runId });
232
232
  const wiringQuestionSeam = resolveQuestionSeam(spec, deps);
233
233
  const wiringQuestionStripped = internals?.questionFaceStripped === true;
234
234
  const wiringManifest = deriveWiringManifest({
@@ -273,6 +273,7 @@ export function prepareWiringManifest(input) {
273
273
  mcp: mcpManifestEntries(lockedPreflight.mcp, mcp.statuses, toolRoster.entries.map((e) => e.name)),
274
274
  ...(writeProtection.mount !== undefined ? { writeProtectionTargetView: writeProtection.mount.targetView } : {}),
275
275
  readDenyBuiltinTiersActive, readDenyFloorUnkept: readFloorUnkept,
276
+ declaredPlaces: { agentConfigDirs: callerPlaces.configRoots.sources, agentHomeDirs: callerPlaces.homes.sources },
276
277
  autoConsolidationOnRecommendation: autoRunOnRecommendationEffective(deps),
277
278
  tools: toolRoster,
278
279
  toolPlan,
@@ -1,4 +1,4 @@
1
- import type { Model, PerModelAuth } from "../../internal/llm.js";
1
+ import type { AssistantMessage, Model, PerModelAuth } from "../../internal/llm.js";
2
2
  import type { AgentMessage, ThinkingLevel } from "../../internal/harness-types.js";
3
3
  import type { Brain } from "../types.js";
4
4
  import type { ModelPricing } from "../pricing.js";
@@ -16,6 +16,8 @@ export interface SuggestionResult {
16
16
  suggestions: string[];
17
17
  tokens: number;
18
18
  costMicroUsd: number;
19
+ /** The pass's reply, present when a call was made (the caller's trace row reads its usage). */
20
+ reply?: AssistantMessage;
19
21
  }
20
22
  /** Parse the model's reply into ≤count clean suggestion strings. Returns [] on anything non-conforming. */
21
23
  export declare function parseSuggestions(text: string, count: number): string[];
@@ -114,5 +114,5 @@ export async function generatePromptSuggestions(llm, transcript, count) {
114
114
  .join("");
115
115
  const u = message.usage;
116
116
  const { costMicroUsd } = usageCostMicroUsd(cacheFamilyOf(llm.model), u, llm.pricing);
117
- return { suggestions: parseSuggestions(text, count), tokens: u.totalTokens || 0, costMicroUsd };
117
+ return { suggestions: parseSuggestions(text, count), tokens: u.totalTokens || 0, costMicroUsd, reply: message };
118
118
  }
@@ -0,0 +1,47 @@
1
+ import { type PermissionResult, type ToolCallRequest } from "../tool-policy.js";
2
+ import type { ShellReadCheck } from "../../tools/fs/shell-read-check.js";
3
+ import type { PersonDirectories } from "./person-path-rows.js";
4
+ /**
5
+ * Does this leg refuse reads outside its declared directories? The declaration (`TaskSpec.blockReadsOutsideRoots`, screened at
6
+ * the door: present ⇒ a boolean) or, on a resume leg, the row's record of it (`CheckpointState.readBlock`): a resume never lifts
7
+ * it, so a host that does not send it again keeps it. Called once per leg, by the branch that mounts the leg (with hands or
8
+ * without), so every reader of the declaration takes this one answer.
9
+ */
10
+ export declare function readBlockOf(leg: {
11
+ readonly spec: {
12
+ readonly blockReadsOutsideRoots?: boolean;
13
+ };
14
+ readonly resume?: {
15
+ readonly seed: {
16
+ readonly readBlock?: true;
17
+ };
18
+ };
19
+ }): boolean;
20
+ /** What the seat changes on a leg with hands, answered once: the remedy its read faces name in place of the escape hint when they
21
+ * refuse a read outside their roots (the one mint of it), whether a person may add a read root mid-run (a card's "allow + this
22
+ * directory" — not where the roots are what was declared; the one answer the grant seat and the shell cards read), and how the
23
+ * read roots take the person's read directories. */
24
+ export declare function readBlockLeg(readBlock: boolean): {
25
+ readonly outsideReadRemedy: string | undefined;
26
+ readonly grantsReadRootMidRun: boolean;
27
+ readonly personDirectories: PersonDirectories;
28
+ };
29
+ /** The read station's refusal of a call's bytes, or `undefined` (no judge on this leg, or the station does not refuse them). */
30
+ export type ReadBoundaryRefusal = (creq: ToolCallRequest, args: unknown, csignal: AbortSignal | undefined) => Promise<Extract<PermissionResult, {
31
+ action: "deny";
32
+ }> | undefined>;
33
+ /**
34
+ * The read station's refusal of `args`, judged BEFORE an inherited station puts an ancestor's question about the call — the
35
+ * ONE mint of that refusal, for the three places such a question is put (an inherited installation's settlement, the
36
+ * shared-instance adapter's arbitration, the approved edit's re-check). `undefined` unless the leg refuses reads outside its
37
+ * directories (`judge`) and the station refuses these bytes. The judge is the fold's own station, bounded as the fold
38
+ * bounds it (the gate's default deadline; a judgment that elapsed or failed is the station's `unanswered`, a refusal on such a
39
+ * leg); its answer is received as the fold receives one (`readStationAnswer`). The refusal is the station's words and card,
40
+ * and its record names the station's layer (`stationRefusal`): the gate files it as the read boundary's, as when the fold's
41
+ * station refuses the same call.
42
+ */
43
+ export declare function readBoundaryRefusalOver(seat: {
44
+ readonly judge: ShellReadCheck | undefined;
45
+ readonly cwd: () => string | undefined;
46
+ readonly signal: AbortSignal;
47
+ }): ReadBoundaryRefusal;
@@ -0,0 +1,33 @@
1
+ import { DEFAULT_GATE_AWAIT_TIMEOUT_MS, gateWaitFailureOf, withGateTimeout } from "../gate-bounded-await.js";
2
+ import { readStationAnswer } from "../shell-read-silence.js";
3
+ import { attest } from "../tool-policy.js";
4
+ import { READ_BLOCK_REMEDY } from "../../tools/fs/file-read-check.js";
5
+ export function readBlockOf(leg) {
6
+ return leg.spec.blockReadsOutsideRoots === true || leg.resume?.seed.readBlock === true;
7
+ }
8
+ export function readBlockLeg(readBlock) {
9
+ return readBlock ? { outsideReadRemedy: READ_BLOCK_REMEDY, grantsReadRootMidRun: false, personDirectories: "set_aside" } : { outsideReadRemedy: undefined, grantsReadRootMidRun: true, personDirectories: "honored" };
10
+ }
11
+ export function readBoundaryRefusalOver(seat) {
12
+ return async (creq, args, csignal) => {
13
+ const { judge } = seat;
14
+ if (judge === undefined)
15
+ return undefined;
16
+ const signal = csignal ?? seat.signal;
17
+ const judged = judge.judge(creq, args, seat.cwd(), signal, { toolCallId: creq.toolCallId });
18
+ if (judged === null)
19
+ return undefined;
20
+ let answer;
21
+ try {
22
+ answer = await withGateTimeout(judged, DEFAULT_GATE_AWAIT_TIMEOUT_MS, signal, "readBoundaryAhead");
23
+ }
24
+ catch (err) {
25
+ answer = judge.unanswered(creq, gateWaitFailureOf(err) === "timeout" ? "the read station timed out" : "the read station could not answer");
26
+ }
27
+ const reading = readStationAnswer(answer, { toolName: creq.toolName, toolCallId: creq.toolCallId });
28
+ if (reading.kind !== "refuse")
29
+ return undefined;
30
+ const { sentence, details } = reading.verdict;
31
+ return attest({ action: "deny", message: sentence ?? `tool "${creq.toolName}" reads what the session's read boundary refuses` }, creq, { stationRefusal: { layer: "read_boundary", ...(details !== undefined ? { details } : {}) } });
32
+ };
33
+ }
@@ -5,21 +5,25 @@
5
5
  *
6
6
  * Each row is a role the engine reads itself at a hop that can refuse; the hop is the engine's own function, the very
7
7
  * one prepare calls — the question below calls it too, so the answer cannot drift from what a task meets, and no
8
- * judgment is written twice. A hop is not a copy: `resolveRunModel` (`seat-model-doors.ts`: the task's own model),
9
- * `resolveCompactionModel` (`prepare-config-doors.ts`: the `summarize` role; `Runner.compactSession` calls it too) and
10
- * `assertAutoConsolidationWirable` (`memory-consolidation-driver.ts`: the consolidation arming door) — all three are called
8
+ * judgment is written twice. A hop is not a copy: `resolveRunModel` (`seat-model-doors.ts`: the task's own model) and
9
+ * `assertAutoConsolidationWirable` (`memory-consolidation-driver.ts`: the consolidation arming door) — both are called
11
10
  * from `prepare-config-doors.ts`, and the rows stand in the order prepare reaches them.
12
11
  *
13
- * `when` says WHAT the hop reads. `per-task`: the face AND the task's own spec (`model`, `modelRole`, `compactionModel`,
14
- * `roles`) — a task that names its model never walks the `default` chain, one that names its compaction model never reads
15
- * `summarize`. `deployment`: the face alone — the deployment's own question, asked of every prepare (the deps door) and of
12
+ * The `summarize` row is deprecated and holds no hop: a compaction summary runs on the task's own model, so no prepare reads
13
+ * the `summarize` role any more, and the row never refuses. The role itself still serves the next-prompt suggestion pass,
14
+ * the consolidation chain (after `consolidate`, the deployment row's own hop) and the classifier chain — none of which
15
+ * refuses at prepare. The row stays for one more minor because the verdict's `role` is typed from this table; it is removed
16
+ * in the next one.
17
+ *
18
+ * `when` says WHAT the hop reads. `per-task`: the face AND the task's own spec (`model`, `modelRole`, `roles`) — a task
19
+ * that names its model never walks the `default` chain. `deployment`: the face alone — the deployment's own question, asked of every prepare (the deps door) and of
16
20
  * a host-run consolidation, and only a refusal when auto-consolidation is armed (`autoRunOnRecommendation: true`); an
17
21
  * explicit `memoryConsolidationDriver.chat` seat is no part of a face, so a deployment that names one holds a seat the
18
22
  * question does not see. Nothing resolves a role at `new Runner` (it receives the catalog and the tier bindings, which are no
19
23
  * roles): the first refusal on a role comes at the first prepare.
20
24
  *
21
25
  * `absence` says what a row does when its role supplies NO model at all: `throws` — the hop refuses; `falls-back` — the
22
- * hop answers "none" and the caller carries on (the compaction pass rides the task's own model).
26
+ * hop answers "none" and the caller carries on.
23
27
  *
24
28
  * Not rows, on purpose: the auto-mode classifier seat (`classifierSeatModel`) and the next-prompt suggestion pass resolve
25
29
  * a role and take the main model when it supplies none — neither refuses; the `subagent` / `verifier` seats resolve when a
@@ -54,7 +58,7 @@ export declare const ROLE_RESOLUTION_TABLE: readonly [Readonly<{
54
58
  }>, Readonly<{
55
59
  role: "summarize";
56
60
  when: "per-task";
57
- hop: "src/core/runner/prepare-config-doors.ts :: resolveCompactionModel";
61
+ hop: "none (deprecated: no prepare reads this role; it serves the suggestion pass, the consolidation chain and the classifier chain)";
58
62
  absence: "falls-back";
59
63
  }>];
60
64
  /** The model face the question is asked of — the members a host hands `new Runner` for models: the catalog, the tier bindings over it, the role map, and the price
@@ -91,8 +95,9 @@ export type ModelFaceVerdict = {
91
95
  * the catalog and the role maps are received once before any hop reads them (a role map that is no map refuses before any
92
96
  * role is read, and the first row asked carries that refusal). A face whose catalog `new Runner` would not accept, given the
93
97
  * same models and pricing, is refused as `new Runner` refuses it — thrown, not a verdict. A role that supplies no model is a refusal only where the row's
94
- * `absence` says `throws`; a `summarize` seat that is unset, or names a word the catalog does not hold, is `ok: true` (the
95
- * compaction pass rides the task's model). A throw that carries no code is not a verdict and is rethrown.
98
+ * `absence` says `throws`; the deprecated `summarize` row never refuses (a compaction pass rides the task's model whatever the
99
+ * seat says), and a task's `compactionModel` is received and not read (deprecated). A throw that carries no code is not a
100
+ * verdict and is rethrown.
96
101
  *
97
102
  * Whether a task's prepare refuses on a role over a given face is answered here and nowhere else: a host that derives it from
98
103
  * its own copy of the role walk (for example by handing the engine a role map cut down to one key) answers a different
@@ -1,16 +1,15 @@
1
1
  import { bindingShown, receiveModelCatalog } from "../roles.js";
2
2
  import { assertAutoConsolidationWirable } from "./memory-consolidation-driver.js";
3
- import { resolveCompactionModel } from "./prepare-config-doors.js";
4
3
  import { receiveRoleMapPriced, resolveRunModel } from "./seat-model-doors.js";
5
4
  export const ROLE_RESOLUTION_TABLE = Object.freeze([
6
5
  Object.freeze({ role: "consolidate", when: "deployment", hop: "src/core/runner/memory-consolidation-driver.ts :: assertAutoConsolidationWirable", absence: "throws" }),
7
6
  Object.freeze({ role: "default", when: "per-task", hop: "src/core/runner/seat-model-doors.ts :: resolveRunModel", absence: "throws" }),
8
- Object.freeze({ role: "summarize", when: "per-task", hop: "src/core/runner/prepare-config-doors.ts :: resolveCompactionModel", absence: "falls-back" }),
7
+ Object.freeze({ role: "summarize", when: "per-task", hop: "none (deprecated: no prepare reads this role; it serves the suggestion pass, the consolidation chain and the classifier chain)", absence: "falls-back" }),
9
8
  ]);
10
9
  const HOPS = {
11
10
  consolidate: (_task, deps) => assertAutoConsolidationWirable({ ...deps, memoryConsolidation: {}, autoRunOnRecommendation: true }),
12
11
  default: (task, deps) => void resolveRunModel(task, deps),
13
- summarize: (task, deps) => void resolveCompactionModel(task, deps, "TaskSpec.compactionModel"),
12
+ summarize: () => undefined,
14
13
  };
15
14
  const WHEN_WORDS = ["per-task", "deployment"];
16
15
  function argumentRefusal(message) {
@@ -42,9 +41,9 @@ export function modelFaceResolvable(face, options = {}) {
42
41
  throw argumentRefusal(`modelFaceResolvable: options.spec must be a task { model?, modelRole?, roles?, compactionModel? } when present (got ${kindOf(given)}).`);
43
42
  const { models: heldModels, tiers, roles: deploymentRoles, pricing } = face;
44
43
  const models = heldModels !== undefined || tiers !== undefined ? receiveModelCatalog(heldModels, tiers, "RunnerDeps", pricing).models : undefined;
45
- const { model, modelRole, roles: taskRoles, compactionModel } = given;
44
+ const { model, modelRole, roles: taskRoles } = given;
46
45
  let read;
47
- const received = () => (read ??= { deps: { models, roles: receiveRoleMapPriced(deploymentRoles, "RunnerDeps.roles", pricing), pricing }, task: { model, modelRole, roles: receiveRoleMapPriced(taskRoles, "TaskSpec.roles", pricing), compactionModel } });
46
+ const received = () => (read ??= { deps: { models, roles: receiveRoleMapPriced(deploymentRoles, "RunnerDeps.roles", pricing), pricing }, task: { model, modelRole, roles: receiveRoleMapPriced(taskRoles, "TaskSpec.roles", pricing) } });
48
47
  for (const row of ROLE_RESOLUTION_TABLE) {
49
48
  if (!when.includes(row.when))
50
49
  continue;
@@ -1,10 +1,13 @@
1
- import { type PermissionMode } from "../ask-origin.js";
1
+ import type { PermissionModeController } from "../mode-policy.js";
2
2
  import { type RuleStoreFault } from "../rule-store-fault.js";
3
3
  import type { RunnerDeps } from "../runner-deps.js";
4
4
  import { type AnnounceOnceLedger } from "./announce-once-ledger.js";
5
- /** The reader's `onUnread` seat over a run's notice sink, the session's announced record and the leg's mode, read when a read finds the
6
- * store unreadable. */
5
+ /** The reader's `onUnread` seat over a run's notice sink, the session's announced record and the leg's mode seat. A read that finds the
6
+ * store unreadable is told once the mode has settled ({@link PermissionModeController.whenArmed}) — the run's start read comes before
7
+ * the deployment's arming facts bind, and a mode the arming folds back (`auto` with no classifier wired, a relaxed mode the deployment
8
+ * denies) would read as itself then, the person left untold and the operator's line naming a mode the leg does not run under. A call's
9
+ * read finds the mode settled and tells at once. */
7
10
  export declare function ruleStoreUnreadableNotice(onNotice: RunnerDeps["onNotice"], ids: {
8
11
  readonly sessionId: string;
9
12
  readonly runId: string;
10
- }, record: Pick<AnnounceOnceLedger, "oncePerSession">, modeNow: () => PermissionMode): (at: "prepare" | "call", faults: readonly RuleStoreFault[]) => void;
13
+ }, record: Pick<AnnounceOnceLedger, "oncePerSession">, modeSeat: Pick<PermissionModeController, "observed" | "whenArmed">): (at: "prepare" | "call", faults: readonly RuleStoreFault[]) => void;
@@ -4,9 +4,9 @@ import { ruleStoreFaultsKey, ruleStoreUnreadableNoticeSentence, ruleStoreUnreada
4
4
  import { announceDigest } from "./announce-once-ledger.js";
5
5
  const RULE_STORE_UNAVAILABLE = "permission.rule_store_unavailable";
6
6
  const RULE_STORE_UNREADABLE_RELAXED = "permission.rule_store_unreadable_relaxed";
7
- export function ruleStoreUnreadableNotice(onNotice, ids, record, modeNow) {
8
- return (at, faults) => {
9
- const mode = modeNow();
7
+ export function ruleStoreUnreadableNotice(onNotice, ids, record, modeSeat) {
8
+ const tell = (at, faults) => {
9
+ const mode = modeSeat.observed;
10
10
  const data = faults.map((f) => ({ sources: [...f.sources], reason: f.reason }));
11
11
  if (modeAnswersUnasked(mode, "rule_unreadable")) {
12
12
  record.oncePerSession(announceDigest(RULE_STORE_UNREADABLE_RELAXED, `${mode}\n${ruleStoreFaultsKey(faults)}`), () => deliverEngineNotice(onNotice, {
@@ -22,4 +22,5 @@ export function ruleStoreUnreadableNotice(onNotice, ids, record, modeNow) {
22
22
  detail: { at, sessionId: ids.sessionId, runId: ids.runId, faults: data },
23
23
  }));
24
24
  };
25
+ return (at, faults) => modeSeat.whenArmed(() => tell(at, faults));
25
26
  }
@@ -1,11 +1,3 @@
1
- /**
2
- * The run body's COMPACTION MACHINERY (R9), verbatim from `Runner.runLocked`: the accounted
3
- * compaction brain (every summary call re-priced onto `stats` like a main-loop call, behind a no-op status
4
- * sink), the within-task compaction switch, the shared consecutive-failure breaker, and the
5
- * window-safety option builder every in-run maybeCompact lane spreads (the fallback-budget gate + the disclosure bridge).
6
- */
7
- import type { Model } from "../../internal/llm.js";
8
- import type { MaybeCompactOptions } from "../auto-compaction.js";
9
1
  import type { ModelPricing } from "../pricing.js";
10
2
  import type { Brain, TaskSpec } from "../types.js";
11
3
  import type { Stats } from "./assemble-result.js";
@@ -38,8 +30,6 @@ export interface RunCompactionMachineryResult {
38
30
  compactionBreaker: {
39
31
  failures: number;
40
32
  };
41
- /** The window-safety wiring (per call — a mid-task degrade moves the fallback target). */
42
- windowSafetyOptions: (mainModel: Model) => Pick<MaybeCompactOptions, "fallbackBudget" | "onWindowSafety">;
43
33
  /** The leg's one door onto the run's usage account (the same function `Prepared.sideCallBookRef.book` holds): every
44
34
  * model call made beside the main loop is booked through it, once, with its lane. */
45
35
  bookSideCall: SideCallBook;
@@ -1,50 +1,14 @@
1
1
  import { compactionEnabled, contextOverlayFor } from "../context-settings.js";
2
- import { emitTrace } from "../trace.js";
3
2
  import { derivedLegBrain, sideCallBookOf } from "./side-call-account.js";
4
3
  import { modelLaneBrainOf } from "./model-lane-seat.js";
4
+ import { observingBrain } from "./prefix-ledger.js";
5
5
  export function runCompactionMachinery(input) {
6
6
  const { spec, prepared, rs, stats, noteUnevaluablePriceTable, runner } = input;
7
7
  const bookSideCall = sideCallBookOf(stats, { telemetry: rs.telemetry, pricing: () => runner.deps.pricing, noteUnevaluablePriceTable, noteFallback: (lane, requested, reading) => rs.degrade.fallbackSeat.observe(lane, requested, reading) });
8
8
  prepared.sideCallBookRef.book = bookSideCall;
9
- const compactionBrain = derivedLegBrain(() => modelLaneBrainOf(runner.deps), "compaction", bookSideCall, () => prepared.fastMode.callFor());
9
+ const compactionBrain = derivedLegBrain(() => observingBrain(modelLaneBrainOf(runner.deps), prepared.observeSideRequest), "compaction", bookSideCall, () => prepared.fastMode.callFor());
10
10
  const legOverlay = () => contextOverlayFor(runner.deps.contextSettings, prepared.harness.getModelRef(), runner.deps);
11
11
  const withinTaskCompaction = () => compactionEnabled("autoCompact", spec.compaction, legOverlay()) && (spec.compaction?.withinTask ?? true);
12
12
  const compactionBreaker = { failures: 0 };
13
- const windowSafetyOptions = (mainModel) => ({
14
- ...(rs.budget.maxCostMicroUsd !== undefined
15
- ? {
16
- fallbackBudget: {
17
- spentMicroUsd: () => stats.costMicroUsd,
18
- capMicroUsd: rs.budget.maxCostMicroUsd,
19
- mainInputPer1M: rs.budget.estimateRatesOf(mainModel).inputPer1M,
20
- },
21
- }
22
- : {}),
23
- onWindowSafety: (info) => {
24
- if (info.kind === "fallback") {
25
- emitTrace(rs.telemetry.tracer, () => ({
26
- kind: "compaction.model_fallback",
27
- version: 1,
28
- taskId: rs.telemetry.taskId,
29
- contentTokens: info.contentTokens,
30
- headroomTokens: info.headroomTokens ?? 0,
31
- truncationRatio: info.truncationRatio,
32
- ...(info.estCostMicroUsd !== undefined ? { estCostMicroUsd: info.estCostMicroUsd } : {}),
33
- ts: Date.now(),
34
- }));
35
- }
36
- else {
37
- emitTrace(rs.telemetry.tracer, () => ({
38
- kind: "compaction.clamp_disclosure",
39
- version: 1,
40
- taskId: rs.telemetry.taskId,
41
- truncationRatio: info.truncationRatio,
42
- reason: info.reason ?? "tolerance",
43
- ...(info.estCostMicroUsd !== undefined ? { estCostMicroUsd: info.estCostMicroUsd } : {}),
44
- ts: Date.now(),
45
- }));
46
- }
47
- },
48
- });
49
- return { compactionBrain, withinTaskCompaction, compactionBreaker, windowSafetyOptions, bookSideCall };
13
+ return { compactionBrain, withinTaskCompaction, compactionBreaker, bookSideCall };
50
14
  }
@@ -25,13 +25,14 @@ import { createWithheldShellEnvSeat } from "./shell-env-withheld.js";
25
25
  import { wireOf } from "../tool-name-readings.js";
26
26
  import { rosterToolName } from "../tool-roster.js";
27
27
  import { legFirstInputOf, userRowSourceOf } from "../user-row-origin.js";
28
+ import { readingOfUsage } from "./prefix-ledger.js";
28
29
  export function createHarnessHandlers(input) {
29
30
  const { prepared, stats, rs, deps } = input;
30
31
  const responseModelSeat = createResponseModelSeat(deps.runnerHooks.onNotice, { sessionId: prepared.sessionId, runId: prepared.runId });
31
32
  const toolCallIdFoldSeat = createToolCallIdFoldSeat(deps.runnerHooks.onNotice, { sessionId: prepared.sessionId, runId: prepared.runId });
32
33
  const toolTurnIncompleteSeat = createToolTurnIncompleteSeat(deps.runnerHooks.onNotice, { sessionId: prepared.sessionId, runId: prepared.runId }, () => prepared.loopReasksRef.count);
33
34
  const finishReasonSeat = createFinishReasonSeat(deps.runnerHooks.onNotice, { sessionId: prepared.sessionId, runId: prepared.runId });
34
- const withheldShellEnvSeat = createWithheldShellEnvSeat(prepared, deps.runnerHooks.onNotice);
35
+ const withheldShellEnvSeat = createWithheldShellEnvSeat(prepared, deps.runnerHooks.onNotice, deps.internals?.receivedPeers?.peerEntries);
35
36
  const { spec, queue, internals, ident, pushContent, display, emitCommitted, startedToolCallIds, toolStartAt, toolProgress, writeFamilyOf, toolLabels, postToolBatchArmed, batchArgs, internalsNotifier, mediaBudgetBase64Chars } = deps;
36
37
  const frames = { push: (f) => pushContent({ ...f, ...ident() }), structured: prepared.structuredProjector, mediaBudgetBase64Chars, reviewRequest: prepared.reviewRequestRef, verdicts: prepared.verdictLedger };
37
38
  const startOf = (e) => {
@@ -122,6 +123,7 @@ export function createHarnessHandlers(input) {
122
123
  }
123
124
  bookLeftHops(rs, stats, answerBills?.reading);
124
125
  const u = m.usage;
126
+ const mainReading = readingOfUsage(u);
125
127
  const answerUsageMissing = m.usageMissing === true;
126
128
  const callEndAt = Date.now();
127
129
  const callIssuedAt = prepared.callIssuedAtRef.current;
@@ -145,25 +147,10 @@ export function createHarnessHandlers(input) {
145
147
  ...(m.role === "assistant" && typeof m.stopReason === "string"
146
148
  ? { stopReason: m.stopReason }
147
149
  : {}),
150
+ ...(mainReading !== undefined ? { request: mainReading } : {}),
148
151
  ts: callEndAt,
149
152
  }));
150
- const cacheRead = u.cacheRead;
151
- const cacheRowUnknown = answerUsageMissing || m.stopReason === "aborted" || cacheRead === undefined;
152
153
  prepared.turnSnapshot?.refreshModel({ provider: m.provider, modelId: m.model });
153
- if (prepared.cacheBreakDetector && prepared.cacheFingerprint && !cacheRowUnknown) {
154
- const finding = prepared.cacheBreakDetector.observe({
155
- turn: stats.turns + 1,
156
- systemPrompt: prepared.cacheFingerprint.systemPrompt,
157
- tools: prepared.cacheFingerprint.tools,
158
- modelKey: `${m.provider}:${m.model}`,
159
- cacheRead,
160
- });
161
- if (finding) {
162
- rs.telemetry.cacheBreakReported = true;
163
- const what = finding.expected === true ? "expected opening" : finding.cause === "server-or-ttl" ? "break" : "undeclared prefix change";
164
- deps.runnerHooks.onError?.(new Error(`prompt-cache: ${what} at turn ${finding.turn} — cache_read ${finding.cacheReadBefore}→${finding.cacheReadAfter}; ${finding.detail}. See design/31.`), { phase: "prompt-cache", sessionId: prepared.sessionId, classification: finding.cause, ...(finding.expected === true ? { expected: true } : {}), ...(finding.firstChangedIndex !== undefined ? { firstChangedIndex: finding.firstChangedIndex } : {}) });
165
- }
166
- }
167
154
  }
168
155
  if (m.role === "assistant" && typeof m.stopReason === "string") {
169
156
  rs.turn.turnStopReason = m.stopReason;
@@ -22,12 +22,14 @@ export function runIdentityWiring(input) {
22
22
  taskIdRef.effectiveMemoryScopes = prepared.effectiveMemoryScopes;
23
23
  if (taskIdRef)
24
24
  taskIdRef.editedFiles = prepared.editedFilesSnapshot;
25
+ if (taskIdRef)
26
+ taskIdRef.readFloorUnkept = prepared.readFloorUnkept;
25
27
  const runSourceTaskId = prepared.taskId;
26
28
  const parentToolCallId = internals?.parentToolCallId;
27
29
  const ident = () => parentToolCallId !== undefined ? { eventId: uuidv7(), parentToolCallId, sourceTaskId: runSourceTaskId } : { eventId: uuidv7() };
28
30
  notificationLane.ident = ident;
29
31
  const internalsNotifier = hostSinkNotifier(runner.deps.onNotice, "run_internals");
30
- const legAt = Object.freeze({ taskId: prepared.taskId, sessionId: prepared.sessionId });
32
+ const legAt = Object.freeze({ taskId: prepared.taskId, sessionId: prepared.sessionId, runId: prepared.runId });
31
33
  const offerLegFrame = (frame) => {
32
34
  Object.freeze(frame);
33
35
  const accepted = queue.push(frame);
@@ -39,6 +41,7 @@ export function runIdentityWiring(input) {
39
41
  createSnapshotFrameSeat(() => prepared.wiringManifest).subscribe((manifest) => offerLegFrame({ type: "wiring_manifest", manifest, ...ident() }));
40
42
  prepared.toolRosterDeltas.subscribe((delta) => queue.push({ type: "tool_roster_delta", delta, ...ident() }));
41
43
  prepared.toolDisclosure?.subscribe((snapshot) => queue.push({ type: "tool_disclosure", ...snapshot, ...ident() }));
44
+ prepared.prefixChanges.subscribe(({ causes, segments, ...where }) => queue.push({ type: "prefix_changed", ...where, causes: [...causes], ...(segments !== undefined ? { segments: [...segments] } : {}), ...ident() }));
42
45
  prepared.workspaceFrame.subscribe((snapshot) => offerLegFrame({ type: "workspace_changed", ...snapshot, ...ident() }));
43
46
  const delegationLifecycleNotifier = hostSinkNotifier(runner.deps.onNotice, "delegation_lifecycle");
44
47
  const emitDelegationLifecycle = (event) => {
@@ -13,7 +13,8 @@ import { offeredAgentListing } from "../mods/agent-stations.js";
13
13
  import { appendAdmittedRow } from "../row-admission.js";
14
14
  import { buildAppliedHumanInputEvent, buildHumanInputEvent, personSteerFrame, projectHumanInput } from "../human-input-projection.js";
15
15
  import { inputSourceOf } from "../steer-replay.js";
16
- import { isScreened, judgedAuthorOf, objectiveAuthorOf } from "../input-author.js";
16
+ import { countsAsOperator, isScreened, judgedAuthorOf, objectiveAuthorOf } from "../input-author.js";
17
+ import { renderSkillMentionFrame, skillMentionsIn } from "./skill-mention.js";
17
18
  import { humanInputAttachmentsOf, readObjectiveAttachments, userAttachmentDeclarations } from "../user-attachment.js";
18
19
  import { findUnansweredToolBatch, NothingQueuedError, readToolCallArguments, uuidv7 } from "../../internal/harness.js";
19
20
  import { ORG_ADJUDICATION_TIMEOUT_MS, settleOrgVerdictWithin } from "../permission-rule-org.js";
@@ -388,6 +389,7 @@ export async function runLeg(input) {
388
389
  else {
389
390
  const objectiveActor = entryActor;
390
391
  let projectedObjective = projectHumanInput({ text: spec.objective ?? "", actor: objectiveActor, source: "objective" });
392
+ let objectiveWords = spec.objective ?? "";
391
393
  let objectiveRewrittenBy;
392
394
  let effectiveObjective = projectedObjective;
393
395
  let promptBlocked = false;
@@ -405,6 +407,7 @@ export async function runLeg(input) {
405
407
  }, prepared.abortController.signal, { author: judgedAuthorOf(author), whileScreened: prepared.hookScreens.prompt });
406
408
  if (screen?.kind === "answered" && screen.rewrittenBy !== undefined) {
407
409
  projectedObjective = projectHumanInput({ text: screen.text, actor: objectiveActor, source: "objective" });
410
+ objectiveWords = screen.text;
408
411
  objectiveRewrittenBy = screen.rewrittenBy;
409
412
  effectiveObjective = projectedObjective;
410
413
  }
@@ -511,6 +514,12 @@ export async function runLeg(input) {
511
514
  if (changedFirst !== undefined)
512
515
  firstFrames.push({ source: "changed_files", body: changedFirst.body, commit: () => undefined, disclose: () => undefined });
513
516
  }
517
+ if (!promptBlocked && !wakeLeg && countsAsOperator(author) && prepared.skillsListing !== undefined && prepared.promptManifest.selectors.host.role !== "coordinator") {
518
+ const named = skillMentionsIn(objectiveWords, new Set(prepared.skillsListing.entries.map((e) => e.name)));
519
+ const mentionBody = named.length > 0 ? renderSkillMentionFrame(named, prepared.engineText) : undefined;
520
+ if (mentionBody !== undefined)
521
+ firstFrames.push({ source: "skill_mention", body: mentionBody, commit: () => undefined, disclose: () => undefined });
522
+ }
514
523
  if (prepared.memoryNoticesFrame !== undefined)
515
524
  effectiveObjective = `${prepared.memoryNoticesFrame}\n${effectiveObjective}`;
516
525
  if (firstFrames.length > 0) {
@@ -690,6 +699,7 @@ export async function runLeg(input) {
690
699
  unsubscribeTaskNotifications();
691
700
  prepared.toolRosterDeltas.unsubscribe();
692
701
  prepared.toolDisclosure?.unsubscribe();
702
+ prepared.prefixChanges.unsubscribe();
693
703
  unsubGitRetry();
694
704
  unsubBoundary();
695
705
  unsub();
@@ -1,5 +1,3 @@
1
- import type { Model } from "../../internal/llm.js";
2
- import { type MaybeCompactOptions } from "../auto-compaction.js";
3
1
  import type { PushQueue } from "../push-queue.js";
4
2
  import type { Brain, TaskEvent, TaskSpec } from "../types.js";
5
3
  import type { InstallingPhaseResult, Prepared, RunnerDepsSeat, RunState } from "./contracts.js";
@@ -29,8 +27,6 @@ export interface RunRecoveryLanesInput {
29
27
  compactionBreaker: {
30
28
  failures: number;
31
29
  };
32
- /** borrowed-readonly — the window-safety option builder (the compaction-machinery lane's), per pass. */
33
- windowSafetyOptions: (mainModel: Model) => Pick<MaybeCompactOptions, "fallbackBudget" | "onWindowSafety">;
34
30
  /** borrowed-readonly — the run's caller-stop gate: the shared pass admits on it and carries it. */
35
31
  callerStop: CallerStopGate;
36
32
  /** borrowed-readonly — the Runner's deployment deps, read LIVE (`onError`; the compaction seams the pass reaches down