@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
@@ -4,8 +4,8 @@ import { err, FileError, ok } from "../../internal/harness.js";
4
4
  import { performsIo } from "../remote-env.js";
5
5
  import { thrownText } from "../thrown-value.js";
6
6
  import { envErrorDetail } from "../../tools/fs/env-error-detail.js";
7
- import { describeRejectedValue } from "../tool-search-setting.js";
8
7
  import { physicalPathOfExisting } from "../physical-path.js";
8
+ import { PROJECT_ID_REGEX } from "../project-seat.js";
9
9
  function pathSegmentsDualFamily(p) {
10
10
  return p.split(/[\\/]/).filter(Boolean);
11
11
  }
@@ -198,7 +198,7 @@ export function assertScopeContractPlacement(args) {
198
198
  }
199
199
  }
200
200
  export const PROJECT_MARKER_PATH = ".sema/project";
201
- export const PROJECT_ID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
201
+ export { PROJECT_ID_REGEX };
202
202
  const UUID_RE = PROJECT_ID_REGEX;
203
203
  export function normalizeProjectId(projectId) {
204
204
  return projectId.toLowerCase();
@@ -354,11 +354,8 @@ export function projectMarkerUnreadableOf(fault) {
354
354
  return undefined;
355
355
  return d.reason === "repo_root_unreadable" || d.markerPath === undefined ? { reason: d.reason } : { reason: d.reason, markerPath: d.markerPath };
356
356
  }
357
- export async function resolveSessionProject(fs, taskRoot, declared, defaultProjectId) {
358
- if (declared !== undefined && (typeof declared !== "string" || !UUID_RE.test(declared))) {
359
- throw identityError("config.project_id_invalid", `TaskSpec.projectId must be a project UUID (the id a \`.sema/project\` marker carries), got ${describeRejectedValue(declared)}; the leg is refused rather than filed under no project.`);
360
- }
361
- const declaredId = declared !== undefined ? normalizeProjectId(declared) : undefined;
357
+ export async function resolveSessionProject(fs, taskRoot, declared, inherited) {
358
+ const declaredId = declared !== undefined ? normalizeProjectId(declared.id) : undefined;
362
359
  let marker;
363
360
  try {
364
361
  marker = await resolveProjectId(fs, taskRoot);
@@ -368,16 +365,19 @@ export async function resolveSessionProject(fs, taskRoot, declared, defaultProje
368
365
  throw e;
369
366
  return { root: taskRoot, markerFault: e };
370
367
  }
371
- if (marker !== null) {
372
- if (declaredId !== undefined && declaredId !== marker.projectId) {
373
- const markerPath = join(marker.markerDir, PROJECT_MARKER_PATH);
374
- throw identityError("config.project_identity_mismatch", `TaskSpec.projectId declares ${declaredId}, but this checkout's project marker ${markerPath} carries ${marker.projectId} — ` +
375
- `the leg is refused rather than filed under the wrong project. Declare the marker's id, or correct the marker.`, { kind: "mismatch", declared: declaredId, marker: marker.projectId, markerPath });
376
- }
377
- return { root: taskRoot, project: { id: marker.projectId, source: "marker" } };
368
+ if (marker !== null && declaredId !== undefined && declaredId !== marker.projectId) {
369
+ const markerPath = join(marker.markerDir, PROJECT_MARKER_PATH);
370
+ throw identityError("config.project_identity_mismatch", `TaskSpec.project.id declares ${declaredId}, but this checkout's project marker ${markerPath} carries ${marker.projectId} — ` +
371
+ `the leg is refused rather than filed under the wrong project. Declare the marker's id, or correct the marker.`, { kind: "mismatch", declared: declaredId, marker: marker.projectId, markerPath });
378
372
  }
379
- const fallbackId = declaredId ?? (defaultProjectId !== undefined ? normalizeProjectId(defaultProjectId) : undefined);
380
- return fallbackId !== undefined ? { root: taskRoot, project: { id: fallbackId, source: "declared" } } : { root: taskRoot };
373
+ const verdict = marker !== null ? { id: marker.projectId, source: "marker" }
374
+ : declaredId !== undefined ? { id: declaredId, source: "declared" }
375
+ : inherited !== undefined ? { id: normalizeProjectId(inherited.id), source: "declared" }
376
+ : undefined;
377
+ if (verdict === undefined)
378
+ return { root: taskRoot };
379
+ const owner = declared ?? (inherited !== undefined && normalizeProjectId(inherited.id) === verdict.id ? inherited : undefined);
380
+ return { root: taskRoot, project: verdict, seat: Object.freeze({ ...owner, id: verdict.id }) };
381
381
  }
382
382
  export function assertMemoryProjectVerdict(sessionProject, scopes, writeScope) {
383
383
  const consumesProjectIdentity = [...scopes, ...(writeScope !== null ? [writeScope] : [])]
@@ -393,10 +393,10 @@ export function assertMemoryProjectVerdict(sessionProject, scopes, writeScope) {
393
393
  const verdict = sessionProject.project;
394
394
  if (verdict === undefined) {
395
395
  throw identityError("config.memory_project_identity", `memory scope contract v2: writeScope ${writeScope} targets projectId ${w.projectId}, ` +
396
- `but this leg has no project verdict (no .sema/project marker and no TaskSpec.projectId) — refusing a project-scoped write without a project identity.`, { kind: "write_without_verdict", writeScope, writeProjectId: w.projectId });
396
+ `but this leg has no project verdict (no .sema/project marker and no TaskSpec.project) — refusing a project-scoped write without a project identity.`, { kind: "write_without_verdict", writeScope, writeProjectId: w.projectId });
397
397
  }
398
398
  if (normalizeProjectId(w.projectId) !== normalizeProjectId(verdict.id)) {
399
399
  throw identityError("config.memory_project_identity", `memory scope contract v2: writeScope ${writeScope} targets projectId ${w.projectId}, ` +
400
- `but this leg's project verdict (${verdict.source === "marker" ? "marker .sema/project" : "declared TaskSpec.projectId"}) is ${verdict.id} — refusing a mis-addressed write.`, { kind: "write_project_mismatch", writeScope, writeProjectId: w.projectId, verdictProjectId: verdict.id, verdictSource: verdict.source });
400
+ `but this leg's project verdict (${verdict.source === "marker" ? "marker .sema/project" : "declared TaskSpec.project.id"}) is ${verdict.id} — refusing a mis-addressed write.`, { kind: "write_project_mismatch", writeScope, writeProjectId: w.projectId, verdictProjectId: verdict.id, verdictSource: verdict.source });
401
401
  }
402
402
  }
@@ -3,13 +3,14 @@ import { screenInboundEntries } from "./data-plane.js";
3
3
  import { scanMemoryFileName, scanMemoryWrite } from "./scan.js";
4
4
  import { MAX_MEMORY_BYTES } from "../memory.js";
5
5
  import { reconcileMemoryEntries } from "./sync.js";
6
+ import { memoryDeletionRecords } from "./deletion-record.js";
6
7
  import { MEMORY_ORIGIN_CAUSES } from "./types.js";
7
8
  import { directoryPinOf, landingPathOf } from "./layout.js";
8
9
  import { egressText } from "../untrusted-egress.js";
9
10
  import { REDACTION_MARKS, userinfoHolds } from "@sema-agent/primitives";
10
11
  import { isReplicableScope } from "./scope-contract.js";
11
12
  const DROP_THE_CURSOR = "drop the cursor to accept re-convergence from an empty baseline — entries changed on both sides are reported as conflicts, " +
12
- "and entries deleted on one side since the last round come back from the other side";
13
+ "and entries deleted on one side since the last round come back from the other side unless that side's store records the deletion and reads it";
13
14
  const REFUSAL_ROWS = {
14
15
  scope: {
15
16
  why: "a cursor is the baseline of one (scope, peer) partition",
@@ -38,8 +39,8 @@ const REFUSAL_ROWS = {
38
39
  outs: () => [
39
40
  "rebind — when this store holds the entries the baseline was taken over (the same store, moved to this root or bound before " +
40
41
  "cursors carried a store), persist the cursor with its store set to this store's identity (memorySyncStoreOf) and sync again",
41
- "clear — delete the cursor and sync from none, accepting that an entry deleted on either side since the last completed round " +
42
- "comes back from the other side",
42
+ "clear — delete the cursor and sync from none, accepting that deletions without a baseline no longer cross and an entry deleted on either side since the last completed round " +
43
+ "comes back from the other side unless that side's store records the deletion and reads it (a recorded deletion blocks landing as a conflict and never deletes on the peer)",
43
44
  ],
44
45
  },
45
46
  "store-plane": {
@@ -444,7 +445,26 @@ export async function syncMemoryScope(opts) {
444
445
  });
445
446
  }
446
447
  }
447
- for (const f of screenInboundEntries(resp.serverEntries.filter((e) => !rejected.has(e.id)))) {
448
+ const heldIds = new Set(fetched.map((e) => e.id));
449
+ const unbaselined = resp.serverEntries.filter((e) => !rejected.has(e.id) && baseRevs[e.id] === undefined && !heldIds.has(e.id));
450
+ const deletionBlocked = new Set();
451
+ if (unbaselined.length > 0) {
452
+ const judged = reconcileMemoryEntries({}, [], unbaselined, { local: await memoryDeletionRecords(backend, unbaselined.map((e) => e.id), scope) });
453
+ for (const c of judged.conflicts) {
454
+ deletionBlocked.add(c.id);
455
+ const record = c.deletion?.record;
456
+ conflicts.push({
457
+ side: "local",
458
+ id: c.id,
459
+ reason: record?.kind === "undecidable"
460
+ ? `deletion_record_unreadable: the center offers ${JSON.stringify(c.id)}, which this store does not hold, and whether this store deleted it cannot be read (${record.why}) — not brought back`
461
+ : `deleted_here: this store deleted ${JSON.stringify(c.id)}${c.baseRev !== undefined ? ` at rev ${JSON.stringify(c.baseRev)}` : ""} and the center offers it at rev ${JSON.stringify(c.remote?.rev)} — not brought back (re-judged next round; nothing deleted on the center)`,
462
+ ...(c.remote?.rev !== undefined ? { currentRev: c.remote.rev } : {}),
463
+ });
464
+ }
465
+ }
466
+ const landable = (id) => !rejected.has(id) && !deletionBlocked.has(id);
467
+ for (const f of screenInboundEntries(resp.serverEntries.filter((e) => landable(e.id)))) {
448
468
  rejected.add(f.id);
449
469
  conflicts.push({
450
470
  side: "local",
@@ -491,7 +511,7 @@ export async function syncMemoryScope(opts) {
491
511
  }
492
512
  const patches = [
493
513
  ...resp.serverEntries
494
- .filter((e) => !rejected.has(e.id))
514
+ .filter((e) => landable(e.id))
495
515
  .map((e) => {
496
516
  const base = baseRevs[e.id];
497
517
  return base !== undefined
@@ -514,7 +534,7 @@ export async function syncMemoryScope(opts) {
514
534
  let nextCursor = cursor;
515
535
  const warnings = [];
516
536
  if (cursorAdvanced) {
517
- const pulledRevById = new Map(resp.serverEntries.map((e) => [e.id, e.rev]));
537
+ const pulledRevById = new Map(resp.serverEntries.filter((e) => landable(e.id)).map((e) => [e.id, e.rev]));
518
538
  const pushedRevById = new Map(request.entries.map((e) => [e.id, e.rev]));
519
539
  const serverAppliedIds = new Set(resp.applied.filter((a) => a.op !== "delete").map((a) => a.id));
520
540
  const disputedIds = new Set(resp.conflicts.map((c) => c.id));
@@ -1,4 +1,5 @@
1
1
  import type { MemoryEntry, ScoredMemoryEntry } from "./types.js";
2
+ import type { DeletionRecord } from "./deletion-record.js";
2
3
  /**
3
4
  * design/142 §3 — the per-replica per-scope sync cursor: the COMMON BASELINE a reconciliation run
4
5
  * judges divergence against (`id → rev` as of the last completed sync round). This is a NEW
@@ -36,6 +37,20 @@ export interface MemorySyncConflict {
36
37
  local?: MemoryEntry;
37
38
  remote?: MemoryEntry;
38
39
  baseRev?: string;
40
+ /** Present when no baseline answered for the id and the absent side's deletion record blocked it from landing on that
41
+ * side: `record` is that side's answer (`deleted` at any version — `baseRev` carries the deleted version when known —
42
+ * or `undecidable`). A deletion record never emits a delete for the other side. */
43
+ deletion?: {
44
+ side: "local" | "remote";
45
+ record: DeletionRecord;
46
+ };
47
+ }
48
+ /** Each side's deletion records for ids it does not hold (`memoryDeletionRecords`): consulted only for an id present on
49
+ * the other side with no baseline. A side whose records are not given is judged as holding none — the caller holding
50
+ * that side's store passes them (a client's push half leaves the peer's side to the peer, which judges it). */
51
+ export interface MemorySyncDeletions {
52
+ local?: ReadonlyMap<string, DeletionRecord>;
53
+ remote?: ReadonlyMap<string, DeletionRecord>;
39
54
  }
40
55
  export interface MemorySyncPlan {
41
56
  /** Entries the LOCAL side should send to the peer (new here or changed-here-only). 独立轨 F8 —
@@ -77,10 +92,13 @@ export interface MemorySyncPlan {
77
92
  * - changed on BOTH sides, or delete-on-one × edit-on-the-other → conflict (caller's ladder);
78
93
  * - deleted on one side × UNCHANGED on the other → the delete propagates (deleteLocal/deleteRemote,
79
94
  * CAS on baseRev: without this leg removals never cross and the plan livelocks);
80
- * - present only on one side with NO baseline → new entry → propagate;
95
+ * - present only on one side with NO baseline → the absent side's deletion record ({@link MemorySyncDeletions}) decides
96
+ * only whether the id may land on that side: `never` (or omitted) ⇒ new entry → propagate; deleted (at any version)
97
+ * or `undecidable` ⇒ conflict carrying `deletion`, never a delete on the present side. Deletions cross only where a
98
+ * baseline exists;
81
99
  * - absent on both but present in baseline → cleared (cursor cleanup).
82
100
  */
83
- export declare function reconcileMemoryEntries(baseRevs: Readonly<Record<string, string>>, local: readonly MemoryEntry[], remote: readonly MemoryEntry[]): MemorySyncPlan;
101
+ export declare function reconcileMemoryEntries(baseRevs: Readonly<Record<string, string>>, local: readonly MemoryEntry[], remote: readonly MemoryEntry[], deletions?: MemorySyncDeletions): MemorySyncPlan;
84
102
  /** The baseline to persist AFTER a sync round completes: every id both sides now agree on. The
85
103
  * caller passes the POST-round entry sets (after applying push/pull and resolving conflicts). */
86
104
  export declare function nextSyncBaseline(local: readonly MemoryEntry[], remote: readonly MemoryEntry[]): Record<string, string>;
@@ -1,4 +1,4 @@
1
- export function reconcileMemoryEntries(baseRevs, local, remote) {
1
+ export function reconcileMemoryEntries(baseRevs, local, remote, deletions) {
2
2
  const plan = { push: [], pull: [], deleteLocal: [], deleteRemote: [], conflicts: [], cleared: [] };
3
3
  const localById = new Map(local.map((e) => [e.id, e]));
4
4
  const remoteById = new Map(remote.map((e) => [e.id, e]));
@@ -20,22 +20,23 @@ export function reconcileMemoryEntries(baseRevs, local, remote) {
20
20
  plan.pull.push(r);
21
21
  continue;
22
22
  }
23
- if (l !== undefined) {
24
- if (base === undefined)
25
- plan.push.push(l);
26
- else if (l.rev !== base)
27
- plan.conflicts.push({ id, local: l, baseRev: base });
28
- else
29
- plan.deleteLocal.push({ id, baseRev: base });
30
- continue;
31
- }
32
- if (r !== undefined) {
33
- if (base === undefined)
34
- plan.pull.push(r);
35
- else if (r.rev !== base)
36
- plan.conflicts.push({ id, remote: r, baseRev: base });
37
- else
38
- plan.deleteRemote.push({ id, baseRev: base });
23
+ if (l !== undefined || r !== undefined) {
24
+ const present = (l ?? r);
25
+ const side = l !== undefined ? { local: l } : { remote: r };
26
+ if (base !== undefined) {
27
+ if (present.rev !== base)
28
+ plan.conflicts.push({ id, ...side, baseRev: base });
29
+ else
30
+ (l !== undefined ? plan.deleteLocal : plan.deleteRemote).push({ id, baseRev: base });
31
+ }
32
+ else {
33
+ const absentSide = l !== undefined ? "remote" : "local";
34
+ const record = deletions?.[absentSide]?.get(id);
35
+ if (record === undefined || record.kind === "never")
36
+ (l !== undefined ? plan.push : plan.pull).push(present);
37
+ else
38
+ plan.conflicts.push({ id, ...side, ...(record.kind === "deleted" && record.rev !== undefined ? { baseRev: record.rev } : {}), deletion: { side: absentSide, record } });
39
+ }
39
40
  continue;
40
41
  }
41
42
  plan.cleared.push(id);
@@ -163,11 +163,15 @@ export declare function createModeGatePolicy(modeRef: {
163
163
  readonly current: PermissionMode;
164
164
  }, seats: ModeGateSeats): ToolPolicy;
165
165
  /**
166
- * The mode a resumed leg REQUESTS: the re-passed spec's word, else the word the checkpoint row recorded — except where the
167
- * resume approves or edits a pause whose approval requests the plan exit (`approvalRequestsPlanExit`, the one answer the
168
- * pause's faces echo: a `plan_review` over a row recorded in `plan`): the plan exits to the word the leg had before it
169
- * (`prePlanMode`, the reference implementation's ExitPlanMode: `prePlanMode ?? "default"`; absent ⇒ the leg's own default),
170
- * unless the resume names another mode — the approver's choice. A re-passed `plan` does not keep an approved plan open.
166
+ * The mode a resumed leg REQUESTS. Without a mode the approval names: the re-passed spec's word, else the word the checkpoint row
167
+ * recorded — except where the resume approves or edits a pause whose approval requests the plan exit (`approvalRequestsPlanExit`, the
168
+ * one answer the pause's faces echo: a `plan_review` over a row recorded in `plan`): the plan exits to the resume's word, else to the
169
+ * word the leg had before it (`prePlanMode`, the reference implementation's ExitPlanMode: `prePlanMode ?? "default"`; absent ⇒ the
170
+ * leg's own default). A re-passed `plan` does not keep an approved plan open.
171
+ * The mode the person's approval names (`outcome.permissionMode`, the one the decided row records), on whatever row it decides: a
172
+ * tightening of that mode holds unconditionally; a widening holds only where the ceiling it is folded under is known — the parent's
173
+ * mode with the deployment's cap (the leg's ceilings fold it after). A leg with a parent whose mode this resume was not handed
174
+ * (`parentModeUnknown`) has no known ceiling: the widening is withheld and the leg requests the mode it would without it.
171
175
  */
172
176
  export declare function modeRequestAfterResume(seat: PermissionMode | undefined, recorded: {
173
177
  readonly permissionMode?: PermissionMode;
@@ -175,7 +179,18 @@ export declare function modeRequestAfterResume(seat: PermissionMode | undefined,
175
179
  }, outcome: {
176
180
  readonly gate: string;
177
181
  readonly decision?: string;
178
- } | undefined): PermissionMode | undefined;
182
+ readonly permissionMode?: PermissionMode;
183
+ } | undefined, parentModeUnknown?: true): PermissionMode | undefined;
184
+ /** The mode an approval named that {@link modeRequestAfterResume} withholds (a widening with no known ceiling), else `undefined` —
185
+ * the one fact a leg says when it does not take the mode a person approved. */
186
+ export declare function withheldApprovalMode(seat: PermissionMode | undefined, recorded: {
187
+ readonly permissionMode?: PermissionMode;
188
+ readonly prePlanMode?: PermissionMode;
189
+ }, outcome: {
190
+ readonly gate: string;
191
+ readonly decision?: string;
192
+ readonly permissionMode?: PermissionMode;
193
+ } | undefined, parentModeUnknown?: true): PermissionMode | undefined;
179
194
  /**
180
195
  * The permission MODE's door — two refusals in the pre-first-await stretch, each by name and never a fold back to
181
196
  * absence (a mode a caller believes it declared must not silently run as another): a `permissionMode` outside
@@ -106,11 +106,17 @@ export function createModeGatePolicy(modeRef, seats) {
106
106
  },
107
107
  };
108
108
  }
109
- export function modeRequestAfterResume(seat, recorded, outcome) {
110
- const exitsPlan = outcome !== undefined && outcome.decision !== "reject" && approvalRequestsPlanExit(outcome.gate, recorded.permissionMode);
111
- if (!exitsPlan)
112
- return seat ?? recorded.permissionMode;
113
- return seat !== undefined && seat !== "plan" ? seat : recorded.prePlanMode;
109
+ export function modeRequestAfterResume(seat, recorded, outcome, parentModeUnknown) {
110
+ const approved = outcome !== undefined && outcome.decision !== "reject";
111
+ const unnamed = !approved || !approvalRequestsPlanExit(outcome.gate, recorded.permissionMode) ? (seat ?? recorded.permissionMode) : seat !== undefined && seat !== "plan" ? seat : recorded.prePlanMode;
112
+ const named = approved ? outcome.permissionMode : undefined;
113
+ if (named === undefined)
114
+ return unnamed;
115
+ return parentModeUnknown !== true || clampPermissionMode(named, unnamed ?? "default").effective === named ? named : unnamed;
116
+ }
117
+ export function withheldApprovalMode(seat, recorded, outcome, parentModeUnknown) {
118
+ const named = outcome !== undefined && outcome.decision !== "reject" ? outcome.permissionMode : undefined;
119
+ return named !== undefined && modeRequestAfterResume(seat, recorded, outcome, parentModeUnknown) !== named ? named : undefined;
114
120
  }
115
121
  export function refusePermissionModeDoors(spec) {
116
122
  const mode = spec.permissionMode;
@@ -236,7 +242,10 @@ export class PermissionModeController {
236
242
  const arming = this.arming;
237
243
  if (effective === "auto" && !this.armedForAuto && arming?.armAuto !== undefined) {
238
244
  this.armedForAuto = true;
239
- void new Promise((resolve) => resolve(arming.armAuto?.())).catch((e) => this.faultSeat.notifyAsync(() => arming.onArmFault?.(e), "permissionMode.onArmFault"));
245
+ void new Promise((resolve) => resolve(arming.armAuto?.())).catch((e) => {
246
+ this.armedForAuto = false;
247
+ this.faultSeat.notifyAsync(() => arming.onArmFault?.(e), "permissionMode.onArmFault");
248
+ });
240
249
  }
241
250
  return effective;
242
251
  }
@@ -8,6 +8,12 @@ export function receiptRefusal(message) {
8
8
  e.code = "config.invalid_argument";
9
9
  return e;
10
10
  }
11
+ function walkRefusal(message, member) {
12
+ const e = receiptRefusal(message);
13
+ if (member !== undefined)
14
+ e.member = member;
15
+ return e;
16
+ }
11
17
  export function refuseProxy(given, words) {
12
18
  if (types.isProxy(given))
13
19
  throw receiptRefusal(`${words.subject} must be a plain object, not a Proxy: its ${words.unit}s are read once off its own descriptors, and a Proxy would run its traps in that read — refused rather than wired through it`);
@@ -51,12 +57,13 @@ function readCaptured(given, words) {
51
57
  const received = receive(given, CONFIG_RECEIPT_MODE);
52
58
  if (received.ok)
53
59
  return received.value;
54
- const name = received.fault.path[0] ?? "";
60
+ const member = received.fault.path[0];
61
+ const name = member ?? "";
55
62
  if (received.fault.kind === "getter-threw")
56
- throw receiptRefusal(`${words.subject}.${name} threw while it was read ${words.moment} — a ${words.unit} is read once, here; refused rather than wired without it`);
63
+ throw walkRefusal(`${words.subject}.${name} threw while it was read ${words.moment} — a ${words.unit} is read once, here; refused rather than wired without it`, member);
57
64
  if (received.fault.kind === "prototype-moved")
58
- throw receiptRefusal(`${words.subject}'s prototype changed while its ${words.unit}s were read ${words.moment} — refused rather than wired from a moving object`);
59
- throw receiptRefusal(`${words.subject} could not be read ${words.moment}: ${describeFault(received.fault)} — refused rather than wired without it`);
65
+ throw walkRefusal(`${words.subject}'s prototype changed while its ${words.unit}s were read ${words.moment} — refused rather than wired from a moving object`, member);
66
+ throw walkRefusal(`${words.subject} could not be read ${words.moment}: ${describeFault(received.fault)} — refused rather than wired without it`, member);
60
67
  }
61
68
  function strayMembersSentence(words, stray, keys) {
62
69
  const named = stray.map((k) => {
@@ -15,8 +15,9 @@ import { type TaskSandboxSettings } from "./command-sandbox.js";
15
15
  import type { ToolExecuteContext } from "./tool-spec.js";
16
16
  import type { FastModeLeg } from "./runner/fast-mode-seat.js";
17
17
  import type { TaskSpec } from "./types.js";
18
+ import { type ProjectSeat } from "./project-seat.js";
18
19
  /** The fields of a spec the seat carries — one `Pick`, shared by the mint's input and the apply's target. */
19
- export type ParentSpecSeatFields = Pick<TaskSpec, "principal" | "isolationScope" | "oneShot" | "clientContext" | "onQuestion" | "mods" | "additionalDirectories" | "additionalReadDirectories" | "envFacts" | "sandbox" | "memoryPersistenceCapable" | "classifyAllShell" | "memory" | "compaction" | "skillListingBudgetFraction" | "skillListingMaxDescChars" | "fileHistory" | "projectMemory" | "promptForm" | "promptBinding" | "promptLocale" | "advisorModel" | "attachments" | "language" | "instructionFamily" | "fastMode" | "projectId">;
20
+ export type ParentSpecSeatFields = Pick<TaskSpec, "principal" | "isolationScope" | "oneShot" | "clientContext" | "onQuestion" | "mods" | "additionalDirectories" | "additionalReadDirectories" | "envFacts" | "sandbox" | "memoryPersistenceCapable" | "classifyAllShell" | "memory" | "compaction" | "skillListingBudgetFraction" | "skillListingMaxDescChars" | "fileHistory" | "projectMemory" | "promptForm" | "promptBinding" | "promptLocale" | "advisorModel" | "attachments" | "language" | "instructionFamily" | "fastMode" | "project">;
20
21
  /**
21
22
  * The seat a run hands its children. Every member is the parent's own value, frozen at mint (arrays copied and
22
23
  * frozen; the facts object copied). Members present iff the parent carries them — an absent member is "nothing to
@@ -88,11 +89,12 @@ export type ParentSpecSeatFields = Pick<TaskSpec, "principal" | "isolationScope"
88
89
  * word as the stream verb (`TaskStream.setFastMode`) last set it ({@link bindParentSpecSeatFastMode}), the spec's word before a
89
90
  * leg is bound — so a toggle reaches every child started after it. Not a clamp: either word travels as written. An ORDINARY
90
91
  * member (fill law): a child's own word stands.
91
- * · `projectId` — the parent leg's project-identity verdict id, bound once after `resolveSessionProject`
92
- * ({@link bindParentSpecSeatProjectId}) so delegation spawners can pass it on `RunInternals.parentProjectId` as a
93
- * low-priority default (used only when the child declares no `projectId` and its own workspace has no marker).
94
- * Deliberately NOT copied onto `TaskSpec.projectId` by {@link applyParentSpecSeat}, because a child's own workspace
95
- * marker must beat the inherited default rather than mismatch against it.
92
+ * · `project` — the parent leg's project SEAT: its verdict's id with the texts that belong to it (`SessionProjectVerdict.seat`; a
93
+ * parent judged by its marker alone hands `{ id }`), bound once after `resolveSessionProject` ({@link bindParentSpecSeatProject}).
94
+ * Every spawner hands it on `RunInternals.parentProject` as the child's DEFAULT (its id used only when the child declares no
95
+ * `project` and its own workspace has no marker; its texts only when the child's verdict is its id) — and a waker hands its own
96
+ * to the agent it wakes. Deliberately NOT copied onto `TaskSpec.project` by {@link applyParentSpecSeat}: a declaration is compared
97
+ * with the child's marker, and a child's own workspace marker must beat the inherited default rather than mismatch against it.
96
98
  */
97
99
  export interface ParentSpecSeat {
98
100
  readonly principal?: string;
@@ -123,7 +125,7 @@ export interface ParentSpecSeat {
123
125
  readonly language?: string;
124
126
  readonly instructionFamily?: TaskSpec["instructionFamily"];
125
127
  readonly fastMode?: boolean;
126
- readonly projectId?: string;
128
+ readonly project?: ProjectSeat;
127
129
  }
128
130
  /** Refuse (by name, `config.deps_retired_key`) a seat that still carries a retired member. Read at every door a seat enters
129
131
  * by hand: the ctx reader, the apply, and the send lane's waker clamps. */
@@ -131,10 +133,10 @@ export declare function assertParentSpecSeatCurrent(seat: object | undefined): v
131
133
  /** Bind the seat a leg minted to that leg's fast mode: from now on the seat's `fastMode` is what the leg asks for at the moment it
132
134
  * is read — a child started after a toggle is filled with the toggled word. Once per seat, by the leg that minted it. */
133
135
  export declare function bindParentSpecSeatFastMode(seat: ParentSpecSeat, leg: Pick<FastModeLeg, "requested">): void;
134
- /** Bind the seat a leg minted to that leg's resolved project verdict id (`sessionProject.project?.id`): from now on the seat's
135
- * `projectId` is the leg's verdict id (whether from marker or declaration, or `undefined` when absent). Bound once per seat,
136
- * after `resolveSessionProject` runs, so mount validation still runs before the marker walk. */
137
- export declare function bindParentSpecSeatProjectId(seat: ParentSpecSeat, projectId: string | undefined): void;
136
+ /** Bind the seat a leg minted to that leg's resolved project seat (`sessionProject.seat`): from now on the seat's `project` is the
137
+ * leg's (`undefined` when the leg has no verdict). Bound once per seat, after `resolveSessionProject` runs, so mount validation still
138
+ * runs before the marker walk. */
139
+ export declare function bindParentSpecSeatProject(seat: ParentSpecSeat, project: ProjectSeat | undefined): void;
138
140
  /** Mint the seat off the parent's REBOUND spec and its frozen question face (spec over deps — the caller resolves it once,
139
141
  * the same value the parent's own question routing reads). Absent fields stay absent; `oneShot` only when `true`. `fastMode` is
140
142
  * read when it is read: the bound leg's ask ({@link bindParentSpecSeatFastMode}) — `undefined` while the leg asks for nothing and
@@ -3,6 +3,7 @@ import { assertNoRetiredKeys } from "./retired-keys.js";
3
3
  import { mergeChildSandbox, receiveTaskSandbox } from "./command-sandbox.js";
4
4
  import { codedRefusal } from "./thrown-value.js";
5
5
  import { isolationScopeOf } from "./isolation-scope.js";
6
+ import { screenProjectSeat } from "./project-seat.js";
6
7
  function frozenDataCopy(v) {
7
8
  if (Array.isArray(v))
8
9
  return Object.freeze(Array.from(v, (x) => frozenDataCopy(x)));
@@ -18,24 +19,27 @@ export function assertParentSpecSeatCurrent(seat) {
18
19
  assertNoRetiredKeys(seat, RETIRED_PARENT_SPEC_SEAT_KEYS, "ParentSpecSeat");
19
20
  }
20
21
  const SEAT_FAST_MODE_LEG = new WeakMap();
21
- const SEAT_PROJECT_ID = new WeakMap();
22
+ const SEAT_PROJECT = new WeakMap();
22
23
  export function bindParentSpecSeatFastMode(seat, leg) {
23
24
  const cell = SEAT_FAST_MODE_LEG.get(seat);
24
25
  if (cell === undefined || cell.leg !== undefined)
25
26
  throw new Error("parentSpecSeat: a seat's fast mode is bound once, by the leg that minted it");
26
27
  cell.leg = leg;
27
28
  }
28
- export function bindParentSpecSeatProjectId(seat, projectId) {
29
- const cell = SEAT_PROJECT_ID.get(seat);
29
+ export function bindParentSpecSeatProject(seat, project) {
30
+ const cell = SEAT_PROJECT.get(seat);
30
31
  if (cell === undefined || cell.bound)
31
- throw new Error("parentSpecSeat: a seat's project id is bound once, by the leg that minted it");
32
+ throw new Error("parentSpecSeat: a seat's project is bound once, by the leg that minted it");
32
33
  cell.bound = true;
33
- cell.id = projectId;
34
+ cell.seat = project;
34
35
  }
35
36
  export function parentSpecSeatOf(spec, frozenOnQuestion) {
36
37
  const word = spec.fastMode;
37
38
  const cell = {};
38
- const projectWord = spec.projectId;
39
+ const minted = screenProjectSeat(spec.project, "ParentSpecSeatFields.project");
40
+ if (!minted.ok)
41
+ throw codedRefusal(minted.code, minted.message);
42
+ const projectWord = minted.seat;
39
43
  const projectCell = { bound: false };
40
44
  const seat = Object.freeze({
41
45
  ...(spec.principal !== undefined ? { principal: spec.principal } : {}),
@@ -66,13 +70,13 @@ export function parentSpecSeatOf(spec, frozenOnQuestion) {
66
70
  const asked = cell.leg?.requested;
67
71
  return asked === undefined || (!asked && word === undefined) ? word : asked;
68
72
  },
69
- get projectId() {
70
- return projectCell.bound ? projectCell.id : projectWord;
73
+ get project() {
74
+ return projectCell.bound ? projectCell.seat : projectWord;
71
75
  },
72
76
  ...clampFieldSeatsOf(spec),
73
77
  });
74
78
  SEAT_FAST_MODE_LEG.set(seat, cell);
75
- SEAT_PROJECT_ID.set(seat, projectCell);
79
+ SEAT_PROJECT.set(seat, projectCell);
76
80
  return seat;
77
81
  }
78
82
  export function applyParentSpecSeat(child, seat) {
@@ -8,7 +8,7 @@ import { optionKeys, strayMembersOf } from "./own-property-receipt.js";
8
8
  import { readMember, readOwnMembers } from "./thrown-value.js";
9
9
  import { assertEndpointBound, httpTrimmed, resolveProtocolHttpHeaders } from "./protocol-http-auth.js";
10
10
  import { askCarriedRevocation } from "./protocol-revocation.js";
11
- import { credentialHeaderValues, holdOwnCredentialValues, isSecretEnvKey, namesASecret } from "./secret-env.js";
11
+ import { credentialHeaderValues, entryLooksLikeCredential, holdOwnCredentialValues, namesASecret } from "./secret-env.js";
12
12
  import { inlineUntrusted } from "./untrusted-text.js";
13
13
  const PEER_SEAT_MEMBERS = Object.freeze(["answer", "hold", "release"]);
14
14
  const RECEIVED = new WeakMap();
@@ -438,7 +438,7 @@ export class PeerCarrier {
438
438
  const pieces = read.carry;
439
439
  this.holdAnswered(pieces);
440
440
  for (const [name, value] of Object.entries(pieces.env ?? {}))
441
- if (isSecretEnvKey(name, value))
441
+ if (entryLooksLikeCredential(name, value))
442
442
  this.remember(value);
443
443
  if (this.lane === "stdio")
444
444
  this.expiresAt = pieces.expiresAt;
@@ -475,7 +475,7 @@ function answeredCredentialValues(answer) {
475
475
  found.add(credential);
476
476
  }
477
477
  for (const [name, value] of stringMembers(members["env"]))
478
- if (isSecretEnvKey(name, value))
478
+ if (entryLooksLikeCredential(name, value))
479
479
  found.add(value);
480
480
  return [...found];
481
481
  }