@sema-agent/core 7.72.0 → 7.73.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 (256) hide show
  1. package/CHANGELOG.md +319 -0
  2. package/dist/agents/inherited-tool-pool.d.ts +26 -1
  3. package/dist/agents/inherited-tool-pool.js +46 -2
  4. package/dist/agents/parked-resume-drive.d.ts +10 -0
  5. package/dist/agents/parked-resume-drive.js +9 -0
  6. package/dist/agents/retain-ledger.d.ts +3 -0
  7. package/dist/agents/send-message-tool.js +1 -0
  8. package/dist/agents/send-user-message-tool.d.ts +12 -0
  9. package/dist/agents/send-user-message-tool.js +67 -0
  10. package/dist/agents/subagent-steps.d.ts +9 -0
  11. package/dist/agents/subagent-steps.js +38 -0
  12. package/dist/agents/subagent.d.ts +2 -0
  13. package/dist/agents/subagent.js +43 -12
  14. package/dist/agents/verify.js +23 -8
  15. package/dist/agents/yield-adoption.js +3 -1
  16. package/dist/brain/anthropic.js +14 -9
  17. package/dist/brain/open-responses.js +4 -5
  18. package/dist/brain/openai.js +30 -23
  19. package/dist/brain/stream-engine.js +159 -151
  20. package/dist/core/actions-digest.d.ts +43 -0
  21. package/dist/core/actions-digest.js +22 -0
  22. package/dist/core/allow-entry.js +3 -3
  23. package/dist/core/auto-mode.d.ts +7 -9
  24. package/dist/core/auto-mode.js +114 -8
  25. package/dist/core/checkpoint-features.d.ts +3 -2
  26. package/dist/core/checkpoint-features.js +1 -1
  27. package/dist/core/checkpoint-rekey.d.ts +1 -1
  28. package/dist/core/checkpoint-rekey.js +6 -1
  29. package/dist/core/checkpoint-requirements.d.ts +23 -3
  30. package/dist/core/checkpoint-requirements.js +5 -1
  31. package/dist/core/checkpoint-row-verdict.js +7 -1
  32. package/dist/core/checkpoint-store.d.ts +24 -2
  33. package/dist/core/checkpoint-store.js +1 -0
  34. package/dist/core/child-clamp-seats.d.ts +15 -0
  35. package/dist/core/child-clamp-seats.js +15 -0
  36. package/dist/core/delegation-frames.d.ts +1 -0
  37. package/dist/core/delegation-frames.js +1 -1
  38. package/dist/core/engine-capabilities.d.ts +5 -1
  39. package/dist/core/engine-capabilities.js +1 -1
  40. package/dist/core/engine-notice.d.ts +30 -22
  41. package/dist/core/engine-version.js +1 -1
  42. package/dist/core/entries-not-applied.d.ts +19 -7
  43. package/dist/core/entries-not-applied.js +33 -1
  44. package/dist/core/governance-codes.d.ts +7 -1
  45. package/dist/core/governance-codes.js +13 -5
  46. package/dist/core/hooks.d.ts +3 -0
  47. package/dist/core/hooks.js +1 -0
  48. package/dist/core/host-instance.d.ts +23 -0
  49. package/dist/core/host-instance.js +69 -0
  50. package/dist/core/instruction-preview.d.ts +63 -0
  51. package/dist/core/instruction-preview.js +406 -0
  52. package/dist/core/leg-budget.d.ts +26 -0
  53. package/dist/core/leg-budget.js +9 -0
  54. package/dist/core/leg-identity.d.ts +51 -1
  55. package/dist/core/leg-identity.js +45 -2
  56. package/dist/core/manager-launch-check.d.ts +48 -0
  57. package/dist/core/manager-launch-check.js +64 -0
  58. package/dist/core/mcp-call-meta.d.ts +2 -2
  59. package/dist/core/mcp-injection-drop.d.ts +20 -10
  60. package/dist/core/mcp-injection-drop.js +9 -3
  61. package/dist/core/mcp-server-spec.d.ts +2 -1
  62. package/dist/core/member-outcome.d.ts +3 -2
  63. package/dist/core/member-outcome.js +1 -1
  64. package/dist/core/memory-engine/deletion-record.d.ts +46 -0
  65. package/dist/core/memory-engine/deletion-record.js +96 -0
  66. package/dist/core/memory-engine/engine.js +24 -16
  67. package/dist/core/memory-engine/file-backend.js +7 -5
  68. package/dist/core/memory-engine/projection-ledger.d.ts +1 -1
  69. package/dist/core/memory-engine/projection-ledger.js +1 -1
  70. package/dist/core/memory-engine/scope-contract.d.ts +18 -13
  71. package/dist/core/memory-engine/scope-contract.js +18 -18
  72. package/dist/core/memory-engine/sync-client.js +26 -6
  73. package/dist/core/memory-engine/sync.d.ts +20 -2
  74. package/dist/core/memory-engine/sync.js +18 -17
  75. package/dist/core/mode-policy.d.ts +21 -6
  76. package/dist/core/mode-policy.js +15 -6
  77. package/dist/core/own-property-receipt.js +11 -4
  78. package/dist/core/parent-spec-seat.d.ts +13 -11
  79. package/dist/core/parent-spec-seat.js +13 -9
  80. package/dist/core/peer-seat.js +3 -3
  81. package/dist/core/peer-task-store.d.ts +365 -0
  82. package/dist/core/peer-task-store.js +682 -0
  83. package/dist/core/permission-rule-consent.js +6 -11
  84. package/dist/core/permission-rule-model.d.ts +27 -0
  85. package/dist/core/permission-rule-model.js +33 -5
  86. package/dist/core/permission-rule-provider.d.ts +35 -33
  87. package/dist/core/permission-rule-provider.js +38 -295
  88. package/dist/core/permission-rule-store.d.ts +181 -8
  89. package/dist/core/permission-rule-store.js +420 -17
  90. package/dist/core/permission-rule-sync.js +15 -1
  91. package/dist/core/project-seat.d.ts +55 -0
  92. package/dist/core/project-seat.js +96 -0
  93. package/dist/core/protocol-http-auth.d.ts +3 -2
  94. package/dist/core/protocol-http-auth.js +26 -18
  95. package/dist/core/remote-env.d.ts +4 -4
  96. package/dist/core/retired-keys.js +1 -0
  97. package/dist/core/rule-offer-read.d.ts +1 -1
  98. package/dist/core/rule-offer-read.js +32 -4
  99. package/dist/core/run-ledger-seat.d.ts +66 -0
  100. package/dist/core/run-ledger-seat.js +70 -0
  101. package/dist/core/run-ledger.d.ts +332 -0
  102. package/dist/core/run-ledger.js +550 -0
  103. package/dist/core/runner/checkpoint-scope.d.ts +13 -3
  104. package/dist/core/runner/checkpoint-scope.js +12 -4
  105. package/dist/core/runner/construction-doors.js +6 -0
  106. package/dist/core/runner/contracts.d.ts +21 -5
  107. package/dist/core/runner/delegation-owner.d.ts +30 -0
  108. package/dist/core/runner/delegation-owner.js +20 -4
  109. package/dist/core/runner/finish-reason-seat.js +4 -2
  110. package/dist/core/runner/leg-frame.js +3 -0
  111. package/dist/core/runner/nested-memory-lane.d.ts +22 -5
  112. package/dist/core/runner/nested-memory-lane.js +91 -30
  113. package/dist/core/runner/person-path-rows.d.ts +21 -16
  114. package/dist/core/runner/person-path-rows.js +80 -15
  115. package/dist/core/runner/prepare-caps-and-workflow.js +98 -88
  116. package/dist/core/runner/prepare-config-doors.d.ts +1 -0
  117. package/dist/core/runner/prepare-config-doors.js +5 -3
  118. package/dist/core/runner/prepare-context-lane.js +1 -0
  119. package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
  120. package/dist/core/runner/prepare-delegation-surface.js +6 -0
  121. package/dist/core/runner/prepare-execution-env.d.ts +3 -3
  122. package/dist/core/runner/prepare-hands-readface.d.ts +5 -2
  123. package/dist/core/runner/prepare-hands-readface.js +12 -1
  124. package/dist/core/runner/prepare-inherited-gate.d.ts +6 -3
  125. package/dist/core/runner/prepare-inherited-gate.js +13 -5
  126. package/dist/core/runner/prepare-run-refs.d.ts +1 -1
  127. package/dist/core/runner/prepare-run-refs.js +3 -2
  128. package/dist/core/runner/prepare-suspend-saga.d.ts +6 -2
  129. package/dist/core/runner/prepare-suspend-saga.js +4 -2
  130. package/dist/core/runner/prepare-task.js +36 -27
  131. package/dist/core/runner/prepare-turn-wiring.d.ts +4 -3
  132. package/dist/core/runner/prepare-turn-wiring.js +2 -1
  133. package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -1
  134. package/dist/core/runner/prepare-wiring-manifest.js +5 -2
  135. package/dist/core/runner/resume-apply.js +11 -5
  136. package/dist/core/runner/resume-review-outcome.d.ts +3 -0
  137. package/dist/core/runner/resume-review-outcome.js +24 -1
  138. package/dist/core/runner/run-harness-handlers.js +3 -0
  139. package/dist/core/runner/run-identity-wiring.js +3 -2
  140. package/dist/core/runner/run-leg.js +3 -0
  141. package/dist/core/runner/run-notification-lane.js +20 -1
  142. package/dist/core/runner/run-settle-and-teardown.js +21 -12
  143. package/dist/core/runner/run-stop-and-final-verify.js +6 -0
  144. package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
  145. package/dist/core/runner/runtask.d.ts +6 -2
  146. package/dist/core/runner/runtask.js +21 -9
  147. package/dist/core/runner/shell-env-withheld.d.ts +3 -2
  148. package/dist/core/runner/shell-env-withheld.js +1 -2
  149. package/dist/core/runner/stop-tail-notice.d.ts +10 -2
  150. package/dist/core/runner/stop-tail-notice.js +9 -2
  151. package/dist/core/runner/stream-settle-backstop.d.ts +1 -0
  152. package/dist/core/runner/stream-settle-backstop.js +1 -0
  153. package/dist/core/runner/task-start-doors.js +6 -3
  154. package/dist/core/runner/terminal-account.d.ts +6 -1
  155. package/dist/core/runner/terminal-account.js +16 -1
  156. package/dist/core/runner/unreadable-person-rows.d.ts +2 -1
  157. package/dist/core/runner-deps.d.ts +13 -10
  158. package/dist/core/secret-env.d.ts +53 -37
  159. package/dist/core/secret-env.js +44 -47
  160. package/dist/core/session-checkout.d.ts +3 -0
  161. package/dist/core/session-checkout.js +1 -0
  162. package/dist/core/session-store.d.ts +12 -6
  163. package/dist/core/session-store.js +26 -6
  164. package/dist/core/session.d.ts +31 -8
  165. package/dist/core/store-contracts/checkpoint-store-contract.js +10 -0
  166. package/dist/core/store-contracts/peer-task-store-contract.d.ts +21 -0
  167. package/dist/core/store-contracts/peer-task-store-contract.js +516 -0
  168. package/dist/core/store-contracts/session-store-contract.d.ts +15 -2
  169. package/dist/core/store-contracts/session-store-contract.js +87 -3
  170. package/dist/core/store-contracts/workflow-journal-store-contract.d.ts +19 -1
  171. package/dist/core/store-contracts/workflow-journal-store-contract.js +89 -1
  172. package/dist/core/task-event.d.ts +10 -3
  173. package/dist/core/task-notification.d.ts +96 -10
  174. package/dist/core/task-notification.js +129 -5
  175. package/dist/core/task-registry-shared.d.ts +12 -1
  176. package/dist/core/task-registry-shared.js +3 -1
  177. package/dist/core/task-registry-workflow.d.ts +1 -1
  178. package/dist/core/task-registry-workflow.js +9 -1
  179. package/dist/core/task-registry.d.ts +39 -2
  180. package/dist/core/task-registry.js +76 -12
  181. package/dist/core/task-result.d.ts +13 -0
  182. package/dist/core/task-spec-members.d.ts +3 -1
  183. package/dist/core/task-spec-members.js +11 -3
  184. package/dist/core/task-spec.d.ts +48 -22
  185. package/dist/core/tool-catalog-entries.js +2 -0
  186. package/dist/core/tool-mount-facts.d.ts +1 -1
  187. package/dist/core/tool-mount-facts.js +1 -0
  188. package/dist/core/tool-mount-plan.d.ts +3 -1
  189. package/dist/core/tool-mount-plan.js +6 -0
  190. package/dist/core/tool-mount-static.d.ts +1 -1
  191. package/dist/core/tool-mount-static.js +4 -2
  192. package/dist/core/tool-result-store.d.ts +19 -2
  193. package/dist/core/tool-result-store.js +51 -2
  194. package/dist/core/tool-spec.d.ts +9 -2
  195. package/dist/core/user-attachment.d.ts +5 -1
  196. package/dist/core/user-attachment.js +14 -7
  197. package/dist/core/wiring-manifest.d.ts +26 -20
  198. package/dist/core/wiring-manifest.js +7 -3
  199. package/dist/core/workflow-journal-store.d.ts +53 -10
  200. package/dist/core/workflow-journal-store.js +27 -4
  201. package/dist/core/workflow-run-store-contract.js +16 -0
  202. package/dist/core/workflow-run-store.d.ts +9 -7
  203. package/dist/core/workflow-run-store.js +4 -1
  204. package/dist/engine/execution-env/node-execution-env.js +3 -1
  205. package/dist/engine/harness/types.d.ts +24 -1
  206. package/dist/engine/harness/types.js +10 -0
  207. package/dist/engine/llm/types.d.ts +5 -7
  208. package/dist/engine/lsp/node-lsp-manager.js +2 -1
  209. package/dist/engine/session/import-validate.js +6 -1
  210. package/dist/engine/session/session.d.ts +15 -2
  211. package/dist/engine/session/session.js +34 -4
  212. package/dist/index.d.ts +18 -7
  213. package/dist/index.js +13 -4
  214. package/dist/orchestration/run-workflow-tool.js +40 -32
  215. package/dist/orchestration/workflow-park-adoption.d.ts +51 -12
  216. package/dist/orchestration/workflow-park-adoption.js +47 -12
  217. package/dist/orchestration/workflow-stop.d.ts +128 -0
  218. package/dist/orchestration/workflow-stop.js +156 -0
  219. package/dist/orchestration/workflow.d.ts +30 -6
  220. package/dist/orchestration/workflow.js +117 -55
  221. package/dist/prompts/manager-recipe.d.ts +18 -0
  222. package/dist/prompts/manager-recipe.js +24 -0
  223. package/dist/stores/file/permission-rule-store.d.ts +3 -1
  224. package/dist/stores/file/permission-rule-store.js +0 -1
  225. package/dist/stores/file/workflow-journal-store.d.ts +16 -3
  226. package/dist/stores/file/workflow-journal-store.js +93 -5
  227. package/dist/stores/file/workflow-run-store.d.ts +1 -1
  228. package/dist/tools/fs/file-write-check.js +9 -3
  229. package/dist/tools/fs/index.d.ts +8 -7
  230. package/dist/tools/fs/index.js +4 -4
  231. package/dist/tools/fs/read-deny-home.d.ts +1 -1
  232. package/dist/tools/fs/read-deny-home.js +5 -5
  233. package/dist/tools/fs/read-deny.d.ts +33 -8
  234. package/dist/tools/fs/read-deny.js +114 -25
  235. package/dist/tools/fs/safety.d.ts +4 -1
  236. package/dist/tools/fs/safety.js +4 -2
  237. package/dist/tools/fs/shell-read-check.d.ts +9 -2
  238. package/dist/tools/fs/shell-read-check.js +96 -14
  239. package/dist/tools/fs/shell-read-establish.d.ts +9 -0
  240. package/dist/tools/fs/shell-read-establish.js +21 -11
  241. package/dist/tools/fs/shell-read-judge.d.ts +13 -1
  242. package/dist/tools/fs/shell-read-judge.js +26 -7
  243. package/dist/tools/fs/shell-read-plan.d.ts +5 -0
  244. package/dist/tools/fs/shell-read-write-targets.js +17 -9
  245. package/package.json +2 -2
  246. package/test/export-surface.snapshot.json +131 -1
  247. package/wire-changes/answers/core-stores-sql@7.73.0.json +28 -0
  248. package/wire-changes/answers/core@7.73.0.json +216 -0
  249. package/wire-changes/answers/mods-kernel@7.73.0.json +7 -0
  250. package/wire-changes/answers/primitives@7.73.0.json +12 -0
  251. package/wire-changes/answers/wiki-gate@7.73.0.json +7 -0
  252. package/wire-changes/core-stores-sql@7.73.0.json +326 -0
  253. package/wire-changes/core@7.73.0.json +6480 -0
  254. package/wire-changes/mods-kernel@7.73.0.json +147 -0
  255. package/wire-changes/primitives@7.73.0.json +227 -0
  256. package/wire-changes/wiki-gate@7.73.0.json +145 -0
@@ -28,6 +28,12 @@ export interface WriteFaceSeat {
28
28
  readonly inForce: () => ContainmentFace;
29
29
  readonly fenced: boolean;
30
30
  }
31
+ /** The two faces the children of a leg that narrowed only its own hands (`TaskSpec.ownHandsReadOnly`) are handed — resolved
32
+ * without that narrowing (`prepare-hands-readface.ts` `carriedFacesOf`). */
33
+ export interface CarriedFaces {
34
+ readonly read: ContainmentFace;
35
+ readonly write: WriteFaceSeat;
36
+ }
31
37
  import type { MaterializedA2a } from "../a2a.js";
32
38
  import type { CompactionForkContext, RapidRefillState } from "../auto-compaction.js";
33
39
  import type { AutoModeArmingRecipe } from "../auto-mode-arming.js";
@@ -373,6 +379,8 @@ export interface Prepared {
373
379
  * prepare emits run-scoped disclosures of its own and each must have a terminal that names it.
374
380
  */
375
381
  runId: string;
382
+ /** Wall-clock epoch ms minted once beside {@link runId} at prepare entry; every leg-start reader (`manifest.leg.instance.startedAt`, `task_started.startedAt`, `task.start.ts`) reads this value. */
383
+ legStartedAt: number;
376
384
  /** The deployment's host floor as the config doors compiled it (absent ⇒ none declared) — the task images' guard reads it. */
377
385
  hostFloor?: import("../host-floor.js").HostFloor;
378
386
  /** The (owner, scope) key this run's registry-facing tools register rows under — ({@link taskId}, mount domain), minted once at prepare; the teardown sweeps read it and never re-derive it. */
@@ -380,6 +388,9 @@ export interface Prepared {
380
388
  readonly owner: string;
381
389
  readonly scope: string;
382
390
  };
391
+ /** The run's member ledger book (`TaskSpec.runLedger`), present only on a run that declares one: the report tool delivers
392
+ * through it, and the settle reads the final ledger off it onto the result. */
393
+ runLedgerBook?: import("../run-ledger.js").RunLedgerBook;
383
394
  /** The session's reminder provenance mark this run mints under (adopted
384
395
  * through the prepare adoption ladder: checkpoint seed → trusted fork channel → session entry →
385
396
  * fresh mint). Every engine-authored `<system-reminder>` open tag in the run carries it, and the
@@ -1546,7 +1557,7 @@ export interface PreparedMicroCompact {
1546
1557
  };
1547
1558
  /** The run's ONE offload persist (write-once, idempotent): the frontier pass, the blocking-point arm and the MC-R arm all clear
1548
1559
  * through it, so they compose identical markers. Absent when no offload store is configured. */
1549
- offloadPersist?: (toolCallId: string, fullText: string) => string;
1560
+ offloadPersist?: import("../tool-result-store.js").OffloadPersist;
1550
1561
  }
1551
1562
  /**
1552
1563
  * Resume inputs threaded into {@link prepareTask} to continue a suspended task. The Runner
@@ -1931,6 +1942,9 @@ export interface RunInternals {
1931
1942
  * a root run it starts (`runTask(spec, { toolCeiling })`): the task-start doors judge it as a host-written workflow ceiling is judged (another spelling of a tool the run carries refuses: `config.tool_face_control`, `near_miss`); its rows record it. Trusted, never a TaskSpec field.
1932
1943
  */
1933
1944
  toolCeiling?: readonly import("../tool-face.js").ToolSelectorLayer[];
1945
+ /** The run's member ledger book (`TaskSpec.runLedger`) — always the run's own lane's (its notification lane mints it and hears the
1946
+ * run's frames into it); undefined on a run without a ledger. Trusted, never a TaskSpec field, never handed to a child. */
1947
+ runLedgerBook?: import("../run-ledger.js").RunLedgerBook | undefined;
1934
1948
  /** Set by the delegation lane when the spawning run's prepare judged this leg's own tool lists (its spec's `allowTools` /
1935
1949
  * `excludeTools` — a definition's or the delegation tool's) against a pool it could list: their digest (`toolListsDigest`), the
1936
1950
  * evidence bound to exactly those lists. A prepare whose own lists digest to it does not judge them again, and its rows record it
@@ -2168,8 +2182,9 @@ export interface RunInternals {
2168
2182
  * mirroring `insideFork`.
2169
2183
  */
2170
2184
  isDelegatedChild?: boolean;
2171
- /** Default project verdict id inherited from the parent leg (used only when child declares none and has no marker; trusted internals). */
2172
- parentProjectId?: string;
2185
+ /** The project seat its spawner (or waker) hands the leg, a DEFAULT: its id only when the leg declares none and has no marker, its texts only
2186
+ * when the leg's verdict is its id (`resolveSessionProject`); screened and copied at the call's internals door (a refused one ends the leg). Trusted internals. */
2187
+ parentProject?: import("../project-seat.js").ProjectSeat;
2173
2188
  /** Who wrote this leg's objective ({@link import("../input-author.js").InputAuthor}), stated by the seat that mints it; absent = the public
2174
2189
  * entry's caller, `operator`. Only the operator's objective passes `classic.UserPromptSubmit`; a non-member reads `unknown`, is screened and
2175
2190
  * reported once (`onError`, `"config"`). Never inherited — each seat says its own. TRUSTED run-scoped channel (NOT a {@link TaskSpec} field). */
@@ -3415,8 +3430,9 @@ export interface RunnerSelfSeat {
3415
3430
  emitTaskOutcome(outcome: TaskOutcome): void;
3416
3431
  /** Announce a fact of a composition's own (the verification gate's `verify.verifier_is_implementer`) on `RunnerDeps.onNotice`, live-read,
3417
3432
  * through the one delivery form every notice leaves by (`deliverEngineNotice`: the same-principal text pass, the session lift, a
3418
- * throwing sink contained). Absent on a hand-built seat ⇒ the composition cannot say it, and says nothing; the Runner always has it. */
3419
- emitNotice?(notice: import("../engine-notice.js").EngineNotice): void;
3433
+ * throwing sink contained). Absent on a hand-built seat ⇒ the composition cannot say it, and says nothing; the Runner always has it. With
3434
+ * a leg's `route` (`noticeAddressOf`) the Runner delivers under that route's admission (`legNoticeAdmission`, its own destination judge). */
3435
+ emitNotice?(notice: import("../engine-notice.js").EngineNotice, route?: import("../leg-identity.js").NoticeRoute): void;
3420
3436
  /** A hold, on the peer seat THIS runner's legs ask, of the references `declared` names — taken by a keeper of declarations outside a
3421
3437
  * leg (which they are: peer-seat.ts's module note), released by it once (peer-seat.ts `holdPeerDeclarations`). */
3422
3438
  holdDeclarations(declared: import("../peer-seat.js").PeerDeclarations): import("../peer-seat.js").PeerDeclarationHold;
@@ -136,6 +136,10 @@ export interface JudgedRow {
136
136
  readonly occupant?: () => Promise<string | undefined>;
137
137
  readonly minted?: boolean;
138
138
  readonly runsOn?: true;
139
+ /** `false`: the claimant's judgement taken without its write — a preview of the leg that would run on the row. Everything the claim
140
+ * needs is judged (a store with no conditional owner write refuses as it refuses the leg); a row that records no owner answers open
141
+ * and unclaimed, and nothing is recorded on it. */
142
+ readonly writes?: false;
139
143
  }
140
144
  /** The one refusal of a claim on a store that has no conditional owner write ({@link SessionStore.recordOwner}) — the whole of what a tree
141
145
  * with an owner meets on a row that records none there; one sentence, one place. */
@@ -188,6 +192,10 @@ export declare function readJudgedRow<T>(sessions: Pick<SessionStore, "headOf" |
188
192
  open: true;
189
193
  }>;
190
194
  }>;
195
+ /** The refusal of a read whose row is not the one judged ({@link readStandsAsJudged}). */
196
+ export declare function rowNotTheOneJudged(): Extract<RowAdmission, {
197
+ kind: "not_ours";
198
+ }>;
191
199
  /** {@link judgeRowForTree} for an entry that reads its CALLER's seat off the tool call (SendMessage, AgentTranscript, an extension's
192
200
  * transcript read): the seat's reading, bounded and ended by the call's stop. A caller that holds no seat — a tool driven with no run around
193
201
  * it, an operator's continuation — is an anonymous tree's ({@link delegationOwnerOf}): it opens only rows that record no owner. What a
@@ -295,6 +303,28 @@ export declare function judgeLegRow(sessions: Pick<SessionStore, "headOf" | "rec
295
303
  }>;
296
304
  };
297
305
  }, leg: JudgedLeg, report?: (err: Error, sessionId: string) => void): Promise<void>;
306
+ /** A leg's refusal of a row its judgement did not open: the store fault's own code ({@link RowStoreFaultCode}) for a store that could not
307
+ * judge it, `delegation.owner_mismatch` for a row that is not the tree's (the row named, no owner). Thrown by the leg's prepare
308
+ * ({@link judgeLegRow}) and answered by a preview of that leg alike. */
309
+ export declare function legRowRefusal(sessionId: string, verdict: Exclude<RowAdmission, {
310
+ open: true;
311
+ }>): Error & {
312
+ code: string;
313
+ };
314
+ /** What a leg's row is judged by ({@link JudgedLeg}), read off its spec, its internals and its tree's owner (`undefined` = the leg holds
315
+ * no seat: nothing is judged). The one reading of a leg's prepare and of a preview of that leg. */
316
+ export declare function judgedLegOf(spec: {
317
+ readonly sessionId?: string;
318
+ readonly requireExistingSession?: boolean;
319
+ readonly signal?: AbortSignal;
320
+ }, internals: {
321
+ readonly sessionIdMintedBySpawner?: boolean;
322
+ } | undefined, treeOwner: {
323
+ readonly owner: string | null;
324
+ } | undefined): JudgedLeg | undefined;
325
+ /** Whether a read of a row stands for the head a judgement read (`judged`; `null` = judged not there): the head after the read records
326
+ * the same owner on the same occupant. A row judged not there stands for no read. */
327
+ export declare function readStandsAsJudged(judged: SessionHead | null, now: SessionHead | undefined): boolean;
298
328
  /** What a delegated leg's row is judged by in prepare: the tree owner its seat bound (`owner`; `null` = anonymous), whether the engine
299
329
  * minted the id for this leg's create-capable acquire (`minted` — no author named it: the store's mint, or the spawning lane's,
300
330
  * `RunInternals.sessionIdMintedBySpawner`), and the leg's own stop (`signal`, its spec's). */
@@ -135,6 +135,8 @@ export async function judgeRowForTree(sessions, row, tree, signal) {
135
135
  const recordOwner = sessions.recordOwner;
136
136
  if (typeof recordOwner !== "function")
137
137
  return claimUnavailable();
138
+ if (row.writes === false)
139
+ return { open: true, claimed: false, head };
138
140
  let answered;
139
141
  try {
140
142
  answered = await boundedOwnerRead(() => Promise.resolve().then(() => recordOwner.call(sessions, sessionId, owner, { row: { owner: null, ...(head.incarnation !== undefined ? { incarnation: head.incarnation } : {}) } })), signal, "delegation owner claim");
@@ -167,10 +169,13 @@ export async function readJudgedRow(sessions, sessionId, verdict, read, signal)
167
169
  throw runAbortedError();
168
170
  return { refused: storeFault("storage", `the row could not be read back after the read (${ownerReadEnd(err) === "unanswered" ? "the session store did not answer in time" : "the session store's read failed"})`, err) };
169
171
  }
170
- if (judged !== null && now !== undefined && (now.owner ?? null) === (judged.owner ?? null) && sameOccupant(now.incarnation, judged.incarnation))
172
+ if (readStandsAsJudged(judged, now))
171
173
  return { read: value };
172
174
  await forgetHeld(sessions, sessionId);
173
- return { refused: refused("the row is not the one judged — it changed hands, was laid down again, or was not there when it was judged") };
175
+ return { refused: rowNotTheOneJudged() };
176
+ }
177
+ export function rowNotTheOneJudged() {
178
+ return { open: false, kind: "not_ours", why: "the row is not the one judged — it changed hands, was laid down again, or was not there when it was judged" };
174
179
  }
175
180
  export async function judgeRowForSeat(sessions, row, seat, signal) {
176
181
  return judgeRowForTree(sessions, row, await delegationOwnerOf(seat, signal), signal);
@@ -268,9 +273,20 @@ export async function judgeLegRow(sessions, held, leg, report) {
268
273
  if (verdict.open)
269
274
  return;
270
275
  await forgetHeld(sessions, held.sessionId, report);
276
+ throw legRowRefusal(held.sessionId, verdict);
277
+ }
278
+ export function legRowRefusal(sessionId, verdict) {
271
279
  if (verdict.kind === "store")
272
- throw rowStoreFaultError(held.sessionId, verdict);
273
- throw Object.assign(new Error(`the session row ${held.sessionId} does not record this delegation tree's owner: ${verdict.why}`), { code: DELEGATION_OWNER_MISMATCH });
280
+ return rowStoreFaultError(sessionId, verdict);
281
+ return Object.assign(new Error(`the session row ${sessionId} does not record this delegation tree's owner: ${verdict.why}`), { code: DELEGATION_OWNER_MISMATCH });
282
+ }
283
+ export function judgedLegOf(spec, internals, treeOwner) {
284
+ if (treeOwner === undefined)
285
+ return undefined;
286
+ return { owner: treeOwner.owner, minted: spec.requireExistingSession !== true && (spec.sessionId === undefined || internals?.sessionIdMintedBySpawner === true), ...(spec.signal !== undefined ? { signal: spec.signal } : {}) };
287
+ }
288
+ export function readStandsAsJudged(judged, now) {
289
+ return judged !== null && now !== undefined && (now.owner ?? null) === (judged.owner ?? null) && sameOccupant(now.incarnation, judged.incarnation);
274
290
  }
275
291
  function forgetHeld(sessions, sessionId, report) {
276
292
  return settleTeardownLeg(() => Promise.resolve(sessions.forget ? sessions.forget(sessionId) : undefined).catch(() => undefined), "forget (acquire-reconcile owner judgement leg)", report && ((e) => report(e, sessionId)));
@@ -26,12 +26,14 @@ export function createFinishReasonSeat(onNotice, ids) {
26
26
  const dropped = readMember(late, "contentDropped");
27
27
  const valid = (statement === "ending" || statement === "error" || statement === "content") && typeof lateWord === "string" && typeof frames === "number";
28
28
  if (valid && typeof dropped === "string") {
29
+ const ending = statement === "ending" ? lateWord : undefined;
29
30
  if (once(`dropped\u0000${dropped}`)) {
30
31
  deliverEngineNotice(onNotice, {
31
32
  code: "route.stream_content_dropped",
32
- message: `After the provider had already ended a response, its stream sent more of the model's output (first: ${dropped} content; ${frames} frame${frames === 1 ? "" : "s"} after the end in all). ` +
33
+ message: `After the provider had already ended a response, its stream sent more of the model's output (first: ${dropped} content` +
34
+ `${ending !== undefined ? ` alongside the ending "${ending}"` : ""}; ${frames} frame${frames === 1 ? "" : "s"} after the end in all). ` +
33
35
  `The first ending stands and that output was not added to the turn — the answer above may be missing what the model sent after it.`,
34
- detail: { word: dropped, frames, sessionId: ids.sessionId, runId: ids.runId },
36
+ detail: { word: dropped, ...(ending !== undefined ? { ending } : {}), frames, sessionId: ids.sessionId, runId: ids.runId },
35
37
  });
36
38
  }
37
39
  }
@@ -1,5 +1,6 @@
1
1
  import { retiredKeyOf, retiredKeyRefusal } from "../retired-keys.js";
2
2
  import { boundedThrownName } from "../thrown-value.js";
3
+ import { captureProjectSeat } from "../project-seat.js";
3
4
  export const DRAINED_LEG_FRAME_TYPES = Object.freeze(["status", "wiring_manifest", "message_committed", "workspace_changed"]);
4
5
  export const LEG_LABEL_KINDS = Object.freeze(["impl", "verifier", "fix", "rung"]);
5
6
  const drained = new WeakSet();
@@ -50,6 +51,8 @@ export function admitLegFrameSeat(internals, entry) {
50
51
  throw retiredKeyRefusal(hit, "RunInternals");
51
52
  }
52
53
  const read = readLegInternals(internals, entry);
54
+ if (read.parentProject !== undefined)
55
+ read.parentProject = captureProjectSeat(read.parentProject, "RunInternals.parentProject");
53
56
  const seat = read.onLegFrame;
54
57
  if (seat === undefined) {
55
58
  refuseHiddenLegFrameSeat(internals, entry);
@@ -8,6 +8,7 @@ import type { ReminderDisclosureCounts } from "../reminder-disclosure.js";
8
8
  import type { TaskSpec } from "../task-spec.js";
9
9
  import type { EngineNotice, RunnerDeps, TaskEvent, TaskEventIdentity } from "../types.js";
10
10
  import type { WiringManifest } from "../wiring-manifest.js";
11
+ import type { WiringInstructions } from "../instruction-preview.js";
11
12
  import type { Prepared } from "./contracts.js";
12
13
  /** At most this many names in `files` (and in `alternate.files`). */
13
14
  export declare const NESTED_MEMORY_MAX_NAMES = 8;
@@ -144,13 +145,28 @@ interface LaneHands {
144
145
  readonly root: string;
145
146
  readonly additionalRoots?: ReadonlyArray<DeclaredRoot>;
146
147
  }
148
+ /** What the lane reads of the leg it serves: the model it sizes frames for, the transcript's host texts, the leg's ids, its once-told
149
+ * record and identity. A prepared leg is one; a preview of a leg builds one with nothing behind it to write to. */
150
+ export interface InstructionLaneLeg {
151
+ readonly harness: {
152
+ getModel(): ReturnType<Prepared["harness"]["getModel"]>;
153
+ };
154
+ readonly session: {
155
+ buildContext(): ReturnType<Prepared["session"]["buildContext"]>;
156
+ };
157
+ readonly sessionId: string;
158
+ readonly runId: string;
159
+ readonly announcedListingsRef: Prepared["announcedListingsRef"];
160
+ readonly frameReceipts: Pick<Prepared["frameReceipts"], "listingSnapshotOwed">;
161
+ readonly hookIdentity: Pick<Prepared["hookIdentity"], "taskId" | "isDelegatedChild">;
162
+ }
147
163
  interface LaneSeatCommon {
148
164
  readonly declaration: ScreenedNestedMemory;
149
165
  readonly signal: AbortSignal;
150
166
  readonly mark: string | undefined;
151
167
  readonly counts: ReminderDisclosureCounts | undefined;
152
168
  readonly deps: Pick<RunnerDeps, "onNotice" | "onError">;
153
- readonly leg: () => Pick<Prepared, "harness" | "session" | "sessionId" | "runId" | "announcedListingsRef" | "frameReceipts" | "hookIdentity"> | undefined;
169
+ readonly leg: () => InstructionLaneLeg | undefined;
154
170
  /** The file tools the run's roster mounts, read at each mint — what a frame's sentence (a cut file's way to the rest) may send the
155
171
  * model to; absent outside a Runner: every one taken as mounted. */
156
172
  readonly fileTools?: () => FrameFileTools;
@@ -213,15 +229,16 @@ export interface NestedMemoryLane {
213
229
  * out. The load's per-request size cap is not applied (it can only take frames away). Empty once that load is taken. */
214
230
  owedAhead(triggers: readonly string[]): readonly MintedAttachmentFrame[];
215
231
  /** Each root's members the conversation holds (a read-state entry) or a load has on its way, relative to that root,
216
- * `/`-separated — the declared names first, in declaration order (`files`, then `localFiles`), then the rules by path: the
217
- * task root's (`selected`) and, under the opt-in, each additional root's in declaration order (the wiring manifest's
218
- * member); none on a lane with no hands (it reads no file). */
219
- selected(): NonNullable<WiringManifest["instructions"]> | undefined;
232
+ * `/`-separated, plus first-load `@`-included and withheld entries (present iff non-empty); `undefined` on a lane with no
233
+ * hands unless host-text withholds occurred. */
234
+ selected(): WiringInstructions | undefined;
220
235
  /** Is this key a member of the declared family — at a root's own level, or at any level — read off the declaration
221
236
  * and the path alone (a member's name, or a markdown file under a rules directory), whoever wrote its entry? */
222
237
  isMember(key: string, at: "root" | "any"): boolean;
223
238
  }
224
239
  export declare function createNestedMemoryLane(seat: NestedMemoryLaneSeat): NestedMemoryLane;
240
+ /** One first-load reading over a seated lane — shared by `primeInstructionLane` (manifest) and `Runner.previewInstructions`. */
241
+ export declare function primeInstructionReading(lane: NestedMemoryLane, report: (e: Error) => void): Promise<WiringInstructions | undefined>;
225
242
  /** The leg's first load, before its manifest goes out, and the manifest's `instructions` member it answers
226
243
  * ({@link WiringManifest.instructions}). A load that throws leaves the leg's first request to load (the operator hears
227
244
  * why); the manifest then says what the read state holds. */
@@ -5,7 +5,7 @@ import { countLines, retireRead, witnessesAfterDelivery } from "../../tools/fs/f
5
5
  import { expandHomeTilde, isAbsoluteForFamily, lexicalViewOf, pathFamilyOf, sha256, startsWithDriveLetter, withinAnyRoot } from "../../tools/fs/safety.js";
6
6
  import { relativeUnderRoot } from "../sensitive-path-policy.js";
7
7
  import { ORG_ADJUDICATION_TIMEOUT_MS } from "../permission-rule-org.js";
8
- import { isInstructionLaneEntry, mintInstructionFrames } from "../user-attachment.js";
8
+ import { instructionFrameOwnerOf, isInstructionLaneEntry, mintInstructionFrames } from "../user-attachment.js";
9
9
  import { deliverEngineNotice } from "../engine-notice.js";
10
10
  import { agentIdOf } from "../leg-identity.js";
11
11
  import { describeRejectedValue } from "../tool-search-setting.js";
@@ -399,6 +399,8 @@ export function createNestedMemoryLane(seat) {
399
399
  queue.unshift(...back);
400
400
  };
401
401
  let primed;
402
+ const firstLoadIncluded = new Map();
403
+ const firstLoadWithheld = new Map();
402
404
  const hostTexts = decl.hostRules.map((t) => {
403
405
  const shown = processInstructionText(normalizeFileText(t.text), decl.includes);
404
406
  return { ...t, shown, owner: OWNER_OF_LEVEL[t.level], anchored: hands !== undefined && isAbsoluteHostPath(t.name), conditional: t.rule && shown.globs !== undefined };
@@ -426,6 +428,12 @@ export function createNestedMemoryLane(seat) {
426
428
  const leg = seat.leg();
427
429
  if (leg === undefined || seat.signal.aborted)
428
430
  return [];
431
+ const forManifest = ask.forManifest === true;
432
+ const recordIncluded = (item, key) => {
433
+ if (forManifest && item.from !== undefined && !firstLoadIncluded.has(key)) {
434
+ firstLoadIncluded.set(key, Object.freeze({ path: key, includedBy: item.from.key, spelled: item.from.spelled }));
435
+ }
436
+ };
429
437
  const accesses = new Set();
430
438
  const current = new Map();
431
439
  const firstLoad = seen === undefined;
@@ -490,15 +498,29 @@ export function createNestedMemoryLane(seat) {
490
498
  fresh.push(d);
491
499
  say();
492
500
  };
493
- const withheld = (item, reason, past, target) => once(INSTRUCTIONS_WITHHELD, item.path, target === undefined ? reason : `${reason}\n${target}`, () => {
494
- if (delegated)
495
- return;
496
- const path = item.path;
497
- const r = rootLevelOf(path);
498
- const what = past !== undefined ? `An instruction text the deployment supplied, the first of ${past} past the ${NESTED_MEMORY_MAX_HOST_RULES} a task carries,` : item.from !== undefined ? `An instruction file that ${item.from.key} includes (\`@${item.from.spelled}\`)` : `An instruction file of ${r === 0 ? "the task root" : r > 0 ? "an additional working directory" : "a directory the model accessed"}`;
499
- const via = item.from !== undefined ? { includedBy: item.from.key, spelled: item.from.spelled } : {};
500
- deliverEngineNotice(seat.deps.onNotice, { code: INSTRUCTIONS_WITHHELD, message: `${what} was not loaded: ${path} (${WITHHELD_TEXT[reason]}). ${WITHHELD_WAY_OUT[reason]}`, detail: { path, reason, sessionId: leg.sessionId, runId: leg.runId, ...via, ...(target !== undefined ? { target } : {}) } });
501
- });
501
+ const withheld = (item, reason, past, target, blockedAfterApproval) => {
502
+ if (forManifest && (item.rule === "any" || item.from !== undefined || reason === "too_many_texts" || reason === "unanchored")) {
503
+ const wKey = `${item.path}\u0000${reason}\u0000${target ?? ""}\u0000${item.from?.key ?? ""}\u0000${item.from?.spelled ?? ""}`;
504
+ if (!firstLoadWithheld.has(wKey)) {
505
+ firstLoadWithheld.set(wKey, Object.freeze({
506
+ path: item.path,
507
+ reason,
508
+ ...(target !== undefined ? { target } : {}),
509
+ ...(item.from !== undefined ? { includedBy: item.from.key, spelled: item.from.spelled } : {}),
510
+ ...(blockedAfterApproval !== undefined ? { blockedAfterApproval } : {}),
511
+ }));
512
+ }
513
+ }
514
+ once(INSTRUCTIONS_WITHHELD, item.path, target === undefined ? reason : `${reason}\n${target}`, () => {
515
+ if (delegated)
516
+ return;
517
+ const path = item.path;
518
+ const r = rootLevelOf(path);
519
+ const what = past !== undefined ? `An instruction text the deployment supplied, the first of ${past} past the ${NESTED_MEMORY_MAX_HOST_RULES} a task carries,` : item.from !== undefined ? `An instruction file that ${item.from.key} includes (\`@${item.from.spelled}\`)` : `An instruction file of ${r === 0 ? "the task root" : r > 0 ? "an additional working directory" : "a directory the model accessed"}`;
520
+ const via = item.from !== undefined ? { includedBy: item.from.key, spelled: item.from.spelled } : {};
521
+ deliverEngineNotice(seat.deps.onNotice, { code: INSTRUCTIONS_WITHHELD, message: `${what} was not loaded: ${path} (${WITHHELD_TEXT[reason]}). ${WITHHELD_WAY_OUT[reason]}`, detail: { path, reason, sessionId: leg.sessionId, runId: leg.runId, ...via, ...(target !== undefined ? { target } : {}) } });
522
+ });
523
+ };
502
524
  const tellOperator = (lane, path, why, sentence) => once(lane, path, why, () => {
503
525
  try {
504
526
  seat.deps.onError?.(new Error(sentence), { phase: "degraded", sessionId: leg.sessionId, classification: "attachment-read" });
@@ -510,10 +532,10 @@ export function createNestedMemoryLane(seat) {
510
532
  const unlimited = (path) => tellOperator("nested_memory_rule_paths", path, "no_limit", `instruction rule ${path} names \`paths:\` but it reads as no limit (nothing listed, only \`**\`, or a form the engine does not recognise), so the rule applies to every file; to limit it, list the globs (\`paths:\` then \`- src/**\` lines, or \`paths: [src/**, lib/**]\`); if every file is meant, remove the key`);
511
533
  const spansLines = (path) => tellOperator("nested_memory_rule_paths", path, "spans_lines", `instruction rule ${path} gives \`paths:\` as one text over several lines, which reads as a single glob that matches no file, so the rule is never loaded; for several globs list them (\`paths:\` then \`- src/**\` lines) or write them on one line separated by commas (\`paths: src/**, lib/**\`)`);
512
534
  const outside = new Map();
513
- const refusedOutside = (item, wide, key, target) => {
535
+ const refusedOutside = (item, wide, key, target, targetOk = false) => {
514
536
  const held = outside.get(item.path);
515
537
  const edge = !foundByLane(item) || item.approved === true;
516
- const told = held === undefined || (edge && !held.edge) ? { item, edge, key: key ?? item.path, target } : held;
538
+ const told = held === undefined || (edge && !held.edge) ? { item, edge, key: key ?? item.path, target, targetOk } : held;
517
539
  outside.set(item.path, { ...told, wide: wide || held?.wide === true });
518
540
  };
519
541
  const reads = [];
@@ -589,8 +611,8 @@ export function createNestedMemoryLane(seat) {
589
611
  if (info.value.kind === "directory")
590
612
  return [];
591
613
  const heldToItsRoots = async (key) => foundByLane(item) && item.approved !== true && !(await approvedByRequest(key));
592
- const outsideItsRoot = (key, judged) => {
593
- refusedOutside(item, false, key, judged);
614
+ const outsideItsRoot = (key, judged, targetOk) => {
615
+ refusedOutside(item, false, key, judged, targetOk);
594
616
  return member !== undefined ? [member] : [];
595
617
  };
596
618
  const target = await hands.reader.resolveTarget(item.path, { signal: seat.signal });
@@ -600,13 +622,13 @@ export function createNestedMemoryLane(seat) {
600
622
  withheld(item, "rule_denied");
601
623
  else if (card === "path_not_in_root") {
602
624
  const judged = judgedKeyOf(target);
603
- return (await heldToItsRoots(judged)) ? outsideItsRoot(undefined, judged) : (refusedOutside(item, true), []);
625
+ return (await heldToItsRoots(judged)) ? outsideItsRoot(undefined, judged, false) : (refusedOutside(item, true), []);
604
626
  }
605
627
  return [];
606
628
  }
607
629
  const key = target.key;
608
630
  if (!insideItsRoots(item.root, key) && (await heldToItsRoots(key)))
609
- return outsideItsRoot(key, key);
631
+ return outsideItsRoot(key, key, true);
610
632
  if (visited.has(key) || inFlight.has(key))
611
633
  return [];
612
634
  const stat = info.value.kind === "symlink" ? await hands.env.fileInfo(key, seat.signal).catch(() => undefined) : info;
@@ -616,6 +638,7 @@ export function createNestedMemoryLane(seat) {
616
638
  const entry = state.get(key);
617
639
  if (entry !== undefined && entry.lastReadAt === mtime && (!decl.includes || includesBy.has(key))) {
618
640
  visited.add(key);
641
+ recordIncluded(item, key);
619
642
  return includesAt(includesBy.get(key) ?? [], item, key);
620
643
  }
621
644
  p.count++;
@@ -624,7 +647,7 @@ export function createNestedMemoryLane(seat) {
624
647
  try {
625
648
  const verdict = await hands.judge({ file_path: item.path, ...(face !== undefined ? { face } : {}) }, NESTED_MEMORY_PROBE_FACE, { deadlineAt });
626
649
  if (verdict.verdict !== "no_objection") {
627
- withheld(item, verdict.verdict === "deny" ? "rule_denied" : verdict.verdict === "ask" ? "approval_required" : "admission_unknown");
650
+ withheld(item, readJudgeBlockOf(verdict));
628
651
  return [];
629
652
  }
630
653
  if (verdict.judged !== undefined && verdict.judged !== key) {
@@ -664,8 +687,10 @@ export function createNestedMemoryLane(seat) {
664
687
  const more = includesAt(targets, item, key);
665
688
  if (pending.has(key))
666
689
  return more;
667
- if (entry !== undefined && entry.hash === hash)
690
+ if (entry !== undefined && entry.hash === hash) {
691
+ recordIncluded(item, key);
668
692
  return more;
693
+ }
669
694
  if (shown.content.trim() === "") {
670
695
  if (entry !== undefined && isInstructionLaneEntry(entry))
671
696
  withdraw(key, item);
@@ -681,6 +706,7 @@ export function createNestedMemoryLane(seat) {
681
706
  const read = {
682
707
  supply: "path",
683
708
  owner: item.owner ?? "repository",
709
+ ...(item.from !== undefined ? { included: true } : {}),
684
710
  layer,
685
711
  label: key,
686
712
  text: cut.text,
@@ -697,6 +723,7 @@ export function createNestedMemoryLane(seat) {
697
723
  },
698
724
  };
699
725
  reads.push({ read, item, key });
726
+ recordIncluded(item, key);
700
727
  return more;
701
728
  };
702
729
  const includeTargetsOf = (paths, from) => {
@@ -813,7 +840,7 @@ export function createNestedMemoryLane(seat) {
813
840
  withheld({ path: spelled, from: { key: t.name, spelled } }, "unanchored");
814
841
  const cut = cutInstructionText(t.shown.content, cap, cpt);
815
842
  const layer = t.conditional ? "nested" : "root";
816
- if (last?.text !== cut.text || last.layer !== layer)
843
+ if (last?.text !== cut.text || last.layer !== layer || (last.owner !== undefined && last.owner !== t.owner))
817
844
  hostRead(t.name, layer, t.owner, cut);
818
845
  }
819
846
  for (const [name, last] of shownNow)
@@ -822,9 +849,27 @@ export function createNestedMemoryLane(seat) {
822
849
  }
823
850
  queueOwed(hostIncludes.filter(claim), true);
824
851
  await drain();
825
- for (const r of outside.values())
826
- if (!visited.has(r.key) && !(inFlight.has(r.key) && !withdrawing.has(r.key)) && !queued.has(itemId(r.item)))
827
- withheld(r.item, r.wide ? "outside_roots" : "outside_its_root", undefined, r.wide ? undefined : r.target);
852
+ for (const r of outside.values()) {
853
+ if (visited.has(r.key) || (inFlight.has(r.key) && !withdrawing.has(r.key)) || queued.has(itemId(r.item)))
854
+ continue;
855
+ let blockedAfterApproval;
856
+ if (!r.wide && forManifest && hands !== undefined) {
857
+ if (!r.targetOk)
858
+ blockedAfterApproval = "outside_roots";
859
+ else {
860
+ try {
861
+ const face = hands.readFace();
862
+ const verdict = await hands.judge({ file_path: r.item.path, ...(face !== undefined ? { face } : {}) }, NESTED_MEMORY_PROBE_FACE, { deadlineAt });
863
+ blockedAfterApproval = readJudgeBlockOf(verdict);
864
+ }
865
+ catch (err) {
866
+ unread(r.item.path, thrownText(err));
867
+ blockedAfterApproval = "admission_unknown";
868
+ }
869
+ }
870
+ }
871
+ withheld(r.item, r.wide ? "outside_roots" : "outside_its_root", undefined, r.wide ? undefined : r.target, blockedAfterApproval);
872
+ }
828
873
  const includeReads = reads.splice(0);
829
874
  reads.push(...rootLayer, ...includeReads, ...familyReads, ...nestedLayer);
830
875
  if (fresh.length > 0) {
@@ -868,7 +913,7 @@ export function createNestedMemoryLane(seat) {
868
913
  if (primed !== undefined)
869
914
  return;
870
915
  const echo = { fn: undefined };
871
- primed = { reads: await collect({}, echo), echo };
916
+ primed = { reads: await collect({ forManifest: true }, echo), echo };
872
917
  },
873
918
  async load(ask) {
874
919
  const held = primed;
@@ -902,8 +947,10 @@ export function createNestedMemoryLane(seat) {
902
947
  return reads.length === 0 ? [] : fitLoad(reads, leg).minted.frames;
903
948
  },
904
949
  selected() {
905
- if (hands === undefined)
906
- return undefined;
950
+ const withheldList = [...firstLoadWithheld.values()];
951
+ if (hands === undefined) {
952
+ return withheldList.length > 0 ? Object.freeze({ selected: Object.freeze([]), withheld: Object.freeze(withheldList) }) : undefined;
953
+ }
907
954
  const keys = roots.map(() => new Set());
908
955
  for (const key of [...state.keys(), ...inFlight]) {
909
956
  const r = withdrawing.has(key) ? -1 : rootLevelOf(key);
@@ -919,19 +966,31 @@ export function createNestedMemoryLane(seat) {
919
966
  return Object.freeze([...keys[r]].map((k) => relIn(r, k)).sort((a, b) => rank(a) - rank(b) || (a < b ? -1 : a > b ? 1 : 0)));
920
967
  };
921
968
  const additional = roots.slice(1).map((x, i) => Object.freeze({ directory: x.directory, selected: of(i + 1) }));
922
- return Object.freeze({ selected: of(0), ...(decl.additionalDirectories ? { additionalDirectories: Object.freeze(additional) } : {}) });
969
+ const included = [...firstLoadIncluded.entries()].filter(([k]) => !withdrawing.has(k) && (state.has(k) || inFlight.has(k))).map(([, v]) => v);
970
+ return Object.freeze({
971
+ selected: of(0),
972
+ ...(decl.additionalDirectories ? { additionalDirectories: Object.freeze(additional) } : {}),
973
+ ...(included.length > 0 ? { included: Object.freeze(included) } : {}),
974
+ ...(withheldList.length > 0 ? { withheld: Object.freeze(withheldList) } : {}),
975
+ });
923
976
  },
924
977
  isMember,
925
978
  };
926
979
  }
927
- export async function primeInstructionLane(lane, manifest, report) {
980
+ function readJudgeBlockOf(verdict) {
981
+ return verdict.verdict === "no_objection" ? undefined : verdict.verdict === "deny" ? "rule_denied" : verdict.verdict === "ask" ? "approval_required" : "admission_unknown";
982
+ }
983
+ export async function primeInstructionReading(lane, report) {
928
984
  try {
929
985
  await lane.prime();
930
986
  }
931
987
  catch (err) {
932
988
  report(asThrownError(err));
933
989
  }
934
- const selected = lane.selected();
990
+ return lane.selected();
991
+ }
992
+ export async function primeInstructionLane(lane, manifest, report) {
993
+ const selected = await primeInstructionReading(lane, report);
935
994
  if (selected !== undefined)
936
995
  manifest.instructions = selected;
937
996
  }
@@ -941,8 +1000,10 @@ function lastHostTexts(messages) {
941
1000
  const a = userAttachmentOf(m);
942
1001
  if (a === undefined || a.supply !== "content_text" || (a.origin !== "nested_memory" && a.origin !== "project_instructions"))
943
1002
  continue;
944
- const blocks = m.content.slice(a.dataBlocks.start, a.dataBlocks.end);
945
- out.set(a.label, { text: a.withdraws !== undefined ? undefined : blocks.map((b) => (b.type === "text" ? (b.text ?? "") : "")).join(""), layer: a.origin === "project_instructions" ? "root" : "nested" });
1003
+ const content = m.content;
1004
+ const blocks = content.slice(a.dataBlocks.start, a.dataBlocks.end);
1005
+ const opening = content[0]?.type === "text" ? (content[0].text ?? "") : "";
1006
+ out.set(a.label, { text: a.withdraws !== undefined ? undefined : blocks.map((b) => (b.type === "text" ? (b.text ?? "") : "")).join(""), layer: a.origin === "project_instructions" ? "root" : "nested", owner: instructionFrameOwnerOf(opening) });
946
1007
  }
947
1008
  return out;
948
1009
  }
@@ -59,7 +59,7 @@ import { type PathRuleBases } from "../permission-rule-model.js";
59
59
  import { type BoundPathRule, type HeadLeads } from "../path-rule-binding.js";
60
60
  import { type RuleStoreFault } from "../rule-store-fault.js";
61
61
  import type { RunnerDeps } from "../runner-deps.js";
62
- import { type JudgedPathRow, type PathRuleDenyRow, type ReadDenyBuiltinConfig, type ReadDenyEntry, type ReadDenySeat, type WriteDenyMatcher } from "../../tools/fs/read-deny.js";
62
+ import { type JudgedPathRow, type PathRuleDenyRow, type ReadDenyBuiltinConfig, type ReadDenyEntry, type ReadDenyRootAnswer, type ReadDenySeat, type WriteDenyMatcher } from "../../tools/fs/read-deny.js";
63
63
  import { type HomeViewSource, type PlacedReadDenyMatcher } from "../../tools/fs/read-deny-home.js";
64
64
  import { type ReadStationMember } from "../../tools/fs/file-read-check.js";
65
65
  import { type ShellReadCheck } from "../../tools/fs/shell-read-check.js";
@@ -209,8 +209,9 @@ export interface PersonPathRows {
209
209
  * asking the store nothing new, the prepare read for the first request, and the newest read asked since the previous
210
210
  * request that the store has left unanswered past its bound. Bounded ({@link PERSON_READ_BOUND_MS}); never rejects. */
211
211
  forRequest(): Promise<PersonRowsRead>;
212
- /** Settles once the tables a reader takes are compiled: a pinned call's own; any other reader's (no id, or a call holding
213
- * no pin), the unit's newest — through every change that lands meanwhile, within {@link PATH_TABLES_READY_BOUND_MS} —
212
+ /** Settles once the tables a reader takes are compiled and the scopes of the bad rows of the read they stand on are judged (or
213
+ * their judgment ran out of time): a pinned call's own; any other reader's (no id, or a call holding no pin), the unit's newest —
214
+ * through every change that lands meanwhile, within {@link PATH_TABLES_READY_BOUND_MS} —
214
215
  * or at `signal` or the run's cut ({@link PersonPathRowsConfig.signal}). Never rejects: a reader whose wait was cut
215
216
  * checks its own signal and refuses; tables still compiling, or that could not be compiled, refuse at the read
216
217
  * ({@link PathTablesFacade.forCall}). */
@@ -305,6 +306,12 @@ export declare function readRootsOver(seats: {
305
306
  type WriteDenySeat = {
306
307
  readonly writeDenyMatch?: (p: string) => string | null;
307
308
  readonly writeDenyGuardsReads?: (pattern: string) => boolean;
309
+ readonly writeDenyUnder?: (p: string) => ReadDenyRootAnswer;
310
+ readonly writeDenyAtOrBelow?: (p: string) => string | null;
311
+ readonly writeDenyNamed?: {
312
+ readonly rows: readonly string[];
313
+ readonly ledBy: (entryName: string) => string | null;
314
+ };
308
315
  };
309
316
  export declare function denySeatsOf(t: PathTables): {
310
317
  readonly read: ReadDenySeat;
@@ -360,19 +367,17 @@ export declare function personPathRowsOfTask(t: {
360
367
  /**
361
368
  * The run's ONE notice of stored rule rows (`config.entries_not_applied`, kind `stored_rule_row`; before 7.70.0 the code
362
369
  * `permission.rule_row_dropped`; audience user): the person's store served rows that take no part in the
363
- * checks (`EffectivePermissionRules.droppedRows`) — entries whose behavior word could not be read (no rows: the sentence names where
364
- * each was served and what was read there, the detail's `element` too), project-scoped rows whose scope root is not a complete absolute
365
- * path, and allow rows not written the way a rule is stored or a part of which could not be read — or deny and ask rows it could not
366
- * read whole, which apply as written when their tool, match and path read or their text says them and stand at their strictest reading
367
- * when neither did
368
- * (`EffectivePermissionRules.unreadableRows`, either personal partition's); minted by whichever read met them first, once per run. The
369
- * sentence names no path and one clause per kind of row present ({@link DROPPED_ROW_SENTENCE}, then {@link UNREADABLE_ROW_SENTENCE});
370
- * the rows ride the detail's `entries` (the left-out rows first, `entriesNotAppliedDetail`): `entry` is the rule text as the store
371
- * served it, through the one reading ({@link noticeRuleText}) every kind's `entry` uses — the machine-read side carries the
372
- * original, the sentence spells — `reason` the row's word, on a scope row only `scopeRoot` neutralized and bounded, on a row a part of
373
- * which could not be read the `member` that could not, on a deny or ask row so read its `behavior`, and on an entry that is no row its
374
- * `element` (`partition`, `index`, what was `read`); `count` is every row of both, `identity` their whole set. The trace keeps every
375
- * read's line.
370
+ * checks (`EffectivePermissionRules.droppedRows`) — project-scoped rows whose scope root is not a complete absolute path, allow rows
371
+ * not written the way a rule is stored or a part of which could not be read, and (for host-supplied views only) `element` entries —
372
+ * or rows it could not read whole (`EffectivePermissionRules.unreadableRows`, either personal partition's): deny/ask rows whose
373
+ * identity read (they apply as written), deny/ask rows whose identity did not read (strictest reading), and rows whose behavior word
374
+ * could not be read (`member: "behavior"`, strictest reading, without claiming `behavior: "ask"` on the notice entry); minted by
375
+ * whichever read met them first, once per run. The sentence names no path and one clause per kind of row present
376
+ * ({@link DROPPED_ROW_SENTENCE}, then {@link UNREADABLE_ROW_SENTENCE}); the rows ride the detail's `entries` (the left-out rows first,
377
+ * `entriesNotAppliedDetail`): `entry` is the rule text as the store served it, through the one reading ({@link noticeRuleText}) every
378
+ * kind's `entry` uses, `reason` the row's word, `scopeRoot` on a scope row neutralized and bounded, `member` on a row a part of which
379
+ * could not be read, `behavior` on a deny or ask row whose behavior word read, and `element` on a host-supplied element entry; `count`
380
+ * is every row of both, `identity` their whole set. The trace keeps every read's line.
376
381
  */
377
382
  export declare function ruleRowsDroppedNotice(onNotice: RunnerDeps["onNotice"], ids: {
378
383
  readonly sessionId: string;