@sema-agent/core 7.64.0 → 7.66.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 (192) hide show
  1. package/CHANGELOG.md +571 -0
  2. package/dist/agents/delegation-registry-seat.d.ts +15 -0
  3. package/dist/agents/delegation-registry-seat.js +13 -0
  4. package/dist/agents/org-delivery-gate.d.ts +8 -1
  5. package/dist/agents/org-delivery-gate.js +9 -3
  6. package/dist/agents/peer-held-queue.js +1 -1
  7. package/dist/agents/peer-idle.js +1 -1
  8. package/dist/agents/peer-session-drain.d.ts +51 -12
  9. package/dist/agents/peer-session-drain.js +47 -34
  10. package/dist/agents/read-inbox-tool.d.ts +6 -2
  11. package/dist/agents/read-inbox-tool.js +18 -5
  12. package/dist/agents/subagent.d.ts +3 -1
  13. package/dist/agents/subagent.js +84 -77
  14. package/dist/brain/reasoning.d.ts +2 -0
  15. package/dist/brain/reasoning.js +1 -0
  16. package/dist/core/allow-entry.d.ts +9 -0
  17. package/dist/core/allow-entry.js +7 -1
  18. package/dist/core/ask-origin.d.ts +23 -3
  19. package/dist/core/ask-origin.js +11 -1
  20. package/dist/core/auto-promote.d.ts +3 -2
  21. package/dist/core/background-agent-store.d.ts +7 -0
  22. package/dist/core/checkpoint-store.d.ts +2 -3
  23. package/dist/core/context-settings.d.ts +1 -2
  24. package/dist/core/context-settings.js +1 -1
  25. package/dist/core/engine-attestation.d.ts +2 -2
  26. package/dist/core/engine-notice.d.ts +13 -1
  27. package/dist/core/engine-notice.js +3 -1
  28. package/dist/core/file-history-store.d.ts +2 -2
  29. package/dist/core/file-history-store.js +0 -4
  30. package/dist/core/gate-fold.js +3 -1
  31. package/dist/core/governance-codes.d.ts +6 -4
  32. package/dist/core/governance-codes.js +5 -3
  33. package/dist/core/human-input-projection.d.ts +9 -0
  34. package/dist/core/human-input-projection.js +13 -0
  35. package/dist/core/input-author.d.ts +66 -6
  36. package/dist/core/input-author.js +21 -3
  37. package/dist/core/leg-identity.d.ts +18 -2
  38. package/dist/core/leg-identity.js +5 -7
  39. package/dist/core/mailbox-store.d.ts +1 -1
  40. package/dist/core/memory-engine/consolidation.d.ts +30 -10
  41. package/dist/core/memory-engine/consolidation.js +41 -6
  42. package/dist/core/memory-engine/control-objects.d.ts +36 -3
  43. package/dist/core/memory-engine/control-objects.js +134 -12
  44. package/dist/core/memory-engine/control-plane-adoption.d.ts +13 -9
  45. package/dist/core/memory-engine/control-plane-adoption.js +58 -31
  46. package/dist/core/memory-engine/delegation-settlement.d.ts +75 -52
  47. package/dist/core/memory-engine/delegation-settlement.js +211 -228
  48. package/dist/core/memory-engine/dual-root.d.ts +3 -2
  49. package/dist/core/memory-engine/dual-root.js +5 -1
  50. package/dist/core/memory-engine/engine.d.ts +33 -16
  51. package/dist/core/memory-engine/engine.js +213 -177
  52. package/dist/core/memory-engine/file-backend.d.ts +21 -12
  53. package/dist/core/memory-engine/file-backend.js +58 -104
  54. package/dist/core/memory-engine/index.d.ts +2 -2
  55. package/dist/core/memory-engine/index.js +2 -2
  56. package/dist/core/memory-engine/layout.d.ts +184 -83
  57. package/dist/core/memory-engine/layout.js +267 -172
  58. package/dist/core/memory-engine/memory-age.d.ts +12 -0
  59. package/dist/core/memory-engine/memory-age.js +17 -0
  60. package/dist/core/memory-engine/memory-backend-contract.js +12 -11
  61. package/dist/core/memory-engine/memory-deployment.d.ts +4 -3
  62. package/dist/core/memory-engine/memory-deployment.js +6 -3
  63. package/dist/core/memory-engine/origin-clearance.d.ts +43 -15
  64. package/dist/core/memory-engine/origin-clearance.js +142 -58
  65. package/dist/core/memory-engine/tools.d.ts +2 -2
  66. package/dist/core/memory-engine/tools.js +7 -7
  67. package/dist/core/memory-engine/types.d.ts +16 -10
  68. package/dist/core/memory-vector.d.ts +6 -14
  69. package/dist/core/memory.d.ts +0 -462
  70. package/dist/core/memory.js +0 -333
  71. package/dist/core/model-receipt.d.ts +2 -1
  72. package/dist/core/model-receipt.js +5 -0
  73. package/dist/core/mods/dollar.d.ts +12 -0
  74. package/dist/core/mods/kernel/dispatch.d.ts +3 -1
  75. package/dist/core/mods/kernel/dispatch.js +5 -2
  76. package/dist/core/mods/kernel/events.d.ts +3 -1
  77. package/dist/core/mods/kernel/events.js +2 -2
  78. package/dist/core/mods/prompt-submit.d.ts +4 -0
  79. package/dist/core/mods/prompt-submit.js +24 -0
  80. package/dist/core/mods/stations.d.ts +23 -4
  81. package/dist/core/mods/stations.js +14 -7
  82. package/dist/core/permission-rule-consent.d.ts +49 -18
  83. package/dist/core/permission-rule-consent.js +59 -38
  84. package/dist/core/permission-rule-store.d.ts +24 -14
  85. package/dist/core/retention.d.ts +2 -7
  86. package/dist/core/retention.js +0 -1
  87. package/dist/core/retired-host-table-account.d.ts +19 -0
  88. package/dist/core/retired-host-table-account.js +28 -0
  89. package/dist/core/retired-tool-name-account.d.ts +60 -0
  90. package/dist/core/retired-tool-name-account.js +32 -0
  91. package/dist/core/roles.d.ts +3 -1
  92. package/dist/core/roles.js +5 -2
  93. package/dist/core/runner/classifier-ladder.d.ts +3 -1
  94. package/dist/core/runner/classifier-ladder.js +2 -2
  95. package/dist/core/runner/compact-session.js +2 -1
  96. package/dist/core/runner/contracts.d.ts +9 -9
  97. package/dist/core/runner/delegation-owner.d.ts +0 -8
  98. package/dist/core/runner/delegation-owner.js +1 -3
  99. package/dist/core/runner/gate-exit.js +9 -2
  100. package/dist/core/runner/memory-consolidation-driver.js +2 -2
  101. package/dist/core/runner/prepare-config-doors.js +1 -1
  102. package/dist/core/runner/prepare-delegation-surface.d.ts +1 -1
  103. package/dist/core/runner/prepare-delegation-surface.js +5 -3
  104. package/dist/core/runner/prepare-gate-stations.d.ts +8 -5
  105. package/dist/core/runner/prepare-gate-stations.js +13 -5
  106. package/dist/core/runner/prepare-inherited-gate.js +2 -0
  107. package/dist/core/runner/prepare-memory-engine-session.js +1 -1
  108. package/dist/core/runner/prepare-memory.js +35 -14
  109. package/dist/core/runner/prepare-policy-chain.js +12 -3
  110. package/dist/core/runner/prepare-project-context.js +2 -2
  111. package/dist/core/runner/prepare-task.d.ts +9 -1
  112. package/dist/core/runner/prepare-task.js +6 -5
  113. package/dist/core/runner/prepare-wiring-manifest.js +5 -4
  114. package/dist/core/runner/prompt-suggestions.js +1 -1
  115. package/dist/core/runner/run-identity-wiring.js +2 -2
  116. package/dist/core/runner/run-leg.js +3 -3
  117. package/dist/core/runner/run-notification-lane.d.ts +3 -0
  118. package/dist/core/runner/run-notification-lane.js +2 -2
  119. package/dist/core/runner/runtask.js +6 -3
  120. package/dist/core/runner/steer-admission.d.ts +11 -2
  121. package/dist/core/runner/stream-steer-verb.d.ts +5 -2
  122. package/dist/core/runner/stream-steer-verb.js +67 -14
  123. package/dist/core/runner/sub-agent-deny-lists.d.ts +8 -8
  124. package/dist/core/runner/sub-agent-deny-lists.js +22 -8
  125. package/dist/core/runner-deps.d.ts +4 -4
  126. package/dist/core/secret-env.d.ts +2 -2
  127. package/dist/core/secret-env.js +6 -20
  128. package/dist/core/session-store.d.ts +6 -6
  129. package/dist/core/session-store.js +3 -3
  130. package/dist/core/shell-run-candidates.js +3 -3
  131. package/dist/core/side-query.js +1 -1
  132. package/dist/core/skill-grant.d.ts +7 -0
  133. package/dist/core/skill-grant.js +14 -5
  134. package/dist/core/store-contracts/background-agent-store-contract.js +13 -0
  135. package/dist/core/task-event.d.ts +14 -0
  136. package/dist/core/task-notification.d.ts +35 -8
  137. package/dist/core/task-notification.js +31 -13
  138. package/dist/core/task-registry-agent.js +1 -0
  139. package/dist/core/task-registry-shared.d.ts +4 -0
  140. package/dist/core/tool-errors.d.ts +3 -3
  141. package/dist/core/tool-policy.js +2 -3
  142. package/dist/core/tool-spec.d.ts +20 -10
  143. package/dist/core/user-attachment.d.ts +5 -1
  144. package/dist/core/user-attachment.js +11 -5
  145. package/dist/core/write-protect.d.ts +16 -0
  146. package/dist/core/write-protect.js +10 -0
  147. package/dist/engine/harness/agent-harness.d.ts +19 -11
  148. package/dist/engine/harness/agent-harness.js +7 -4
  149. package/dist/engine/llm/types.d.ts +22 -10
  150. package/dist/engine/session/repo-utils.d.ts +14 -4
  151. package/dist/engine/session/repo-utils.js +5 -4
  152. package/dist/index.d.ts +10 -8
  153. package/dist/index.js +9 -7
  154. package/dist/prompts/default.d.ts +1 -2
  155. package/dist/scenarios/full-body.d.ts +1 -1
  156. package/dist/shell/lex.d.ts +50 -15
  157. package/dist/shell/lex.js +43 -9
  158. package/dist/stores/file/adoption/adopt.d.ts +1 -1
  159. package/dist/stores/file/index.d.ts +1 -15
  160. package/dist/stores/file/index.js +1 -15
  161. package/dist/stores/file/permission-rule-store.d.ts +12 -1
  162. package/dist/stores/file/permission-rule-store.js +31 -4
  163. package/dist/stores/file/session-store.js +1 -1
  164. package/dist/tools/fs/fs-bash.js +3 -3
  165. package/dist/tools/fs/removal-targets.d.ts +8 -2
  166. package/dist/tools/fs/removal-targets.js +31 -4
  167. package/dist/tools/fs/shell-read-argv.js +7 -1
  168. package/dist/tools/fs/shell-read-bindings.d.ts +21 -5
  169. package/dist/tools/fs/shell-read-bindings.js +130 -44
  170. package/dist/tools/fs/shell-read-plan.js +95 -29
  171. package/dist/tools/fs/shell-read-sourced.d.ts +25 -0
  172. package/dist/tools/fs/shell-read-sourced.js +119 -0
  173. package/dist/tools/fs/shell-read-word.d.ts +2 -2
  174. package/dist/tools/fs/shell-read-word.js +4 -5
  175. package/dist/tools/fs/shell-read-workdir.d.ts +19 -3
  176. package/dist/tools/fs/shell-read-workdir.js +60 -15
  177. package/dist/tools/fs/shell-reentry-text.d.ts +10 -2
  178. package/dist/tools/fs/shell-reentry-text.js +11 -4
  179. package/package.json +2 -2
  180. package/test/export-surface.snapshot.json +21 -79
  181. package/wire-changes/core-stores-sql@7.65.0.json +30 -0
  182. package/wire-changes/core-stores-sql@7.66.0.json +30 -0
  183. package/wire-changes/core@7.65.0.json +1650 -0
  184. package/wire-changes/core@7.66.0.json +1218 -0
  185. package/wire-changes/mods-kernel@7.65.0.json +30 -0
  186. package/wire-changes/mods-kernel@7.66.0.json +65 -0
  187. package/wire-changes/primitives@7.65.0.json +337 -0
  188. package/wire-changes/primitives@7.66.0.json +30 -0
  189. package/dist/core/memory-recall.d.ts +0 -208
  190. package/dist/core/memory-recall.js +0 -136
  191. package/dist/stores/file/memory-store.d.ts +0 -124
  192. package/dist/stores/file/memory-store.js +0 -353
@@ -1,6 +1,6 @@
1
1
  import { types } from "node:util";
2
2
  import { engineVersion } from "../version.js";
3
- import { resolveModel } from "../roles.js";
3
+ import { resolveModel, resolveTaskModel } from "../roles.js";
4
4
  import { brainToRuntime } from "../runtime.js";
5
5
  import { deliverEngineNotice } from "../engine-notice.js";
6
6
  import { extensionWords } from "../untrusted-egress.js";
@@ -138,6 +138,7 @@ export async function dispatchClassic(bus, event, e, options) {
138
138
  const check = options.checkAnswer;
139
139
  return await bus.dispatch(event, e, {
140
140
  bottom: engineCore,
141
+ ...(options.raisedUnder !== undefined ? { frames: options.raisedUnder.frames, origin: options.raisedUnder.origin } : {}),
141
142
  ...(options.participant !== undefined ? { participant: options.participant } : {}),
142
143
  ...(options.signal !== undefined ? { signal: options.signal } : {}),
143
144
  ...(check !== undefined ? { checkAnswer: (a, ce, by, below, run) => (a === ENGINE_CORE_ANSWER ? undefined : check(a, ce, by, below, run)) } : {}),
@@ -259,10 +260,13 @@ function readSubmitAnswer(a) {
259
260
  return { why: PROMPT_SUBMIT_FORM };
260
261
  }
261
262
  const PROMPT_SUBMIT_RANKS = Object.freeze({ of: (a) => (isPlainRecord(a) && Object.hasOwn(a, "drop") ? 1 : 0), top: 1 });
262
- export async function screenUserPrompt(bus, e, signal) {
263
+ const OPERATOR_SCREEN = Object.freeze({ author: "operator" });
264
+ export async function screenUserPrompt(bus, e, signal, input = OPERATOR_SCREEN) {
263
265
  if (!promptScreenHasHandlers(bus))
264
266
  return undefined;
265
- const { prompt, ...facts } = e;
267
+ const { prompt, ...classicFacts } = e;
268
+ const facts = { ...classicFacts, author: input.author, ...(input.extension !== undefined ? { extension: input.extension } : {}) };
269
+ const raisedUnder = input.raisedUnder;
266
270
  const changes = textChanges(prompt);
267
271
  const checkHandOn = (handed, by) => {
268
272
  const t = handed["text"];
@@ -274,7 +278,7 @@ export async function screenUserPrompt(bus, e, signal) {
274
278
  const seen = {};
275
279
  const bottom = async (handed) => {
276
280
  const text = handed["text"];
277
- const classic = await screenClassicPrompt(bus, { ...e, prompt: text }, signal);
281
+ const classic = await screenClassicPrompt(bus, { ...e, prompt: text }, signal, raisedUnder);
278
282
  if (classic !== undefined)
279
283
  seen.classic = classic;
280
284
  if (classic === undefined || (classic.kind === "answered" && !classic.block))
@@ -293,7 +297,7 @@ export async function screenUserPrompt(bus, e, signal) {
293
297
  };
294
298
  let outcome;
295
299
  try {
296
- outcome = await bus.dispatch("prompt.submit", { ...facts, text: prompt }, { bottom, checkAnswer, checkHandOn, ranks: PROMPT_SUBMIT_RANKS, ...(signal !== undefined ? { signal } : {}) });
300
+ outcome = await bus.dispatch("prompt.submit", { ...facts, text: prompt }, { bottom, checkAnswer, checkHandOn, ranks: PROMPT_SUBMIT_RANKS, ...(signal !== undefined ? { signal } : {}), ...(raisedUnder !== undefined ? { frames: raisedUnder.frames, origin: raisedUnder.origin } : {}) });
297
301
  }
298
302
  catch (err) {
299
303
  return { kind: "failed", registration: "engine", cause: "threw", reason: `could not raise the screen: ${describeThrown(err)}`, skipped: [] };
@@ -314,11 +318,12 @@ export async function screenUserPrompt(bus, e, signal) {
314
318
  return { kind: "answered", text: prompt, ...context };
315
319
  return { kind: "answered", text: read.text, rewrittenBy: changes.rewrittenBy(), ...context };
316
320
  }
317
- async function screenClassicPrompt(bus, e, signal) {
321
+ async function screenClassicPrompt(bus, e, signal, raisedUnder) {
318
322
  let outcome;
319
323
  try {
320
324
  outcome = await dispatchClassic(bus, "classic.UserPromptSubmit", e, {
321
325
  ...(signal !== undefined ? { signal } : {}),
326
+ ...(raisedUnder !== undefined ? { raisedUnder } : {}),
322
327
  checkAnswer: stringMembersAnswer("classic.UserPromptSubmit", ["block", "additionalContext"]),
323
328
  ranks: USER_PROMPT_RANKS,
324
329
  });
@@ -518,6 +523,7 @@ function lateView() {
518
523
  "session.append": (args, ctx) => need("session.append").sessionAppend(args, ctx),
519
524
  "session.send": (args, ctx) => need("session.send").sessionSend(args, ctx),
520
525
  "session.compact": (args, ctx) => need("session.compact").sessionCompact(args, ctx),
526
+ "prompt.submit": (args, ctx) => need("prompt.submit").promptSubmit(args, ctx),
521
527
  },
522
528
  bind: (s) => {
523
529
  seats = s;
@@ -580,7 +586,7 @@ export function legFacadeSeats(input) {
580
586
  const model = request.model !== undefined ? resolveModel(request.model, input.deps.models) : input.model;
581
587
  answeredBy.set(model.id, model);
582
588
  const auth = await input.spec.getApiKeyAndHeaders?.(model);
583
- const reply = await runtime.completeSimple(model, { ...request.context, messages: [...request.context.messages] }, { signal, maxTokens: request.maxTokens, ...(auth?.apiKey !== undefined ? { apiKey: auth.apiKey } : {}), ...(auth?.headers !== undefined ? { headers: auth.headers } : {}) });
589
+ const reply = await runtime.completeSimple(model, { ...request.context, messages: [...request.context.messages] }, { signal, maxTokens: request.maxTokens, reasoning: resolveTaskModel({ model }, {}).thinking, ...(auth?.apiKey !== undefined ? { apiKey: auth.apiKey } : {}), ...(auth?.headers !== undefined ? { headers: auth.headers } : {}) });
584
590
  if (reply.stopReason === "error" || reply.stopReason === "aborted")
585
591
  throw new Error(`model.complete: ${reply.errorMessage ?? reply.stopReason}`);
586
592
  if (reply.usage !== undefined)
@@ -612,6 +618,7 @@ export function legFacadeSeats(input) {
612
618
  sessionAppend: input.sessionAppend,
613
619
  sessionSend: input.sessionSend,
614
620
  sessionCompact: input.sessionCompact,
621
+ promptSubmit: input.promptSubmit,
615
622
  };
616
623
  }
617
624
  export async function admitModChain(seats, onError) {
@@ -307,7 +307,10 @@ export declare function mintRuleTicket(recordId: string, candidateIndex: number)
307
307
  * field in which to write a rule of one's own, on this entry as on the redemption entry.
308
308
  *
309
309
  * `toolCallId` and `boundInputHash` are recorded so an auditor can tie the record back to the exact ask,
310
- * and a command the lane cannot speak for yields no record and no tickets at all.
310
+ * and a command the lane cannot speak for yields no record and no tickets at all (`undefined`). A record the approval-record
311
+ * store fails to create answers the refusal, not a rejection: `status: "refused"`, `code` `store_write`, `committed` `no`,
312
+ * `retriable` `true` (no rule is written here; a backend can commit the record and lose its acknowledgement, but nobody holds
313
+ * that record's id, so a repeat prepares a fresh card).
311
314
  *
312
315
  * What this does NOT claim: that the command named here is the command that was displayed. A surface that
313
316
  * shows one thing and says another is the same-layer trust §5 already states plainly — in an in-process
@@ -376,7 +379,7 @@ export declare function prepareCardApproval(opts: {
376
379
  offers: readonly RuleOffer[];
377
380
  tickets: RuleTicket[];
378
381
  candidates: RuleCandidate[];
379
- } | undefined>;
382
+ } | StoreRefusal | undefined>;
380
383
  /**
381
384
  * The authenticated confirmation transfer: pending → approved.
382
385
  *
@@ -430,8 +433,15 @@ export declare function confirmRuleApproval(opts: {
430
433
  * (missing echo, a record minted without one, or a different card). Refused BEFORE anything else,
431
434
  * settled replays included, and never returns a minted ticket;
432
435
  * - `"edit_rejected"` — the edited text failed a gate (validator refusal, coverage, record shape);
433
- * `detail` carries the specifics. */
434
- export type ConfirmRefusalReason = "record_not_found" | "record_schema_stale" | "record_malformed" | "selection_missing" | "selection_invalid" | "selection_mismatch" | "not_pending" | "conflict" | "edit_disabled" | "edit_binding_mismatch" | "edit_rejected";
436
+ * `detail` carries the specifics.
437
+ * The two storage words are the approval-record store's failure, in the words the redemption leg answers it in
438
+ * ({@link RuleRefusalCode}), minted by the same step ({@link storeStep}); `detail.message` carries the store's own message:
439
+ * - `"store_read"` — a read of the record threw, before anything of this confirmation was written;
440
+ * - `"store_write"` — the compare-and-set that records the confirmation threw: a backend can commit and lose its
441
+ * acknowledgement, so the record may or may not be settled — repeat the same confirmation, which a settled record
442
+ * answers as the idempotent yes.
443
+ * A confirmation writes no rule, so it carries no `committed` of its own: the word says what happened to the record. */
444
+ export type ConfirmRefusalReason = "record_not_found" | "record_schema_stale" | "record_malformed" | "selection_missing" | "selection_invalid" | "selection_mismatch" | "not_pending" | "conflict" | "edit_disabled" | "edit_binding_mismatch" | "edit_rejected" | "store_read" | "store_write";
435
445
  /** The confirmation outcome: landed, or refused with a named reason.
436
446
  *
437
447
  * `mintedCandidate` (additive) is present exactly when an EDITED candidate settled this confirmation —
@@ -440,8 +450,9 @@ export type ConfirmRefusalReason = "record_not_found" | "record_schema_stale" |
440
450
  * second card). `rule` is the CANONICAL spelling, which may differ from the submitted bytes (spelling
441
451
  * normalization); a surface echoes it back so the person sees the form that will actually persist.
442
452
  *
443
- * `detail` (additive, refusal arm) rides `edit_rejected`: `code` is the shared validator's refusal
444
- * code when the validator is what refused, absent when another gate did; `message` always says why. */
453
+ * `detail` (additive, refusal arm) rides `edit_rejected` and the two storage words: `code` is the shared validator's refusal
454
+ * code when the validator is what refused, absent when another gate did (and always absent beside a storage word); `message`
455
+ * always says why. */
445
456
  export type ConfirmResult = {
446
457
  ok: true;
447
458
  mintedCandidate?: {
@@ -512,7 +523,8 @@ export type EditedRuleTextPrecheck = {
512
523
  * so the surface's move is to not offer the edit box at all.
513
524
  */
514
525
  export declare function precheckEditedRuleText(text: string, command: string): EditedRuleTextPrecheck;
515
- /** What a redemption produced. `alreadyRedeemed` marks the replay path — the same dot, no second rule.
526
+ /** What a redemption produced. `alreadyRedeemed` marks the replay path — the same dot, no second rule. `redeemed` says
527
+ * the rule stands: a replayed dot the person removed since answers `dot_removed`, never `redeemed`.
516
528
  *
517
529
  * `rev` is the DURABLE store's revision. A session-scope redemption (design/382 §4.3) lands in the
518
530
  * session overlay and does not move it: its `rev` is a best-effort read of the store's current
@@ -522,7 +534,8 @@ export declare function precheckEditedRuleText(text: string, command: string): E
522
534
  * A refusal is one shape wherever this module refuses — the single ticket, the batch's own record-level refusals and
523
535
  * (with the member's identity beside them) a batch member's row: `reason` is the sentence for a person and is never
524
536
  * parsed, `code` the cause ({@link RuleRefusalCode}), `committed` what may be claimed about the bytes
525
- * ({@link RuleWriteCommitted}). */
537
+ * ({@link RuleWriteCommitted}), `retriable` whether repeating the same call may land what this one did not
538
+ * ({@link refusalRetriable}). */
526
539
  export type RedeemResult = {
527
540
  status: "redeemed";
528
541
  behavior: RuleBehavior;
@@ -535,8 +548,16 @@ export type RedeemResult = {
535
548
  status: "refused";
536
549
  code: RuleRefusalCode;
537
550
  committed: RuleWriteCommitted;
551
+ retriable: boolean;
538
552
  reason: string;
539
553
  };
554
+ /** What a step of this module that asks the approval-record store (or the writer's dot allocation) answers when it fails: the
555
+ * one mint's refusal, narrowed to the two words a storage failure carries. */
556
+ type StoreRefusal = Extract<RedeemResult, {
557
+ status: "refused";
558
+ }> & {
559
+ readonly code: "store_read" | "store_write";
560
+ };
540
561
  /**
541
562
  * Redeem one ticket into one persisted rule.
542
563
  *
@@ -545,7 +566,7 @@ export type RedeemResult = {
545
566
  * turn a click on `git status` into a rule for something else.
546
567
  *
547
568
  * This is also the one leg every member of a batch walk takes ({@link redeemRuleBatch}), so a refusal here is the
548
- * same `code` / `committed` / `reason` a member row carries (a member's row adds the member's identity).
569
+ * same `code` / `committed` / `retriable` / `reason` a member row carries (a member's row adds the member's identity).
549
570
  */
550
571
  export declare function redeemRuleTicket(opts: {
551
572
  ticket: RuleTicket;
@@ -608,10 +629,12 @@ export interface ImportPreview {
608
629
  * independent `alreadyRedeemed` axis (the single-leg replay marker: a dot-recorded-but-unlanded
609
630
  * retry is `alreadyRedeemed: true` AND `persisted`; a rule that pre-existed in the store is
610
631
  * `false` AND `deduped` — the two axes answer different questions and neither implies the other).
611
- * A refused row always carries its `reason` (a sentence for a person, never parsed) and two closed words: `code`, the
612
- * cause ({@link RuleRefusalCode}), and `committed`, what may be claimed about the bytes — the one reading is
613
- * {@link RuleWriteCommitted}'s, stated there and not here (a member whose dot a successful read finds no longer live is
614
- * read by it too). `deduped` counts as LANDED: an equivalent rule already standing means the consent is already in effect.
632
+ * A refused row always carries its `reason` (a sentence for a person, never parsed), two closed words — `code`, the
633
+ * cause ({@link RuleRefusalCode}), and `committed`, what may be claimed about the bytes (the one reading is
634
+ * {@link RuleWriteCommitted}'s, stated there and not here; a member whose dot a successful read finds no longer live is
635
+ * read by it too) — and `retriable`, whether walking the batch again may land this member ({@link refusalRetriable},
636
+ * derived once from the two words). `deduped` counts as LANDED: an equivalent rule already standing means the consent is
637
+ * already in effect.
615
638
  *
616
639
  * design/382 §4.3 — on a SESSION-scope member the two landed words mean the same thing about a
617
640
  * different home: landed in / already in the session's OVERLAY (a session rule's home store), never
@@ -635,6 +658,7 @@ export type RedeemedBatchMember = {
635
658
  readonly status: "refused";
636
659
  readonly code: RuleRefusalCode;
637
660
  readonly committed: RuleWriteCommitted;
661
+ readonly retriable: boolean;
638
662
  readonly reason: string;
639
663
  };
640
664
  /**
@@ -651,6 +675,10 @@ export type RedeemedBatchMember = {
651
675
  * asks". An entry that does not import (a spelling with no rule form, a tool the lane does not speak
652
676
  * for, a non-string) is DISCLOSED in `skipped` with its reason and stays in the settings file.
653
677
  *
678
+ * A record the approval-record store fails to create answers the same refusal the card entry does (`status: "refused"`,
679
+ * `store_write`, `committed: no`, `retriable: true`), in place of `{ preview, approvalId }`: a preview with no record behind it
680
+ * confirms nothing.
681
+ *
654
682
  * Only a rule the store reads the way its layer does is carried. A bare tool name is not (`unsupported.form`), and
655
683
  * neither is a user-layer path pattern written from `/` (`unsupported.layer_root`, every behavior): the user layer reads
656
684
  * it at its own directory (the configuration directory), a stored global rule reads `/x` at each task's project root, and
@@ -667,7 +695,7 @@ export declare function prepareCcImport(opts: {
667
695
  }): Promise<{
668
696
  preview: ImportPreview;
669
697
  approvalId?: string;
670
- }>;
698
+ } | StoreRefusal>;
671
699
  /**
672
700
  * The factory-reviewed starter set, offered when there is nothing to import.
673
701
  *
@@ -678,7 +706,8 @@ export declare function prepareCcImport(opts: {
678
706
  */
679
707
  export declare const STARTER_RULES: readonly string[];
680
708
  /** Prepare the starter batch as a pending approval record. Nothing takes effect without confirmation;
681
- * an unconfirmed deployment simply starts with an empty rule set. */
709
+ * an unconfirmed deployment simply starts with an empty rule set. A record the approval-record store fails to create answers
710
+ * the refusal (`status: "refused"`, `store_write`, `committed: no`, `retriable: true`), as the card and import entries do. */
682
711
  export declare function prepareStarterBatch(opts: {
683
712
  principal?: string;
684
713
  owner?: RuleOwner;
@@ -686,7 +715,7 @@ export declare function prepareStarterBatch(opts: {
686
715
  }): Promise<{
687
716
  preview: RuleCandidate[];
688
717
  approvalId: string;
689
- }>;
718
+ } | StoreRefusal>;
690
719
  /**
691
720
  * Redeem the CHOSEN offer of a confirmed record, member by member — reporting what actually landed
692
721
  * rather than what was previewed (dedup, concurrency and redemption-time validation can all move a
@@ -703,7 +732,8 @@ export declare function prepareStarterBatch(opts: {
703
732
  * dot reuse included; the walk adds no concurrency primitive of its own;
704
733
  * · a refused member does NOT fold the batch: "all or nothing" is the CONFIRMATION's semantics
705
734
  * (one yes covered the whole offer), not the landing's transaction shape — the walk continues
706
- * and the member's row says refused, with its reason, cause (`code`) and claim (`committed`);
735
+ * and the member's row says refused, with its reason, cause (`code`), claim (`committed`) and whether a
736
+ * re-walk may land it (`retriable`);
707
737
  * · resuming a partial walk IS re-walking: already-landed members answer `alreadyRedeemed: true`
708
738
  * and reuse their recorded dots (two concurrent walkers converge on one dot set, zero double
709
739
  * mints), unlanded members mint on;
@@ -714,7 +744,7 @@ export declare function prepareStarterBatch(opts: {
714
744
  * partial one;
715
745
  * · a walk that cannot start (the record is missing or cannot be read, another principal's, stale, pending,
716
746
  * malformed, or the owner's store cannot be resolved) answers no table: it answers the
717
- * {@link RedeemResult} refused arm, `code` / `committed` / `reason`, the one shape a single
747
+ * {@link RedeemResult} refused arm, `code` / `committed` / `retriable` / `reason`, the one shape a single
718
748
  * ticket's refusal and a member's row take.
719
749
  */
720
750
  export declare function redeemRuleBatch(opts: {
@@ -728,3 +758,4 @@ export declare function redeemRuleBatch(opts: {
728
758
  } | Extract<RedeemResult, {
729
759
  status: "refused";
730
760
  }>>;
761
+ export {};
@@ -466,7 +466,9 @@ export async function prepareCardApproval(opts) {
466
466
  ...(opts.toolCallId !== undefined ? { toolCallId: opts.toolCallId } : {}),
467
467
  ...(opts.boundInputHash !== undefined ? { boundInputHash: opts.boundInputHash } : {}),
468
468
  };
469
- await opts.deps.approvals.create(record);
469
+ const created = await storeStep(() => opts.deps.approvals.create(record), RECORD_CREATE);
470
+ if ("refused" in created)
471
+ return created.refused;
470
472
  return {
471
473
  approvalId: record.id,
472
474
  offers: ruleOffersOfRecord(record),
@@ -491,7 +493,10 @@ export async function confirmRuleApproval(opts) {
491
493
  e.code = "config.invalid_argument";
492
494
  throw e;
493
495
  }
494
- const rec = await opts.deps.approvals.get(opts.approvalId);
496
+ const read = await storeStep(() => opts.deps.approvals.get(opts.approvalId), RECORD_READ);
497
+ if ("refused" in read)
498
+ return confirmStoreFailure(read.refused);
499
+ const rec = read.value;
495
500
  const recOwner = rec === undefined ? undefined : ownerOfRecord(rec);
496
501
  if (rec === undefined || recOwner === undefined || !sameRuleOwner(recOwner, caller))
497
502
  return no("record_not_found");
@@ -518,10 +523,15 @@ export async function confirmRuleApproval(opts) {
518
523
  return no("not_pending");
519
524
  if (rec.selectedOffer !== undefined)
520
525
  return no("record_malformed", { message: "a pending record must not already carry a chosen offer" });
521
- const won = await opts.deps.approvals.cas(rec.id, rec.rev, { ...rec, rev: rec.rev + 1, state: "approved", selectedOffer: chosen });
522
- if (won)
526
+ const casted = await storeStep(() => opts.deps.approvals.cas(rec.id, rec.rev, { ...rec, rev: rec.rev + 1, state: "approved", selectedOffer: chosen }), RECORD_CONFIRM_CAS);
527
+ if ("refused" in casted)
528
+ return confirmStoreFailure(casted.refused);
529
+ if (casted.value)
523
530
  return { ok: true };
524
- const again = await opts.deps.approvals.get(rec.id);
531
+ const reread = await storeStep(() => opts.deps.approvals.get(rec.id), RECORD_READ);
532
+ if ("refused" in reread)
533
+ return confirmStoreFailure(reread.refused);
534
+ const again = reread.value;
525
535
  if (again === undefined)
526
536
  return no("record_not_found");
527
537
  if (isStale(again))
@@ -646,9 +656,14 @@ async function confirmEditedCandidate(rec, edit, deps) {
646
656
  selectedOffer: rec.offers.length,
647
657
  edited: { index, text: edit.text, at: nowIso(deps), ...(checked.warnings !== undefined ? { warnings: checked.warnings.map((w) => w.code) } : {}) },
648
658
  };
649
- const won = await deps.approvals.cas(rec.id, rec.rev, next);
650
- if (!won) {
651
- const again = await deps.approvals.get(rec.id);
659
+ const casted = await storeStep(() => deps.approvals.cas(rec.id, rec.rev, next), RECORD_EDIT_CAS);
660
+ if ("refused" in casted)
661
+ return confirmStoreFailure(casted.refused);
662
+ if (!casted.value) {
663
+ const reread = await storeStep(() => deps.approvals.get(rec.id), RECORD_READ);
664
+ if ("refused" in reread)
665
+ return confirmStoreFailure(reread.refused);
666
+ const again = reread.value;
652
667
  if (again === undefined || isStale(again))
653
668
  return no("record_not_found");
654
669
  if (again.state === "pending")
@@ -657,20 +672,29 @@ async function confirmEditedCandidate(rec, edit, deps) {
657
672
  }
658
673
  return { ok: true, mintedCandidate: { index, rule: checked.canonicalRule, ticket: mintRuleTicket(rec.id, index) } };
659
674
  }
675
+ function refusalRetriable(code, committed) {
676
+ return (code === "store_read" || code === "store_write") && committed === "no";
677
+ }
660
678
  function refusal(code, reason, committed = "no") {
661
- return { status: "refused", code, committed, reason };
679
+ return { status: "refused", code, committed, retriable: refusalRetriable(code, committed), reason };
662
680
  }
663
681
  async function storeStep(step, failure) {
664
682
  try {
665
683
  return { value: await step() };
666
684
  }
667
685
  catch (err) {
668
- return { refused: refusal(failure.code, `${failure.what}: ${errText(err)}`, failure.code === "store_write" ? "unknown" : "no") };
686
+ return { refused: refusal(failure.code, `${failure.what}: ${errText(err)}`) };
669
687
  }
670
688
  }
671
689
  const RECORD_READ = { code: "store_read", what: "could not read the approval record" };
672
690
  const RECORD_CAS = { code: "store_write", what: "the approval record store failed the compare-and-set that records this redemption's dot" };
673
691
  const DOT_ALLOCATION = { code: "store_write", what: "the permission-rule store failed to allocate this redemption's dot" };
692
+ const RECORD_CREATE = { code: "store_write", what: "the approval record store failed to create the record" };
693
+ const RECORD_CONFIRM_CAS = { code: "store_write", what: "the approval record store failed the compare-and-set that records this confirmation" };
694
+ const RECORD_EDIT_CAS = { code: "store_write", what: "the approval record store failed the compare-and-set that records this card edit" };
695
+ function confirmStoreFailure(refused) {
696
+ return { ok: false, reason: refused.code, detail: { message: refused.reason } };
697
+ }
674
698
  export async function redeemRuleTicket(opts) {
675
699
  const caller = resolveCallerOwner(opts.principal, opts.owner, "redeemRuleTicket");
676
700
  const parsed = parseRuleTicket(opts.ticket);
@@ -764,12 +788,14 @@ async function tighteningSiblingsStand(rec, offer, index, store, durableSnapshot
764
788
  if (dot === undefined)
765
789
  return false;
766
790
  const view = sibling.scope.kind === "session" ? await effectiveOrThrow(store, { sessionId: sibling.scope.sessionId }) : durableSnapshot;
767
- const live = view.rules.some((r) => r.behavior === sibling.behavior && r.rule === sibling.rule && sameScope(r.scope, sibling.scope) && r.adds.some((a) => a.dot.actor === dot.actor && a.dot.counter === dot.counter));
768
- if (!live)
791
+ if (!redeemedDotLive(view, sibling, dot))
769
792
  return false;
770
793
  }
771
794
  return true;
772
795
  }
796
+ function redeemedDotLive(view, candidate, dot) {
797
+ return view.rules.some((r) => r.behavior === candidate.behavior && sameScope(r.scope, candidate.scope) && r.adds.some((a) => a.dot.actor === dot.actor && a.dot.counter === dot.counter));
798
+ }
773
799
  async function applyRedemption(args) {
774
800
  let store;
775
801
  try {
@@ -810,6 +836,17 @@ async function applyRedemption(args) {
810
836
  });
811
837
  if (!landing.landed)
812
838
  return refusal(landing.code, landing.reason, landing.committed);
839
+ let live = false;
840
+ try {
841
+ const snap = await effectiveOrThrow(store, args.candidate.scope.kind === "session" ? { sessionId: args.candidate.scope.sessionId } : undefined);
842
+ live = redeemedDotLive(snap, args.candidate, args.dot);
843
+ }
844
+ catch (err) {
845
+ return refusal("store_read", `could not read the permission-rule store to confirm this ${args.candidate.behavior} rule stands after its redemption: ${errText(err)}`, "unknown");
846
+ }
847
+ if (!live) {
848
+ return refusal("dot_removed", `this ${args.candidate.behavior} rule's redeemed dot ${args.dot.actor}#${args.dot.counter} is not live in the store (removed since it was redeemed) — a removed rule is not re-landed by replaying its record; a new consent is required`);
849
+ }
813
850
  return { status: "redeemed", behavior: args.parsedRule.behavior, rule: args.parsedRule.rule, scope: args.candidate.scope, dot: args.dot, rev: landing.rev, alreadyRedeemed: args.replay };
814
851
  }
815
852
  function originOfRecordKind(kind) {
@@ -931,7 +968,9 @@ export async function prepareCcImport(opts) {
931
968
  offers: [{ kind: "batch", candidates: candidates.map((_, i) => i) }],
932
969
  createdAt: nowIso(opts.deps),
933
970
  };
934
- await opts.deps.approvals.create(record);
971
+ const created = await storeStep(() => opts.deps.approvals.create(record), RECORD_CREATE);
972
+ if ("refused" in created)
973
+ return created.refused;
935
974
  return { preview, approvalId: record.id };
936
975
  }
937
976
  export const STARTER_RULES = [
@@ -965,7 +1004,9 @@ export async function prepareStarterBatch(opts) {
965
1004
  offers: [{ kind: "batch", candidates: candidates.map((_, i) => i) }],
966
1005
  createdAt: nowIso(opts.deps),
967
1006
  };
968
- await opts.deps.approvals.create(record);
1007
+ const created = await storeStep(() => opts.deps.approvals.create(record), RECORD_CREATE);
1008
+ if ("refused" in created)
1009
+ return created.refused;
969
1010
  return { preview: candidates, approvalId: record.id };
970
1011
  }
971
1012
  export async function redeemRuleBatch(opts) {
@@ -1009,7 +1050,8 @@ export async function redeemRuleBatch(opts) {
1009
1050
  for (const candidateIndex of ordered) {
1010
1051
  const candidate = rec.candidates[candidateIndex];
1011
1052
  const row = { candidateIndex, behavior: candidate.behavior, rule: candidate.rule, scope: candidate.scope };
1012
- if (candidate.behavior === "allow" && tighteningFailed !== undefined) {
1053
+ const tightening = candidate.behavior !== "allow";
1054
+ if (!tightening && tighteningFailed !== undefined) {
1013
1055
  members.push({ ...row, ...refusal("withheld", `withheld: candidate ${tighteningFailed} (a deny/ask member of this batch) did not land, and an allow must not stand wider than the list that was confirmed — redeem the batch again once the store accepts the tightening member`) });
1014
1056
  continue;
1015
1057
  }
@@ -1022,7 +1064,7 @@ export async function redeemRuleBatch(opts) {
1022
1064
  }
1023
1065
  catch (err) {
1024
1066
  members.push({ ...row, ...refusal("store_read", `could not read the permission-rule store: ${errText(err)}`) });
1025
- if (candidate.behavior !== "allow")
1067
+ if (tightening)
1026
1068
  tighteningFailed ??= candidateIndex;
1027
1069
  continue;
1028
1070
  }
@@ -1034,31 +1076,10 @@ export async function redeemRuleBatch(opts) {
1034
1076
  });
1035
1077
  if (res.status === "refused") {
1036
1078
  members.push({ ...row, ...res });
1037
- if (candidate.behavior !== "allow")
1079
+ if (tightening)
1038
1080
  tighteningFailed ??= candidateIndex;
1039
1081
  continue;
1040
1082
  }
1041
- if (candidate.behavior !== "allow") {
1042
- let live = false;
1043
- let unreadable;
1044
- try {
1045
- const snap = await effectiveOrThrow(store, candidate.scope.kind === "session" ? { sessionId: candidate.scope.sessionId } : undefined);
1046
- live = snap.rules.some((r) => r.behavior === candidate.behavior && r.rule === candidate.rule && sameScope(r.scope, candidate.scope) && r.adds.some((a) => a.dot.actor === res.dot.actor && a.dot.counter === res.dot.counter));
1047
- }
1048
- catch (err) {
1049
- unreadable = errText(err);
1050
- }
1051
- if (unreadable !== undefined) {
1052
- members.push({ ...row, ...refusal("store_read", `could not read the permission-rule store to confirm this ${candidate.behavior} member stands after its redemption: ${unreadable}`, "unknown") });
1053
- tighteningFailed ??= candidateIndex;
1054
- continue;
1055
- }
1056
- if (!live) {
1057
- members.push({ ...row, ...refusal("dot_removed", `this ${candidate.behavior} member's redeemed dot ${res.dot.actor}#${res.dot.counter} is not live in the store (removed since it was redeemed) — a removed rule is not re-landed by replaying its record; a new consent is required`) });
1058
- tighteningFailed ??= candidateIndex;
1059
- continue;
1060
- }
1061
- }
1062
1083
  rev = candidate.scope.kind === "session" ? Math.max(rev, res.rev) : res.rev;
1063
1084
  members.push({ ...row, status: alreadyThere ? "deduped" : "persisted", alreadyRedeemed: res.alreadyRedeemed, dot: res.dot });
1064
1085
  }
@@ -619,18 +619,26 @@ export type RemovalLiveness = (typeof REMOVAL_LIVENESS_WORDS)[number];
619
619
  * `"no"` = it has, and nothing does: a face that cannot write at all, a target the type face refuses,
620
620
  * a read that failed before any write, a refused preflight, an epoch seal, a compare-and-set that lost
621
621
  * every attempt. Each of those is the store saying nothing landed, so saying it is a fact. The same word
622
- * covers a write that DID land and that a read which SUCCEEDED then finds removed (a redemption walk's
623
- * `dot_removed`): the add's dot is in the raw state under its tombstone, the rule does not stand, and the
622
+ * covers a write that DID land and that a read which SUCCEEDED then finds removed (a redemption's
623
+ * `dot_removed`, at the single ticket and a batch member alike): the add's dot is in the raw state under its tombstone, the rule does not stand, and the
624
624
  * store has said so — the word is about whether the call's rule stands, never about the history of the
625
625
  * bytes, and a retry of the same ticket re-reads the same tombstone (a new consent is what lands it).
626
- * `"unknown"` = it has not: the apply THREW, which proves nothing either way (a backend can commit and
627
- * then lose its acknowledgement), or the read-back that would have settled it could not be taken. A
628
- * settled absence is never `unknown`: that word would send the caller to reconcile with `list()` for an
629
- * answer the store already gave.
630
- *
631
- * The word exists because the caller's two branches — retry, or reconcile with `list()` — are not
632
- * derivable from the failure PROSE. A consumer reading the strength out of the sentence is parsing a
633
- * message written for a person, and every such reader has to be updated by hand when the sentence is.
626
+ * The same word covers a failure at a step BEFORE the call's rule write is sent — the approval record's
627
+ * read, its creation, the compare-and-set that records the dot (or a confirmation, or a card edit), the
628
+ * dot's allocation: whatever that step's own bytes did (a compare-and-set can commit and lose its
629
+ * acknowledgement), the rule write was never issued, so the call's rule does not stand; a replay of the
630
+ * same ticket reuses the dot the record kept.
631
+ * `"unknown"` = it has not: the rule write WAS issued and the apply threw, which proves nothing either
632
+ * way (a backend can commit and then lose its acknowledgement), or the read-back after it that would have
633
+ * settled it could not be taken. A settled absence is never `unknown`: that word would send the caller to
634
+ * reconcile with `list()` for an answer the store already gave.
635
+ *
636
+ * The word exists because the caller's branch — reconcile with `list()`, or not — is not derivable from
637
+ * the failure PROSE. A consumer reading the strength out of the sentence is parsing a message written for
638
+ * a person, and every such reader has to be updated by hand when the sentence is. `no` does not say that
639
+ * repeating the call would land anything (a refused preflight, a tombstone and an epoch seal are all `no`,
640
+ * and none is cured by a retry): a redemption's refusal answers that second question beside this word, in
641
+ * its own member (`retriable`), derived once from the cause and this word, and never read off `no`.
634
642
  */
635
643
  export declare const RULE_WRITE_COMMITTED_WORDS: readonly ["no", "unknown"];
636
644
  export type RuleWriteCommitted = (typeof RULE_WRITE_COMMITTED_WORDS)[number];
@@ -643,7 +651,9 @@ export type RuleWriteCommitted = (typeof RULE_WRITE_COMMITTED_WORDS)[number];
643
651
  *
644
652
  * It rides beside {@link RuleWriteCommitted}, and the two answer different questions. The code says what stopped the
645
653
  * redemption; `committed` says what may be claimed about the bytes. The same code can carry both words (`store_read`:
646
- * a read before any write says `no`, a read-back after one that could not be taken says `unknown`).
654
+ * a read before the rule write says `no`, a read-back after it that could not be taken says `unknown`; `store_write`: a
655
+ * step before the rule write says `no`, the rule write itself `unknown`), and a consumer that needs to tell two `no`s
656
+ * apart reads the code.
647
657
  *
648
658
  * - `unsupported.layer_root` — an import record's global rule written from `/`, which no stored row can hold
649
659
  * - `ticket_invalid` — the ticket does not name a candidate (unparseable, or an index the record has none at)
@@ -657,11 +667,11 @@ export type RuleWriteCommitted = (typeof RULE_WRITE_COMMITTED_WORDS)[number];
657
667
  * - `store_unavailable` — the owner's store cannot be resolved, or has no write face
658
668
  * - `record_changed` — the record moved under this redemption and the dot it needed is not there
659
669
  * - `withheld` — held back because the batch's deny/ask members do not all stand, and an allow may not stand wider
660
- * - `store_read` — a store read failed: the permission-rule store's, or the approval record's (before the write: `no`; the read-back after it: `unknown`)
661
- * - `store_write` — the write threw, answered unreadably, or was reported landed with no trace of its dot; or the approval record's compare-and-set that records the dot, or the dot's allocation, threw (`unknown`)
670
+ * - `store_read` — a store read failed: the permission-rule store's, or the approval record's (before the rule write: `no`; the read-back after it: `unknown`); the confirmation and card-edit entries answer a failed record read with the same word
671
+ * - `store_write` — the rule write threw, answered unreadably, or was reported landed with no trace of its dot (`unknown`); or a step before it threw — the approval record's compare-and-set that records the dot (or the confirmation, or a card edit), the dot's allocation, or the record's creation at the prepare, import and starter entries (`no`: the rule write was never issued)
662
672
  * - `session_ended` — a session-scope rule whose session has ended; a late redemption cannot revive it
663
673
  * - `occ` — every optimistic-concurrency attempt lost its compare-and-set
664
- * - `dot_removed` — the member's redeemed dot is no longer live in the store (the rule was removed since); its
674
+ * - `dot_removed` — the redeemed dot (a single ticket's or a batch member's) is no longer live in the store (the rule was removed since); its
665
675
  * `committed` is `no`, the store having settled that the rule does not stand ({@link RuleWriteCommitted})
666
676
  */
667
677
  export declare const RULE_REFUSAL_CODES: readonly ["unsupported.layer_root", "ticket_invalid", "record_missing", "wrong_principal", "record_schema_stale", "not_confirmed", "record_malformed", "not_chosen", "parse_rejected", "store_unavailable", "record_changed", "withheld", "store_read", "store_write", "session_ended", "occ", "dot_removed"];
@@ -1,5 +1,4 @@
1
1
  import type { EngineStorageBackend } from "./engine-storage-backend.js";
2
- import type { MemoryStore } from "./memory.js";
3
2
  import type { WorkflowRunStore } from "./workflow-run-store.js";
4
3
  /** A store's retention declaration: `"managed"` = this store's rows are deleted on schedule by the
5
4
  * deployment; `"none"` = nothing deletes them on schedule. Absent ⇒ read fail-closed as `"none"`. */
@@ -89,10 +88,9 @@ export type RetentionCascadeDomain = (typeof RETENTION_CASCADE_DOMAINS)[number];
89
88
  * opt-out record dir and the lineage ledger are governance FACTS about content that exists, not
90
89
  * session data: deleting them makes a one-way privacy record revocable. */
91
90
  export declare const RETENTION_CASCADE_EXEMPT: readonly ["session-pollution", "session-capture-optout", "lineage.json"];
92
- /** The stores {@link RETENTION_CASCADE} covers, by seat name: every store member of {@link EngineStorageBackend}, the memory
93
- * store the bundled file backend carries beside them, and the workflow-run store a deployment constructs itself. */
91
+ /** The stores {@link RETENTION_CASCADE} covers, by seat name: every store member of {@link EngineStorageBackend} and the
92
+ * workflow-run store a deployment constructs itself. */
94
93
  export type RetentionCascadeStores = Omit<EngineStorageBackend, "retention" | "dispose"> & {
95
- readonly memoryStore: MemoryStore;
96
94
  readonly workflowRunStore: WorkflowRunStore;
97
95
  };
98
96
  /** One leg of a store's row: the store method a domain's operation calls on it. */
@@ -241,9 +239,6 @@ export declare const RETENTION_CASCADE: {
241
239
  usageWindowStore: {
242
240
  exempt: string;
243
241
  };
244
- memoryStore: {
245
- exempt: string;
246
- };
247
242
  };
248
243
  /** One session's erasure in order — {@link RETENTION_CASCADE}'s session-tree legs, ascending by step (the one reading of the order). */
249
244
  export declare const RETENTION_SESSION_TREE_STEPS: readonly (RetentionCascadeLeg & {
@@ -51,7 +51,6 @@ export const RETENTION_CASCADE = deepFreeze({
51
51
  ],
52
52
  },
53
53
  usageWindowStore: { exempt: "a usage-governance ledger keyed by principal: token and cost counts, no session content, bounded by the deployment's live window set" },
54
- memoryStore: { exempt: "memory is not session data: entries outlive the session that wrote them, and the governance records about them are RETENTION_CASCADE_EXEMPT" },
55
54
  });
56
55
  export const RETENTION_SESSION_TREE_STEPS = deepFreeze(Object.entries(RETENTION_CASCADE)
57
56
  .flatMap(([store, row]) => ("legs" in row ? row.legs.filter((leg) => leg.domain === "session-trees").map((leg) => ({ store, ...leg })) : []))
@@ -0,0 +1,19 @@
1
+ import { type RetiredToolNameAccount } from "./retired-tool-name-account.js";
2
+ /**
3
+ * The account of a restricting tool table the HOST owns and the engine never reads (`settings.permissions.neverAuto`): the entries of `table` that
4
+ * name a tool the engine retired with NO successor — read by the same reader and asked the same question as the engine's own tables
5
+ * (`compileAllowList` then `isRetiredLeftOut`: the name is retired with no `currentName`, and `roster` carries no other case of it) — in the same
6
+ * sentence and the same detail shape as the engine's retired-name notice, or `undefined` when there is none. Pure: it
7
+ * carries no code, no audience, no minter and no session — the host mints its own notice (the retired-name notice's code, minter the host) with
8
+ * `sessionId` added to `detail`, and decides what its table does with the entries (the engine's tables leave them out and go on). `roster` = the
9
+ * names the host knows are mounted (a tool mounted under a retired name is its own, not retired; a tool mounted under another case of it keeps the
10
+ * entry refused, as it does in the engine); `source` names the table in the sentence and in each entry's `source`. A renamed name (it has a
11
+ * successor), an unprefixed or unmintable one is NOT here: the host refuses those as the engine does. `deny` and `ask` read a name alike (both restrict).
12
+ * A table that is no object, a `field` outside `deny` / `ask`, a `source` that is not a non-blank string and `entries` that are no list are refused
13
+ * with a `TypeError` coded `config.invalid_argument` — no sentence is made from them; an entry that is no string reads as nothing.
14
+ */
15
+ export declare function retiredToolNameAccount(table: {
16
+ readonly field: "deny" | "ask";
17
+ readonly source: string;
18
+ readonly entries: readonly string[];
19
+ }, roster?: ReadonlySet<string>): RetiredToolNameAccount | undefined;
@@ -0,0 +1,28 @@
1
+ import { compileAllowList, isRetiredLeftOut } from "./allow-entry.js";
2
+ import { accountOfRetired } from "./retired-tool-name-account.js";
3
+ const NO_ROSTER = new Set();
4
+ function shownValue(v) {
5
+ if (typeof v === "string")
6
+ return JSON.stringify(v.length > 40 ? `${v.slice(0, 40)}…` : v);
7
+ return v === null ? "null" : Array.isArray(v) ? "an array" : typeof v;
8
+ }
9
+ function refuseTable(problem) {
10
+ throw Object.assign(new TypeError(`retiredToolNameAccount: ${problem} — no account is made`), { code: "config.invalid_argument" });
11
+ }
12
+ export function retiredToolNameAccount(table, roster = NO_ROSTER) {
13
+ if (typeof table !== "object" || table === null)
14
+ return refuseTable(`the table is an object { field, source, entries }, not ${shownValue(table)}`);
15
+ const { field, source, entries } = table;
16
+ if (field !== "deny" && field !== "ask")
17
+ return refuseTable(`field ${shownValue(field)} is not a restricting list ("deny" or "ask")`);
18
+ if (typeof source !== "string" || source.trim() === "")
19
+ return refuseTable(`source ${shownValue(source)} names no table — it is the table's name in the sentence`);
20
+ if (!Array.isArray(entries))
21
+ return refuseTable(`entries are a list of tool names, not ${shownValue(entries)}`);
22
+ const retired = [];
23
+ for (const e of compileAllowList(entries, "deny", roster).inert) {
24
+ if (isRetiredLeftOut(e, roster) && e.guidance !== undefined)
25
+ retired.push({ field, entry: e.entry, layer: "host_table", guidance: e.guidance, source });
26
+ }
27
+ return retired.length === 0 ? undefined : accountOfRetired("host_table", retired);
28
+ }