@sema-agent/core 7.56.0 → 7.58.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 (319) hide show
  1. package/CHANGELOG.md +926 -0
  2. package/LICENSE +1 -1
  3. package/dist/agents/org-delivery-gate.js +3 -4
  4. package/dist/agents/peer-held-queue.d.ts +69 -49
  5. package/dist/agents/peer-held-queue.js +255 -106
  6. package/dist/agents/peer-session-drain.js +63 -43
  7. package/dist/agents/send-message-tool.js +3 -2
  8. package/dist/agents/subagent-steps.js +2 -4
  9. package/dist/agents/subagent.js +8 -8
  10. package/dist/brain/anthropic.js +16 -8
  11. package/dist/brain/open-responses.js +10 -8
  12. package/dist/brain/openai.js +11 -9
  13. package/dist/brain/provider-dialect.d.ts +3 -2
  14. package/dist/brain/provider-dialect.js +2 -2
  15. package/dist/brain/request-params.d.ts +6 -0
  16. package/dist/brain/request-params.js +14 -1
  17. package/dist/brain/route-adjudicator.js +2 -1
  18. package/dist/brain/stream-engine.d.ts +9 -0
  19. package/dist/brain/stream-engine.js +24 -10
  20. package/dist/brain/stream-shared.d.ts +5 -4
  21. package/dist/brain/stream-shared.js +4 -4
  22. package/dist/core/a2a.d.ts +2 -1
  23. package/dist/core/a2a.js +23 -10
  24. package/dist/core/allow-entry.d.ts +5 -11
  25. package/dist/core/allow-entry.js +19 -26
  26. package/dist/core/approval-object.d.ts +21 -5
  27. package/dist/core/approval-object.js +44 -17
  28. package/dist/core/ask-origin.d.ts +23 -4
  29. package/dist/core/ask-origin.js +5 -1
  30. package/dist/core/auto-compaction.d.ts +75 -6
  31. package/dist/core/auto-compaction.js +43 -27
  32. package/dist/core/auto-mode-directive.d.ts +29 -5
  33. package/dist/core/auto-mode-directive.js +38 -8
  34. package/dist/core/background-agent-store.d.ts +6 -2
  35. package/dist/core/background-agent-store.js +1 -1
  36. package/dist/core/checkpoint-requirements.d.ts +13 -1
  37. package/dist/core/checkpoint-requirements.js +4 -0
  38. package/dist/core/checkpoint-store.d.ts +44 -40
  39. package/dist/core/checkpoint-store.js +32 -14
  40. package/dist/core/cross-boundary-taint.js +4 -2
  41. package/dist/core/engine-notice.d.ts +4 -3
  42. package/dist/core/engine-notice.js +6 -0
  43. package/dist/core/file-history-store.d.ts +14 -8
  44. package/dist/core/file-history-store.js +14 -4
  45. package/dist/core/fs-write-gate-policy.d.ts +4 -2
  46. package/dist/core/fs-write-gate-policy.js +7 -3
  47. package/dist/core/gate-fold.js +6 -3
  48. package/dist/core/gate-lanes.js +13 -5
  49. package/dist/core/git-worktree-env.d.ts +53 -11
  50. package/dist/core/git-worktree-env.js +96 -12
  51. package/dist/core/hooks.d.ts +6 -3
  52. package/dist/core/hooks.js +12 -5
  53. package/dist/core/human-input-projection.d.ts +1 -0
  54. package/dist/core/human-input-projection.js +3 -0
  55. package/dist/core/locked-config.d.ts +15 -1
  56. package/dist/core/locked-config.js +38 -2
  57. package/dist/core/mailbox-store.d.ts +62 -1
  58. package/dist/core/mailbox-store.js +59 -0
  59. package/dist/core/mcp-call-meta.d.ts +66 -0
  60. package/dist/core/mcp-call-meta.js +103 -0
  61. package/dist/core/mcp-connection-pool.d.ts +3 -1
  62. package/dist/core/mcp-connection-pool.js +3 -1
  63. package/dist/core/mcp-failure.d.ts +7 -1
  64. package/dist/core/mcp-failure.js +10 -0
  65. package/dist/core/mcp-name-judge.d.ts +46 -0
  66. package/dist/core/mcp-name-judge.js +61 -0
  67. package/dist/core/mcp-probe.d.ts +5 -1
  68. package/dist/core/mcp-probe.js +3 -6
  69. package/dist/core/mcp-server-link.d.ts +5 -2
  70. package/dist/core/mcp-server-spec.d.ts +46 -18
  71. package/dist/core/mcp-server-spec.js +1 -18
  72. package/dist/core/mcp.d.ts +6 -14
  73. package/dist/core/mcp.js +85 -65
  74. package/dist/core/memory-engine/consolidation-driver.js +4 -3
  75. package/dist/core/memory-engine/distiller.js +26 -17
  76. package/dist/core/memory-engine/layout.js +5 -2
  77. package/dist/core/memory-engine/scope-contract.d.ts +45 -4
  78. package/dist/core/memory-engine/scope-contract.js +80 -11
  79. package/dist/core/mode-policy.d.ts +8 -5
  80. package/dist/core/mode-policy.js +5 -4
  81. package/dist/core/mods/host.js +1 -1
  82. package/dist/core/mods/kernel/dispatch.d.ts +3 -0
  83. package/dist/core/mods/kernel/dispatch.js +10 -8
  84. package/dist/core/mods/kernel/events.d.ts +5 -1
  85. package/dist/core/mods/kernel/events.js +1 -1
  86. package/dist/core/mods/kernel/registration.d.ts +5 -1
  87. package/dist/core/mods/kernel/site-rules.d.ts +3 -0
  88. package/dist/core/mods/kernel/site-rules.js +10 -0
  89. package/dist/core/mods/package.d.ts +23 -0
  90. package/dist/core/mods/package.js +118 -0
  91. package/dist/core/mods/stations.d.ts +2 -2
  92. package/dist/core/mods/stations.js +1 -1
  93. package/dist/core/mods/tool-call.d.ts +5 -1
  94. package/dist/core/mods/tool-call.js +12 -3
  95. package/dist/core/park-selfcheck.js +2 -0
  96. package/dist/core/path-guard-rows.d.ts +20 -0
  97. package/dist/core/path-guard-rows.js +11 -0
  98. package/dist/core/peer-seat.d.ts +186 -0
  99. package/dist/core/peer-seat.js +307 -0
  100. package/dist/core/permission-rule-consent.d.ts +5 -3
  101. package/dist/core/permission-rule-consent.js +20 -15
  102. package/dist/core/permission-rule-model.d.ts +43 -2
  103. package/dist/core/permission-rule-model.js +52 -8
  104. package/dist/core/permission-rule-org.js +1 -1
  105. package/dist/core/present-plan-tool.d.ts +10 -1
  106. package/dist/core/present-plan-tool.js +46 -2
  107. package/dist/core/protocol-http-auth.d.ts +56 -31
  108. package/dist/core/protocol-http-auth.js +71 -42
  109. package/dist/core/protocol-naming.d.ts +20 -0
  110. package/dist/core/protocol-naming.js +20 -3
  111. package/dist/core/read-only-shell.d.ts +20 -5
  112. package/dist/core/read-only-shell.js +29 -14
  113. package/dist/core/redaction-marks.d.ts +16 -0
  114. package/dist/core/redaction-marks.js +16 -0
  115. package/dist/core/redaction-passes.js +8 -9
  116. package/dist/core/remote-env.d.ts +37 -1
  117. package/dist/core/remote-env.js +11 -0
  118. package/dist/core/resume-startup-cause.d.ts +24 -2
  119. package/dist/core/resume-startup-cause.js +20 -1
  120. package/dist/core/retention.d.ts +41 -15
  121. package/dist/core/retention.js +59 -12
  122. package/dist/core/rewrite-rejudge.d.ts +37 -0
  123. package/dist/core/rewrite-rejudge.js +40 -0
  124. package/dist/core/roles.js +50 -7
  125. package/dist/core/run-origin.d.ts +40 -0
  126. package/dist/core/run-origin.js +37 -0
  127. package/dist/core/runner/advertised-writable-dirs.d.ts +57 -38
  128. package/dist/core/runner/advertised-writable-dirs.js +126 -0
  129. package/dist/core/runner/compact-session.d.ts +10 -0
  130. package/dist/core/runner/compact-session.js +202 -0
  131. package/dist/core/runner/compaction-call-options.d.ts +2 -2
  132. package/dist/core/runner/compaction-restate.d.ts +15 -6
  133. package/dist/core/runner/compaction-restate.js +28 -2
  134. package/dist/core/runner/compaction-seams.d.ts +21 -1
  135. package/dist/core/runner/compaction-seams.js +11 -8
  136. package/dist/core/runner/contracts.d.ts +36 -21
  137. package/dist/core/runner/derived-route-fallback.d.ts +13 -0
  138. package/dist/core/runner/derived-route-fallback.js +6 -0
  139. package/dist/core/runner/env-capability-census.d.ts +3 -2
  140. package/dist/core/runner/env-capability-census.js +9 -3
  141. package/dist/core/runner/gate-exit.d.ts +18 -4
  142. package/dist/core/runner/gate-exit.js +5 -1
  143. package/dist/core/runner/permission-rule-lanes.d.ts +7 -7
  144. package/dist/core/runner/permission-rule-lanes.js +17 -11
  145. package/dist/core/runner/prepare-acquire-reconcile.d.ts +3 -0
  146. package/dist/core/runner/prepare-acquire-reconcile.js +2 -1
  147. package/dist/core/runner/prepare-caps-and-workflow.d.ts +2 -0
  148. package/dist/core/runner/prepare-caps-and-workflow.js +1 -1
  149. package/dist/core/runner/prepare-config-doors.d.ts +14 -5
  150. package/dist/core/runner/prepare-config-doors.js +16 -13
  151. package/dist/core/runner/prepare-delegation-surface.d.ts +4 -0
  152. package/dist/core/runner/prepare-delegation-surface.js +15 -18
  153. package/dist/core/runner/prepare-gate-stations.js +1 -1
  154. package/dist/core/runner/prepare-hands-readface.d.ts +10 -4
  155. package/dist/core/runner/prepare-hands-readface.js +6 -1
  156. package/dist/core/runner/prepare-memory.d.ts +3 -0
  157. package/dist/core/runner/prepare-memory.js +19 -23
  158. package/dist/core/runner/prepare-park-ask.d.ts +2 -0
  159. package/dist/core/runner/prepare-park-ask.js +2 -2
  160. package/dist/core/runner/prepare-policy-chain.d.ts +4 -4
  161. package/dist/core/runner/prepare-policy-chain.js +4 -6
  162. package/dist/core/runner/prepare-protocol-tools.d.ts +4 -2
  163. package/dist/core/runner/prepare-protocol-tools.js +3 -3
  164. package/dist/core/runner/prepare-suspend-saga.d.ts +2 -0
  165. package/dist/core/runner/prepare-suspend-saga.js +2 -1
  166. package/dist/core/runner/prepare-task.d.ts +4 -1
  167. package/dist/core/runner/prepare-task.js +46 -37
  168. package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +13 -0
  169. package/dist/core/runner/prepare-tool-disclosure-mount.js +13 -7
  170. package/dist/core/runner/prepare-wiring-manifest.d.ts +1 -0
  171. package/dist/core/runner/prepare-wiring-manifest.js +2 -2
  172. package/dist/core/runner/prepare-workspace-restore.d.ts +3 -0
  173. package/dist/core/runner/prepare-workspace-restore.js +4 -4
  174. package/dist/core/runner/resume-admission.js +1 -1
  175. package/dist/core/runner/resume-checkpoint-screen.js +2 -0
  176. package/dist/core/runner/rewind-files.d.ts +2 -5
  177. package/dist/core/runner/rewind-files.js +9 -51
  178. package/dist/core/runner/run-harness-handlers.d.ts +3 -4
  179. package/dist/core/runner/run-harness-handlers.js +1 -8
  180. package/dist/core/runner/run-identity-wiring.js +1 -0
  181. package/dist/core/runner/run-leg.js +15 -22
  182. package/dist/core/runner/run-notification-lane.d.ts +2 -0
  183. package/dist/core/runner/run-notification-lane.js +5 -2
  184. package/dist/core/runner/run-recovery-lanes.js +3 -4
  185. package/dist/core/runner/run-settle-and-teardown.js +5 -11
  186. package/dist/core/runner/run-terminal-adoption.js +3 -4
  187. package/dist/core/runner/run-turn-boundary.js +3 -5
  188. package/dist/core/runner/runtask.d.ts +8 -1
  189. package/dist/core/runner/runtask.js +28 -34
  190. package/dist/core/runner/send-message-continuation.js +1 -1
  191. package/dist/core/runner/session-verb-doors.d.ts +28 -0
  192. package/dist/core/runner/session-verb-doors.js +48 -0
  193. package/dist/core/runner/session-write-ledger.d.ts +30 -0
  194. package/dist/core/runner/session-write-ledger.js +101 -0
  195. package/dist/core/runner/stream-settle-backstop.js +11 -14
  196. package/dist/core/runner/sub-agent-deny-lists.d.ts +25 -3
  197. package/dist/core/runner/sub-agent-deny-lists.js +21 -10
  198. package/dist/core/runner/teardown-bounded.d.ts +1 -0
  199. package/dist/core/runner/teardown-bounded.js +1 -0
  200. package/dist/core/runner/terminal-account.js +3 -3
  201. package/dist/core/runner/tool-end-body.js +1 -0
  202. package/dist/core/runner/tool-occurrence.d.ts +4 -1
  203. package/dist/core/runner/tool-occurrence.js +2 -1
  204. package/dist/core/runner/write-protection-station.d.ts +8 -2
  205. package/dist/core/runner/write-protection-station.js +2 -0
  206. package/dist/core/runner-deps.d.ts +4 -4
  207. package/dist/core/secret-env.d.ts +4 -0
  208. package/dist/core/secret-env.js +3 -0
  209. package/dist/core/sensitive-path-policy.js +6 -7
  210. package/dist/core/session-log-transfer.d.ts +24 -0
  211. package/dist/core/session-log-transfer.js +166 -0
  212. package/dist/core/session-policy-store.d.ts +7 -2
  213. package/dist/core/session-policy-store.js +1 -1
  214. package/dist/core/session-store.d.ts +84 -19
  215. package/dist/core/session-store.js +162 -24
  216. package/dist/core/session.d.ts +92 -1
  217. package/dist/core/shell-read-silence.js +1 -0
  218. package/dist/core/shell-wrapper-projection.d.ts +1 -1
  219. package/dist/core/steer-replay.d.ts +4 -2
  220. package/dist/core/steer-replay.js +2 -1
  221. package/dist/core/store-contracts/background-agent-store-contract.js +1 -0
  222. package/dist/core/store-contracts/checkpoint-store-contract.js +19 -1
  223. package/dist/core/store-contracts/file-history-store-contract.js +9 -0
  224. package/dist/core/store-contracts/mailbox-store-contract.js +49 -1
  225. package/dist/core/store-contracts/session-repo-contract.js +112 -5
  226. package/dist/core/store-contracts/session-store-contract.d.ts +4 -1
  227. package/dist/core/store-contracts/session-store-contract.js +236 -2
  228. package/dist/core/task-event.d.ts +68 -8
  229. package/dist/core/task-registry-agent.d.ts +8 -4
  230. package/dist/core/task-registry-agent.js +14 -8
  231. package/dist/core/task-registry-shared.d.ts +36 -6
  232. package/dist/core/task-registry-shared.js +11 -0
  233. package/dist/core/task-registry.d.ts +1 -1
  234. package/dist/core/task-registry.js +1 -1
  235. package/dist/core/task-spec.d.ts +37 -0
  236. package/dist/core/task-stream.d.ts +2 -1
  237. package/dist/core/terminal-cause.d.ts +1 -1
  238. package/dist/core/tool-catalog-entries.d.ts +6 -0
  239. package/dist/core/tool-catalog-entries.js +2 -0
  240. package/dist/core/tool-name-aliases.d.ts +32 -2
  241. package/dist/core/tool-name-aliases.js +23 -0
  242. package/dist/core/tool-name-readings.d.ts +4 -0
  243. package/dist/core/tool-name-readings.js +1 -0
  244. package/dist/core/tool-policy.d.ts +10 -6
  245. package/dist/core/tool-policy.js +4 -7
  246. package/dist/core/tool-result-store.d.ts +17 -10
  247. package/dist/core/tool-result-store.js +3 -1
  248. package/dist/core/trace.d.ts +4 -1
  249. package/dist/core/trace.js +2 -1
  250. package/dist/core/types.d.ts +1 -1
  251. package/dist/core/untrusted-egress.d.ts +18 -0
  252. package/dist/core/untrusted-egress.js +82 -12
  253. package/dist/core/wiring-manifest.d.ts +12 -3
  254. package/dist/core/wiring-manifest.js +4 -3
  255. package/dist/core/workspace-snapshot.d.ts +44 -0
  256. package/dist/core/workspace-snapshot.js +34 -0
  257. package/dist/core/write-protect.d.ts +43 -3
  258. package/dist/core/write-protect.js +43 -16
  259. package/dist/engine/execution-env/node-execution-env.js +15 -11
  260. package/dist/engine/execution-env/symlink-chain.d.ts +7 -5
  261. package/dist/engine/harness/agent-harness.d.ts +12 -5
  262. package/dist/engine/harness/agent-harness.js +13 -2
  263. package/dist/engine/harness/types.d.ts +48 -7
  264. package/dist/engine/harness/types.js +5 -1
  265. package/dist/engine/llm/types.d.ts +12 -3
  266. package/dist/engine/llm/types.js +1 -1
  267. package/dist/engine/loop/agent-loop.d.ts +1 -4
  268. package/dist/engine/loop/agent-loop.js +26 -4
  269. package/dist/engine/session/import-validate.js +3 -0
  270. package/dist/engine/session/memory-repo.d.ts +17 -9
  271. package/dist/engine/session/memory-repo.js +44 -34
  272. package/dist/engine/session/repo-utils.d.ts +22 -4
  273. package/dist/engine/session/repo-utils.js +49 -1
  274. package/dist/engine/session/storage-base.d.ts +10 -1
  275. package/dist/engine/session/storage-base.js +7 -1
  276. package/dist/index.d.ts +23 -11
  277. package/dist/index.js +15 -6
  278. package/dist/internal/harness-types.d.ts +1 -1
  279. package/dist/internal/harness.d.ts +4 -3
  280. package/dist/internal/harness.js +3 -2
  281. package/dist/stores/file/checkpoint-store.d.ts +0 -4
  282. package/dist/stores/file/checkpoint-store.js +0 -1
  283. package/dist/stores/file/file-history-store.js +12 -4
  284. package/dist/stores/file/index.d.ts +4 -1
  285. package/dist/stores/file/index.js +4 -1
  286. package/dist/stores/file/mailbox-store.d.ts +2 -1
  287. package/dist/stores/file/mailbox-store.js +26 -1
  288. package/dist/stores/file/session-store.d.ts +15 -8
  289. package/dist/stores/file/session-store.js +28 -13
  290. package/dist/tools/fs/bash-readonly-classifier.d.ts +15 -19
  291. package/dist/tools/fs/bash-readonly-classifier.js +5 -10
  292. package/dist/tools/fs/fs-bash.js +10 -3
  293. package/dist/tools/fs/fs-write.d.ts +6 -3
  294. package/dist/tools/fs/fs-write.js +8 -7
  295. package/dist/tools/fs/index.d.ts +3 -0
  296. package/dist/tools/fs/index.js +1 -1
  297. package/dist/tools/fs/pattern-kill-guard.d.ts +3 -2
  298. package/dist/tools/fs/pattern-kill-guard.js +68 -36
  299. package/dist/tools/fs/safety.js +40 -8
  300. package/dist/tools/fs/search.js +6 -24
  301. package/dist/tools/fs/shell-read-check.d.ts +18 -1
  302. package/dist/tools/fs/shell-read-check.js +66 -16
  303. package/dist/tools/fs/shell-read-establish.js +2 -1
  304. package/dist/tools/fs/shell-read-identity.d.ts +12 -9
  305. package/dist/tools/fs/shell-read-identity.js +10 -5
  306. package/dist/tools/fs/shell-read-judge.d.ts +10 -1
  307. package/dist/tools/web.js +9 -7
  308. package/dist/tools/worktree.d.ts +42 -15
  309. package/dist/tools/worktree.js +60 -32
  310. package/package.json +4 -2
  311. package/test/export-surface.snapshot.json +141 -3
  312. package/wire-changes/core-stores-sql@7.57.0.json +29 -0
  313. package/wire-changes/core-stores-sql@7.58.0.json +29 -0
  314. package/wire-changes/core@7.57.0.json +1487 -0
  315. package/wire-changes/core@7.58.0.json +2188 -0
  316. package/wire-changes/mods-kernel@7.57.0.json +29 -0
  317. package/wire-changes/mods-kernel@7.58.0.json +81 -0
  318. package/wire-changes/primitives@7.57.0.json +245 -0
  319. package/wire-changes/primitives@7.58.0.json +29 -0
@@ -0,0 +1,101 @@
1
+ import { SessionError } from "../session.js";
2
+ import { thrownText } from "../thrown-value.js";
3
+ export class SessionWriteLedger {
4
+ #inFlight = new Map();
5
+ #drainWaiters = new Map();
6
+ openLeg(report) {
7
+ let closedAt;
8
+ const tell = (sessionId, message) => {
9
+ try {
10
+ report(new Error(message), sessionId);
11
+ }
12
+ catch {
13
+ }
14
+ };
15
+ return {
16
+ issue: (sessionId, what, start) => {
17
+ if (closedAt !== undefined) {
18
+ const message = `session "${sessionId}": a ${what} write was issued after its leg ended and was not started`;
19
+ tell(sessionId, message);
20
+ return Promise.reject(new SessionError("conflict", message));
21
+ }
22
+ let write;
23
+ try {
24
+ write = Promise.resolve(start());
25
+ }
26
+ catch (err) {
27
+ return Promise.reject(err);
28
+ }
29
+ this.#add(sessionId, write);
30
+ const settledLate = (outcome) => {
31
+ this.#remove(sessionId, write);
32
+ if (closedAt !== undefined)
33
+ tell(sessionId, `session "${sessionId}": a ${what} write issued by a leg that has since ended settled ${Date.now() - closedAt}ms after the leg ended — ${outcome}`);
34
+ };
35
+ write.then(() => settledLate("it landed"), (err) => settledLate(`it failed: ${thrownText(err)}`));
36
+ return write;
37
+ },
38
+ close: () => {
39
+ closedAt ??= Date.now();
40
+ },
41
+ };
42
+ }
43
+ async settleBeforeHold(sessionId, ms) {
44
+ if (await this.drained(sessionId, ms))
45
+ return;
46
+ throw new SessionError("conflict", `session "${sessionId}": a write an earlier leg of this session issued has not settled after ${ms}ms — this leg wrote nothing; retry once it settles`);
47
+ }
48
+ busy(sessionId) {
49
+ return (this.#inFlight.get(sessionId)?.size ?? 0) > 0;
50
+ }
51
+ drained(sessionId, ms) {
52
+ if (!this.busy(sessionId))
53
+ return Promise.resolve(true);
54
+ return new Promise((resolve) => {
55
+ const waiters = this.#drainWaiters.get(sessionId) ?? new Set();
56
+ this.#drainWaiters.set(sessionId, waiters);
57
+ const done = () => {
58
+ clearTimeout(timer);
59
+ waiters.delete(done);
60
+ if (waiters.size === 0 && this.#drainWaiters.get(sessionId) === waiters)
61
+ this.#drainWaiters.delete(sessionId);
62
+ resolve(true);
63
+ };
64
+ const timer = setTimeout(() => {
65
+ waiters.delete(done);
66
+ if (waiters.size === 0 && this.#drainWaiters.get(sessionId) === waiters)
67
+ this.#drainWaiters.delete(sessionId);
68
+ resolve(false);
69
+ }, ms);
70
+ waiters.add(done);
71
+ });
72
+ }
73
+ #add(sessionId, write) {
74
+ const set = this.#inFlight.get(sessionId) ?? new Set();
75
+ set.add(write);
76
+ this.#inFlight.set(sessionId, set);
77
+ }
78
+ #remove(sessionId, write) {
79
+ const set = this.#inFlight.get(sessionId);
80
+ if (set === undefined)
81
+ return;
82
+ set.delete(write);
83
+ if (set.size > 0)
84
+ return;
85
+ this.#inFlight.delete(sessionId);
86
+ for (const wake of [...(this.#drainWaiters.get(sessionId) ?? [])])
87
+ wake();
88
+ }
89
+ }
90
+ export function writesThroughLeg(storage, leg, sessionId) {
91
+ return new Proxy(storage, {
92
+ get(target, prop, receiver) {
93
+ if (prop === "appendEntry")
94
+ return (...args) => leg.issue(sessionId, args[0].type, () => target.appendEntry(...args));
95
+ if (prop === "setLeafId")
96
+ return (...args) => leg.issue(sessionId, "leaf", () => target.setLeafId(...args));
97
+ const value = Reflect.get(target, prop, receiver);
98
+ return typeof value === "function" ? value.bind(target) : value;
99
+ },
100
+ });
101
+ }
@@ -1,5 +1,5 @@
1
- import { errorCodeOf, thrownFailureOf } from "./terminal-account.js";
2
- import { reopenReasonOf, resumeStartupCauseOf } from "../resume-startup-cause.js";
1
+ import { thrownFailureOf } from "./terminal-account.js";
2
+ import { compensateUnstarted, reopenReasonOf, resumeStartupCauseOf, unstartedRowSentence } from "../resume-startup-cause.js";
3
3
  import { resumeDecisionWasNegative } from "./decide-continuation.js";
4
4
  import { drainForwardedFramesBeforeDone, forwardsSubagentEvents } from "./prepare-run-refs.js";
5
5
  import { hasDestroy } from "../remote-env.js";
@@ -13,23 +13,20 @@ export function streamSettleBackstop(input) {
13
13
  const onRunRejected = async (err) => {
14
14
  let { code, message, detail } = thrownFailureOf(err, thrownText(err));
15
15
  const reopenReason = reopenReasonOf(resumeStartupCauseOf(code));
16
- const reopenable = resume !== undefined && resume.pendingActionStarted !== true && reopenReason !== undefined && !(resumeDecisionWasNegative(resume) && resume.decisionDelivered === true);
16
+ const reopenable = resume !== undefined && live.resultValue === undefined && resume.pendingActionStarted !== true && !(resumeDecisionWasNegative(resume) && resume.decisionDelivered === true);
17
17
  let reopenCommitted = false;
18
18
  let reopenStateUnknown = false;
19
- if (reopenable && resume?.onEnvRestoreFailed) {
20
- try {
21
- await resume.onEnvRestoreFailed(reopenReason);
19
+ if (reopenable && resume !== undefined) {
20
+ const row = await compensateUnstarted(resume.reopenUnstarted, reopenReason);
21
+ if (row.kind === "reopened") {
22
22
  reopenCommitted = true;
23
+ message = `${message} — ${unstartedRowSentence(row)}`;
23
24
  }
24
- catch (reopenErr) {
25
+ else {
25
26
  parentConstraintRegistry.delete(resume.cp.token);
26
27
  const original = asThrownError(err);
27
- const reopenMsg = thrownText(reopenErr);
28
- const definitive = errorCodeOf(reopenErr) === "checkpoint.reopen_failed";
29
- reopenStateUnknown = !definitive;
30
- err = Object.assign(new Error(definitive
31
- ? `${reopenMsg} (original resume failure: ${original.message})`
32
- : `checkpoint reopen threw mid-flight — state UNKNOWN, confirm via the checkpoint store before retrying: ${reopenMsg} (original resume failure: ${original.message})`, { cause: original }), { code: "checkpoint.reopen_failed" });
28
+ reopenStateUnknown = row.kind === "unknown";
29
+ err = Object.assign(new Error(`${original.message} — ${unstartedRowSentence(row)}`, { cause: original }), { code: "checkpoint.reopen_failed" });
33
30
  const replacement = thrownFailureOf(err, thrownText(err));
34
31
  code = replacement.code;
35
32
  message = replacement.message;
@@ -38,7 +35,7 @@ export function streamSettleBackstop(input) {
38
35
  }
39
36
  if (resume)
40
37
  locallyClaimedTokens.delete(resume.cp.token);
41
- if (resume && !reopenCommitted) {
38
+ if (resume && !reopenCommitted && live.resultValue === undefined) {
42
39
  parentConstraintRegistry.delete(resume.cp.token);
43
40
  await settleTeardownLeg(() => sessions.unpin?.(resume.cp.sessionId), "sessions.unpin (resume-failure leg)", (e) => runner.deps.onError?.(e, { phase: "config", sessionId: resume.cp.sessionId }));
44
41
  if (!reopenStateUnknown) {
@@ -36,7 +36,7 @@
36
36
  import type { AgentTool } from "../../internal/harness.js";
37
37
  import { valveLeaves } from "../../agents/tool-filter.js";
38
38
  import { type ProtocolId } from "../protocol-table.js";
39
- import type { ToolLegKind, ToolSelectorLayer } from "../tool-face.js";
39
+ import type { ToolLegKind, ToolSelector, ToolSelectorLayer } from "../tool-face.js";
40
40
  import { type ConstraintChainEntry } from "../tool-policy.js";
41
41
  import type { TaskSpec } from "../types.js";
42
42
  import type { CheckpointErrorReason } from "../checkpoint-store.js";
@@ -87,6 +87,27 @@ export type PersistedToolFaceReason = Extract<CheckpointErrorReason, "not_a_list
87
87
  * leg's roster and a sink; the leg's own policy-name audit is what reads them.
88
88
  */
89
89
  export declare function deniedToolNamesOf(where: string, value: unknown): string[];
90
+ /**
91
+ * Whose lists a run's own layer are, in the words every sentence about them uses: the delegation tool (and agent definition) that wrote
92
+ * them when the run records one (`RunInternals.ownToolLists`), else `undefined` — the run's own `TaskSpec` seats.
93
+ */
94
+ export declare function ownListsWhereOf(ownBy: RunInternals["ownToolLists"]): string | undefined;
95
+ /**
96
+ * THE build of a leg's tool selector: `layers` are the ceiling it was spawned under, then its own lists (the last is its own), and
97
+ * `legs` the kinds of leg it is. Every layer is read by the one layer reader ({@link readSelectorLayer}), once, whoever judged it and
98
+ * whatever evidence the run carries — a live ceiling and the run's own lists were judged by the engine that wrote them, which may have
99
+ * read what this one cannot (a list that is not one, a member that is not a string, an entry no rule syntax reads), so the leg does not
100
+ * start without a layer that says something. The selector is compiled from what was read, never from the layers again: a getter that
101
+ * answers differently the second time is not asked a second time, and the selector's layers (handed to the leg's children as their
102
+ * ceiling) are the frozen product. Built before anything reads it, and before the session is acquired, so a refusal needs nothing given
103
+ * back. `where` is whose lists the own layer is ({@link ownListsWhereOf}). (A ceiling a resumed row restored was read by the same reader
104
+ * before the claim — `persistedToolNamesRefusal`.)
105
+ */
106
+ export declare function readToolSelector(input: {
107
+ readonly layers: readonly unknown[];
108
+ readonly where: string | undefined;
109
+ readonly legs: readonly ToolLegKind[];
110
+ }): ToolSelector;
90
111
  /**
91
112
  * THE read-back of the tool names a checkpoint row carries, before the claim: the ceiling the resumed leg will run under when it is
92
113
  * the row's (`ceiling`: absent when a live seat hands one) — each layer read by {@link readSelectorLayer} as a recorded layer — and
@@ -141,8 +162,9 @@ export interface RunToolListsInput {
141
162
  readonly allow: readonly string[] | undefined;
142
163
  readonly exclude: readonly string[] | undefined;
143
164
  };
144
- /** borrowed-readonly — every layer of the run's selector (the ceiling, then its own) and the kinds of leg it is. */
145
- layers: readonly ToolSelectorLayer[];
165
+ /** borrowed-readonly — the run's selector, as {@link readToolSelector} built it: every layer of it (the ceiling, then its own) already read, and judged here as read. */
166
+ selector: ToolSelector;
167
+ /** The kinds of leg the run is (the ones the selector was built for). */
146
168
  legs: readonly ToolLegKind[];
147
169
  /** True ⇔ the spawning run's prepare judged exactly these own lists where they were mounted, against a pool it could list (as the
148
170
  * child-facing lists of the delegation tool or definition that wrote them) — the evidence digest it handed down (live, or recorded
@@ -150,14 +150,31 @@ function readSelectorLayer(layer, layerWhere, listWhere, recorded) {
150
150
  if (!isToolSelectorLayer(layer)) {
151
151
  throw refused(`${layerWhere} are a value that is ${valueTypeLabel(layer)}, not a pair of tool-name lists (an allowed and a denied list) — the leg does not start. Fix the layer.`, "config.tool_face_control", "not_a_list");
152
152
  }
153
+ const lists = {};
153
154
  for (const side of ["allowed", "denied"]) {
154
155
  const where = listWhere(side);
155
- const entries = readableToolNameList(where, side, side === "allowed" ? layer.allow : layer.deny, "config.tool_face_control");
156
+ const value = side === "allowed" ? layer.allow : layer.deny;
157
+ const entries = readableToolNameList(where, side, value, "config.tool_face_control");
156
158
  const written = recorded ? entries.find((read) => !isCanonicalToolName(read.entry)) : undefined;
157
159
  if (written !== undefined) {
158
160
  throw refused(`${where} declares ${renderListEntry(written.entry)} in its ${LIST_WORD[side]}: a row records each tool name in its bare spelling (\`Read\`, never \`Read()\`, \`Read(*)\` or \`Read(…)\`), and this entry was recorded by an engine that read the list otherwise — it is read here neither as that engine read it nor as this one would`, "config.tool_face_control", "unsupported_pattern");
159
161
  }
162
+ if (value !== undefined && value !== null)
163
+ lists[side] = Object.freeze(entries.map((read) => read.entry));
160
164
  }
165
+ return Object.freeze({ ...(lists.allowed !== undefined ? { allow: lists.allowed } : {}), deny: lists.denied ?? Object.freeze([]) });
166
+ }
167
+ export function ownListsWhereOf(ownBy) {
168
+ return ownBy !== undefined ? delegationListWhere(ownBy.toolName, ownBy.definition) : undefined;
169
+ }
170
+ export function readToolSelector(input) {
171
+ const layers = [...input.layers];
172
+ const ceilings = layers.length - 1;
173
+ const read = layers.map((layer, i) => {
174
+ const inherited = i === ceilings ? undefined : inheritedListsWhere(ceilings, i);
175
+ return readSelectorLayer(layer, inherited ?? "this run's own tool lists", (side) => inherited ?? input.where ?? (side === "allowed" ? "TaskSpec.allowTools" : "TaskSpec.excludeTools"), false);
176
+ });
177
+ return compileToolSelector(read, input.legs);
161
178
  }
162
179
  function ownToolListsFlaw(value) {
163
180
  try {
@@ -255,14 +272,9 @@ export function judgeRunToolLists(input) {
255
272
  catch {
256
273
  }
257
274
  };
258
- const ownWhere = input.ownBy !== undefined ? delegationListWhere(input.ownBy.toolName, input.ownBy.definition) : undefined;
259
- const ceilings = input.layers.length - 1;
260
- input.layers.forEach((layer, i) => {
261
- const own = i === ceilings;
262
- const inherited = own ? undefined : inheritedListsWhere(ceilings, i);
263
- readSelectorLayer(layer, inherited ?? "this run's own tool lists", (side) => inherited ?? ownWhere ?? (side === "allowed" ? "TaskSpec.allowTools" : "TaskSpec.excludeTools"), false);
264
- });
265
- const denied = deniedProtocolTools(input.layers, input.legs);
275
+ const ownWhere = ownListsWhereOf(input.ownBy);
276
+ const selector = input.selector;
277
+ const denied = deniedProtocolTools(selector.layers, input.legs);
266
278
  if (denied.length > 0) {
267
279
  const names = [...new Set(denied.map((h) => `"${h.name}"`))];
268
280
  const one = names.length === 1;
@@ -273,7 +285,6 @@ export function judgeRunToolLists(input) {
273
285
  const by = [...deniedBy(true, ownWhere ?? "this run's own excludeTools"), ...deniedBy(false, "an inherited list (the spawning run's excludeTools, or one it inherits)")];
274
286
  throw refused(`This kind of leg (${input.legs.join(", ")}) relies on ${names.join(", ")}, but ${by.join(" and ")} — the leg cannot work without ${one ? "it" : "them"}. Remove the entry from the list that names it.`, "config.tool_face_control", "protocol_denied");
275
287
  }
276
- const selector = compileToolSelector(input.layers, input.legs);
277
288
  const pool = delegationPoolReading(spec.tools ?? [], valveLeaves(spec, selector));
278
289
  const mounted = mountedToolNames([...tools, ...(spec.tools ?? [])]);
279
290
  if (!input.judgedUpstream) {
@@ -27,6 +27,7 @@
27
27
  export declare const TEARDOWN_LEG_MAX_MS = 15000;
28
28
  /** Test hook (fs-atomic TxnLockTimings precedent): shrink the budget so wedge pins need no real 15s. */
29
29
  export declare function setTeardownLegBudgetForTests(ms: number | undefined): void;
30
+ export declare const teardownLegBudget: () => number;
30
31
  /** The typed timeout incident — `leg` names the site so a leak is attributable from the report alone. */
31
32
  export declare class TeardownLegTimeoutError extends Error {
32
33
  readonly leg: string;
@@ -4,6 +4,7 @@ let teardownLegBudgetMs = TEARDOWN_LEG_MAX_MS;
4
4
  export function setTeardownLegBudgetForTests(ms) {
5
5
  teardownLegBudgetMs = ms ?? TEARDOWN_LEG_MAX_MS;
6
6
  }
7
+ export const teardownLegBudget = () => teardownLegBudgetMs;
7
8
  export class TeardownLegTimeoutError extends Error {
8
9
  leg;
9
10
  constructor(leg, budgetMs) {
@@ -4,6 +4,7 @@ import { isProviderCondition, isProviderConditionSource } from "../../brain/prov
4
4
  import { admittedRequestRoute } from "../../brain/request-route.js";
5
5
  import { readMember } from "../thrown-value.js";
6
6
  import { egressText } from "../untrusted-egress.js";
7
+ import { REDACTION_MARK } from "../redaction-marks.js";
7
8
  import { isSensitiveName, looksLikeCredentialValue } from "../secret-env.js";
8
9
  import { isSensitiveRecordKey } from "../credential-vocabulary.js";
9
10
  export function providerVerdictOf(final) {
@@ -38,7 +39,6 @@ const CODED_DETAIL_ENTRIES = 64;
38
39
  const CODED_DETAIL_STRING = 4_096;
39
40
  const CODED_DETAIL_VALUES = 256;
40
41
  const CODED_DETAIL_CHARS = 16_384;
41
- const REDACTED = "[redacted]";
42
42
  const INDEX_KEY_RE = /^(?:0|[1-9][0-9]*)$/;
43
43
  function carriesCredential(text) {
44
44
  return looksLikeCredentialValue(text) || egressText("same-principal", text) !== text;
@@ -58,14 +58,14 @@ function charge(budget, chars) {
58
58
  }
59
59
  function leafOf(keyContext, read, depth, budget) {
60
60
  if (keyContext !== undefined && namesCredential(keyContext))
61
- return charge(budget, REDACTED.length) ? REDACTED : undefined;
61
+ return charge(budget, REDACTION_MARK.length) ? REDACTION_MARK : undefined;
62
62
  const value = read();
63
63
  if (value === null || typeof value === "boolean" || (typeof value === "number" && Number.isFinite(value)))
64
64
  return charge(budget, 0) ? value : undefined;
65
65
  if (typeof value === "string") {
66
66
  if (value.length > CODED_DETAIL_STRING)
67
67
  return undefined;
68
- const shown = carriesCredential(value) ? REDACTED : value;
68
+ const shown = carriesCredential(value) ? REDACTION_MARK : value;
69
69
  return charge(budget, shown.length) ? shown : undefined;
70
70
  }
71
71
  if (typeof value !== "object" || depth >= CODED_DETAIL_DEPTH)
@@ -77,6 +77,7 @@ export function emitSettled(table, start, end, frames) {
77
77
  ...toolEndBodyFrom(end.result, isError, frames, gate, end.gatedCallIdOfRun),
78
78
  ...(gate?.disposition.kind === "denied" && occ.wireName !== undefined ? { wireName: occ.wireName } : {}),
79
79
  ...(notExecuted ? { notExecuted: true } : {}), ...(occ.answeredInPlaceBy !== undefined ? { answeredBy: occ.answeredInPlaceBy } : {}), ...(occ.requestedBy !== undefined ? { requestedBy: occ.requestedBy } : {}),
80
+ ...(occ.rewrite !== undefined && !notExecuted ? { rewrite: occ.rewrite } : {}),
80
81
  });
81
82
  return { ...(gate !== undefined ? { gate } : {}), isError, ...(notExecuted ? { notExecuted: true } : {}) };
82
83
  }
@@ -68,6 +68,9 @@ export interface ToolOccurrence extends OccurrenceStart {
68
68
  /** An extension at `tool.call` answered for the call in place of its body — its result, or its refusal — and named here:
69
69
  * the body was never called (positive evidence the call did not run). Absent: no station answered in its place. */
70
70
  readonly answeredInPlaceBy?: string;
71
+ /** The latest gate exit's record of a rewrite (`tool_end.rewrite`): the args it let the call go with and who replaced them,
72
+ * when they are not the ones it took. Each gate round writes it (a round without one clears it). */
73
+ readonly rewrite?: import("../task-event.js").ToolInputRewrite;
71
74
  }
72
75
  /** The table of one leg's occurrences — the record's only writer. */
73
76
  export interface ToolOccurrenceTable {
@@ -87,7 +90,7 @@ export interface ToolOccurrenceTable {
87
90
  /** The engine lets the call go to its executor — the one transition into `released`, whichever leg makes it. */
88
91
  release(toolCallId: string): void;
89
92
  /** A gate exit for this call: its record and the input it decided on (frozen by the gate's exit). */
90
- gateRound(toolCallId: string, outcome: GateOutcome, finalInput?: unknown): void;
93
+ gateRound(toolCallId: string, outcome: GateOutcome, finalInput?: unknown, rewrite?: import("../task-event.js").ToolInputRewrite): void;
91
94
  /** A station after the gate refused the call: one more gate record, minted as a veto of whatever the latest one
92
95
  * settled (a person's yes stays on the settlement; the refusing layer is the disposition). Returns the record. */
93
96
  refuse(toolCallId: string, layer: DeniedBy): GateOutcome;
@@ -84,11 +84,12 @@ export function createToolOccurrenceTable() {
84
84
  throw new Error(`tool occurrence: call "${toolCallId}" (attempt ${occ.attempt}) cannot be released from "${occ.life}"`);
85
85
  occ.life = "released";
86
86
  },
87
- gateRound(toolCallId, outcome, finalInput) {
87
+ gateRound(toolCallId, outcome, finalInput, rewrite) {
88
88
  const occ = held(toolCallId, "a gate round");
89
89
  occ.gateRounds.push(outcome);
90
90
  if (finalInput !== undefined)
91
91
  occ.finalInput = finalInput;
92
+ occ.rewrite = rewrite;
92
93
  },
93
94
  refuse(toolCallId, layer) {
94
95
  const occ = held(toolCallId, "a refusal");
@@ -25,7 +25,7 @@ import type { RunnerDeps } from "../runner-deps.js";
25
25
  import type { TaskSpec } from "../task-spec.js";
26
26
  import type { ToolRoster } from "../tool-roster.js";
27
27
  import type { ToolPolicy } from "../tool-policy.js";
28
- import { type WriteProtectionMount } from "../write-protect.js";
28
+ import { type ExemptFile, type ManagedCheckoutView, type WriteProtectionMount } from "../write-protect.js";
29
29
  import type { ShellReadBoundary } from "../../tools/fs/shell-read-judge.js";
30
30
  /** The leg's write judgment, read by its two readers: the gate's tighten over the always-on table (`mount`, absent when that
31
31
  * table is empty) and the shell station's ONE question about each write target a command names (`judgeWriteTarget`, over
@@ -35,10 +35,16 @@ export interface LegWriteProtection {
35
35
  readonly judgeWriteTarget: ShellReadBoundary["writeTargetJudge"];
36
36
  }
37
37
  /** The leg's write-guard seats: its one exempt root (the leg's single resolution of `RunnerDeps.memoryEngineDir`, the same
38
- * list every policy adjudication of the leg is stamped with) and the chain policies' guarded write rows. */
38
+ * list every policy adjudication of the leg is stamped with), the chain policies' guarded write rows, and the leg's current
39
+ * managed tree (`checkout`, read per judgment off the leg's one write-location reader — the write judgment's current-tree
40
+ * reading, `WriteProtectionCompileOptions.checkoutOf`). */
39
41
  export interface LegWriteGuard {
40
42
  readonly exemptRoots: readonly string[];
43
+ /** The engine's own files the table does not demote — the session plan file as the advertised-writable seat admitted it
44
+ * (absent when none was declared). */
45
+ readonly exemptFiles?: readonly ExemptFile[];
41
46
  readonly rows: ToolPolicy["writeGuardRows"];
47
+ readonly checkout?: () => ReadonlyArray<ManagedCheckoutView> | undefined;
42
48
  }
43
49
  export declare function mountWriteProtection(input: {
44
50
  /** borrowed-readonly — the deployment seats: the table (`writeProtectedPaths`; absent ⇒ the default
@@ -7,7 +7,9 @@ export function mountWriteProtection(input) {
7
7
  const announced = new Set();
8
8
  const judgment = compileLegWriteJudgment(unionAddOnly("writeProtectedAdditions", resolveWriteProtectedTable(input.deps.writeProtectedPaths), input.spec.writeProtectedAdditions), {
9
9
  exemptRoots: input.guard.exemptRoots,
10
+ ...(input.guard.exemptFiles !== undefined ? { exemptFiles: input.guard.exemptFiles } : {}),
10
11
  ...(input.guard.rows !== undefined ? { guardRows: input.guard.rows } : {}),
12
+ ...(input.guard.checkout !== undefined ? { checkoutOf: input.guard.checkout } : {}),
11
13
  ...(input.deps.agentConfigDir !== undefined ? { agentConfigDir: input.deps.agentConfigDir } : {}),
12
14
  ...(input.env !== undefined ? { env: input.env } : {}),
13
15
  rootPath: input.rootPath,
@@ -140,10 +140,10 @@ export interface RunnerDeps {
140
140
  * notice (a resume re-materializes and may announce again — the standing condition is re-news at
141
141
  * each fresh mount, never per-call). The notice is a deployment wiring fact: `detail: { message }`
142
142
  * only, no session attribution, `"operator"` audience by its explicit {@link NOTICE_AUDIENCE} row — a wire projector
143
- * forwards it operator-tier and needs no per-session de-duplication of its own.
144
- * The probe's second argument, `{ fingerprint }`, is passed exactly when the server's declaration carries one.
143
+ * forwards it operator-tier and needs no per-session de-duplication of its own. The probe's second argument, `{ fingerprint }`, is passed exactly when the server's declaration carries one.
145
144
  */
146
145
  mcpRevocations?: import("./mcp-server-spec.js").McpRevocationLedger;
146
+ peerSeat?: import("./peer-seat.js").PeerSeat;
147
147
  /**
148
148
  * design/147 S1c (ruled 2026-07-18) — the DURABLE name→agent roster behind explicit-name
149
149
  * addressing, a storage-tier seam like the checkpoint store: core bundles `MemoryRosterStore`
@@ -968,8 +968,8 @@ export interface RunnerDeps {
968
968
  * organization's delivery gate appends cross-principal letters; the mailbox contract's fourth chain).
969
969
  * Absent = no consumer, no lane (byte for byte as before); a deployment that mounts a gate DECLARES
970
970
  * `{ assistant: "<agent handle>" }` (the scope's assistant is the only consumer; no terminal leg touches the
971
- * box). `"terminals"` (each terminal drains the box as a second lane) is refused until held decisions are
972
- * shared across terminals (`detail.reason: "terminals_unsupported"`). Letters are judged on the principal's
971
+ * box) or `"terminals"` (each terminal drains the box as a second lane; a held letter's decision is the
972
+ * letter's own field in the box, so every terminal reads the same one). Letters are judged on the principal's
973
973
  * `crossSessionInbound` layers (managed, user), held when unset. ANY other value fails the prepare of a leg
974
974
  * that drains a session box with `config.principal_inbox_consumer_invalid` (`detail.reason: "malformed"`).
975
975
  */
@@ -61,6 +61,10 @@ export interface WithheldEnvDeclaration {
61
61
  * a flag or placeholder word, one character repeated, or fewer than eight characters. */
62
62
  readonly values: readonly string[];
63
63
  }
64
+ /** {@link notACredentialReason}'s answer as a yes: the same guess for the second place that pays for withholding a string — every
65
+ * occurrence of a request's key taken out of a remote's words (`remoteWords`): a key that names no secret (`EMPTY`, a local gateway's
66
+ * one-letter key) is left in the words, as it is left to every child. */
67
+ export declare function namesASecret(value: string): boolean;
64
68
  /**
65
69
  * Declare this deployment's OWN credentials in this process's environment — the engine's or its host's: an approval
66
70
  * bearer, a service token — by name and by value. From then on no child spawned on this host inherits one, whatever the
@@ -209,6 +209,9 @@ function notACredentialReason(value) {
209
209
  return "one character repeated, which names no secret";
210
210
  return undefined;
211
211
  }
212
+ export function namesASecret(value) {
213
+ return notACredentialReason(value) === undefined;
214
+ }
212
215
  function credentialValueProblem(v) {
213
216
  if (typeof v !== "string")
214
217
  return kindOf(v);
@@ -3,7 +3,7 @@ import { isAbsolute, join, resolve } from "node:path";
3
3
  import { anchorSpelling, canonicalizeTarget, expandHomeTilde, isAbsoluteForFamily, isWinFormPath, pathFamilyOf, writeTargetPath } from "../tools/fs/safety.js";
4
4
  import { spelledExemptionOf } from "./write-protect.js";
5
5
  import { compileSegmentPattern, READ_FACE_BUILTIN_DENY_TABLE, readDenyPatternRun, segmentGuardRow } from "../tools/fs/read-deny.js";
6
- import { judgePathRows } from "./path-guard-rows.js";
6
+ import { guardHitReachClause, guardHitVia, judgePathRows } from "./path-guard-rows.js";
7
7
  import { agentConfigDirSegments, agentConfigDirTail, checkedAgentConfigDir } from "./agent-config-dir.js";
8
8
  import { isProtectedWrite, protectivePathTargetOf } from "./tool-registry.js";
9
9
  import { pathTargetBaseOf } from "./effective-path-target.js";
@@ -182,7 +182,7 @@ export function createSensitivePathPolicy(opts) {
182
182
  return { kind: "clear" };
183
183
  if (hit.unreadable !== undefined)
184
184
  return { kind: "unresolved", cause: hit.unreadable };
185
- return { kind: "hit", pattern: hit.row.name, via: hit.viewKind === "hop" ? "chain" : hit.viewKind === "canonical" ? "target" : "spelling" };
185
+ return { kind: "hit", pattern: hit.row.name, via: guardHitVia(hit.viewKind) };
186
186
  };
187
187
  return {
188
188
  ...(compiled.length > 0 ? { writeGuardRows: (at) => rowsOf(at.env, at.signal) } : {}),
@@ -200,13 +200,12 @@ export function createSensitivePathPolicy(opts) {
200
200
  return { action: "deny", message: `write to "${path}" is refused (target_unresolved): where it leads on disk could not be determined, so the sensitive-path list cannot tell whether it is a guarded path — ${judged.cause}`, decisionReason: "safety" };
201
201
  }
202
202
  if (judged.kind === "hit") {
203
+ const reach = guardHitReachClause(judged.via);
203
204
  return {
204
205
  action: "deny",
205
- message: judged.via === "target"
206
- ? `write to "${path}" is blocked: its real target resolves onto the guarded sensitive path "${judged.pattern}"`
207
- : judged.via === "chain"
208
- ? `write to "${path}" is blocked: its symlink chain passes through the guarded sensitive path "${judged.pattern}"`
209
- : `write to "${path}" is blocked: its path names the guarded sensitive path "${judged.pattern}"`,
206
+ message: reach === undefined
207
+ ? `write to "${path}" is blocked: its path names the guarded sensitive path "${judged.pattern}"`
208
+ : `write to "${path}" is blocked: the guarded sensitive path "${judged.pattern}" — ${reach}`,
210
209
  decisionReason: "safety",
211
210
  };
212
211
  }
@@ -0,0 +1,24 @@
1
+ import { type SessionHead, type SessionRowExpectation, type SessionRowRead, type SessionTreeEntry } from "../internal/harness.js";
2
+ import type { SessionLogTransfer } from "./session.js";
3
+ /**
4
+ * What a store's {@link SessionLogTransfer} reads and writes through: the repo's one read of a row (metadata, head and log of one
5
+ * generation) and its conditional import (judged against the row as that read answered it, in the import's own step, answering the head
6
+ * it wrote), and the store's own hold of an id — the one gate its other row writers (acquire, register, release) wait on, which also drops
7
+ * the store's cached view of the id so the view a commit replaces is not served again. Writers the hold does not see (another instance,
8
+ * a write straight through the repo) are met by the import's expectation instead.
9
+ */
10
+ export interface LogTransferSeat {
11
+ readRow(sessionId: string): Promise<SessionRowRead | undefined>;
12
+ importEntries(sessionId: string, owner: string | undefined, entries: SessionTreeEntry[], options: {
13
+ preserveActorAssertions?: boolean;
14
+ expect: SessionRowExpectation;
15
+ }): Promise<SessionHead>;
16
+ holding<T>(sessionId: string, work: () => Promise<T>): Promise<T>;
17
+ }
18
+ /**
19
+ * The {@link SessionLogTransfer} of a store over a repo that holds each log whole: reads are the repo's row read, a staging lives in this
20
+ * process until its commit, and a commit is the repo's conditional import under the store's hold of the id — the import itself judging,
21
+ * in the step that replaces the log, the write law (`importRowCells`: an existing row must already be the committer's; a placed row is
22
+ * refused) and that the row is still the one the commit read (its head, log included), and answering the head it wrote.
23
+ */
24
+ export declare function repoLogTransfer(seat: LogTransferSeat): SessionLogTransfer;