@sema-agent/core 7.61.0 → 7.63.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 (298) hide show
  1. package/CHANGELOG.md +840 -0
  2. package/dist/agents/cascade.d.ts +11 -3
  3. package/dist/agents/cascade.js +1 -1
  4. package/dist/agents/peer-held-queue.d.ts +27 -4
  5. package/dist/agents/peer-held-queue.js +81 -36
  6. package/dist/agents/peer-session-drain.js +13 -3
  7. package/dist/agents/subagent-transcript-placement.d.ts +23 -0
  8. package/dist/agents/subagent-transcript-placement.js +14 -0
  9. package/dist/agents/subagent.d.ts +6 -1
  10. package/dist/agents/subagent.js +143 -58
  11. package/dist/agents/suspend-guard.d.ts +38 -16
  12. package/dist/agents/suspend-guard.js +9 -4
  13. package/dist/agents/verify.js +4 -3
  14. package/dist/brain/route-adjudicator.js +9 -4
  15. package/dist/core/approval-object.js +1 -1
  16. package/dist/core/arg-summary.js +1 -1
  17. package/dist/core/ask-question.d.ts +2 -2
  18. package/dist/core/canonical-json.d.ts +23 -13
  19. package/dist/core/canonical-json.js +4 -4
  20. package/dist/core/checkpoint-features.d.ts +722 -0
  21. package/dist/core/checkpoint-features.js +98 -0
  22. package/dist/core/checkpoint-queries.d.ts +47 -4
  23. package/dist/core/checkpoint-queries.js +36 -16
  24. package/dist/core/checkpoint-requirements.d.ts +12 -5
  25. package/dist/core/checkpoint-requirements.js +11 -5
  26. package/dist/core/checkpoint-row-verdict.d.ts +110 -0
  27. package/dist/core/checkpoint-row-verdict.js +245 -0
  28. package/dist/core/checkpoint-store.d.ts +76 -753
  29. package/dist/core/checkpoint-store.js +83 -144
  30. package/dist/core/compliance.d.ts +6 -2
  31. package/dist/core/compliance.js +3 -3
  32. package/dist/core/engine-attestation.d.ts +1 -1
  33. package/dist/core/engine-notice.d.ts +38 -7
  34. package/dist/core/engine-notice.js +9 -2
  35. package/dist/core/gate-fold.js +2 -2
  36. package/dist/core/git-worktree-env.d.ts +62 -3
  37. package/dist/core/git-worktree-env.js +91 -30
  38. package/dist/core/governance-codes.d.ts +9 -3
  39. package/dist/core/governance-codes.js +16 -3
  40. package/dist/core/hooks.d.ts +13 -0
  41. package/dist/core/human-input-projection.d.ts +1 -0
  42. package/dist/core/human-input-projection.js +3 -0
  43. package/dist/core/image-admission.d.ts +1 -1
  44. package/dist/core/locked-config.d.ts +2 -2
  45. package/dist/core/mcp-host-seat.js +6 -1
  46. package/dist/core/memory-engine/consolidation-driver.d.ts +33 -18
  47. package/dist/core/memory-engine/consolidation-driver.js +99 -98
  48. package/dist/core/memory-engine/consolidation.d.ts +73 -10
  49. package/dist/core/memory-engine/consolidation.js +167 -11
  50. package/dist/core/memory-engine/data-plane.d.ts +8 -4
  51. package/dist/core/memory-engine/data-plane.js +11 -6
  52. package/dist/core/memory-engine/delegation-settlement.d.ts +37 -35
  53. package/dist/core/memory-engine/delegation-settlement.js +53 -59
  54. package/dist/core/memory-engine/dual-root.d.ts +12 -6
  55. package/dist/core/memory-engine/dual-root.js +9 -5
  56. package/dist/core/memory-engine/engine.d.ts +98 -35
  57. package/dist/core/memory-engine/engine.js +477 -380
  58. package/dist/core/memory-engine/entry-scan.d.ts +8 -0
  59. package/dist/core/memory-engine/entry-scan.js +3 -0
  60. package/dist/core/memory-engine/file-backend.d.ts +29 -3
  61. package/dist/core/memory-engine/file-backend.js +66 -35
  62. package/dist/core/memory-engine/index.d.ts +7 -7
  63. package/dist/core/memory-engine/index.js +6 -6
  64. package/dist/core/memory-engine/landing-admission.d.ts +5 -3
  65. package/dist/core/memory-engine/landing-admission.js +3 -3
  66. package/dist/core/memory-engine/layout.d.ts +121 -45
  67. package/dist/core/memory-engine/layout.js +252 -102
  68. package/dist/core/memory-engine/memory-backend-contract.d.ts +19 -1
  69. package/dist/core/memory-engine/memory-backend-contract.js +320 -0
  70. package/dist/core/memory-engine/memory-deployment.d.ts +31 -8
  71. package/dist/core/memory-engine/memory-deployment.js +26 -12
  72. package/dist/core/memory-engine/scope-contract.d.ts +52 -11
  73. package/dist/core/memory-engine/scope-contract.js +68 -19
  74. package/dist/core/memory-engine/session-write-home.d.ts +3 -1
  75. package/dist/core/memory-engine/session-write-home.js +1 -1
  76. package/dist/core/memory-engine/sync-client.d.ts +3 -1
  77. package/dist/core/memory-engine/sync-client.js +7 -0
  78. package/dist/core/memory-engine/sync-report.d.ts +3 -2
  79. package/dist/core/memory-engine/sync-report.js +6 -2
  80. package/dist/core/memory-engine/tools.d.ts +2 -2
  81. package/dist/core/memory-engine/tools.js +10 -10
  82. package/dist/core/memory-engine/types.d.ts +118 -19
  83. package/dist/core/memory-engine/types.js +1 -0
  84. package/dist/core/memory-vector.d.ts +1 -1
  85. package/dist/core/memory.d.ts +10 -10
  86. package/dist/core/memory.js +15 -6
  87. package/dist/core/mode-policy.js +1 -1
  88. package/dist/core/mods/classic-events.d.ts +9 -1
  89. package/dist/core/mods/dollar.d.ts +32 -1
  90. package/dist/core/mods/dollar.js +13 -1
  91. package/dist/core/mods/kernel/events.d.ts +11 -3
  92. package/dist/core/mods/kernel/events.js +13 -10
  93. package/dist/core/mods/lifecycle-stations.d.ts +36 -4
  94. package/dist/core/mods/lifecycle-stations.js +44 -9
  95. package/dist/core/mods/session-append.d.ts +4 -1
  96. package/dist/core/mods/session-append.js +7 -0
  97. package/dist/core/mods/session-receive.js +12 -15
  98. package/dist/core/mods/stations.d.ts +70 -6
  99. package/dist/core/mods/stations.js +144 -1
  100. package/dist/core/own-property-receipt.d.ts +7 -0
  101. package/dist/core/own-property-receipt.js +3 -0
  102. package/dist/core/park-selfcheck.js +2 -2
  103. package/dist/core/pause-registry.d.ts +2 -0
  104. package/dist/core/pause-registry.js +3 -0
  105. package/dist/core/permission-rule-consent.d.ts +10 -3
  106. package/dist/core/permission-rule-consent.js +37 -24
  107. package/dist/core/permission-rule-store.d.ts +35 -1
  108. package/dist/core/permission-rule-store.js +27 -8
  109. package/dist/core/read-only-shell.js +3 -2
  110. package/dist/core/read-root-candidate.js +1 -1
  111. package/dist/core/redaction-marks.d.ts +8 -0
  112. package/dist/core/redaction-marks.js +6 -0
  113. package/dist/core/remote-env.d.ts +12 -1
  114. package/dist/core/remote-env.js +3 -0
  115. package/dist/core/resume-startup-cause.d.ts +5 -4
  116. package/dist/core/runner/child-tree.d.ts +29 -3
  117. package/dist/core/runner/child-tree.js +39 -16
  118. package/dist/core/runner/compact-session.js +5 -2
  119. package/dist/core/runner/contracts.d.ts +36 -17
  120. package/dist/core/runner/delegation-owner.d.ts +43 -0
  121. package/dist/core/runner/delegation-owner.js +59 -0
  122. package/dist/core/runner/gate-exit.js +2 -2
  123. package/dist/core/runner/inherited-ask-grants.js +1 -1
  124. package/dist/core/runner/lineage-reroot-view.d.ts +56 -0
  125. package/dist/core/runner/lineage-reroot-view.js +108 -0
  126. package/dist/core/runner/memory-consolidation-driver.d.ts +6 -3
  127. package/dist/core/runner/memory-consolidation-driver.js +4 -4
  128. package/dist/core/runner/memory-consolidation-write-judge.d.ts +2 -1
  129. package/dist/core/runner/memory-consolidation-write-judge.js +3 -2
  130. package/dist/core/runner/permission-rule-lanes.d.ts +2 -1
  131. package/dist/core/runner/permission-rule-lanes.js +2 -2
  132. package/dist/core/runner/person-path-rows.d.ts +23 -3
  133. package/dist/core/runner/person-path-rows.js +31 -4
  134. package/dist/core/runner/placement-fence.d.ts +12 -0
  135. package/dist/core/runner/placement-fence.js +20 -6
  136. package/dist/core/runner/prepare-acquire-reconcile.d.ts +4 -1
  137. package/dist/core/runner/prepare-acquire-reconcile.js +7 -2
  138. package/dist/core/runner/prepare-ask-lane.js +2 -2
  139. package/dist/core/runner/prepare-caps-and-workflow.d.ts +5 -1
  140. package/dist/core/runner/prepare-caps-and-workflow.js +6 -3
  141. package/dist/core/runner/prepare-config-doors.d.ts +6 -6
  142. package/dist/core/runner/prepare-config-doors.js +3 -4
  143. package/dist/core/runner/prepare-execution-env.js +17 -6
  144. package/dist/core/runner/prepare-hands-readface.d.ts +3 -2
  145. package/dist/core/runner/prepare-hands-readface.js +32 -10
  146. package/dist/core/runner/prepare-inherited-gate.d.ts +12 -8
  147. package/dist/core/runner/prepare-inherited-gate.js +14 -6
  148. package/dist/core/runner/prepare-memory-engine-session.d.ts +2 -4
  149. package/dist/core/runner/prepare-memory-engine-session.js +4 -4
  150. package/dist/core/runner/prepare-memory.d.ts +3 -2
  151. package/dist/core/runner/prepare-memory.js +28 -20
  152. package/dist/core/runner/prepare-park-ask.js +4 -3
  153. package/dist/core/runner/prepare-task.js +22 -16
  154. package/dist/core/runner/prepare-workspace-restore.js +3 -6
  155. package/dist/core/runner/resume-admission.d.ts +3 -3
  156. package/dist/core/runner/resume-admission.js +6 -3
  157. package/dist/core/runner/resume-apply.d.ts +4 -0
  158. package/dist/core/runner/resume-apply.js +11 -4
  159. package/dist/core/runner/resume-checkpoint-screen.d.ts +9 -0
  160. package/dist/core/runner/resume-checkpoint-screen.js +4 -84
  161. package/dist/core/runner/run-git-lane.d.ts +2 -0
  162. package/dist/core/runner/run-git-lane.js +4 -1
  163. package/dist/core/runner/run-harness-handlers.d.ts +2 -0
  164. package/dist/core/runner/run-harness-handlers.js +3 -2
  165. package/dist/core/runner/run-leg.js +25 -8
  166. package/dist/core/runner/run-settle-and-teardown.js +6 -4
  167. package/dist/core/runner/run-stop-and-final-verify.js +2 -1
  168. package/dist/core/runner/run-turn-boundary.js +7 -4
  169. package/dist/core/runner/runtask.js +6 -6
  170. package/dist/core/runner/steering-preview.d.ts +9 -0
  171. package/dist/core/runner/steering-preview.js +5 -0
  172. package/dist/core/runner/stream-steer-verb.js +8 -0
  173. package/dist/core/runner/terminal-account.js +1 -1
  174. package/dist/core/runner/tool-face-overlay.js +2 -0
  175. package/dist/core/runner/turn-attachments.d.ts +5 -0
  176. package/dist/core/runner/turn-attachments.js +1 -1
  177. package/dist/core/runner-deps.d.ts +8 -4
  178. package/dist/core/secret-env.d.ts +9 -6
  179. package/dist/core/secret-env.js +41 -22
  180. package/dist/core/session-checkout.d.ts +108 -0
  181. package/dist/core/session-checkout.js +485 -0
  182. package/dist/core/session-store.d.ts +13 -5
  183. package/dist/core/session-store.js +28 -4
  184. package/dist/core/session.d.ts +29 -5
  185. package/dist/core/session.js +3 -0
  186. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +6 -12
  187. package/dist/core/store-contracts/checkpoint-store-contract.js +73 -6
  188. package/dist/core/store-contracts/session-store-contract.js +61 -8
  189. package/dist/core/task-event.d.ts +28 -1
  190. package/dist/core/task-notification.d.ts +9 -1
  191. package/dist/core/task-notification.js +8 -1
  192. package/dist/core/task-registry-agent.d.ts +40 -8
  193. package/dist/core/task-registry-agent.js +57 -24
  194. package/dist/core/task-registry-shared.d.ts +33 -11
  195. package/dist/core/task-registry-workflow.js +4 -3
  196. package/dist/core/task-registry.d.ts +27 -10
  197. package/dist/core/task-registry.js +19 -13
  198. package/dist/core/task-result.d.ts +5 -5
  199. package/dist/core/task-spec-members.js +1 -1
  200. package/dist/core/task-spec.d.ts +21 -1
  201. package/dist/core/terminal-cause.d.ts +6 -6
  202. package/dist/core/tool-face.d.ts +6 -2
  203. package/dist/core/tool-face.js +1 -1
  204. package/dist/core/tool-policy.d.ts +16 -13
  205. package/dist/core/tool-policy.js +11 -10
  206. package/dist/core/tool-roster.d.ts +4 -4
  207. package/dist/core/tool-spec.d.ts +42 -19
  208. package/dist/core/types.d.ts +2 -2
  209. package/dist/core/types.js +1 -1
  210. package/dist/core/untrusted-egress.d.ts +15 -4
  211. package/dist/core/untrusted-egress.js +23 -22
  212. package/dist/core/workspace-snapshot.d.ts +3 -1
  213. package/dist/core/workspace-snapshot.js +1 -0
  214. package/dist/engine/execution-env/node-execution-env.d.ts +3 -0
  215. package/dist/engine/execution-env/node-execution-env.js +12 -5
  216. package/dist/engine/harness/types.d.ts +77 -1
  217. package/dist/engine/harness/types.js +108 -0
  218. package/dist/engine/session/import-validate.js +6 -1
  219. package/dist/engine/session/parent-chain-guard.d.ts +3 -3
  220. package/dist/engine/session/parent-chain-guard.js +1 -1
  221. package/dist/engine/session/path-to-root.d.ts +18 -3
  222. package/dist/engine/session/path-to-root.js +15 -1
  223. package/dist/engine/session/repo-utils.d.ts +12 -1
  224. package/dist/engine/session/repo-utils.js +41 -0
  225. package/dist/engine/session/session.d.ts +24 -1
  226. package/dist/engine/session/session.js +46 -2
  227. package/dist/engine/session/storage-base.d.ts +20 -0
  228. package/dist/engine/session/storage-base.js +28 -9
  229. package/dist/index.d.ts +16 -12
  230. package/dist/index.js +11 -8
  231. package/dist/internal/harness-types.d.ts +1 -1
  232. package/dist/internal/harness.d.ts +4 -3
  233. package/dist/internal/harness.js +3 -2
  234. package/dist/orchestration/run-workflow-tool.d.ts +7 -1
  235. package/dist/orchestration/run-workflow-tool.js +28 -11
  236. package/dist/orchestration/workflow-governance.d.ts +1 -1
  237. package/dist/orchestration/workflow.d.ts +6 -0
  238. package/dist/orchestration/workflow.js +5 -8
  239. package/dist/stores/file/checkpoint-store.d.ts +2 -0
  240. package/dist/stores/file/checkpoint-store.js +7 -6
  241. package/dist/stores/file/fs-atomic.d.ts +0 -22
  242. package/dist/stores/file/fs-atomic.js +0 -17
  243. package/dist/stores/file/index.d.ts +2 -9
  244. package/dist/stores/file/index.js +2 -4
  245. package/dist/stores/file/session-store.d.ts +13 -7
  246. package/dist/stores/file/session-store.js +42 -18
  247. package/dist/tools/fs/bash-program-position.d.ts +3 -2
  248. package/dist/tools/fs/bash-program-position.js +10 -10
  249. package/dist/tools/fs/program-read-model.d.ts +34 -10
  250. package/dist/tools/fs/program-read-model.js +37 -7
  251. package/dist/tools/fs/program-read-model.rows.js +13 -2
  252. package/dist/tools/fs/read-deny.d.ts +13 -1
  253. package/dist/tools/fs/read-deny.js +10 -2
  254. package/dist/tools/fs/removal-targets.js +5 -5
  255. package/dist/tools/fs/safety.d.ts +2 -0
  256. package/dist/tools/fs/safety.js +1 -1
  257. package/dist/tools/fs/shell-read-argv.d.ts +11 -2
  258. package/dist/tools/fs/shell-read-argv.js +45 -29
  259. package/dist/tools/fs/shell-read-bindings.d.ts +20 -2
  260. package/dist/tools/fs/shell-read-bindings.js +153 -69
  261. package/dist/tools/fs/shell-read-brace.d.ts +18 -0
  262. package/dist/tools/fs/shell-read-brace.js +79 -0
  263. package/dist/tools/fs/shell-read-check.js +29 -11
  264. package/dist/tools/fs/shell-read-establish.js +43 -22
  265. package/dist/tools/fs/shell-read-functions.js +2 -2
  266. package/dist/tools/fs/shell-read-judge.d.ts +11 -0
  267. package/dist/tools/fs/shell-read-judge.js +3 -3
  268. package/dist/tools/fs/shell-read-object-path.d.ts +59 -0
  269. package/dist/tools/fs/shell-read-object-path.js +119 -0
  270. package/dist/tools/fs/shell-read-plan.d.ts +18 -0
  271. package/dist/tools/fs/shell-read-plan.js +217 -104
  272. package/dist/tools/fs/shell-read-start.d.ts +76 -13
  273. package/dist/tools/fs/shell-read-start.js +97 -17
  274. package/dist/tools/fs/shell-read-word.d.ts +10 -0
  275. package/dist/tools/fs/shell-read-word.js +9 -5
  276. package/dist/tools/fs/shell-read-workdir.d.ts +54 -14
  277. package/dist/tools/fs/shell-read-workdir.js +103 -19
  278. package/dist/tools/fs/shell-read-write-targets.js +13 -8
  279. package/dist/tools/worktree.d.ts +3 -2
  280. package/dist/tools/worktree.js +7 -35
  281. package/package.json +3 -2
  282. package/test/export-surface.snapshot.json +93 -43
  283. package/wire-changes/core-stores-sql@7.62.0.json +30 -0
  284. package/wire-changes/core-stores-sql@7.63.0.json +30 -0
  285. package/wire-changes/core@7.62.0.json +2181 -0
  286. package/wire-changes/core@7.63.0.json +3523 -0
  287. package/wire-changes/mods-kernel@7.62.0.json +42 -0
  288. package/wire-changes/mods-kernel@7.63.0.json +30 -0
  289. package/wire-changes/primitives@7.62.0.json +30 -0
  290. package/wire-changes/primitives@7.63.0.json +445 -0
  291. package/dist/core/consolidate-scope.d.ts +0 -93
  292. package/dist/core/consolidate-scope.js +0 -98
  293. package/dist/core/credential-vocabulary.d.ts +0 -176
  294. package/dist/core/credential-vocabulary.js +0 -190
  295. package/dist/core/redaction-passes.d.ts +0 -82
  296. package/dist/core/redaction-passes.js +0 -377
  297. package/dist/core/runner/memory-consolidation.d.ts +0 -109
  298. package/dist/core/runner/memory-consolidation.js +0 -251
@@ -568,6 +568,8 @@ export interface Prepared {
568
568
  /** The leg's `session.compact` station and its `$.session.compact` window (`session-compact.ts`): every compaction lane runs
569
569
  * its pass through it. */
570
570
  compactStation: import("../mods/session-compact.js").CompactStation;
571
+ /** The leg's latest context measurement (`lifecycle-stations.ts`): each turn boundary writes it, `$.session.usage` reads it. */
572
+ sessionMeasure: import("../mods/lifecycle-stations.js").SessionMeasureSeat;
571
573
  /**
572
574
  * This session's DURABLE box, present iff this leg mounted the session-box drain (a top-level leg
573
575
  * over a cross-process-safe mailbox with a grammatical session id). The notification lane binds it
@@ -704,12 +706,14 @@ export interface Prepared {
704
706
  * plane that owns the write gate — the read-only plane is internal to `inject`/`harvest`). */
705
707
  engine: MemoryEngine;
706
708
  handle: MemorySessionHandle;
709
+ /** The session's scope contract (`TaskSpec.memory.scopeContract`): the owner of `handle.writeScope` is read under it. */
710
+ scopeContract: "v2" | undefined;
707
711
  /** Merged injection across all planes (single-root sessions: identical to engine.inject(handle)). */
708
- inject: () => import("../memory-engine/engine.js").MemoryInjection;
712
+ inject: () => Promise<import("../memory-engine/engine.js").MemoryInjection>;
709
713
  harvest: (phase?: "checkpoint" | "terminal") => Promise<HarvestReport | undefined>;
710
714
  /** End this mount's session leg WITHOUT a harvest: the run that mounted it will never reach its
711
715
  * terminal harvest (a prepare that failed after the mount). Never throws. */
712
- release: () => void;
716
+ release: () => Promise<void>;
713
717
  /**
714
718
  * The session's capture opt-out face (the `TaskStream.optOutMemoryCapture`
715
719
  * verb's target; host-API only — no tool face reads it, §2.6). `flip` re-adjudicates the
@@ -755,15 +759,16 @@ export interface Prepared {
755
759
  execIsExternalContent: boolean;
756
760
  };
757
761
  /**
758
- * The delegation-settlement handle: the control-plane coordinates a
759
- * settlement writer needs, as PURE DATA. Consumers (the subagent background leg's write-ahead
760
- * + terminal observation, the tool wrap's sync unattestable row) can outlive this prepared
761
- * leg, so they rebuild their write handle from these fields alone — never from the live
762
- * engine/session objects above. Present only under `memoryProvenance: "carry"` (the default):
763
- * an `"off"` deployment keeps the pre-336 accepted-cost posture byte-level.
762
+ * The delegation-settlement handle: what a settlement writer needs. Consumers (the subagent
763
+ * background leg's write-ahead + terminal observation, the tool wrap's sync unattestable row)
764
+ * can outlive this prepared leg, so they write through these fields alone — never through the
765
+ * live engine/session objects above. Present only under `memoryProvenance: "carry"` (the
766
+ * default): an `"off"` deployment keeps the pre-336 accepted-cost posture byte-level.
764
767
  */
765
768
  settlement?: {
766
- /** The WRITE plane's control-plane dir (the pollution-marker/lineage sidecar home). */
769
+ /** The WRITE plane's governance store (the settlement / lineage / challenge documents). */
770
+ governance: import("../memory-engine/types.js").MemoryGovernanceDocs;
771
+ /** The WRITE plane's control-plane dir (the pollution marker and hold custody files). */
767
772
  controlDir: string;
768
773
  sessionId: string;
769
774
  provenance: "carry";
@@ -2058,6 +2063,11 @@ export interface RunInternals {
2058
2063
  * after a restart those intermediate sessions are dead ends, and a recovery face enumerating
2059
2064
  * "everything under this host session" needs the root anchor, not an alias walk. */
2060
2065
  rootSessionId?: string;
2066
+ /** The delegation tree's owner seat ({@link import("./delegation-owner.js").DelegationOwnerSeat}): a fixed point like
2067
+ * {@link rootSessionId} — the spawning run hands its own seat down by reference (the delegation and workflow lanes), so the tree
2068
+ * reads its root row's owner once. Absent ⇒ this run is nobody's child here (a top-level run, a revival, a resumed park) and its
2069
+ * prepare mints a seat over the row it acquired. TRUSTED run-scoped channel (never a {@link TaskSpec} field). */
2070
+ delegationOwner?: import("./delegation-owner.js").DelegationOwnerSeat;
2061
2071
  /**
2062
2072
  * The run tree's PLACEMENT root: the fixed point a target-bound env factory keys
2063
2073
  * its placement lookup on ({@link import("../remote-env.js").ExecutionEnvFactoryContext.placementRootSessionId}).
@@ -2301,6 +2311,12 @@ export interface RunInternals {
2301
2311
  * leg, a caller that does not delegate through core).
2302
2312
  */
2303
2313
  callerRoot?: string;
2314
+ /**
2315
+ * The checkout the SPAWNING run writes in when it has switched to a tree other than its root (an EnterWorktree tree — it can
2316
+ * lie outside {@link callerRoot}, since a managed tree hangs at the repository root): a child placed inside it is placed in the
2317
+ * caller's own tree as well. Filled ONLY by core delegation callers beside {@link callerRoot}; absent when the caller writes in its root.
2318
+ */
2319
+ callerCheckout?: string;
2304
2320
  /**
2305
2321
  * `parentCwd` is a worktree the caller minted for THIS child (the delegation tool's `isolation: "worktree"`): a child
2306
2322
  * its environment placed inside the caller's own tree instead is refused before it starts (`isolation.unavailable`).
@@ -2677,15 +2693,15 @@ export interface RunState {
2677
2693
  };
2678
2694
  }
2679
2695
  /**
2680
- * Config re-supplied to {@link Runner.resume}. A suspended task's tools / model / policy /
2681
- * hooks cannot be reconstructed from a checkpoint token (the session stores neither tool implementations
2682
- * nor the hand band), so the caller's trusted control plane re-supplies the same {@link TaskSpec} it ran
2683
- * with — minus the conversation bits: `sessionId` comes from the checkpoint and `objective` is replaced by
2684
- * an internally-generated continuation, so both are omitted.
2696
+ * Config handed to {@link Runner.resume}: the {@link TaskSpec} members the resumed leg runs with. `sessionId` comes from the checkpoint;
2697
+ * a resume sends no new human message, so it takes no objective, `userAttachments` or `runOrigin` (either present is refused before the
2698
+ * claim; a wake states its leg's word on the input it hands over). The row records no tool, hand band or server list: `tools`, `mcp`,
2699
+ * `a2a` and the `skills` specs are the deployment's CURRENT ones as this resume hands them (the leg dials these lists as the config doors
2700
+ * judge them; absent declares none) — a host replaying the parked run's lists re-dials a server its user removed. The parked call is
2701
+ * judged against what this resume mounts: its server no longer declared ⇒ `resume.tool_unavailable` (never dialed, not run, the row
2702
+ * reopened `pending`); a replacement ⇒ `resume.tool_contract_mismatch`; a moved face or declaration ⇒ `resume.target_moved`. Identity is
2703
+ * kept instead: a contradicting `principal` is refused (`resume.principal_mismatch`), an absent one inherits the row's.
2685
2704
  */
2686
- /** A resume continues the suspended leg: it sends no new human message, so it takes neither an objective nor the
2687
- * objective's attachments nor the objective's run origin (a config that carries `userAttachments` or `runOrigin` anyway is
2688
- * refused before the claim; a wake states its leg's word on the input it hands over). */
2689
2705
  export type ResumeTaskConfig = Omit<TaskSpec, "objective" | "sessionId" | "userAttachments" | "runOrigin">;
2690
2706
  /**
2691
2707
  * A composition leg's identity ({@link RunInternals.compositionLeg}, `CheckpointState.compositionLeg`): which entry handed the
@@ -2753,6 +2769,9 @@ export interface ResumeRun {
2753
2769
  * §4.3-3 reserves for the cross-process parked leg). Present only when a wake message passed a
2754
2770
  * screen that supplied context. */
2755
2771
  wakeMessageHookContext?: string;
2772
+ /** Who rewrote {@link wakeMessage}'s text at that screen (`prompt.submit`), in the order they did — its applied
2773
+ * `human_input` account names them. Absent ⇒ nobody rewrote it. */
2774
+ wakeMessageRewrittenBy?: readonly string[];
2756
2775
  /** The resumed leg's bus when the wake-message screen admitted it before the claim — prepare adopts it. */
2757
2776
  legMods?: LegMods;
2758
2777
  /** The claim's reversal, bound to THIS resume's token and scope by `resumeStream` — REQUIRED, as the store's
@@ -0,0 +1,43 @@
1
+ import type { SessionStore } from "../session.js";
2
+ /**
3
+ * The delegation tree's owner as one run binds it: `bound` with the owner (`null` = the tree root's row is anonymous), or `unbound`
4
+ * when the row this run acquired no longer stands under its id (deleted, or deleted and created again for another occupant) the first
5
+ * time the owner is asked for — a child placed on that answer would record whoever holds the id now, not this tree's owner. `reason` is
6
+ * the engine's sentence; a read that threw carries what it threw in `fault` (the host's to read, never the model's text).
7
+ */
8
+ export type DelegationOwnerReading = {
9
+ readonly bound: true;
10
+ readonly owner: string | null;
11
+ } | {
12
+ readonly bound: false;
13
+ readonly reason: string;
14
+ readonly fault?: unknown;
15
+ };
16
+ /**
17
+ * The delegation tree's owner: the owner cell of the tree root's row, as the root run read it — once. A run spawned by another run
18
+ * holds its spawner's seat (by reference, so the whole tree shares one reading); a run nobody spawned (a top-level run, a revived
19
+ * child, a parked child resumed on its own) holds a seat over the row it acquired itself ({@link ownRowDelegationOwner}). The first
20
+ * answer that binds or refuses is the answer for every later call; a read fault rejects and binds nothing.
21
+ */
22
+ export interface DelegationOwnerSeat {
23
+ read(): Promise<DelegationOwnerReading>;
24
+ }
25
+ /**
26
+ * The seat of a run nobody spawned: the owner of the row it acquired, read by id through its own store's {@link SessionStore.headOf}
27
+ * and taken only while the row's occupant is the one acquired — the head's `incarnation` equals the acquired session's metadata's
28
+ * (both absent = a row written before occupants were minted, taken as it reads). A store without a by-id read has no owner to read:
29
+ * the reading is `null`.
30
+ */
31
+ export declare function ownRowDelegationOwner(sessions: Pick<SessionStore, "headOf">, sessionId: string, acquiredIncarnation: () => Promise<string | undefined>): DelegationOwnerSeat;
32
+ /** The refusal of a delegation whose tree owner does not bind ({@link DelegationOwnerReading}): the child is not started and no row is
33
+ * created for it. */
34
+ export declare const DELEGATION_OWNER_UNBOUND = "delegation.owner_unbound";
35
+ export declare function delegationOwnerUnbound(reason: string): Error & {
36
+ code: typeof DELEGATION_OWNER_UNBOUND;
37
+ };
38
+ /** The owner a seat binds, or `null` where no seat rides (a tool driven with no run around it has no tree root to read). */
39
+ export declare function delegationOwnerOf(seat: DelegationOwnerSeat | undefined): Promise<DelegationOwnerReading>;
40
+ /** A revived child's tree owner: the owner its own row records, read by id through the store it lives in (`null` where the store has
41
+ * no by-id read, or holds no row for the id — a revival of a missing row re-opens nothing). A row whose owner cell is not a name or
42
+ * `null` does not bind, as in the seat of a run nobody spawned. */
43
+ export declare function rowOwnerReading(sessions: Pick<SessionStore, "headOf">, sessionId: string | undefined): Promise<DelegationOwnerReading>;
@@ -0,0 +1,59 @@
1
+ function ownerCellReading(sessionId, head) {
2
+ const owner = head.owner;
3
+ if (owner === null || typeof owner === "string")
4
+ return { bound: true, owner };
5
+ return { bound: false, reason: `the session ${sessionId}'s row answers an owner that is neither a name nor anonymous (${owner === undefined ? "none" : typeof owner})` };
6
+ }
7
+ export function ownRowDelegationOwner(sessions, sessionId, acquiredIncarnation) {
8
+ let settled;
9
+ let inFlight;
10
+ const bind = async () => {
11
+ const headOf = sessions.headOf;
12
+ if (typeof headOf !== "function")
13
+ return { bound: true, owner: null };
14
+ const [head, acquired] = await Promise.all([headOf.call(sessions, sessionId), acquiredIncarnation()]);
15
+ if (head === undefined)
16
+ return { bound: false, reason: `the session ${sessionId} this run acquired has no row any more` };
17
+ if (head.incarnation !== acquired)
18
+ return { bound: false, reason: `the session ${sessionId} this run acquired now holds another occupant` };
19
+ return ownerCellReading(sessionId, head);
20
+ };
21
+ return {
22
+ read() {
23
+ if (settled !== undefined)
24
+ return Promise.resolve(settled);
25
+ inFlight ??= bind().then((reading) => {
26
+ settled = reading;
27
+ return reading;
28
+ }, (err) => {
29
+ inFlight = undefined;
30
+ throw err;
31
+ });
32
+ return inFlight;
33
+ },
34
+ };
35
+ }
36
+ export const DELEGATION_OWNER_UNBOUND = "delegation.owner_unbound";
37
+ export function delegationOwnerUnbound(reason) {
38
+ return Object.assign(new Error(`the delegation tree's owner does not bind: ${reason}`), { code: DELEGATION_OWNER_UNBOUND });
39
+ }
40
+ async function settled(read) {
41
+ try {
42
+ return await read();
43
+ }
44
+ catch (err) {
45
+ return { bound: false, reason: "the row that names it could not be read", fault: err };
46
+ }
47
+ }
48
+ export function delegationOwnerOf(seat) {
49
+ return seat === undefined ? Promise.resolve({ bound: true, owner: null }) : settled(() => seat.read());
50
+ }
51
+ export function rowOwnerReading(sessions, sessionId) {
52
+ return settled(async () => {
53
+ const headOf = sessions.headOf;
54
+ if (typeof headOf !== "function" || sessionId === undefined)
55
+ return { bound: true, owner: null };
56
+ const head = await headOf.call(sessions, sessionId);
57
+ return head === undefined ? { bound: true, owner: null } : ownerCellReading(sessionId, head);
58
+ });
59
+ }
@@ -93,7 +93,7 @@ export function createSettlementLedger(call) {
93
93
  `(\`attestation\`), never a resolver's member; denied fail-closed rather than recording a settlement nobody can attribute`, contractRefusal(origin));
94
94
  }
95
95
  const edited = resolved.action === "allow" && resolved.updatedInput !== undefined;
96
- const licensed = () => edited ? licenseCovers(record.inputDigest, resolved.updatedInput) : licenseCovers(record.inputDigest, req.args) && (resolved.presentedInput === undefined || licenseCovers(record.inputDigest, resolved.presentedInput));
96
+ const licensed = () => edited ? licenseCovers(record.inputDigest, call.toolName, resolved.updatedInput) : licenseCovers(record.inputDigest, call.toolName, req.args) && (resolved.presentedInput === undefined || licenseCovers(record.inputDigest, call.toolName, resolved.presentedInput));
97
97
  const bound = record?.settlement !== undefined && record.origin === origin && sameClasses(record.classes, asked.classes) ? record.settlement : undefined;
98
98
  const refusal = bound !== undefined && SETTLEMENT_IS_REFUSAL[bound.kind] ? bound : undefined;
99
99
  if (resolved.action === "allow") {
@@ -134,7 +134,7 @@ export function createSettlementLedger(call) {
134
134
  return { decision, deniedBy: refusal ? "ask_resolution" : "policy" };
135
135
  },
136
136
  keepForBytes(runs) {
137
- if (settled !== undefined && !licenseCovers(settled.licensed, runs))
137
+ if (settled !== undefined && !licenseCovers(settled.licensed, call.toolName, runs))
138
138
  settled = undefined;
139
139
  },
140
140
  causeOf(decision) {
@@ -34,5 +34,5 @@ export function consumeInheritedAskGrant(grants, onAsk, humanReviewRef, decision
34
34
  const settlement = attestationOf(grant.settled, req)?.settlement;
35
35
  if (settlement === undefined || decision.action !== "ask")
36
36
  return reused;
37
- return attest(reused, req, { settlement, ...(decision.origin !== undefined ? { origin: decision.origin } : {}), ...(decision.classes !== undefined ? { classes: decision.classes } : {}), inputDigest: exactBoundInputHashOf(grant.presented) });
37
+ return attest(reused, req, { settlement, ...(decision.origin !== undefined ? { origin: decision.origin } : {}), ...(decision.classes !== undefined ? { classes: decision.classes } : {}), inputDigest: exactBoundInputHashOf(req.toolName, grant.presented) });
38
38
  }
@@ -0,0 +1,56 @@
1
+ /**
2
+ * A run continues a session whose log lost records: the leg's view of the session's storage tells the run what the replay that loaded the
3
+ * log dropped (`SessionStorage.getReplayLoss`), at the first branch read of the run. Two findings, one notice a leg:
4
+ *
5
+ * - the branch read broke at a parent the log does not hold, and the replay dropped records (the {@link LineageBreak}'s `replayLoss`) —
6
+ * the evidence that the missing parent may be one of them: the branch ends at the entry that names it, the entries that survive below
7
+ * the break are the conversation the run continues, and the finding is a `break`;
8
+ * - the branch is whole but the replay dropped records (the log's last records were unreadable and its head fell back to the last one
9
+ * still readable, or the damage sat off the branch): the finding is the count and the head the run continues from.
10
+ *
11
+ * The stop is the walk's own floor stop (`pathToRoot` with the break's child as the floor), so no second walk exists. A break the
12
+ * replay cannot account for (it dropped nothing: a log written with a parent it never held) is refused as it was — `corrupt_session` —
13
+ * and so is every reader outside a run (a fork, an export, the store kit), which gets no announcement and so no re-root.
14
+ */
15
+ import { type SessionStorage } from "../../internal/harness.js";
16
+ import type { NoticeSeatInput } from "./notice-seat-input.js";
17
+ /** What a branch read found of the records the log's replay dropped: the replay's count, the head the branch was read from (`null` = nothing
18
+ * of the log is readable) and the branch's length. */
19
+ export interface BranchLoss {
20
+ readonly recordsDropped: number;
21
+ readonly recordsTotal: number;
22
+ readonly leaf: string | null;
23
+ readonly entriesOnPath: number;
24
+ }
25
+ /** What one re-rooted branch read found besides: the parent the log does not hold, the entry the branch now starts at, and how many entries
26
+ * of the log do not descend from that entry (the history above the break, and its side branches). */
27
+ export interface LineageReroot extends BranchLoss {
28
+ readonly leaf: string;
29
+ readonly missingParentId: string;
30
+ readonly rootedAt: string;
31
+ readonly entriesCut: number;
32
+ }
33
+ /** What a branch read found: the branch broke (and was ended at the break), or it is whole and the replay dropped records. */
34
+ export type ReplayLossFinding = ({
35
+ readonly break: false;
36
+ } & BranchLoss) | ({
37
+ readonly break: true;
38
+ } & LineageReroot);
39
+ /** The leg's view of `storage`: every member as the storage answers it, but a branch read that breaks at a replay-proven loss ends at the
40
+ * break, and a branch read in a log whose replay dropped records is reported to `found` (`leaf` = the entry the read started from). */
41
+ export declare function viewThroughReplayLoss(storage: SessionStorage, found: (finding: ReplayLossFinding) => void): SessionStorage;
42
+ /** The leg's account of what the log's replay dropped (`session.lineage_rerooted`): one a leg for a whole branch, one a break for a broken one
43
+ * (whichever read met it first), and a broken branch's notice already carries the count, so a whole branch read after it says nothing more. */
44
+ export declare function replayLossSeat(ids: Pick<NoticeSeatInput, "onNotice" | "runId">): (finding: ReplayLossFinding, sessionId: string) => void;
45
+ /** One leg's reading of what the log's replay dropped. The acquire phase reads again after a lost write race and keeps only the attempt
46
+ * that holds, so what an attempt found is held until the phase settles on one and said then (a break before a whole branch, so the break's
47
+ * notice is the leg's only one); reads after that are said as they are made. */
48
+ export interface ReplayLossLeg {
49
+ /** `storage` as this leg reads it, naming the session its findings are about. */
50
+ view(storage: SessionStorage, sessionId: string): SessionStorage;
51
+ /** The attempt that found what is held is discarded: none of it is said. */
52
+ discard(): void;
53
+ /** The attempt that holds is known: say what it found. */
54
+ settle(): void;
55
+ }
56
+ export declare function replayLossLeg(ids: Pick<NoticeSeatInput, "onNotice" | "runId">): ReplayLossLeg;
@@ -0,0 +1,108 @@
1
+ import { LineageBreak, entryParentLinks, pathToRoot, replayLossText } from "../../internal/harness.js";
2
+ import { deliverEngineNotice } from "../engine-notice.js";
3
+ const LINEAGE_REROOTED = "session.lineage_rerooted";
4
+ export function viewThroughReplayLoss(storage, found) {
5
+ return new Proxy(storage, {
6
+ get(target, prop, receiver) {
7
+ if (prop === "getPathToRoot")
8
+ return (leafId) => branchReadingLoss(target, leafId, found);
9
+ const value = Reflect.get(target, prop, receiver);
10
+ return typeof value === "function" ? value.bind(target) : value;
11
+ },
12
+ });
13
+ }
14
+ async function branchReadingLoss(storage, leafId, found) {
15
+ let path;
16
+ try {
17
+ path = await storage.getPathToRoot(leafId);
18
+ }
19
+ catch (err) {
20
+ if (!(err instanceof LineageBreak) || err.replayLoss === undefined || err.replayLoss.dropped === 0 || leafId === null)
21
+ throw err;
22
+ const entries = await storage.getEntries();
23
+ const byId = new Map(entries.map((entry) => [entry.id, entry]));
24
+ const leaf = byId.get(leafId);
25
+ if (leaf === undefined)
26
+ throw err;
27
+ const rerooted = pathToRoot(leaf, entryParentLinks(byId), err.childId);
28
+ found({
29
+ break: true,
30
+ missingParentId: err.missingParentId,
31
+ rootedAt: err.childId,
32
+ recordsDropped: err.replayLoss.dropped,
33
+ recordsTotal: err.replayLoss.total,
34
+ leaf: leafId,
35
+ entriesOnPath: rerooted.length,
36
+ entriesCut: entries.length - descendantsOf(entries, err.childId),
37
+ });
38
+ return rerooted;
39
+ }
40
+ const loss = storage.getReplayLoss?.();
41
+ if (loss !== undefined && loss.dropped > 0)
42
+ found({ break: false, recordsDropped: loss.dropped, recordsTotal: loss.total, leaf: leafId, entriesOnPath: path.length });
43
+ return path;
44
+ }
45
+ function descendantsOf(entries, rootId) {
46
+ const children = new Map();
47
+ for (const entry of entries) {
48
+ const parent = entry.parentId || null;
49
+ if (parent === null)
50
+ continue;
51
+ const list = children.get(parent);
52
+ if (list === undefined)
53
+ children.set(parent, [entry.id]);
54
+ else
55
+ list.push(entry.id);
56
+ }
57
+ const seen = new Set([rootId]);
58
+ const todo = [rootId];
59
+ for (let id = todo.pop(); id !== undefined; id = todo.pop()) {
60
+ for (const child of children.get(id) ?? []) {
61
+ if (seen.has(child))
62
+ continue;
63
+ seen.add(child);
64
+ todo.push(child);
65
+ }
66
+ }
67
+ return seen.size;
68
+ }
69
+ const WHOLE_BRANCH = "\0whole";
70
+ function lossSentence(finding) {
71
+ const count = replayLossText({ dropped: finding.recordsDropped, total: finding.recordsTotal });
72
+ if (finding.break) {
73
+ return (`This session's log is damaged: entry ${finding.missingParentId}, the parent of ${finding.rootedAt}, is not in it (${count}). ` +
74
+ `The run continues from ${finding.rootedAt}: ${finding.entriesOnPath} entries of the conversation are kept, and ${finding.entriesCut} entries the log holds above the damage are not in its context.`);
75
+ }
76
+ if (finding.leaf === null)
77
+ return `This session's log is damaged: ${count}, and none of it is readable. The run starts from an empty conversation.`;
78
+ return (`This session's log is damaged: ${count}. The run continues from entry ${finding.leaf}, where the records the log still holds leave the conversation: ` +
79
+ `${finding.entriesOnPath} entries of it are kept, and what the unreadable records said — possibly its latest turns — is not in its context.`);
80
+ }
81
+ export function replayLossSeat(ids) {
82
+ const said = new Set();
83
+ return (finding, sessionId) => {
84
+ const key = finding.break ? `${finding.missingParentId}\n${finding.rootedAt}` : WHOLE_BRANCH;
85
+ if (said.has(key))
86
+ return;
87
+ said.add(key);
88
+ if (finding.break)
89
+ said.add(WHOLE_BRANCH);
90
+ deliverEngineNotice(ids.onNotice, { code: LINEAGE_REROOTED, message: lossSentence(finding), detail: { ...finding, sessionId, runId: ids.runId } });
91
+ };
92
+ }
93
+ export function replayLossLeg(ids) {
94
+ const say = replayLossSeat(ids);
95
+ let held = [];
96
+ return {
97
+ view: (storage, sessionId) => viewThroughReplayLoss(storage, (finding) => (held !== undefined ? void held.push({ finding, sessionId }) : say(finding, sessionId))),
98
+ discard: () => {
99
+ held = [];
100
+ },
101
+ settle: () => {
102
+ const found = [...(held ?? [])].sort((a, b) => Number(b.finding.break) - Number(a.finding.break));
103
+ held = undefined;
104
+ for (const { finding, sessionId } of found)
105
+ say(finding, sessionId);
106
+ },
107
+ };
108
+ }
@@ -15,7 +15,7 @@
15
15
  import type { Model } from "../../internal/llm.js";
16
16
  import type { Brain, ModelRoles, ModelRef, TaskSpec } from "../types.js";
17
17
  import { type DistillerChatFn } from "../memory-engine/distiller.js";
18
- import { type RunMemoryConsolidationOptions, type ConsolidationDriverEngine, type ConsolidationWriteJudge } from "../memory-engine/consolidation-driver.js";
18
+ import { type RunMemoryConsolidationOptions, type ConsolidationCompliance, type ConsolidationDriverEngine, type ConsolidationWriteJudge } from "../memory-engine/consolidation-driver.js";
19
19
  import { type MemoryConsolidationOptions } from "../memory-engine/consolidation.js";
20
20
  import type { LlmDistillerContract } from "../memory-engine/distiller.js";
21
21
  import type { EngineNotice } from "../engine-notice.js";
@@ -65,7 +65,8 @@ export declare function consolidationSeatResolvable(deps: MemoryConsolidationDri
65
65
  * failure table settles the run (zero-write on mint failure, `_incomplete` on non-convergence), this
66
66
  * bridge only relays the run's advisory notices to `onNotice` and routes a seat/engine fault to
67
67
  * `onError(phase:"memory")`. Adds no failure semantics of its own — the trigger is the only new thing.
68
- * The write judge is the LEG's; its refusal is a person's standing rule at work, so it is a refusal NOTICE, never a fault.
68
+ * The write judge is the LEG's; its refusal is a person's standing rule at work, so it is a refusal NOTICE, never a fault —
69
+ * as is the compliance posture's denial; a posture seat that faulted reaches `onError`.
69
70
  */
70
71
  export declare function autoRunConsolidationFromRecommendation(args: {
71
72
  deps: MemoryConsolidationDriverDeps;
@@ -73,6 +74,8 @@ export declare function autoRunConsolidationFromRecommendation(args: {
73
74
  scope: string;
74
75
  sessionId: string;
75
76
  writeJudge: ConsolidationWriteJudge;
77
+ /** The run's compliance veto: the deployment's posture seat, the leg's scope contract and its own denies. */
78
+ compliance: ConsolidationCompliance;
76
79
  onNotice?: (notice: EngineNotice) => void;
77
80
  onError?: (err: unknown, ctx: {
78
81
  phase: "memory";
@@ -111,7 +114,7 @@ export declare function autoRunOnRecommendationEffective(deps: MemoryConsolidati
111
114
  * a scope forever: the edge sat disarmed, nothing advanced `lastRunAt`.) A gate the engine cannot read
112
115
  * answers `false` — the verbs would refuse loudly on it anyway.
113
116
  */
114
- export declare function scopeHasUnconsumedRecommendation(engine: Pick<ConsolidationDriverEngine, "readConsolidationGate">, scope: string): boolean;
117
+ export declare function scopeHasUnconsumedRecommendation(engine: Pick<ConsolidationDriverEngine, "readConsolidationGate">, scope: string): Promise<boolean>;
115
118
  /**
116
119
  * The auto-consolidation ARMING door (bad-value loudness, three states), called from
117
120
  * the prepare config doors at construction on every leg. A garbage value refuses; a CONTRADICTION
@@ -69,10 +69,10 @@ export function consolidationSeatResolvable(deps) {
69
69
  return (roleModelIfSet("consolidate", {}, { models, roles: deps.roles }) ?? roleModelIfSet("summarize", {}, { models, roles: deps.roles })) !== undefined;
70
70
  }
71
71
  export function autoRunConsolidationFromRecommendation(args) {
72
- const { deps, engine, scope, sessionId, writeJudge, onNotice, onError } = args;
72
+ const { deps, engine, scope, sessionId, writeJudge, compliance, onNotice, onError } = args;
73
73
  return (async () => {
74
74
  try {
75
- await runMemoryConsolidationDriver(engine, scope, { ...resolveMemoryConsolidationDriver(deps), writeJudge, onNotice });
75
+ await runMemoryConsolidationDriver(engine, scope, { ...resolveMemoryConsolidationDriver(deps), writeJudge, compliance, onNotice });
76
76
  }
77
77
  catch (err) {
78
78
  if (deliverWriteRefusal(err, scope, onNotice))
@@ -94,8 +94,8 @@ export function autoRunOnRecommendationEffective(deps) {
94
94
  return false;
95
95
  return AUTO_RUN_ON_RECOMMENDATION_DEFAULT && deps.memoryConsolidation !== undefined && consolidationSeatResolvable(deps);
96
96
  }
97
- export function scopeHasUnconsumedRecommendation(engine, scope) {
98
- const row = engine.readConsolidationGate(scope);
97
+ export async function scopeHasUnconsumedRecommendation(engine, scope) {
98
+ const row = await engine.readConsolidationGate(scope);
99
99
  return row !== undefined && recommendationUnconsumed(row);
100
100
  }
101
101
  function autoRunRefusal(message) {
@@ -57,5 +57,6 @@ export interface ConsolidationWriteJudgeLeg {
57
57
  * engine's leg passes the same `input` and its `leg`, so the same rows give the same answer on both.
58
58
  */
59
59
  export declare function createConsolidationWriteJudge(input: ConsolidationWriteJudgeInput, leg?: ConsolidationWriteJudgeLeg): ConsolidationWriteJudge;
60
- /** Deliver a write-judge refusal as the verb's refusal notice; false (nothing delivered) for any other error. */
60
+ /** Deliver a standing judgment's refusal of a consolidation run — the write judge's or the compliance posture's — as the
61
+ * verb's refusal notice; false (nothing delivered) for any other error. */
61
62
  export declare function deliverWriteRefusal(err: unknown, scope: string, onNotice: ((notice: EngineNotice) => void) | undefined): boolean;
@@ -44,9 +44,10 @@ function hostLeg(input, owner) {
44
44
  facts: () => ({ face: engineWriteFace(), ...(root !== undefined ? { root, cwd: root } : {}) }),
45
45
  };
46
46
  }
47
+ const STANDING_REFUSAL_CODES = [CONSOLIDATION_WRITE_REFUSED_CODE, "config.compliance_denied"];
47
48
  export function deliverWriteRefusal(err, scope, onNotice) {
48
- if (!(err instanceof ConsolidationRefusedError) || err.code !== CONSOLIDATION_WRITE_REFUSED_CODE)
49
+ if (!(err instanceof ConsolidationRefusedError) || !STANDING_REFUSAL_CODES.includes(err.code))
49
50
  return false;
50
- deliverEngineNotice(onNotice, memoryConsolidationRefusedNotice({ code: CONSOLIDATION_WRITE_REFUSED_CODE, scope, reason: err.message, occurrenceId: err.occurrenceId }));
51
+ deliverEngineNotice(onNotice, memoryConsolidationRefusedNotice({ code: err.code, scope, reason: err.message, occurrenceId: err.occurrenceId }));
51
52
  return true;
52
53
  }
@@ -179,9 +179,10 @@ export declare function createPermissionRuleLanes(cfg: {
179
179
  /** Sink for a judgment against the rows that threw, and for the org lane's degraded-snapshot line. */
180
180
  onDisclosure: (message: string) => void;
181
181
  /** The run's one reader of the person's rules: the call's ONE read of the bytes judged, pinned, that the read station, the
182
- * org lane and the personal lane all take (the lanes consume a reader; they do not make one). */
182
+ * org lane and the personal lane all take, and a request's read the whole-tool readings take (the lanes consume a reader). */
183
183
  rows: {
184
184
  pin(toolCallId: string, judged?: unknown): Promise<PersonRowsRead>;
185
+ forRequest(): Promise<PersonRowsRead>;
185
186
  };
186
187
  /** The allow layer's auto strip over a stored ALLOW row (true ⇒ out of this call's table BEFORE the coverage is chosen). */
187
188
  stripsAllow?: (rule: PersistedRule, req: ToolCallRequest) => boolean;
@@ -1,4 +1,4 @@
1
- import { REFUSES_NO_WHOLE_TOOL, TOOL_TABLE_VIEW_READ, toolPolicyWholeToolRefusals } from "../tool-policy.js";
1
+ import { REFUSES_NO_WHOLE_TOOL, toolPolicyWholeToolRefusals } from "../tool-policy.js";
2
2
  import { persistedRuleMandateOf, ruleClearanceOf } from "../ask-origin.js";
3
3
  import {} from "../hooks.js";
4
4
  import { adjudicatePersistedDomainRules, adjudicatePersistedNameRules, adjudicatePersistedPathRules, adjudicatePersistedRules, adjudicatePersistedToolRules, callPathFaceOf, cardRuleFormOf, eligiblePersisted, escapeForDisclosure, faceRowsSpeakFor, parseRuleText, ruleWordsOf, nameRuleSubjectOf, ruleToolGrammarOf, segmentCoverageOf, suggestRuleForHost, suggestRuleForName, suggestRuleForTool, suggestRulesForCommand, wholeToolRuleReaches } from "../permission-rule-model.js";
@@ -191,7 +191,7 @@ export function createPermissionRuleLanes(cfg) {
191
191
  };
192
192
  const personal = provider.partitions.durable ? { adjudicate: personalAdjudicate } : undefined;
193
193
  let inFlight;
194
- const viewRead = () => (inFlight ??= reader.pin(TOOL_TABLE_VIEW_READ).finally(() => (inFlight = undefined)));
194
+ const viewRead = () => (inFlight ??= reader.forRequest().finally(() => (inFlight = undefined)));
195
195
  const wholeToolRefusals = toolPolicyWholeToolRefusals([
196
196
  personal !== undefined ? { wholeToolRefusals: async () => personalRefusesWholeOver((await viewRead()).rules) } : undefined,
197
197
  org !== undefined ? { wholeToolRefusals: async () => ((read) => (read.org !== undefined ? org.refusesWholeOver(read.org) : REFUSES_NO_WHOLE_TOOL))(await viewRead()) } : undefined,
@@ -11,6 +11,17 @@
11
11
  * table no longer holds that attempt. A judgment that is no call of the leg (a visibility probe's fixed id, a gate with no
12
12
  * leg) keeps nothing: its rule lanes take a read of their own, its read station the run's latest tables.
13
13
  *
14
+ * ## One read per request
15
+ *
16
+ * A model request's view of the tool table stands on one read per request ({@link PersonPathRows.forRequest}), asked when the
17
+ * request is sent: a read asked earlier may have been asked before a tool the request follows wrote a rule (a call's read
18
+ * always is; a visibility probe's may be — a changed-files scan outlives its turn's boundary). Two reads stand for a request
19
+ * instead, and ask the store nothing new: the prepare read, for the first request while no read has started after it (no
20
+ * call has been judged before it); and the newest read the store has left unanswered past its bound, asked since the
21
+ * previous request, while no read started after it has been answered — its verdict is the failure law's, the one a new read
22
+ * of the silent store would give. A store that answers slowly, or not at all, so costs a request at most one bound beyond its
23
+ * calls' own reads.
24
+ *
14
25
  * ## The run's unit, one entry per partition
15
26
  *
16
27
  * Every read's outcome lands in the run's unit, per personal partition (the durable one — its user and project rows — and
@@ -113,6 +124,10 @@ export interface PersonPathRows {
113
124
  * holds — a judgment reads the store, as the session rules' does. Any other judgment (no leg, or an id the table does not
114
125
  * hold — a visibility probe) takes a read of its own, kept by nobody. Bounded ({@link PERSON_READ_BOUND_MS}); never rejects. */
115
126
  pin(toolCallId: string, judged?: unknown): Promise<PersonRowsRead>;
127
+ /** The read one model request's view of the tool table stands on, which the request then holds: a read asked now — or,
128
+ * asking the store nothing new, the prepare read for the first request, and the newest read asked since the previous
129
+ * request that the store has left unanswered past its bound. Bounded ({@link PERSON_READ_BOUND_MS}); never rejects. */
130
+ forRequest(): Promise<PersonRowsRead>;
116
131
  /** Settles once the tables a reader takes are compiled: a pinned call's own; any other reader's (no id, or a call holding
117
132
  * no pin), the unit's newest — through every change that lands meanwhile, within {@link PATH_TABLES_READY_BOUND_MS} —
118
133
  * or at `signal` or the run's cut ({@link PersonPathRowsConfig.signal}). Never rejects: a reader whose wait was cut
@@ -184,11 +199,15 @@ export declare function readRootsOver(seats: {
184
199
  readonly store: () => string | undefined;
185
200
  readonly onHeld: (dir: string, store: string) => void;
186
201
  }): ReadRootsSeat;
202
+ /** The deny seats a shell read boundary carries for one compiled table pair, through the ONE adapter every face mounting a
203
+ * deny table uses (`readDenySeat`: zero entries is no judge), resolved once per table. */
204
+ type WriteDenySeat = {
205
+ readonly writeDenyMatch?: (p: string) => string | null;
206
+ readonly writeDenyGuardsReads?: (pattern: string) => boolean;
207
+ };
187
208
  export declare function denySeatsOf(t: PathTables): {
188
209
  readonly read: ReadDenySeat;
189
- readonly write: {
190
- readonly writeDenyMatch?: (p: string) => string | null;
191
- };
210
+ readonly write: WriteDenySeat;
192
211
  };
193
212
  /**
194
213
  * The leg's read stations as ONE gate input, each judgment on its call's pinned read of the person's rules: a station is
@@ -248,3 +267,4 @@ export declare function ruleRowsDroppedNotice(onNotice: RunnerDeps["onNotice"],
248
267
  readonly sessionId: string;
249
268
  readonly runId: string;
250
269
  }): (rows: EffectivePermissionRules["droppedRows"]) => void;
270
+ export {};