@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
@@ -1,4 +1,4 @@
1
- import { type MemoryAnnouncement } from "./types.js";
1
+ import { type MemoryAnnouncement, type MemoryGovernanceDocName, type MemoryGovernanceDocs } from "./types.js";
2
2
  import type { AssertAllKeysHandled } from "../ask-origin.js";
3
3
  import { physicalPathOfExisting } from "../physical-path.js";
4
4
  /** Cursor sidecar for the design/84 Seam B pair on the FileBackend (`{ [scope]: cursor }`). B3: control plane. */
@@ -135,6 +135,11 @@ export declare function resolveMemoryEngineRoot(explicit?: string): string;
135
135
  * collision (two distinct scopes → one dir name), so even a hash collision cannot silently merge scopes.
136
136
  */
137
137
  export declare function scopeDirName(scope: string): string;
138
+ /** Forget every cached case-fold verdict, so the next fold-equal registration probes its volume again. The verdicts are
139
+ * per process and per directory identity: a file system that hands a removed directory's identity to a new one (inode
140
+ * reuse) answers the new directory from the old one's verdict, and no probe file is written for it. Exported for the
141
+ * layout pins, which need a probe to be written on demand; not part of the package surface. */
142
+ export declare function forgetCaseFoldVerdicts(): void;
138
143
  /**
139
144
  * Whether `dir`'s volume FOLDS letter case — two names differing only in case address ONE
140
145
  * directory entry (the macOS/Windows default). Probed on the actual directory, never guessed from
@@ -151,7 +156,7 @@ export declare function dirCaseFolds(dir: string): boolean | undefined;
151
156
  * empty, never `.`/`..`, never a separator — so two labels are two distinct directory entries. */
152
157
  export declare const SCOPE_DIR_LABEL_RE: RegExp;
153
158
  /** Prefix of the case-fold probe files the layout leaves (briefly) at a memory root. One spelling
154
- * for the probe writer and for the migration's residue removal. */
159
+ * for the probe writer, for the migration's residue removal and for {@link STORE_OPEN_ARTIFACTS}. */
155
160
  export declare const CASEFOLD_PROBE_PREFIX = ".casefold-probe-";
156
161
  /** The four shapes a scope registry read can take. */
157
162
  export declare const SCOPE_REGISTRY_SHAPES: readonly ["absent", "v1", "v2", "migrating"];
@@ -262,7 +267,8 @@ export declare function layoutNeedsAdoption(root: string, controlDir: string): b
262
267
  * 4. move: per entry, lstat the destination (absent ⇒ rename; present ⇒ refuse; source gone ⇒
263
268
  * already moved); probe residue removed. No sidecar key and no index text is rewritten (the
264
269
  * ledger form keys are location-free; the index heals through its rebuild law).
265
- * 5. `index-revs.json` cleared (fail-open snapshot; the next rebuild keeps model wording once).
270
+ * 5. `index-revs.json` cleared when one exists (fail-open snapshot; the next rebuild keeps model wording
271
+ * once) — with none there is no line number to void, and a read must not leave one behind.
266
272
  * 6. commit B: the marker removed; `memory.layout_migrated` disclosed.
267
273
  */
268
274
  export declare function adoptRootScopeLayout(rootPath: string, controlDir: string, opts?: AdoptRootScopeLayoutOptions): void;
@@ -628,8 +634,53 @@ export declare function dropStagingSecondNames(seat: string, opened: {
628
634
  */
629
635
  export declare function restoreContainedBaseline(path: string, committed: string, leftOnPlane: string | undefined): "written" | "kept" | "failed";
630
636
  export declare function quarantineAndTombstone(path: string, content: string, quarantineDir: string, now: () => number): QuarantineOutcome;
631
- /** S2-B — the queued memory-change announcements (control plane; drained at session-first inject).
632
- * One file, one bounded queue PER SCOPE inside it (see {@link enqueueMemoryAnnouncement}). */
637
+ /** The name prefix of {@link atomicWriteFileSync}'s temporary file, created beside its target and renamed onto it.
638
+ * One spelling for the writer and for {@link STORE_OPEN_ARTIFACTS}. */
639
+ export declare const ATOMIC_WRITE_TMP_PREFIX = ".tmp-";
640
+ /** The infix of a stolen lock's tombstone, `<lock directory><infix><unique>`: both mkdir mutexes (the sidecar lock
641
+ * and the store's transaction lock) rename a crashed holder's lock to it before removing it. One spelling for both
642
+ * steals and for {@link STORE_OPEN_ARTIFACTS}. */
643
+ export declare const LOCK_TOMB_INFIX = ".stale-";
644
+ /**
645
+ * The named artifacts of a File store's mount — the files an OPEN or a READ of the store may leave there, by place
646
+ * and exact name (or fixed prefix); the list the contract `memory.deployment.store_set` names. Opening anchors the
647
+ * root (the anchor, written through a temporary file under its lock); a read registers the scope it reads (the
648
+ * registry and its commit journal, under the registry's lock); a refused request or a recovery takes the store's
649
+ * transaction lock; a lock found stale is stolen through a tombstone; a registration of two labels that differ only
650
+ * in letter case probes the volume with a dot-file at the memory directory's top level — on any volume, folding or not,
651
+ * and only while the process holds no verdict for that directory's identity (`dirCaseFolds`).
652
+ * - control plane, top level, a file: one of `files`, or a name starting with one of `filePrefixes`;
653
+ * - control plane, top level, a directory: one of `lockDirs`, or its tombstone `<lock>.stale-…` — the whole tree;
654
+ * - memory directory, top level, a file: a name starting with one of `memoryFilePrefixes`.
655
+ * Nothing is matched at another depth or by another pattern: a record's name may begin with these spellings (a
656
+ * capture opt-out record is named after its session id, and `.tmp-x` is a session id), so a pattern below the top
657
+ * level would hide it. The anchor, the registry and its journal are artifacts as an open or a read leaves them, whole
658
+ * ({@link namedArtifactDamaged}). The list is a promise a host's assertions read: a change to it carries its reason with it.
659
+ */
660
+ export declare const STORE_OPEN_ARTIFACTS: Readonly<{
661
+ files: readonly string[];
662
+ filePrefixes: readonly string[];
663
+ lockDirs: readonly string[];
664
+ memoryFilePrefixes: readonly string[];
665
+ }>;
666
+ /** Whether the non-directory item at `rel` — its path segments under a File store's control plane (`"control"`) or
667
+ * memory directory (`"memory"`) — is one of {@link STORE_OPEN_ARTIFACTS}. Exported for the closure pins. */
668
+ export declare function isStoreOpenArtifact(where: "control" | "memory", rel: readonly string[]): boolean;
669
+ /**
670
+ * Whether a File store's mount holds a record: a non-directory item under its control plane or its memory directory
671
+ * that is not one of {@link STORE_OPEN_ARTIFACTS} — a file only a write leaves. Opening the store, reading it and a
672
+ * request it refused leave named artifacts only, so none of them makes the mount hold a record; a write lands at
673
+ * least one file that is not named (a ledger, an evidence row, an entry, a capture record). A directory that cannot
674
+ * be read — any failure but absence; a link that leads nowhere, at it or above it, is no absence — counts as holding
675
+ * one: a store may be there, and opening it says what is; so does a named artifact that stands but cannot be read as
676
+ * what it is (the root anchor, the scope registry or its journal that is a link, not a regular file, unreadable, not
677
+ * JSON or out of shape — an open or a read leaves them whole; see {@link namedArtifactDamaged}). Read from the disk at each call. This answers "does a store live on this mount"; whether a root must stay guarded
678
+ * by its anchor is {@link controlPlaneHoldsStore}'s question.
679
+ */
680
+ export declare function storeHoldsRecord(memoryDir: string, controlDir: string): boolean;
681
+ /** S2-B — the File governance store's file for the `announcements` document (the queued memory-change
682
+ * announcements, drained at session-first inject): one file, one bounded queue PER SCOPE inside it (see
683
+ * {@link enqueueMemoryAnnouncement}). */
633
684
  export declare const ANNOUNCEMENTS_FILE = "announcements.json";
634
685
  /** S2-B — bounded queue, per scope: overflow FOLDS (oldest dropped, counted) instead of growing
635
686
  * unbounded. The bound, the fold count and the standing-condition sweep are all one scope's —
@@ -685,8 +736,17 @@ export interface DrainedMemoryAnnouncements {
685
736
  * over once and resets it; a peek reports it without resetting. */
686
737
  unscopedDiscarded: number;
687
738
  }
739
+ /** Say a refused notice filing to the host (`memory.announce_failed`): which filing (`stage`) and why. Every
740
+ * place that files a notice is fail-open and says this when the queue refuses (the engine's router, the File
741
+ * backend's store notices). No sink ⇒ nothing said; a throwing sink never propagates — it must not
742
+ * re-introduce the fault the fail-open avoids, nor recurse into the queue. */
743
+ export declare function sayAnnounceFailure(sink: MemoryPartitionIncidentSink | undefined, stage: string, cause: unknown): void;
688
744
  /**
689
- * S2-B — enqueue one announcement (journaled + locked; bounded with overflow folding).
745
+ * S2-B — enqueue one announcement into the governance store's `announcements` document (one serialized
746
+ * `updateDoc`; bounded with overflow folding). What the queue means — the per-scope bound, the fold, the
747
+ * standing-condition sweep below — is this function's `fn`; the store only keeps the document. The File
748
+ * store writes it before this call's first await (its update is synchronous underneath), so a caller that
749
+ * does not wait still finds the line on disk when the call returns, as it did when the queue was a file.
690
750
  *
691
751
  * `opts.supersedesPrefix` (#495) declares this announcement to be a STANDING CONDITION — one whose
692
752
  * sentence is re-derived at every entry point until the condition clears — and names the family it
@@ -707,24 +767,30 @@ export interface DrainedMemoryAnnouncements {
707
767
  * condition is one sentence), and the prefix must name the family precisely — anything else sharing
708
768
  * it would be dropped as a stale sibling.
709
769
  */
710
- export declare function enqueueMemoryAnnouncement(controlDir: string, ann: MemoryAnnouncement, opts?: {
770
+ export declare function enqueueMemoryAnnouncement(docs: MemoryGovernanceDocs, ann: MemoryAnnouncement, opts?: {
711
771
  supersedesPrefix?: string;
712
- }): void;
772
+ }): Promise<void>;
713
773
  /**
714
774
  * S2-B — drain the queues of `scopes` (session-first inject, 时机①): returns what those scopes had
715
775
  * queued and resets exactly them. Every other scope's queue is left as it was, for the session that
716
- * mounts it — the drain that empties a queue is a reader of that queue, never a bystander.
776
+ * mounts it — the drain that empties a queue is a reader of that queue, never a bystander. A document
777
+ * never written answers empty without an update (no lock, no write).
717
778
  */
718
- export declare function drainMemoryAnnouncements(controlDir: string, scopes: readonly string[]): DrainedMemoryAnnouncements;
719
- /** Test/observability peek of `scopes` (journal-aware, non-destructive). */
720
- export declare function peekMemoryAnnouncements(controlDir: string, scopes: readonly string[]): DrainedMemoryAnnouncements;
779
+ export declare function drainMemoryAnnouncements(docs: MemoryGovernanceDocs, scopes: readonly string[]): Promise<DrainedMemoryAnnouncements>;
780
+ /** Test/observability peek of `scopes` (the document as last committed, non-destructive). */
781
+ export declare function peekMemoryAnnouncements(docs: MemoryGovernanceDocs, scopes: readonly string[]): Promise<DrainedMemoryAnnouncements>;
721
782
  /**
722
- * Move every scope's queue from one control plane to another (a mount-key switch re-homes the control
723
- * plane, and the notices queued under the old key must not be orphaned). Each line keeps its scope; the
724
- * destination's per-scope bounds apply as each line lands. The only whole-file read there is: it hands
725
- * lines to the same scopes' queues elsewhere, never to a reader.
783
+ * Move every scope's queue from one store's `announcements` document to another's (a mount-key switch
784
+ * re-homes a control plane, and the notices queued under the old key must not be orphaned — meaningful
785
+ * between two File stores; a store keyed by scope has nothing to move). Each line keeps its scope; the
786
+ * destination's per-scope bounds apply once the lines land, and the fold counts are carried. The only
787
+ * whole-document read there is: it hands lines to the same scopes' queues elsewhere, never to a reader.
788
+ * The move is three steps (read, destination, retirement): a drain of the source between the read and the
789
+ * retirement, a second move of the same source, or a retry after a failed retirement can leave a line (and
790
+ * a fold count) in both places — over-delivery, never loss (KL-3307-c). The Runner moves a queue once per
791
+ * marker switch: its hint is read and recorded in one synchronous step (`prepare-memory.ts`).
726
792
  */
727
- export declare function transferMemoryAnnouncements(fromControlDir: string, toControlDir: string): void;
793
+ export declare function transferMemoryAnnouncements(from: MemoryGovernanceDocs, to: MemoryGovernanceDocs): Promise<void>;
728
794
  /** The fuse key for a memory file: the ledger form `(scope, rel)` (`rel` relative to the scope's
729
795
  * home, `/`-separated) — location-free, so a home move never re-keys a count. */
730
796
  export declare function scanFuseKey(scope: string, rel: string): string;
@@ -924,6 +990,16 @@ export declare function clearScanFuse(controlDir: string, keys: Iterable<string>
924
990
  export declare const LINEAGE_FILE = "lineage.json";
925
991
  /** The challenge generation-event ledger (control plane, fail-closed). */
926
992
  export declare const CHALLENGES_FILE = "challenges.json";
993
+ /** The design/336 delegation-settlement ledger (control plane, fail-closed). */
994
+ export declare const DELEGATION_SETTLEMENT_FILE = "delegation-settlement.json";
995
+ /** The design/336 session open/close account (control plane, fail-closed). */
996
+ export declare const SESSION_ACCOUNTS_FILE = "session-accounts.json";
997
+ /** A governance document's File coordinates. A name outside {@link MEMORY_GOVERNANCE_DOC_NAMES} is refused
998
+ * (`memory.governance_doc_unknown`) — never mapped to a file of its own. */
999
+ export declare function fileGovernanceDocOf(name: MemoryGovernanceDocName): {
1000
+ readonly file: string;
1001
+ readonly what: string;
1002
+ };
927
1003
  /** Per-commit lineage AUDIT history (bookkeeping, fail-open, bounded rotation) — the load-bearing
928
1004
  * queries never read it; it exists so the deduped contribution set is not the only trace. */
929
1005
  export declare const LINEAGE_AUDIT_FILE = "lineage-audit.json";
@@ -1001,14 +1077,14 @@ export interface LineagePendingTxn {
1001
1077
  }
1002
1078
  /** Stage this transaction's would-commit rows BEFORE `applyPatches` (write-ahead). Throws on any
1003
1079
  * write/lock/corruption failure — the caller refuses the whole harvest (fail-closed). */
1004
- export declare function stageLineagePending(controlDir: string, txnId: string, sessionId: string, rows: readonly LineagePendingRow[], now: () => number, incarnation?: string): void;
1080
+ export declare function stageLineagePending(docs: MemoryGovernanceDocs, txnId: string, sessionId: string, rows: readonly LineagePendingRow[], now: () => number, incarnation?: string): Promise<void>;
1005
1081
  /** Discard a staged transaction that never reached `applyPatches` (the pre-commit abort path —
1006
1082
  * step ③ of the handshake, or a refused commit). Safe by construction: nothing was committed. */
1007
- export declare function discardLineagePending(controlDir: string, txnId: string): void;
1083
+ export declare function discardLineagePending(docs: MemoryGovernanceDocs, txnId: string): Promise<void>;
1008
1084
  /** Record the commit credential — `applyPatches` returned, these ids were APPLIED (non-delete ops).
1009
1085
  * Written before promotion so a crash between the two converges by credential, never by reading
1010
1086
  * the backend's current state back (design/180 r4: later syncs/updates rewrite that scene). */
1011
- export declare function recordLineageCredential(controlDir: string, txnId: string, appliedIds: readonly string[], now: () => number): void;
1087
+ export declare function recordLineageCredential(docs: MemoryGovernanceDocs, txnId: string, appliedIds: readonly string[], now: () => number): Promise<void>;
1012
1088
  /** What one promotion moved into the committed set. */
1013
1089
  export interface LineagePromotion {
1014
1090
  entryId: string;
@@ -1023,15 +1099,15 @@ export interface LineagePromotion {
1023
1099
  * committed contribution set (deduped by (entryId, sessionId) — a repeat pair takes the incoming
1024
1100
  * lastRev and the credential's date, never grows the set); rows NOT in the applied set (conflicted/refused ops) are
1025
1101
  * dropped without ever becoming ancestry. Throws when the txn is unknown or uncredentialed. */
1026
- export declare function promoteLineagePending(controlDir: string, txnId: string): LineagePromotion[];
1102
+ export declare function promoteLineagePending(docs: MemoryGovernanceDocs, txnId: string): Promise<LineagePromotion[]>;
1027
1103
  /** The host adjudication for the UNDECIDABLE crash window (a pending txn with no credential —
1028
1104
  * design/180 r5: never auto-discarded). `"promote"` = the host verified the commit landed (all
1029
1105
  * staged rows join the committed set); `"discard"` = the host verified it did not. Idempotent on
1030
1106
  * an unknown txn. Also accepts a credentialed txn (then `"promote"` follows the credential). */
1031
- export declare function adjudicateLineagePending(controlDir: string, txnId: string, action: "promote" | "discard", now: () => number): LineagePromotion[];
1107
+ export declare function adjudicateLineagePending(docs: MemoryGovernanceDocs, txnId: string, action: "promote" | "discard", now: () => number): Promise<LineagePromotion[]>;
1032
1108
  /** Reconciliation (harvest-opening / host-triggered): promote every CREDENTIALED orphan pending
1033
1109
  * txn; report the uncredentialed ones (their latch stays until the host adjudicates). */
1034
- export declare function reconcileLineage(controlDir: string): {
1110
+ export declare function reconcileLineage(docs: MemoryGovernanceDocs): Promise<{
1035
1111
  promoted: LineagePromotion[];
1036
1112
  undecidable: Array<{
1037
1113
  txnId: string;
@@ -1039,7 +1115,7 @@ export declare function reconcileLineage(controlDir: string): {
1039
1115
  entryIds: string[];
1040
1116
  kind?: "latch-only";
1041
1117
  }>;
1042
- };
1118
+ }>;
1043
1119
  /** design/178 v2-c §1 — the import COMPLETION-RECEIPT directory (control plane): one `wx`-minted
1044
1120
  * JSON per bundle hash, written only after the import's governance legs all landed. Its presence
1045
1121
  * is {@link releaseImportLatch}'s hard precondition and the idempotent re-import's short-circuit
@@ -1057,10 +1133,10 @@ export declare function importLatchTxnId(bundleHash: string): string;
1057
1133
  * withhold standing (durable pending row), and re-staging the same bundle is an idempotent
1058
1134
  * overwrite with identical content. Never credentialed, never promoted.
1059
1135
  */
1060
- export declare function stageImportLatch(controlDir: string, bundleHash: string, rows: ReadonlyArray<{
1136
+ export declare function stageImportLatch(docs: MemoryGovernanceDocs, bundleHash: string, rows: ReadonlyArray<{
1061
1137
  entryId: string;
1062
1138
  rev: string;
1063
- }>, now: () => number): string;
1139
+ }>, now: () => number): Promise<string>;
1064
1140
  /**
1065
1141
  * design/178 v2-c §1-2⑥ — the ONE latch release channel. Hard precondition: the durable completion
1066
1142
  * receipt for the bundle is IN PLACE (`import-receipts/<bundleHash>.json`, minted after the
@@ -1069,12 +1145,12 @@ export declare function stageImportLatch(controlDir: string, bundleHash: string,
1069
1145
  * reads as "no receipt" — fail-closed). Idempotent: an already-released (absent) txn is a no-op;
1070
1146
  * a NON-latch txn under the id is refused (this is never a generic discard).
1071
1147
  */
1072
- export declare function releaseImportLatch(controlDir: string, txnId: string): void;
1148
+ export declare function releaseImportLatch(docs: MemoryGovernanceDocs, controlDir: string, txnId: string): Promise<void>;
1073
1149
  /** The DIRTY-LATCH set: every entry id named by ANY pending row (credentialed or not). While an id
1074
1150
  * is latched, its model-visible read faces (index mechanical rows / memory_search / memory_get)
1075
1151
  * refuse — "the account is not settled, the content does not go on the table". Throws on a
1076
1152
  * corrupt ledger (integrity unknown ≠ no latch). */
1077
- export declare function lineageLatchedIds(controlDir: string): Set<string>;
1153
+ export declare function lineageLatchedIds(docs: MemoryGovernanceDocs): Promise<Set<string>>;
1078
1154
  /** Every committed contribution of `sessionId` (the pollution-retroaction sweep input, and the
1079
1155
  * erasure lane's sessionId-selector resolver). Throws on a corrupt ledger. Lookups are
1080
1156
  * OWN-property (the twin law {@link lineageAccountOfEntry} states): a prototype-member sessionId
@@ -1086,12 +1162,12 @@ export declare function lineageLatchedIds(controlDir: string): Set<string>;
1086
1162
  * PROVABLY belongs to another ({@link sessionRecordBindsIncarnation}). An absent `asking`, and
1087
1163
  * every unstamped row, keeps the whole by-id set — the superset this face has always answered, and
1088
1164
  * the conservative side here (a sweep that challenges too little publishes). */
1089
- export declare function lineageContributionsOfSession(controlDir: string, sessionId: string, asking?: string): Array<{
1165
+ export declare function lineageContributionsOfSession(docs: MemoryGovernanceDocs, sessionId: string, asking?: string): Promise<Array<{
1090
1166
  entryId: string;
1091
1167
  lastRev: string;
1092
1168
  lastAt: number;
1093
1169
  marked?: true;
1094
- }>;
1170
+ }>>;
1095
1171
  /** design/178 v2-a §1.3 — the BY-ENTRY lineage account, from ONE parse of the ledger (the
1096
1172
  * by-session read's transpose; the committed set is keyed by entryId, so the index is O(1) after
1097
1173
  * the load — the load itself still parses and validates the whole account). BOTH halves come from
@@ -1102,17 +1178,17 @@ export declare function lineageContributionsOfSession(controlDir: string, sessio
1102
1178
  * {@link ControlPlaneCorruptError} on a corrupt ledger — an audit answer is never assembled over
1103
1179
  * an account whose integrity is unknown. Lookups are own-property (a prototype-member entryId
1104
1180
  * such as "constructor" must answer the empty account, never a phantom). */
1105
- export declare function lineageAccountOfEntry(controlDir: string, entryId: string): {
1181
+ export declare function lineageAccountOfEntry(docs: MemoryGovernanceDocs, entryId: string): Promise<{
1106
1182
  contributors: Array<{
1107
1183
  sessionId: string;
1108
1184
  lastRev: string;
1109
1185
  lastAt: number;
1110
1186
  }>;
1111
1187
  pendingLatched: boolean;
1112
- };
1188
+ }>;
1113
1189
  /** Drop an entry's lineage rows once the entry is DELETED (an applied tombstone) — space hygiene
1114
1190
  * only, taken at the harvest that saw the applied delete (design/180 §10). */
1115
- export declare function clearLineageForEntries(controlDir: string, entryIds: readonly string[]): void;
1191
+ export declare function clearLineageForEntries(docs: MemoryGovernanceDocs, entryIds: readonly string[]): Promise<void>;
1116
1192
  /**
1117
1193
  * design/178 v2-b §7.2-3 — capture-and-clear an erased id set's lineage in ONE strict-lock write:
1118
1194
  * - the COMMITTED contributors of each id are captured (the attestation's testimony) and the rows
@@ -1129,7 +1205,7 @@ export declare function clearLineageForEntries(controlDir: string, entryIds: rea
1129
1205
  * call loses the return set — the caller's replay re-runs it idempotently and its attestation
1130
1206
  * carries the chain's pre-captured set (honest downgrade, never a fabricated rebuild).
1131
1207
  */
1132
- export declare function captureAndClearLineageForEntries(controlDir: string, entryIds: readonly string[]): Map<string, string[]>;
1208
+ export declare function captureAndClearLineageForEntries(docs: MemoryGovernanceDocs, entryIds: readonly string[]): Promise<Map<string, string[]>>;
1133
1209
  /** One (entryId, sessionId) pair whose imported value LOST to the destination's standing row —
1134
1210
  * design/178 v2-c §5.1's disclosure seat (kept is always "destination": the in-account fact is
1135
1211
  * never overwritten by an equal-time divergent import, only reported). */
@@ -1151,18 +1227,18 @@ export interface LineageImportDivergence {
1151
1227
  * never rewritten by an外来 package; the disagreement must not be silent).
1152
1228
  * Throws on a corrupt ledger (fail-closed family).
1153
1229
  */
1154
- export declare function importLineageCommitted(controlDir: string, rows: ReadonlyArray<{
1230
+ export declare function importLineageCommitted(docs: MemoryGovernanceDocs, rows: ReadonlyArray<{
1155
1231
  entryId: string;
1156
1232
  sessionId: string;
1157
1233
  lastRev: string;
1158
1234
  lastAt: number;
1159
1235
  marked?: true;
1160
- }>): LineageImportDivergence[];
1236
+ }>): Promise<LineageImportDivergence[]>;
1161
1237
  /** Full-ledger read (tests / host observability). Throws on corruption. */
1162
- export declare function readLineageRecord(controlDir: string): {
1238
+ export declare function readLineageRecord(docs: MemoryGovernanceDocs): Promise<{
1163
1239
  committed: Record<string, Record<string, LineageContribution>>;
1164
1240
  pending: Record<string, LineagePendingTxn>;
1165
- };
1241
+ }>;
1166
1242
  /** Fail-open per-commit AUDIT history (bounded rotation) — never consulted by the load-bearing
1167
1243
  * queries; a broken audit account degrades silently, exactly like the retrieved account. */
1168
1244
  export declare function appendLineageAudit(controlDir: string, rows: ReadonlyArray<{
@@ -1230,12 +1306,12 @@ export interface ChallengeAppendResult {
1230
1306
  /** Append S-grade challenge events (idempotent per eventId, generation allocation inside the strict
1231
1307
  * lock). Every NEW eventId opens a NEW generation for its entry — a resolve of an earlier
1232
1308
  * generation never immunizes the entry against later pollution (design/180 R-8). */
1233
- export declare function appendChallengeEvents(controlDir: string, events: ReadonlyArray<{
1309
+ export declare function appendChallengeEvents(docs: MemoryGovernanceDocs, events: ReadonlyArray<{
1234
1310
  eventId: string;
1235
1311
  entryId: string;
1236
1312
  reason: string;
1237
1313
  challengedRev?: string;
1238
- }>, now: () => number): ChallengeAppendResult;
1314
+ }>, now: () => number): Promise<ChallengeAppendResult>;
1239
1315
  /** The trusted resolve: closes EXACTLY the named generation (a later challenge's generation stays
1240
1316
  * open — resolves never blanket-clear). Idempotent: resolving an already-resolved generation is a
1241
1317
  * no-op. `resolved` is false ⇔ no such open generation existed.
@@ -1245,19 +1321,19 @@ export declare function appendChallengeEvents(controlDir: string, events: Readon
1245
1321
  * falsification review, verified — hanging the disclosure off the challenge writer alone leaves a ledger
1246
1322
  * that crossed the bound on a resolve silent until the next challenge, which may never come).
1247
1323
  * `undefined` when nothing was appended. */
1248
- export declare function resolveChallengeEvent(controlDir: string, entryId: string, generation: number, reason: string, now: () => number, requestId?: string): {
1324
+ export declare function resolveChallengeEvent(docs: MemoryGovernanceDocs, entryId: string, generation: number, reason: string, now: () => number, requestId?: string): Promise<{
1249
1325
  resolved: boolean;
1250
1326
  eventCount: number | undefined;
1251
- };
1327
+ }>;
1252
1328
  /** The exclusion predicate's input: entry id → its LATEST unresolved challenge generation. An entry
1253
1329
  * appears iff at least one challenge generation has no matching resolve. Throws on corruption —
1254
1330
  * consumers refuse service (integrity unknown ≠ clean). */
1255
- export declare function challengedEntryIds(controlDir: string): Map<string, {
1331
+ export declare function challengedEntryIds(docs: MemoryGovernanceDocs): Promise<Map<string, {
1256
1332
  generation: number;
1257
1333
  at: number;
1258
- }>;
1334
+ }>>;
1259
1335
  /** Full event read (host audit / tests). Throws on corruption. */
1260
- export declare function readChallengeEvents(controlDir: string): ChallengeEvent[];
1336
+ export declare function readChallengeEvents(docs: MemoryGovernanceDocs): Promise<ChallengeEvent[]>;
1261
1337
  /** Which fail-closed control-plane ledger a rebuild targets. */
1262
1338
  export type StrictControlPlaneLedger = "lineage" | "challenges";
1263
1339
  /** What one rebuild did — the deployment's record of a taint-bearing account it chose to reset. */