@sema-agent/core 7.62.0 → 7.64.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (320) hide show
  1. package/CHANGELOG.md +936 -0
  2. package/dist/agents/cc-peer-directory.js +1 -0
  3. package/dist/agents/cc-peer-wire.d.ts +4 -0
  4. package/dist/agents/cc-peer-wire.js +1 -0
  5. package/dist/agents/cc-uds-peer-channel.js +5 -0
  6. package/dist/agents/cross-session-judge.d.ts +3 -1
  7. package/dist/agents/cross-session-judge.js +4 -1
  8. package/dist/agents/peer-directory.d.ts +8 -0
  9. package/dist/agents/peer-directory.js +4 -0
  10. package/dist/agents/peer-held-queue.d.ts +9 -3
  11. package/dist/agents/peer-held-queue.js +12 -9
  12. package/dist/agents/peer-idle.d.ts +20 -1
  13. package/dist/agents/peer-idle.js +23 -12
  14. package/dist/agents/peer-notice-route.d.ts +16 -5
  15. package/dist/agents/peer-notice-route.js +11 -9
  16. package/dist/agents/peer-notices.d.ts +25 -8
  17. package/dist/agents/peer-notices.js +6 -1
  18. package/dist/agents/peer-session-drain.d.ts +32 -6
  19. package/dist/agents/peer-session-drain.js +100 -26
  20. package/dist/agents/send-message-tool.d.ts +7 -0
  21. package/dist/agents/send-message-tool.js +18 -6
  22. package/dist/agents/subagent-transcript-placement.d.ts +23 -0
  23. package/dist/agents/subagent-transcript-placement.js +14 -0
  24. package/dist/agents/subagent.js +102 -54
  25. package/dist/brain/route-adjudicator.js +9 -4
  26. package/dist/core/allow-entry.d.ts +4 -0
  27. package/dist/core/approval-object.js +1 -1
  28. package/dist/core/arg-summary.js +1 -1
  29. package/dist/core/ask-origin.d.ts +1 -1
  30. package/dist/core/ask-origin.js +2 -2
  31. package/dist/core/ask-question.d.ts +2 -2
  32. package/dist/core/ask-unresolvable-notice.d.ts +13 -4
  33. package/dist/core/ask-unresolvable-notice.js +10 -3
  34. package/dist/core/auto-compaction.d.ts +7 -5
  35. package/dist/core/background-agent-store.d.ts +7 -0
  36. package/dist/core/background-agent-store.js +3 -0
  37. package/dist/core/canonical-json.d.ts +23 -13
  38. package/dist/core/canonical-json.js +4 -4
  39. package/dist/core/checkpoint-queries.d.ts +50 -4
  40. package/dist/core/checkpoint-queries.js +42 -17
  41. package/dist/core/checkpoint-requirements.d.ts +3 -3
  42. package/dist/core/checkpoint-requirements.js +2 -1
  43. package/dist/core/checkpoint-row-verdict.d.ts +15 -4
  44. package/dist/core/checkpoint-row-verdict.js +22 -2
  45. package/dist/core/checkpoint-store.d.ts +28 -11
  46. package/dist/core/checkpoint-store.js +45 -4
  47. package/dist/core/compliance.d.ts +6 -2
  48. package/dist/core/compliance.js +3 -3
  49. package/dist/core/context-settings.d.ts +40 -9
  50. package/dist/core/context-settings.js +32 -10
  51. package/dist/core/engine-attestation.d.ts +27 -7
  52. package/dist/core/engine-attestation.js +5 -1
  53. package/dist/core/engine-notice.d.ts +43 -5
  54. package/dist/core/extension-requester.d.ts +9 -0
  55. package/dist/core/extension-requester.js +7 -0
  56. package/dist/core/file-history-store.d.ts +28 -0
  57. package/dist/core/file-history-store.js +48 -5
  58. package/dist/core/fs-write-gate-policy.js +1 -1
  59. package/dist/core/gate-fold.js +2 -0
  60. package/dist/core/gate-lanes.js +2 -0
  61. package/dist/core/gate-outcome.d.ts +39 -2
  62. package/dist/core/gate-outcome.js +20 -1
  63. package/dist/core/git-worktree-env.d.ts +62 -3
  64. package/dist/core/git-worktree-env.js +91 -30
  65. package/dist/core/governance-codes.d.ts +9 -3
  66. package/dist/core/governance-codes.js +17 -3
  67. package/dist/core/leg-identity.d.ts +19 -1
  68. package/dist/core/leg-identity.js +12 -0
  69. package/dist/core/mailbox-store.d.ts +39 -4
  70. package/dist/core/mailbox-store.js +14 -2
  71. package/dist/core/memory-engine/consolidation-driver.d.ts +32 -17
  72. package/dist/core/memory-engine/consolidation-driver.js +99 -98
  73. package/dist/core/memory-engine/consolidation.d.ts +74 -10
  74. package/dist/core/memory-engine/consolidation.js +183 -11
  75. package/dist/core/memory-engine/control-objects.d.ts +25 -0
  76. package/dist/core/memory-engine/control-objects.js +151 -0
  77. package/dist/core/memory-engine/control-plane-adoption.d.ts +48 -0
  78. package/dist/core/memory-engine/control-plane-adoption.js +159 -0
  79. package/dist/core/memory-engine/data-plane.d.ts +8 -4
  80. package/dist/core/memory-engine/data-plane.js +11 -6
  81. package/dist/core/memory-engine/delegation-settlement.d.ts +58 -40
  82. package/dist/core/memory-engine/delegation-settlement.js +270 -85
  83. package/dist/core/memory-engine/dual-root.d.ts +12 -6
  84. package/dist/core/memory-engine/dual-root.js +11 -7
  85. package/dist/core/memory-engine/engine.d.ts +136 -58
  86. package/dist/core/memory-engine/engine.js +491 -394
  87. package/dist/core/memory-engine/entry-scan.d.ts +8 -0
  88. package/dist/core/memory-engine/entry-scan.js +3 -0
  89. package/dist/core/memory-engine/file-backend.d.ts +62 -60
  90. package/dist/core/memory-engine/file-backend.js +122 -198
  91. package/dist/core/memory-engine/index.d.ts +8 -7
  92. package/dist/core/memory-engine/index.js +7 -6
  93. package/dist/core/memory-engine/landing-admission.d.ts +5 -3
  94. package/dist/core/memory-engine/landing-admission.js +3 -3
  95. package/dist/core/memory-engine/layout.d.ts +127 -46
  96. package/dist/core/memory-engine/layout.js +264 -109
  97. package/dist/core/memory-engine/memory-backend-contract.d.ts +26 -1
  98. package/dist/core/memory-engine/memory-backend-contract.js +476 -0
  99. package/dist/core/memory-engine/memory-deployment.d.ts +42 -11
  100. package/dist/core/memory-engine/memory-deployment.js +54 -15
  101. package/dist/core/memory-engine/origin-clearance.d.ts +12 -3
  102. package/dist/core/memory-engine/origin-clearance.js +68 -9
  103. package/dist/core/memory-engine/scope-contract.d.ts +52 -11
  104. package/dist/core/memory-engine/scope-contract.js +68 -19
  105. package/dist/core/memory-engine/session-write-home.d.ts +37 -2
  106. package/dist/core/memory-engine/session-write-home.js +38 -11
  107. package/dist/core/memory-engine/sync-client.d.ts +3 -1
  108. package/dist/core/memory-engine/sync-client.js +7 -0
  109. package/dist/core/memory-engine/sync-report.d.ts +3 -2
  110. package/dist/core/memory-engine/sync-report.js +6 -2
  111. package/dist/core/memory-engine/tools.d.ts +2 -2
  112. package/dist/core/memory-engine/tools.js +10 -10
  113. package/dist/core/memory-engine/types.d.ts +155 -19
  114. package/dist/core/memory-engine/types.js +2 -0
  115. package/dist/core/memory.js +15 -6
  116. package/dist/core/mode-policy.js +3 -3
  117. package/dist/core/mods/agent-stations.d.ts +18 -0
  118. package/dist/core/mods/agent-stations.js +8 -6
  119. package/dist/core/mods/extension-call.d.ts +4 -0
  120. package/dist/core/mods/extension-call.js +8 -0
  121. package/dist/core/mods/stations.d.ts +20 -1
  122. package/dist/core/mods/stations.js +21 -2
  123. package/dist/core/mods/tool-call.js +3 -4
  124. package/dist/core/parent-spec-seat.d.ts +2 -2
  125. package/dist/core/park-selfcheck.js +2 -2
  126. package/dist/core/pause-registry.d.ts +2 -0
  127. package/dist/core/pause-registry.js +3 -0
  128. package/dist/core/peer-channel.d.ts +5 -0
  129. package/dist/core/permission-rule-consent.d.ts +26 -8
  130. package/dist/core/permission-rule-consent.js +76 -36
  131. package/dist/core/permission-rule-store.d.ts +72 -13
  132. package/dist/core/permission-rule-store.js +29 -8
  133. package/dist/core/read-only-shell.js +3 -2
  134. package/dist/core/redaction-marks.d.ts +8 -0
  135. package/dist/core/redaction-marks.js +6 -0
  136. package/dist/core/refusal-echo.d.ts +20 -0
  137. package/dist/core/refusal-echo.js +33 -0
  138. package/dist/core/remote-env.d.ts +12 -1
  139. package/dist/core/remote-env.js +3 -0
  140. package/dist/core/retention.d.ts +180 -10
  141. package/dist/core/retention.js +45 -0
  142. package/dist/core/retired-keys.d.ts +5 -0
  143. package/dist/core/retired-keys.js +3 -0
  144. package/dist/core/rule-offer-read.d.ts +0 -4
  145. package/dist/core/rule-offer-read.js +2 -18
  146. package/dist/core/runner/child-tree.d.ts +29 -3
  147. package/dist/core/runner/child-tree.js +39 -16
  148. package/dist/core/runner/classifier-ladder.d.ts +7 -1
  149. package/dist/core/runner/classifier-ladder.js +4 -2
  150. package/dist/core/runner/compact-session.js +10 -7
  151. package/dist/core/runner/compaction-call-options.d.ts +7 -7
  152. package/dist/core/runner/compaction-call-options.js +3 -2
  153. package/dist/core/runner/contracts.d.ts +39 -11
  154. package/dist/core/runner/delegation-owner.d.ts +10 -3
  155. package/dist/core/runner/delegation-owner.js +4 -1
  156. package/dist/core/runner/gate-exit.d.ts +6 -0
  157. package/dist/core/runner/gate-exit.js +13 -4
  158. package/dist/core/runner/inherited-ask-grants.js +1 -1
  159. package/dist/core/runner/memory-consolidation-driver.d.ts +10 -5
  160. package/dist/core/runner/memory-consolidation-driver.js +12 -9
  161. package/dist/core/runner/memory-consolidation-write-judge.d.ts +2 -1
  162. package/dist/core/runner/memory-consolidation-write-judge.js +3 -2
  163. package/dist/core/runner/person-path-rows.d.ts +8 -3
  164. package/dist/core/runner/person-path-rows.js +5 -1
  165. package/dist/core/runner/placement-fence.d.ts +12 -0
  166. package/dist/core/runner/placement-fence.js +20 -6
  167. package/dist/core/runner/prepare-ask-lane.js +5 -5
  168. package/dist/core/runner/prepare-caps-and-workflow.d.ts +7 -2
  169. package/dist/core/runner/prepare-caps-and-workflow.js +7 -4
  170. package/dist/core/runner/prepare-config-doors.js +4 -0
  171. package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
  172. package/dist/core/runner/prepare-delegation-surface.js +2 -2
  173. package/dist/core/runner/prepare-execution-env.js +17 -6
  174. package/dist/core/runner/prepare-gate-stations.d.ts +5 -0
  175. package/dist/core/runner/prepare-gate-stations.js +5 -5
  176. package/dist/core/runner/prepare-hands-readface.d.ts +2 -1
  177. package/dist/core/runner/prepare-hands-readface.js +5 -4
  178. package/dist/core/runner/prepare-inherited-gate.d.ts +13 -9
  179. package/dist/core/runner/prepare-inherited-gate.js +12 -6
  180. package/dist/core/runner/prepare-memory-engine-session.d.ts +2 -4
  181. package/dist/core/runner/prepare-memory-engine-session.js +4 -4
  182. package/dist/core/runner/prepare-memory.d.ts +7 -2
  183. package/dist/core/runner/prepare-memory.js +41 -39
  184. package/dist/core/runner/prepare-park-ask.js +4 -3
  185. package/dist/core/runner/prepare-policy-chain.js +7 -7
  186. package/dist/core/runner/prepare-prompt-inputs.js +1 -1
  187. package/dist/core/runner/prepare-task.js +26 -18
  188. package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -1
  189. package/dist/core/runner/prepare-wiring-manifest.js +3 -2
  190. package/dist/core/runner/prepare-workspace-restore.js +3 -6
  191. package/dist/core/runner/resume-admission.d.ts +2 -2
  192. package/dist/core/runner/resume-admission.js +2 -23
  193. package/dist/core/runner/role-resolution-table.d.ts +98 -0
  194. package/dist/core/runner/role-resolution-table.js +62 -0
  195. package/dist/core/runner/run-compaction-machinery.js +2 -2
  196. package/dist/core/runner/run-identity-wiring.js +12 -9
  197. package/dist/core/runner/run-leg.js +9 -5
  198. package/dist/core/runner/run-notification-lane.js +22 -22
  199. package/dist/core/runner/run-recovery-lanes.js +3 -3
  200. package/dist/core/runner/run-settle-and-teardown.js +3 -2
  201. package/dist/core/runner/run-terminal-adoption.js +1 -1
  202. package/dist/core/runner/run-turn-boundary.js +14 -15
  203. package/dist/core/runner/runtask.js +1 -1
  204. package/dist/core/runner/terminal-account.js +1 -1
  205. package/dist/core/runner/tool-occurrence.d.ts +4 -2
  206. package/dist/core/runner/tool-occurrence.js +2 -2
  207. package/dist/core/runner-deps.d.ts +7 -3
  208. package/dist/core/secret-env.d.ts +1 -1
  209. package/dist/core/secret-env.js +4 -4
  210. package/dist/core/session-checkout.d.ts +168 -0
  211. package/dist/core/session-checkout.js +579 -0
  212. package/dist/core/session-store.d.ts +12 -4
  213. package/dist/core/session-store.js +23 -3
  214. package/dist/core/session.d.ts +16 -2
  215. package/dist/core/session.js +3 -0
  216. package/dist/core/shell-read-silence.js +8 -0
  217. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +0 -12
  218. package/dist/core/store-contracts/checkpoint-store-contract.js +6 -7
  219. package/dist/core/store-contracts/peer-directory-contract.js +8 -1
  220. package/dist/core/store-contracts/session-store-contract.js +39 -0
  221. package/dist/core/task-event.d.ts +30 -5
  222. package/dist/core/task-notification.d.ts +119 -32
  223. package/dist/core/task-notification.js +186 -100
  224. package/dist/core/task-registry-agent.d.ts +25 -2
  225. package/dist/core/task-registry-agent.js +56 -22
  226. package/dist/core/task-registry-shared.d.ts +33 -11
  227. package/dist/core/task-registry.d.ts +33 -9
  228. package/dist/core/task-registry.js +36 -18
  229. package/dist/core/task-spec-members.js +1 -1
  230. package/dist/core/task-spec.d.ts +27 -2
  231. package/dist/core/tool-errors.d.ts +14 -6
  232. package/dist/core/tool-errors.js +1 -1
  233. package/dist/core/tool-policy.d.ts +32 -13
  234. package/dist/core/tool-policy.js +27 -17
  235. package/dist/core/tool-result-store.d.ts +20 -0
  236. package/dist/core/tool-spec.d.ts +42 -19
  237. package/dist/core/trace.d.ts +3 -2
  238. package/dist/core/types.d.ts +1 -1
  239. package/dist/core/untrusted-egress.d.ts +15 -4
  240. package/dist/core/untrusted-egress.js +23 -22
  241. package/dist/core/workflow-journal-store.d.ts +11 -0
  242. package/dist/core/workflow-journal-store.js +7 -0
  243. package/dist/core/workflow-run-store.d.ts +9 -0
  244. package/dist/core/workflow-run-store.js +6 -0
  245. package/dist/core/workspace-snapshot.d.ts +3 -1
  246. package/dist/core/workspace-snapshot.js +1 -0
  247. package/dist/engine/compaction/compaction.d.ts +2 -1
  248. package/dist/engine/harness/types.d.ts +67 -1
  249. package/dist/engine/harness/types.js +108 -0
  250. package/dist/engine/session/import-validate.js +6 -1
  251. package/dist/engine/session/session.d.ts +30 -1
  252. package/dist/engine/session/session.js +48 -1
  253. package/dist/index.d.ts +12 -7
  254. package/dist/index.js +12 -7
  255. package/dist/internal/harness-types.d.ts +1 -1
  256. package/dist/orchestration/run-workflow-tool.d.ts +8 -1
  257. package/dist/orchestration/run-workflow-tool.js +8 -0
  258. package/dist/orchestration/workflow-types.d.ts +2 -1
  259. package/dist/orchestration/workflow.d.ts +6 -0
  260. package/dist/orchestration/workflow.js +5 -2
  261. package/dist/stores/file/checkpoint-store.d.ts +6 -0
  262. package/dist/stores/file/checkpoint-store.js +4 -1
  263. package/dist/stores/file/file-history-store.d.ts +13 -0
  264. package/dist/stores/file/file-history-store.js +75 -13
  265. package/dist/stores/file/index.d.ts +11 -1
  266. package/dist/stores/file/index.js +7 -11
  267. package/dist/stores/file/permission-rule-store.d.ts +23 -0
  268. package/dist/stores/file/permission-rule-store.js +75 -7
  269. package/dist/stores/file/session-store.js +2 -1
  270. package/dist/stores/file/tool-result-store.d.ts +14 -0
  271. package/dist/stores/file/tool-result-store.js +39 -2
  272. package/dist/stores/file/workflow-journal-store.d.ts +4 -0
  273. package/dist/stores/file/workflow-journal-store.js +17 -0
  274. package/dist/stores/file/workflow-run-store.d.ts +3 -0
  275. package/dist/stores/file/workflow-run-store.js +15 -0
  276. package/dist/tools/fs/bash-program-position.js +3 -3
  277. package/dist/tools/fs/program-read-model.d.ts +34 -10
  278. package/dist/tools/fs/program-read-model.js +37 -7
  279. package/dist/tools/fs/program-read-model.rows.js +13 -2
  280. package/dist/tools/fs/read-deny.d.ts +28 -3
  281. package/dist/tools/fs/read-deny.js +18 -2
  282. package/dist/tools/fs/removal-targets.js +3 -3
  283. package/dist/tools/fs/safety.d.ts +2 -0
  284. package/dist/tools/fs/safety.js +1 -1
  285. package/dist/tools/fs/shell-read-argv.d.ts +8 -1
  286. package/dist/tools/fs/shell-read-argv.js +34 -29
  287. package/dist/tools/fs/shell-read-bindings.d.ts +2 -0
  288. package/dist/tools/fs/shell-read-bindings.js +5 -1
  289. package/dist/tools/fs/shell-read-brace.d.ts +18 -0
  290. package/dist/tools/fs/shell-read-brace.js +79 -0
  291. package/dist/tools/fs/shell-read-check.d.ts +8 -2
  292. package/dist/tools/fs/shell-read-check.js +16 -14
  293. package/dist/tools/fs/shell-read-establish.js +23 -16
  294. package/dist/tools/fs/shell-read-judge.d.ts +11 -0
  295. package/dist/tools/fs/shell-read-judge.js +3 -3
  296. package/dist/tools/fs/shell-read-plan.d.ts +10 -0
  297. package/dist/tools/fs/shell-read-plan.js +189 -93
  298. package/dist/tools/fs/shell-read-start.d.ts +19 -9
  299. package/dist/tools/fs/shell-read-start.js +20 -12
  300. package/dist/tools/fs/shell-read-word.d.ts +10 -0
  301. package/dist/tools/fs/shell-read-word.js +9 -5
  302. package/dist/tools/fs/shell-read-workdir.d.ts +26 -7
  303. package/dist/tools/fs/shell-read-workdir.js +73 -12
  304. package/dist/tools/fs/shell-read-write-targets.js +13 -8
  305. package/dist/tools/worktree.d.ts +3 -2
  306. package/dist/tools/worktree.js +7 -35
  307. package/package.json +3 -2
  308. package/test/export-surface.snapshot.json +135 -11
  309. package/wire-changes/core-stores-sql@7.63.0.json +30 -0
  310. package/wire-changes/core-stores-sql@7.64.0.json +30 -0
  311. package/wire-changes/core@7.63.0.json +3523 -0
  312. package/wire-changes/core@7.64.0.json +2653 -0
  313. package/wire-changes/mods-kernel@7.63.0.json +30 -0
  314. package/wire-changes/mods-kernel@7.64.0.json +30 -0
  315. package/wire-changes/primitives@7.63.0.json +445 -0
  316. package/wire-changes/primitives@7.64.0.json +30 -0
  317. package/dist/core/credential-vocabulary.d.ts +0 -176
  318. package/dist/core/credential-vocabulary.js +0 -190
  319. package/dist/core/redaction-passes.d.ts +0 -82
  320. package/dist/core/redaction-passes.js +0 -377
@@ -1,4 +1,4 @@
1
- import { isCentralAuthorityScope, parseScopeKey } from "./scope-contract.js";
1
+ import { isPersonalPlaneScope, parseScopeKey } from "./scope-contract.js";
2
2
  import { CONTROL_PLANE_DIR, resolveMemoryEngineRoot } from "./layout.js";
3
3
  import { ERASURE_CARRIER_CLASSES, FileMemoryEngineBackend } from "./file-backend.js";
4
4
  import { thrownText } from "../thrown-value.js";
@@ -14,9 +14,9 @@ export function classifyScopePlanes(scopes, writeScope) {
14
14
  const project = [];
15
15
  const personal = [];
16
16
  for (const s of scopes) {
17
- (isCentralAuthorityScope(parseScopeKey(s)) ? personal : project).push(s);
17
+ (isPersonalPlaneScope(parseScopeKey(s)) ? personal : project).push(s);
18
18
  }
19
- const writePlane = writeScope === null ? null : isCentralAuthorityScope(parseScopeKey(writeScope)) ? "personal" : "project";
19
+ const writePlane = writeScope === null ? null : isPersonalPlaneScope(parseScopeKey(writeScope)) ? "personal" : "project";
20
20
  return { project, personal, writePlane };
21
21
  }
22
22
  export function scopePlanesOf(scopes, writeScope, scopeContract) {
@@ -43,12 +43,16 @@ export function judgeMemoryStoreSeat(face, input) {
43
43
  if (!Object.prototype.hasOwnProperty.call(input, key))
44
44
  refuseMemoryStoreInput(face, `${key} is a required key (write undefined to state its absence)`, undefined);
45
45
  }
46
- if (scopeContract !== undefined && scopeContract !== "v2")
47
- refuseMemoryStoreInput(face, `scopeContract must be "v2" or undefined`, scopeContract);
46
+ judgeScopeContract(face, scopeContract);
48
47
  if (memoryEngineDir !== undefined && (typeof memoryEngineDir !== "string" || memoryEngineDir === ""))
49
48
  refuseMemoryStoreInput(face, "memoryEngineDir must be a non-empty string or undefined", memoryEngineDir);
50
49
  }
50
+ function judgeScopeContract(face, scopeContract) {
51
+ if (scopeContract !== undefined && scopeContract !== "v2")
52
+ refuseMemoryStoreInput(face, `scopeContract must be "v2" or undefined`, scopeContract);
53
+ }
51
54
  export function memoryScopePlaneOf(face, scope, scopeContract) {
55
+ judgeScopeContract(face, scopeContract);
52
56
  let spec;
53
57
  try {
54
58
  spec = normalizeMemorySpec({ scopes: [scope], writeScope: scope, ...(scopeContract === "v2" ? { scopeContract } : {}) });
@@ -85,14 +89,14 @@ export function mergeInjections(project, personal) {
85
89
  const indexParts = [project.index, personal.index].filter((s) => Boolean(s && s.trim()));
86
90
  const announcements = [...(project.announcements ?? []), ...(personal.announcements ?? [])];
87
91
  const announceParts = [project.announceBlock, personal.announceBlock].filter((s) => Boolean(s && s.trim()));
88
- const blockParts = [instruction || readOnlyNotice, ...indexParts, ...announceParts];
92
+ const blockParts = [instruction || readOnlyNotice, ...indexParts];
89
93
  const indexSeed = project.indexSeed ?? personal.indexSeed;
90
94
  return {
91
95
  instruction,
92
96
  ...(readOnlyNotice !== undefined ? { readOnlyNotice } : {}),
93
97
  ...(indexParts.length > 0 ? { index: indexParts.join("\n\n") } : {}),
94
98
  ...(announcements.length > 0 ? { announcements } : {}),
95
- ...(announceParts.length > 0 ? { announceBlock: announceParts.join("\n\n") } : {}),
99
+ ...(announceParts.length > 0 ? { announceBlock: announceParts.join("\n") } : {}),
96
100
  ...(indexSeed !== undefined ? { indexSeed } : {}),
97
101
  block: blockParts.filter((s) => s && s.trim()).join("\n\n"),
98
102
  };
@@ -1,12 +1,14 @@
1
1
  import type { EngineNotice } from "../types.js";
2
2
  import { type ConsolidationGateRead, type ConsolidationGateRow, type ConsolidationPlanFile, type ConsolidationProposal, type ConsolidationRunStopReason, type ConsolidationWriteGate, type MemoryConsolidationOptions } from "./consolidation.js";
3
3
  import { foreignDanglingSessionAccounts, type SessionAccountWrite, type EffectiveSettlement, type HoldRow } from "./delegation-settlement.js";
4
+ import { type SessionWriteHomeReading } from "./session-write-home.js";
4
5
  import { type OriginClearanceRow } from "./origin-clearance.js";
5
6
  import { type CommittedBinding, type EraseMemoryEntriesInput, type MemoryErasureAttestation, type TransferEvidence } from "./file-backend.js";
6
7
  import { type MemoryExportBundle, type MemoryImportReport } from "./export-bundle.js";
7
8
  import { type ChallengeAssignment, type ChallengeEvent, type ControlPlaneRebuildReceipt, type StrictControlPlaneLedger, type ChallengedHistoryRow, type LineagePendingTxn, type LineagePromotion, type MemoryPartitionIncidentSink, type RetrievedAccountRow, type SessionPollutionMarkOutcome, type SessionPollutionRecord, type SessionCaptureOptOutMarkOutcome, type SessionCaptureOptOutRecord, type SessionCaptureRecordStore } from "./layout.js";
8
9
  import { type SessionIncarnationResolver } from "./session-incarnation.js";
9
- import type { HarvestReport, MemoryAnnouncement, MemoryBackend, MemoryEntry, MemoryEntryHeader, MemoryEntryOrigin, MemoryScopeEnumeration, MemorySessionHandle, ScanFinding, SessionCaptureResidueSweep } from "./types.js";
10
+ import type { ConsolidationDriverRunRow } from "./consolidation-driver.js";
11
+ import type { HarvestReport, MemoryAnnouncement, MemoryBackend, MemoryEntry, MemoryEntryHeader, MemoryEntryOrigin, MemoryGovernanceStore, MemoryScopeEnumeration, MemorySessionHandle, PatchReport, ScanFinding, SessionCaptureResidueSweep } from "./types.js";
10
12
  /**
11
13
  * The RECALL-FRAMING sentence shared by every arm of the `# Memory` prompt section — the one
12
14
  * sentence that tells the model what a recalled memory IS (background context, not an instruction)
@@ -123,17 +125,19 @@ export declare function entryFileHeadCarriesOrigin(absPath: string, maxBytes?: n
123
125
  export declare const MEMORY_PREFERENCE_DISCIPLINE = "When the user confirms a stored preference or fact still holds, refresh that entry's `last-confirmed: <YYYY-MM-DD>` frontmatter line (add it when absent). When you save a preference, add an `applies-when: <context>` frontmatter line naming when it applies. Both are plain frontmatter lines \u2014 write them yourself; nothing fills them in for you.";
124
126
  /**
125
127
  * Corrections for announcement segments that carry store-mutation guidance ("record a fresh entry …
126
- * tombstone the old one", minted in an earlier writable session) a session cannot act on. The queue
128
+ * delete the old entry", minted in an earlier writable session) a session cannot act on. The queue
127
129
  * items are opaque strings (rewriting them would be text surgery over minted-at-enqueue wording),
128
130
  * so the correction is a trailing coda, not a rewrite — in two scopes, because the two mounting
129
131
  * seats speak about different things (an unqualified "the memory store is not writable" beside
130
132
  * another, WRITABLE plane's instruction would negate that plane's guidance):
131
- * - PLANE scope, attached by `inject()` right after a read-only layering's own announcement block:
133
+ * - PLANE scope, attached by `inject()` right after a read-only layering's own notices reminder:
132
134
  * explicitly local to the immediately preceding notices, so a mixed dual-root merge keeps the
133
135
  * writable plane's instruction and announcements fully actionable.
134
- * - SESSION scope, attached by the runner at the block tail when the whole session cannot persist:
135
- * there is no writable instruction left standing there (it is replaced or absent), so the global
136
- * wording is accurate. Name-free by construction (#181 class).
136
+ * - SESSION scope, attached by the runner after all the notices when the whole session cannot
137
+ * persist: there is no writable instruction left standing (it is replaced or absent), so the
138
+ * global wording is accurate. Name-free by construction (#181 class).
139
+ * A coda is its own reminder, minted right after the notices it qualifies (#1123: the notices ride a
140
+ * user message, where an engine sentence outside a reminder would read as the user's words).
137
141
  */
138
142
  export declare const MEMORY_ANNOUNCEMENT_READONLY_PLANE_CODA = "The notices immediately above concern a READ-ONLY memory store: any guidance in them to record, update, or tombstone an entry cannot be applied to that store this session \u2014 surface it to the user instead of claiming it done.";
139
143
  export declare const MEMORY_ANNOUNCEMENT_READONLY_CODA = "The memory store itself is not writable this session, so any guidance above to record, update, or tombstone a memory entry cannot be applied here \u2014 surface it to the user instead of claiming it done.";
@@ -194,8 +198,8 @@ export declare const MEMORY_CAPTURE_OPTOUT_NOTICE = "# Memory\n\nMemory capture
194
198
  * not {@link MEMORY_CAPTURE_OPTOUT_NOTICE} ("at the user's request" would put words in the user's mouth over an
195
199
  * outage), not {@link MEMORY_READONLY_NOTICE} (a session-wide categorical claim, false once the store answers or a
196
200
  * later run mounts: the honest tense is "right now"). The closing correction folds the announcement-coda duty and is
197
- * DIRECTION-FREE on purpose: this notice is composed FIRST and drained announcements ride last, so a locator pointing
198
- * "above" would name a region no announcement can occupy. The second paragraph splices {@link MEMORY_RECALL_FRAMING}.
201
+ * LOCATION-FREE on purpose: the drained notices ride the leg's first request, not this section (#1123), so neither a
202
+ * locator pointing "above" nor one naming "this memory section" would reach them. The second paragraph splices {@link MEMORY_RECALL_FRAMING}.
199
203
  */
200
204
  export interface MemoryUnavailableFacts {
201
205
  what: "capture-record-unreadable" | "mount-failed";
@@ -223,12 +227,13 @@ export declare const DEFAULT_HARVEST_FILE_BUDGET = 2000;
223
227
  * on background-child lifetimes; the cost of the window is that a held instruction entry is
224
228
  * delayed at most this long, never lost. */
225
229
  export declare const DEFAULT_HOLD_SETTLE_TIMEOUT_MS: number;
226
- /** design/138 §2.4 删除防线 — the mass-deletion fuse threshold (fraction of materialized writable
227
- * entries missing at harvest above which the whole harvest is judged an incident and refused). The
228
- * fuse guards the BACKEND from having a wipe written back; renames (same id re-appearing elsewhere)
229
- * never count toward it (验收 M1). Below the fuse, missing committed files are restored from the
230
- * committed copy (B1); above it NOTHING is restored or written — the incident waits for a human
231
- * (for an in-repo git-tracked scope git history is the natural recycle bin). */
230
+ /** design/138 §2.4 删除防线 — the mass-deletion fuse ratio: the ratio leg of the deletion fuse
231
+ * ({@link deletionFuseCeiling} — max(floor, ⌊ratio × N⌋) over the materialized writable files). A
232
+ * session's removal of a file it was served on its write face is its delete of that entry (the
233
+ * removal IS the write); more removals than the ceiling in one harvest is judged an incident and
234
+ * the whole harvest refused — NOTHING is deleted or restored, the incident waits for a human (for
235
+ * an in-repo git-tracked scope git history is the natural recycle bin). Renames (same id
236
+ * re-appearing elsewhere) never count toward it (验收 M1). */
232
237
  export declare const MASS_DELETION_FUSE_RATIO = 0.5;
233
238
  export interface MemoryEngineOptions {
234
239
  backend: MemoryBackend;
@@ -329,7 +334,7 @@ export interface MemoryEngineOptions {
329
334
  * byte-identical to a pre-339 deployment (G1). PRESENT = enabled; every knob screens at
330
335
  * construction (#123 bad-value loudness — see {@link import("./consolidation.js").screenConsolidationOptions}),
331
336
  * `provenance: "off"` beside it refuses at construction (D-12a: the fold law must be able to
332
- * mint), and `multiNode: true` without an injected lease refuses (D-13a). Note the READ-side
337
+ * mint), and `multiNode: true` without an injected lease (D-13a) or over a replica-local backend refuses. Note the READ-side
333
338
  * active-set treatment (index rows / search filter / get disclosure) is NOT behind this switch —
334
339
  * supersession edges are store-level data facts and take effect wherever they exist (D-4a).
335
340
  */
@@ -357,15 +362,20 @@ export interface MemoryInjection {
357
362
  * counterfeit it, tool-name-free because the engine cannot vouch for the roster). Undefined
358
363
  * when empty. */
359
364
  index?: string;
360
- /** design/138 S2-B (时机①) — the announcements DRAINED by this inject (queued by the previous
361
- * session's harvest / the backend's read-side external-change detection). Already rendered into
362
- * {@link block}; exposed raw for observability/tests. Absent when the queue was empty. */
365
+ /** design/138 S2-B (时机①) — the announcements DRAINED by this inject (queued by a harvest of
366
+ * this or an earlier session / the backend's read-side external-change detection). Rendered into
367
+ * {@link announceBlock}; exposed raw for observability/tests. Absent when the queue was empty. */
363
368
  announcements?: MemoryAnnouncement[];
364
- /** The RENDERED announcements segment of {@link block} (design/142 S2b): dual-root
365
- * merging composes from STRUCTURED fields — never by re-parsing `block` (whose instruction/index
366
- * segments contain blank lines a split would shred). Absent when the queue was empty. */
369
+ /** The drained announcements, RENDERED: one engine reminder of notices, followed — for a read-only
370
+ * layering — by the plane coda in a reminder of its own. An EVENT, not state (#1123): it is NOT part
371
+ * of {@link block}. The Runner delivers it once, on the leg's first request (ahead of the user's
372
+ * message), so the cached prompt prefix never carries it; a host driving the engine directly places
373
+ * it the same way. Dual-root merging composes from STRUCTURED fields (design/142 S2b). Absent when
374
+ * the queue was empty. */
367
375
  announceBlock?: string;
368
- /** `instruction + index + announcements` — what prepare-task mounts in the stable-prefix memory slot. */
376
+ /** `instruction + index` — the memory store's STATE, what the Runner mounts in the stable-prefix
377
+ * memory slot. Byte-identical across runs until the state itself changes; the drained notices are
378
+ * {@link announceBlock} (#1123). */
369
379
  block: string;
370
380
  /**
371
381
  * RB-276 — the materialized MEMORY.md whose FULL disk text rides in this injection, for prepare-task
@@ -597,6 +607,35 @@ export declare function pollutionContainmentCounts(report: HarvestReport): {
597
607
  moved: number;
598
608
  escalated: number;
599
609
  };
610
+ /**
611
+ * One harvest conflict, said by what the backend reported rather than by one fixed word: a per-id CAS
612
+ * miss — the row carries BOTH the patch's base rev and the store's current rev, as every backend's
613
+ * CAS refusal does — is another writer's newer commit; any other conflict is the store's own refusal
614
+ * of the patch, named as a refusal and never as concurrency. The store's reason text is not quoted:
615
+ * it can name another scope's coordinates, and both faces reading this sentence (the next session's
616
+ * announcement, the user-tier `memory.harvest_conflict` notice) carry write-scope facts only — the
617
+ * harvest report holds the reason for the host. Only the CAS reading knows the entry is still stored
618
+ * (the store answered its current rev), so only it says a conflicted deletion left the entry in place.
619
+ * The outcome is said first and short: an announcement line is capped at 160 characters.
620
+ */
621
+ export declare function harvestConflictSentence(c: PatchReport["conflicts"][number]): string;
622
+ /**
623
+ * `memory.harvest_refused` (audience `user`) — the boundary harvest was refused wholesale (an incident:
624
+ * the deletion fuse, a vanished write root, a control plane that could not be read or written), so
625
+ * what this session did to memory did not take effect. The person is the one who was told "remembered"
626
+ * or "forgotten" during the session; this is where they learn it did not hold. One notice per refused
627
+ * harvest; `detail: { kind, committed, reportId?, sessionId? }` — `committed` is the report's applied
628
+ * patch count (0 for a refused single-plane harvest; a dual-root merge can carry the other plane's).
629
+ */
630
+ export declare function memoryHarvestRefusedNotice(report: HarvestReport, sessionId?: string): EngineNotice | undefined;
631
+ /**
632
+ * `memory.harvest_conflict` (audience `user`) — the harvest committed, but the store refused some of
633
+ * this session's changes ({@link harvestConflictSentence} per change: a newer commit by another
634
+ * writer, or the store's own refusal); those changes did not take effect. One notice per harvest
635
+ * with at least one conflict; `detail:
636
+ * { count, conflicts: [{ op, id, concurrent }] (first 20), reportId?, sessionId? }`.
637
+ */
638
+ export declare function memoryHarvestConflictNotice(report: HarvestReport, sessionId?: string): EngineNotice | undefined;
600
639
  export declare function memoryHarvestQuarantinedNotice(input: {
601
640
  count: number;
602
641
  moved: number;
@@ -833,6 +872,7 @@ export declare class MemoryEngine {
833
872
  private readonly backend;
834
873
  private readonly memoryDir;
835
874
  private readonly controlDir;
875
+ private readonly governanceStore;
836
876
  private readonly now;
837
877
  private readonly perScopeBudgetBytes;
838
878
  private readonly perFileBytes;
@@ -872,7 +912,7 @@ export declare class MemoryEngine {
872
912
  * re-opened the row, and the later leg is still live). A record that cannot be written leaves the
873
913
  * row reading live (restores of its layer withheld) and is disclosed, never silent.
874
914
  */
875
- endSessionLeg(handle: MemorySessionHandle, sessionId: string): SessionAccountWrite | undefined;
915
+ endSessionLeg(handle: MemorySessionHandle, sessionId: string): Promise<SessionAccountWrite | undefined>;
876
916
  private endLeg;
877
917
  /** design/336 §3.6 (slice 2) — the session-account incident channel (`memory.session_account_failed`):
878
918
  * a degraded residue classification is DISCLOSED, never quiet (the behavioral fail-closed half —
@@ -948,6 +988,13 @@ export declare class MemoryEngine {
948
988
  * undefined when the account has no row, `"undecidable"` when the account cannot be read whole
949
989
  * (a pending journal, a fault, no audit face) — never a guess from a copy that carries no seat. */
950
990
  private committedRowOf;
991
+ /** Where the store holds the entry a write-face removal names: `absent` (no longer held), `held`
992
+ * with its committed scope (and, from a copy-out backend, the committed frontmatter that read
993
+ * returned), or `unknown` (the read failed, or the account holds the row without a seat). A
994
+ * directory-pinned store answers from its audit face ({@link committedRowOf}, side-effect-free —
995
+ * the plane there is the session's working copy, never the committed seat); a copy-out backend
996
+ * answers from `getByIds`. */
997
+ private committedPlacementOf;
951
998
  /** A caught memory-write failure as a report / incident line: its text, plus the remedy when the
952
999
  * file system refused it on permissions ({@link withPermissionRemedy} — the one spelling every
953
1000
  * write seat surfaces, so no seat renders a permission refusal as a bare errno). */
@@ -968,7 +1015,11 @@ export declare class MemoryEngine {
968
1015
  * The one router of a model-face memory notice: a line is filed under the scope it reports on, so
969
1016
  * only a session mounting that scope ever reads it (`MemoryAnnouncement.scope`). A line that names
970
1017
  * no single scope — `scope` absent — reaches no model face: it goes to the host's incident sink
971
- * (`memory.announcement_withheld`), and nowhere else. Fail-open like every enqueue site.
1018
+ * (`memory.announcement_withheld`), and nowhere else. Fail-open like every enqueue site: the answer
1019
+ * never rejects — a queue that refuses is said ({@link discloseAnnounceFailure}). The line goes to
1020
+ * the engine's governance store (its `announcements` document), so the notices follow the backend
1021
+ * that keeps the other governance documents; every caller awaits it, so a line a flow announced is
1022
+ * in the queue before that flow's next step (a session's first injection drains it).
972
1023
  */
973
1024
  private announce;
974
1025
  /** The operator half of {@link announce}: a notice no single scope owns, said to the host only. */
@@ -988,8 +1039,10 @@ export declare class MemoryEngine {
988
1039
  * scope's. */
989
1040
  private scopeOfPlaneRel;
990
1041
  /** Model-face notices whose scope is resolved after the call that raised them (the challenge lanes:
991
- * their sync callers hold an entry id, and only the store knows its scope). One chain, in order;
992
- * {@link settleAnnouncementWork} bounds how long a mount waits for it. */
1042
+ * their callers hold an entry id, and only the store knows its scope). One chain, in order;
1043
+ * {@link settleAnnouncementWork} bounds how long a mount waits for it. It orders that attribution
1044
+ * work only: every other notice is awaited by the flow that raised it ({@link announce}), and the
1045
+ * queue's own read-modify-write is serialized by the store (`updateDoc`). */
993
1046
  private announcementWork;
994
1047
  /** The warnings of a report that are NOT about the write home, each with the scope it is about
995
1048
  * (`undefined` for a sentence about several scopes or the whole store — the host's). Every other
@@ -1013,6 +1066,10 @@ export declare class MemoryEngine {
1013
1066
  /** In-process half of the one-way marker: a session marked in THIS process stays polluted here
1014
1067
  * even when the durable write failed (the disk half is best-effort WITH disclosure). */
1015
1068
  private readonly pollutedSessions;
1069
+ /** The retroactive challenge sweeps a pollution mark has started and not finished. A caller that does not await the
1070
+ * mark (a tool lane's synchronous mark seat) still gets them: {@link readChallengeExclusions} waits for every sweep
1071
+ * already started, so no exclusion read after a mark answers without that mark's challenges. A sweep never rejects. */
1072
+ private readonly pendingPollutionSweeps;
1016
1073
  /**
1017
1074
  * Mark `sessionId`'s memory POLLUTED (the session invoked an external-content-class tool).
1018
1075
  * One-way by construction: there is no unmark API at any layer, a repeat mark keeps the FIRST
@@ -1026,7 +1083,7 @@ export declare class MemoryEngine {
1026
1083
  * markers of one session would both read clean and both announce). Callers that do not disclose
1027
1084
  * ignore it exactly as before.
1028
1085
  */
1029
- markSessionPolluted(sessionId: string, reason: string, cause?: import("./types.js").MemoryOriginCause): SessionPollutionMarkOutcome;
1086
+ markSessionPolluted(sessionId: string, reason: string, cause?: import("./types.js").MemoryOriginCause): Promise<SessionPollutionMarkOutcome>;
1030
1087
  /** The session's pollution record (in-process mark first, then the durable marker) — undefined =
1031
1088
  * clean. Reads are side-effect-free. */
1032
1089
  sessionPollution(sessionId: string): SessionPollutionRecord | undefined;
@@ -1070,6 +1127,8 @@ export declare class MemoryEngine {
1070
1127
  * refuses to imply — the deliberate divergence from the pollution marker's best-effort arm.
1071
1128
  */
1072
1129
  markSessionCaptureOptOut(sessionId: string, reason: string): SessionCaptureOptOutMarkOutcome | Promise<SessionCaptureOptOutMarkOutcome>;
1130
+ /** The mark half of {@link markSessionCaptureOptOut}, after the in-flight guard. */
1131
+ private markCaptureRecord;
1073
1132
  /** The session's capture opt-out record (in-process first, then the durable store) — undefined =
1074
1133
  * capture is on. Side-effect-free OBSERVER face; a THROWING store read degrades to the
1075
1134
  * in-process answer here. Every consumer whose answer decides whether bytes COMMIT must use
@@ -1140,17 +1199,17 @@ export declare class MemoryEngine {
1140
1199
  * unknowable — consumers must refuse service loudly (corrupt ≠ clean), the same law the pollution
1141
1200
  * marker already follows.
1142
1201
  */
1143
- readChallengeExclusions(): Map<string, {
1202
+ readChallengeExclusions(): Promise<Map<string, {
1144
1203
  code: "challenged" | "lineage_pending";
1145
1204
  generation?: number;
1146
1205
  at?: number;
1147
- }>;
1206
+ }>>;
1148
1207
  /** The shared challenge writer: append events idempotently, then announce OPAQUELY (id + code +
1149
1208
  * generation only — the announcement is a model-visible face, so no name/description/free reason
1150
1209
  * rides it; content stays on the host audit face). Failures are disclosed, never thrown past. */
1151
1210
  private challengeAndAnnounce;
1152
1211
  /** The challenge notices, filed under each entry's own scope. The ledger append above is the fact and
1153
- * stays synchronous; the scope comes from the committed store (side-effect-free read), so the filing
1212
+ * is awaited before this runs; the scope comes from the committed store (side-effect-free read), so the filing
1154
1213
  * is chained work a mount waits for ({@link settleAnnouncementWork}). An id the store no longer
1155
1214
  * holds has no scope to file under — said to the host only. A failed attribution is disclosed, never
1156
1215
  * swallowed. */
@@ -1181,7 +1240,7 @@ export declare class MemoryEngine {
1181
1240
  * `reason` is required and recorded in the announcement's shape (not its text — the announcement is a
1182
1241
  * model-visible face and stays opaque); it is the operator's own note on the host error face.
1183
1242
  */
1184
- rebuildCorruptControlPlaneLedger(ledger: StrictControlPlaneLedger, reason: string): ControlPlaneRebuildReceipt;
1243
+ rebuildCorruptControlPlaneLedger(ledger: StrictControlPlaneLedger, reason: string): Promise<ControlPlaneRebuildReceipt>;
1185
1244
  /**
1186
1245
  * Host API (advisory, control-plane trust level — the same plane that can mark pollution):
1187
1246
  * challenge entries by id. `requestId` is REQUIRED (the generation ledger's idempotency identity;
@@ -1189,7 +1248,7 @@ export declare class MemoryEngine {
1189
1248
  * ack cannot open a second generation). Each entry's eventId derives as `<requestId>:<entryId>`,
1190
1249
  * so one batched request stays per-entry attributable.
1191
1250
  */
1192
- challengeEntries(ids: readonly string[], reason: string, requestId: string): ChallengeAssignment[];
1251
+ challengeEntries(ids: readonly string[], reason: string, requestId: string): Promise<ChallengeAssignment[]>;
1193
1252
  /**
1194
1253
  * design/178 v2-b §3.3(b) — the HOST erasure API: explicit, named, evidenced, loud. This is a
1195
1254
  * host-plane DECLARED deletion, not a second deletion throat: it executes through the same
@@ -1269,8 +1328,8 @@ export declare class MemoryEngine {
1269
1328
  *
1270
1329
  * Failure posture is the control plane's existing fail-closed law: a corrupt lineage or challenge
1271
1330
  * ledger THROWS (`ControlPlaneCorruptError` — an answer is never assembled over an account whose
1272
- * integrity is unknown), and the backend's own refusals (v1-compat store, contended snapshot
1273
- * fence) propagate. CAPABILITY ABSENCE is not failure: a backend without the audit faces answers
1331
+ * integrity is unknown), and the backend's own refusals (a ledger it refuses, a contended
1332
+ * snapshot fence) propagate. CAPABILITY ABSENCE is not failure: a backend without the audit faces answers
1274
1333
  * `binding: "unknown"` / `contentState: "capability-absent"` / `custody: "capability-absent"` —
1275
1334
  * reported honestly, never fabricated and never a throw (#196 absence-reports-not-silent-green).
1276
1335
  */
@@ -1312,20 +1371,20 @@ export declare class MemoryEngine {
1312
1371
  /** Host API: challenge every entry the lineage ledger attributes to `sessionId` (post-hoc source
1313
1372
  * falsification — trustedTools misconfigured, a tool re-classified, late delegation evidence).
1314
1373
  * Same requestId contract as {@link challengeEntries}. */
1315
- challengeSession(sessionId: string, reason: string, requestId: string): ChallengeAssignment[];
1374
+ challengeSession(sessionId: string, reason: string, requestId: string): Promise<ChallengeAssignment[]>;
1316
1375
  /** Host API: the TRUSTED resolve — closes exactly the named generation (a later challenge stays
1317
1376
  * open; a resolve never blanket-clears, and there is no model-face path to this call). Returns
1318
1377
  * false ⇔ no such generation was ever opened. */
1319
- resolveChallenge(entryId: string, generation: number, reason: string, requestId?: string): boolean;
1378
+ resolveChallenge(entryId: string, generation: number, reason: string, requestId?: string): Promise<boolean>;
1320
1379
  /** Host API: adjudicate one UNDECIDABLE pending lineage transaction (the applyPatches-success →
1321
1380
  * credential-write crash window; design/180 r5 — never auto-discarded). The host, holding its own
1322
1381
  * deployment facts, states whether the commit landed. */
1323
- adjudicatePendingLineage(txnId: string, action: "promote" | "discard"): LineagePromotion[];
1382
+ adjudicatePendingLineage(txnId: string, action: "promote" | "discard"): Promise<LineagePromotion[]>;
1324
1383
  /** Host observability: the staged lineage transactions still awaiting settlement (their entry ids
1325
1384
  * are latched — see {@link readChallengeExclusions}). Throws on a corrupt ledger. */
1326
- listPendingLineage(): Record<string, LineagePendingTxn>;
1385
+ listPendingLineage(): Promise<Record<string, LineagePendingTxn>>;
1327
1386
  /** Host audit reads (throw on corruption — audit must not read a laundered ledger as clean). */
1328
- readChallengeLedger(): ChallengeEvent[];
1387
+ readChallengeLedger(): Promise<ChallengeEvent[]>;
1329
1388
  /** Observability/tests — the collect-only challenged-history account (B-3; zero engine consumers). */
1330
1389
  readChallengedHistoryAccount(): Record<string, ChallengedHistoryRow>;
1331
1390
  /** Promotion settlement (shared by harvest step ⑤, reconciliation and host adjudication): a
@@ -1344,10 +1403,12 @@ export declare class MemoryEngine {
1344
1403
  shadowNames?: ReadonlyMap<string, string>;
1345
1404
  }): Promise<MemorySessionHandle>;
1346
1405
  private materializeCore;
1406
+ /** Async because its one destructive read — the drain of the session's notice queues — goes through the
1407
+ * governance store (the `announcements` document), which may answer asynchronously. */
1347
1408
  inject(handle: MemorySessionHandle, opts?: {
1348
1409
  writeToolMounted?: boolean;
1349
1410
  reminderMark?: string;
1350
- }): MemoryInjection;
1411
+ }): Promise<MemoryInjection>;
1351
1412
  /**
1352
1413
  * design/138 S2-C — gate ONE tool write (Write/Edit/NotebookEdit) against the memory domain.
1353
1414
  * `canonicalPath` is the tool band's already-canonical containment key; a path outside the
@@ -1415,7 +1476,7 @@ export declare class MemoryEngine {
1415
1476
  /** §3.3 — the settlement valve: an audited host ruling over one delegation's outcome. `"clean"`
1416
1477
  * releases the post-expiry gates (effective only — the history bit never flips, and a LATER
1417
1478
  * observed `external` overrides the ruling); `"external"` convicts. Advisory trust plane. */
1418
- resolveSettlement(settleId: string, to: "clean" | "external", requestId: string): void;
1479
+ resolveSettlement(settleId: string, to: "clean" | "external", requestId: string): Promise<void>;
1419
1480
  /** §4.2③ — the hold valve: `"release"` commits the held entry at the next harvest WITH a
1420
1481
  * `"static"`-cause marker (a valve release is not a cleanliness proof); `"discard"` disposes it
1421
1482
  * to quarantine. Audited (requestId required). */
@@ -1424,20 +1485,15 @@ export declare class MemoryEngine {
1424
1485
  * residue arm keeps firing until the next full-domain harvest closes normally — a valve close
1425
1486
  * must not launder the window it covers). It also ends the session's leg (no live writer of its
1426
1487
  * layer any more). Audited (requestId required). */
1427
- resolveSessionAccount(sessionId: string, requestId: string): void;
1428
- /** The engine's control-plane directory (the sidecar home: pollution markers, lineage/challenge
1429
- * ledgers, and the design/336 settlement/hold/session accounts). Exposed so a host (and the
1430
- * runner's settlement handle) can address the SAME plane the engine writes — a second derivation
1431
- * would be a drift seam. */
1432
- get controlPlaneDir(): string;
1488
+ resolveSessionAccount(sessionId: string, requestId: string): Promise<void>;
1433
1489
  /** Read face: every delegation settlement row with its folded effective status (host audit). */
1434
- readDelegationSettlements(): EffectiveSettlement[];
1490
+ readDelegationSettlements(): Promise<EffectiveSettlement[]>;
1435
1491
  /** Read face: every instruction-hold row (host audit; custody bytes are addressable through
1436
1492
  * `captureName`/`disposition.quarantineName` under the control plane). */
1437
1493
  readInstructionHolds(): HoldRow[];
1438
1494
  /** Read face: the dangling foreign session-account rows a given session would classify residue
1439
1495
  * against (host audit for the §3.6 valve). */
1440
- readDanglingSessionAccounts(selfSessionId: string): ReturnType<typeof foreignDanglingSessionAccounts>;
1496
+ readDanglingSessionAccounts(selfSessionId: string): Promise<Awaited<ReturnType<typeof foreignDanglingSessionAccounts>>>;
1441
1497
  /** The coded off-switch refusal every verb answers first (G1). */
1442
1498
  private requireConsolidation;
1443
1499
  /** Gate-store read with the strict fail-closed translation (F5: corrupt ⇒ verbs refuse coded;
@@ -1535,9 +1591,12 @@ export declare class MemoryEngine {
1535
1591
  /** Take the application of `plan`: the last claimer holds it, an earlier holder is stale from now on and stops at its next owned write.
1536
1592
  * The gate store's lock serves as the mutex (no gate row is touched). A plan that is gone or already terminal is nobody's to apply. */
1537
1593
  private claimPlanForApply;
1538
- /** A write of the plan's book by its holder: refused when another applier took over or the book was settled meanwhile (stale holders write nothing). */
1594
+ /** A write of the plan's book by its holder: refused when another applier took over or the book was settled meanwhile (stale holders write nothing).
1595
+ * The owner read and the write are one transaction of the consolidation store — nobody's takeover lands between them. */
1539
1596
  private writePlanOwned;
1540
- /** Throws unless `plan` is still held by this applier: same token on disk, and the book is not settled into a state other than the one being written. */
1597
+ /** An unfenced plan write (the plan's first durable write at freeze; the host valve's override). */
1598
+ private writePlan;
1599
+ /** Throws unless `plan` is still held by this applier: same token in the store (`cur`, as read), and the book is not settled into a state other than the one being written. */
1541
1600
  private assertPlanOwner;
1542
1601
  private throwPlanNotHeld;
1543
1602
  /** Terminal settlement: per-item terminals → the plan terminal, the credential write (§1.5-3:
@@ -1597,7 +1656,7 @@ export declare class MemoryEngine {
1597
1656
  * is where the conflict notice tells a host to look. */
1598
1657
  private reconstructIntentsForRetry;
1599
1658
  /** §6.2 — host read face: every plan's summary (audit enumeration, zero model surface). */
1600
- listConsolidationPlans(): ConsolidationPlanSummary[];
1659
+ listConsolidationPlans(): Promise<ConsolidationPlanSummary[]>;
1601
1660
  /**
1602
1661
  * design/376 slice ③ (#436) — host read face: one plan's MEMBER-LEVEL fold evidence (which ids
1603
1662
  * its APPLIED products supersede). This is the conservation wall's terminal witness: the
@@ -1621,12 +1680,12 @@ export declare class MemoryEngine {
1621
1680
  * mint re-judges the live world. A LIVE-standing re-derivation here would instead false-red the
1622
1681
  * honestly converged re-covered case, and the ruled evidence form is the per-plan applied edge.
1623
1682
  */
1624
- readConsolidationPlanFoldEvidence(planId: string): ConsolidationPlanFoldEvidence;
1683
+ readConsolidationPlanFoldEvidence(planId: string): Promise<ConsolidationPlanFoldEvidence>;
1625
1684
  /** §6.2 — host read face: one scope's gate row (undefined when the store has no row — reading
1626
1685
  * never creates the file, so the OFF deployment stays byte-identical, G1). A corrupt store
1627
1686
  * ALSO answers undefined here — this face cannot distinguish the two; a consumer that needs
1628
1687
  * the difference reads {@link readConsolidationGateState} (#437②). */
1629
- readConsolidationGate(scope: string): ConsolidationGateRow | undefined;
1688
+ readConsolidationGate(scope: string): Promise<ConsolidationGateRow | undefined>;
1630
1689
  /**
1631
1690
  * design/376 slice ③ (#437②) — host read face: one scope's gate row as a DISCRIMINATED answer.
1632
1691
  * The undiscriminated face above folds a corrupt store into `undefined`, so a healthy never-run
@@ -1635,7 +1694,7 @@ export declare class MemoryEngine {
1635
1694
  * creates the file — the OFF deployment stays byte-identical, G1); `corrupt` carries the
1636
1695
  * refusal detail. Additive; the undiscriminated face is unchanged.
1637
1696
  */
1638
- readConsolidationGateState(scope: string): ConsolidationGateRead;
1697
+ readConsolidationGateState(scope: string): Promise<ConsolidationGateRead>;
1639
1698
  /**
1640
1699
  * design/376 片② — host read face: one scope's committed FOLD STATE, in the freeze's own
1641
1700
  * accounting (`active` counts entries neither superseded nor excluded — byte-for-byte the
@@ -1654,10 +1713,19 @@ export declare class MemoryEngine {
1654
1713
  * Host read face: the engine's RESOLVED control-plane directory (the same coordinate a
1655
1714
  * directory-pinned backend already publishes as `controlPlaneRoot`; this accessor answers it
1656
1715
  * after the engine's own precedence — backend pin > constructor argument > derived default).
1657
- * The shipped consolidation driver keeps its run account and mint archives in this plane
1658
- * (design/376 §1.6-4); path knowledge is not authority — nothing here bypasses a verb.
1716
+ * The one accessor of that directory: the runner's settlement handle and the capture floor's
1717
+ * plane coordinate read it here, so a host and the runner address the SAME plane the engine
1718
+ * writes (a second derivation would be a drift seam). Path knowledge is not authority — nothing
1719
+ * here bypasses a verb.
1659
1720
  */
1660
1721
  get controlPlaneRoot(): string;
1722
+ /** The store this engine keeps its consolidation state in: the backend's own (`MemoryBackend.governance`) when it
1723
+ * carries one, else the File store over this engine's control plane. Whether that state survives the replica is
1724
+ * `memoryGovernanceDurability`'s answer, not this member's presence. */
1725
+ get governance(): MemoryGovernanceStore;
1726
+ /** Host read face: the scope's latest consolidation driver run row (pending = resumable; settled = audit), read
1727
+ * through {@link governance}; a malformed account throws `ControlPlaneCorruptError`. */
1728
+ readConsolidationDriverRun(scope: string): Promise<ConsolidationDriverRunRow | undefined>;
1661
1729
  /**
1662
1730
  * design/376 slice ③ (#437③) — host read face: the store's scope enumeration, capability-probed
1663
1731
  * on the backend (`listScopes`, the audit-face probe family). A backend WITHOUT the face
@@ -1703,6 +1771,15 @@ export declare class MemoryEngine {
1703
1771
  * Never throws — an unreadable source is an absent key, which IS the answer.
1704
1772
  */
1705
1773
  sessionMemoryStatus(sessionId: string): Promise<SessionMemoryStatus>;
1774
+ /**
1775
+ * {@link sessionMemoryStatus} with the reading that named (or failed to name) its `writeHome`, from the same one pass over
1776
+ * the ledgers: what a deployment of several stores needs to choose among the stores' homes by the law each store applies
1777
+ * to its own two sources (`chooseSessionWriteHome`). `status` is exactly what `sessionMemoryStatus` answers. Never throws.
1778
+ */
1779
+ sessionMemoryStatusRead(sessionId: string): Promise<{
1780
+ readonly status: SessionMemoryStatus;
1781
+ readonly writeHome: SessionWriteHomeReading;
1782
+ }>;
1706
1783
  /** The committed, side-effect-free audit read: the adoption-restricted committed view when the
1707
1784
  * backend offers one (the File backend — ledger+shadow, no disk adoption), else a non-adopting
1708
1785
  * retrieval view where one is offered, else the backend itself (Pg/TiDB shapes — naturally committed
@@ -1929,7 +2006,8 @@ export declare class MemoryEngine {
1929
2006
  private censusScopeTree;
1930
2007
  }
1931
2008
  /** Render drained announcements as ONE engine-owned system-reminder block (the lead/frame is
1932
- * trusted; item identifiers were neutralized at enqueue — see {@link MemoryAnnouncement.items}). */
2009
+ * trusted; item identifiers were neutralized at enqueue — see {@link MemoryAnnouncement.items}). The
2010
+ * lead names no session: a notice may be about this session's own harvest (#1123 ②). */
1933
2011
  export declare function renderAnnouncements(queue: readonly MemoryAnnouncement[], folded: number, reminderMark?: string): string;
1934
2012
  /** Truncate the derived index to the CC injection parameters (200 lines / 25KB). */
1935
2013
  export declare function truncateIndex(text: string): string;