@sema-agent/core 7.62.0 → 7.64.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 (320) hide show
  1. package/CHANGELOG.md +936 -0
  2. package/dist/agents/cc-peer-directory.js +1 -0
  3. package/dist/agents/cc-peer-wire.d.ts +4 -0
  4. package/dist/agents/cc-peer-wire.js +1 -0
  5. package/dist/agents/cc-uds-peer-channel.js +5 -0
  6. package/dist/agents/cross-session-judge.d.ts +3 -1
  7. package/dist/agents/cross-session-judge.js +4 -1
  8. package/dist/agents/peer-directory.d.ts +8 -0
  9. package/dist/agents/peer-directory.js +4 -0
  10. package/dist/agents/peer-held-queue.d.ts +9 -3
  11. package/dist/agents/peer-held-queue.js +12 -9
  12. package/dist/agents/peer-idle.d.ts +20 -1
  13. package/dist/agents/peer-idle.js +23 -12
  14. package/dist/agents/peer-notice-route.d.ts +16 -5
  15. package/dist/agents/peer-notice-route.js +11 -9
  16. package/dist/agents/peer-notices.d.ts +25 -8
  17. package/dist/agents/peer-notices.js +6 -1
  18. package/dist/agents/peer-session-drain.d.ts +32 -6
  19. package/dist/agents/peer-session-drain.js +100 -26
  20. package/dist/agents/send-message-tool.d.ts +7 -0
  21. package/dist/agents/send-message-tool.js +18 -6
  22. package/dist/agents/subagent-transcript-placement.d.ts +23 -0
  23. package/dist/agents/subagent-transcript-placement.js +14 -0
  24. package/dist/agents/subagent.js +102 -54
  25. package/dist/brain/route-adjudicator.js +9 -4
  26. package/dist/core/allow-entry.d.ts +4 -0
  27. package/dist/core/approval-object.js +1 -1
  28. package/dist/core/arg-summary.js +1 -1
  29. package/dist/core/ask-origin.d.ts +1 -1
  30. package/dist/core/ask-origin.js +2 -2
  31. package/dist/core/ask-question.d.ts +2 -2
  32. package/dist/core/ask-unresolvable-notice.d.ts +13 -4
  33. package/dist/core/ask-unresolvable-notice.js +10 -3
  34. package/dist/core/auto-compaction.d.ts +7 -5
  35. package/dist/core/background-agent-store.d.ts +7 -0
  36. package/dist/core/background-agent-store.js +3 -0
  37. package/dist/core/canonical-json.d.ts +23 -13
  38. package/dist/core/canonical-json.js +4 -4
  39. package/dist/core/checkpoint-queries.d.ts +50 -4
  40. package/dist/core/checkpoint-queries.js +42 -17
  41. package/dist/core/checkpoint-requirements.d.ts +3 -3
  42. package/dist/core/checkpoint-requirements.js +2 -1
  43. package/dist/core/checkpoint-row-verdict.d.ts +15 -4
  44. package/dist/core/checkpoint-row-verdict.js +22 -2
  45. package/dist/core/checkpoint-store.d.ts +28 -11
  46. package/dist/core/checkpoint-store.js +45 -4
  47. package/dist/core/compliance.d.ts +6 -2
  48. package/dist/core/compliance.js +3 -3
  49. package/dist/core/context-settings.d.ts +40 -9
  50. package/dist/core/context-settings.js +32 -10
  51. package/dist/core/engine-attestation.d.ts +27 -7
  52. package/dist/core/engine-attestation.js +5 -1
  53. package/dist/core/engine-notice.d.ts +43 -5
  54. package/dist/core/extension-requester.d.ts +9 -0
  55. package/dist/core/extension-requester.js +7 -0
  56. package/dist/core/file-history-store.d.ts +28 -0
  57. package/dist/core/file-history-store.js +48 -5
  58. package/dist/core/fs-write-gate-policy.js +1 -1
  59. package/dist/core/gate-fold.js +2 -0
  60. package/dist/core/gate-lanes.js +2 -0
  61. package/dist/core/gate-outcome.d.ts +39 -2
  62. package/dist/core/gate-outcome.js +20 -1
  63. package/dist/core/git-worktree-env.d.ts +62 -3
  64. package/dist/core/git-worktree-env.js +91 -30
  65. package/dist/core/governance-codes.d.ts +9 -3
  66. package/dist/core/governance-codes.js +17 -3
  67. package/dist/core/leg-identity.d.ts +19 -1
  68. package/dist/core/leg-identity.js +12 -0
  69. package/dist/core/mailbox-store.d.ts +39 -4
  70. package/dist/core/mailbox-store.js +14 -2
  71. package/dist/core/memory-engine/consolidation-driver.d.ts +32 -17
  72. package/dist/core/memory-engine/consolidation-driver.js +99 -98
  73. package/dist/core/memory-engine/consolidation.d.ts +74 -10
  74. package/dist/core/memory-engine/consolidation.js +183 -11
  75. package/dist/core/memory-engine/control-objects.d.ts +25 -0
  76. package/dist/core/memory-engine/control-objects.js +151 -0
  77. package/dist/core/memory-engine/control-plane-adoption.d.ts +48 -0
  78. package/dist/core/memory-engine/control-plane-adoption.js +159 -0
  79. package/dist/core/memory-engine/data-plane.d.ts +8 -4
  80. package/dist/core/memory-engine/data-plane.js +11 -6
  81. package/dist/core/memory-engine/delegation-settlement.d.ts +58 -40
  82. package/dist/core/memory-engine/delegation-settlement.js +270 -85
  83. package/dist/core/memory-engine/dual-root.d.ts +12 -6
  84. package/dist/core/memory-engine/dual-root.js +11 -7
  85. package/dist/core/memory-engine/engine.d.ts +136 -58
  86. package/dist/core/memory-engine/engine.js +491 -394
  87. package/dist/core/memory-engine/entry-scan.d.ts +8 -0
  88. package/dist/core/memory-engine/entry-scan.js +3 -0
  89. package/dist/core/memory-engine/file-backend.d.ts +62 -60
  90. package/dist/core/memory-engine/file-backend.js +122 -198
  91. package/dist/core/memory-engine/index.d.ts +8 -7
  92. package/dist/core/memory-engine/index.js +7 -6
  93. package/dist/core/memory-engine/landing-admission.d.ts +5 -3
  94. package/dist/core/memory-engine/landing-admission.js +3 -3
  95. package/dist/core/memory-engine/layout.d.ts +127 -46
  96. package/dist/core/memory-engine/layout.js +264 -109
  97. package/dist/core/memory-engine/memory-backend-contract.d.ts +26 -1
  98. package/dist/core/memory-engine/memory-backend-contract.js +476 -0
  99. package/dist/core/memory-engine/memory-deployment.d.ts +42 -11
  100. package/dist/core/memory-engine/memory-deployment.js +54 -15
  101. package/dist/core/memory-engine/origin-clearance.d.ts +12 -3
  102. package/dist/core/memory-engine/origin-clearance.js +68 -9
  103. package/dist/core/memory-engine/scope-contract.d.ts +52 -11
  104. package/dist/core/memory-engine/scope-contract.js +68 -19
  105. package/dist/core/memory-engine/session-write-home.d.ts +37 -2
  106. package/dist/core/memory-engine/session-write-home.js +38 -11
  107. package/dist/core/memory-engine/sync-client.d.ts +3 -1
  108. package/dist/core/memory-engine/sync-client.js +7 -0
  109. package/dist/core/memory-engine/sync-report.d.ts +3 -2
  110. package/dist/core/memory-engine/sync-report.js +6 -2
  111. package/dist/core/memory-engine/tools.d.ts +2 -2
  112. package/dist/core/memory-engine/tools.js +10 -10
  113. package/dist/core/memory-engine/types.d.ts +155 -19
  114. package/dist/core/memory-engine/types.js +2 -0
  115. package/dist/core/memory.js +15 -6
  116. package/dist/core/mode-policy.js +3 -3
  117. package/dist/core/mods/agent-stations.d.ts +18 -0
  118. package/dist/core/mods/agent-stations.js +8 -6
  119. package/dist/core/mods/extension-call.d.ts +4 -0
  120. package/dist/core/mods/extension-call.js +8 -0
  121. package/dist/core/mods/stations.d.ts +20 -1
  122. package/dist/core/mods/stations.js +21 -2
  123. package/dist/core/mods/tool-call.js +3 -4
  124. package/dist/core/parent-spec-seat.d.ts +2 -2
  125. package/dist/core/park-selfcheck.js +2 -2
  126. package/dist/core/pause-registry.d.ts +2 -0
  127. package/dist/core/pause-registry.js +3 -0
  128. package/dist/core/peer-channel.d.ts +5 -0
  129. package/dist/core/permission-rule-consent.d.ts +26 -8
  130. package/dist/core/permission-rule-consent.js +76 -36
  131. package/dist/core/permission-rule-store.d.ts +72 -13
  132. package/dist/core/permission-rule-store.js +29 -8
  133. package/dist/core/read-only-shell.js +3 -2
  134. package/dist/core/redaction-marks.d.ts +8 -0
  135. package/dist/core/redaction-marks.js +6 -0
  136. package/dist/core/refusal-echo.d.ts +20 -0
  137. package/dist/core/refusal-echo.js +33 -0
  138. package/dist/core/remote-env.d.ts +12 -1
  139. package/dist/core/remote-env.js +3 -0
  140. package/dist/core/retention.d.ts +180 -10
  141. package/dist/core/retention.js +45 -0
  142. package/dist/core/retired-keys.d.ts +5 -0
  143. package/dist/core/retired-keys.js +3 -0
  144. package/dist/core/rule-offer-read.d.ts +0 -4
  145. package/dist/core/rule-offer-read.js +2 -18
  146. package/dist/core/runner/child-tree.d.ts +29 -3
  147. package/dist/core/runner/child-tree.js +39 -16
  148. package/dist/core/runner/classifier-ladder.d.ts +7 -1
  149. package/dist/core/runner/classifier-ladder.js +4 -2
  150. package/dist/core/runner/compact-session.js +10 -7
  151. package/dist/core/runner/compaction-call-options.d.ts +7 -7
  152. package/dist/core/runner/compaction-call-options.js +3 -2
  153. package/dist/core/runner/contracts.d.ts +39 -11
  154. package/dist/core/runner/delegation-owner.d.ts +10 -3
  155. package/dist/core/runner/delegation-owner.js +4 -1
  156. package/dist/core/runner/gate-exit.d.ts +6 -0
  157. package/dist/core/runner/gate-exit.js +13 -4
  158. package/dist/core/runner/inherited-ask-grants.js +1 -1
  159. package/dist/core/runner/memory-consolidation-driver.d.ts +10 -5
  160. package/dist/core/runner/memory-consolidation-driver.js +12 -9
  161. package/dist/core/runner/memory-consolidation-write-judge.d.ts +2 -1
  162. package/dist/core/runner/memory-consolidation-write-judge.js +3 -2
  163. package/dist/core/runner/person-path-rows.d.ts +8 -3
  164. package/dist/core/runner/person-path-rows.js +5 -1
  165. package/dist/core/runner/placement-fence.d.ts +12 -0
  166. package/dist/core/runner/placement-fence.js +20 -6
  167. package/dist/core/runner/prepare-ask-lane.js +5 -5
  168. package/dist/core/runner/prepare-caps-and-workflow.d.ts +7 -2
  169. package/dist/core/runner/prepare-caps-and-workflow.js +7 -4
  170. package/dist/core/runner/prepare-config-doors.js +4 -0
  171. package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
  172. package/dist/core/runner/prepare-delegation-surface.js +2 -2
  173. package/dist/core/runner/prepare-execution-env.js +17 -6
  174. package/dist/core/runner/prepare-gate-stations.d.ts +5 -0
  175. package/dist/core/runner/prepare-gate-stations.js +5 -5
  176. package/dist/core/runner/prepare-hands-readface.d.ts +2 -1
  177. package/dist/core/runner/prepare-hands-readface.js +5 -4
  178. package/dist/core/runner/prepare-inherited-gate.d.ts +13 -9
  179. package/dist/core/runner/prepare-inherited-gate.js +12 -6
  180. package/dist/core/runner/prepare-memory-engine-session.d.ts +2 -4
  181. package/dist/core/runner/prepare-memory-engine-session.js +4 -4
  182. package/dist/core/runner/prepare-memory.d.ts +7 -2
  183. package/dist/core/runner/prepare-memory.js +41 -39
  184. package/dist/core/runner/prepare-park-ask.js +4 -3
  185. package/dist/core/runner/prepare-policy-chain.js +7 -7
  186. package/dist/core/runner/prepare-prompt-inputs.js +1 -1
  187. package/dist/core/runner/prepare-task.js +26 -18
  188. package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -1
  189. package/dist/core/runner/prepare-wiring-manifest.js +3 -2
  190. package/dist/core/runner/prepare-workspace-restore.js +3 -6
  191. package/dist/core/runner/resume-admission.d.ts +2 -2
  192. package/dist/core/runner/resume-admission.js +2 -23
  193. package/dist/core/runner/role-resolution-table.d.ts +98 -0
  194. package/dist/core/runner/role-resolution-table.js +62 -0
  195. package/dist/core/runner/run-compaction-machinery.js +2 -2
  196. package/dist/core/runner/run-identity-wiring.js +12 -9
  197. package/dist/core/runner/run-leg.js +9 -5
  198. package/dist/core/runner/run-notification-lane.js +22 -22
  199. package/dist/core/runner/run-recovery-lanes.js +3 -3
  200. package/dist/core/runner/run-settle-and-teardown.js +3 -2
  201. package/dist/core/runner/run-terminal-adoption.js +1 -1
  202. package/dist/core/runner/run-turn-boundary.js +14 -15
  203. package/dist/core/runner/runtask.js +1 -1
  204. package/dist/core/runner/terminal-account.js +1 -1
  205. package/dist/core/runner/tool-occurrence.d.ts +4 -2
  206. package/dist/core/runner/tool-occurrence.js +2 -2
  207. package/dist/core/runner-deps.d.ts +7 -3
  208. package/dist/core/secret-env.d.ts +1 -1
  209. package/dist/core/secret-env.js +4 -4
  210. package/dist/core/session-checkout.d.ts +168 -0
  211. package/dist/core/session-checkout.js +579 -0
  212. package/dist/core/session-store.d.ts +12 -4
  213. package/dist/core/session-store.js +23 -3
  214. package/dist/core/session.d.ts +16 -2
  215. package/dist/core/session.js +3 -0
  216. package/dist/core/shell-read-silence.js +8 -0
  217. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +0 -12
  218. package/dist/core/store-contracts/checkpoint-store-contract.js +6 -7
  219. package/dist/core/store-contracts/peer-directory-contract.js +8 -1
  220. package/dist/core/store-contracts/session-store-contract.js +39 -0
  221. package/dist/core/task-event.d.ts +30 -5
  222. package/dist/core/task-notification.d.ts +119 -32
  223. package/dist/core/task-notification.js +186 -100
  224. package/dist/core/task-registry-agent.d.ts +25 -2
  225. package/dist/core/task-registry-agent.js +56 -22
  226. package/dist/core/task-registry-shared.d.ts +33 -11
  227. package/dist/core/task-registry.d.ts +33 -9
  228. package/dist/core/task-registry.js +36 -18
  229. package/dist/core/task-spec-members.js +1 -1
  230. package/dist/core/task-spec.d.ts +27 -2
  231. package/dist/core/tool-errors.d.ts +14 -6
  232. package/dist/core/tool-errors.js +1 -1
  233. package/dist/core/tool-policy.d.ts +32 -13
  234. package/dist/core/tool-policy.js +27 -17
  235. package/dist/core/tool-result-store.d.ts +20 -0
  236. package/dist/core/tool-spec.d.ts +42 -19
  237. package/dist/core/trace.d.ts +3 -2
  238. package/dist/core/types.d.ts +1 -1
  239. package/dist/core/untrusted-egress.d.ts +15 -4
  240. package/dist/core/untrusted-egress.js +23 -22
  241. package/dist/core/workflow-journal-store.d.ts +11 -0
  242. package/dist/core/workflow-journal-store.js +7 -0
  243. package/dist/core/workflow-run-store.d.ts +9 -0
  244. package/dist/core/workflow-run-store.js +6 -0
  245. package/dist/core/workspace-snapshot.d.ts +3 -1
  246. package/dist/core/workspace-snapshot.js +1 -0
  247. package/dist/engine/compaction/compaction.d.ts +2 -1
  248. package/dist/engine/harness/types.d.ts +67 -1
  249. package/dist/engine/harness/types.js +108 -0
  250. package/dist/engine/session/import-validate.js +6 -1
  251. package/dist/engine/session/session.d.ts +30 -1
  252. package/dist/engine/session/session.js +48 -1
  253. package/dist/index.d.ts +12 -7
  254. package/dist/index.js +12 -7
  255. package/dist/internal/harness-types.d.ts +1 -1
  256. package/dist/orchestration/run-workflow-tool.d.ts +8 -1
  257. package/dist/orchestration/run-workflow-tool.js +8 -0
  258. package/dist/orchestration/workflow-types.d.ts +2 -1
  259. package/dist/orchestration/workflow.d.ts +6 -0
  260. package/dist/orchestration/workflow.js +5 -2
  261. package/dist/stores/file/checkpoint-store.d.ts +6 -0
  262. package/dist/stores/file/checkpoint-store.js +4 -1
  263. package/dist/stores/file/file-history-store.d.ts +13 -0
  264. package/dist/stores/file/file-history-store.js +75 -13
  265. package/dist/stores/file/index.d.ts +11 -1
  266. package/dist/stores/file/index.js +7 -11
  267. package/dist/stores/file/permission-rule-store.d.ts +23 -0
  268. package/dist/stores/file/permission-rule-store.js +75 -7
  269. package/dist/stores/file/session-store.js +2 -1
  270. package/dist/stores/file/tool-result-store.d.ts +14 -0
  271. package/dist/stores/file/tool-result-store.js +39 -2
  272. package/dist/stores/file/workflow-journal-store.d.ts +4 -0
  273. package/dist/stores/file/workflow-journal-store.js +17 -0
  274. package/dist/stores/file/workflow-run-store.d.ts +3 -0
  275. package/dist/stores/file/workflow-run-store.js +15 -0
  276. package/dist/tools/fs/bash-program-position.js +3 -3
  277. package/dist/tools/fs/program-read-model.d.ts +34 -10
  278. package/dist/tools/fs/program-read-model.js +37 -7
  279. package/dist/tools/fs/program-read-model.rows.js +13 -2
  280. package/dist/tools/fs/read-deny.d.ts +28 -3
  281. package/dist/tools/fs/read-deny.js +18 -2
  282. package/dist/tools/fs/removal-targets.js +3 -3
  283. package/dist/tools/fs/safety.d.ts +2 -0
  284. package/dist/tools/fs/safety.js +1 -1
  285. package/dist/tools/fs/shell-read-argv.d.ts +8 -1
  286. package/dist/tools/fs/shell-read-argv.js +34 -29
  287. package/dist/tools/fs/shell-read-bindings.d.ts +2 -0
  288. package/dist/tools/fs/shell-read-bindings.js +5 -1
  289. package/dist/tools/fs/shell-read-brace.d.ts +18 -0
  290. package/dist/tools/fs/shell-read-brace.js +79 -0
  291. package/dist/tools/fs/shell-read-check.d.ts +8 -2
  292. package/dist/tools/fs/shell-read-check.js +16 -14
  293. package/dist/tools/fs/shell-read-establish.js +23 -16
  294. package/dist/tools/fs/shell-read-judge.d.ts +11 -0
  295. package/dist/tools/fs/shell-read-judge.js +3 -3
  296. package/dist/tools/fs/shell-read-plan.d.ts +10 -0
  297. package/dist/tools/fs/shell-read-plan.js +189 -93
  298. package/dist/tools/fs/shell-read-start.d.ts +19 -9
  299. package/dist/tools/fs/shell-read-start.js +20 -12
  300. package/dist/tools/fs/shell-read-word.d.ts +10 -0
  301. package/dist/tools/fs/shell-read-word.js +9 -5
  302. package/dist/tools/fs/shell-read-workdir.d.ts +26 -7
  303. package/dist/tools/fs/shell-read-workdir.js +73 -12
  304. package/dist/tools/fs/shell-read-write-targets.js +13 -8
  305. package/dist/tools/worktree.d.ts +3 -2
  306. package/dist/tools/worktree.js +7 -35
  307. package/package.json +3 -2
  308. package/test/export-surface.snapshot.json +135 -11
  309. package/wire-changes/core-stores-sql@7.63.0.json +30 -0
  310. package/wire-changes/core-stores-sql@7.64.0.json +30 -0
  311. package/wire-changes/core@7.63.0.json +3523 -0
  312. package/wire-changes/core@7.64.0.json +2653 -0
  313. package/wire-changes/mods-kernel@7.63.0.json +30 -0
  314. package/wire-changes/mods-kernel@7.64.0.json +30 -0
  315. package/wire-changes/primitives@7.63.0.json +445 -0
  316. package/wire-changes/primitives@7.64.0.json +30 -0
  317. package/dist/core/credential-vocabulary.d.ts +0 -176
  318. package/dist/core/credential-vocabulary.js +0 -190
  319. package/dist/core/redaction-passes.d.ts +0 -82
  320. package/dist/core/redaction-passes.js +0 -377
@@ -175,6 +175,8 @@ export async function runLeg(input) {
175
175
  const unavailableResume = owedMcpUnavailable(prepared, rs.attach.attachmentsCfg);
176
176
  if (unavailableResume !== undefined)
177
177
  continuation += "\n\n" + mintSystemReminder(sanitizeUntrustedText(unavailableResume.body, attachmentEnvelopeTags("mcp_unavailable")), prepared.reminderMark);
178
+ if (prepared.memoryNoticesFrame !== undefined)
179
+ continuation += "\n\n" + prepared.memoryNoticesFrame;
178
180
  const advisorResumeFrame = advisorFrameText(prepared);
179
181
  if (advisorResumeFrame !== undefined)
180
182
  continuation += "\n\n" + advisorResumeFrame;
@@ -431,6 +433,8 @@ export async function runLeg(input) {
431
433
  }
432
434
  if (prepared.outputStyleFrame !== undefined)
433
435
  firstFrames.push({ source: "output_style", body: prepared.outputStyleFrame, commit: () => undefined, disclose: () => undefined });
436
+ if (prepared.memoryNoticesFrame !== undefined)
437
+ effectiveObjective = `${prepared.memoryNoticesFrame}\n${effectiveObjective}`;
434
438
  if (firstFrames.length > 0) {
435
439
  effectiveObjective = `${firstFrames.map((f) => mintSystemReminder(sanitizeUntrustedText(f.body, attachmentEnvelopeTags(f.source)), prepared.reminderMark)).join("\n")}\n${effectiveObjective}`;
436
440
  }
@@ -643,9 +647,9 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
643
647
  occurrences.gateRound(pendingAction.toolCallId, decidedGate, frozenInputSnapshot(resolvedArgs));
644
648
  let notExecuted = false;
645
649
  const resultRow = (text, isError) => withRowNotExecuted(toolResultMsg(pendingAction.toolCallId, pendingAction.toolName, text, isError), notExecuted);
646
- const settleEnd = async (isError, result, refusedBy, neverRan, extension) => {
650
+ const settleEnd = async (isError, result, refusedBy, neverRan, facts) => {
647
651
  if (refusedBy !== undefined)
648
- occurrences.refuse(pendingAction.toolCallId, refusedBy, extension);
652
+ occurrences.refuse(pendingAction.toolCallId, refusedBy, facts);
649
653
  const settled = emitSettled(occurrences, callStart, { result, isError, ...(neverRan ? { notExecuted: true } : {}) }, { push: emit, structured: prepared.structuredProjector, mediaBudgetBase64Chars: runner.deps.mediaBudgetBase64Chars });
650
654
  notExecuted = settled.notExecuted === true;
651
655
  const gate = settled.gate ?? decidedGate;
@@ -691,12 +695,12 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
691
695
  const screened = await prepared.approvedCallScreen?.({ toolCallId: pendingAction.toolCallId, toolName: pendingAction.toolName, args: structuredClone(resolvedArgs), decidedBy: outcome.hostDecision.decidedBy });
692
696
  if (screened !== undefined && "refused" in screened) {
693
697
  const hookDenial = formatHookFeedback(screened.refused, prepared.reminderMark);
694
- await settleEnd(true, { content: hookDenial }, "hook", undefined, screened.extension);
698
+ await settleEnd(true, { content: hookDenial }, "hook", undefined, screened.extension !== undefined ? { extension: screened.extension } : undefined);
695
699
  emitCommitted(await appendAdmittedRow(prepared.admitRows, prepared.session, resultRow(hookDenial, true)), "toolResult", pendingAction.toolCallId);
696
700
  return;
697
701
  }
698
702
  const executedArgs = resolvedArgs;
699
- const unseen = !licenseCovers(pendingAction.boundInputHash, executedArgs);
703
+ const unseen = !licenseCovers(pendingAction.boundInputHash, pendingAction.toolName, executedArgs);
700
704
  let beltReading;
701
705
  const beltReq = () => ({ toolName: pendingAction.toolName, args: executedArgs, toolCallId: pendingAction.toolCallId, ...callFaceSeat(beltFace()), budget: beltBudget, ...(prepared.cwdRef !== undefined ? { cwd: prepared.cwdRef.current } : {}), ...(prepared.handsRoot !== undefined ? { root: prepared.handsRoot } : {}), ...advertisedWritableRootsSeat(prepared.advertisedWritableDirs), ...exemptRootsSeat(prepared.exemptRoots), ...(beltReading !== undefined ? { targetReading: beltReading } : {}), ...requestGrantBinding((call, args) => skillGrantBindingMembers(call, args, prepared.skillSpecs, SKILL_TOOL_NAME), pendingAction, executedArgs) });
702
706
  const unjudgeable = unseen ? chainCannotJudge(resume.cp.state.inheritedGate) : undefined;
@@ -845,7 +849,7 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
845
849
  const reading = readStationAnswer(verdict, { toolName: pendingAction.toolName, toolCallId: pendingAction.toolCallId });
846
850
  if (reading.kind === "refuse" || reading.kind === "silence" || (unseen && reading.kind !== "vouch")) {
847
851
  const readDenial = formatHookFeedback(`The approved tool call "${pendingAction.toolName}" was not executed: ${reading.verdict.sentence ?? "the read boundary does not vouch for what it reads on this leg"} This approval is spent — the call has to be re-issued and approved again.`, prepared.reminderMark);
848
- await settleEnd(true, { content: readDenial, ...(reading.verdict.details !== undefined ? { details: reading.verdict.details } : {}) }, "read_boundary");
852
+ await settleEnd(true, { content: readDenial, ...(reading.verdict.details !== undefined ? { details: reading.verdict.details } : {}) }, "read_boundary", undefined, reading.verdict.echoed !== undefined ? { echoed: reading.verdict.echoed } : undefined);
849
853
  const eid = await appendAdmittedRow(prepared.admitRows, prepared.session, resultRow(readDenial, true));
850
854
  emitCommitted(eid, "toolResult", pendingAction.toolCallId);
851
855
  return;
@@ -2,7 +2,7 @@ import { createPeerInboundChainRef, createPeerSelfRef } from "../../agents/peer-
2
2
  import { boundInputHashOf } from "../canonical-json.js";
3
3
  import { readPendingSteerQueue } from "../checkpoint-store.js";
4
4
  import { wakeOpening } from "../run-origin.js";
5
- import { bindDeliveryObligations, createLiveNotificationLane, DeliveryObligations, DurableAppendObligations, injectionLaneOf, isDelegatedAgentTerminal, isTerminalTaskNotification, renderTaskNotificationXml, routeOrParkNotification, SystemInjectionQueue, taskNotificationDedupKey } from "../task-notification.js";
5
+ import { bindDeliveryObligations, createLiveNotificationLane, DeliveryObligations, DurableAppendObligations, injectionLaneOf, isDelegatedAgentTerminal, isTerminalTaskNotification, renderTaskNotificationXml, routeOrParkNotification, sessionAddressOf, SystemInjectionQueue, taskNotificationDedupKey } from "../task-notification.js";
6
6
  import { settleConsumedFrame } from "../frame-settlement.js";
7
7
  import { createReceivingChain } from "../mods/session-receive.js";
8
8
  import { asThrownError } from "../thrown-value.js";
@@ -43,11 +43,11 @@ async function runNotificationLaneAs(input, obligations) {
43
43
  let notificationHarness;
44
44
  let notificationIdent = () => ({});
45
45
  let notificationLaneLive = true;
46
- let notificationSessionId;
46
+ let notificationAddress;
47
47
  let descendantAnchorDisclosed = false;
48
48
  const parkTaskNotification = (payload, priority, onDisposition) => {
49
49
  laneSeat.handOff(payload);
50
- const ownSession = notificationSessionId;
50
+ const ownSession = notificationAddress;
51
51
  if (ownSession !== undefined)
52
52
  routeOrParkNotification(pendingSessionNotifications, ownSession, payload, priority, onDisposition);
53
53
  else
@@ -60,18 +60,18 @@ async function runNotificationLaneAs(input, obligations) {
60
60
  uplink(payload, { priority });
61
61
  }
62
62
  catch (e) {
63
- runner.deps.onError?.(e, { phase: "degraded", sessionId: notificationSessionId ?? "", classification: "descendant-terminal-uplink" });
63
+ runner.deps.onError?.(e, { phase: "degraded", sessionId: notificationAddress?.sessionId ?? "", classification: "descendant-terminal-uplink" });
64
64
  }
65
65
  return;
66
66
  }
67
67
  const rootAnchor = internals?.rootSessionId;
68
- if (rootAnchor !== undefined && rootAnchor !== notificationSessionId) {
69
- routeOrParkNotification(pendingSessionNotifications, rootAnchor, payload, priority);
68
+ if (rootAnchor !== undefined && rootAnchor !== notificationAddress?.sessionId) {
69
+ routeOrParkNotification(pendingSessionNotifications, { sessionId: rootAnchor, occupant: internals?.rootSessionIncarnation }, payload, priority);
70
70
  return;
71
71
  }
72
72
  if (internals?.parentSessionId !== undefined && !descendantAnchorDisclosed) {
73
73
  descendantAnchorDisclosed = true;
74
- runner.deps.onError?.(new Error(`background-agent terminal ${payload.task_id} stayed on this run's own session — the delegation tree's root session is not reachable from this run (no uplink, no root anchor)`), { phase: "degraded", sessionId: notificationSessionId ?? "", classification: "descendant-terminal-unrouted" });
74
+ runner.deps.onError?.(new Error(`background-agent terminal ${payload.task_id} stayed on this run's own session — the delegation tree's root session is not reachable from this run (no uplink, no root anchor)`), { phase: "degraded", sessionId: notificationAddress?.sessionId ?? "", classification: "descendant-terminal-unrouted" });
75
75
  }
76
76
  };
77
77
  const receiving = createReceivingChain(() => prepared.receiveSeat);
@@ -83,7 +83,7 @@ async function runNotificationLaneAs(input, obligations) {
83
83
  settleConsumedFrame(prepared.frameSettlement, taskNotificationDedupKey(item.payload), verdict.by, verdict.reason);
84
84
  item.onDisposition?.("refused");
85
85
  },
86
- fault: (e) => runner.deps.onError?.(asThrownError(e), { phase: "degraded", sessionId: notificationSessionId ?? "", classification: "receive-hand-over" }),
86
+ fault: (e) => runner.deps.onError?.(asThrownError(e), { phase: "degraded", sessionId: notificationAddress?.sessionId ?? "", classification: "receive-hand-over" }),
87
87
  });
88
88
  });
89
89
  function handOver(item, shown) {
@@ -153,31 +153,31 @@ async function runNotificationLaneAs(input, obligations) {
153
153
  sessionModeSeats,
154
154
  onTaskNotification: laneSink,
155
155
  }, self, taskIdRef, holdSessionLock, legWrites);
156
- pendingSessionNotifications.bindSessionBox(prepared.sessionId, prepared.sessionBox);
157
- const settling = pendingSessionNotifications.settleBoxDebts(prepared.sessionId, prepared.abortController.signal);
156
+ pendingSessionNotifications.admit(sessionAddressOf(prepared), prepared.sessionBox);
157
+ const settling = pendingSessionNotifications.settleBoxDebts(sessionAddressOf(prepared), prepared.abortController.signal);
158
158
  if (settling !== undefined)
159
159
  await settling;
160
160
  const notificationLane = {
161
161
  get harness() { return notificationHarness; }, set harness(h) { notificationHarness = h; },
162
- get sessionId() { return notificationSessionId; },
163
- set sessionId(s) {
164
- if (notificationSessionId !== undefined)
165
- pendingSessionNotifications.liveLanes.unregister(notificationSessionId, takeAsDestination);
166
- notificationSessionId = s;
167
- if (s !== undefined && notificationLaneLive)
168
- pendingSessionNotifications.liveLanes.register(s, takeAsDestination);
162
+ get address() { return notificationAddress; },
163
+ set address(a) {
164
+ if (notificationAddress !== undefined)
165
+ pendingSessionNotifications.liveLanes.unregister(notificationAddress, takeAsDestination);
166
+ notificationAddress = a;
167
+ if (a !== undefined && notificationLaneLive)
168
+ pendingSessionNotifications.liveLanes.register(a, takeAsDestination);
169
169
  },
170
170
  get ident() { return notificationIdent; }, set ident(f) { notificationIdent = f; },
171
171
  get live() { return notificationLaneLive; },
172
172
  set live(v) {
173
173
  notificationLaneLive = v;
174
- if (notificationSessionId === undefined)
174
+ if (notificationAddress === undefined)
175
175
  return;
176
176
  if (v) {
177
- pendingSessionNotifications.liveLanes.register(notificationSessionId, takeAsDestination);
177
+ pendingSessionNotifications.liveLanes.register(notificationAddress, takeAsDestination);
178
178
  }
179
179
  else {
180
- pendingSessionNotifications.liveLanes.unregister(notificationSessionId, takeAsDestination);
180
+ pendingSessionNotifications.liveLanes.unregister(notificationAddress, takeAsDestination);
181
181
  laneSeat.release();
182
182
  }
183
183
  },
@@ -186,8 +186,8 @@ async function runNotificationLaneAs(input, obligations) {
186
186
  return await next({ prepared, injectTaskNotification, deliveredAtTurnOpen, peerInboundChainRef, modelCatalog, notificationLane, unsubscribeTaskNotifications, deliveryObligations });
187
187
  }
188
188
  finally {
189
- if (notificationSessionId !== undefined)
190
- pendingSessionNotifications.liveLanes.unregister(notificationSessionId, takeAsDestination);
189
+ if (notificationAddress !== undefined)
190
+ pendingSessionNotifications.liveLanes.unregister(notificationAddress, takeAsDestination);
191
191
  await obligations.settle();
192
192
  }
193
193
  }
@@ -15,7 +15,7 @@ import { asThrownError } from "../thrown-value.js";
15
15
  export function runRecoveryLanes(input) {
16
16
  const { spec, prepared, queue, rs, ident, compactionBrain, compactionBreaker, windowSafetyOptions, callerStop, runner } = input;
17
17
  const runForcedCompactionPass = async (lane, turnSignal) => {
18
- if (!compactionEnabled(spec.compaction?.enabled, legContextOverlayOption(prepared, runner).contextOverlay))
18
+ if (!compactionEnabled("autoCompact", spec.compaction, legContextOverlayOption(prepared, runner).contextOverlay))
19
19
  return false;
20
20
  if (compactionBreaker.failures >= MAX_CONSECUTIVE_COMPACTION_FAILURES)
21
21
  return false;
@@ -36,7 +36,7 @@ export function runRecoveryLanes(input) {
36
36
  brain: compactionBrain,
37
37
  getApiKeyAndHeaders: spec.getApiKeyAndHeaders,
38
38
  thinking: prepared.thinking,
39
- settings: legCompactionSettings(spec, legContextOverlayOption(prepared, runner).contextOverlay),
39
+ settings: legCompactionSettings(spec, legContextOverlayOption(prepared, runner).contextOverlay, "autoCompact"),
40
40
  customInstructions: spec.compaction?.instructions ?? DEFAULT_COMPACTION_INSTRUCTIONS,
41
41
  signal: passSignal,
42
42
  manualCancelSignal: callerStop.signal,
@@ -120,7 +120,7 @@ export function runRecoveryLanes(input) {
120
120
  return false;
121
121
  if (prepared.microCompact.clearOnRejection && attempt === 1) {
122
122
  const proj = prepared.microCompact.projectionRef.current;
123
- const compactionAvailable = compactionEnabled(spec.compaction?.enabled, legContextOverlayOption(prepared, runner).contextOverlay) && compactionBreaker.failures < MAX_CONSECUTIVE_COMPACTION_FAILURES;
123
+ const compactionAvailable = compactionEnabled("autoCompact", spec.compaction, legContextOverlayOption(prepared, runner).contextOverlay) && compactionBreaker.failures < MAX_CONSECUTIVE_COMPACTION_FAILURES;
124
124
  const declineArm = compactionAvailable ? "forced_compaction" : "none";
125
125
  const plan = proj === undefined
126
126
  ? { declined: "no_candidates" }
@@ -222,8 +222,9 @@ export async function runSettleAndTeardown(input) {
222
222
  const mes = prepared.memoryEngineSession;
223
223
  await settleTeardownLeg(() => mes.harvest(), "memoryEngineSession.harvest (settle leg)", (e) => runner.deps.onError?.(e, { phase: "config", sessionId: prepared.sessionId }));
224
224
  const scope = mes.handle.writeScope;
225
- if (scope !== null && autoRunOnRecommendationEffective(runner.deps) && scopeHasUnconsumedRecommendation(mes.engine, scope)) {
226
- void autoRunConsolidationFromRecommendation({ deps: runner.deps, engine: mes.engine, scope, sessionId: prepared.sessionId, writeJudge: prepared.consolidationWriteJudge, onNotice: runner.deps.onNotice, onError: runner.deps.onError });
225
+ if (scope !== null && autoRunOnRecommendationEffective(runner.deps) && (await scopeHasUnconsumedRecommendation(mes.engine, scope))) {
226
+ const compliance = { postureOf: runner.deps.compliancePostureResolver, scopeContract: mes.scopeContract, denies: spec.complianceAdditionalDenies };
227
+ void autoRunConsolidationFromRecommendation({ deps: runner.deps, engine: mes.engine, scope, sessionId: prepared.sessionId, writeJudge: prepared.consolidationWriteJudge, compliance, onNotice: runner.deps.onNotice, onError: runner.deps.onError });
227
228
  }
228
229
  }
229
230
  emitTrace(rs.telemetry.tracer, () => ({
@@ -166,7 +166,7 @@ async function finish(spec, prepared, opts, runner, sessions) {
166
166
  brain: opts?.brain ?? runner.deps.brain,
167
167
  getApiKeyAndHeaders: spec.getApiKeyAndHeaders,
168
168
  thinking: prepared.thinking,
169
- settings: legCompactionSettings(spec, legContextOverlayOption(prepared, runner).contextOverlay),
169
+ settings: legCompactionSettings(spec, legContextOverlayOption(prepared, runner).contextOverlay, "autoCompact"),
170
170
  customInstructions: spec.compaction?.instructions ?? DEFAULT_COMPACTION_INSTRUCTIONS,
171
171
  signal: opts.callerStop.signal,
172
172
  manualCancelSignal: opts.callerStop.signal,
@@ -3,6 +3,7 @@ import { mintSystemReminder } from "../reminder-mint.js";
3
3
  import { eventDefaultOn } from "../../prompt-assembly/event-registry.js";
4
4
  import { compactionFailureReason, compactionPassReport, DEFAULT_COMPACTION_INSTRUCTIONS, isCompactionManualCancel, manualCompactOutcomeOf, maybeCompact, mintCompactedEvent, nextTrimForceBackoff, recordCompactionAndCheckRapidRefill } from "../auto-compaction.js";
5
5
  import { emitTrace } from "../trace.js";
6
+ import { compactionEnabled } from "../context-settings.js";
6
7
  import { steeringPreview } from "./steering-preview.js";
7
8
  import { ATTACHMENT_BYTE_CAP, CHANGED_FILES_MAX, TOTAL_TOKENS_REMINDER_DEFAULT_MODE, attachmentEnvelopeTags, clipToBytes, collectDateChange, collectDueAttachments, collectInstructionsChange, commitAgentListing, commitInstructionsChange, commitSkillsListing, isIntactSource, rebaseCadenceWindows, renderAgentListingFrame, renderMcpInstructionsDelta, selectMcpDroppedBatch, renderSkillsListingFrame } from "./turn-attachments.js";
8
9
  import { announceListingTruncation } from "../skill-listing-budget.js";
@@ -514,6 +515,11 @@ export function createTurnBoundary(input) {
514
515
  return outcome;
515
516
  };
516
517
  const compactionPass = async (model, call) => {
518
+ if (manualCompactRef.requested && !compactionEnabled("manualCompact", spec.compaction, legContextOverlayOption(prepared, runner).contextOverlay)) {
519
+ emitTrace(rs.telemetry.tracer, () => ({ kind: "compaction.disabled", version: 1, taskId: rs.telemetry.taskId, ts: Date.now() }));
520
+ queue.push({ type: "compaction_outcome", outcome: "disabled", trigger: "manual", ...requesterOf(manualCompactRef.waiters), ...ident() });
521
+ drainManualCompact("disabled");
522
+ }
517
523
  const forceManual = manualCompactRef.requested;
518
524
  if ((!withinTaskCompaction() && !forceManual) ||
519
525
  prepared.abortController.signal.aborted ||
@@ -570,7 +576,7 @@ export function createTurnBoundary(input) {
570
576
  const trimPressureArmed = prepared.trimPressureRef.droppedMessages;
571
577
  if (trimPressureArmed)
572
578
  prepared.trimPressureRef.droppedMessages = false;
573
- const trimPressure = trimPressureArmed && !rs.counters.trimForceBackoff;
579
+ const trimPressure = trimPressureArmed && !rs.counters.trimForceBackoff && withinTaskCompaction();
574
580
  const passTrigger = trimPressure ? "forced" : forceManual ? "manual" : "auto";
575
581
  let manualOutcome = "failed";
576
582
  const manualInstructions = claimedManual?.instructions;
@@ -588,7 +594,7 @@ export function createTurnBoundary(input) {
588
594
  brain: compactionBrain,
589
595
  getApiKeyAndHeaders: spec.getApiKeyAndHeaders,
590
596
  thinking: prepared.thinking,
591
- settings: legCompactionSettings(spec, legContextOverlayOption(prepared, runner).contextOverlay),
597
+ settings: legCompactionSettings(spec, legContextOverlayOption(prepared, runner).contextOverlay, forceManual ? "manualCompact" : "autoCompact"),
592
598
  customInstructions: manualInstructions ?? spec.compaction?.instructions ?? DEFAULT_COMPACTION_INSTRUCTIONS,
593
599
  signal: compactionPassSignal,
594
600
  manualCancelSignal,
@@ -643,23 +649,16 @@ export function createTurnBoundary(input) {
643
649
  }
644
650
  manualOutcome = manualCompactOutcomeOf(comp);
645
651
  if (forceManual && !comp.compacted && !comp.blocked) {
646
- if (comp.disabled) {
647
- emitTrace(rs.telemetry.tracer, () => ({ kind: "compaction.disabled", version: 1, taskId: rs.telemetry.taskId, ts: Date.now() }));
648
- }
649
- else {
650
- emitTrace(rs.telemetry.tracer, () => ({ kind: "compaction.noop", version: 1, taskId: rs.telemetry.taskId, ts: Date.now() }));
651
- }
652
+ emitTrace(rs.telemetry.tracer, () => ({ kind: "compaction.noop", version: 1, taskId: rs.telemetry.taskId, ts: Date.now() }));
652
653
  }
653
654
  if (!comp.compacted) {
654
655
  const outcome = comp.blocked
655
656
  ? "blocked"
656
- : comp.disabled
657
- ? (forceManual || trimPressure ? "disabled" : undefined)
658
- : comp.suppressedByFloor
659
- ? "suppressed"
660
- : comp.noop || forceManual
661
- ? "noop"
662
- : undefined;
657
+ : comp.suppressedByFloor
658
+ ? "suppressed"
659
+ : comp.noop || forceManual
660
+ ? "noop"
661
+ : undefined;
663
662
  if (outcome !== undefined) {
664
663
  queue.push({ type: "compaction_outcome", outcome, trigger: passTrigger, ...requester, ...ident() });
665
664
  }
@@ -83,7 +83,7 @@ export class Runner {
83
83
  verbLockSeats = { sessionBusy: (id) => this.sessionLocks.has(id) || this.sessionWrites.busy(id), takeSessionLock: (id) => this.acquireSessionLock(id) };
84
84
  sessionReadStates = new SessionReadFileStates();
85
85
  sessionModeSeats = new SessionModeSeats();
86
- pendingSessionNotifications = new PendingSessionNotifications();
86
+ pendingSessionNotifications = new PendingSessionNotifications({ onNotice: () => this.deps.onNotice });
87
87
  parentConstraintRegistry = new Map();
88
88
  suspendedEnvReaps = new Map();
89
89
  locallyClaimedTokens = new LocalClaims();
@@ -7,7 +7,7 @@ import { readMember } from "../thrown-value.js";
7
7
  import { egressText } from "../untrusted-egress.js";
8
8
  import { REDACTION_MARK } from "../redaction-marks.js";
9
9
  import { isSensitiveName, looksLikeCredentialValue } from "../secret-env.js";
10
- import { isSensitiveRecordKey } from "../credential-vocabulary.js";
10
+ import { isSensitiveRecordKey } from "@sema-agent/primitives";
11
11
  const LOOP_EXIT_FAILURE = {
12
12
  completed: undefined,
13
13
  aborted_before_stream: undefined,
@@ -24,6 +24,7 @@
24
24
  * the resumed leg's), joined by the checkpoint row the resumed leg was opened from — never by a field here.
25
25
  */
26
26
  import type { DeniedBy, GateOutcome } from "../gate-outcome.js";
27
+ import { type GateExitFacts } from "./gate-exit.js";
27
28
  /** The one clock the occurrence's heartbeat facts are stamped on. MONOTONIC for the reason the progress lane
28
29
  * states: every reading is subtracted from another, and a wall-clock step backwards would silence the beat. A
29
30
  * host without `performance` falls back to the wall clock and inherits its rollback behaviour. */
@@ -92,8 +93,9 @@ export interface ToolOccurrenceTable {
92
93
  /** A gate exit for this call: its record and the input it decided on (frozen by the gate's exit). */
93
94
  gateRound(toolCallId: string, outcome: GateOutcome, finalInput?: unknown, rewrite?: import("../task-event.js").ToolInputRewrite): void;
94
95
  /** A station after the gate refused the call: one more gate record, minted as a veto of whatever the latest one
95
- * settled (a person's yes stays on the settlement; the refusing layer is the disposition). Returns the record. */
96
- refuse(toolCallId: string, layer: DeniedBy, extension?: string): GateOutcome;
96
+ * settled (a person's yes stays on the settlement; the refusing layer is the disposition). `facts` is what the refusing
97
+ * station knows beside the layer word: the extension that refused, the literals its sentence quoted. Returns the record. */
98
+ refuse(toolCallId: string, layer: DeniedBy, facts?: Pick<GateExitFacts, "extension" | "echoed">): GateOutcome;
97
99
  /** An extension at `tool.call` answered for the call before its body was called (the kernel's record says the body had
98
100
  * not started): the body is never called for this attempt. Once per attempt; a second is an engine defect. */
99
101
  answeredInPlace(toolCallId: string, by: string): void;
@@ -91,10 +91,10 @@ export function createToolOccurrenceTable() {
91
91
  occ.finalInput = finalInput;
92
92
  occ.rewrite = rewrite;
93
93
  },
94
- refuse(toolCallId, layer, extension) {
94
+ refuse(toolCallId, layer, facts) {
95
95
  const occ = held(toolCallId, "a refusal");
96
96
  const latest = occ.gateRounds.at(-1);
97
- const round = mintGateOutcome({ deniedBy: layer, ...(extension !== undefined ? { extension } : {}), ...(latest?.settlement !== undefined && latest.origin !== undefined ? { settled: { settlement: latest.settlement, origin: latest.origin } } : {}) });
97
+ const round = mintGateOutcome({ deniedBy: layer, ...(facts?.extension !== undefined ? { extension: facts.extension } : {}), ...(facts?.echoed !== undefined ? { echoed: facts.echoed } : {}), ...(latest?.settlement !== undefined && latest.origin !== undefined ? { settled: { settlement: latest.settlement, origin: latest.origin } } : {}) });
98
98
  occ.gateRounds.push(round);
99
99
  return round;
100
100
  },
@@ -114,7 +114,7 @@ export interface RunnerDeps {
114
114
  models?: Record<string, Model>;
115
115
  /**
116
116
  * The deployment's per-model CONTEXT-WINDOW overlay, keyed by CATALOG WORD ({@link ContextSettings}):
117
- * `contextTokens` / `autoCompactTokens` / `enabled` over what the model card declares.
117
+ * `contextTokens` / `autoCompactTokens` over what the model card declares, `autoCompact` / `manualCompact` the task seats' twins.
118
118
  *
119
119
  * It is the ONE hot-swappable seat an IN-FLIGHT leg re-reads. Every other seat follows the snapshot law
120
120
  * (a running task keeps the deps object it prepared under) because those seats are the routing card —
@@ -377,7 +377,9 @@ export interface RunnerDeps {
377
377
  * stays host-owned (the four verbs are engine host API; nothing in a task can trigger a run).
378
378
  * `provenance: "off"` beside this refuses loudly at prepare
379
379
  * (`config.memory_consolidation_provenance_off` — the fold law must be able to mint);
380
- * `multiNode: true` without a lease refuses (`config.memory_consolidation_lease_required`);
380
+ * `multiNode: true` without a lease refuses (`config.memory_consolidation_lease_required`), and over a backend whose
381
+ * consolidation state is replica-local (`memoryGovernanceDurability`) it refuses
382
+ * (`config.memory_consolidation_replica_local`);
381
383
  * every other bad value refuses under `config.memory_consolidation` (#123). DEPLOYMENT seat
382
384
  * ONLY (no TaskSpec twin, not in the governed workflow whitelist), same law as
383
385
  * {@link memoryProvenance}.
@@ -703,8 +705,10 @@ export interface RunnerDeps {
703
705
  * resolver fault rather than an adjudicated posture). `undefined` (no resolver / no posture for
704
706
  * the principal) = no compliance restriction from the deployment — existing deployments are untouched. The run's deny
705
707
  * set is this posture's UNION the request's own denies ({@link TaskSpec.complianceAdditionalDenies}, add-only).
708
+ * One seat is asked a second question: the automatic consolidation run a settled leg fires asks it for the posture of the
709
+ * consolidated scope's OWNER (`memory_consolidation`, read by the consolidation verb at its start, not frozen at prepare).
706
710
  */
707
- compliancePostureResolver?: (principal: string | undefined) => import("./compliance.js").CompliancePosture | undefined | Promise<import("./compliance.js").CompliancePosture | undefined>;
711
+ compliancePostureResolver?: import("./compliance.js").CompliancePostureSeat;
708
712
  /**
709
713
  * Org-memory tenant admission (ruled 2026-08-05) — the fail-closed adjudicator for REQUEST-origin
710
714
  * `org:` memory scopes (`TaskSpec.memory` / a subagent's `AgentDefinition.memory`, under the v2
@@ -19,7 +19,7 @@
19
19
  * as written, three ways stricter: plural `TOKENS` is a credential word unless a count word touches it, the GitHub
20
20
  * token names are not held back from the name shape, and the name shape always runs.
21
21
  */
22
- import { type RedactionConfidence, type RedactionSource } from "./credential-vocabulary.js";
22
+ import { type RedactionConfidence, type RedactionSource } from "@sema-agent/primitives";
23
23
  import { type EngineNotice } from "./engine-notice.js";
24
24
  /** Does a value carry a credential? A URL userinfo (after every `scheme://`, and a leading `//`) with a password or a
25
25
  * token-like user; a scheme-less `user:password@host`; a credential assignment; a webhook URL; a Sonar login; a
@@ -1,6 +1,6 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { types } from "node:util";
3
- import { CREDENTIAL_MIN_CHARS, CREDENTIAL_VOCABULARY, envNameView, isSensitiveHeaderName, splitCamelCase } from "./credential-vocabulary.js";
3
+ import { CREDENTIAL_MIN_CHARS, envNameView, isSensitiveHeaderName, splitCamelCase } from "@sema-agent/primitives";
4
4
  import { DEFAULT_INHERITED_ENV_VARS } from "@modelcontextprotocol/client/stdio";
5
5
  import { deliverEngineNotice } from "./engine-notice.js";
6
6
  import { optionKeys, receiveMembers } from "./own-property-receipt.js";
@@ -9,9 +9,9 @@ const PROXY_ENV_RE = /^(?:(?:https?|ftp|all|no)_proxy|npm_config_(?:https?_)?pro
9
9
  function isExemptEnvName(name) {
10
10
  return GIT_CONFIG_ENV_RE.test(name) || PROXY_ENV_RE.test(name);
11
11
  }
12
- const ENV_NAMES = envNameView(CREDENTIAL_VOCABULARY);
12
+ const ENV_NAMES = envNameView();
13
13
  const OTEL_ENV_RE = /^(?:INPUT_)?OTEL_/i;
14
- const SEMA_NAMESPACE_SECRET_RE = new RegExp(`^SEMA_(?:.*_)?${ENV_NAMES.segmentWord}(?:_|$)`, "is");
14
+ const SEMA_NAMESPACE_SECRET_RE = ENV_NAMES.anySegmentUnder("SEMA_");
15
15
  const BUNDLER_SETTINGS = ["BUILD", "LOCAL", "MIRROR", "PATH", "WITH", "WITHOUT", "CACHE", "DISABLE", "IGNORE", "ONLY"];
16
16
  const BUNDLER_HOST = "(?:[A-Za-z0-9]+(?:___[A-Za-z0-9]+)*__)+[A-Za-z]{2,}";
17
17
  const BUNDLER_CREDENTIAL_RE = new RegExp(`^(?:INPUT_)?BUNDLE_(?!(?:${BUNDLER_SETTINGS.join("|")})__(?!${BUNDLER_HOST}$))\\w*__`, "i");
@@ -210,7 +210,7 @@ function notACredentialReason(value) {
210
210
  return `a string of fewer than ${CREDENTIAL_MIN_CHARS} characters, which names no secret`;
211
211
  if (PLACEHOLDER_KEY_WORDS.has(text.toLowerCase()))
212
212
  return "a flag or placeholder word, which names no secret";
213
- if (ONE_REPEATED_CHARACTER_RE.test(text.replace(CREDENTIAL_VOCABULARY.tokenPrefix, "")))
213
+ if (ONE_REPEATED_CHARACTER_RE.test(text.replace(ENV_NAMES.tokenPrefix, "")))
214
214
  return "one character repeated, which names no secret";
215
215
  return undefined;
216
216
  }
@@ -0,0 +1,168 @@
1
+ import type { ExecutionEnv, Session, SessionCheckoutCell, SessionCheckoutDeclared, SessionCheckoutRecord } from "../internal/harness-types.js";
2
+ /** One declared code source: the root it is for, the repository URL (`https` only), the full commit id the session's code
3
+ * starts from, and a display label. */
4
+ export interface WorkspaceSourceDeclaration {
5
+ /** `"taskRoot"`, or `{ directory }` naming an entry of `TaskSpec.additionalDirectories` (the same spelling). */
6
+ readonly root: "taskRoot" | {
7
+ readonly directory: string;
8
+ };
9
+ /** The repository URL. `https` only; normalized (host lowercased, a trailing `/` or `.git` dropped). A user name or password in
10
+ * it, or a query / fragment parameter whose name reads as a credential, is refused, and the refusal echoes only the origin. */
11
+ readonly remote: string;
12
+ /** The full commit id (40 or 64 lowercase hex). The engine checks it on the session's first leg. */
13
+ readonly sha: string;
14
+ /** A display / continuation label (a branch name); never resolved. */
15
+ readonly ref?: string;
16
+ }
17
+ /** `TaskSpec.workspace`: the session's workspace declaration. */
18
+ export interface WorkspaceDeclaration {
19
+ /** `"worktree"`: the session works in its own managed tree of the task root's repository, minted on its first leg. */
20
+ readonly isolation?: "worktree";
21
+ /** Where the tree starts: `"fresh"` (default — the default branch tip) or `"head"` (the current local HEAD). Only with
22
+ * `isolation`, and not with a source for the task root (the source's commit is the start). */
23
+ readonly baseRef?: "fresh" | "head";
24
+ /** The tree's managed name (the EnterWorktree name grammar); absent ⇒ derived from the session id. Only with `isolation`. */
25
+ readonly name?: string;
26
+ /** The code sources, one per repository. */
27
+ readonly sources?: readonly WorkspaceSourceDeclaration[];
28
+ }
29
+ /** Why a checkout cannot get a managed tree here — the probe's closed set. */
30
+ export declare const WORKTREE_INCAPABLE_REASONS: readonly ["git_unavailable", "not_a_repository", "bare_repository", "no_commit", "managed_parent_symlinked", "parent_not_writable", "name_in_use"];
31
+ export type WorktreeIncapableReason = (typeof WORKTREE_INCAPABLE_REASONS)[number];
32
+ /** What {@link probeWorktreeCapability} answered. `gitRoot` = the repository root the managed parent hangs at (present once
33
+ * the location is known to be a repository). */
34
+ export interface WorktreeCapability {
35
+ readonly worktreeCapable: boolean;
36
+ readonly gitRoot?: string;
37
+ readonly reason?: WorktreeIncapableReason;
38
+ /** One human sentence for the refusal; absent when capable. */
39
+ readonly detail?: string;
40
+ }
41
+ /** The release outcome of one tree. `branch` is present while the tree's branch still exists after the release. */
42
+ export interface ReleasedTree {
43
+ readonly path: string;
44
+ readonly removed: boolean;
45
+ readonly branch?: string;
46
+ readonly kept?: "dirty" | "ignored" | "commits" | "unverifiable" | "requested" | "not_owned";
47
+ readonly detail?: string;
48
+ }
49
+ /**
50
+ * THE shape judge of `TaskSpec.workspace` — `undefined` for an absent declaration, else the normalized declaration the record
51
+ * stores and every later leg is compared on. Refused (`config.session_workspace_invalid`): a non-object, an unknown key, a word
52
+ * outside a closed set, `baseRef` / `name` without `isolation`, a name outside the managed grammar, an empty or oversized
53
+ * `sources`, two sources for one root, a source for the isolated task root together with `baseRef`, a declaration that declares
54
+ * nothing.
55
+ */
56
+ export declare function screenWorkspaceDeclaration(value: unknown): SessionCheckoutDeclared | undefined;
57
+ /**
58
+ * THE capability judge of a managed tree for the checkout at `cwd`: git runs, `cwd` is inside a non-bare work tree with a
59
+ * commit, no level of the managed parent is a symlink, the managed parent can be written, and — with `name` — that name's
60
+ * directory and branch are free. The first failing check answers, in that order. Reads only (no git write); a host calls it
61
+ * before offering isolation, and a session's first leg calls it before minting.
62
+ */
63
+ export declare function probeWorktreeCapability(env: ExecutionEnv, cwd: string, opts?: {
64
+ readonly name?: string;
65
+ }): Promise<WorktreeCapability>;
66
+ export interface OpenSessionCheckoutInput {
67
+ /** The leg's hands environment (the one git runs in). */
68
+ readonly env: ExecutionEnv;
69
+ readonly session: Session;
70
+ readonly sessionId: string;
71
+ /** The leg's raw `TaskSpec.workspace`. */
72
+ readonly declaration: unknown;
73
+ /** The leg's task root as the deployment and the workspace restore settled it (the base checkout's location). */
74
+ readonly baseRoot: string;
75
+ /** The leg's `TaskSpec.additionalDirectories` (declared spellings). */
76
+ readonly additionalDirectories: readonly string[] | undefined;
77
+ }
78
+ export interface OpenedSessionCheckout {
79
+ /** The leg's task root: the task root's place in the session's tree when the task root's repository is isolated, else `baseRoot`. */
80
+ readonly taskRoot: string;
81
+ /** The session's checkout record, when it has one. */
82
+ readonly record?: SessionCheckoutRecord;
83
+ }
84
+ /**
85
+ * THE per-leg judge of a session's checkout (see the module header): reads the record, compares the leg's declaration with it,
86
+ * mints the allocation on the session's first leg, and answers the leg's task root. Throws a coded refusal; the first leg's
87
+ * allocation records nothing unless everything succeeded (every path check runs before the mint; a tree minted for a refused
88
+ * allocation is removed while still clean only when its allocation mark is proved absent, else kept and named; the record is
89
+ * written only once everything succeeded — immediately, not at settle).
90
+ */
91
+ export declare function openSessionCheckout(input: OpenSessionCheckoutInput): Promise<OpenedSessionCheckout>;
92
+ /**
93
+ * Release a session's checkout — the host's door when it archives or deletes a session. Each of the session's trees is removed
94
+ * only when it is clean (no uncommitted file, no file git ignores, no commit past its base, its state readable) AND its birth record names this
95
+ * allocation; the removal itself runs without `--force`, so a write landing after the check keeps the tree. Everything else
96
+ * is kept and reported with its path and why. The tree's branch is deleted with it only while the branch still sits at the
97
+ * base commit. Then the release is recorded once (`released: true`), after which the session runs no further leg. Calling it
98
+ * again re-reports and never removes a tree another allocation took over.
99
+ *
100
+ * `onExit`: `"keep-if-dirty"` (default) | `"keep"` (keep every tree; only record the release). A discarding removal is not
101
+ * offered. A session with no checkout answers an empty list; a tree its first leg kept because the record could not be written
102
+ * is no record's to release — {@link listOrphanSessionTrees} lists it.
103
+ */
104
+ export declare function releaseSessionCheckout(env: ExecutionEnv, session: Session, opts?: {
105
+ readonly onExit?: "keep-if-dirty" | "keep";
106
+ }): Promise<{
107
+ readonly trees: readonly ReleasedTree[];
108
+ }>;
109
+ /** Why a session tree whose allocation mark reads is no record's ({@link OrphanSessionTree.why}). */
110
+ export type OrphanSessionTreeWhy = "unrecorded" | "record_unreadable" | "record_elsewhere";
111
+ /** A session tree no record holds — what {@link listOrphanSessionTrees} lists. */
112
+ export interface OrphanSessionTree {
113
+ /** `<repository root>/.sema/worktrees/<name>`, the list's spelling — the path {@link releaseOrphanSessionTree} takes. */
114
+ readonly path: string;
115
+ /** The tree's branch (`sema/<name>`), present while it exists. */
116
+ readonly branch?: string;
117
+ /** The session its allocation mark names. */
118
+ readonly sessionId: string;
119
+ /** The allocation its mark names. */
120
+ readonly allocationId: string;
121
+ /** The commit it was minted at (its mark). */
122
+ readonly baseSha: string;
123
+ /** `unrecorded`: the host's lookup says that session does not exist, or its log holds no checkout record · `record_unreadable`:
124
+ * the lookup threw, the session's record cannot be read, or its log is loaded from a bounded window that may hold the record
125
+ * below its floor · `record_elsewhere`: the session's record holds another allocation (a first leg refused while another leg
126
+ * recorded kept the tree it minted). */
127
+ readonly why: OrphanSessionTreeWhy;
128
+ /** `record_unreadable`: why; `record_elsewhere`: the allocation the record holds. */
129
+ readonly detail?: string;
130
+ /** The tree directory's modification time (ms since the epoch): a hint for a host's retention policy, not liveness. */
131
+ readonly modifiedAt: number;
132
+ }
133
+ /**
134
+ * The host's lookup of a session by id, handed to the orphan doors.
135
+ *
136
+ * @contract session_checkout.session_of.absence_is_authority — `undefined` asserts that the host's DURABLE session store holds no
137
+ * session with that id (a cache miss is not absence), and the lookup throws whenever it cannot tell. The doors read `undefined` as
138
+ * "no leg of that session will take the tree back" (the host never reuses a session id) and a throw as `record_unreadable`, which
139
+ * neither door removes.
140
+ */
141
+ export type OrphanSessionLookup = (sessionId: string) => Promise<Session | undefined>;
142
+ /**
143
+ * List the session trees under the repository at `root` that no record holds: each managed tree whose allocation mark reads and
144
+ * whose session ({@link OrphanSessionLookup}) holds no record of that allocation — the tree a first leg kept when its record could
145
+ * not be written, or one whose session the host deleted without releasing it. Reads only. A tree its session's record holds is
146
+ * not listed ({@link releaseSessionCheckout} is its door), nor a directory with no readable mark (no session tree, or one neither
147
+ * door touches). Answers `{ repository, trees }`; a repository with no managed parent answers no trees.
148
+ */
149
+ export declare function listOrphanSessionTrees(env: ExecutionEnv, root: string, opts: {
150
+ readonly sessionOf: OrphanSessionLookup;
151
+ }): Promise<{
152
+ readonly repository: string;
153
+ readonly trees: readonly OrphanSessionTree[];
154
+ }>;
155
+ /**
156
+ * Release one orphan session tree — the host's door for a tree no record holds (as {@link listOrphanSessionTrees} lists it).
157
+ * The tree is judged again: a tree a session's record holds now answers `kept: "not_owned"` (release that session's checkout
158
+ * instead), one whose record cannot be read `kept: "unverifiable"`, one with no allocation mark `not_owned`; an orphan is then
159
+ * removed by the same judgment as {@link releaseSessionCheckout} (clean, no commit past its base, the mark read again right
160
+ * before the removal, no `--force`; the branch only while it sits at the base commit). Removes nothing on its own initiative,
161
+ * appends to no session. The host runs the removals of one repository one at a time — this door's, the release's, a deleted
162
+ * session's cascade (a removal and a mint of the same name between two of them is the known window, KNOWN-LIMITS KL-3462-a).
163
+ */
164
+ export declare function releaseOrphanSessionTree(env: ExecutionEnv, path: string, opts: {
165
+ readonly sessionOf: OrphanSessionLookup;
166
+ }): Promise<ReleasedTree>;
167
+ /** The frame's `session` member: the record's cells as the leg reports them (`undefined` when the session has no checkout). */
168
+ export declare function sessionFrameOf(record: SessionCheckoutRecord | undefined): ReadonlyArray<SessionCheckoutCell> | undefined;