@sema-agent/core 7.71.1 → 7.72.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 (151) hide show
  1. package/CHANGELOG.md +181 -0
  2. package/dist/agents/cross-session-ref.d.ts +2 -2
  3. package/dist/agents/cross-session-ref.js +7 -2
  4. package/dist/agents/inherited-tool-pool.d.ts +4 -1
  5. package/dist/agents/inherited-tool-pool.js +7 -5
  6. package/dist/agents/send-message-tool.js +6 -2
  7. package/dist/agents/subagent.js +5 -1
  8. package/dist/agents/verify.js +1 -0
  9. package/dist/core/a2a.d.ts +24 -3
  10. package/dist/core/a2a.js +27 -8
  11. package/dist/core/agent-state.d.ts +28 -7
  12. package/dist/core/agent-state.js +19 -6
  13. package/dist/core/approval-object.d.ts +7 -3
  14. package/dist/core/approval-object.js +30 -9
  15. package/dist/core/checkpoint-features.d.ts +13 -3
  16. package/dist/core/checkpoint-features.js +34 -5
  17. package/dist/core/checkpoint-row-verdict.d.ts +1 -1
  18. package/dist/core/checkpoint-row-verdict.js +3 -3
  19. package/dist/core/effective-path-target.d.ts +19 -0
  20. package/dist/core/effective-path-target.js +95 -38
  21. package/dist/core/engine-notice.d.ts +4 -1
  22. package/dist/core/engine-version.js +1 -1
  23. package/dist/core/file-history-store.d.ts +15 -4
  24. package/dist/core/file-history-store.js +53 -23
  25. package/dist/core/gate-fold.js +3 -1
  26. package/dist/core/governance-codes.d.ts +4 -1
  27. package/dist/core/governance-codes.js +4 -0
  28. package/dist/core/judged-read.d.ts +57 -0
  29. package/dist/core/judged-read.js +1 -0
  30. package/dist/core/mcp-host-seat.d.ts +5 -0
  31. package/dist/core/mcp-host-seat.js +7 -1
  32. package/dist/core/mcp.js +3 -1
  33. package/dist/core/memory-engine/index.d.ts +1 -1
  34. package/dist/core/memory-engine/index.js +1 -1
  35. package/dist/core/memory-engine/layout.js +6 -4
  36. package/dist/core/memory-engine/scope-contract.d.ts +59 -6
  37. package/dist/core/memory-engine/scope-contract.js +90 -25
  38. package/dist/core/mounted-mcp.d.ts +7 -2
  39. package/dist/core/mounted-mcp.js +10 -1
  40. package/dist/core/param-rule-reach.d.ts +8 -3
  41. package/dist/core/param-rule-reach.js +9 -1
  42. package/dist/core/parent-spec-seat.d.ts +11 -1
  43. package/dist/core/parent-spec-seat.js +14 -0
  44. package/dist/core/peer-registration.d.ts +52 -0
  45. package/dist/core/peer-registration.js +37 -0
  46. package/dist/core/peer-seat.d.ts +3 -1
  47. package/dist/core/permission-rule-model.js +1 -1
  48. package/dist/core/runner/chain-mismatch.d.ts +32 -0
  49. package/dist/core/runner/chain-mismatch.js +29 -0
  50. package/dist/core/runner/changes-history.d.ts +1 -0
  51. package/dist/core/runner/changes-history.js +2 -2
  52. package/dist/core/runner/contracts.d.ts +3 -0
  53. package/dist/core/runner/file-history-restore.d.ts +3 -1
  54. package/dist/core/runner/file-history-restore.js +9 -6
  55. package/dist/core/runner/loaded-skills.d.ts +2 -0
  56. package/dist/core/runner/loaded-skills.js +10 -0
  57. package/dist/core/runner/person-path-rows.d.ts +2 -4
  58. package/dist/core/runner/person-path-rows.js +2 -3
  59. package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -0
  60. package/dist/core/runner/prepare-caps-and-workflow.js +7 -2
  61. package/dist/core/runner/prepare-file-history.js +1 -1
  62. package/dist/core/runner/prepare-hands-readface.d.ts +5 -0
  63. package/dist/core/runner/prepare-hands-readface.js +24 -21
  64. package/dist/core/runner/prepare-inherited-gate.d.ts +2 -2
  65. package/dist/core/runner/prepare-inherited-gate.js +1 -1
  66. package/dist/core/runner/prepare-memory-engine-session.d.ts +2 -2
  67. package/dist/core/runner/prepare-memory-engine-session.js +2 -2
  68. package/dist/core/runner/prepare-memory.js +3 -15
  69. package/dist/core/runner/prepare-project-context.d.ts +1 -1
  70. package/dist/core/runner/prepare-project-context.js +3 -7
  71. package/dist/core/runner/prepare-protocol-tools.d.ts +5 -0
  72. package/dist/core/runner/prepare-protocol-tools.js +2 -2
  73. package/dist/core/runner/prepare-task.js +20 -16
  74. package/dist/core/runner/prepare-wiring-manifest.d.ts +2 -0
  75. package/dist/core/runner/prepare-wiring-manifest.js +4 -3
  76. package/dist/core/runner/read-session-changes.js +1 -1
  77. package/dist/core/runner/resume-checkpoint-screen.d.ts +8 -7
  78. package/dist/core/runner/resume-checkpoint-screen.js +7 -6
  79. package/dist/core/runner/rewind-files.js +3 -2
  80. package/dist/core/runner/run-leg.js +6 -2
  81. package/dist/core/runner/terminal-account.d.ts +4 -0
  82. package/dist/core/runner/terminal-account.js +7 -2
  83. package/dist/core/runner/tool-face-overlay.d.ts +2 -11
  84. package/dist/core/runner/tool-face-overlay.js +39 -0
  85. package/dist/core/runner/trim-stretch.js +7 -2
  86. package/dist/core/scheduler.d.ts +47 -7
  87. package/dist/core/scheduler.js +19 -7
  88. package/dist/core/secret-env.d.ts +7 -0
  89. package/dist/core/secret-env.js +1 -1
  90. package/dist/core/sensitive-path-policy.js +14 -7
  91. package/dist/core/shell-read-silence.js +1 -0
  92. package/dist/core/store-contracts/checkpoint-store-contract.js +7 -0
  93. package/dist/core/task-event.d.ts +4 -3
  94. package/dist/core/task-notification.d.ts +2 -1
  95. package/dist/core/task-spec.d.ts +13 -5
  96. package/dist/core/tool-catalog-entries.js +2 -0
  97. package/dist/core/tool-face-reader.js +1 -1
  98. package/dist/core/tool-face.d.ts +7 -0
  99. package/dist/core/tool-face.js +1 -0
  100. package/dist/core/tool-mount-facts.d.ts +4 -2
  101. package/dist/core/tool-mount-facts.js +3 -3
  102. package/dist/core/tool-mount-plan.d.ts +4 -2
  103. package/dist/core/tool-mount-plan.js +5 -5
  104. package/dist/core/tool-mount-static.d.ts +1 -1
  105. package/dist/core/tool-mount-static.js +25 -13
  106. package/dist/core/tool-registry.d.ts +33 -1
  107. package/dist/core/tool-registry.js +33 -0
  108. package/dist/core/tool-roster.d.ts +16 -0
  109. package/dist/core/tool-roster.js +6 -0
  110. package/dist/core/tool-spec.d.ts +4 -2
  111. package/dist/core/tools.d.ts +6 -0
  112. package/dist/core/tools.js +1 -1
  113. package/dist/core/wiring-manifest.d.ts +66 -12
  114. package/dist/core/wiring-manifest.js +37 -1
  115. package/dist/engine/harness/messages.d.ts +1 -1
  116. package/dist/engine/harness/messages.js +2 -1
  117. package/dist/engine/loop/types.d.ts +2 -0
  118. package/dist/engine/session/session.js +1 -1
  119. package/dist/index.d.ts +9 -5
  120. package/dist/index.js +7 -4
  121. package/dist/orchestration/workflow.js +2 -1
  122. package/dist/stores/file/adoption/marker.d.ts +2 -27
  123. package/dist/stores/file/adoption/marker.js +12 -0
  124. package/dist/stores/file/index.d.ts +1 -1
  125. package/dist/stores/file/index.js +1 -1
  126. package/dist/tools/artifact/artifact-tool.js +11 -6
  127. package/dist/tools/fs/file-read-check.d.ts +45 -11
  128. package/dist/tools/fs/file-read-check.js +200 -57
  129. package/dist/tools/fs/judged-reads.d.ts +51 -0
  130. package/dist/tools/fs/judged-reads.js +68 -0
  131. package/dist/tools/fs/safety.d.ts +8 -0
  132. package/dist/tools/fs/safety.js +12 -1
  133. package/dist/tools/fs/shell-read-check.d.ts +16 -3
  134. package/dist/tools/fs/shell-read-check.js +4 -1
  135. package/dist/tools/fs/shell-read-establish.js +13 -3
  136. package/dist/tools/scheduler-store-move.d.ts +74 -0
  137. package/dist/tools/scheduler-store-move.js +103 -0
  138. package/dist/tools/scheduler-tools.d.ts +43 -29
  139. package/dist/tools/scheduler-tools.js +161 -118
  140. package/package.json +2 -2
  141. package/test/export-surface.snapshot.json +43 -3
  142. package/wire-changes/answers/core-stores-sql@7.72.0.json +12 -0
  143. package/wire-changes/answers/core@7.72.0.json +84 -0
  144. package/wire-changes/answers/mods-kernel@7.72.0.json +7 -0
  145. package/wire-changes/answers/primitives@7.72.0.json +6 -0
  146. package/wire-changes/answers/wiki-gate@7.72.0.json +7 -0
  147. package/wire-changes/core-stores-sql@7.72.0.json +215 -0
  148. package/wire-changes/core@7.72.0.json +2426 -0
  149. package/wire-changes/mods-kernel@7.72.0.json +147 -0
  150. package/wire-changes/primitives@7.72.0.json +143 -0
  151. package/wire-changes/wiki-gate@7.72.0.json +145 -0
@@ -14,7 +14,7 @@ import { adjudicateCaptureOptOut, captureOptOutDeniedError } from "./memory-capt
14
14
  import { isDeliberateMemoryRefusal, unpersistedOptOutRefusal } from "./memory-phase-refusals.js";
15
15
  import { sessionIncarnationResolver } from "../memory-engine/session-incarnation.js";
16
16
  import { createMemoryEngineTools } from "../memory-engine/tools.js";
17
- import { assertScopeContractPlacement, parseScopeKey } from "../memory-engine/scope-contract.js";
17
+ import { assertMemoryProjectVerdict, assertScopeContractPlacement, parseScopeKey } from "../memory-engine/scope-contract.js";
18
18
  import { writableRootOf } from "../memory-engine/types.js";
19
19
  import { MEMORY_TAIL_MAX_CHARS } from "./conversation-segment.js";
20
20
  import { indexCopyOf, keepIndexCopy } from "../memory-engine/index-copies.js";
@@ -145,29 +145,17 @@ export async function prepareMemory(input) {
145
145
  refuseAbsentPlaneStores(backend, engineRoot, planes !== undefined && reachesPersonalPlane(planes));
146
146
  assertRootNotSensitive("engine_root", engineRoot);
147
147
  const repoRoot = deps.rootPath ?? taskRootPath;
148
+ if (memorySpec.scopeContract === "v2")
149
+ assertMemoryProjectVerdict(input.sessionProject, memorySpec.scopes, memorySpec.writeScope);
148
150
  if (repoRoot) {
149
151
  adoptLegacyRepoDirs(engineRoot, repoRoot, (err) => deps.onError?.(err, { phase: "memory", sessionId }));
150
152
  }
151
153
  let identityKey;
152
154
  if (memorySpec.scopeContract === "v2" && repoRoot) {
153
- const consumesProjectIdentity = [...memorySpec.scopes, ...(memorySpec.writeScope !== null ? [memorySpec.writeScope] : [])]
154
- .map(parseScopeKey)
155
- .some((k) => k.kind === "proj" || k.kind === "userproj");
156
- if (input.sessionProject.markerFault !== undefined && consumesProjectIdentity)
157
- throw input.sessionProject.markerFault;
158
155
  const marker = input.sessionProject.project?.source === "marker" ? { projectId: input.sessionProject.project.id } : undefined;
159
156
  const verdictOnPartitionRoot = deriveRepoKey(input.sessionProject.root) === deriveRepoKey(repoRoot);
160
157
  if (marker) {
161
158
  identityKey = marker.projectId;
162
- if (memorySpec.writeScope !== null) {
163
- const w = parseScopeKey(memorySpec.writeScope);
164
- if ((w.kind === "proj" || w.kind === "userproj") && w.projectId !== marker.projectId) {
165
- const e = new Error(`memory scope contract v2: writeScope ${memorySpec.writeScope} targets projectId ${w.projectId}, ` +
166
- `but this checkout's marker (.sema/project) declares ${marker.projectId} — refusing a mis-addressed write.`);
167
- e.code = "config.memory_project_identity";
168
- throw e;
169
- }
170
- }
171
159
  const firstSwitch = verdictOnPartitionRoot && lookupProjectIdHint(engineRoot, repoRoot) !== marker.projectId;
172
160
  if (verdictOnPartitionRoot)
173
161
  recordProjectIdHint(engineRoot, repoRoot, marker.projectId);
@@ -3,7 +3,7 @@ import type { RunnerDeps, TaskSpec, ToolSpec } from "../types.js";
3
3
  import { type SkillGrantTable, type SkillSeatReader } from "../skill-grant.js";
4
4
  import { type AllowEntryTable } from "../allow-entry.js";
5
5
  import type { AnnounceOnceSink, Prepared, PrepareResume, RunInternals, ToolFaceSnapshot } from "./contracts.js";
6
- import { normalizeSkills } from "./synthetic-tools.js";
6
+ import { type normalizeSkills } from "./synthetic-tools.js";
7
7
  import { RosterBuilder } from "../tool-roster.js";
8
8
  import { type RetiredNameView } from "../tool-name-aliases.js";
9
9
  export interface PrepareProjectContextInput {
@@ -7,8 +7,8 @@ import { allowedToolsNotGrantedNotices, classifiesAllShell, seedAllowEntryTables
7
7
  import { deliverEngineNotice } from "../engine-notice.js";
8
8
  import { announceMemoryNotMounted, noticeOncePerSink } from "./announce-once-ledger.js";
9
9
  import { INSTRUCTIONS_FAMILY_UNDECLARED, instructionFamilyOf, instructionsFamilyUndeclaredNotice } from "./nested-memory-lane.js";
10
- import { SKILL_CONTENT_MAX_CHARS, SKILL_TOOL_NAME, createSkillTool, normalizeSkills } from "./synthetic-tools.js";
11
- import { skillLoadReading } from "./skill-base-dir.js";
10
+ import { SKILL_CONTENT_MAX_CHARS, SKILL_TOOL_NAME, createSkillTool } from "./synthetic-tools.js";
11
+ import { loadedSkills } from "./loaded-skills.js";
12
12
  import { RosterBuilder } from "../tool-roster.js";
13
13
  import { mountedToolNames } from "../tool-name-aliases.js";
14
14
  import { valveLeaves } from "../../agents/tool-filter.js";
@@ -24,12 +24,8 @@ export async function prepareProjectContext(input) {
24
24
  for (const s of spec.skills ?? [])
25
25
  if (!declaredSkillRank.has(s.name))
26
26
  declaredSkillRank.set(s.name, declaredSkillRank.size);
27
- const skillSpecs = normalizeSkills(spec.skills ?? []).filter((s) => {
28
- const { loads, delivered } = skillLoadReading(s, SKILL_CONTENT_MAX_CHARS);
29
- if (loads)
30
- return true;
27
+ const skillSpecs = loadedSkills(spec.skills ?? [], (s, delivered) => {
31
28
  deps.onError?.(new Error(`Skill "${s.name}" content is ${delivered} chars${delivered === s.content.length ? "" : ` once its base directory resolves (${s.content.length} as written)`}, over the ${SKILL_CONTENT_MAX_CHARS}-char load limit — skill not loaded (skills are never truncated; shrink the body or move material to attachments/files).`), { phase: "config", sessionId });
32
- return false;
33
29
  });
34
30
  const frozenSkillGrants = readFrozenSkillGrants(resume?.seed.skillGrants);
35
31
  if (frozenSkillGrants === undefined)
@@ -26,6 +26,7 @@ import type { ToolMarkSource } from "../ask-origin.js";
26
26
  import type { AgentTool } from "../../internal/harness.js";
27
27
  import { type MaterializedMcp, type McpDroppedTool, type McpReconnectResult } from "../mcp.js";
28
28
  import { type MaterializedA2a } from "../a2a.js";
29
+ import type { ToolCtxEnricher } from "../tools.js";
29
30
  import { type LockedPreflight } from "../locked-config.js";
30
31
  import type { NoticeTold } from "../engine-notice.js";
31
32
  import type { RunnerDeps, TaskSpec, ToolEffect } from "../types.js";
@@ -66,6 +67,10 @@ export interface PrepareProtocolToolsInput {
66
67
  mcpRequestMeta: import("../mcp-call-meta.js").McpLegMetaReader;
67
68
  /** borrowed-readonly — the leg's activity seat (`RunInternals.onSubtreeActivity`): an MCP call's progress notification beats it. Absent ⇒ none. */
68
69
  onSubtreeActivity?: RunInternals["onSubtreeActivity"];
70
+ /** borrowed-readonly — the leg's per-call ctx builder (`prepareInheritedGate`'s `enrichSpecToolCtx`, the one every caller tool and the first-party
71
+ * delegation tools run with): every A2A tool carries it as the means to compute what one of its calls reaches (registry, run lane, admission);
72
+ * a call itself never runs it. */
73
+ enrichSpecToolCtx: ToolCtxEnricher;
69
74
  /** borrowed-readonly — the run's invocation id (the revocation probe-failure notice names it). */
70
75
  runId: string;
71
76
  /** borrowed-readonly — the acquired session id (operator-line context). */
@@ -23,7 +23,7 @@ import { credentialEchoNotice } from "../credential-echo.js";
23
23
  import { mcpBinaryKeptSeat } from "./tool-result-media-seat.js";
24
24
  import { refusalAbout } from "../config-refusal-input.js";
25
25
  export async function prepareProtocolTools(input) {
26
- const { lockedPreflight, hostFloor, spec, deps, mcpPool, reminderMark, reminderDisclosureCounts, runId, sessionId, onceLedger, roster, rosterSeat, remoteToolOffload, toolResultBytes, toolFaceSnapshot, toolEffects, axisExplicitNegatives, irreversibilityTier, irreversibleTools, egressTools, toolMarkSources, abortController, rollback } = input;
26
+ const { lockedPreflight, hostFloor, spec, deps, mcpPool, reminderMark, reminderDisclosureCounts, runId, sessionId, onceLedger, roster, rosterSeat, remoteToolOffload, toolResultBytes, toolFaceSnapshot, toolEffects, axisExplicitNegatives, irreversibilityTier, irreversibleTools, egressTools, toolMarkSources, abortController, rollback, enrichSpecToolCtx } = input;
27
27
  const markedBy = (name, source) => {
28
28
  const set = toolMarkSources.get(name);
29
29
  if (set !== undefined)
@@ -202,7 +202,7 @@ export async function prepareProtocolTools(input) {
202
202
  foldProtocolAxes(mcp.toolAxes, "MCP");
203
203
  const a2aDeclared = lockedPreflight.a2a;
204
204
  const a2a = a2aDeclared
205
- ? await materializeLegA2aTools(revocations, a2aDeclared, spec.principal, abortController.signal, hostFloor, deps.peerSeat, credentialEchoNotice(deps.onNotice, sessionId, runId, "a2a"), (entry) => serverReached(mintNamespacePrefix(A2A_NAMESPACE, entry.name)), deps.a2a?.isolatePeers === true)
205
+ ? await materializeLegA2aTools(revocations, a2aDeclared, spec.principal, abortController.signal, hostFloor, deps.peerSeat, credentialEchoNotice(deps.onNotice, sessionId, runId, "a2a"), (entry) => serverReached(mintNamespacePrefix(A2A_NAMESPACE, entry.name)), deps.a2a?.isolatePeers === true, enrichSpecToolCtx)
206
206
  : { tools: [], toolAxes: [], warnings: [], statuses: [], refresh: async () => [], dispose: async () => { } };
207
207
  if (a2aDeclared)
208
208
  rollback.push(function a2aDispose() { return a2a.dispose(); });
@@ -25,7 +25,7 @@ import { ruleStoreUnreadableNotice } from "./rule-store-unreadable-notice.js";
25
25
  import { STALL_FIRST_BYTE_MS, STALL_FIRST_TOKEN_MS, STALL_IDLE_MS, withBrainCallGuardrail } from "../../brain/timeout.js";
26
26
  import { createFastModeLeg, SessionFastModeSeats } from "./fast-mode-seat.js";
27
27
  import { preparePromptSeats } from "./session-prompt-seats.js";
28
- import { bindParentSpecSeatFastMode } from "../parent-spec-seat.js";
28
+ import { bindParentSpecSeatFastMode, bindParentSpecSeatProjectId } from "../parent-spec-seat.js";
29
29
  import { rootSessionAddressKeyOf, rootSessionAddressOf, treeRootAddressOf } from "../../agents/root-session-lane.js";
30
30
  import { OFFLOAD_TOOL_NAME } from "../tool-result-store.js";
31
31
  import { saveToolResultReach } from "../tool-result-bytes.js";
@@ -112,7 +112,8 @@ import { defaultTaskRegistry } from "../task-registry.js";
112
112
  import { announcePeerLaneMount, judgeSessionBoxDrain } from "../../agents/peer-session-drain.js";
113
113
  import { sessionAddressOf } from "../task-notification.js";
114
114
  import { createFrameSettlement } from "../frame-settlement.js";
115
- import { createSchedulerTools, sessionLaneScopeOf } from "../../tools/scheduler-tools.js";
115
+ import { announceSchedulerStoreUnmoved, createSchedulerTools } from "../../tools/scheduler-tools.js";
116
+ import { readSchedulerDeclaration } from "../scheduler.js";
116
117
  import { selfOrchestrationFailClosedReason } from "../../orchestration/workflow-script-runner.js";
117
118
  import { valveLeaves, valveLeavesPeer } from "../../agents/tool-filter.js";
118
119
  import { backgroundAgentsFact, envMountFacts, legSeatMountFacts, seatMountFacts, specMountFacts } from "../tool-mount-facts.js";
@@ -138,7 +139,7 @@ import { toolCallFaceOf, ToolRosterDeltaSeat } from "../tool-roster.js";
138
139
  import { createExistingTargetSeat, readFirstWaiverOf } from "../existing-target.js";
139
140
  import { mountedMcpOf } from "../mounted-mcp.js";
140
141
  import { McpConnectionPool } from "../mcp-connection-pool.js";
141
- import { rosterCanPersistMemory } from "../tool-registry.js";
142
+ import { declaredReadSlotOf, rosterCanPersistMemory } from "../tool-registry.js";
142
143
  import { AdvertisedWritableDirs, planFileInvalid, planFileShown } from "./advertised-writable-dirs.js";
143
144
  import { resolveTaskRootCanonical } from "./task-root-canonical.js";
144
145
  import { projectMarkerFsOf, resolveSessionProject } from "../memory-engine/scope-contract.js";
@@ -403,7 +404,8 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
403
404
  const givenNoWorkspace = skippedFactory && !handsEnabled;
404
405
  if (!handsEnabled)
405
406
  refuseUserAttachmentPathsWithoutWorkspace(userAttachmentsSeat);
406
- const mountFacts = { ...legMountFacts, ...envMountFacts(handsEnabled, executionEnv) };
407
+ const schedulerReading = readSchedulerDeclaration(executionEnv);
408
+ const mountFacts = { ...legMountFacts, ...envMountFacts(handsEnabled, executionEnv, schedulerReading) };
407
409
  const externalContentTargetActive = targetIsExternal(executionEnv) !== false || resume?.seed.externalContentTarget === true || internals?.externalContentTarget === true;
408
410
  const crossBoundaryTree = joinedCrossBoundaryTree(internals?.crossBoundaryTree, (m) => deps.onError?.(new Error(m), { phase: "config", sessionId }));
409
411
  const abortController = new AbortController();
@@ -558,8 +560,8 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
558
560
  let legReadBlock = false;
559
561
  const pausedRef = {};
560
562
  const mcpHostSeats = internals?.mcpHostSeats;
561
- const mountedMcpNow = installedPreflight.mcp?.length ? () => mountedMcpOf({ declared: installedPreflight.mcp, roster: roster.tools, aggregateNames: new Set(mcp.tools.filter((t) => t.mcpRemoteName === undefined).map((t) => t.name)), ...(mcpHostSeats !== undefined ? { hostSeats: mcpHostSeats } : {}) }) : undefined;
562
- const { sharedArtifactReadsCell, liveInheritedGate, seedInheritedGate, inheritedAncestorRules, inheritedShellGate, inheritedParentConstraints, permissionMode, commitModeSeats, endModeCeiling, inheritedAdmittedOrgScopes, inheritedRuleBuckets, priorOwnOrgVerdict, orgGovernedProvenance, effectiveShellGate, ownSessionRulesRef, ancestorSessionRulesRef, ancestorRulesNow, memoryAdmittedOrgScopesRef, ownOrgVerdictRef, runClampSource, faceCheckpointSection, writeFaceCheckpointSection, skillGrantCheckpointSection, frozenOnAsk, hookEnvSource, frozenOnQuestion, parentSpecSeat, provenanceForChildrenRef, delegationSettlementRef, inheritedGateForChildren, carrierReadFace, carrierWriteFace, fullShellReachable, gateStopRef, stopForDenialLimit, enrichSpecToolCtx } = prepareInheritedGate({ spec, deps, commandSandboxRequirement, callerPlaces, delegationOwner, delegated: delegation.isDelegatedChild, askSeat: doors.askSeat, hostFloor: doors.hostFloor, crossBoundaryTree, internals, resume, sessions, sessionId, runId, hostTaskId, taskRootFinal, delegationCwd, givenNoWorkspace, ownTarget, executionEnv, ownedEnv, lockedPreflight: installedPreflight, pathRuleAnchors: { chainTop, onLeg: onLeg.chained, siteOf: onLeg.siteOf }, checkpointSeat, checkpointScope, taskScope, pausedRef, toolFaceSnapshot, mountsCallerTool, ...(mountedMcpNow !== undefined ? { mountedMcp: mountedMcpNow } : {}), promptLean, resolvedInteractionPosture, permissionModeSeat, mountFacts, spendSeat: spend, harnessRef, skillGrants, requestAllowedTools: allowedToolTables.request, forwardEvent, subagentRetain, taskArtifacts, worktreeIsolation, requestReview, requestStopAfterTurn, enterPlanMode, reminderMark, reminderDisclosureCounts, fileHistoryEnabled, historyScope, historyRoot, historyFs, abortRun: () => { abortController.abort(); void harness.abort(); }, runtimeCaps: () => runtimeCaps, approvalParkNotResumable, hostApprovalParksNotResumable: doors.hostApprovalParksNotResumable, modBus: legMods.standing, ownModChain, autoModeDecider: () => autoModeDeciderRef.current, legNotice, autoModeDenialTracking: () => autoModeDenialTrackingRef.current, autoModeArming: () => autoModeArmingRef.current, agentForkDenial: () => agentForkDenial, agentStations: () => agentStationsRef.current, sendStation: () => sendStationRef.current, taskStations: () => taskStationsRef.current, continuationReach, observersActive: () => observersActive, resolvedReadFace: () => resolvedReadFace, resolvedWriteFace: () => resolvedWriteFace, readDenyAdditionsNormalized: () => readDenyAdditionsNormalized, handsLessResolvedFace: () => handsLessResolvedFace, handsLessResolvedWriteFace: () => handsLessResolvedWriteFace, readBlock: () => legReadBlock, centerAdoption: () => centerAdoptionRef.current, memoryEngineSession: () => memoryEngineSession, sessionIncarnation: () => sessionIncarnation });
563
+ const mountedMcpNow = () => mountedMcpOf({ declared: installedPreflight.mcp, roster: roster.tools, aggregateNames: new Set(mcp.tools.filter((t) => t.mcpRemoteName === undefined).map((t) => t.name)), ...(mcpHostSeats !== undefined ? { hostSeats: mcpHostSeats } : {}) });
564
+ const { sharedArtifactReadsCell, liveInheritedGate, seedInheritedGate, inheritedAncestorRules, inheritedShellGate, inheritedParentConstraints, permissionMode, commitModeSeats, endModeCeiling, inheritedAdmittedOrgScopes, inheritedRuleBuckets, priorOwnOrgVerdict, orgGovernedProvenance, effectiveShellGate, ownSessionRulesRef, ancestorSessionRulesRef, ancestorRulesNow, memoryAdmittedOrgScopesRef, ownOrgVerdictRef, runClampSource, faceCheckpointSection, writeFaceCheckpointSection, skillGrantCheckpointSection, frozenOnAsk, hookEnvSource, frozenOnQuestion, parentSpecSeat, provenanceForChildrenRef, delegationSettlementRef, inheritedGateForChildren, carrierReadFace, carrierWriteFace, fullShellReachable, gateStopRef, stopForDenialLimit, enrichSpecToolCtx } = prepareInheritedGate({ spec, deps, commandSandboxRequirement, callerPlaces, delegationOwner, delegated: delegation.isDelegatedChild, askSeat: doors.askSeat, hostFloor: doors.hostFloor, crossBoundaryTree, internals, resume, sessions, sessionId, runId, hostTaskId, taskRootFinal, delegationCwd, givenNoWorkspace, ownTarget, executionEnv, ownedEnv, lockedPreflight: installedPreflight, pathRuleAnchors: { chainTop, onLeg: onLeg.chained, siteOf: onLeg.siteOf }, checkpointSeat, checkpointScope, taskScope, pausedRef, toolFaceSnapshot, mountsCallerTool, mountedMcp: mountedMcpNow, promptLean, resolvedInteractionPosture, permissionModeSeat, mountFacts, spendSeat: spend, harnessRef, skillGrants, requestAllowedTools: allowedToolTables.request, forwardEvent, subagentRetain, taskArtifacts, worktreeIsolation, requestReview, requestStopAfterTurn, enterPlanMode, reminderMark, reminderDisclosureCounts, fileHistoryEnabled, historyScope, historyRoot, historyFs, abortRun: () => { abortController.abort(); void harness.abort(); }, runtimeCaps: () => runtimeCaps, approvalParkNotResumable, hostApprovalParksNotResumable: doors.hostApprovalParksNotResumable, modBus: legMods.standing, ownModChain, autoModeDecider: () => autoModeDeciderRef.current, legNotice, autoModeDenialTracking: () => autoModeDenialTrackingRef.current, autoModeArming: () => autoModeArmingRef.current, agentForkDenial: () => agentForkDenial, agentStations: () => agentStationsRef.current, sendStation: () => sendStationRef.current, taskStations: () => taskStationsRef.current, continuationReach, observersActive: () => observersActive, resolvedReadFace: () => resolvedReadFace, resolvedWriteFace: () => resolvedWriteFace, readDenyAdditionsNormalized: () => readDenyAdditionsNormalized, handsLessResolvedFace: () => handsLessResolvedFace, handsLessResolvedWriteFace: () => handsLessResolvedWriteFace, readBlock: () => legReadBlock, centerAdoption: () => centerAdoptionRef.current, memoryEngineSession: () => memoryEngineSession, sessionIncarnation: () => sessionIncarnation });
563
565
  bindPermissionModeSeat(permissionMode);
564
566
  const personRowNotices = { onUnread: ruleStoreUnreadableNotice(deps.onNotice, { sessionId, runId }, onceLedger, permissionMode), onRowsDropped: ruleRowsDroppedNotice(deps.onNotice, { sessionId, runId }) };
565
567
  const sessionRulesRead = { unread: { own: () => true, ancestor: () => true } };
@@ -581,14 +583,16 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
581
583
  const legExemptRoots = Object.freeze(dataRootSpellings(deps.memoryEngineDir));
582
584
  const legWriteGuard = { exemptRoots: legExemptRoots, rows: toolPolicyWriteGuardRows([installedToolPolicy, ...(inheritedParentConstraints ?? []).map((c) => c.policy)]), checkout };
583
585
  const sideCallBookRef = {};
586
+ const judgedReadsSeat = {};
584
587
  const prefixLeg = {};
585
588
  const legPrefix = legPrefixObservers(acquired.session, deps.cacheBreakDetection !== false);
586
- const { roster, blockedRef, runtimeCaps, runtimeCapsFaulted, complianceDenies, complianceDegraded, agentForkDenial, observersActive, autoModeArmReason, autoModeDeciderRef, autoModeDenialTrackingRef, autoModeArmingRef, armAutoMode, selfOrchestrationActive, workflowSizeGuideline, workflowParkAdopter } = await prepareCapsAndWorkflow({ observeSideRequest: legPrefix.observeSide, spec, deps, delegationOwner, askSeat: doors.askSeat, internals, crossBoundaryTree, session, sessionId, runId, legNotice, hostTaskId, taskScope, taskRootFinal, delegationCwd, ownTarget, model, thinking, lockedPreflight, checkpointSeat, toolEffects, toolFaceSnapshot, promptLean, resolvedInteractionPosture, harnessRef, parentSpecSeat, runClampSource, forwardEvent, inheritedGateForChildren, enrichSpecToolCtx, maybeOffload, taskArtifacts, requestReview, suspendTargetGap: suspendTargetGapOf(ownedEnv), ...(spec.planFile !== undefined ? { planFileSource: { path: spec.planFile, shown: planFileShown(spec.planFile), read: (signal) => advertisedWritableDirs?.readPlanFile(signal) ?? Promise.resolve({ ok: false, reason: "this run admitted no plan file" }) } } : {}), enterPlanMode, permissionMode, readDenyEntries: () => personRows.tablesReady().then(() => ({ entries: readDenyMatcher?.entries ?? [], ruleRows: pathTables?.ruleRows() ?? effectivePathDenyRules })), peerLaneActive, peerSendMessageBuiltIn, runnerSelf, mountFacts, memoryEngineSession: () => memoryEngineSession, sessionIncarnation: () => sessionIncarnation, centerAdoption: () => centerAdoptionRef.current, agentStations: () => agentStationsRef.current, delegated: delegation.isDelegatedChild, checkpointScope, approvalParkNotResumable, sideCallBookRef });
589
+ const { roster, blockedRef, runtimeCaps, runtimeCapsFaulted, complianceDenies, complianceDegraded, agentForkDenial, observersActive, autoModeArmReason, autoModeDeciderRef, autoModeDenialTrackingRef, autoModeArmingRef, armAutoMode, selfOrchestrationActive, workflowSizeGuideline, workflowParkAdopter } = await prepareCapsAndWorkflow({ observeSideRequest: legPrefix.observeSide, spec, deps, delegationOwner, askSeat: doors.askSeat, internals, crossBoundaryTree, session, sessionId, runId, legNotice, hostTaskId, taskScope, taskRootFinal, delegationCwd, ownTarget, model, thinking, lockedPreflight, checkpointSeat, toolEffects, toolFaceSnapshot, promptLean, resolvedInteractionPosture, harnessRef, parentSpecSeat, runClampSource, forwardEvent, inheritedGateForChildren, enrichSpecToolCtx, judgedReadsSeat, maybeOffload, taskArtifacts, requestReview, suspendTargetGap: suspendTargetGapOf(ownedEnv), ...(spec.planFile !== undefined ? { planFileSource: { path: spec.planFile, shown: planFileShown(spec.planFile), read: (signal) => advertisedWritableDirs?.readPlanFile(signal) ?? Promise.resolve({ ok: false, reason: "this run admitted no plan file" }) } } : {}), enterPlanMode, permissionMode, readDenyEntries: () => personRows.tablesReady().then(() => ({ entries: readDenyMatcher?.entries ?? [], ruleRows: pathTables?.ruleRows() ?? effectivePathDenyRules })), peerLaneActive, peerSendMessageBuiltIn, runnerSelf, mountFacts, memoryEngineSession: () => memoryEngineSession, sessionIncarnation: () => sessionIncarnation, centerAdoption: () => centerAdoptionRef.current, agentStations: () => agentStationsRef.current, delegated: delegation.isDelegatedChild, checkpointScope, approvalParkNotResumable, sideCallBookRef });
587
590
  const tools = roster.tools;
588
591
  const forcedGateNotResumable = runtimeCaps?.forceDurableGate === true && notResumableSays;
589
592
  const legNotResumable = notResumableSays !== undefined ? { source: notResumableSays, mandated: forcedGateNotResumable !== false && forcedGateNotResumable !== undefined } : undefined;
590
593
  const crossBoundary = await prepareCrossBoundaryLane({ token: crossBoundaryTree, posture: doors.crossBoundaryPosture, externalContentTargetActive, env: executionEnv, session, resumeLeg: resume !== undefined, sessionId, runId, hostTaskId, noticeRoute: legNotice.route, deps });
591
- const sessionProject = await resolveSessionProject(projectMarkerFsOf(executionEnv), taskRootCanonical, spec.projectId);
594
+ const sessionProject = await resolveSessionProject(projectMarkerFsOf(executionEnv), taskRootCanonical, spec.projectId, internals?.parentProjectId);
595
+ bindParentSpecSeatProjectId(parentSpecSeat, sessionProject.project?.id);
592
596
  if (sessionProject.markerFault !== undefined)
593
597
  deps.onError?.(sessionProject.markerFault, { phase: "config", sessionId });
594
598
  const undeliveredContinuationRef = { current: { parkedSteers: [], orphanTasks: [] } };
@@ -655,7 +659,7 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
655
659
  const toolResultBytes = { ...(offloadStore !== undefined ? { store: offloadStore } : {}), sessionId, saveReach: () => saveToolResultReach(roster.tools.filter(valveLeaves(toolFaceSnapshot.selector)), offloadReachableToolsRef.current?.()) };
656
660
  const treePool = installedPreflight.mcp?.length && internals?.sessionMcpPools !== undefined ? internals.sessionMcpPools.of(treeRootAddressOf(internals, ownAddressOf(await readLegRow()), taskScope), spec.principal, deps.peerSeat) : undefined;
657
661
  const mcpPool = treePool !== undefined ? { pool: treePool, owned: false } : installedPreflight.mcp?.length ? { pool: new McpConnectionPool(), owned: true } : undefined;
658
- const { mcp, a2a, rebuildHarnessToolsRef, contentOriginWrapRef, toolCallGateArmedRef, mcpRedial } = await prepareProtocolTools({ lockedPreflight, hostFloor: doors.hostFloor, spec, deps, modBus: legMods.bus, ...(mcpPool !== undefined ? { mcpPool } : {}), ...(mcpHostSeats !== undefined ? { mcpHostSeats } : {}), reminderMark, reminderDisclosureCounts, mcpRequestMeta, ...(internals?.onSubtreeActivity !== undefined ? { onSubtreeActivity: internals.onSubtreeActivity } : {}), runId, sessionId, onceLedger, roster, rosterSeat, remoteToolOffload, toolResultBytes: { ...toolResultBytes, documents: () => pdfModelCapabilitiesOf(harnessRef.current?.getModel() ?? model).document }, toolFaceSnapshot, toolEffects, axisExplicitNegatives, irreversibilityTier, irreversibleTools, egressTools, toolMarkSources, abortController, rollback });
662
+ const { mcp, a2a, rebuildHarnessToolsRef, contentOriginWrapRef, toolCallGateArmedRef, mcpRedial } = await prepareProtocolTools({ lockedPreflight, hostFloor: doors.hostFloor, spec, deps, modBus: legMods.bus, ...(mcpPool !== undefined ? { mcpPool } : {}), ...(mcpHostSeats !== undefined ? { mcpHostSeats } : {}), reminderMark, reminderDisclosureCounts, mcpRequestMeta, ...(internals?.onSubtreeActivity !== undefined ? { onSubtreeActivity: internals.onSubtreeActivity } : {}), enrichSpecToolCtx, runId, sessionId, onceLedger, roster, rosterSeat, remoteToolOffload, toolResultBytes: { ...toolResultBytes, documents: () => pdfModelCapabilitiesOf(harnessRef.current?.getModel() ?? model).document }, toolFaceSnapshot, toolEffects, axisExplicitNegatives, irreversibilityTier, irreversibleTools, egressTools, toolMarkSources, abortController, rollback });
659
663
  const callIssuedAtRef = {};
660
664
  const workCutRef = { continuation: false, abortedBeforeTurnEnd: false };
661
665
  const loopTerminalRef = {}, loopReasksRef = { count: 0 };
@@ -740,8 +744,9 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
740
744
  const readFirstWaiver = {};
741
745
  const contextRoom = createContextRoomSeat({ messages: async () => (await session.buildContext()).messages, model: () => harnessRef.current?.getModel() ?? model, contextOverlay: legContextOverlay, settings: () => legCompactionSettings(spec, legContextOverlay(), "autoCompact"), overheadTokens: () => preparedHolder.current?.promptOverheadTokens, onNoWindow: (u) => { if (preparedHolder.current !== undefined)
742
746
  discloseUnevaluableWindow(u, preparedHolder.current, spec.tracer ?? deps.tracer, hostTaskId, deps.onError); } });
743
- const handsReadFaceInput = { legOccupant, ...(commandSandboxStart !== undefined ? { commandSandbox: commandSandboxStart } : {}), callerPlaces, told: legNotice.told, permissionMode, denyRuleRows: effectivePathDenyRules, readAskRuleRows: effectiveReadAskRules, headLeads, writeTargetJudge: () => writeTargetJudgeRef.current, personRows, handsEnabled, executionEnv, taskRootFinal, taskRootCanonical, rebaseRestoredPath, resume, session, sessionId, runId, hostTaskId, taskScope, fullShellReachable, effectiveShellGate, toolFaceSnapshot, model, spec, deps, internals, memoryWriteGate, ...(offloadStore !== undefined ? { offloadStore } : {}), ...(advertisedWritableDirs !== undefined ? { advertisedWritableDirs } : {}), firstPartyOffload, roster, egressTools, irreversibilityTier, irreversibleTools, reversibilityProbes, reminderMark, reminderDisclosureCounts, modelFileReaderSeat, readFirstWaiver, ...(trackFileEdit !== undefined ? { trackFileEdit } : {}), onFileEdited: noteFileEdited, harnessRef, delegation, toolProgressRef, toolOccurrences, writeLocation, contextRoom };
747
+ const handsReadFaceInput = { judgedReadsSeat, legOccupant, ...(commandSandboxStart !== undefined ? { commandSandbox: commandSandboxStart } : {}), callerPlaces, told: legNotice.told, permissionMode, denyRuleRows: effectivePathDenyRules, readAskRuleRows: effectiveReadAskRules, headLeads, writeTargetJudge: () => writeTargetJudgeRef.current, personRows, handsEnabled, executionEnv, taskRootFinal, taskRootCanonical, rebaseRestoredPath, resume, session, sessionId, runId, hostTaskId, taskScope, fullShellReachable, effectiveShellGate, toolFaceSnapshot, model, spec, deps, internals, memoryWriteGate, ...(offloadStore !== undefined ? { offloadStore } : {}), ...(advertisedWritableDirs !== undefined ? { advertisedWritableDirs } : {}), firstPartyOffload, roster, egressTools, irreversibilityTier, irreversibleTools, reversibilityProbes, reminderMark, reminderDisclosureCounts, modelFileReaderSeat, readFirstWaiver, ...(trackFileEdit !== undefined ? { trackFileEdit } : {}), onFileEdited: noteFileEdited, harnessRef, delegation, toolProgressRef, toolOccurrences, writeLocation, contextRoom };
744
748
  const handsReadFace = handsEnabled ? await prepareHandsMount(handsReadFaceInput) : resolveHandsLessReadFace(handsReadFaceInput);
749
+ judgedReadsSeat.current = handsReadFace.judgedReadsOf ?? null;
745
750
  const { readFileStateForCheckpoint, seedContextFiles, seededCopies, seenFiles, handsCwdRef, workspaceStateSettle, wsSnapshot, rebaseWsPath, shellReadCheck, shellReadAdmission, runReadFloor, shellReadLandings, additionalRootsCanonical, declaredAdditionalRoots, attachmentRootCanonical, readDenyMatcher, readRoots, pathTables, envHandToolNames, sealReadStateSeat } = handsReadFace;
746
751
  screenReadDenySeat("readDenyFloorRequired", deps.readDenyFloorRequired);
747
752
  runFloorSeat.current = runReadFloor;
@@ -758,16 +763,15 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
758
763
  await armAutoMode();
759
764
  const { worktreeSessionRef, sendMessageTier } = prepareDelegationSurface({ spec, deps, internals, resume, sessionId, sessionAddress, legOccupant, hostTaskId, taskScope, taskRootFinal, taskRootCanonical, executionEnv, runnerSelf, shellReadAdmission, runReadFloor: runFloor, ...(commandSandboxStart !== undefined ? { commandSandbox: commandSandboxStart } : {}), peerLaneActive, peerLaneRefs, sessionBox, roster, toolEffects, axisExplicitNegatives, toolFaceSnapshot, firstPartyOffload, offloadStore, toolResultBytes, taskArtifacts, subagentRetain, continuationReach, enrichSpecToolCtx, checkpointSeat, handsCwdRef, wsSnapshot, rebaseWsPath, rebaseRestoredPath, workspaceStateSettle, worktreeSeat });
760
765
  const { liveQuestionFace, contentAskBindings, contentAskRoutable, strandLateAnswer, settleContentAskBindings, durableQuestionFace, questionToolMounted, mountedQuestionTool } = prepareQuestionFace({ frozenOnQuestion, spec, askSource, deps, checkpointStore, runtimeCaps, approvalParkNotResumable, resolvedInteractionPosture, resume, sessionId, roster, inheritedUnavailableAsks: () => inheritedUnavailableAsks });
766
+ announceSchedulerStoreUnmoved(schedulerReading, deps.onNotice);
761
767
  if (roster.mounts.holds("cron-list")) {
762
- const sessionScope = sessionLaneScopeOf({ sessionId, isolationScope: spec.isolationScope, principal: spec.principal, taskId: spec.taskId });
763
768
  roster.mountAll(createSchedulerTools(executionEnv, {
764
- scope: sessionScope,
765
769
  ...(spec.principal !== undefined ? { principal: spec.principal } : {}),
766
770
  ...(spec.isolationScope !== undefined ? { isolationScope: spec.isolationScope } : {}),
767
771
  ...(sessionId !== undefined ? { sessionId } : {}),
768
772
  timeZone: judgedUserTimeZone(spec.clientContext),
769
773
  requestStopAfterTurn,
770
- })
774
+ }, schedulerReading)
771
775
  .filter((t) => roster.mounts.judgeTool(t)), { source: "builtin", mountedBy: "scheduler" });
772
776
  }
773
777
  if (internals?.insideFork !== true &&
@@ -815,7 +819,7 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
815
819
  const { cardFacts, runTimeReminders } = preparePromptSeats({ seats: internals?.sessionPromptSeats, key: sessionTreeKey, traits: promptTraits, childLeg: delegation.isDelegatedChild, attachments: spec.attachments, mode: permissionMode.current, prePlanMode: permissionMode.prePlanModeObserved, now });
816
820
  const { deferred, memoryBlock, toolSearch: toolSearchPolicy, toolFace } = prepareDeferClassify({ spec, deps, roster, toolFaceSnapshot, promptTraits, cardFacts, model, mcp, declaredMcp: lockedPreflight.mcp ?? [], legs: toolLegs, a2a, sharedMemoryPairMounted, memoryEnginePairMounted, memoryBlock: memoryBlockFromEngine, memoryRecallSegment, onceLedger, sessionId });
817
821
  tableReach = roster.tools.some((t) => t.name === SEND_MESSAGE_TOOL_NAME) ? sendMessageTier : "unmounted";
818
- prepareMemoryEngineSession({ memoryEngineSession, internals, memoryDelegationEvidence, externalContentTargetActive, lockedPreflight, ...(mountedMcpNow !== undefined ? { mountedMcp: mountedMcpNow } : {}), sessionId, runId, deps, provenanceForChildrenRef, delegationSettlementRef, spec, envHandToolNames, roster, contentOriginWrapRef });
822
+ prepareMemoryEngineSession({ memoryEngineSession, internals, memoryDelegationEvidence, externalContentTargetActive, lockedPreflight, mountedMcp: mountedMcpNow, sessionId, runId, deps, provenanceForChildrenRef, delegationSettlementRef, spec, envHandToolNames, roster, contentOriginWrapRef });
819
823
  const { systemPromptSeat, renderWithDate, systemBlocks, prefixHeadBlocks, promptHashSalt, promptManifest, promptIdentity, buildAssembleInputs, identityFor, adoptsCandidates, centerAdoptionRef, eventCopy } = await preparePromptAssembly({ session, deps, internals, resume, sugar: sugar.overlays, host: { ...(sugar.hostRole !== undefined ? { role: sugar.hostRole } : {}), ...(promptHost.form !== undefined ? { form: promptHost.form } : {}) }, binding: promptBinding, locale: promptLocale, modBus: legMods.bus, signal: abortController.signal, featureFlags, deferred, toolFace, mcpInstructionsBlock, memoryBlock, envFacts, promptTraits, shellFirstSession: cardFacts.shellFirstSession, skillsAnnounced: (skillsListing?.entries.length ?? 0) > 0, tools, model, sessionId, onceLedger });
820
824
  replacedTemplates.current = eventCopy;
821
825
  legPrefix.seatSalt(promptHashSalt.salt);
@@ -971,7 +975,7 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
971
975
  const { basePolicyForResumeEdit, denyNarrowingPolicy, skillGrantLane, sessionRulesUnread, allowEntryLanes, policyLayers, effectivePolicy, inheritedUnavailableAsks, deferredAskIdentities, inheritedAskGrants, riskAxesOf, ruleOffersOf, callGrantDoorOf, callBindingSeat, grantBindingOf, permissionRuleLane, permissionRuleGateLane, ruleLaneFacts, permissionRuleOrgLane, storedRuleWholeToolRefusals, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, foldAskClasses, ancestorSandboxAdmissions, ancestorArbitrations, inheritedInstallations, hostPoliciesUnderView } = await preparePolicyChain({ retiredNames, commandSandboxSideOf: commandSandboxSideFor, destinationOf: destinationFor, sandboxPlanOf, hostFloor: doors.hostFloor, spec, deps, sessionId, runId, hostTaskId, approvalWords, engineText, taskRootFinal, additionalRootsCanonical, writeLocation, executionEnv, lockedPreflight: installedPreflight, pathRuleAnchors: { leg: legAnchors, chainTop }, headLeads, tools, harnessTools, selector: toolFaceSnapshot.selector, toolEffects, egressTools, irreversibilityTier, axisExplicitNegatives, shellGatedTools, toolMarkSources, envHandToolNames, handsCwdRef, readDenyMatcher, readBlockJudge: handsReadFace.readBlockJudge, personRows, questionToolMounted, runtimeCaps, approvalParkNotResumable, notResumableSays, forcedGateNotResumable, inheritedAncestorRules, ancestorSessionRulesRef, inheritedParentConstraints, inheritedRuleBuckets, seedInheritedGate, skillGrants, skillSpecs, allowedToolTables, frozenOnAsk, hookEnvSource, notifyOwnHookCrash, modBus: legMods.bus, ownModChain, autoModeDecider: () => autoModeDeciderRef.current, whileHeld: toolOccurrences.whileHeld, readFace: () => resolvedReadFace, permissionMode, autoStripNotice, toolRosterDeltas: rosterSeat, stopForDenialLimit, askSource, parkRouteOf: (toolCallId) => ({ parkRoute: callParkRoute(legParkClosureSeat.built && !legParkClosureSeat.continuationCalls.has(toolCallId), legMods.bus, toolCallId), suspendTargetGap: legParkClosureSeat.suspendTargetGap }), abortController, now, ownSessionRulesRef, announced: { announcedListingsRef, frameReceipts } });
972
976
  sessionRulesRead.unread = sessionRulesUnread;
973
977
  toolTableViewRef.current = createToolTableView({ policy: effectivePolicy, stored: { wholeToolRefusals: storedRuleWholeToolRefusals }, roster: rosterSeat, verdicts: verdictLedger.verdicts, turnSnapshotRef });
974
- const { onAsk, preToolContexts, blockedToolCalls, batchHaltRef, blockedTracked, suspendTargetGap, durableSuspendInfraReady, suspendLaneGap, resourceSuspendEligible, usageGovernance, durableApproval, wiringManifest, askSeatWord, writeProtection, parkLaneArmed, gateMachineryActive, hookIdentity, hookEnvFace, sessionBoxBound } = prepareWiringManifest({ spec, deps, callerPlaces, askSeat: doors.askSeat, hostFloorPosture: doors.hostFloor?.posture, crossBoundaryStationEngaged: crossBoundary.stationEngaged, internals, resume, sessionId, runId, hostTaskId, taskScope, modBus: legMods.bus, standingModBus: legMods.standing, policyLayers, effectivePolicy, handsEnabled, skippedFactory, taskRootFinal, legWriteGuard: advertisedWritableDirs?.planFile !== undefined ? { ...legWriteGuard, exemptFiles: [advertisedWritableDirs.planFile] } : legWriteGuard, mcp, a2a, irreversibleTools, egressTools, shellReadStationArmed: handsReadFace.shellReadStationArmed, toolEffects, ownedEnv, executionEnv, offloadStore, onceLedger, usageWindows, envLifetimeSuspendAt, runtimeCaps, resolvedInteractionPosture, durableQuestionFace, liveQuestionFace, checkpointStore, sessions, modelGateManifest, autoModeArmReason, permissionMode, fastMode: fastModeLeg, lockedPreflight, peerLaneRefs, frameSettlement, receiveSeat, harness, pausedRef, liveInheritedGate, delegation, approvalParkNotResumable, forcedGateNotResumable, toolRoster, toolPlan, readDenyBuiltinTiersActive: handsReadFace.readDenyBuiltinTiersActive, readFloorUnkept: handsReadFace.readFloorUnkept.current, lspManagerWired, lspDiagnosticsLive: lspDiagnostics !== undefined, fileHistoryFact, projectMemoryFact, sessionRulesChildrenReadLive: ownSessionRulesRef.current !== undefined, sessionBox, sessionAddress, runEnd, checkpointScope, memoryPollution: () => memoryEngineSession?.pollution, advisorFact: advisor.manifest, runOrigin: doors.runOrigin, commandSandboxFact: commandSandboxRun.state === "unavailable" ? { state: "unavailable", reason: commandSandboxRun.reason } : { state: commandSandboxRun.state } });
978
+ const { onAsk, preToolContexts, blockedToolCalls, batchHaltRef, blockedTracked, suspendTargetGap, durableSuspendInfraReady, suspendLaneGap, resourceSuspendEligible, usageGovernance, durableApproval, wiringManifest, askSeatWord, writeProtection, parkLaneArmed, gateMachineryActive, hookIdentity, hookEnvFace, sessionBoxBound } = prepareWiringManifest({ spec, deps, callerPlaces, askSeat: doors.askSeat, hostFloorPosture: doors.hostFloor?.posture, sessionProject, crossBoundaryStationEngaged: crossBoundary.stationEngaged, internals, resume, sessionId, runId, hostTaskId, taskScope, modBus: legMods.bus, standingModBus: legMods.standing, policyLayers, effectivePolicy, handsEnabled, skippedFactory, taskRootFinal, legWriteGuard: advertisedWritableDirs?.planFile !== undefined ? { ...legWriteGuard, exemptFiles: [advertisedWritableDirs.planFile] } : legWriteGuard, mcp, a2a, irreversibleTools, egressTools, shellReadStationArmed: handsReadFace.shellReadStationArmed, toolEffects, ownedEnv, executionEnv, offloadStore, onceLedger, usageWindows, envLifetimeSuspendAt, runtimeCaps, resolvedInteractionPosture, durableQuestionFace, liveQuestionFace, checkpointStore, sessions, modelGateManifest, autoModeArmReason, permissionMode, fastMode: fastModeLeg, lockedPreflight, peerLaneRefs, frameSettlement, receiveSeat, harness, pausedRef, liveInheritedGate, delegation, approvalParkNotResumable, forcedGateNotResumable, toolRoster, toolPlan, readDenyBuiltinTiersActive: handsReadFace.readDenyBuiltinTiersActive, readFloorUnkept: handsReadFace.readFloorUnkept.current, lspManagerWired, lspDiagnosticsLive: lspDiagnostics !== undefined, fileHistoryFact, projectMemoryFact, sessionRulesChildrenReadLive: ownSessionRulesRef.current !== undefined, sessionBox, sessionAddress, runEnd, checkpointScope, memoryPollution: () => memoryEngineSession?.pollution, advisorFact: advisor.manifest, runOrigin: doors.runOrigin, commandSandboxFact: commandSandboxRun.state === "unavailable" ? { state: "unavailable", reason: commandSandboxRun.reason } : { state: commandSandboxRun.state } });
975
979
  refuseDisplayWithoutSentences(legMods.bus, legEventsOf(hookIdentity));
976
980
  agentStationsRef.current = createAgentStations({ bus: legMods.bus, identity: hookIdentity, permissionMode: () => permissionMode.observed });
977
981
  sendStationRef.current = createSessionSendStation({ bus: legMods.bus, identity: hookIdentity });
@@ -1032,7 +1036,7 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
1032
1036
  ...(commandSandboxRequirement !== undefined ? { effectiveSandbox: commandSandboxRequirement } : {}),
1033
1037
  ...(externalContentTargetActive ? { effectiveExternalContentTarget: true } : {}),
1034
1038
  };
1035
- const buildPrepared = () => ({ harness, session, sessionId, ...(rewindOutcome !== undefined ? { rewindOutcome } : {}), ...(captureLineage.own !== undefined ? { sessionIncarnation: captureLineage.own } : {}), ...(captureLineage.fault ? { sessionIncarnationUnread: true } : {}), taskId: hostTaskId, runId, crossBoundary, ...(doors.hostFloor !== undefined ? { hostFloor: doors.hostFloor } : {}), registryAccess: { owner: hostTaskId, scope: taskScope }, reminderMark, seededCopies, reminderDisclosureCounts, fullShellReachable, approvalPosture: { get mode() { return permissionMode.current; }, askEffective: askSeatWord }, ...(outputStyleSeat !== undefined ? { outputStyleFrame: renderOutputStyle(outputStyleSeat, engineText) } : {}), runTimeReminders, permissionMode, editedFilesSnapshot, taskRootPath: taskRootFinal, model, thinking, fastMode: fastModeLeg, mcp, ...(mcpRedial !== undefined ? { mcpRedial } : {}), ...(a2a.tools.length > 0 ? { a2a } : {}), blockedRef, outputRef, abortController, writeRefusal, blockedToolCalls, toolOccurrences, hookScreens, hookProgress, batchHaltRef, nestedStats, spend, laneDeps: deps, ...(rewindNotes.length > 0 ? { rewindNotes } : {}), ...(fileHistoryBoundary !== undefined ? { fileHistoryBoundary } : {}), ...(effectiveReadFaceObserved !== undefined ? { effectiveReadFace: effectiveReadFaceObserved, effectiveWriteFace: effectiveWriteFaceObserved } : {}), ...(effectiveReadDenyObserved !== undefined ? { effectiveReadDenyPatterns: effectiveReadDenyObserved } : {}), ...legPostureSeats, callerPlaces, effectiveMemoryScopes: memoryEffectiveScopes, readFloorUnkept: handsReadFace.readFloorUnkept, ...(placementValueOrAbsent(placementRootResolved) !== undefined ? { placementRoot: placementRootResolved } : {}), cwdRef: handsCwdRef, ...(attachmentRootCanonical !== undefined ? { handsRoot: attachmentRootCanonical } : {}), ...(stampCallTarget !== undefined ? { stampCallTarget } : {}), toolProgressRef, turnAbortRef, ...(advertisedWritableDirs !== undefined ? { advertisedWritableDirs } : {}), exemptRoots: legExemptRoots, ...(worktreeSessionRef !== undefined ? { worktreeSessionRef } : {}), workspaceFrame: createWorkspaceFrameSeat(givenNoWorkspace ? undefined : { root: taskRootCanonical, ...(handsCwdRef !== undefined ? { cwdRef: handsCwdRef } : {}), ...(worktreeSessionRef !== undefined ? { worktreeSessionRef } : {}), ...sessionFrameOf(sessionCheckout.record), ...(sessionCheckout.directories !== undefined ? { directories: sessionCheckout.directories } : {}), ...(sessionProject.project !== undefined ? { project: sessionProject.project } : {}), remote: workspaceRemote }), ...(workspaceStateSettle !== undefined ? { workspaceStateSettle } : {}), ...(sealReadStateSeat !== undefined ? { sealReadStateSeat } : {}), denyNarrowingPolicy, skillGrants: skillGrantLane, skillSpecs, ...(permissionRuleLane !== undefined ? { persistedRuleLane: permissionRuleLane } : {}), ...(basePolicyForResumeEdit !== undefined ? { basePolicyForResumeEdit } : {}), consolidationWriteJudge, ...(permissionRuleOrgLane !== undefined ? { permissionRuleOrg: permissionRuleOrgLane } : {}), releaseSignal, endModeCeiling, settleContentAskBindings, prefixChanges: legPrefix.changes, endPrefixLeg: () => endPrefixLeg(legPrefix.ledger, prefixLeg.number, limitApproachRef, session), observeSideRequest: legPrefix.observeSide, prefixAnchor, wiringManifest, promptManifest, promptIdentity, activeTools, ...(deferred.size > 0 ? { deferredToolNames: deferred } : {}), toolMaterializeStatic, deferDirectCall, ...(staticFaceForRef.current !== undefined ? { staticFaceFor: staticFaceForRef.current } : {}), ownedEnv, ...(workspaceSync !== undefined ? { workspaceSync } : {}), pausedRef, undeliveredContinuationRef, suspendProgressRef, remoteEnvFailures, refusedAsks, verdictLedger, reviewRequestRef, suspendLoopRef, suspendForResource, ...(suspendForPlatformLimit !== undefined ? { suspendForPlatformLimit } : {}), ...(suspendLaneGap !== undefined ? { suspendLaneGap } : {}), ...(envLifetimeSuspendAt !== undefined ? { envLifetimeSuspendAt } : {}), ...(usageGovernance !== undefined ? { usageGovernance } : {}), callIssuedAtRef, workCutRef, loopTerminalRef, loopReasksRef, brainCallGuardrailRef, gateStopRef, stopForDenialLimit, suspendForReview, ...(readFileStateForCheckpoint !== undefined ? { readFileState: readFileStateForCheckpoint } : {}), resourceLedger: priorLedger, liveSpendRef, humanReviewRef, now, tools, toolRoster, toolRosterDeltas: rosterSeat, structuredProjector, toolEffects, wakeRecovered, promptOverheadTokens, lastBrainContext, lastSentRequest: () => lastBrainContextRef.current, ...(advisor.instruction !== undefined ? { advisorInstruction: advisor.instruction } : {}), ...(languageSeat !== undefined ? { languageSeat } : {}), ...(sandboxFrameSeat !== undefined ? { sandboxFrameSeat } : {}), ...(memoryNoticesFrame !== undefined ? { memoryNoticesFrame } : {}), ...(compactionRestore !== undefined ? { compactionRestore } : {}), recentlyReadFiles, normalizeAttachmentPath, ...(onCompactionApplied ? { onCompactionApplied } : {}), compactionReuseRef, trimPressureRef, microCompact, ...(memoryEngineSession ? { memoryEngineSession } : {}), ...(subagentRetain ? { subagentRetain } : {}), ...(lspDiagnostics && nudgeLspOnEdit && withheldDiagnosticsOf ? { lspDiagnostics: { registry: lspDiagnostics, nudge: nudgeLspOnEdit, runIdent: lspRunIdent, withheldOf: withheldDiagnosticsOf } } : {}), stopRequestedRef, announcedSnapshotRecovered: onceLedger.recovered, ...(dateChange ? { dateChange } : {}), ...(workflowSizeGuideline ? { workflowSizeGuideline } : {}), ...(detectExternalChanges ? { detectExternalChanges } : {}), ...(nestedMemory !== undefined ? { nestedMemory } : {}), ...(toolsDeltaRef ? { toolsDeltaRef } : {}), ...(mcpUnavailable ? { mcpUnavailable } : {}), ...(agentListing ? { agentListing } : {}), ...(skillsListing ? { skillsListing } : {}), announcedListingsRef, frameReceipts, engineText, frameSettlement, ...(userAttachmentsSeat !== undefined ? { userAttachments: userAttachmentsSeat } : {}), attachmentDelivery: createAttachmentDelivery(), imageUnprocessed, ...(modelFileReaderSeat.current !== undefined ? { modelFileReader: modelFileReaderSeat.current } : {}), syntheticReadVerdict, ...(peerLaneRefs.boundaryRound !== undefined ? { peerBoundaryRound: peerLaneRefs.boundaryRound } : {}), gitStatusRef, postureFrameRef, requestCoreRef, limitApproachRef, listBackgroundTasks, taskReadHandleOf, hookIdentity, legNotice, modBus: legMods.bus, endModLife: legMods.end, admitRows: rowSeat.admitRows, receiveSeat, turnOpenRedelivery: {}, compactStation, sessionMeasure, sideCallBookRef, ...(sessionBoxBound !== undefined ? { sessionBox: sessionBoxBound } : {}), ...(turnSnapshotRef.current !== undefined ? { turnSnapshot: turnSnapshotRef.current } : {}), ...(centerCompactionCandidate !== undefined ? { centerCompactionCandidate } : {}), ...(shellReadCheck !== undefined ? { shellReadCheck } : {}), ...(shellReadLandings !== undefined ? { shellReadLandings } : {}), commandSandboxPlanOf: sandboxPlanOf, ...(toolDisclosureSeat !== undefined ? { toolDisclosure: toolDisclosureSeat } : {}), ...(approvedCallScreen !== undefined ? { approvedCallScreen } : {}), ...(toolCallStationRef.current !== undefined ? { toolCallStation: toolCallStationRef.current } : {}), legAdoption });
1039
+ const buildPrepared = () => ({ harness, session, sessionId, ...(rewindOutcome !== undefined ? { rewindOutcome } : {}), ...(captureLineage.own !== undefined ? { sessionIncarnation: captureLineage.own } : {}), ...(captureLineage.fault ? { sessionIncarnationUnread: true } : {}), taskId: hostTaskId, runId, crossBoundary, ...(doors.hostFloor !== undefined ? { hostFloor: doors.hostFloor } : {}), registryAccess: { owner: hostTaskId, scope: taskScope }, reminderMark, seededCopies, reminderDisclosureCounts, fullShellReachable, approvalPosture: { get mode() { return permissionMode.current; }, askEffective: askSeatWord }, ...(outputStyleSeat !== undefined ? { outputStyleFrame: renderOutputStyle(outputStyleSeat, engineText) } : {}), runTimeReminders, permissionMode, editedFilesSnapshot, taskRootPath: taskRootFinal, model, thinking, fastMode: fastModeLeg, mcp, ...(mcpRedial !== undefined ? { mcpRedial } : {}), ...(a2a.tools.length > 0 ? { a2a } : {}), blockedRef, outputRef, abortController, writeRefusal, blockedToolCalls, toolOccurrences, hookScreens, hookProgress, batchHaltRef, nestedStats, spend, laneDeps: deps, ...(rewindNotes.length > 0 ? { rewindNotes } : {}), ...(fileHistoryBoundary !== undefined ? { fileHistoryBoundary } : {}), ...(effectiveReadFaceObserved !== undefined ? { effectiveReadFace: effectiveReadFaceObserved, effectiveWriteFace: effectiveWriteFaceObserved } : {}), ...(effectiveReadDenyObserved !== undefined ? { effectiveReadDenyPatterns: effectiveReadDenyObserved } : {}), ...legPostureSeats, callerPlaces, effectiveMemoryScopes: memoryEffectiveScopes, readFloorUnkept: handsReadFace.readFloorUnkept, ...(placementValueOrAbsent(placementRootResolved) !== undefined ? { placementRoot: placementRootResolved } : {}), cwdRef: handsCwdRef, ...(attachmentRootCanonical !== undefined ? { handsRoot: attachmentRootCanonical } : {}), ...(stampCallTarget !== undefined ? { stampCallTarget } : {}), toolProgressRef, turnAbortRef, ...(advertisedWritableDirs !== undefined ? { advertisedWritableDirs } : {}), exemptRoots: legExemptRoots, ...(worktreeSessionRef !== undefined ? { worktreeSessionRef } : {}), workspaceFrame: createWorkspaceFrameSeat(givenNoWorkspace ? undefined : { root: taskRootCanonical, ...(handsCwdRef !== undefined ? { cwdRef: handsCwdRef } : {}), ...(worktreeSessionRef !== undefined ? { worktreeSessionRef } : {}), ...sessionFrameOf(sessionCheckout.record), ...(sessionCheckout.directories !== undefined ? { directories: sessionCheckout.directories } : {}), ...(sessionProject.project !== undefined ? { project: sessionProject.project } : {}), remote: workspaceRemote }), ...(workspaceStateSettle !== undefined ? { workspaceStateSettle } : {}), ...(sealReadStateSeat !== undefined ? { sealReadStateSeat } : {}), denyNarrowingPolicy, skillGrants: skillGrantLane, skillSpecs, ...(permissionRuleLane !== undefined ? { persistedRuleLane: permissionRuleLane } : {}), ...(basePolicyForResumeEdit !== undefined ? { basePolicyForResumeEdit } : {}), consolidationWriteJudge, ...(permissionRuleOrgLane !== undefined ? { permissionRuleOrg: permissionRuleOrgLane } : {}), releaseSignal, endModeCeiling, settleContentAskBindings, prefixChanges: legPrefix.changes, endPrefixLeg: () => endPrefixLeg(legPrefix.ledger, prefixLeg.number, limitApproachRef, session), observeSideRequest: legPrefix.observeSide, prefixAnchor, wiringManifest, promptManifest, promptIdentity, activeTools, ...(deferred.size > 0 ? { deferredToolNames: deferred } : {}), toolMaterializeStatic, deferDirectCall, ...(staticFaceForRef.current !== undefined ? { staticFaceFor: staticFaceForRef.current } : {}), ownedEnv, ...(workspaceSync !== undefined ? { workspaceSync } : {}), pausedRef, undeliveredContinuationRef, suspendProgressRef, remoteEnvFailures, refusedAsks, verdictLedger, reviewRequestRef, suspendLoopRef, suspendForResource, ...(suspendForPlatformLimit !== undefined ? { suspendForPlatformLimit } : {}), ...(suspendLaneGap !== undefined ? { suspendLaneGap } : {}), ...(envLifetimeSuspendAt !== undefined ? { envLifetimeSuspendAt } : {}), ...(usageGovernance !== undefined ? { usageGovernance } : {}), callIssuedAtRef, workCutRef, loopTerminalRef, loopReasksRef, brainCallGuardrailRef, gateStopRef, stopForDenialLimit, suspendForReview, ...(readFileStateForCheckpoint !== undefined ? { readFileState: readFileStateForCheckpoint } : {}), resourceLedger: priorLedger, liveSpendRef, humanReviewRef, now, tools, toolRoster, toolRosterDeltas: rosterSeat, structuredProjector, toolEffects, wakeRecovered, promptOverheadTokens, lastBrainContext, lastSentRequest: () => lastBrainContextRef.current, ...(advisor.instruction !== undefined ? { advisorInstruction: advisor.instruction } : {}), ...(languageSeat !== undefined ? { languageSeat } : {}), ...(sandboxFrameSeat !== undefined ? { sandboxFrameSeat } : {}), ...(memoryNoticesFrame !== undefined ? { memoryNoticesFrame } : {}), ...(compactionRestore !== undefined ? { compactionRestore } : {}), recentlyReadFiles, normalizeAttachmentPath, ...(onCompactionApplied ? { onCompactionApplied } : {}), compactionReuseRef, trimPressureRef, microCompact, ...(memoryEngineSession ? { memoryEngineSession } : {}), ...(subagentRetain ? { subagentRetain } : {}), ...(lspDiagnostics && nudgeLspOnEdit && withheldDiagnosticsOf ? { lspDiagnostics: { registry: lspDiagnostics, nudge: nudgeLspOnEdit, runIdent: lspRunIdent, withheldOf: withheldDiagnosticsOf } } : {}), stopRequestedRef, announcedSnapshotRecovered: onceLedger.recovered, ...(dateChange ? { dateChange } : {}), ...(workflowSizeGuideline ? { workflowSizeGuideline } : {}), ...(detectExternalChanges ? { detectExternalChanges } : {}), ...(nestedMemory !== undefined ? { nestedMemory } : {}), ...(toolsDeltaRef ? { toolsDeltaRef } : {}), ...(mcpUnavailable ? { mcpUnavailable } : {}), ...(agentListing ? { agentListing } : {}), ...(skillsListing ? { skillsListing } : {}), announcedListingsRef, frameReceipts, engineText, frameSettlement, ...(userAttachmentsSeat !== undefined ? { userAttachments: userAttachmentsSeat } : {}), attachmentDelivery: createAttachmentDelivery(), imageUnprocessed, ...(modelFileReaderSeat.current !== undefined ? { modelFileReader: modelFileReaderSeat.current } : {}), syntheticReadVerdict, ...(peerLaneRefs.boundaryRound !== undefined ? { peerBoundaryRound: peerLaneRefs.boundaryRound } : {}), gitStatusRef, postureFrameRef, requestCoreRef, limitApproachRef, listBackgroundTasks, taskReadHandleOf, hookIdentity, legNotice, modBus: legMods.bus, endModLife: legMods.end, admitRows: rowSeat.admitRows, receiveSeat, turnOpenRedelivery: {}, compactStation, sessionMeasure, sideCallBookRef, ...(sessionBoxBound !== undefined ? { sessionBox: sessionBoxBound } : {}), ...(turnSnapshotRef.current !== undefined ? { turnSnapshot: turnSnapshotRef.current } : {}), ...(centerCompactionCandidate !== undefined ? { centerCompactionCandidate } : {}), ...(shellReadCheck !== undefined ? { shellReadCheck } : {}), ...(shellReadLandings !== undefined ? { shellReadLandings } : {}), commandSandboxPlanOf: sandboxPlanOf, ...(toolDisclosureSeat !== undefined ? { toolDisclosure: toolDisclosureSeat } : {}), ...(approvedCallScreen !== undefined ? { approvedCallScreen } : {}), ...(toolCallStationRef.current !== undefined ? { toolCallStation: toolCallStationRef.current } : {}), legAdoption, declaredReadKeys: (id, call) => (declaredReadSlotOf(call) === undefined ? undefined : (judgedReadsSeat.current?.(id)?.map((t) => t.key) ?? "unjudged")) });
1036
1040
  refuseLateRosterChanges(callerRoster.roster);
1037
1041
  rollback.commit();
1038
1042
  prefixLeg.number = await legPrefix.ledger.openLeg(() => session.getBranch(), (id) => session.getBranch(id));
@@ -38,6 +38,7 @@ import { type AskEffective, type AutoModeArmFact, type SuspendLaneReason, type W
38
38
  import { type PermissionModeController } from "../mode-policy.js";
39
39
  import type { AnnounceOnceSink, Prepared, PrepareResume, RunInternals, UsageGovernance } from "./contracts.js";
40
40
  import type { RosterSpec } from "./caller-roster.js";
41
+ import { type SessionProjectVerdict } from "../memory-engine/scope-contract.js";
41
42
  export interface PrepareWiringManifestInput {
42
43
  /** borrowed-readonly — the REBOUND spec. Read: `onQuestion` (the question seam), `handsReadOnly` / `tools` (the ungated scan),
43
44
  * `resourceSuspend` (the task-axis lane), `durableApproval` / `principal` (the synthesis and the notice), `interactiveTools` /
@@ -156,6 +157,7 @@ export interface PrepareWiringManifestInput {
156
157
  /** borrowed-readonly — the leg's declared places (the driver's one mint): the write table's roots, and the manifest's count of each. */ callerPlaces: import("./leg-caller-places.js").LegCallerPlaces;
157
158
  /** borrowed-readonly — the advisor phase's answer, relayed. */ advisorFact?: WiringManifest["advisor"]; /** borrowed-readonly — the config doors' compiled host floor's posture, relayed (absent ⇒ none declared). */
158
159
  hostFloorPosture: WiringManifest["hostFloor"];
160
+ /** borrowed-readonly — this leg's project verdict from `resolveSessionProject` (same mint as `workspace_changed.project` and P-e refusal detail), relayed into `project` / `projectMarkerUnreadable`; absent ⇒ no verdict. */ sessionProject?: Pick<SessionProjectVerdict, "project" | "markerFault">;
159
161
  /** borrowed-readonly — the arming outcome the caps phase reads live (the manifest's auto-mode face at this leg's start). */
160
162
  autoModeArmReason: () => AutoModeArmFact;
161
163
  /** borrowed-readonly — the leg's live permission-mode seat: its receipt at this leg's start rides the manifest, and the
@@ -17,6 +17,7 @@ import { isShellFaceToolName } from "../tool-registry.js";
17
17
  import { LSP_CONTRACT_ID, mcpManifestEntries, askAnsweredClassesOf, askSeatEffective, countElicitOptIns, deriveHandsSeam, executionEnvSeatOf, interactionSeatsOf, deriveLspSeam, deriveWiringManifest, resolveDeclaredDurability, resolveElicitSeam, resolveQuestionSeam, resolveSubagentTranscriptTier, wiringLegKindOf } from "../wiring-manifest.js";
18
18
  import { modePolicyOf, modeQuestionReaches } from "../mode-policy.js";
19
19
  import { deploymentBagOf } from "./model-lane-seat.js";
20
+ import { projectMarkerUnreadableOf } from "../memory-engine/scope-contract.js";
20
21
  function buildUsageGovernance(windows, deps, principal, sessionId) {
21
22
  if (windows === undefined || windows.length === 0)
22
23
  return undefined;
@@ -138,7 +139,7 @@ export function durableSuspendInfraGaps(facts) {
138
139
  return gaps;
139
140
  }
140
141
  export function prepareWiringManifest(input) {
141
- const { spec, deps, internals, resume, sessionId, runId, hostTaskId, taskScope, modBus, standingModBus, checkpointScope, policyLayers, effectivePolicy, handsEnabled, skippedFactory, taskRootFinal, legWriteGuard, mcp, a2a, irreversibleTools, egressTools, toolEffects, ownedEnv, executionEnv, offloadStore, onceLedger, usageWindows, envLifetimeSuspendAt, runtimeCaps, resolvedInteractionPosture, durableQuestionFace, liveQuestionFace, checkpointStore, sessions, modelGateManifest, autoModeArmReason, permissionMode, fastMode, lockedPreflight, peerLaneRefs, frameSettlement, receiveSeat, sessionBox, sessionAddress, runEnd, harness, pausedRef, askSeat, liveInheritedGate, delegation, approvalParkNotResumable, forcedGateNotResumable, toolRoster, toolPlan, readDenyBuiltinTiersActive, readFloorUnkept, lspManagerWired, shellReadStationArmed, crossBoundaryStationEngaged, lspDiagnosticsLive, fileHistoryFact, projectMemoryFact, sessionRulesChildrenReadLive, memoryPollution, advisorFact, hostFloorPosture, runOrigin, commandSandboxFact, callerPlaces } = input;
142
+ const { spec, deps, internals, resume, sessionId, runId, hostTaskId, taskScope, modBus, standingModBus, checkpointScope, policyLayers, effectivePolicy, handsEnabled, skippedFactory, taskRootFinal, legWriteGuard, mcp, a2a, irreversibleTools, egressTools, toolEffects, ownedEnv, executionEnv, offloadStore, onceLedger, usageWindows, envLifetimeSuspendAt, runtimeCaps, resolvedInteractionPosture, durableQuestionFace, liveQuestionFace, checkpointStore, sessions, modelGateManifest, autoModeArmReason, permissionMode, fastMode, lockedPreflight, peerLaneRefs, frameSettlement, receiveSeat, sessionBox, sessionAddress, runEnd, harness, pausedRef, askSeat, liveInheritedGate, delegation, approvalParkNotResumable, forcedGateNotResumable, toolRoster, toolPlan, readDenyBuiltinTiersActive, readFloorUnkept, lspManagerWired, shellReadStationArmed, crossBoundaryStationEngaged, lspDiagnosticsLive, fileHistoryFact, projectMemoryFact, sessionRulesChildrenReadLive, memoryPollution, advisorFact, hostFloorPosture, sessionProject, runOrigin, commandSandboxFact, callerPlaces } = input;
142
143
  const onAsk = askSeat.value;
143
144
  const handWriteTools = toolRoster.entries.filter((e) => e.mountedBy === "hands" && (e.effect === "write" || e.effect === "idempotent")).map((e) => e.name);
144
145
  const hasEffectAwareGate = policyLayers.length > 0 || chainJudges(standingModBus);
@@ -177,7 +178,7 @@ export function prepareWiringManifest(input) {
177
178
  : `wire an effect-aware tool policy (or a PreToolUse hook). bash/MCP irreversible actions are otherwise unadjudicated; the deployment sandbox/egress boundary is the only protection. `) +
178
179
  (peerWriteUngated.length > 0 ? `Under ${permissionMode.current} a server's tools run with nobody stating them; a deny or ask rule naming them still gates them. ` : "") +
179
180
  (callerWriteUnasked.length > 0
180
- ? `Under ${permissionMode.current} a caller's tool that declares no permission seat answers for itself: the mode's question never reaches its calls (in auto, the classifier rules only on what a rule or a policy asks); declare permissionSeat: "passthrough" on it to put each call to the mode's question. A deny or ask rule naming it still gates it. `
181
+ ? `Under ${permissionMode.current} a caller's tool that declares no permission seat answers for itself: the mode's question never reaches its calls (in auto, the classifier rules only on what a rule or a policy asks); declare permissionSeat: "passthrough" on it to put each call to the mode's question. A deny or ask rule naming it still gates it, and a read target it declares (pathTarget access "read") is judged by the read station whatever its seat. `
181
182
  : "") +
182
183
  `(This warning fires once per deployment per tool-set shape.)`), { phase: "config", sessionId });
183
184
  }
@@ -260,7 +261,7 @@ export function prepareWiringManifest(input) {
260
261
  mods: modBus.records,
261
262
  ...(lspManagerWired ? { lsp: deriveLspSeam(toolRoster.entries.some((e) => e.contract.contractId === LSP_CONTRACT_ID), lspDiagnosticsLive) } : {}),
262
263
  hands: deriveHandsSeam(handsEnabled, skippedFactory), executionEnvSeat: executionEnvSeatOf(deps),
263
- fileHistory: fileHistoryFact, commandSandbox: commandSandboxFact, projectMemory: projectMemoryFact, sessionRulesChildrenReadLive, ...(advisorFact !== undefined ? { advisor: advisorFact } : {}), ...(hostFloorPosture !== undefined ? { hostFloor: hostFloorPosture } : {}),
264
+ fileHistory: fileHistoryFact, commandSandbox: commandSandboxFact, projectMemory: projectMemoryFact, sessionRulesChildrenReadLive, ...(advisorFact !== undefined ? { advisor: advisorFact } : {}), ...(hostFloorPosture !== undefined ? { hostFloor: hostFloorPosture } : {}), ...(sessionProject?.project !== undefined ? { project: sessionProject.project } : {}), ...((u) => (u !== undefined ? { projectMarkerUnreadable: u } : {}))(projectMarkerUnreadableOf(sessionProject?.markerFault)),
264
265
  };
265
266
  const wiringManifest = deriveWiringManifest(wiringFacts);
266
267
  const askSeatWord = askSeatEffective(wiringFacts);
@@ -79,7 +79,7 @@ async function readGit(req, session, sessions, takeEnv) {
79
79
  async function readSource(req, source, store, session, sessions, takeEnv) {
80
80
  const { sessionId, contentOf } = req;
81
81
  const unavailable = (reason, fault) => ({ kind: "unavailable", source, reason, ...(fault !== undefined ? { fault } : {}) });
82
- const sinceOn = (env, entryId, opened) => readSince(store, { scope: opened.historyScope, entryId, env, root: opened.historyRoot, signal: req.signal }, contentOf);
82
+ const sinceOn = (env, entryId, opened) => readSince(store, { scope: opened.historyScope, entryId, env, root: opened.historyRoot, signal: req.signal, ...(opened.row.forkedFrom !== undefined && opened.row.forkedFrom !== sessionId ? { forkedSession: true } : {}) }, contentOf);
83
83
  const treeOf = (env) => ({ hands: env !== undefined && env.handsEnabled ? { env: env.env, baseRoot: env.baseRoot } : undefined, refusedAs: checkoutRefusedAs(sessionId), sessions });
84
84
  if (source.kind === "since") {
85
85
  const env = await takeEnv();
@@ -43,12 +43,13 @@ export declare function resumeCheckpointScreen(input: ResumeCheckpointScreenInpu
43
43
  * `inheritedGate` (a task that inherited nothing, incl. every pre-seam checkpoint) resumes as before.
44
44
  * (3b) the re-supplied chain must have the SAME length the suspend recorded — a partial re-supply would run the resumed
45
45
  * leg under a thinner (or different) ancestor chain. Older checkpoints (no recorded count) keep only the check above.
46
- * (3c) F-012 L1 — the re-supplied chain's projections must digest to the recorded value (the count alone accepted a
47
- * same-length chain of DIFFERENT policies). Opaque layers contribute an explicit placeholder — swapping one opaque
48
- * closure for another still passes (nothing content-addressable to compare; the live-resupply trust contract governs
49
- * those layers), but any change in projectable deny data, layer order, or which layers are opaque refuses. The same
50
- * mint body the park used, with the arming carry taken from the ROW (`constraintChainEntryOfSuppliedLayer`,
51
- * positional against the persisted chain the row's verdict validated): a row that recorded a recipe must have it
52
- * handed back. PRE-F-012 checkpoints (no digest) keep the count-only contract — and only they do. An earlier meaning: `reading_changed`.
46
+ * (3c) F-012 L1 — the re-supplied chain's projections must digest to the recorded value (the count alone accepted a same-length
47
+ * chain of DIFFERENT policies). A layer that projects no component (opaque, or empty with a live remainder) is judged live, whole
48
+ * — swapping its live rules still passes (nothing content-addressable to compare; the live-resupply trust contract governs those
49
+ * layers); layers are compared position by position, so a change in the number of layers, a layer's kind or facts, or a projected
50
+ * component refuses, while swapping two non-projecting layers whose facts are the same is the same chain. The same mint body the
51
+ * park used, with the arming carry taken from the ROW (`constraintChainEntryOfSuppliedLayer`, positional against the persisted
52
+ * chain the row's verdict validated): a row that recorded a recipe must have it handed back; one value in its two spellings is one
53
+ * value (`inRecordedSpelling`). PRE-F-012 checkpoints (no digest) keep the count-only contract — and only they do. An earlier meaning: `reading_changed`.
53
54
  */
54
55
  export declare function parentConstraintChainVerdict(state: Pick<Checkpoint["state"], "inheritedGate">, supplied: InheritedGate["parentConstraints"] | undefined): CheckpointError | undefined;
@@ -1,6 +1,7 @@
1
1
  import { CheckpointError, realApprovalOrgFact } from "../checkpoint-store.js";
2
2
  import { resumeCancelledSentence } from "../park-noun.js";
3
3
  import { constraintChainDigest, constraintChainDigestReading, constraintChainEntryOfSuppliedLayer } from "../tool-policy.js";
4
+ import { chainChanged, chainUnjudgeable, inRecordedSpelling, withMismatchCause } from "./chain-mismatch.js";
4
5
  import { earlierChainMeaningRefusal } from "../checkpoint-row-verdict.js";
5
6
  import { chainInstallationGaps, chainInstallationRefusal } from "./child-tree.js";
6
7
  import { chainEntryFault } from "../mods/stations.js";
@@ -24,7 +25,7 @@ export function resumeCheckpointScreen(input) {
24
25
  "(the checkpoint stays pending and is resumable without it).");
25
26
  }
26
27
  refuseRecordedAndMountedToolNames(cp, internals, tools);
27
- const chainRung = chainRungRefusal(cp, internals, chainRefusal);
28
+ const chainRung = withMismatchCause(chainRungRefusal(cp, internals, chainRefusal));
28
29
  if (chainRung !== undefined)
29
30
  return { resumeInternals: internals, chainRung };
30
31
  const resumeInternals = internals?.inheritedGate?.parentConstraints !== undefined
@@ -51,10 +52,10 @@ function chainRungRefusal(cp, internals, chainRefusal) {
51
52
  if (gaps.length > 0)
52
53
  return chainInstallationRefusal(gaps, true);
53
54
  const malformed = chainEntryFault(chain ?? []);
54
- return malformed !== undefined ? new CheckpointError("resume.parent_constraint_mismatch", `${malformed}; rejected pre-CAS (the checkpoint stays pending)`) : undefined;
55
+ return malformed !== undefined ? chainUnjudgeable(`${malformed}; rejected pre-CAS (the checkpoint stays pending)`) : undefined;
55
56
  }
56
57
  catch (e) {
57
- return chainRefusalOfThrown(e, (what) => new CheckpointError("resume.parent_constraint_mismatch", `the inherited constraint chain could not be judged (${what} was thrown); rejected pre-CAS (the checkpoint stays pending)`));
58
+ return chainRefusalOfThrown(e, (what) => chainUnjudgeable(`the inherited constraint chain could not be judged (${what} was thrown); rejected pre-CAS (the checkpoint stays pending)`));
58
59
  }
59
60
  }
60
61
  export function parentConstraintChainVerdict(state, supplied) {
@@ -70,19 +71,19 @@ export function parentConstraintChainVerdict(state, supplied) {
70
71
  }
71
72
  const expected = recorded.parentConstraintCount;
72
73
  if (expected !== undefined && count !== expected) {
73
- return new CheckpointError("resume.parent_constraint_mismatch", `re-supplied ${count} parent constraint(s) but the checkpoint recorded ${expected} — a partial/mismatched ` +
74
+ return chainChanged(`re-supplied ${count} parent constraint(s) but the checkpoint recorded ${expected} — a partial/mismatched ` +
74
75
  "re-supply would run the resumed leg under a different ancestor chain than it suspended with; " +
75
76
  "rejected pre-CAS (the checkpoint stays pending) — re-resume with the full original chain");
76
77
  }
77
78
  const expectedDigest = recorded.constraintDigest;
78
79
  const persistedChain = recorded.constraintChain;
79
80
  if (expectedDigest !== undefined && persistedChain !== undefined) {
80
- const suppliedChain = (supplied ?? []).map((pc, i) => constraintChainEntryOfSuppliedLayer(pc, persistedChain[i]));
81
+ const suppliedChain = (supplied ?? []).map((pc, i) => inRecordedSpelling(constraintChainEntryOfSuppliedLayer(pc, persistedChain[i]), persistedChain[i]));
81
82
  const reading = constraintChainDigestReading(suppliedChain, expectedDigest);
82
83
  if (reading === "earlier")
83
84
  return earlierChainMeaningRefusal();
84
85
  if (reading !== "same") {
85
- return new CheckpointError("resume.parent_constraint_mismatch", "the re-supplied parent-constraint chain's projection content does not match what the checkpoint recorded " +
86
+ return chainChanged("the re-supplied parent-constraint chain's projection content does not match what the checkpoint recorded " +
86
87
  `(recorded ${expectedDigest}, re-supplied ${constraintChainDigest(suppliedChain)}) — a same-shape chain with different frozen ` +
87
88
  "deny data would run the resumed leg under a different ancestor gate than it suspended with; " +
88
89
  "rejected pre-CAS (the checkpoint stays pending) — re-resume with the original chain's policies " +
@@ -88,13 +88,14 @@ async function rewindOnEnv(req, env, handsEnabled, baseRoot, ctx) {
88
88
  const roots = { own: () => Promise.resolve(historyRoot), source: async (origin) => { const r = await recordedRootOf(at, origin); return r === undefined ? undefined : canonicalOrSelf(env, r); } };
89
89
  if (ctx.captureStore !== undefined)
90
90
  await adoptForkedFileHistory(ctx.captureStore, { origin: row.forkedFrom, originIncarnation: row.forkedFromIncarnation }, req.sessionId, ownScope, ctx.seats.deps.onError, roots);
91
+ const forkedSession = row.forkedFrom !== undefined && row.forkedFrom !== req.sessionId;
91
92
  if (req.dryRun) {
92
- const plan = await planFileHistoryRestore(ctx.store, { scope: historyScope, entryId: req.to, env, root: historyRoot, ...(req.signal !== undefined ? { signal: req.signal } : {}), ...(req.restoreOptions !== undefined ? { options: req.restoreOptions } : {}) });
93
+ const plan = await planFileHistoryRestore(ctx.store, { scope: historyScope, entryId: req.to, env, root: historyRoot, ...(req.signal !== undefined ? { signal: req.signal } : {}), ...(req.restoreOptions !== undefined ? { options: req.restoreOptions } : {}), ...(forkedSession ? { forkedSession: true } : {}) });
93
94
  refuseUnheldPlan(plan, req.to, req.sessionId, "preview");
94
95
  refuseFailedPlan(plan.restore, req.to, req.sessionId, "preview");
95
96
  return { dryRun: true, preview: plan.diffStats };
96
97
  }
97
- const restore = await settleFileHistoryRestore({ store: ctx.store, sessionId: req.sessionId, scope: historyScope, target: req.to, before: false, env, root: historyRoot, signal: req.signal, readStates: ctx.readStates, options: req.restoreOptions, wholeOrNothing: false, outcome: ctx.outcome });
98
+ const restore = await settleFileHistoryRestore({ store: ctx.store, sessionId: req.sessionId, scope: historyScope, target: req.to, before: false, env, root: historyRoot, signal: req.signal, readStates: ctx.readStates, options: req.restoreOptions, wholeOrNothing: false, ...(forkedSession ? { forkedSession: true } : {}), outcome: ctx.outcome });
98
99
  return { dryRun: false, restore };
99
100
  }
100
101
  function withVerbSettlement(err, outcome) {
@@ -53,6 +53,7 @@ import { settleExecutionRecord } from "./execution-record.js";
53
53
  import { holdPrompt } from "./prompt-block.js";
54
54
  import { frozenInputSnapshot, permissionDeniedOf } from "./gate-exit.js";
55
55
  import { withGateTimeout } from "../gate-bounded-await.js";
56
+ import { unestablishedDetails } from "../../tools/fs/shell-read-check.js";
56
57
  import { readStationAnswer } from "../shell-read-silence.js";
57
58
  import { resolveGitLegDelivery, wrapGitFrame } from "./git-leg-delivery.js";
58
59
  import { GIT_STATUS_ECHO_PREVIEW, protectedGitFrameOf } from "./git-status-frame.js";
@@ -927,7 +928,7 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
927
928
  verdict = await withGateTimeout(judged, ORG_ADJUDICATION_TIMEOUT_MS, prepared.abortController.signal, "shellReadStation");
928
929
  }
929
930
  catch {
930
- verdict = prepared.shellReadCheck.unanswered(readCall, "the read station could not answer on the resumed leg");
931
+ verdict = prepared.shellReadCheck.unanswered({ ...readCall, toolCallId: pendingAction.toolCallId }, "the read station could not answer on the resumed leg");
931
932
  }
932
933
  const reading = readStationAnswer(verdict, { toolName: pendingAction.toolName, toolCallId: pendingAction.toolCallId });
933
934
  if (reading.kind === "refuse" || reading.kind === "silence" || (unseen && (reading.kind !== "vouch" || reading.verdict.askRule !== undefined))) {
@@ -941,7 +942,10 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
941
942
  const { targetReading: _belts, ...unread } = beltReq();
942
943
  const targetReading = (await prepared.stampCallTarget?.(unread, prepared.abortController.signal))?.targetReading;
943
944
  const reads = prepared.shellReadLandings?.(pendingAction.toolCallId);
944
- const atExecution = judgeApprovalObject(pendingAction, { tool: mounted().entry, args: executedArgs, skills: prepared.skillSpecs, skillToolName: SKILL_TOOL_NAME, ...(humanRewrite !== undefined ? { decided: resolvedArgs } : {}), targetReading, reads }, "execution");
945
+ const landings = prepared.declaredReadKeys?.(pendingAction.toolCallId, callFaceSeat(beltFace()));
946
+ if (landings === "unjudged")
947
+ return refuseCall(`The approved tool call "${pendingAction.toolName}" was not executed: no read station on this leg judged where it reads, so the approval cannot be checked against what it would read now. This approval is spent — the call has to be re-issued and approved again.`, { layer: "read_boundary" }, { details: unestablishedDetails() });
948
+ const atExecution = judgeApprovalObject(pendingAction, { tool: mounted().entry, args: executedArgs, skills: prepared.skillSpecs, skillToolName: SKILL_TOOL_NAME, ...(humanRewrite !== undefined ? { decided: resolvedArgs } : {}), targetReading, reads, ...(landings !== undefined ? { landings } : {}) }, "execution");
945
949
  if (atExecution !== "match")
946
950
  return atExecution.disposition === "reopen" ? reopen(atExecution) : vetoApproval(atExecution);
947
951
  tool = mounted().tool;
@@ -35,6 +35,10 @@ export declare function requestRouteOfMessage(final: AssistantMessage): RequestR
35
35
  * account); `outputLimit` only beside `truncated`, only with a boolean `capStop`, its counts only as non-negative
36
36
  * integers — an unreadable limit leaves the cause standing without it. */
37
37
  export declare function modelOutputInvalidOfMessage(final: AssistantMessage): ModelOutputInvalid | undefined;
38
+ /** Admit one string value for a `coded` failure detail (and any wire mirror of its string members, e.g.
39
+ * `WiringManifest.projectMarkerUnreadable.markerPath`): drops strings over {@link CODED_DETAIL_STRING} (`undefined`)
40
+ * and replaces any string that {@link carriesCredential} with {@link CREDENTIAL_LEAF}; otherwise returns `text` verbatim. */
41
+ export declare function codedDetailStringOf(text: string): string | undefined;
38
42
  /**
39
43
  * Extract a machine-readable code from a thrown error (e.g. `SessionError.code`, a Node error code).
40
44
  * Walks the `cause` chain because the harness wraps lower-level errors (e.g. a `SessionError("conflict")`
@@ -69,6 +69,11 @@ const INDEX_KEY_RE = /^(?:0|[1-9][0-9]*)$/;
69
69
  function carriesCredential(text) {
70
70
  return looksLikeCredentialValue(text) || egressText("same-principal", text) !== text;
71
71
  }
72
+ export function codedDetailStringOf(text) {
73
+ if (text.length > CODED_DETAIL_STRING)
74
+ return undefined;
75
+ return carriesCredential(text) ? CREDENTIAL_LEAF : text;
76
+ }
72
77
  const NAME_CHARS = 128;
73
78
  function namesCredential(name) {
74
79
  return name.length <= NAME_CHARS && (isSensitiveName(name) || isSensitiveRecordKey(name));
@@ -91,11 +96,11 @@ function leafOf(keyContext, read, depth, budget) {
91
96
  if (value === null || typeof value === "boolean" || (typeof value === "number" && Number.isFinite(value)))
92
97
  return charge(budget, 0) ? value : undefined;
93
98
  if (typeof value === "string") {
94
- if (value.length > CODED_DETAIL_STRING) {
99
+ const shown = codedDetailStringOf(value);
100
+ if (shown === undefined) {
95
101
  budget.cuts++;
96
102
  return undefined;
97
103
  }
98
- const shown = carriesCredential(value) ? CREDENTIAL_LEAF : value;
99
104
  return charge(budget, shown.length) ? shown : undefined;
100
105
  }
101
106
  if (typeof value !== "object")