provident-storeroom 1.12.0 → 2.0.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.
@@ -1,12 +1,52 @@
1
1
  // `D-2` (`docs/L1/entry-subdivision.md` §1 part `7`) — bytes moved from `bindings/js/index.mjs`; no logic changed.
2
- import { types } from 'node:util';
3
- import { appendOwn, fail } from './refusal.mjs';
4
- import { withAddon, boundaryReject } from './artefact.mjs';
2
+ // **⟶ AND THE `Proxy` PREDICATE IS THE INSTALLED CLASS-DECISION INSTRUMENT FROM 2026-11-17** (`D-156` item 1 and
3
+ // the loader split's row for these five parts, `docs/L3/wasm-realm/design.md` §5: the host import line is *"swapped
4
+ // for a local helper"* — **neutralised**, conditional on that design's §4 instrument). **`isProxyOf` IS
5
+ // `class-instrument.mjs`'s one predicate and this file carries no host specifier for the class decision any more**:
6
+ // every site below takes the answer `util.types.isProxy` gave, because **the NODE entry installs `types.isProxy`
7
+ // ITSELF at load** (`index.mjs`, at the head of the module), and on the other arm the instrument is
8
+ // `structuredClone` while **the ANSWER does not move** (`D-156` item 1: the refusal stays rank-neutral and
9
+ // class-for-class what this arm answers). **NO DECISION, NO ORDER AND NO ANSWER OF THIS FILE MOVES** — only the
10
+ // predicate's name and its home.
11
+ // **⟶ AND THE CARRIER PREDICATE IS THE ONE THIS FILE TAKES, FROM 2026-11-17 — `D-167`.** **BOTH OF THIS FILE'S
12
+ // `Proxy` SITES ARE CARRIER GATES AND NEITHER IS DATA**: the write's fourth position (`commitPositionRefusal` —
13
+ // the site the ruling's classification censuses as `delivery.mjs:53`) and the terminal arm's record (`terminalArm`
14
+ // — its `:1171`) are the COMMIT RECORD: the package's own bookkeeping, which never enters the Rust store. **THOSE
15
+ // TWO LINE NUMBERS ARE THE RULING'S CITED POSITIONS AND NOT THIS FILE'S, BECAUSE THIS PARAGRAPH MOVES THE LINES
16
+ // BELOW THEM.** **THE RULE THE RULING GIVES, APPLIED AT EACH SITE, IS *"CAN THIS
17
+ // RECORD CARRY A FUNCTION? IF IT CAN, IT IS A CARRIER"***, and the answer at the fourth position is measured, not argued: **the
18
+ // repair's own context is the shape the API HANDS THAT POSITION** — `store.write(address, tier, value, context)`,
19
+ // the route `§2.11` clause 6 declares and `tests/e2e/blind-defect-cases.test.mjs:197` drives — and
20
+ // `kernel-registration.mjs`'s `registrationRepairContext` carries `write: registrationRoute(...)`, **a function, as
21
+ // its seventh member**. So a lawful commit record carries a function by construction, `structuredClone` throws on
22
+ // it, and the probe would have refused the repair's own write as *"a Proxy"* on the WASM arm. **AT `:1171` the
23
+ // record carries no function today** — `CommitRecord` is four members and its `attempt` is `AttemptRef { id }`
24
+ // (`index.d.ts`), so the probe answers `false` there and the two predicates agree — **and it is still a carrier by
25
+ // the same rule, because it is the package's own record and not data the store holds**; the switch is therefore
26
+ // behaviourally inert on both arms there, which is the honest reading and is stated rather than dressed up.
27
+ // **ON THE NODE ARM BOTH SWITCHES ARE INERT TOO**: `isProxyOfCarrier` IS `types.isProxy`, so every `Proxy` these
28
+ // two sites refuse is still refused, in the same form with the same message
29
+ // (`tests/e2e/repair-in-commit.test.mjs`'s `Proxy` row and `tests/e2e/file-tier-save-properties.test.mjs`'s).
30
+ import { isProxyOfCarrier } from './class-instrument.mjs';
31
+ import { appendOwn, fail, refusalAddress, refusalLog } from './refusal.mjs';
32
+ import { withAddon, boundaryReject } from './addon-slot.mjs';
5
33
  import { arrayClass, classSpelling, hasLoneSurrogate, isPlainObjectValue, targetSpelling } from './class-decision.mjs';
6
34
  import { encodeAddress, encodeOpId, handleWire, inDomainHandle } from './carrier.mjs';
7
35
  import { decodeSegments, spellConstraintAddress } from './frame.mjs';
8
- import { addressSpelling } from './kernel-foundations.mjs';
9
- import { entryOf, carryRefusal, commitFile, homeAddressKey, externalCall, commitLogOf, SETTLED_ON_THE_PASSING_ARM, SAVE_FAILED_AT_THE_TERMINAL_ARM } from './state.mjs';
36
+ import { addressSpelling, append } from './kernel-foundations.mjs';
37
+ // **⟶ AND TWO NAMES JOIN THE `state.mjs` IMPORT, 2026-11-17 — `U-STOREROOM-06 DELIVERY-SETTLE`.**
38
+ // **`BODY_FAILURES` IS THE `Symbol.for` KEY THE RECEIPT'S DATUM IS INSTALLED UNDER** — it stands in `state.mjs`'s
39
+ // symbol block beside `COMMIT_LOG` and `SETTLED_ON_THE_PASSING_ARM` (`design.md §5`: *"`settledAnswer` installs
40
+ // `record[BODY_FAILURES] = failures`, a symbol-keyed own property (beside `COMMIT_LOG`/`SETTLED_ON_THE_PASSING_ARM`
41
+ // in `state.mjs`'s symbol block) — invisible to both censuses"*) — **and `BODY_FAILURES_EMPTY` is the ONE FROZEN `{}`
42
+ // the empty map answers**, the very value the receipt's accessor answers where the key is absent
43
+ // (`constraints.mjs`'s `defineBodyFailures`), so **no reader can tell *"no settle ran"* from *"the settle found no
44
+ // rejection"*** (`contract.md §2`: *"`BODY_FAILURES` and `BODY_FAILURES_EMPTY` (one symbol and one frozen
45
+ // empty)"*). **NO OTHER NAME OF THIS LINE MOVES.**
46
+ // **⟶ AND TWO MORE NAMES DO, 2026-11-17 — `U-STOREROOM-08 RETURN-VALUES`** (`D-150` item 1): `RETURNED_VALUES` is
47
+ // the key the receipt's fourth datum is installed under, and `RETURNED_VALUES_EMPTY` the one frozen `{}` a settle that
48
+ // found no value answers — the very value the accessor answers where the key is absent.
49
+ import { entryOf, carryRefusal, commitFile, homeAddressKey, externalCall, commitLogOf, BODY_FAILURES, BODY_FAILURES_EMPTY, RETURNED_VALUES, RETURNED_VALUES_EMPTY, SETTLED_ON_THE_PASSING_ARM, SAVE_FAILED_AT_THE_TERMINAL_ARM } from './state.mjs';
10
50
 
11
51
  /// `PAR-JS-13`: the returned record is `{op, watched, triggered}` — fresh on every call, never a view.
12
52
  ///
@@ -29,7 +69,11 @@ export function commitPositionRefusal(commit) {
29
69
  // **A `Proxy` IS OUTSIDE THE POSITION'S DOMAIN** (`§2.20`'s outside-value row) and is refused BEFORE a
30
70
  // member is read from it, so a `get` trap is never raised — the class order `encodeAddress` and
31
71
  // `encodeTier` already take at their own carriers (`A76`/`JS-2`).
32
- if (!types.isProxy(commit) && !Array.isArray(commit)) {
72
+ // **⟶ AND THE PREDICATE IS THE CARRIER'S FROM 2026-11-17 (`D-167`)**: this record is the package's own, it
73
+ // never crosses, and it carries a function whenever it is a repair's context (`write`). **The arm, the order,
74
+ // the refusal and the sentence do not move** — on the Node arm the answer is identical; on the WASM arm the
75
+ // probe would have refused every repair's own write as *"a Proxy"* and this is the line that stops it.
76
+ if (!isProxyOfCarrier(commit) && !Array.isArray(commit)) {
33
77
  let pending;
34
78
  try {
35
79
  pending = commit.pending;
@@ -102,7 +146,47 @@ export function commitPositionRefusal(commit) {
102
146
  /// triggering ADDRESS as its argument; no other argument is declared and no return value is read"*) — the
103
147
  /// address the addon's own record carries beside the id set. **The two are different data and the cells
104
148
  /// assert exactly one argument** (`S-FIRE-WINDOW`'s `argCount === 1`).
105
- export function deliver(state, triggered, triggeringAddress) {
149
+ ///
150
+ /// **⟶ ADDED 2026-11-17 — THE FOURTH POSITION `settlement`, AND THE ANSWER THAT REPLACES THIS LOOP'S `void`**
151
+ /// (`U-STOREROOM-06 DELIVERY-SETTLE`; `contract.md §3`'s `deliver` row and `§4`'s `PIN-1`, `PIN-2`, `PIN-3`,
152
+ /// `PIN-4`, `PIN-6`, `PIN-9`; `design.md §2` row `1` and `§3`). **THE SCOPE SENTENCE, VERBATIM (`contract.md §1`):
153
+ /// *"every body of a write's or a delete's delivered set is *started* in the one synchronous invocation loop, and
154
+ /// the act's answer is *withheld* until that set has settled"*** — **so the loop below does not move**: its
155
+ /// snapshot, its dedupe on `entry.handle`, its kind test and its one-argument invocation are the bytes they were
156
+ /// (`PIN-1`'s *"in the one shipped loop"*). **WHAT IT GAINS IS THREE FACTS AND NOTHING ELSE:**
157
+ /// * **THE `invoked` LIST** — one `{handle, address, returned}` per **STARTED** recipient: `returned` is what
158
+ /// `externalCall` handed back, `address` is the binding's own address off the trigger pair (`:157`'s
159
+ /// `item.address`). **IT IS A LOCAL OF THIS FUNCTION AND NOT A COUNTER** — a count would have to be
160
+ /// module-level or a slot of `state`, *"a sixth slot `§4` must defend"* (`design.md §3`).
161
+ /// * **THE TWO `null` ARMS**, which are what keep this landing invisible where nothing suspends: `null` where
162
+ /// **`settlement` is falsy** — *this caller has no answer to withhold*, the creation's, the four registration
163
+ /// instants' and the reversal's legs' arm (`PIN-2`: *"and **only** where an answer exists"*; `PIN-11`;
164
+ /// `D-149` item 1) — and `null` where **no started invocation returned a thenable** (`PIN-6`, VERBATIM: *"A
165
+ /// delivered set whose bodies are all synchronous produces **no thenable**: `deliver` answers `null`,
166
+ /// `settledAnswer` is never invoked, `write` answers the record it answered before"*). **BOTH ARE TAKEN
167
+ /// BEFORE `bodyFailures` IS REACHED**, so no all-synchronous delivery produces a promise anywhere.
168
+ /// * **THE ANSWER `null | Promise<readonly BodyFailure[]>`** — `bodyFailures(invoked)` below, which awaits the one
169
+ /// `Promise.allSettled` over the started invocations' returned values and answers the rejections as a datum.
170
+ /// **IT CANNOT REJECT ON ANY ARM**: `Promise.allSettled` has no rejecting arm, and **no `async` frame stands
171
+ /// between a store act and the caller** (`PIN-5`: *"No `Promise` rejection is a failure form on any arm"*).
172
+ ///
173
+ /// **AND THE SEAM THIS LOOP MAY NOT CROSS — `D-73`, WHICH IS THE UNIT'S SPINE.** **NO `async` AND NO `await` STANDS
174
+ /// ANYWHERE BETWEEN THE FIRST INVOCATION AND THE LAST** (`PIN-4`'s second half), **and no `try` closes around an
175
+ /// invocation**: a body that throws SYNCHRONOUSLY leaves this function as a throw, crosses `terminalArm` (whose
176
+ /// assignment carries no `try`), `settleArm` and `runAttempt`, and is re-thrown unchanged — **the write answers no
177
+ /// record and no thenable, and a sibling already started is neither awaited nor observed** (`design.md §7` arm 1;
178
+ /// `D-138` item 4's declared asymmetry, kept). **`settledAnswer` IS ENTERED ONLY AFTER THIS LOOP RETURNED
179
+ /// NORMALLY**, which is the whole of what keeps a synchronous throw off the rejection channel.
180
+ ///
181
+ /// **AND THE SENTENCE ABOVE — *"no return value is read"* — IS RE-DERIVED, NOT WITHDRAWN** (`RCA-8(g)`'s
182
+ /// annotate-beside): it says the invocation reads no return value **as an argument, a member or a subject of the
183
+ /// store's act**, and from this date the answer a body hands back is **captured into a local and settled** — never
184
+ /// passed anywhere, never rendered, and never a member of any record but the datum's own entries.
185
+ ///
186
+ /// **NO ORDER IS ASSERTED BY THE ANSWER EITHER** (`PIN-3`; `DD-22`: *"a drive compares sets, never sequences"*):
187
+ /// `allSettled` reports a **set** of outcomes, the started count is `invoked.length`, and the datum's own key order
188
+ /// is the arrival order and is promised by no clause.
189
+ export function deliver(state, triggered, triggeringAddress, settlement) {
106
190
  const address = typeof triggeringAddress === 'object' && triggeringAddress !== null ? triggeringAddress : [];
107
191
  // **⟶ THE RECIPIENT SET IS SNAPSHOTTED WHEN THE WINDOW OPENS, BEFORE THE FIRST INVOCATION — `C-2` OF THE
108
192
  // GATE-4 ADVERSARIAL PASS (2026-10-11; `CF-DUP-3`'s re-homing clause, `surface.md §2.4` item 7 (b),
@@ -153,6 +237,16 @@ export function deliver(state, triggered, triggeringAddress) {
153
237
  // occurrence, in an order no clause asserts (`DD-22`).
154
238
  const matched = [];
155
239
  const recipients = [];
240
+ // **⟶ AND THE STARTED SET'S OWN LIST, ADDED 2026-11-17 — ONE ENTRY PER **STARTED** RECIPIENT AND NEVER ONE PER
241
+ // DELIVERED ELEMENT** (`contract.md §3`'s `deliver` row: *"the local `invoked` list, one `{handle, address,
242
+ // returned}` per **started** recipient"*; `design.md §3` step `(2)`). **IT IS FILLED BY THE INVOCATION LOOP BELOW
243
+ // AND BY NOTHING ELSE**, so its length is the started count `PIN-9` compares against the deduplicated triggered
244
+ // set's count, and its members are the only datum the settle — and `U-08`'s `returnedValues` after it — ever reads
245
+ // (`contract.md §8`: *"both consumers … read **the same list at the same instant**"*). **NO SECOND LIST, NO
246
+ // COUNTER, NO QUEUE, NO MAP AND NO `state` SLOT**: the snapshot above already holds one recipient per distinct
247
+ // handle, so the started set is that snapshot's FUNCTIONAL members and this list is the record of which of them
248
+ // the loop reached.
249
+ const invoked = [];
156
250
  for (let i = 0; i < triggered.length; i += 1) {
157
251
  const item = triggered[i];
158
252
  let seen = false;
@@ -176,9 +270,19 @@ export function deliver(state, triggered, triggeringAddress) {
176
270
  // storeroom-js/surface.md §2.4` rule 1) — no longer excludes it by ABSENCE. **THE KIND DOES**: *"an element
177
271
  // whose handle is a constraint's `id` is asked; a listener's is delivered."* **A PAIR'S BODY IS ASKED BY THE
178
272
  // PASS, WITH THE `AttemptContext` ITS SHAPE DECLARES; IT IS NEVER INVOKED HERE, WITH THE TRIGGERING ADDRESS.**
273
+ //
274
+ // **⟶ AND THE ROW'S THIRD POSITION IS THE BINDING'S OWN ADDRESS, ADDED 2026-11-17** (`contract.md §3`'s
275
+ // `deliver` row: *"one `{handle, address, returned}` per **started** recipient"*; `design.md §5`: *"`address` is
276
+ // the binding's own address off the pair at `deliver:157`"*). **IT IS READ FROM THE TRIGGER PAIR THIS ITERATION
277
+ // ALREADY HOLDS** — the store's own decoded segments — **and it is NOT the one argument the invocation is
278
+ // handed**: that argument remains the TRIGGERING address (`PAR-JS-12`), because **the two are different data**
279
+ // (`:140`–`:141`, `AB-3`: *"A body cannot tell which binding matched, and that is declared."*). **THE
280
+ // SNAPSHOT'S MEMBERSHIP, ITS ORDER, ITS KIND TEST AND ITS FUNCTION SLOT DO NOT MOVE**: the third position is a
281
+ // datum carried on the row for the settle's message, never a second test and never a second invocation.
179
282
  appendOwn(recipients, [
180
283
  item.handle,
181
284
  entry === undefined || entry.off === true || entry.kind === 'constraint' ? undefined : entry.fn,
285
+ item.address,
182
286
  ]);
183
287
  }
184
288
  for (let r = 0; r < recipients.length; r += 1) {
@@ -203,9 +307,204 @@ export function deliver(state, triggered, triggeringAddress) {
203
307
  // (`tests/e2e/external-commit.test.mjs` prints both figures). **NOTHING IS INFERRED FROM THE FRAME ANY
204
308
  // MORE**: the name is set here, restored when the body returns or throws, and every internal step of the
205
309
  // listener's own write names the commit that write opened.
206
- externalCall(state.receiver, () => listener(decodeSegments(address)));
310
+ //
311
+ // **⟶ AND THE INVOCATION'S ANSWER IS CAPTURED, 2026-11-17 — THE ONE BYTE THIS LOOP GAINS** (`contract.md §3`'s
312
+ // `deliver` row; `design.md §3` step `(2)`: *"for each recipient with a function, `const returned =
313
+ // externalCall(state.receiver, () => listener(decodeSegments(address)))` and append"*). **THE CALL IS THE
314
+ // SHIPPED CALL AND ITS ONE ARGUMENT IS THE SHIPPED ARGUMENT**: what moves is that the answer it hands back is
315
+ // **STOOD BESIDE THE RECIPIENT instead of being dropped**. **A THROW HERE LEAVES THIS FUNCTION IMMEDIATELY
316
+ // AND NO BYTE BELOW RUNS** — no `try`, no `catch`, no retry and no rollback (`D-73`; `design.md §7` arm 1) —
317
+ // and a body that suspends is **STARTED, NOT WAITED FOR**: the loop reaches the next recipient in the same
318
+ // synchronous frame (`PIN-1`; `contract.md §6` row 7: *"a suspension delays no sibling and the answer only"*).
319
+ const returned = externalCall(state.receiver, () => listener(decodeSegments(address)));
320
+ appendOwn(invoked, { handle: pair[0], address: pair[2], returned });
321
+ }
322
+ }
323
+ // ── THE SETTLE'S TWO `null` ARMS, AND THEN THE ANSWER ────────────────────────────────────────────────────────
324
+ // **⟶ THE FIRST ARM IS THE MISSING CALLER — `PIN-2`'s *"and **only** where an answer exists"*.** The creation
325
+ // (`index.mjs:334`), the four registration instants (`:575`) and the reversal's legs (`constraints.mjs:3037`) pass
326
+ // NO fourth position, so this function answers `null` and **observes nothing there** — which is `PIN-11`'s
327
+ // deliberate asymmetry (`D-138` item 4): **a rejecting body at those instants stays `D-130` item 5's caller hazard
328
+ // and is never converted into a declared silence.** **NOTHING IS READ AT ALL ON THIS ARM** — no `then` is touched,
329
+ // no `Promise` is built — so the no-receipt instants are answered by the loop's own throw or by nothing.
330
+ if (!settlement) return null;
331
+ // **⟶ THE SECOND ARM IS THE ALL-SYNCHRONOUS SET — `PIN-6`, VERBATIM: *"a delivered set whose bodies are all
332
+ // synchronous produces **no thenable**"*.** **THE READ IS ONE `typeof` ON THE LANGUAGE'S OWN ASSIMILATION SLOT**:
333
+ // the answer a body handed back is asked whether it carries a callable `then`, which is the same question
334
+ // `Promise.allSettled` asks a moment later — **and NOTHING OF THE BODY IS INVOKED TO ASK IT.** **THE LOOP IS A
335
+ // LOCAL INDEX LOOP** (`contract.md §2.1` item `(1c)(i)`'s form): no `Array.prototype.some`, no iterator and no
336
+ // spread, so a forged prototype reaches no byte of this path; a non-object answer — `undefined`, `null`, a string,
337
+ // a number — cannot be a thenable and is skipped by the class test before any member is read.
338
+ let thenable = false;
339
+ for (let s = 0; s < invoked.length; s += 1) {
340
+ const answered = invoked[s].returned;
341
+ if (
342
+ answered !== null
343
+ && (typeof answered === 'object' || typeof answered === 'function')
344
+ && typeof answered.then === 'function'
345
+ ) {
346
+ thenable = true;
347
+ break;
207
348
  }
208
349
  }
350
+ if (!thenable) return null;
351
+ return bodyFailures(invoked);
352
+ }
353
+
354
+ /// **⟶ ADDED 2026-11-17 — `settledAnswer(settle, answer)`: THE UNIT'S ONLY SUSPENSION POINT**
355
+ /// (`U-STOREROOM-06 DELIVERY-SETTLE`; `contract.md §3`'s own row for it; `design.md §2` row `8`, `§3`, `§6`).
356
+ ///
357
+ /// **WHAT IT DOES IS THREE THINGS IN ONE ORDER AND NOTHING ELSE: it waits for the settle, it stands the datum on the
358
+ /// answer, and it answers.** *"one `Promise.allSettled` over `invoked`'s returned values, then the datum, then the
359
+ /// answer"* (`contract.md §3`) — the settle having been started by `bodyFailures` below **after `deliver`'s loop
360
+ /// returned normally**, so **no `async` frame ever stands between a store act and the caller** (`PIN-4`).
361
+ ///
362
+ /// **ITS "MUST NOT ACQUIRE" COLUMN IS THE DECLARATION, AND IT IS NEGATIVE** (`contract.md §3`): **no invocation** —
363
+ /// nothing of the delivered set is called here · **no store call** · **no `deliver`** · **no `.then`** (the `await`
364
+ /// resolves through the promise's own internal slots and reads no `Promise.prototype` member — a corpus reason, not a
365
+ /// measurement, `design.md §3`) · **no `new Promise`** · **no timeout** (a timer is a scheduler, `contract.md:602`) ·
366
+ /// and **no read of any package slot** — `state` is not among this function's positions.
367
+ ///
368
+ /// **IT CANNOT REJECT ON ANY ARM**, which is `PIN-5`'s *"No `Promise` rejection is a failure form on any arm"*: the
369
+ /// settle it awaits is `Promise.allSettled`'s, whose answer is a list on every input, and the only work after the
370
+ /// `await` is one `defineProperty` on the record this frame already holds and one `return`. **A BODY'S REJECTION IS
371
+ /// THEREFORE A DATUM AND NEVER A REJECTION OF THE WRITE** (`D-138` items 2 and 4: *"the write **resolves** with that
372
+ /// same record"*), and nothing retries and nothing rolls back.
373
+ ///
374
+ /// **AND THE WAIT IS THE ANSWER'S WHOLE WAIT** (`PIN-9`): the frame it resumes in holds no store call, no invocation
375
+ /// and no commit — `closeCommit` has already run in the caller's own `finally`, `state.leg` and `state.legDelivery`
376
+ /// are restored, and the record is built (`design.md §6`: *"the only thing unsettled when the caller receives the
377
+ /// record is the caller's own knowledge of the bodies' outcomes — **which is the datum**"*).
378
+ export async function settledAnswer(settle, answer) {
379
+ // **⟶ AND THE ONE `await` ANSWERS THE SETTLE'S TWO DATA, 2026-11-17** (`U-STOREROOM-08 RETURN-VALUES`;
380
+ // `contract.md §8`: *"both consumers … read the same list at the same instant"*). **No second wait and no second
381
+ // settle**: `bodyFailures` below performed the one `Promise.allSettled`, and this frame resumes on the very microtask
382
+ // the failure datum always resumed on, so the map is over outcomes already total and final.
383
+ const settledOutcome = await settle;
384
+ const failures = settledOutcome.failures;
385
+ const values = returnedValues(settledOutcome.settled, settledOutcome.invoked);
386
+ // **THE DATUM IS A SYMBOL-KEYED OWN DATA PROPERTY AND NEVER A MEMBER** (`A117` (D6)): invisible to `Object.keys` and
387
+ // to `Object.getOwnPropertyNames`, so the record's declared census moves by nothing. **IT IS DEFINED AND NOT
388
+ // ASSIGNED** — `[[Set]]` walks the chain, and a caller's accessor at the well-known symbol would answer for the
389
+ // accessor that reads it; `[[DefineOwnProperty]]` is this record's own row and nothing else (`F8-2`'s write vector).
390
+ Object.defineProperty(answer, BODY_FAILURES, {
391
+ value: failures,
392
+ enumerable: false,
393
+ writable: false,
394
+ configurable: true,
395
+ });
396
+ // **⟶ AND THE VALUE MAP IS INSTALLED IN THE SAME FRAME, BY THE SAME DEVICE, 2026-11-17** (`D-149` item 2's seat;
397
+ // `D-150` item 1). **Defined and not assigned**, for the failure datum's own reason: `[[Set]]` walks the chain, while
398
+ // `[[DefineOwnProperty]]` is this record's own row and nothing else (`F8-2`'s write vector). **The value is the map
399
+ // `returnedValues` built from the same `settled` array, or the shared frozen `{}` where no body returned one.**
400
+ Object.defineProperty(answer, RETURNED_VALUES, {
401
+ value: values,
402
+ enumerable: false,
403
+ writable: false,
404
+ configurable: true,
405
+ });
406
+ return answer;
407
+ }
408
+
409
+ /// **⟶ ADDED 2026-11-17 — `bodyFailures(invoked)`: THE SETTLE ITSELF, AND THE PLURALITY AS DATA**
410
+ /// (`contract.md §3`'s own row; `design.md §3` steps `(5)`, `§5`'s *"the plurality — confirmed, with one correction to
411
+ /// `D-138`'s claim"*).
412
+ ///
413
+ /// **ONE `Promise.allSettled` OVER THE STARTED INVOCATIONS' RETURNED VALUES, AND NOTHING ELSE IS WAITED FOR** —
414
+ /// **no timer, no queue, no flush boundary and no scheduler is minted anywhere** (`D-131` item 4: a timer is a
415
+ /// scheduler) — **and the outcome count equals the started count because the list it walks is `deliver`'s own**
416
+ /// (`PIN-9`: *"the answer resolves after the last settlement and after no other event"*).
417
+ ///
418
+ /// **ITS ANSWER IS A MAP KEYED BY HANDLE — ONE ENTRY PER REJECTING BODY, `{status, message, address}`** (`design.md
419
+ /// §5`: *"Each entry is `{status, message, address}`"*; `D-138`'s plurality: *"`N` rejections become `N` entries and
420
+ /// no rule is owed for *which one crosses*, because none is dropped"*). **`status` IS RANK `23`'S OWN NAME, USED AND
421
+ /// NEVER MINTED, RENAMED OR WIDENED** (`D-137` item 5; `D-149` item 1: *"rank `23` `ListenerBodyRejected` is USED
422
+ /// here and neither minted, renamed nor widened, and no rank `24` exists"*) · **`message` is the generator's own
423
+ /// sentence** — `"<address> was refused by a listener body that rejected, a fired listener body's rejection refuses
424
+ /// the act that fired it"` — rendered over **the watched address's spelling** (`D-137` item 5: *"ITS SUBJECT is the
425
+ /// WATCHED ADDRESS'S SPELLING — the address whose triggering fired the body"*) · **`address` is the binding's own
426
+ /// address, off the pair `deliver` read at `:157`**.
427
+ ///
428
+ /// **THE REJECTION'S OWN REASON IS NEVER READ, STORED OR RENDERED** (`PIN-5`; `D-137` item 5: *"the sentence declares
429
+ /// what crossed and not what the body rejected with"*; `D-58`'s retained-data bound): the settled result's `reason`
430
+ /// member is not touched on any arm and nothing of it reaches the entry — so no throwable crosses as itself, and this
431
+ /// is **not** a catch-and-report (`DD-23`'s *"not caught, not retried, not reported"*: the package catches nothing and
432
+ /// reports through its own answer's datum).
433
+ ///
434
+ /// **NO ORDER IS ASSERTED AMONG THE ENTRIES** (`PIN-3`; `DD-22`). A JS object's own string keys are read in insertion
435
+ /// order, so the ARRIVAL order is legible at `Object.keys(failures)` — **and no clause promises it and no drive may
436
+ /// assert it** (`design.md §5`'s one correction to `D-138`). **THE KEYS ARE THE HANDLES**: a body that settled
437
+ /// fulfilled is not in the map, an absent handle is not in it, and the per-handle value map `U-08` owes is a
438
+ /// different datum read off this same list at this same instant (`contract.md §8`).
439
+ ///
440
+ /// **AN EMPTY MAP IS THE ONE FROZEN CONSTANT** (`state.mjs`'s `BODY_FAILURES_EMPTY`): `{}` here means *"this settle
441
+ /// found no rejection"*, it carries no client data, and it is **the same value the receipt's accessor answers where
442
+ /// no settle ran at all** — `D-58`'s bound is a retained LIST and there is none here (`design.md §5`, on
443
+ /// `defineResolutionLog`'s precedent for `[]`).
444
+ async function bodyFailures(invoked) {
445
+ // **THE RETURNED VALUES ARE COLLECTED BY A LOCAL INDEX LOOP AND APPLIED BY NOTHING ELSE** (`contract.md §2.1` item
446
+ // `(1c)(i)`'s form): no `.map`, no spread and no iterator reaches a mutable prototype, and the list is fresh.
447
+ const answered = [];
448
+ for (let i = 0; i < invoked.length; i += 1) appendOwn(answered, invoked[i].returned);
449
+ const settled = await Promise.allSettled(answered);
450
+ let failures = BODY_FAILURES_EMPTY;
451
+ for (let i = 0; i < settled.length; i += 1) {
452
+ if (settled[i].status !== 'rejected') continue;
453
+ const entry = invoked[i];
454
+ // **THE MAP IS MINTED AT THE FIRST REJECTION AND NEVER BEFORE**, so a settle that found none answers the frozen
455
+ // constant and no mutable empty ever reaches a caller's record.
456
+ if (failures === BODY_FAILURES_EMPTY) failures = {};
457
+ const spelled = Array.isArray(entry.address) ? addressSpelling(entry.address) : '';
458
+ // **THE ROW IS AN OWN-PROPERTY DEFINE AND NOT AN ASSIGNMENT** (`F8-2`'s write vector, read for a map): an
459
+ // inherited accessor at the handle's own key would otherwise turn a lawful delivery's datum into a raw host
460
+ // `TypeError`, and a handle a caller spelled as `__proto__` would move a prototype instead of adding a row.
461
+ Object.defineProperty(failures, entry.handle, {
462
+ value: {
463
+ status: 'ListenerBodyRejected',
464
+ message: `${spelled} was refused by a listener body that rejected, a fired listener body's rejection refuses the act that fired it`,
465
+ address: entry.address,
466
+ },
467
+ enumerable: true,
468
+ writable: true,
469
+ configurable: true,
470
+ });
471
+ }
472
+ // **⟶ AND THE ANSWER IS THE SETTLE'S TWO DATA, 2026-11-17 — THE FAILURE MAP UNMOVED, HANDED OUT WITH THE `settled`
473
+ // LIST IT WAS COMPUTED FROM AND THE `invoked` LIST IT WAS COMPUTED OVER** (`contract.md §8`). **This is the one byte
474
+ // of this function that moves, and it adds no wait and no settle**: the outcome count is still `invoked.length`
475
+ // (`PIN-9`), the one `Promise.allSettled` above is still the only one, and `settledAnswer` is this answer's one reader.
476
+ return { failures, settled, invoked };
477
+ }
478
+
479
+ /// **⟶ ADDED 2026-11-17 — `returnedValues(settled, invoked)`: THE DELIVERED SET'S SETTLED RETURN VALUES AS ONE MAP,
480
+ /// KEYED BY HANDLE** (`U-STOREROOM-08 RETURN-VALUES`; `D-149` item 2; `D-150` items 1–2; `contract.md §8`).
481
+ ///
482
+ /// **`D-149` ITEM 2: *"the answer gains a datum keyed by handle, one entry per listener that RETURNED A VALUE"*** —
483
+ /// **and `D-148` item 1(c) fixes what an entry IS**: *"a body that returns `undefined` … does not pass back"*, so
484
+ /// **an `undefined`-returner contributes NO entry and its silence is the caller's to read**.
485
+ ///
486
+ /// **IT READS THE FULFILLED HALF OF THE ONE SETTLED LIST AND NOTHING ELSE** — the same `settled` array `bodyFailures`
487
+ /// awaited and the same `invoked` list it walked; it awaits nothing, invokes nothing and builds no promise. **A result is
488
+ /// read for its value only where it FULFILLED**, so a rejected body never crosses as a value and its `reason` is never
489
+ /// read, stored or rendered (`D-137` item 5; `D-58`; `PIN-5`). **No order is asserted** (`PIN-3`; `DD-22`). **A row is an
490
+ /// own-property DEFINE and never an assignment** (`F8-2`'s write vector). **An empty map is `RETURNED_VALUES_EMPTY`**, the
491
+ /// one frozen constant, so no reader can tell *"no settle ran"* from *"the settle found no value"* (`D-150` item 2).
492
+ function returnedValues(settled, invoked) {
493
+ let values = RETURNED_VALUES_EMPTY;
494
+ for (let i = 0; i < settled.length; i += 1) {
495
+ if (settled[i].status !== 'fulfilled') continue;
496
+ const entry = invoked[i];
497
+ const value = settled[i].value;
498
+ if (value === undefined) continue;
499
+ if (values === RETURNED_VALUES_EMPTY) values = {};
500
+ Object.defineProperty(values, entry.handle, {
501
+ value,
502
+ enumerable: true,
503
+ writable: true,
504
+ configurable: true,
505
+ });
506
+ }
507
+ return values;
209
508
  }
210
509
 
211
510
  // ⟶ MOVED 2026-10-18 (`RCA-8(g)`): deleteOp is deleted; its doc block and body are now the
@@ -479,7 +778,23 @@ export function installRegistrationSave(instance, state) {
479
778
  Object.defineProperty(instance, REGISTRATION_SAVE, {
480
779
  value: (opId) => {
481
780
  if (typeof opId !== 'string' || opId.length === 0) return undefined;
482
- commitFile(state.receiver, opId);
781
+ // **⟶ AND THE INSTANT'S SAVE TAKES THE TERMINAL ARM'S OWN BRANCH FROM 2026-11-17 — `D-133` ITEM 3, AND THE DEFECT
782
+ // THE DEMO FOUND.** **`D-133` item 3, verbatim: *"the store's own writer is NOT USED"*** — and until this line the
783
+ // registration instant was the ONE path where it still was, so **a seeded `saveCall` store whose constraint landed a
784
+ // `file`-tier repair could not be constructed at all**: the store's writer answered rank `15` `FileCommitFailed` on a
785
+ // path-less register, unwound the repair, and the caller's saver — which would have succeeded — was never reached
786
+ // (measured; the discriminator is exactly `saveCall` ∧ a `file`-tier write, since the same repair at `mem` tier and
787
+ // the same repair on a `filePath` store both stood).
788
+ //
789
+ // **THE BRANCH IS THE TERMINAL ARM'S AND IT IS TOLD BY ONE VALUE**: `state.saveCall` is `null` exactly where the caller
790
+ // supplied none, so the `file` arm keeps today's bytes byte-for-byte and the `saveCall` arm performs the export, the
791
+ // caller's function and the verdict entry — the same three acts, in the same order, in the same `§2.11` clause 2
792
+ // position, before any body of the instant's delivered set.
793
+ if (state.saveCall === null) {
794
+ commitFile(state.receiver, opId);
795
+ return undefined;
796
+ }
797
+ saveAtRegistration(state, opId);
483
798
  return undefined;
484
799
  },
485
800
  writable: false,
@@ -876,7 +1191,12 @@ export function terminalArm(state, record) {
876
1191
  // **THE CLASS TEST COMES FIRST AND IS THE ONE THE FIFTH POSITION ALREADY TAKES** (`docs/specs/storeroom-js/surface.md §2.4` item 9 (g) item 1
877
1192
  // read with `§2.20`): a value carrying no `pending` is no record position, and this channel is the kernel's
878
1193
  // own — a caller never reaches it. Nothing is changed by a refused value.
879
- if (record === null || typeof record !== 'object' || types.isProxy(record) || record.pending === undefined) {
1194
+ // **⟶ AND THE RECORD IS THE CARRIER PREDICATE'S FROM 2026-11-17 (`D-167`)** — the package's own four-member
1195
+ // `CommitRecord`, which carries the delivered set's handles and never enters the store. **Its members are
1196
+ // cloneable today** (`attempt: AttemptRef { id }`, `op`, `triggered[]`, `pending[]`), so this switch answers
1197
+ // exactly what the shipped byte answered on BOTH arms; it is made because the RECORD's class is the carrier's
1198
+ // and not because a measurement moved.
1199
+ if (record === null || typeof record !== 'object' || isProxyOfCarrier(record) || record.pending === undefined) {
880
1200
  return undefined;
881
1201
  }
882
1202
  // ── `docs/specs/storeroom-js/surface.md §2.11` CLAUSE 2: THE TERMINAL ARM'S FIRST ACT, ON THE PASSING ARM ────
@@ -885,6 +1205,12 @@ export function terminalArm(state, record) {
885
1205
  // **AND THE OP'S OWN TIER WORD IS NOT READ AT THIS GATE FROM 2026-11-02**: the eligibility question is the
886
1206
  // store's (`PIN-4` (i)), and the conjunct that pre-answered it here is below, withdrawn with its reason.
887
1207
  const answer = state.leg;
1208
+ // **⟶ AND THE AWAITED SAVE'S ONE LOCAL, 2026-11-17 — `null` ON EVERY SYNCHRONOUS ARM.** It is written by the save
1209
+ // block below and read by the delivery assignment at the foot of this frame: **a `saveCall` that answered a thenable
1210
+ // hands the slot its own composed settle** (`D-153` item 2), **and every other arm — the `file` arm, and a `saveCall`
1211
+ // whose verdict arrived synchronously — leaves it `null`**, so the delivery below is this arm's own and the slot's
1212
+ // value is byte-for-byte what it was (`PIN-8`: one writer, one reader).
1213
+ let saveSettle = null;
888
1214
  if (
889
1215
  record[SETTLED_ON_THE_PASSING_ARM] === true
890
1216
  && answer !== null
@@ -936,7 +1262,18 @@ export function terminalArm(state, record) {
936
1262
  // act at the commit's own op address, and that address is read off the leg the store's verb left
937
1263
  // (`state.leg.op.address`, decoded by `index.mjs` at the verb's return) — the carrier this call hands
938
1264
  // spells an OP ID and never an address, so the member would be `null` if it were derived here.
939
- carryRefusal(() => commitFile(state.receiver, answer.op.opId), [encodeOpId(answer.op.opId)], commitLogOf(record), answer.op.address);
1265
+ // **⟶ AND THE ACT IS THE CALLER'S WHERE THE CALLER SUPPLIED A SAVER — `U-STOREROOM-04`, 2026-11-17.** **`D-133`
1266
+ // item 3, verbatim: *"the store's own writer is NOT USED"***, so on a `saveCall` store this one call is **the export,
1267
+ // the caller's function and the verdict entry** and `commitFile` is not reached at all. **The `file` arm keeps
1268
+ // today's bytes, unmoved.** **The two arms are told apart by one value and nothing else**: `state.saveCall` is `null`
1269
+ // exactly where the caller supplied none. **`saveThroughCaller` answers `null` where the verdict arrived
1270
+ // synchronously and the composed settle where the answer was a thenable** (`D-144` item 1's *"(async optional)"*) —
1271
+ // and in both the act stands FIRST, before any body of the delivered set (`§2.11` clause 2).
1272
+ if (state.saveCall === null) {
1273
+ carryRefusal(() => commitFile(state.receiver, answer.op.opId), [encodeOpId(answer.op.opId)], commitLogOf(record), answer.op.address);
1274
+ } else {
1275
+ saveSettle = saveThroughCaller(state, record, answer, answer.op);
1276
+ }
940
1277
  } catch (saveFailure) {
941
1278
  // **THE FAILURE CARRIES THE VERY THROWABLE AND ITS OWN MARK** (`docs/specs/storeroom-js/surface.md §2.11` clause 9): the kernel's catch
942
1279
  // reads `SAVE_FAILED_AT_THE_TERMINAL_ARM` to tell a failed save from a body of the delivered set that
@@ -984,11 +1321,320 @@ export function terminalArm(state, record) {
984
1321
  if (state.legDelivery !== 'member') {
985
1322
  // `deliver` is THE SAME loop the post-verb window uses (`docs/specs/storeroom-js/surface.md §2.4` rules 1–3 read once, at both instants): ONE
986
1323
  // invocation per DISTINCT handle, and a handle with no registered function fires nothing silently.
987
- deliver(state, triggered, triggeringAddress);
1324
+ //
1325
+ // **⟶ AND THE DELIVERED SET'S SETTLE LEAVES BY THE STATE SLOT AND NOT BY THIS ARM'S RETURN — ONE ASSIGNMENT,
1326
+ // 2026-11-17** (`contract.md §3`'s `terminalArm` row: *"**one assignment** at `:987`: `state.legSettle =
1327
+ // deliver(state, triggered, triggeringAddress, true)` — taken only where `state.legDelivery !== 'member'`"*;
1328
+ // `PIN-2`'s *"`settlement` is passed at `delivery.mjs:987` and `index.mjs:887` and nowhere else"*; `PIN-8`).
1329
+ // **THE RETURN CANNOT CARRY IT AND THAT IS FORCED, NOT PREFERRED**: `PAR-JS-19`'s answer cell says *"ITS ANSWER
1330
+ // IS `undefined` AND NO KERNEL ACT BRANCHES ON IT"* (`state.mjs:84`–`:85`) and the kernel discards it
1331
+ // (`kernel-attempt.mjs:550`) — **so `return undefined` below stands byte-for-byte, and the settle leaves by the
1332
+ // slot exactly as `state.leg` carries the leg's record.**
1333
+ //
1334
+ // **THE SLOT'S LIFETIME IS ONE SYNCHRONOUS SPAN** (`PIN-8`): **one writer** — this line — **and one
1335
+ // reader-and-clearer** — `constraintWrite`'s tail, synchronously, after the kernel returned and before any
1336
+ // record accessor is read — **so the value is `null` at every microtask boundary**, and **a nested write's own
1337
+ // tail clears its own value BEFORE this enclosing assignment is made** (`deliver` runs the whole start loop
1338
+ // inside its own call, and the assignment stands after it returns).
1339
+ //
1340
+ // **NO `try` GOES AROUND IT** (`D-73`; `contract.md §3`'s *"a `try` around the delivery"* in the must-not column):
1341
+ // a body that throws synchronously leaves `deliver` as a throw, crosses this frame unchanged, and **the write
1342
+ // answers nothing** — no `async`, no `await`, no rollback and no second writer of the slot exist here.
1343
+ // **⟶ AND THE SLOT'S VALUE IS THE SAVE'S WHERE THE SAVER'S ANSWER WAS AWAITED — 2026-11-17** (`D-153` item 2).
1344
+ // **One writer and one reader still** (`PIN-8`): the composed settle was created by the save block above and starts the
1345
+ // delivered set at its own tail, **after the save has settled and never before**, so `§2.11` clause 2's order holds on
1346
+ // the awaited arm too. **The all-synchronous arm is byte-unmoved**: `deliver` is called exactly where it was, with the
1347
+ // same four positions, and `PIN-6`'s *"no thenable anywhere"* stands for every `file`-arm write and every `saveCall`
1348
+ // write whose saver answered in its own frame.
1349
+ state.legSettle = saveSettle === null ? deliver(state, triggered, triggeringAddress, true) : saveSettle;
988
1350
  }
989
1351
  return undefined;
990
1352
  }
991
1353
 
1354
+ // ---------------------------------------------------------------------------------------------
1355
+ // **⟶ ADDED 2026-11-17 — `saveCall`'S ARM OF THE TERMINAL SAVE: THE EXPORT, THE CALLER'S FUNCTION AND THE VERDICT
1356
+ // ENTRY** (`U-STOREROOM-04 SAVE-CALL`; `D-132` item 1; `D-133` item 3; `D-137` items 1–2; `D-144` items 1–7;
1357
+ // `D-145` items 1–2; `D-146`; `D-153` items 1–2).
1358
+ //
1359
+ // **THE SAVE'S PLACE DOES NOT MOVE; ITS ACT CHANGES IDENTITY**: on a store constructed with a `saveCall` the arm performs
1360
+ // `exportImage()`'s act — synchronous, marking nothing, refusing at rank `15` as the writer it replaces does — hands
1361
+ // the text to the caller's function at ONE position, and crosses the verdict to the store through `saveSucceeded(opId)`
1362
+ // or `saveFailed(opId)` and through nothing else (`D-146` item 2: *"no verdict is carried on any entry's position"*).
1363
+ //
1364
+ // **THE THREE ARMS.** **SUCCESS** — `success === true` — marks the record saved and answers `null`, so the arm's
1365
+ // delivery below runs after it (`§2.11` clause 2, by construction). **FAILURE** — any other answer, a non-object, a
1366
+ // THROW, and a thenable that settles into either — is the failed arm: **`saveFailed(opId)` FIRST** (`§2.11` clause 5:
1367
+ // *"the store rolls the write back first and answers second"*; `D-146` item 1), **the caller's `message[]` as one
1368
+ // `'save'`-kind entry per string on the commit's own list** (`D-145` item 2; `D-153` item 1), **and then the surface's ONE
1369
+ // form at rank `15` `FileCommitFailed`** — widened and never minted, **its `message` the store's generator's** and never
1370
+ // the caller's words. **AWAITED** — a thenable — the arm starts no delivery of its own and hands `state.legSettle` a
1371
+ // composed settle that does.
1372
+ //
1373
+ // **THE SAVER'S ANSWER IS READ TOLERANTLY AND NO CODE IS MINTED FOR A MALFORMED ONE** (`design.md §4`'s arm `(b)`, the
1374
+ // always-available default): every answer that is not `{success: true}` is a failed save, and `message` is read **only
1375
+ // where it is an array**, each member crossing only where it is a `string`.
1376
+ // ---------------------------------------------------------------------------------------------
1377
+
1378
+ /// **THE FAILED SAVE'S SEAT, SPELLED HERE BECAUSE NO STORE CALL PRODUCES IT ON THIS ARM** — `D-145` item 1's rank `15`,
1379
+ /// **widened and not joined**: `CODES` stays at its array's length, `StoreStatus` at its literals, and **no code is minted**.
1380
+ const FILE_COMMIT_FAILED = 'FileCommitFailed';
1381
+
1382
+ /// **THE AWAITED SAVE'S OWN SETTLE, MARKED SO `constraintWrite`'S TAIL CAN TELL IT FROM THE DELIVERY'S** — the third arm's
1383
+ /// carrier (`D-153` item 2). **A `Symbol.for` spelling on purpose** (`A117` (D6)): no member is added to any record, and
1384
+ /// both its writer and its reader are this file's.
1385
+ const SAVE_SETTLE = Symbol.for('provident-storeroom.save-settle-at-the-terminal-arm');
1386
+
1387
+ /// **WHETHER THIS SLOT'S VALUE IS THE AWAITED SAVE'S COMPOSED SETTLE** — answered by the settlement's mark and by nothing
1388
+ /// else (`D-153` item 2). The DELIVERY's settle is a different promise and carries no mark, so it takes the arm it has
1389
+ /// always taken.
1390
+ export function isSaveSettle(value) {
1391
+ if (value === null || (typeof value !== 'object' && typeof value !== 'function')) return false;
1392
+ if (typeof value.then !== 'function') return false;
1393
+ return value[SAVE_SETTLE] === true;
1394
+ }
1395
+
1396
+ /// **⟶ AND THE THIRD ARM'S OWN ANSWER — `D-153` ITEM 2's *"the refusal is a datum the settle RESOLVES INTO, never a
1397
+ /// rejection of the promise"*.**
1398
+ ///
1399
+ /// **The settle cannot reject**: `saveAwaited` below catches the thenable's rejection and reads it as the failed arm, so what
1400
+ /// this frame awaits is a value on every input. **A settle carrying a refusal answers that refusal** — the surface's one
1401
+ /// thrown form, already built at the arm that performed the rollback and appended the caller's words — **and a settle
1402
+ /// carrying none is the delivery's, handed to `settledAnswer` unchanged.** **The value is already settled**, so
1403
+ /// `settledAnswer`'s `await` resolves on the spot: no second wait, no second settle, no second `Promise.allSettled`.
1404
+ export async function settledSaveAnswer(settle, answer) {
1405
+ const settledOutcome = await settle;
1406
+ if (
1407
+ settledOutcome !== null
1408
+ && typeof settledOutcome === 'object'
1409
+ && settledOutcome.refusal !== undefined
1410
+ && settledOutcome.refusal !== null
1411
+ ) {
1412
+ throw settledOutcome.refusal;
1413
+ }
1414
+ return settledAnswer(settledOutcome, answer);
1415
+ }
1416
+
1417
+ /// **THE `saveCall` ARM'S WHOLE ACT, IN THE ONE ORDER `§2.11` DECLARES** — the export, the call, the verdict — and its
1418
+ /// two answers: **`null` where the verdict arrived synchronously** (the arm's delivery is then the caller's own) and **the
1419
+ /// composed settle where the saver answered a thenable.**
1420
+ function saveThroughCaller(state, record, answer, op) {
1421
+ const commitList = commitLogOf(record);
1422
+ const addon_ = withAddon();
1423
+ // **THE EXPORT IS THE STORE'S OWN ACT AND IT MARKS NOTHING** (`D-137` item 2): its refusal crosses in the surface's one
1424
+ // form through `carryRefusal`, exactly as the writer's failing write does.
1425
+ const text = carryRefusal(() => addon_.exportImage.call(state.receiver), [], commitList, op.address);
1426
+ let verdict;
1427
+ try {
1428
+ // **ONE POSITION, THE IMAGE TEXT** (`D-144` item 1). **A THROW IS THE FAILED ARM** (`design.md §4`).
1429
+ verdict = Reflect.apply(state.saveCall, undefined, [text]);
1430
+ } catch (thrown) {
1431
+ throw saveFailedEntry(state, op, commitList, null);
1432
+ }
1433
+ if (
1434
+ verdict !== null
1435
+ && (typeof verdict === 'object' || typeof verdict === 'function')
1436
+ && typeof verdict.then === 'function'
1437
+ ) {
1438
+ return saveAwaited(state, record, answer, op, verdict, commitList);
1439
+ }
1440
+ if (isSaveSuccess(verdict)) {
1441
+ saveSucceededEntry(state, op, commitList);
1442
+ return null;
1443
+ }
1444
+ throw saveFailedEntry(state, op, commitList, verdict);
1445
+ }
1446
+
1447
+ /// **THE AWAITED ARM: ONE COMPOSED SETTLE, ITS HEAD THE SAVE AND ITS TAIL THE DELIVERED SET** (`D-153` item 2).
1448
+ ///
1449
+ /// **It resolves on every input and rejects on none.** The verdict entry runs, **the caller's words are appended on the
1450
+ /// commit's list BEFORE anything is answered**, and then either **the delivered set is started** — this file's one
1451
+ /// `deliver`, with the same four positions the synchronous arm hands it, so the save still precedes every body it starts
1452
+ /// (`§2.11` clause 2) — or **a refusal datum is resolved**, which the tail reads and throws.
1453
+ function saveAwaited(state, record, answer, op, pending, commitList) {
1454
+ const ownsDelivery = state.legDelivery !== 'member';
1455
+ const composed = (async () => {
1456
+ let verdict;
1457
+ try {
1458
+ verdict = await pending;
1459
+ } catch (thrown) {
1460
+ // **A REJECTED ANSWER IS THE FAILED ARM**: the reason is the caller's and is neither read, stored nor rendered.
1461
+ verdict = null;
1462
+ }
1463
+ let refusal;
1464
+ try {
1465
+ if (isSaveSuccess(verdict)) {
1466
+ saveSucceededEntry(state, op, commitList);
1467
+ if (!ownsDelivery) return settleOfNothing();
1468
+ const triggered = Array.isArray(record.pending) ? record.pending.slice() : [];
1469
+ const triggeringAddress = answer === null || answer === undefined
1470
+ || answer.op === null || answer.op === undefined
1471
+ ? undefined
1472
+ : answer.op.address;
1473
+ const delivered = deliver(state, triggered, triggeringAddress, true);
1474
+ return delivered === null ? settleOfNothing() : delivered;
1475
+ }
1476
+ refusal = saveFailedEntry(state, op, commitList, verdict);
1477
+ } catch (thrown) {
1478
+ // **A VERDICT ENTRY'S OWN REFUSAL IS THE FAILED ARM AND NEVER THE CALLER'S ANSWER**: carried as the datum, at the seat
1479
+ // it names, and never as a rejection of the settle.
1480
+ refusal = refusalFormOf(thrown, op, commitList);
1481
+ }
1482
+ record[SAVE_FAILED_AT_THE_TERMINAL_ARM] = refusal;
1483
+ return { refusal };
1484
+ })();
1485
+ // **THE MARK IS DEFINED AND NOT ASSIGNED** (`F8-2`'s write vector): a promise is an object, and `[[Set]]` would walk the
1486
+ // chain a caller owns.
1487
+ Object.defineProperty(composed, SAVE_SETTLE, {
1488
+ value: true,
1489
+ enumerable: false,
1490
+ writable: false,
1491
+ configurable: true,
1492
+ });
1493
+ return composed;
1494
+ }
1495
+
1496
+ /// **⟶ ADDED 2026-11-17 — `saveAtRegistration(state, opId)`: THE `saveCall` ARM AT A REGISTRATION INSTANT**
1497
+ /// (`D-133` item 3; `D-144` item 1; `D-146`; the terminal arm's own trio below is its precedent, act for act).
1498
+ ///
1499
+ /// **THE THREE ACTS IN `§2.11` CLAUSE 2'S OWN ORDER, AND THE INSTANT IS THE REASON THEY ARE SPELLED APART FROM
1500
+ /// `saveThroughCaller`**: the export, the caller's function at ONE position, and the verdict entry — **and no delivery is
1501
+ /// started here**, because the instant's delivery is `registrationDelivery`'s own and starting a second one would invoke a
1502
+ /// body twice (`D-104` item 2's once-per-distinct-handle law).
1503
+ ///
1504
+ /// **A FAILED SAVE IS `saveFailed(opId)` FIRST AND THE ONE FORM SECOND** (`D-146` item 1; `§2.11` clause 5): the store
1505
+ /// unwinds, and rank `15` `FileCommitFailed` crosses with the caller's `message[]` carried as the fifth kind's entries where
1506
+ /// a commit list stands to carry them — **and at this instant it is `null`, because the close that names this op has no
1507
+ /// record in hand** (`design.md §4`'s own note on the instant), so the words ride the copy the helper builds.
1508
+ ///
1509
+ /// **★ AND AN AWAITED SAVER IS A DECLARED BOUNDARY HERE, STATED RATHER THAN SILENTLY UNCONFIRMED.** A construction is
1510
+ /// SYNCHRONOUS (`D-147` item 2), so this frame cannot wait for a thenable: **an answer that is a thenable takes the failed
1511
+ /// arm and refuses the act at rank `15`**, because a save this frame cannot confirm must not be claimed. **The `saveCall`
1512
+ /// key's own declaration says so in the same breath as its `(async optional)` domain**: the asynchrony is a WRITE's, and a
1513
+ /// construction's save is synchronous by construction.
1514
+ function saveAtRegistration(state, opId) {
1515
+ const addon_ = withAddon();
1516
+ // **THE EXPORT IS THE STORE'S OWN ACT AND IT MARKS NOTHING** (`D-137` item 2).
1517
+ const text = carryRefusal(() => addon_.exportImage.call(state.receiver), [], null, null);
1518
+ let verdict;
1519
+ try {
1520
+ verdict = Reflect.apply(state.saveCall, undefined, [text]);
1521
+ } catch (thrown) {
1522
+ throw saveRegistrationFailure(state, opId, null);
1523
+ }
1524
+ const awaited = verdict !== null
1525
+ && (typeof verdict === 'object' || typeof verdict === 'function')
1526
+ && typeof verdict.then === 'function';
1527
+ if (!awaited && isSaveSuccess(verdict)) {
1528
+ const wire = encodeOpId(opId);
1529
+ carryRefusal(() => addon_.saveSucceeded.call(state.receiver, wire), [wire], null, null);
1530
+ return undefined;
1531
+ }
1532
+ throw saveRegistrationFailure(state, opId, awaited ? null : verdict);
1533
+ }
1534
+
1535
+ /// **THE REGISTRATION INSTANT'S FAILED ARM**: `saveFailed(opId)` first, then the one form at rank `15` with the caller's
1536
+ /// words as `'save'`-kind entries (`D-146` item 1; `D-145` items 1–2; `D-153` item 1). **The store's own rollback runs
1537
+ /// before the form is built**, and **no journal entry survives it**.
1538
+ function saveRegistrationFailure(state, opId, verdict) {
1539
+ const addon_ = withAddon();
1540
+ const wire = encodeOpId(opId);
1541
+ carryRefusal(() => addon_.saveFailed.call(state.receiver, wire), [wire], null, null);
1542
+ const op = { opId, address: null };
1543
+ const log = appendSaveMessages(null, op, verdict);
1544
+ return saveFailureForm(op, log);
1545
+ }
1546
+
1547
+ /// **`saveSucceeded(opId)` AT THE ONE INSTANT IT IS OWED** (`D-144` item 6; `D-145` item 3): the record the save was owed for
1548
+ /// is marked saved and **no byte moves**. Its one position is the op id, encoded exactly as `commitFile`'s is.
1549
+ function saveSucceededEntry(state, op, commitList) {
1550
+ const addon_ = withAddon();
1551
+ const wire = encodeOpId(op.opId);
1552
+ carryRefusal(() => addon_.saveSucceeded.call(state.receiver, wire), [wire], commitList, op.address);
1553
+ }
1554
+
1555
+ /// **`saveFailed(opId)` AND THE CALLER'S WORDS, THEN THE SURFACE'S ONE FORM** — the failed arm's three acts in the declared
1556
+ /// order: **the rollback FIRST** (`D-146` item 1; `§2.11` clause 5), **then one `'save'` entry per string on the commit's
1557
+ /// own list**, **then the rank-`15` form**. **It answers the form and throws nothing**: the synchronous arm throws it at its
1558
+ /// own site, and the awaited arm resolves it as a datum.
1559
+ function saveFailedEntry(state, op, commitList, verdict) {
1560
+ const addon_ = withAddon();
1561
+ const wire = encodeOpId(op.opId);
1562
+ carryRefusal(() => addon_.saveFailed.call(state.receiver, wire), [wire], commitList, op.address);
1563
+ const log = appendSaveMessages(commitList, op, verdict);
1564
+ return saveFailureForm(op, log);
1565
+ }
1566
+
1567
+ /// **THE ONE FORM, AT RANK `15`, WITH THE STORE'S OWN SENTENCE** (`D-145` item 1): **its `message` is asked of the
1568
+ /// generator, never authored here**, and its `path` slot's disposition on an arm with no path is a spec byte and not this
1569
+ /// pass's (`design.md §7` `O-8`).
1570
+ function saveFailureForm(op, log) {
1571
+ const addon_ = withAddon();
1572
+ const spelled = Array.isArray(op.address) ? addressSpelling(op.address) : '';
1573
+ return {
1574
+ status: FILE_COMMIT_FAILED,
1575
+ message: addon_.errorMessage(FILE_COMMIT_FAILED, spelled),
1576
+ log: refusalLog(log),
1577
+ address: refusalAddress(op.address),
1578
+ };
1579
+ }
1580
+
1581
+ /// **A REFUSAL A VERDICT ENTRY ANSWERED WITH, RE-SHAPED INTO THIS ARM'S ONE FORM** — its `status` and `message` cross
1582
+ /// VERBATIM and `log`/`address` are attached beside them (`surface.md §2.5` item 10 (ii)). **A RAW HOST THROWABLE IS NOT
1583
+ /// THIS FORM'S PROVENANCE** (`D-35`'s read half), so its sentence never becomes a refusal's `message`.
1584
+ function refusalFormOf(thrown, op, commitList) {
1585
+ const isObject = thrown !== null && typeof thrown === 'object';
1586
+ const status = isObject && typeof thrown.status === 'string' ? thrown.status : null;
1587
+ const message = status !== null && typeof thrown.message === 'string'
1588
+ ? thrown.message
1589
+ : saveFailureForm(op, commitList).message;
1590
+ return {
1591
+ status: status === null ? FILE_COMMIT_FAILED : status,
1592
+ message,
1593
+ log: refusalLog(commitList),
1594
+ address: refusalAddress(op.address),
1595
+ };
1596
+ }
1597
+
1598
+ /// **THE CALLER'S `message: string[]` AS LOG ENTRIES OF THE FIFTH KIND, ON THE COMMIT'S OWN LIST** (`D-145` item 2;
1599
+ /// `D-153` item 1: *"one entry per string, in the commit's own list"*).
1600
+ ///
1601
+ /// **The list is the attempt's own log by identity** (`kernel-commit.mjs` defines `COMMIT_LOG` with `value: attempt.log`), so
1602
+ /// the kernel's one appender is handed a carrier whose `log` member IS that array. **Every member is the kernel's own
1603
+ /// reading**: `kind` `'save'`, `opId` the op the save was for, `state` `null`, and `id` the op's address spelling. **A string
1604
+ /// is the only member that crosses** — a non-string is skipped — and no caller text is ever rendered into a sentence this
1605
+ /// package authored.
1606
+ ///
1607
+ /// **⟶ AND THE LIST IS CHOSEN BY ONE FACT THE AWAITED ARM MAKES TRUE, MEASURED 2026-11-17**: the pass SEALS the commit's
1608
+ /// list when it closes (`D-119`'s `sealHandoff`), and on the awaited arm the pass has already closed — so an append to it
1609
+ /// raises a raw host `TypeError` on a refusal path. **The entries are carried anyway and nothing is mutated**: where the
1610
+ /// list is still open (every synchronous arm) they are written into it and the refusal's `log` IS that array by identity;
1611
+ /// where it is sealed, they ride a copy taken at their own instant, in the same append order.
1612
+ function appendSaveMessages(commitList, op, verdict) {
1613
+ const messages = verdict !== null && typeof verdict === 'object' && Array.isArray(verdict.message)
1614
+ ? verdict.message
1615
+ : [];
1616
+ const spelled = Array.isArray(op.address) ? addressSpelling(op.address) : null;
1617
+ const open = Array.isArray(commitList) && Object.isExtensible(commitList);
1618
+ const carried = open ? commitList : (Array.isArray(commitList) ? commitList.slice() : []);
1619
+ for (let i = 0; i < messages.length; i += 1) {
1620
+ const message = messages[i];
1621
+ if (typeof message !== 'string') continue;
1622
+ append({ log: carried }, 'save', { pair: { id: spelled }, op }, message, null);
1623
+ }
1624
+ return carried;
1625
+ }
1626
+
1627
+ /// **`{success: true}` AND NOTHING ELSE** (`D-144` item 1): the boolean is the verdict and the array is the reason.
1628
+ function isSaveSuccess(verdict) {
1629
+ return verdict !== null && typeof verdict === 'object' && verdict.success === true;
1630
+ }
1631
+
1632
+ /// **THE SETTLE OF A DELIVERED SET THAT STARTED NOTHING THAT SUSPENDED** — the same two data `deliver`'s answer carries on
1633
+ /// the all-synchronous arm, built at the frozen empty it is.
1634
+ function settleOfNothing() {
1635
+ return { failures: BODY_FAILURES_EMPTY, settled: [], invoked: [] };
1636
+ }
1637
+
992
1638
  /// **⟶ THE ORDERING SEAM IS REMOVED WHOLE, 2026-10-18 — `settle(record)` IS NOT A MEMBER OF THIS PRODUCT.
993
1639
  /// THIS SITE CARRIES THE POINTER AND NO BYTES OF THE FUNCTION THAT STOOD HERE** (`surface.md §2.4` item 9
994
1640
  /// (the `REMOVED-WHOLE` pointer of that date, whose own words are *"NO DRIVE MAY ASSERT A CALL OF `settle`