provident-storeroom 1.0.1 → 1.2.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.
@@ -109,6 +109,51 @@ export const FORGET_PAIR = Symbol.for('provident-storeroom.forget-pair');
109
109
  // COMMIT OPENS AND DECREMENTED ONCE ON THE FINAL RETURN TO THE CLIENT."* **A VERB THAT FINDS AN EXTANT
110
110
  // COMMIT JOINS IT RATHER THAN OPENING A SECOND**, which is what keeps the count exact under nesting.
111
111
  //
112
+ // **⟶ AMENDED 2026-10-27, SECOND CLAUSE — THE DISCRIMINATOR IS THE COMMIT A CALL NAMES ON ENTRY AND IS NEITHER
113
+ // DEPTH'S NOR AN AUTHORSHIP THE PACKAGE INFERS (`D-46`). THE CLAUSES ABOVE AND THE `D-45` ONE BELOW STAND
114
+ // BYTE-FOR-BYTE AND ARE READ THROUGH THIS ONE.**
115
+ //
116
+ // **THE ARCHITECT, VERBATIM: *"A listener should be operating at the surface and opening a new commit"* · *"A
117
+ // constraint's repair needs to stay as part of the same commit so that it can be tracked as part of the commit
118
+ // process"* · *"The original way of maintaining this was to accept an optional parameter on entry for the commit
119
+ // id, so that a constraint can identify which open commit it is repairing"*** (`strata/decisions.md` · `D-46`).
120
+ //
121
+ // **THE RULE, AS ONE SENTENCE: A CALL THAT NAMES A COMMIT ON ITS OWN ENTRY JOINS THAT COMMIT, AND A CALL THAT
122
+ // NAMES NONE OPENS A NEW ONE.** **The position that carries the name is the `write` METHOD'S FOURTH** — the
123
+ // commit, at the position `index.d.ts` declares (*"the commit, at the FOURTH position of the METHOD"*), which
124
+ // takes a RECORD (an object carrying an own, present `pending`) and never an id token. **AND WHERE A CALL SITS
125
+ // INSIDE AN INVOCATION THE PACKAGE ITSELF MADE OF CALLER CODE, THE NAME MAY COME FROM THE INVOCATION'S OWN
126
+ // ENTRY** — see `EXTERNAL_COMMIT` below: **the kernel names the attempt's commit when it invokes a REPAIR, and
127
+ // names nothing when it invokes a listener or a constraint body.** **A NAME IS NEVER INFERRED FROM A FRAME
128
+ // COUNT, AN AUTHORSHIP MARK, A DEPTH OR A WINDOW, AND TWO NAMES CANNOT CONFLICT: THE ENTRY'S OWN POSITION WINS
129
+ // AND THE INVOCATION'S IS ITS FALLBACK.**
130
+ //
131
+ // **WHY THE REPAIR JOINS AND THE LISTENER DOES NOT, IN THE ARCHITECT'S OWN TERMS.** A repair is **PART OF THE
132
+ // ATTEMPT BEING TRACKED** — *"so that it can be tracked as part of the commit process"* — so its ops belong to
133
+ // the attempt's commit and that commit's record describes the repair it performed; a listener body is
134
+ // **externally-passed code operating at the surface**, so *"it's entering at the package surface"* and opens one
135
+ // of its own (`D-43` item `1`, `D-45`), **and it has no commit in hand to name.** **THAT IS THE ONE CALLER THAT
136
+ // CANNOT SUPPLY AN ID, AND IT IS THE RULE'S OWN ABSENT ARM RATHER THAN AN EXCEPTION TO IT.**
137
+ //
138
+ // **AMENDED 2026-10-27 — THE JOIN RULE IS NARROWED TO AUTHORSHIP AND IS NO LONGER DEPTH'S (`D-45`).**
139
+ // The sentences above stand BYTE-FOR-BYTE and are read THROUGH this clause. **THE ARCHITECT, VERBATIM:
140
+ // *"For 43, how is a listener supposed to be able to reuse the outer verb's commit? The listener is an
141
+ // externally-passed function and should be making calls at the package surface. It should be opening a new
142
+ // commit by default of entering at the surface"*** (`strata/decisions.md` · `D-45`). **THE RULE ABOVE WAS
143
+ // WRITTEN FOR ONE CASE — THE PACKAGE'S OWN MACHINERY INSIDE ITS OWN VERB — AND IT CONFLATED THAT WITH
144
+ // EXTERNAL RE-ENTRY**: *"a listener body, a constraint body"* is **A DIFFERENT ACT BY A DIFFERENT AUTHOR,
145
+ // entering the package surface from outside, and it has no claim on the outer verb's commit at all.**
146
+ // **SO: A CALL ENTERING THE SURFACE FROM AN EXTERNALLY-SUPPLIED FUNCTION OPENS A NEW COMMIT BY DEFAULT, AND
147
+ // ONLY THE PACKAGE'S OWN INTERNAL CONTINUATION JOINS. THE DISCRIMINATOR IS AUTHORSHIP, NOT DEPTH.**
148
+ //
149
+ // **HOW AUTHORSHIP IS MEASURED, AND IT IS THE SECOND THING THE COUNT NEEDS.** `EXTERNAL_DEPTH` below is the
150
+ // number of caller-supplied frames the package is, at this instant, running INSIDE; every window the index
151
+ // opens records the depth it was opened at (`attemptIndex(...).externalAt`, in lockstep with `windows`).
152
+ // **`openCommit` JOINS IFF THE CURRENT DEPTH IS NOT GREATER THAN THE DEPTH OF THE COMMIT IN FLIGHT** — so the
153
+ // package's own continuation of that commit, which runs at the same depth, joins; **a call made from a
154
+ // caller's function, which runs one frame deeper, opens.** **NO COUNT IS MINTED AND NO SECOND INDEX EXISTS**:
155
+ // the mark is a depth and a per-window number, both of them this file's own.
156
+ //
112
157
  // **AND ITS READER IS THE SEAM `§4.2` DECLARES**, reached as two `Symbol.for` channels ON THE STORE
113
158
  // INSTANCE — **NOT module exports of `constraint-kernel.mjs`**, whose export set a standing assertion
114
159
  // closes at the six `K-1`–`K-6` items (`§4.2` item 3; `implementation-plan.md §2` step `4`). **THE ROUTE
@@ -121,7 +166,137 @@ export const FORGET_PAIR = Symbol.for('provident-storeroom.forget-pair');
121
166
  const ATTEMPT_COUNT = Symbol.for('provident-storeroom.attempt-count');
122
167
  const ATTEMPT_OPENED = Symbol.for('provident-storeroom.attempt-opened');
123
168
 
124
- /** The per-store index: `{ open, observers }`, keyed by the store instance and by nothing else. */
169
+ /// **⟶ ADDED 2026-10-27 — `D-44`'s ENFORCEMENT POINT: THE COMMIT SCOPE, AND IT IS THE SEAM'S THIRD CHANNEL.**
170
+ ///
171
+ /// **THE RULING IS THE ARCHITECT'S, VERBATIM: *"There should be no state where a constraint is being checked
172
+ /// without an open commit. Any action that would cause a constraint check should open a commit before
173
+ /// beginning"*** (`strata/decisions.md` · `D-44`) — **and it is an INVARIANT, enforced WHERE THE CHECK RUNS and
174
+ /// not at its callers**: *"a seam a driver can bypass is not an invariant."* `runAttempt` has ONE production
175
+ /// call site (`constraints.mjs`'s `constraintWrite`) **and is also driven DIRECTLY by the batteries**, so a
176
+ /// bracket taken in the entry would be bypassed by every direct drive. **THE SCOPE IS THEREFORE OPENED BY THE
177
+ /// PASS ITSELF**, and the kernel — which declares an EMPTY import footprint (`kernel-surface.md §1` item 1) and
178
+ /// cannot import this module — reaches it through the seam `installAttemptSeam` already installs: the same
179
+ /// `Symbol.for` device, a third channel on the object `storeCreate` returns.
180
+ ///
181
+ /// **WHAT THE CHANNEL DOES, AND THE ONE RULE IT KEEPS**: `store[COMMIT_SCOPE](run)` runs the thunk `run` inside
182
+ /// a commit window — **OPENING one if none is open, JOINING the extant one if one is, and CLOSING ONLY WHAT IT
183
+ /// OPENED** (`openCommit` answers whether THIS call opened; `closeCommit` releases iff it did). **THAT IS
184
+ /// `§4.1`'s OWN RULE** — *"a verb that finds an extant commit JOINS it rather than opening a second, which is
185
+ /// what keeps the count exact under nesting"* — **so the production path's nesting is JOINED and never
186
+ /// doubled**: the caller's verb bracket already holds the count at `1` and the pass's scope inside it moves the
187
+ /// count by nothing. **A THROWABLE OUT OF `run` CROSSES UNCHANGED**, and the window is released on that arm
188
+ /// too, so no count is ever left standing (`§5`'s failure list).
189
+ ///
190
+ /// **NO MEMBER IS ADDED TO ANY RECORD AND NONE TO THE PRODUCT**: the channel is a `Symbol.for` key, invisible to
191
+ /// `Object.keys` and to `Object.getOwnPropertyNames` (`A117` (D6)), so the product's declared own members are
192
+ /// unmoved, no census of a `CommitRecord` moves and no kernel item is minted (`kernel-surface.md §1` item 2).
193
+ const COMMIT_SCOPE = Symbol.for('provident-storeroom.commit-scope');
194
+
195
+ /// **⟶ ADDED 2026-10-27 — `D-42`'s RESTART CONSUMER, AND IT NOW SITS WHERE THE SCOPE IS OWNED.**
196
+ ///
197
+ /// **THE FINDING THIS CLOSES, SAID AS THE LAST PASS MEASURED IT** (`docs/specs/storeroom-js/contract.md §2.6`'s
198
+ /// `D-44` annotate-beside, item `4`): *"a reversal issued INSIDE a directly driven pass is still neither judged
199
+ /// nor restarted … the restart's consumer is the write's check path (`constraintWrite`'s
200
+ /// `restartInvalidatedCheck`) and a directly driven pass has no such frame above it, so the request the body
201
+ /// raises dies with its window."* **`D-44` gave every check an open commit and stopped there**; the request a
202
+ /// check's own body raises was still consumed by ONE call site (`constraintWrite`), which is a property of a
203
+ /// caller and not of the check. **So the consumption moves to the frame that owns the scope — `runAttempt` —
204
+ /// and the store reaches its consumer by a fifth `Symbol.for` channel on this same seam.**
205
+ ///
206
+ /// **THE CHANNEL IS THE SAME DEVICE AS THE SCOPE ABOVE**: installed once by `installAttemptSeam`, invisible to
207
+ /// `Object.keys` and `Object.getOwnPropertyNames` (`A117` (D6)), no member added to any record and none to the
208
+ /// product, and no kernel item minted (`kernel-surface.md §1` item 2: `K-1`–`K-5` and no sixth name). **Its one
209
+ /// argument is the closed `AttemptReport` the pass answered with**, and its answer is the report the kernel
210
+ /// returns: the consumer may leave it untouched (no request stood, or the restarted check passed) or answer it
211
+ /// amended (the restarted check refused). **ITS IMPLEMENTATION IS THE ENTRY'S AND IT IS INJECTED HERE**
212
+ /// (`installRestartConsumer` below): this module may not import `constraints.mjs` — `constraints.mjs` imports
213
+ /// this one, and `kernel-attempt.mjs` imports neither — so the restart machinery stays in its own file and only
214
+ /// the CHANNEL is declared on the seam.
215
+ ///
216
+ /// **AND IT RUNS INSIDE THE PASS'S OWN SCOPE**: `runAttempt` calls it after its pass and before the scope is
217
+ /// released, so the restarted check is a check with a commit open — `D-44`'s invariant reaches the restart
218
+ /// itself, which it could not while the consumer was a frame outside the scope.
219
+ const RESTART_DRAIN = Symbol.for('provident-storeroom.restart-drain');
220
+
221
+ /// **THE RESTART'S ONE IMPLEMENTATION, INJECTED BY THE FILE THAT OWNS IT** — `constraints.mjs` calls
222
+ /// `installRestartConsumer(drainRestartRequests)` at its own module scope. **A NULL SLOT IS A STORE WITH NO
223
+ /// RESTART MACHINERY AND ITS PASS ANSWERS ITS REPORT UNCHANGED** — a request can only be raised by a pair, a
224
+ /// pair is only carried by `constraints.mjs`, and a tree that never loads that file has no request to consume.
225
+ let RESTART_CONSUMER = null;
226
+ export function installRestartConsumer(consumer) {
227
+ RESTART_CONSUMER = consumer;
228
+ }
229
+
230
+ /// **⟶ ADDED 2026-10-27 (`D-45`), RE-SPELLED 2026-10-27 (`D-46`) — THE SEAM'S SIXTH CHANNEL, AND IT CARRIES
231
+ /// THE COMMIT AN INVOCATION OF CALLER CODE NAMES ON ITS OWN ENTRY.**
232
+ ///
233
+ /// **WHAT IT CARRIES NOW, AND WHAT IT NO LONGER CARRIES.** `D-45` armed it with **A DEPTH** — the number of
234
+ /// caller-supplied frames in flight — and `openCommit` compared that depth against the depth the commit in
235
+ /// flight was opened at. **`D-46` REPLACES THE DEPTH WITH THE COMMIT ITSELF**: the second position holds **the
236
+ /// commit the invocation names**, or `undefined` where the invocation names none, and **`openCommit` reads it as
237
+ /// the name a call supplies when its own entry position carries none.** **THE DEPTH IS DELETED, NOT KEPT BESIDE
238
+ /// IT** — one discriminator, stated once: **a call that names a commit JOINS it; a call that names none OPENS
239
+ /// one** (`openCommit` below).
240
+ ///
241
+ /// **WHICH INVOCATIONS NAME ONE, AND IT IS THE WHOLE OF `D-46`'s SECOND DIRECTION.** **A REPAIR NAMES THE
242
+ /// ATTEMPT'S COMMIT** — *"A constraint's repair needs to stay as part of the same commit so that it can be
243
+ /// tracked as part of the commit process"* — so the kernel hands the attempt's own record at the two frames that
244
+ /// invoke a repair body (`kernel-attempt.mjs`'s arm (b) and `kernel-registration.mjs`'s state `3`), and the write
245
+ /// a repair body makes **joins the attempt's commit by declaration**: its ops are the attempt's ops, its
246
+ /// `repair-run` entry names the op it landed, and **no second commit opens for it** (`attempt-opened` stays at
247
+ /// ONE for a write that repairs `tests/e2e/repair-in-commit.test.mjs` prints it). **A LISTENER BODY NAMES
248
+ /// NOTHING, AND THAT IS NOT AN OMISSION: IT HAS NO COMMIT IN HAND TO NAME** — it is externally-passed code
249
+ /// entering at the surface (`D-43` item `1`, `D-45`), so its call **OPENS ITS OWN** and the descendant window
250
+ /// stays closed by construction (`tests/e2e/external-commit.test.mjs`, unchanged and green). **A CONSTRAINT
251
+ /// BODY NAMES NOTHING EITHER**: it is invoked to be *asked*, not to act, so a verb it calls is a fresh act at the
252
+ /// surface — the same reading `D-45` gave it.
253
+ ///
254
+ /// **WHAT IT MARKS AND FOR HOW LONG**: one invocation of a caller-supplied function and nothing else. The site
255
+ /// arms it BEFORE the call and restores the previous value AFTER, on the throwing arm too, so no name outlives
256
+ /// the invocation and a nested invocation is measured by its own name and not its caller's.
257
+ ///
258
+ /// **WHY IT IS A `Symbol.for` CHANNEL ON THE PRODUCT AND NOT AN EXPORT THE KERNEL IMPORTS** (`A117` (D6), the
259
+ /// family `TERMINAL_ARM`, `FORGET_PAIR`, `COMMIT_SCOPE` and `RESTART_DRAIN` are declared under): the kernel's
260
+ /// four part modules declare an EMPTY import footprint (`kernel-surface.md §1` item 1; `A110`) and cannot
261
+ /// import this file, so **both sides spell the same key and neither side imports the other**. **IT IS INVISIBLE
262
+ /// TO `Object.keys` AND TO `Object.getOwnPropertyNames`**, so the product's declared own members are unmoved,
263
+ /// no census moves, and no kernel item is minted (`§1` item 2: `K-1`–`K-6` and no seventh name).
264
+ const EXTERNAL_CALL = Symbol.for('provident-storeroom.external-call');
265
+
266
+ /// **THE NAME ITSELF — the commit the invocation in flight was handed, for the process** (`undefined` where it
267
+ /// was handed none), read by `openCommit` and moved by the channel below and by nothing else.
268
+ let EXTERNAL_COMMIT = undefined;
269
+
270
+ /// **AND THE MARK'S OWN SECOND FACT IS KEPT, AS `D-46`'s FALLBACK FOR THE CALLERS THAT CANNOT NAME ONE** — the
271
+ /// depth of caller-supplied frames in flight, read at `openCommit`'s unnamed arm and moved by the same channel.
272
+ /// **IT NO LONGER DECIDES ANY CALL THAT NAMES A COMMIT**: `D-45`'s rule is narrowed to the unnamed arm and is the
273
+ /// whole of what answers there, which is what keeps the package's own continuation (`constraintOn`'s nested
274
+ /// `listen`, a pass's scope) JOINING while a listener body's or a constraint body's verb — one frame deeper than
275
+ /// the commit it finds — OPENS. **TWO FACTS, ONE RULE**: the name if the call has one, and authorship only where
276
+ /// it has none (see `openCommit`).
277
+ let EXTERNAL_DEPTH = 0;
278
+
279
+ /// **THE ONE FORM THE ENTRY'S OWN SITES CALL** — it hands the thunk to the channel the store carries **without a
280
+ /// commit, because the entry's own two sites are a listener body's delivery and a reversal's judgement, and
281
+ /// neither has one to name**, and answers what the invocation answered; its throwable crosses unchanged.
282
+ ///
283
+ /// **A STORE THAT CARRIES NO CHANNEL ANSWERS THE INVOCATION WITH NOTHING NAMED** — a store this package never
284
+ /// installed the seam on, or a caller that read the symbol property away. That is the CONSERVATIVE side for this
285
+ /// mechanism: the call then opens its own commit, which is the rule's own absent arm, and it can never join a
286
+ /// commit nobody named.
287
+ export function externalCall(store, run) {
288
+ const channel = store !== null && typeof store === 'object' ? store[EXTERNAL_CALL] : undefined;
289
+ if (typeof channel === 'function') return channel(run);
290
+ return run();
291
+ }
292
+
293
+ /** The per-store index: `{ open, observers, windows, marks, windowSeq }`, keyed by the store instance and by
294
+ * nothing else. **`windows` IS THE STACK OF OPEN WINDOW IDENTITIES** — one number per commit this store opened, the
295
+ * top being the window in flight — and it exists so a restart request can name the window that raised it
296
+ * (`D-42`'s *"a request belongs to the act that raised it"*, made a measurement instead of an inference).
297
+ * **`marks` IS THE STACK BESIDE IT AND IT IS THE SAME ONE STACK READ AS THE JOURNAL MARK** — one entry per commit
298
+ * that OPENED, pushed and popped in lockstep with `windows` (`openCommit`/`closeCommit`), so `windowMark` answers
299
+ * the outermost opening's mark and a join neither pushes nor pops. */
125
300
  const ATTEMPT_INDEX = new WeakMap();
126
301
 
127
302
  function attemptIndex(store) {
@@ -136,7 +311,7 @@ function attemptIndex(store) {
136
311
  // refusal.** The list preserves the Set's own two facts — insertion order and uniqueness — and the copy
137
312
  // is taken before any notification, so an observer that removes itself mid-notification still moves
138
313
  // nothing.
139
- index = { open: 0, observers: [] };
314
+ index = { open: 0, observers: [], windows: [], marks: [], externalAt: [], windowSeq: 0 };
140
315
  ATTEMPT_INDEX.set(store, index);
141
316
  }
142
317
  return index;
@@ -163,12 +338,126 @@ export function openCommits(store) {
163
338
  return attemptIndex(store).open;
164
339
  }
165
340
 
341
+ /// **⟶ ADDED 2026-10-27 — THE WINDOW IN FLIGHT, AS THE PLAIN ACCESSOR BESIDE THE COUNT ABOVE.**
342
+ ///
343
+ /// **IT ANSWERS THE IDENTITY OF THE COMMIT THE STORE HAS OPEN, AND `0` WHERE NONE IS** — a number minted once
344
+ /// per commit that OPENS (`windowSeq`, strictly increasing and never reused) and held on a stack so that a
345
+ /// nested verb's JOIN answers the enclosing window's identity and not a second one. **IT IS READ BY EXACTLY
346
+ /// ONE ACT AND FOR EXACTLY ONE FACT**: `constraints.mjs`'s `reversalWatch` stamps the restart request an
347
+ /// in-commit action raises with the window that raised it, and `drainRestartRequests` consumes a request only
348
+ /// where that stamp equals the window the draining pass runs in. **SO *"A REQUEST BELONGS TO THE ACT THAT
349
+ /// RAISED IT"* — `D-42`'s own sentence — IS MEASURED RATHER THAN ASSUMED**, and the two declared windows that
350
+ /// have no check to run (`D-42`'s `delete` delivery, and the pass a hand drives) no longer need a counting
351
+ /// frame to tell them apart from the write the check belongs to.
352
+ ///
353
+ /// **IT IS A PURE READ** in `§4.2` item 1's sense — no state, no code, no journal entry and no file — and it
354
+ /// creates its index on miss exactly as `openCommits` does, so it cannot answer `undefined` on any path.
355
+ export function currentWindow(store) {
356
+ const windows = attemptIndex(store).windows;
357
+ return windows.length === 0 ? 0 : windows[windows.length - 1];
358
+ }
359
+
360
+ /// **⟶ ADDED 2026-10-27 — THE MARK THE WINDOW IN FLIGHT CACHED AT ITS OPENING, AND `undefined` WHERE NO COMMIT
361
+ /// IS OPEN.**
362
+ ///
363
+ /// **THE RULING IT CARRIES, THE ARCHITECT, VERBATIM: *"Cache the restoreMark when opening a commit, based on the
364
+ /// last valid state/op of the journal."*** **THE DEFECT IT CLOSES IS `DEF-AE`'s AND IT IS A DATA-INTEGRITY ONE:**
365
+ /// the refused reversal's restore named **the journal's HEAD**, on the reasoning that *"a reversal appends no
366
+ /// journal entry, so that head describes the state that stood BEFORE the action"* — **a reasoning that fails on
367
+ /// exactly one arm**. In the restart arm the ENCLOSING WRITE'S OWN OP STANDS AT THE HEAD when the listener's
368
+ /// reversal runs, so the compensation restored **the write's landing, not the pre-attempt state**: a write that
369
+ /// reported refusal left its own value standing (`9 → 7`).
370
+ ///
371
+ /// **SO THE MARK IS TAKEN WHERE IT IS TRUE AND NOT WHERE IT IS NEEDED.** Every commit that OPENS reads the store's
372
+ /// last valid mark (`withAddon().journalMark`, the store's own `journalMark`) and stands it on the window beside
373
+ /// the window's identity. **THE INSTANT IS THE WHOLE POINT**: at an outermost opening nothing of the attempt has
374
+ /// landed yet, so the mark names the state the commit FOUND. A JOIN IS THE SAME ACT AND RE-CACHES NOTHING — a join
375
+ /// appends no window and no mark, so the cache in flight stays the outermost opening's — which is what makes a
376
+ /// repair's write (a join, `D-46`) and a pass's scope (a join on the production path, `D-44`) read the attempt's
377
+ /// own position rather than a later one. **A CALLBACK'S OWN COMMIT IS ITS OWN OPENING WITH ITS OWN CACHE**
378
+ /// (`D-45`/`D-46`: a listener body's call names nothing and opens), so the mark a listener's own attempt restores
379
+ /// to is where ITS window opened.
380
+ ///
381
+ /// **A WINDOW WITH NO CACHE IS A WINDOW THAT NEVER OPENED, AND `undefined` IS ITS SPELLING.** The store answers
382
+ /// `{k:'s', v:<op id>}` where the journal holds an entry and `{k:'F'}` where it holds none (the FLOOR — the state
383
+ /// the store was born with); `undefined` means the read could not answer at all (a store whose artefact could not
384
+ /// be reached), and the refused-reversal restore REFUSES rather than falling back to the head
385
+ /// (`constraints.mjs`'s `restoreReversal` states that arm). **THE MARK IS OPAQUE HERE**: this file caches the
386
+ /// store's own carrier and never composes a position of its own.
387
+ export function windowMark(store) {
388
+ const index = attemptIndex(store);
389
+ if (index.windows.length === 0) return undefined;
390
+ return index.marks[index.marks.length - 1];
391
+ }
392
+
393
+ /// **THE MARK THE OPENING TAKES** — the store's own read, once per commit that OPENS and never per join. **IT IS
394
+ /// TAKEN THROUGH THE ENTRY THE ADDON PUBLISHES** (`journalMark`), bound to the store object exactly as every other
395
+ /// addon call is (`commitFile` above is the same form). **A READ THAT THROWS IS A WINDOW WITH NO CACHE AND NOT A
396
+ /// REFUSED CALL**: the opening is not the act the consumer asked for, and refusing the consumer's verb because the
397
+ /// journal read failed would answer a form the verb does not declare — so the arm answers `undefined`, the window
398
+ /// stands without a cache, and the one consumer that needs the mark refuses its own restore instead.
399
+ function journalMarkAtOpening(store) {
400
+ try {
401
+ const addon_ = withAddon();
402
+ return Reflect.apply(addon_.journalMark, store, []);
403
+ } catch (unanswered) {
404
+ return undefined;
405
+ }
406
+ }
407
+
166
408
  /** **THE INCREMENT MOMENT** (`PAR-ADA-15`): the opening of a commit. It is taken iff THIS call opens one —
167
- * a call that finds the count already above zero has joined an extant commit and opens nothing. */
168
- export function openCommit(store) {
409
+ * a call that finds the count already above zero has joined an extant commit and opens nothing.
410
+ *
411
+ * **⟶ AND FROM 2026-10-27 THE TEST IS THE COMMIT THE CALL NAMES** (`D-46`; the clause at this section's head):
412
+ * **A CALL THAT NAMES A COMMIT JOINS THAT COMMIT, AND A CALL THAT NAMES NONE OPENS A NEW ONE FROM A STORE AT
413
+ * REST OR FROM A CALLER-SUPPLIED FUNCTION — while the package's own continuation, which can name nothing
414
+ * either, JOINS the commit in flight.** `commit` IS THE ENTRY'S POSITION — `write`'s FOURTH, the one
415
+ * `index.d.ts` declares *"the commit, at the FOURTH position of the METHOD"*, whose domain is a RECORD (an
416
+ * object carrying an own, present `pending`) and never an id token. **AND WHERE A CALL SITS INSIDE AN
417
+ * INVOCATION THE PACKAGE ITSELF MADE OF CALLER CODE, THE NAME IS THE ONE THAT INVOCATION WAS HANDED**
418
+ * (`EXTERNAL_COMMIT` above): the kernel names the attempt's commit when it invokes a **repair** — *"so that it
419
+ * can be tracked as part of the commit process"* — and names nothing when it invokes a listener body or a
420
+ * constraint body. **ONE RULE AND TWO PLACES THE NAME MAY COME FROM; THE ENTRY'S OWN POSITION WINS, THE
421
+ * INVOCATION'S IS ITS FALLBACK, AND THE AUTHORSHIP MARK BELOW IS THE FALLBACK OF THE FALLBACK — read only
422
+ * where neither position stands.**
423
+ *
424
+ * **SO THE COUNT STILL MOVES BY EXACTLY ONE PER ACT**: an ordinary write's opening is the only one it takes
425
+ * (its kernel leg names the record and joins, its pass scope names it and joins, its repair names it and
426
+ * joins), a listener body's own write names nothing and is a window of its own beside it (`open` rises by one
427
+ * for the callback and falls by one when the callback's call ends, the outer verb's count unchanged across
428
+ * it), and a constraint body's nested write does the same (`D-45`). **A JOIN CAN ONLY BE A JOIN OF A COMMIT
429
+ * THAT IS OPEN** — where the count stands at zero there is nothing to join, so the call opens, which is what
430
+ * keeps `D-44`'s direct `K-2`/`K-3` drive's pass inside a commit of its own. */
431
+ export function openCommit(store, commit) {
169
432
  const index = attemptIndex(store);
170
- if (index.open > 0) return false;
433
+ // THE COMMIT THIS CALL NAMES — the entry's own position first, the invocation's second (`EXTERNAL_COMMIT`).
434
+ const named = commit !== undefined ? commit : EXTERNAL_COMMIT;
435
+ if (index.open > 0) {
436
+ // **A NAMED COMMIT IS JOINED** — `D-46`'s rule, and it stands FIRST and decides wherever a name exists.
437
+ if (named !== undefined) return false;
438
+ // **AND WHERE NO NAME STANDS, `D-45`'S MARK DECIDES, AND IT IS THE FALLBACK FOR EXACTLY THE CALLERS THAT
439
+ // CANNOT NAME A COMMIT**: the package's own continuation of the commit in flight runs at the depth that
440
+ // commit was opened at and JOINS; a call made from a caller-supplied function — one frame deeper — OPENS.
441
+ const at = index.externalAt.length === 0 ? 0 : index.externalAt[index.externalAt.length - 1];
442
+ if (EXTERNAL_DEPTH <= at) return false;
443
+ }
171
444
  index.open += 1;
445
+ // **AND THE WINDOW'S OWN IDENTITY IS MINTED WITH THE OPENING AND STOOD ON THE STACK** (`currentWindow`
446
+ // above): a commit that JOINS answers an id already held, so the nesting `§4.1` keeps exact in the count is
447
+ // kept exact in the identity too, and no window id is ever reused.
448
+ index.windowSeq += 1;
449
+ appendOwn(index.windows, index.windowSeq);
450
+ // **⟶ AND THE MARK THE OPENING TAKES, 2026-10-27 — THE ARCHITECT'S RULING: *"Cache the restoreMark when opening
451
+ // a commit, based on the last valid state/op of the journal."*** **THE CACHE IS TAKEN HERE AND ONLY HERE**: this
452
+ // is the arm that OPENS (a join returned above and takes nothing), so the store's read names the journal's
453
+ // position at the instant the commit was entered — before anything the commit will land has landed. **IT IS
454
+ // TAKEN BEFORE THE OBSERVERS FIRE** (the notification below is part of the opening, and an observer that acts
455
+ // would open its own commit; this window's mark is the one that stood when the window itself opened). It is
456
+ // pushed in lockstep with `windows` so the two stacks are one stack, and `closeCommit` releases it with it.
457
+ appendOwn(index.marks, journalMarkAtOpening(store));
458
+ // **AND THE DEPTH FALLBACK'S OWN RECORD IS STOOD BESIDE IT**: the depth this commit was opened at, in lockstep
459
+ // with `windows`, so the next unnamed call can tell the package's own continuation from a callback's act.
460
+ appendOwn(index.externalAt, EXTERNAL_DEPTH);
172
461
  // **THE OBSERVER SEAM IS READ AT THE INSTANT OF THE OPENING** (`§4.2` item 2), one call per opening — and
173
462
  // the iteration is a copy, so an observer that unsubscribes itself mid-notification moves nothing. **The
174
463
  // copy and the notification are LOCAL INDEX LOOPS** (item `(1c)(i)`): no spread, no iterator.
@@ -185,6 +474,24 @@ export function closeCommit(store, opened) {
185
474
  if (!opened) return;
186
475
  const index = attemptIndex(store);
187
476
  index.open -= 1;
477
+ // **AND THE WINDOW THE OPENING STOOD ON GOES WITH IT**, by a local index loop rather than through a mutable
478
+ // prototype's `slice`/`pop` (`contract.md §2.1`'s clause of 2026-10-24 on `F7-1`/`F8-2`). A joining call
479
+ // opened nothing and releases nothing, so the enclosing window's identity stands. **AND THE DEPTH STOOD BESIDE
480
+ // IT GOES WITH IT, IN THE SAME LOOP AND AT THE SAME INSTANT**: the two stacks are one stack read two ways, so a
481
+ // commit's depth can never be left standing for a commit that has closed. **AND THE MARK THE OPENING CACHED
482
+ // GOES WITH IT IN THAT SAME LOOP** — `windows`, `externalAt` and `marks` are one stack read three ways, so no
483
+ // closed window's journal position can be answered to a later act.
484
+ const kept = [];
485
+ const keptAt = [];
486
+ const keptMark = [];
487
+ for (let i = 0; i + 1 < index.windows.length; i += 1) {
488
+ appendOwn(kept, index.windows[i]);
489
+ appendOwn(keptAt, index.externalAt[i]);
490
+ appendOwn(keptMark, index.marks[i]);
491
+ }
492
+ index.windows = kept;
493
+ index.externalAt = keptAt;
494
+ index.marks = keptMark;
188
495
  }
189
496
 
190
497
  /// **THE TWO CHANNELS, INSTALLED ONCE ON THE OBJECT `storeCreate` RETURNS** (`§4.2` item 4: *"`storeCreate`
@@ -237,6 +544,71 @@ export function installAttemptSeam(instance) {
237
544
  configurable: true,
238
545
  });
239
546
  }
547
+ // **⟶ AND THE SCOPE, INSTALLED ONCE BY THE SAME RULE** (`§4.2` item 4: *"`storeCreate` installs each channel
548
+ // once on the object it returns"*; `D-44`). **It is the two moments `openCommit`/`closeCommit` already own,
549
+ // composed into one bracket and minting no third count**: this channel adds no index, no state and no
550
+ // increment — it only decides WHO opens. **AND FROM 2026-10-27 IT TAKES THE PASS'S OWN COMMIT AT ITS SECOND
551
+ // POSITION** (`D-46`): `runAttempt` hands the record `K-2` built, so **the pass's scope NAMES the commit the
552
+ // attempt is tracked in and joins it** on the production path, **and on a direct `K-2`/`K-3` drive the name
553
+ // has nothing to join and the scope OPENS the one commit the pass owes** (`D-44`'s direct-pass window).
554
+ if (typeof instance[COMMIT_SCOPE] !== 'function') {
555
+ Object.defineProperty(instance, COMMIT_SCOPE, {
556
+ value: (run, commit) => {
557
+ const opened = openCommit(instance, commit);
558
+ try {
559
+ return run();
560
+ } finally {
561
+ closeCommit(instance, opened);
562
+ }
563
+ },
564
+ writable: true,
565
+ enumerable: false,
566
+ configurable: true,
567
+ });
568
+ }
569
+ // **⟶ AND THE INVOCATION'S OWN ENTRY, INSTALLED ONCE BY THE SAME ONE-INSTALLATION RULE, 2026-10-27 —
570
+ // `D-45`'s channel, carrying `D-46`'s name.** It takes ONE thunk — **the invocation of a caller-supplied
571
+ // function** — and, at its SECOND position, **the commit that invocation names** (absent where it names
572
+ // none), runs the thunk with `EXTERNAL_COMMIT` holding that name, and answers what the thunk answered. **THE
573
+ // NAME IS RESTORED IN A `finally`**, so a body that throws leaves no name standing and the next invocation
574
+ // reads the one it was handed; and **the arming and the restoring are this closure's whole body**, so nothing
575
+ // the package does outside an invocation is ever measured by a name. **A CALLER THAT SUPPLIES ONLY THE THUNK
576
+ // NAMES NOTHING** — which is the rule's own absent arm and not a second rule, and it is how the kernel's
577
+ // `externalCall` (`kernel-foundations.mjs`) and this module's own `externalCall` above reach the channel.
578
+ if (typeof instance[EXTERNAL_CALL] !== 'function') {
579
+ Object.defineProperty(instance, EXTERNAL_CALL, {
580
+ value: (run, commit) => {
581
+ const standing = EXTERNAL_COMMIT;
582
+ EXTERNAL_COMMIT = commit;
583
+ EXTERNAL_DEPTH += 1;
584
+ try {
585
+ return run();
586
+ } finally {
587
+ EXTERNAL_DEPTH -= 1;
588
+ EXTERNAL_COMMIT = standing;
589
+ }
590
+ },
591
+ writable: true,
592
+ enumerable: false,
593
+ configurable: true,
594
+ });
595
+ }
596
+ // **⟶ AND THE RESTART'S CONSUMER, BY THE SAME ONE-INSTALLATION RULE, 2026-10-27.** `runAttempt` calls it
597
+ // AFTER its pass and INSIDE the scope above, handing THE REPORT THE PASS ANSWERED WITH; the answer is the
598
+ // report the kernel returns, amended where the restarted check refused (`constraints.mjs`'s
599
+ // `carryRestartRefusal`) and untouched where none refused. **A STORE WITH NO INJECTED CONSUMER ANSWERS ITS
600
+ // REPORT UNCHANGED** — the restart machinery is the entry's and its absence is a tree that never loaded it,
601
+ // which is also a tree that carries no pair and so can have raised no request.
602
+ if (typeof instance[RESTART_DRAIN] !== 'function') {
603
+ Object.defineProperty(instance, RESTART_DRAIN, {
604
+ value: (report) => (typeof RESTART_CONSUMER === 'function'
605
+ ? RESTART_CONSUMER(instance, report)
606
+ : report),
607
+ writable: true,
608
+ enumerable: false,
609
+ configurable: true,
610
+ });
611
+ }
240
612
  }
241
613
 
242
614
  // ---------------------------------------------------------------------------------------------