provident-storeroom 1.12.0 → 2.0.1

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.
package/index.mjs CHANGED
@@ -84,27 +84,93 @@
84
84
  // is the declared observable), and the invocation's ONE argument is the triggering ADDRESS (`PAR-JS-12`):
85
85
  // the matched id and the address are two different data and only the address is passed.**
86
86
 
87
- import { readFileSync } from 'node:fs';
87
+ import { readFileSync, existsSync, unlinkSync } from 'node:fs';
88
88
  import { createRequire } from 'node:module';
89
89
  import { dirname as dirOf, join } from 'node:path';
90
90
  import { fileURLToPath } from 'node:url';
91
91
  import { types } from 'node:util';
92
92
 
93
- import { appendOwn, fail } from './src/entry/refusal.mjs';
94
- import { withAddon, boundaryReject, adoptModuleContext } from './src/entry/artefact.mjs';
95
- import { VALUE_ARGUMENT_POSITION, accessorOrSymbolArm, arrayClass, classSpelling, extendedPath, hasLoneSurrogate, inDomainAddress, isAdmittedArray, isLawfulListenerElement, isPlainObjectValue, protoClass, shapeArmClass, targetSpelling, valueReject, valueTargetSpelling } from './src/entry/class-decision.mjs';
96
- import { encodeAddress, encodeFilePath, encodeJournalLength, encodeOpId, encodeTier, encodeValue, handleWire, inDomainHandle } from './src/entry/carrier.mjs';
97
- import { admittedConstraintBatch, admittedListenerBatch, constraintAddress, decodeBaseState, decodeJournalOp, decodeSegments, decodeValue, encodeConfig, spellConstraintAddress } from './src/entry/frame.mjs';
98
- // ⟶ `addressSpelling`'s import is DELETED 2026-11-01 with its last two readers (`B-6`'s and `B-4`'s messages,
99
- // which now name no address at all — `D-98` §3.4). The function keeps its home and its other readers in the
100
- // entry's other parts.
101
- import { FORGET_PAIR, INSTANCES, STORE_INDEX, STORE_RETIREMENT, TERMINAL_ARM, appendRepairLeg, carryRefusal, closeCommit, crossTriggered, currentWindow, entryOf, installAttemptSeam, isStoreReceiver, openCommit, writeRefusal } from './src/entry/state.mjs';
102
- import { commitPositionRefusal, constraintOverwrittenByListen, deliver, installListenRoute, installRegistrationDelivery, installRegistrationSave, installRegistrationSeam, listenerStandingAt, listenOn, registerOn, terminalArm } from './src/entry/delivery.mjs';
103
- import { ARGUMENT_POSITION_FIRST, addressSetKey, carryConstraint, constraintDetached, constraintPairKey, constraintRefuse, constraintSite, constraintUncarried, constraintDelete, constraintWrite, constraintsKernel, currentRaise, defineDiscardWitness, defineResolutionLog, enumerateConstraints, judgeReversal, registrationCrossing, restoreHeldPair, reversalWatch, unionAddressSets, withEmptyLog, witnessDiscardedReversal, witnessRaise, withdrawStanding } from './src/entry/constraints.mjs';
93
+ // **⟶ AND THE NODE ARM'S GLUE IS INSTALLED BY ONE SIDE-EFFECT IMPORT, 2026-11-17** (`D-156` item 1; the loader
94
+ // split, `docs/L3/wasm-realm/design.md` §5): `artefact.mjs` walks for the artefact through `artefact-node.mjs` —
95
+ // the three `node:` imports, the platform table, `packageVersion()` and the three rungs — and hands the walk, the
96
+ // attempt list's own subject renderer and this ENTRY's artefact path to `addon-slot.mjs`, which holds the slot
97
+ // every part now reads. **THE GLUE INSTALLS A LOAD PATH AND NOT A MODULE**: nothing is looked for until a
98
+ // construction asks for it, so this entry still loads and still reads no file at its own evaluation.
99
+ import './src/entry/artefact.mjs';
100
+ // **⟶ AND THE MODULE-CONTEXT SEAM IS THE NODE HALF'S FROM 2026-11-17** (`D-156` item 1; the loader split's
101
+ // extraction, `docs/L3/wasm-realm/design.md` §5). `adoptModuleContext` stores the three facts THIS module derives
102
+ // from its own `import.meta.url` — the `createRequire` base, the artefact path and the manifest's directory — and
103
+ // the three-rung walk that reads them is `artefact-node.mjs`'s, so the seam and its storage are imported from
104
+ // THERE. **THE CALL AT THIS MODULE'S OWN EVALUATION IS UNMOVED BYTE-FOR-BYTE AND SO ARE ITS THREE POSITIONS**
105
+ // (`I-29`; `PUB-DD-20`): the entry still adopts its own context, and a part still derives nothing from its own
106
+ // URL. **NO OTHER NAME OF THE LINE ABOVE MOVES.**
107
+ import { adoptModuleContext } from './src/entry/artefact-node.mjs';
108
+ // **⟶ AND THE CLASS-DECISION INSTRUMENT'S SETTER JOINS THIS BLOCK, 2026-11-17** (`D-156` item 1; the loader
109
+ // split's row: *"`node:util` in five parts — one import line swapped for a local helper — **neutralised**"*).
110
+ // **`installClassInstrument` IS THE ONE SETTER** and it is called once, below, at this module's own evaluation;
111
+ // the five parts that decide `DD-34`'s `Proxy` refusal read the predicate from `class-instrument.mjs` and carry
112
+ // no `node:` specifier for it.
113
+ import { installClassInstrument } from './src/entry/class-instrument.mjs';
114
+ import { installConstructionFileGuard } from './src/entry/state.mjs';
115
+ // **⟶ AND THE FIFTEEN MEMBERS' BODY HAS ONE COPY, 2026-11-17** (`D-156` item 1; `design.md` §5: *"the shared
116
+ // body — the fifteen members, `deliver`, the kernel glue — is ONE copy"*). THIS ENTRY IS NOW THE NODE ARM'S
117
+ // HEAD AND ITS ONE EXPORT IS THE SHARED BODY'S: the construction, the instance and the fifteen members stand in
118
+ // `src/entry/instance.mjs`, which carries no `node:` specifier and reads no host fact, so the second realm's own
119
+ // entry imports the SAME body and differences itself by ONE function — how its bindings arrive. **THE NAMESPACE IS
120
+ // UNMOVED** (`surface.md §2.9` item 1: ONE value-level name, `storeCreate`), the arity is the body's (`1`), and no
121
+ // byte of any construction, member or refusal moved.
122
+ export { storeCreate } from './src/entry/instance.mjs';
123
+
104
124
  const require_ = createRequire(import.meta.url);
105
125
  const ADDON_PATH = join(dirOf(fileURLToPath(import.meta.url)), 'build', 'Release', 'storeroom_js_binding.node');
106
126
 
107
127
  adoptModuleContext(import.meta.url, require_, ADDON_PATH);
128
+ // ---------------------------------------------------------------------------------------------
129
+ // **⟶ AND THE CLASS-DECISION INSTRUMENT IS INSTALLED HERE, AT THE HEAD OF THE MODULE AND BEFORE ANY PART CAN
130
+ // CLASSIFY A SINGLE VALUE — 2026-11-17** (`D-156` item 1; `docs/L3/wasm-realm/design.md` §5). **THE NODE ARM'S
131
+ // INSTRUMENT IS `types.isProxy` ITSELF**, handed over as an arrow that reads it at call time, and the five parts
132
+ // that decide `DD-34`'s refusal (25 sites) reach it through `class-instrument.mjs`'s one predicate — **so every
133
+ // answer those sites take is the answer they took when each imported `node:util` directly: the instrument's HOME
134
+ // moved and the decision, its order and its answer did not.**
135
+ //
136
+ // **★ AND THIS LINE IS WHAT MAKES `isProxyOf`'S DEFAULT UNREACHABLE, WHICH IS THE WHOLE OF ITS DUTY.** Before an
137
+ // instrument is installed that predicate answers `false` — "not a `Proxy`" — for every value, which is a SILENT
138
+ // LOSS of the `DD-34` refusal and can let a trap run on a path that promises no trap does. **The default is `false`
139
+ // deliberately**: the other arm, refusing everything, refuses every value's prototype link, so no value crosses and
140
+ // no store can be constructed at all. **The entry's installation is therefore the thing that closes the gap, and it
141
+ // happens at the module's own evaluation, before any verb and before any part classifies anything.**
142
+ //
143
+ // **⟶ AND THE SETTER TAKES BOTH PREDICATES FROM 2026-11-17 — `D-167`.** The seam holds two questions now — the DATA
144
+ // one (`isProxyOf`: *does this value enter the Rust store?*) and the CARRIER one (`isProxyOfCarrier`: *is this the
145
+ // package's own `cfg`/listeners/constraints/commit carrier?*) — and **THE NODE ARM'S ANSWER TO BOTH IS
146
+ // `types.isProxy`, WHICH IS WHY THIS LINE CHANGES BY ONE ARGUMENT AND NOTHING ON THIS ARM MOVES BY A BYTE**: that
147
+ // predicate is precise here (it reads the exotic object's own internal slot, invokes no handler and throws for
148
+ // nothing), so every `Proxy` a carrier gate refused before this line changed is still refused, in the same form
149
+ // with the same message. **WHAT THE SECOND ARGUMENT BUYS IS NOTHING ON THIS ARM AND EVERYTHING ON THE OTHER**: it
150
+ // is the arm whose probe cannot answer the carrier question that must be able to answer it differently, and **an
151
+ // entry that installed only the data instrument would leave `isProxyOfCarrier` at its `false` default HERE, which is
152
+ // a silent loss of `DD-34` at every carrier gate** — so the setter requires both and this line passes both.
153
+ // ---------------------------------------------------------------------------------------------
154
+ installClassInstrument((value) => types.isProxy(value), (value) => types.isProxy(value));
155
+
156
+ // ---------------------------------------------------------------------------------------------
157
+ // **⟶ AND THE CONSTRUCTION'S FILE GUARD IS INSTALLED HERE — 2026-11-17** (`SS-9`; `A55`'s *"leaves nothing behind"*).
158
+ // **THE NODE ARM IS THE ONLY ARM WITH A FILESYSTEM, SO IT IS THE ONLY ARM THAT INSTALLS ONE**: `existsSync` is read BEFORE
159
+ // the store's exclusive create and `unlinkSync` removes the store's own zero-length artefact **only where the construction
160
+ // made it and then refused** — a construction over an ABSENT path whose constraint body throws at registration.
161
+ // **THE INJECTED ARM INSTALLS NOTHING**: it refuses `filePath` outright, so it never creates a file to remove.
162
+ // ---------------------------------------------------------------------------------------------
163
+ installConstructionFileGuard((filePath) => {
164
+ const existed = existsSync(filePath);
165
+ return {
166
+ existed,
167
+ undo: () => {
168
+ if (existed === true) return;
169
+ try { unlinkSync(filePath); } catch { /* the refusal path never throws for this */ }
170
+ },
171
+ };
172
+ });
173
+
108
174
 
109
175
  // ---------------------------------------------------------------------------------------------
110
176
  // **⟶ `copySegments` MOVED WITH ITS ONLY READER, 2026-11-01 (`D-99`'s ANSWERED clause; `C-17`, §9.2).**
@@ -115,2086 +181,3 @@ adoptModuleContext(import.meta.url, require_, ADDON_PATH);
115
181
  // same local index loop over the caller's own exotic `length` and its own indices, appending by `appendOwn`,
116
182
  // answering a FRESH segment list — and no member of this module's namespace was ever this function.
117
183
  // ---------------------------------------------------------------------------------------------
118
-
119
- // ---------------------------------------------------------------------------------------------
120
- // THE SURFACE — `surface.md §2.9` item 1: the EIGHT verbs, and NOTHING else. `findAddress` is NOT exposed
121
- // (`A63`), no `exists` verb exists (`docs/specs/storeroom-js/surface.md §2.9` item 3) and no release verb is declared (`A74`).
122
- // ---------------------------------------------------------------------------------------------
123
-
124
- /// **ONE MEMBER OF A HANDED VALUE, READ AS AN OWN DATA PROPERTY OR NOT AT ALL** — `[[GetOwnProperty]]`'s answer,
125
- /// which consults no prototype chain (`D-35`'s read half, the reading `refusal.mjs` and the kernel take). Used by
126
- /// the sweep's guard and by its refusal conversion, where the values read are a caller's own returned outcome and
127
- /// a refusal this package threw.
128
- function ownValue(value, name) {
129
- if (value === null || typeof value !== 'object') return undefined;
130
- const descriptor = Object.getOwnPropertyDescriptor(value, name);
131
- if (descriptor === undefined || !Object.hasOwn(descriptor, 'value')) return undefined;
132
- return descriptor.value;
133
- }
134
-
135
- /// **THE ACT'S CONVERSION OF A FIRED BODY'S THROWABLE — `PIN-10`, `Q-13`, AND IT IS TAKEN BEFORE THE ANSWER.**
136
- /// **THE DELIVER PRECEDES THE ANSWER AT THIS INSTANT** (`PIN-2`: SAVE → DELIVER → THE ANSWER), so a body that
137
- /// threw PRE-EMPTS it: the caller receives rank `21` `ListenerBodyThrew` and never the identity or the
138
- /// `undefined` it would have had. **NOTHING IS UNDONE** (`Q-13`: *"the pair stands registered, its save stands,
139
- /// and no withdrawal arm is declared"*) and **no rollback composes** — the composition was this registration's
140
- /// own and it was spent before the delivery ran.
141
- ///
142
- /// **THE SLOT IS CONSUMED HERE AND ITS ABSENCE IS THE ORDINARY ARM**: the act reads it once, at its own answer,
143
- /// and nothing else in the package can see it — a value of the package's own state, exactly as `legDelivery` is.
144
- function raiseListenerFailure(state) {
145
- const failure = state.listenerFailure;
146
- state.listenerFailure = null;
147
- if (failure === null || typeof failure !== 'object') return undefined;
148
- const at = ownValue(failure, 'address');
149
- listenerBodyRefused(Array.isArray(at) ? at : []);
150
- return undefined;
151
- }
152
-
153
- /// **THE SWEEP'S GUARD — ONE APPLIED-REPAIR BIT, CONSULTED AT THE ASK AND SET AT THE REPAIR — AND ITS SCOPE IS
154
- /// THE SWEEP'S AND NOTHING ELSE'S** (`PIN-4` (i), (ii); `D-124` item 1; `D-125` item 4). It wraps a carried
155
- /// pair's own body and answers EXACTLY what that body answered, except in one state:
156
- ///
157
- /// * **THE SWEEP IS NOT THE ACT IN HAND** (`sweep.live !== true`) — **THE WRAPPER IS INERT**: the body is
158
- /// invoked, its answer is handed back AS THE BODY MADE IT, and **no bit is read, no member is read and no
159
- /// object is rebuilt.** **⟶ AND THIS IS THE STATE A PAIR IS LEFT IN WHEN THE CONSTRUCTION ANSWERS — THE
160
- /// GATE 4 DEFECT THIS CLAUSE CLOSES.** The wrapper the sweep installs is registered with the kernel and
161
- /// stored as the entry's element (`constraints.mjs`'s `carryConstraint`, `entry.fn = constraint`;
162
- /// `kernel-attempt.mjs`'s `pair.constraint`), so **it outlives the sweep by construction and cannot be
163
- /// un-installed by this frame**: re-registering the original body would ASK THE BODY AGAIN (and could land a
164
- /// second repair), which is a second act and not a restoration. **SO THE SCOPE IS THE DEVICE**: `sweep` is
165
- /// one object local to the construction, it is cleared the instant its last round ends, and from that byte on
166
- /// the wrapper is a transparent identity over the caller's body — **the pair's every later refusal keeps its
167
- /// `repair` and runs it**, which is what *"local to this construction and gone when it answers"* has to mean
168
- /// where the body it wraps cannot be swapped back.
169
- ///
170
- /// * **THE BIT IS UNSET** — the outcome crosses as the body made it, with its `repair` member wrapped by the one
171
- /// wrapper that SETS the bit when the kernel invokes it. **The bit is set at the INVOCATION and not at the
172
- /// credit**, which is the rule the act needs: a repair that ran and was then refused refuses the act, so no
173
- /// later instant can read the bit as a repair that stood.
174
- /// * **THE BIT IS SET AND THIS ASK IS A LATER ROUND'S (`suppress`)** — the pair would repair a SECOND time, and
175
- /// **the repair is NOT handed over**: the outcome crosses with its message and without its `repair`, so the
176
- /// kernel sees a violation with no repair registered, refuses the registration, and **no write of the second
177
- /// repair is ever performed** (`PIN-4` (i): *"A pair may land AT MOST ONE REPAIR in a construction"*). The
178
- /// `cycled` mark records that the refusal was a CYCLE, and the sweep converts it to rank `20`.
179
- /// * **THE BIT IS SET AND THIS ASK IS INSIDE THE SAME REGISTRATION CALL** (`suppress` false, which is the
180
- /// carry's own round) — the outcome crosses whole: **the re-run's cycle arm is the KERNEL's**
181
- /// (`kernel-registration.mjs`'s `CYCLE_ARM`), so the within-call cycle refuses at rank `20` from the frame
182
- /// that owns the attempt, and the shipped `KC` reading of every other refusing arm is unmoved.
183
- ///
184
- /// **AND A PAIR ASKED AGAIN THAT PASSES IS NOT A CYCLE** (`D-125` item 4: *"asking is not repairing"*): an outcome
185
- /// that is `true` carries no `repair` and crosses untouched, which is what makes an inconsistent result
186
- /// decidable at all.
187
- ///
188
- /// **⟶ AND THE TRANSFORM IS TAKEN ONLY WHERE THE KERNEL READS THE OUTCOME AS ITS MESSAGE ARM — THE GATE 4 DEFECT
189
- /// THIS CLAUSE CLOSES.** The kernel takes an outcome's `repair` ONLY where `message` is an OWN member
190
- /// (`kernel-registration.mjs`'s `Object.hasOwn(outcome, 'message')` guard; `kernel-attempt.mjs`'s three-arm read),
191
- /// and **every other object is the corpus's own `VA-11` arm — a value outside the three declared arms, read as the
192
- /// `{message}` arm and never as one of its own** (`PAR-C-5`). So a body that answers `{ repair }` and no `message`
193
- /// registers NO repair at any instant the shipped tree asks it. **THE REBUILT OUTCOME INVENTED THAT MEMBER**: it
194
- /// handed the kernel `{ message: undefined, repair }`, which is an OWN-message outcome carrying a repair, so **one
195
- /// body's one outcome read one way at a creation and the other way at `addConstraint` — the pair repaired at the
196
- /// creation and ran nothing at the registration, on the same bytes.** **THE FIX IS THE TEST THE KERNEL MAKES**: the
197
- /// own `message` is read FIRST, and where it is absent the outcome crosses UNTOUCHED — **no member the body did not
198
- /// return is added, no marker is set (a repair that is never handed over is never invoked), and the suppression
199
- /// below is reachable only on an outcome that carries a repair the kernel would actually run.** That is what makes
200
- /// the guard's own claim — *it answers EXACTLY what that body answered* — true at every instant.
201
- ///
202
- /// **NO MEMBER IS MINTED AND NO STATE IS MINTED BEYOND THE BIT**: the marker is a local row, the scope object is
203
- /// the construction's own, and **the outcome crossing the transforming arm carries EXACTLY the body's own `message`
204
- /// and its wrapped `repair` — the two members the kernel reads, and never a third it would have to ignore.**
205
- function sweepGuarded(body, marker, sweep, suppress) {
206
- return function sweepGuardedBody(context) {
207
- const outcome = body(context);
208
- // **THE SCOPE IS THE SWEEP'S: ONCE IT ANSWERS, THE CALLER'S BODY HAS THE INSTANT TO ITSELF** (the defect
209
- // closed at the head of this block).
210
- if (sweep.live !== true) return outcome;
211
- if (outcome === null || typeof outcome !== 'object') return outcome;
212
- // **THE KERNEL'S OWN ARM TEST, TAKEN HERE SO THE GUARD CANNOT WIDEN IT** (`VA-11`; see the clause above).
213
- if (Object.hasOwn(outcome, 'message') !== true) return outcome;
214
- const repair = ownValue(outcome, 'repair');
215
- if (typeof repair !== 'function') return outcome;
216
- if (suppress === true) {
217
- marker.cycled = true;
218
- return { message: ownValue(outcome, 'message') };
219
- }
220
- return {
221
- message: ownValue(outcome, 'message'),
222
- repair: function guardedRepair(record) {
223
- marker.applied = true;
224
- return repair(record);
225
- },
226
- };
227
- };
228
- }
229
-
230
- /// **WHETHER TWO ADDRESSES ARE THE SAME ADDRESS** — segment for segment, by value, with no join and no spelling.
231
- /// The creation's delivery groups the adopted elements BY ADDRESS (`PIN-6` (i)), so the grouping's equality is
232
- /// taken here once rather than re-derived per comparison.
233
- function sameSegments(first, second) {
234
- if (!Array.isArray(first) || !Array.isArray(second)) return false;
235
- if (first.length !== second.length) return false;
236
- for (let i = 0; i < first.length; i += 1) {
237
- if (first[i] !== second[i]) return false;
238
- }
239
- return true;
240
- }
241
-
242
- /// **AN ADDRESS'S OWN BARE SPELLING — segments joined by `/`, no quoting** — the `<SEGMENT>` slot the store's
243
- /// generator takes (`§8.2`, and `kernel-registration.mjs`'s `registrationRefusal` spells the same way). The
244
- /// generator quotes the subject it is handed, so a quoted spelling here would render `''a''`.
245
- function spellAddressBare(address) {
246
- let spelled = '';
247
- for (let i = 0; i < address.length; i += 1) {
248
- spelled += i === 0 ? String(address[i]) : `/${String(address[i])}`;
249
- }
250
- return spelled;
251
- }
252
-
253
- /// **WHETHER AN ADDRESS RESOLVES IN THE REGISTER** — `PIN-7`'s qualifier, read at the store's own `read`.
254
- ///
255
- /// **`AddressNotFound` IS THE ONE ABSENT ANSWER** (`PIN-7`: *"a listener whose watched address does not resolve
256
- /// is not fired, and that is not a refusal"*): every OTHER answer counts as present — a value, and the store's own
257
- /// `ReadTargetIsBranch` for an address a CONTAINER stands at, which is present and is exactly what `PIN-7`
258
- /// distinguishes from absent. **NOTHING IS MINTED, NO LOG ENTRY IS APPENDED AND NOTHING IS THROWN**; the read is
259
- /// the construction's own act and opens no commit.
260
- function registerHolds(state, address) {
261
- try {
262
- state.receiver.read(address);
263
- return true;
264
- } catch (refused) {
265
- return ownValue(refused, 'status') !== 'AddressNotFound';
266
- }
267
- }
268
-
269
- /// **A LISTENER BODY'S THROW AT A REGISTRATION INSTANT, REFUSED AT RANK `21` `ListenerBodyThrew`** (`PIN-10`;
270
- /// `D-124` item 2, the minted member). **THE SENTENCE IS THE STORE'S GENERATOR'S** (`§8.2`'s row for the member)
271
- /// **AND THE CLAUSE IS THIS PACKAGE'S**, appended as every boundary refusal appends one: **the body's own
272
- /// throwable is the caller's and is never rendered as this package's text.** **NO ROLLBACK COMPOSES AND NOTHING
273
- /// IS WITHDRAWN** (`PIN-10`: the delivery sits after the saves), and the member this refusal crosses with is the
274
- /// store's own closed set's — the package carries it and mints nothing (`DD-40`).
275
- function listenerBodyRefused(address) {
276
- boundaryReject(
277
- 'ListenerBodyThrew',
278
- spellAddressBare(address),
279
- 'the listener body threw at the registration instant, and the throwable it raised is its own and refuses the act instead of crossing as itself',
280
- 'listeners',
281
- );
282
- }
283
-
284
- /// **THE CREATION'S AND THE BOOT'S DELIVER — THE ADOPTED SET ∩ THE ADDRESSES THAT RESOLVE** (`PIN-6` (i), (iii),
285
- /// (iv); `PIN-2`; `D-123` item 2; `D-125` item 1).
286
- ///
287
- /// **ONE `deliver` CALL PER ADDRESS, IN CREATION ORDER, WITH THE RUNNING HANDLE LIST HELD ACROSS THE CALLS** — the
288
- /// reversal's own mechanism, spelled here as it stands at `constraints.mjs:3009`–`:3037` — so **an identity two
289
- /// addresses would fire fires ONCE, at the first address that names it** (`PIN-6` (iii); `surface.md §2.4` rule
290
- /// 3), and `deliver`'s own snapshot, dedupe and one-invocation rules are unmoved.
291
- ///
292
- /// **THE ONE ARGUMENT IS THE LISTENER'S OWN WATCHED ADDRESS** (`PIN-6` (iv); `Q-3`'s default) — the address the
293
- /// call is made for — and **an address that does not resolve is SILENT** (`PIN-7`): no invocation, no code, no log
294
- /// entry and no throw, with the construction returning its instance.
295
- ///
296
- /// **A FIRED BODY'S THROWABLE REFUSES THE CONSTRUCTION AT RANK `21`** (`PIN-10`; `D-124` item 2): the instance
297
- /// does not exist, **no rollback composes** (the saves the registrations' own closes made already stand —
298
- /// `PIN-12`), and the refusal crosses through `listenerBodyRefused` above. **AN EMPTY SET IS A COUNT OF ZERO AND
299
- /// NOT SILENCE** (`PIN-6` (v)): a construction that adopted nothing, or whose adopted addresses all fail to
300
- /// resolve, delivers nothing and answers its instance.
301
- function deliverAtTheCreation(state, adopted) {
302
- const delivered = [];
303
- for (let position = 0; position < adopted.length; position += 1) {
304
- const watched = adopted[position].address;
305
- let named = false;
306
- for (let earlier = 0; earlier < position; earlier += 1) {
307
- if (sameSegments(adopted[earlier].address, watched)) {
308
- named = true;
309
- break;
310
- }
311
- }
312
- // ONE CALL PER ADDRESS: the FIRST adopted element that watches it is the call's own position.
313
- if (named === true) continue;
314
- if (registerHolds(state, watched) !== true) continue;
315
- const owed = [];
316
- for (let each = position; each < adopted.length; each += 1) {
317
- if (sameSegments(adopted[each].address, watched) !== true) continue;
318
- const handle = adopted[each].handle;
319
- let seen = false;
320
- for (let matched = 0; matched < delivered.length; matched += 1) {
321
- if (delivered[matched] === handle) {
322
- seen = true;
323
- break;
324
- }
325
- }
326
- if (seen === true) continue;
327
- appendOwn(delivered, handle);
328
- // **THE ELEMENT `deliver` READS**: the identity it resolves and the watched address it is handed, and no
329
- // address of the store's own — a bare `{address, handle}` record, which is the store's own set's shape.
330
- appendOwn(owed, { address: watched, handle });
331
- }
332
- if (owed.length === 0) continue;
333
- try {
334
- deliver(state, owed, watched);
335
- } catch (thrown) {
336
- listenerBodyRefused(watched);
337
- }
338
- }
339
- return undefined;
340
- }
341
-
342
- /// `docs/specs/storeroom-js/surface.md §2.1`: `storeCreate(cfg)` takes ONE plain object carrying the store's FOUR declared keys, passes them
343
- /// through WITHOUT adding a default, a rename or a fifth key (`DD-36`) — **the as-filed *"THREE declared
344
- /// keys … a fourth key"* is read THROUGH this re-spelling, at `docs/specs/storeroom-js/surface.md §2.1`'s `cfg` block dated 2026-10-15 and its
345
- /// dated clause of 2026-10-16, and a CALLER-SUPPLIED key beyond the four is IGNORED, never refused
346
- /// (`contract.md §7.1`; `§8.1`'s complement)** — and **never returns a partial instance** — it throws the
347
- /// single failure form instead. **⟶ `docs/specs/storeroom-js/surface.md §2.1`'s dated clause (a), LANDED 2026-10-11
348
- /// BY THE `Q1` CONTRACT AMENDMENT, RE-DERIVES THE MEMBER FIGURE THIS SENTENCE CARRIED: *"the object it
349
- /// returns carries EXACTLY the one own member `surface.md §2.4` item 5 (a) declares, and not one member
350
- /// beside it"* STANDS BYTE-FOR-BYTE ABOVE AND IS READ THROUGH THIS CLAUSE — from this date the member set
351
- /// is `{ register, on, off }`, THREE OWN MEMBERS AND NOTHING ELSE — **⟶ AND THAT FIGURE IS RE-SPELLED IN PLACE, 2026-10-16 BY THE FILE-TIER-SAVE COMMENT PASS: *"THREE OWN MEMBERS"* IS THE 2026-10-11 FIGURE OF THE CLAUSE ABOVE AND NOT THE OPERATIVE ONE, WHICH IS `{ register, on, off, settle }`, FOUR OWN MEMBERS AND NOTHING ELSE** — the fourth being the `A116` ORDERING SEAM, the ONE member the KERNEL calls and the entry implements (`docs/decisions.md` `A116` (D1): the set *"opens by ONE clause"* to carry it; (D3): the lift is NARROW, so NO FIFTH member; its own home is `surface.md §2.4` item 9, and a CALLER's addressable sub-surface stays the three there declared), the count read at `surface.md §2.7` item 8 AS AMENDED (the as-filed `{register, on, off}` there is *"SUPERSEDED AS FIGURES"* and reads `{register, on, off, settle}`), at `§2.11` clause 7, and by the live battery's `FTS-12.1`, whose members are exactly those four. And `docs/specs/storeroom-js/surface.md §2.4` item 5 (a)'s *"one own
352
- /// member"* is superseded AS A MEMBER-SET FIGURE at its own `§` by the same amendment (`surface.md §2.11` clause 7: *"the instance's member set stays `{ register, on, off, settle }`"*).** **THE MODULE
353
- /// NAMESPACE IS UNMOVED at the eight declared verbs: neither new member is a named export, because both
354
- /// are reached through THIS factory's own product and through nothing else** (`surface.md §2.1`'s dated
355
- /// clauses (a)–(b); `A79`).
356
- export function storeCreate(cfg) {
357
- const addon_ = withAddon();
358
- // **⟶ THE CONSTRUCTION'S OWN READ OF THE CALLER'S `cfg` STANDS OUTSIDE THE BOUNDARY'S CATCH — CORRECTED
359
- // 2026-10-17 (`A64`'s one form read with `surface.md §2.5` item 5 (e); the ruling *"catch a throw from a
360
- // repair and encapsulate the message to distinguish forgeries"*).**
361
- //
362
- // **THE DEFECT IT CLOSES, NAMED AT ITS BYTES: the walk below READS THE CALLER'S OWN PROPERTIES — `cfg`'s
363
- // four declared keys by `Object.hasOwn` and by the member reads `encodeConfig` performs — so a `cfg`
364
- // carrying an own ACCESSOR is a caller's own body, and a `get` that THROWS is a CALLER'S OWN THROWABLE.
365
- // While this read stood INSIDE the `try`, that throwable reached `fail`, which constructs THE STORE'S
366
- // SINGLE FORM out of whatever it is handed: `storeCreate({ journalLength: 64, listeners: [],
367
- // get constraints() { throw { status: 'AddressMalformed', message: 'FORGED BY THE CALLER' } } })` answered
368
- // `{"status":"AddressMalformed","message":"FORGED BY THE CALLER"}` — A CALLER-CHOSEN STATUS CARRIED AS
369
- // THIS STORE'S OWN REFUSAL — a thrown `TypeError` answered `{status: undefined, message: '…'}`, a thrown
370
- // bare string lost its message entirely, and a thrown `undefined` or `null` made the read itself fault on
371
- // `refusal.status`. **THE DEFECT WAS NEVER *"a caller can forge a status"* BUT *"A CALLER'S OWN EXCEPTION
372
- // IS CAUGHT AND RE-SHAPED BY A PATH THAT ASSUMES IT IS THE STORE'S."**
373
- //
374
- // **THE FIX IS THE SCOPE AND NOT A NEW FORM: the walk that READS THE CALLER'S OWN VALUES stands outside
375
- // the catch, so the caller's own body's throwable PROPAGATES AS ITSELF — the same value, wearing no member
376
- // this unit minted and no status of the store's closed set — while `fail` is reached on this path by THE
377
- // ADDON'S OWN REFUSAL ALONE, which is the ONE provenance `docs/specs/storeroom-js/surface.md §2.5`'s two-member form belongs to.** **AND THE
378
- // CLAUSE THIS IMPLEMENTS IS `surface.md §2.5` ITEM 5 (e)'s OWN RULE CARRIED TO THIS SITE** — *"a rejection
379
- // is NEVER A RAW HOST ERROR — a `TypeError` … a string thrown, or any host object escaping from the
380
- // boundary's own frame is a FINDING at whatever site produced it, not a rejection"* — read with
381
- // `kernel-surface.md §2.3` item 1's body-throw clause, which fixes the SAME disposition for the two
382
- // caller-side functions this unit registers: **a caller's body's throwable is *"NOT a kernel state and NOT
383
- // a store state"* and reaches the caller UNCHANGED.** **NO CODE, NO MEMBER AND NO MESSAGE MOVES ON ANY ARM
384
- // THE CALLER'S `cfg` IS LAWFUL: where `encodeConfig` RETURNS, this function's boundary call, its catch and
385
- // `fail` are the bytes they were.**
386
- const encoded = encodeConfig(cfg);
387
- // ═════════════════════════════════════════════════════════════════════════════════════════════════════
388
- // **⟶ STEP 2 OF THE CONSTRUCTION'S ACT ORDER — THE BATCH'S MEMBER CHECKS, ADDED 2026-10-24 (`D-26`, `D-27`;
389
- // `docs/L1/surface-deltas.md` §3.1).** (`B-1` the function check, `B-2` the within-batch uniqueness check,
390
- // `B-3` the cross-kind check against the construction's adopted listeners, per element and ascending.)
391
- //
392
- // **WHERE IT SITS, AND WHY THE POSITION IS THE RULING'S AND NOT A PREFERENCE.** Every check **precedes any
393
- // filesystem act**, and **the construction's FIRST filesystem act is inside `addon_.storeCreate(encoded)`**
394
- // — `encodeFilePath` class-tests the value and the path probe is the store's. **So this is the last instant
395
- // at which a refusal can leave nothing behind**, which §10.4 part 5 requires (*"every construction that
396
- // fails leaves nothing behind"*), and a check placed in the arming loop below would refuse AFTER the
397
- // exclusive create had left the store's own zero-length file on disk.
398
- //
399
- // **AND IT IS WHY STEPS 5 AND 6 COMMUTE.** Under `D-22`/`D-24` the pair's home entry is created under the
400
- // caller's own `id`, and `listen`'s purge is total over the entries the handle names — so a batch `id` equal
401
- // to an adopted listener's `handle` would have made the order of step 5 and step 6 a correctness matter,
402
- // whichever ran second purging the first. **Step 2 removes the colliding state before either act runs, so
403
- // that order becomes unobservable and stays as filed** (`D-26`'s open question, answered by `D-27` as *"an
404
- // information dependency"* rather than as a sequence).
405
- //
406
- // **THE VALUE IT ANSWERS IS THE ADMITTED LIST — ONE ENTRY PER ELEMENT THE STORE WOULD ADMIT, CARRYING THE
407
- // FORWARDED `constraint` MEMBER — AND IT IS WHAT STEP 5 ARMS.** `D-26` item 3: *"the boundary carries the
408
- // PAIR and the package arms the SUBSTANCE"*; `D-27` item 1: *"Functions are armed"*.
409
- const batch = admittedConstraintBatch(cfg);
410
- // **⟶ AND STEP `2`'S SECOND WALK, BESIDE IT AND FOR THE SAME REASON — `PIN-8`, `PIN-9`, `D-123` item `2`,
411
- // 2026-11-06.** **A `cfg.listeners[]` ENTRY THAT CARRIES NO FUNCTION IS REFUSED HERE, BEFORE ANY FILESYSTEM
412
- // ACT** — so no file is ever created for it (`contract.md §10.4` part `5`) — in the form this position already
413
- // answers with (`AddressMalformed` naming `listeners`, `frame.mjs`'s own `boundaryReject`, and NO CODE IS
414
- // MINTED FOR IT). **THE VALUE IT ANSWERS IS THE ADOPTED LIST — ONE ENTRY PER ELEMENT THE STORE WOULD ADMIT,
415
- // CARRYING THE FORWARDED `listener` MEMBER — AND IT IS WHAT THE ARMING WALK BELOW ARMS**: the element's third
416
- // member never crosses (`frame.mjs`'s projection strips it) and **THE PACKAGE ARMS THE SUBSTANCE**, so the
417
- // adopted handle holds a body from the instant the instance exists.
418
- const adopted = admittedListenerBatch(cfg);
419
- let id;
420
- try {
421
- id = addon_.storeCreate(encoded);
422
- } catch (refusal) {
423
- // **`D-77`'s `null` ARM**: the construction's own refusal is about a `cfg`, an artefact or a store path
424
- // and never about an act at an address, so the member is present and names nothing.
425
- fail(refusal);
426
- }
427
- // **ONE HANDLE PER TOKEN PER INSTANCE**: the map is read in BOTH directions, so a token the store
428
- // returns twice (a lawful duplicate, `docs/specs/storeroom-js/surface.md §2.4` rule 3) reaches the caller as the SAME opaque value.
429
- // **THE PACKAGE'S OWN REGISTRY, ONE PER INSTANCE** (`surface.md §2.4`): the opaque handle -> the
430
- // caller's FUNCTION. **`unlisten` withdraws the store-side home entry and NEVER the function** (`docs/specs/storeroom-js/surface.md §2.4`
431
- // rule 4, `DD-15`), so `unlisten` removes no entry, and a re-registration of a handle REPLACES its entry
432
- // (rule 2, never a fan-out). **⟶ AND `off` — the ONE declared member that DOES remove an entry —
433
- // removes THE ONE THE HANDLE NAMES** (`docs/specs/storeroom-js/surface.md §2.4` item 7 (b); `DD-53`), while the instance's own state is
434
- // still released with the instance and by nothing else (`DD-17`; `A74`: `off` is not a release verb).
435
- // **⟶ AND `withheld` IS GONE WITH THE ADOPTION MACHINERY, 2026-10-18** (`docs/specs/storeroom-js/surface.md §2.4` item 9's
436
- // adoption-machinery clause, whose item `(i)` disposes of this very name: *"the WITHHOLD as a declared
437
- // STATE is WITHDRAWN WITH THE MEMBER THAT HELD IT"*). **NO WRITE-IN-FLIGHT SET, NO LEDGER AND NO DELIVERED
438
- // MARK STANDS ON THIS INSTANCE**: the kernel drives every write and its terminal arm is the delivery's one
439
- // instant, so the entry has nothing to withhold.
440
- // **`constraints` IS THE ENTRY'S OWN REGISTRY OF THE PAIRS IT CARRIES** (`surface.md §2.12` item 1's
441
- // preamble clause (a)–(b)): keyed by `(address, id)`, holding the pair's element and ITS address's own
442
- // spelling. **⟶ FROM 2026-10-18 IT IS A READ MODEL AND NOTHING MORE** (`docs/specs/storeroom-js/surface.md §2.12` item 1's amended clause
443
- // (iii)): the write path reads the STORE'S OWN `triggered` set and the KERNEL'S registry, and **NO
444
- // WRITE-PATH BRANCH OF THIS FILE IS TAKEN ON THIS MAP'S CONTENTS** — its one reader is `a.constraints()`.
445
- // **IT IS POPULATED BY THE ONE ACT BOTH ROUTES REACH AND BY NOTHING ELSE** (`carryConstraint` below), and
446
- // **`leg` IS THE SLOT THE NESTED FOUR-POSITION CALL THE KERNEL'S STORE LEG MAKES LEAVES ITS OWN RETURNED
447
- // RECORD IN**, so that a kernel-driven write answers the record its own write returned rather than a copy
448
- // of it (`docs/specs/storeroom-js/surface.md §2.12` item 1's stage 2).
449
- //
450
- // **⟶ AND THE ADOPTION MACHINERY IS REMOVED WHOLE, 2026-10-18** (`docs/specs/storeroom-js/surface.md §2.4` item 9's adoption-machinery
451
- // clause, the three architect's rulings of that date): **`withheld`, `adopted`, `answered` and `delivered`
452
- // are GONE WITH `settle`**, because they existed only to marshal ONE delivery BETWEEN TWO ACTORS — a
453
- // caller who made a bare write and a kernel which drove the other. **RULINGS `(2)` AND `(3)` LEAVE ONE
454
- // ACTOR**: the kernel drives every write, so there is nothing to marshal and the machinery has no state to
455
- // hold. **THIS IS WHERE THE DOWNSTREAM `DEF-D` DEFECT LIVED** — an abandoned adoption consumed by the next
456
- // unrelated write — and its SUBSTRATE, not its symptom, is what this removal takes.
457
- // **⟶ `state.tokens` IS DELETED AND `state.registry` TAKES THE ONE MAP'S SHAPE — `U-STOREROOM-HELD-LISTENER-IDENTITY`.**
458
- // **THE ONE MAP IS `Map<handle, {fn, off}>`, KEYED BY THE HANDLE STRING** (`identity-and-domain.md §4` item
459
- // 5; `P: docs/pending.md · P-6`, fork (d): *"the map becomes `Map<handle, {fn, off}>`, keyed by the identity
460
- // the addon also holds"*; `P: docs/pending.md · (AD-1)`: the value record is `{ fn, off }` *"and nothing
461
- // else. There is no `token` property"*). **`state.home` SURVIVES AS THE MIRROR** — its column is now the
462
- // CALLER'S OWN HANDLE and not a token (`identity-and-domain.md §1` item 2 (ii)) — **and `state.constraints`
463
- // stays the read model.**
464
- // **⟶ AND `establishing` IS DELETED 2026-11-01 (`D-99`'s ANSWERED clause; `C-18`, §9.3), SO THIS MEMBER'S
465
- // OWN SEVEN-OCCURRENCE CENSUS CLOSES AT ZERO.** The clause that stood here declared a marker — *"the `id` of
466
- // the pair the kernel is right now registering, and nothing else"* — and named its purpose as *"how `B-6`'s
467
- // cross-kind test still knows the act is a CONSTRAINT's own registration and not a listener's"*. **BOTH
468
- // SENTENCES ARE WITHDRAWN, AND THEY STAND AS TEXT READ THROUGH THIS ONE:** the act that needed the exemption
469
- // **does not pass the test at all** any more, because the kernel's registration reaches the store through its
470
- // OWN ROUTE (`LISTEN_ROUTE`, `delivery.mjs`'s `listenOn`) and the cross-kind test lives on the CALLER's
471
- // members and nowhere else. **SO: NO MARKER LANDS, NO BRACKET LANDS AT ANY OF THE FOUR SITES, AND `Q-1`'S
472
- // RESIDUAL (`docs/L1/cross-kind-handle-only.md` §7) DISAPPEARS WITH THE MARKER RATHER THAN BEING ACCEPTED OR
473
- // TIGHTENED** — a constraint body that calls `listen('<its own pair id>', …)` during its own registration is
474
- // now refused at `B-6` exactly as any caller's act is.
475
- const state = {
476
- home: [], registry: new Map(), constraints: new Map(), leg: null, receiver: null,
477
- // **⟶ AND THE RESIDUE'S DELIVERER, ADDED 2026-10-29 — A PRIVATE FACT ABOUT WHICH ACT OWNS A LEG'S
478
- // DELIVERY.** The terminal arm performs `surface.md §2.7` item 7's delivery for a kernel-driven WRITE
479
- // (`delivery.mjs`'s `terminalArm`), and it is the delete's OWN member that performs it (`D-49` declared that
480
- // delivery the window whose check never ran, and this build does not move it). **IT IS A VALUE OF THE
481
- // PACKAGE'S OWN STATE AND NOT A MEMBER OF ANY RECORD** (`surface.md §2.1` (e) item 1: a record, a commit
482
- // and a Map are never own members of the product): `'arm'` on every path that does not say otherwise, and
483
- // `'member'` for the instant a `delete` stands in, restored in the same `finally` as the leg itself.
484
- legDelivery: 'arm',
485
- // **⟶ AND THE TWO VALUES THE REGISTRATION INSTANTS' DELIVERY OWES — `D-125` ITEM `1`, 2026-11-06.**
486
- // **`registrationDelivery` SAYS WHICH SET THE INSTANT IN HAND DELIVERS**: `'adopted'` for the construction
487
- // and a boot — `PIN-6` (i)'s adopted ∩ existing, delivered by `storeCreate`'s own seat below — and
488
- // `'triggered'` for `addConstraint` and a re-arm, where `PIN-6` (ii) makes the set *"THE STORE'S OWN
489
- // `triggered`"* and `delivery.mjs`'s registration-delivery channel delivers it from the registration's own
490
- // passing close. **A VALUE OF THE PACKAGE'S OWN STATE AND NOT A MEMBER OF ANY RECORD**, exactly as
491
- // `legDelivery` above is.
492
- registrationDelivery: 'adopted',
493
- // **AND THE SLOT A FIRED BODY'S THROWABLE WAITS IN** (`PIN-10`, `Q-13`): the channel catches it rather than
494
- // raising it through the kernel's frames, and the ACT that called the registration converts it into rank
495
- // `21` `ListenerBodyThrew` before it answers. `null` on every arm that delivered cleanly.
496
- listenerFailure: null,
497
- };
498
- // **⟶ THE RECEIVER IS THE STORE OBJECT ITSELF, AND THE INTEGER THE PACKAGE USED TO HAND ACROSS IS NOT
499
- // HANDED AT ALL** (`receiver-and-refusal.md §1`; `js-unwrap.md §4`). The addon resolves its store from the
500
- // receiver, reading the index the package published as the object's own NON-ENUMERABLE row (`STORE_INDEX`
501
- // below) — so **`state.id` HAS NO SITE LEFT IN THIS FILE**, and the object IS the carrier.
502
- //
503
- // **AND THE ARGUMENT THAT USED TO BE THE INTEGER IS NOT REPLACED BY A DIFFERENT ONE ON A DIFFERENT
504
- // CHANNEL:** the addon's per-verb entries read the store from position `0` of the call array, and position
505
- // `0` is this object. **NO ENTRY CARRIES A LEADING INSTANCE POSITION** (`export-set-and-dispatch.md §4`).
506
- const instance = {
507
- /// **`surface.md §2.4` item 9 (f)'s clause of 2026-10-18 — THE PRODUCT'S DECLARED MEMBER SET IS FIFTEEN
508
- /// OWN MEMBERS, `10 + 1 + 1 + 2 + 1 = 15` ✓: THE TEN METHODS, `register`, `constraints`, THE TWO REMOVAL MEMBERS AND `readTiered`.** **`settle` IS
509
- /// REMOVED WHOLE** (`REMOVED-WHOLE`, item 9's pointer of that date): the member set moved `13 → 12`, and
510
- /// **THE TWO REMAINING SINGLES ARE NAMED** because *"a lone `+1` would not compute"* — the first `1` is
511
- /// `register` and the second is `constraints`, the registered-constraint read. Each is reached through
512
- /// THIS factory's own product alone (`package.md §1.3` item 3): the module namespace carries ONE name,
513
- /// `storeCreate` (`docs/specs/storeroom-js/surface.md §2.9` item 1's `A127` clause; `11 → 1` ✓, and *"a deprecation window"* is declared
514
- /// away at that clause on `A128`'s fiat), so NO member below is a named export and the ten
515
- /// store-reaching names have no second spelling at any layer.
516
- /// **THE STATE STAYS PRIVATE** (`docs/specs/storeroom-js/surface.md §2.1` (e) item 1): `state` below is this factory's own closure and is
517
- /// keyed in `INSTANCES` — NO own member is store data, a record, a Map, a Set, a tier, an address, a
518
- /// handle or a commit, and the fifteen members above are the whole of what a caller sees. **⟶ CORRECTED 2026-11-06: this clause printed `twelve`, `10 + 1 + 1 = 12`, and was stale twice over at that print — the held-listener-identity unit's `12 → 14` move of 2026-10-19 added `removeListener` and `removeConstraint`, and `U-STOREROOM-TIER-READOUT`'s `readTiered` takes the set `14 → 15`; the operative figures are `index.d.ts`'s `StoreInstance` and `surface.md §2.4` item 9 (f), and NO CODE LINE MOVES WITH THIS CORRECTION.**
519
- /// **`on` AND `off` ARE MERGED AWAY AND ARE NOT MEMBERS** (`A127`): the listener registration route is
520
- /// `listen` + `register` and its withdrawal is `unlisten`, exactly as the seven store-reaching methods
521
- /// and `register` below spell them.
522
- // ⟶ MOVED 2026-10-18 (`RCA-8(g)`, gate-4 finding F-1): the `A127` region header stood here, above the free-function list `P-8` deleted, and its second half — the call-arity sentence that named the receiver's argument count `n`, and the arity-fold sentence that read the `n`-as-written folds against that count minus one — is falsified by that merge: no such `n` binding exists on this object and no function stands below. Bytes: archive/p8-merge/2026-10-18/post-gate4/region-header-live.md (pre-move copy: archive/p8-merge/2026-10-18/blocks/region-header.md). The `A127` rule it stated stands at this factory's own member doc above.
523
- /** `docs/specs/storeroom-js/surface.md §2.2`: `read` — a leaf's literal, a branch's assembled value, the empty address's whole register. */
524
- read(address, tier) {
525
- // A position the call supplied no value for is handed as the runtime's own `undefined` — NEVER as an
526
- // absent array slot — so the facade can tell an unsupplied position from a supplied `undefined` and the
527
- // core is never reached with a null pointer (`crossing.md §1.3`'s absent-versus-`undefined` rule).
528
- const args = arguments.length >= 1 ? [encodeAddress(address, undefined, 'first argument')] : [];
529
- // `PAR-JS-6`: a SUPPLIED `undefined` at this position is PRESENT and takes the row's own
530
- // `AddressMalformed`; the NO-ARGUMENT call is the one that folds to the ABSENT row.
531
- // **⟶ AND THE ARGUMENT LIST IS EXTENDED BY INDEX, NOT BY `Array.prototype.push`** (`contract.md §2.1`'s
532
- // clause of 2026-10-24 on `F7-1`, item `(1b)`, and the battery's row `(g)`): the as-built `args.push`
533
- // was a member of a MUTABLE PROTOTYPE read by every verb, and a caller's `push` answering `0` without
534
- // copying EMPTIED the carrier list before any verb was reached — so an admitted write answered
535
- // `AddressMalformed: 'tier' requires a tier argument`. **⟶ AND THE APPEND IS AN OWN-PROPERTY DEFINE AND
536
- // NOT AN INDEX WRITE, 2026-10-25:** `args[args.length] = …` performs `[[Set]]`, which WALKS THE CHAIN, so
537
- // a caller's getter-only accessor at `Array.prototype[0]` turned this lawful verb's first append into a raw
538
- // host `TypeError` (`F8-2`'s write vector). `appendOwn` (`src/entry/refusal.mjs`) defines the own property.
539
- appendOwn(args, encodeTier(tier, arguments.length >= 2, false, 'first argument'));
540
- // **⟶ AND THE ENTRY IS INVOKED BY `Reflect.apply`, NEVER BY AN ARGUMENT SPREAD** (`contract.md §2.1`'s
541
- // clause of 2026-10-24 on `F8-1` and `F8-2`, items `(1b)`, `(1c)` and `(1d)`'s boundary; the cells
542
- // `JC-TC-64`, `JC-TC-65` and `JC-TC-66`): `…args` reads the local list through
543
- // `Array.prototype[Symbol.iterator]` BEFORE any verb is reached, so a forged iterator handed `undefined`
544
- // at every position and an admitted `write` was refused `AddressMalformed` (*"'tier' requires a tier
545
- // argument"*) — the argument list was the caller's answer. **`Reflect.apply` reads the list BY INDEX**
546
- // (`CreateListFromArrayLike`: the array's own `length` and its own indices), which is item `(1c)(v)`'s own
547
- // form, and `Reflect` is a GLOBAL BINDING whose `apply` is its own DATA property — not a prototype member,
548
- // which is exactly where item `(1d)`'s boundary stops a sweep. No position, no arity fold and no
549
- // absent-versus-`undefined` answer moves: the entry receives the same list it always received.
550
- return decodeValue(carryRefusal(() => Reflect.apply(entryOf().read, this, args), args));
551
- },
552
- /** `docs/specs/storeroom-js/surface.md §2.2` / `docs/specs/storeroom-js/surface.md §2.9` item 2: `readLiteral` narrows the read to a leaf and answers `ReadTargetIsBranch`. */
553
- readLiteral(address, tier) {
554
- const args = arguments.length >= 1 ? [encodeAddress(address, undefined, 'first argument')] : [];
555
- appendOwn(args, encodeTier(tier, arguments.length >= 2, false, 'first argument'));
556
- // THE ENTRY IS INVOKED BY `Reflect.apply`, NOT BY A SPREAD — see `read`'s clause of 2026-10-24 above.
557
- return decodeValue(carryRefusal(() => Reflect.apply(entryOf().readLiteral, this, args), args));
558
- },
559
- /** **`D-121-ter` item 5: `readTiered` — `read`'s OWN ARITY AND DECLARED WALK AND REFUSAL SET, WITH THE ANSWER COMPILED** (`U-STOREROOM-TIER-READOUT`, 2026-11-06; `contract.md`'s `PIN-2`). A MEMBER and NEVER a module export: the namespace stays ONE name, `storeCreate` (`PIN-2` (iv)). Its three devices are `read`'s own — the address encoded at the first position, the tier appended by `appendOwn` on the caller's own `arguments.length`, and the entry invoked by `Reflect.apply` — and no byte of `read` or `readLiteral` moves. */
560
- readTiered(address, tier) {
561
- // The FIRST device is `read`'s, verb for verb: a position the call supplied no value for is handed as
562
- // the runtime's own `undefined` — NEVER an absent array slot — and a SUPPLIED `undefined` at the tier
563
- // position is PRESENT and takes the row's own `AddressMalformed` (`crossing.md §1.3`; `PAR-JS-6`).
564
- const args = arguments.length >= 1 ? [encodeAddress(address, undefined, 'first argument')] : [];
565
- // The SECOND device is `read`'s too: the append is an own-property define and not an index write, so a
566
- // caller's getter on `Array.prototype` cannot turn the append into a raw host `TypeError` (`appendOwn`;
567
- // `F8-2`'s write vector).
568
- appendOwn(args, encodeTier(tier, arguments.length >= 2, false, 'first argument'));
569
- // THE THIRD DEVICE: the entry is invoked by `Reflect.apply`, never by an argument spread, so a forged
570
- // iterator cannot hand the entry a different list (`F8-1`/`F8-2`; see `read`'s clause).
571
- return decodeValue(carryRefusal(() => Reflect.apply(entryOf().readTiered, this, args), args));
572
- },
573
- write(address, tier, value, commit) {
574
- // **⟶ THE RECEIVER IS CHECKED HERE, BEFORE EITHER ROUTE IS CHOSEN — `write` IS THE ONE MEMBER WITH TWO
575
- // OF THEM.** Its three-position call reaches the STORE through the KERNEL (`constraintWrite`) rather
576
- // than through its own entry, so **a receiver check taken only at the entry would leave the kernel route
577
- // open to a DETACHED call — and a detached `write` that ANSWERS is exactly `receiver-and-refusal.md §7`'s
578
- // named regression read backwards** (*"`const { read } = layout; read(…)` IS LEGAL TODAY AND THROWS
579
- // AFTER THIS CHANGE"*), and `P-SAS-4`'s failure list names *"a success"* as its third term. **THE CHECK
580
- // IS `§3`'s ONE ARM AND ASKS ONLY WHETHER THE CALL SUPPLIED THE STORE OBJECT AS ITS RECEIVER**: the
581
- // kernel route is the package's own and still needs the same object, so the route is chosen only after
582
- // the receiver is known to be one. **NO TOKEN IS MINTED AND NO SECOND FORM IS BUILT** — the entry's own
583
- // refusal is what answers, reached by handing the receiver on.
584
- if (!isStoreReceiver(this)) return decodeValue(carryRefusal(() => entryOf().write.call(this), []));
585
- // **⟶ `§4.1`: `write` OPENS ONE — UNLESS THE CALL NAMES A COMMIT AT THIS METHOD'S FOURTH POSITION, WHICH
586
- // IS THE DISCRIMINATOR `D-46` SETS: A CALL THAT SUPPLIES IT JOINS THE COMMIT IT NAMES, AND A CALL THAT
587
- // SUPPLIES NONE OPENS A NEW ONE** (`strata/decisions.md` · `D-46`). **THE POSITION IS READ HERE AND
588
- // NOWHERE ELSE**, because this member is the one place a call's own entry names a commit: the kernel's
589
- // store leg is a FOUR-position call (`store.write(address, tier, value, record)`, `kernel-commit.mjs`) and
590
- // therefore JOINS the commit the caller's three-position write opened, while a caller's plain write, a
591
- // listener body's write and a constraint body's write all supply three positions and OPEN — the listener's
592
- // being `D-43` item `1`'s *"its own commit"*, reached by declaration rather than by an authorship the
593
- // package used to infer. **A SUPPLIED POSITION NAMES A COMMIT WHETHER OR NOT IT IS IN THE POSITION'S CLASS
594
- // DOMAIN**: the class test below refuses an outside value before any store act, and a refused write
595
- // releases the bracket in the `finally` below like every other arm.
596
- // **THE DECREMENT IS ON THE FINAL RETURN TO THE CLIENT** (`closeCommit`), taken in a `finally` so the
597
- // bracket is released on every arm — a count left standing after a return is on `§5`'s failure list.
598
- const opened = openCommit(instance, arguments.length >= 4 ? commit : undefined);
599
- try {
600
- // **⟶ `docs/specs/storeroom-js/surface.md §2.12` ITEM 1, STAGE 1, AMENDED 2026-10-18 — THE ENTRY→KERNEL EDGE IS UNCONDITIONAL: EVERY
601
- // FOUR-POSITION WRITE ENTERS THE KERNEL'S `K-2`, AND THE `carriesConstraintAt` GATE THIS VERB ONCE TOOK
602
- // BEFORE THE CALL IS REMOVED.** The architect's ruling, verbatim: *"Always route to the kernel, because the
603
- // JS code does not decide whether constraints trigger."* — and its sibling, *"The kernel is always
604
- // supposed to be in the middle. Any occasion where the write path is not governed by the kernel is a
605
- // hallucination."* **SO THE JS DECIDES NOTHING ABOUT WHETHER A CONSTRAINT TRIGGERS**: the STORE'S OWN
606
- // `triggered` SET and the KERNEL'S OWN PAIR-KEYED REGISTRY are the trigger authority (`docs/specs/storeroom-js/surface.md §2.12` item 1's
607
- // amended clause (iii)), and `state.constraints` is a READ MODEL for `a.constraints()` and for nothing on
608
- // this path. **AN INSTANCE THAT CARRIES NO PAIR AT THIS ADDRESS STILL ENTERS THE KERNEL**: the pass over an
609
- // address with no registered pair evaluates NOTHING and PASSES, and the write proceeds to the terminal arm's
610
- // delivery exactly as `docs/specs/storeroom-js/surface.md §2.7` items 6–7 declare (amended clause (ii)).
611
- //
612
- // **AND THE FIVE-POSITION CALL IS THE KERNEL'S OWN STORE LEG AND NEVER ENTERS `K-2`** — item 1's stage `4`
613
- // no-recursion clause, which this edit leaves UNMOVED: *"a five-position call can never start a second pass
614
- // — and the call that carries an ADOPTED identity is item 3's own, so there is no recursion and need not be
615
- // one"*. **THAT EXCLUSION IS THE CLAUSE'S AND NOT THIS TEST'S**: the gate removed above was an
616
- // ADDRESS-CARRYING test, and the position test below is the one stage `4` declares. `K-2` calls this very
617
- // `write` with FOUR positions (`src/constraint-kernel.mjs`'s `store.write(address, tier, value, record)` is
618
- // the method's own four, the `instance` receiver not being a position of it), so the kernel's leg reaches
619
- // `constraintWrite` NOT AT ALL: it reaches the store verb through the `n <= 3` arm below, and the recursion
620
- // stage `4` forbids is unreachable BY POSITION and not by a registry's contents.
621
- //
622
- // **⟶ AND THE FIFTH POSITION'S CLASS TEST IS TAKEN HERE, BEFORE THE ROUTE IS CHOSEN, BECAUSE IT IS THE
623
- // POSITION'S AND NOT THE ROUTE'S** (`docs/specs/storeroom-js/surface.md §2.4` item 9 (g) item 1; `§2.20`'s answer cell): **a SUPPLIED COMMIT
624
- // THAT IS NOT A RECORD POSITION IS REFUSED ON BOTH PATHS THE SAME WAY** — the routing amendment removed an
625
- // ADDRESS-CARRYING gate and touches no class test, and a drive that supplied an invalid commit to a
626
- // no-pair instance asserted the refusal before this date and asserts it after (`a127`'s two
627
- // fifth-position cells). **THE REFUSAL LEAVES NO LANDING AND NO ADOPTION TO RELEASE**: nothing is opened
628
- // and nothing is put in flight, which is the whole of what the machinery's release used to secure.
629
- if (arguments.length >= 4) {
630
- const refusal = commitPositionRefusal(commit);
631
- if (refusal !== null) throw refusal;
632
- }
633
- // **⟶ AND THE BOUNDARY'S OWN WALK IS TAKEN BEFORE THE ROUTE IS CHOSEN, WHICH IS THE ONE THING THE ROUTING
634
- // AMENDMENT MOVES OUT OF THE ORDER IT STOOD IN** (`§2.5` item 5 (a)–(c); `docs/specs/storeroom-js/surface.md §2.2` clause 3). **THE ENTRY'S OWN
635
- // POSITIONS ARE ENCODED HERE, ONCE, FOR BOTH PATHS**: the four-position call enters the kernel with values
636
- // THIS BOUNDARY HAS ALREADY ADMITTED, so an outside address still answers the store's `AddressMalformed`
637
- // with the FAILING TARGET and the ARGUMENT POSITION in it (`§2.5` item 5 (a)–(b); `convenience.test.mjs`'s
638
- // `AddressArg` rows drive exactly this), **and a route to the kernel can never be a route AROUND the
639
- // boundary's own class tests.** **NOTHING IS DECIDED TWICE: the encoders are total over the positions and
640
- // their answers are the store's own, so the kernel receives the same values the bare path always built.**
641
- // ⟶ `subject` is `contract.md §2.1`'s clause of 2026-10-24, item `(2)`'s slot: `null` means "render the
642
- // failing target" and any string means "the arm declared its own PART ONE subject" (`DEF-2026-10-24-D`).
643
- const fault = { found: null, value: undefined, path: [], subject: null, nodes: 0 };
644
- const args = arguments.length >= 1 ? [encodeAddress(address, undefined, 'first argument')] : [];
645
- // `PAR-JS-7`: `write`'s tier is REQUIRED — an ABSENT position and a SUPPLIED `undefined` both answer
646
- // `AddressMalformed`, and neither folds.
647
- appendOwn(args, encodeTier(tier, arguments.length >= 2, false, 'first argument'));
648
- // THE WALK'S OWN FAULT RECORD — see `refusedValue`: the walk CLASSIFIES and RECORDS, and the record is
649
- // read at the one site where the store answered `ValueNotAdmitted` for a value the walk refused.
650
- // **⟶ AND THIS EXTENSION IS THE SAME INDEX WRITE** (`F7-1`, item `(1b)`): a no-op `push` dropped the
651
- // VALUE position too, so the admitted drive lost its crossed member and not merely its tier.
652
- appendOwn(args, encodeValue(value, [], 0, [], fault));
653
- // **THE VALUE REFUSAL IS ANSWERED BEFORE ANY VERB** (`parameter-semantics.md §3`): the carrier positions
654
- // above have already answered in their own order, so this keeps `write(undefined, 'mem', null)` on the
655
- // carrier row and never lets a refused tree reach the store.
656
- if (fault.found !== null) valueReject(fault);
657
- if (arguments.length <= 3) {
658
- return constraintWrite(state, instance, address, tier, value);
659
- }
660
- let answer;
661
- try {
662
- // **`write`'S OWN ENTRY, CALLED DIRECTLY BY ITS OWN NAME** (`js-unwrap.md §5`) — the `writeCall`
663
- // wrapper that stood here is deleted (`§1`), **and its `ValueNotAdmitted` re-render moves into this
664
- // member's own body** (`§3`), which is where `P-SAS-8` drives it. **THE FIVE POSITIONS ARE THE VERB'S
665
- // OWN AND THE FIRST ARGUMENT IS THE STORE OBJECT THE PACKAGE RETURNED** (`receiver-and-refusal.md
666
- // §1`): no instance position stands among them (`export-set-and-dispatch.md §4`).
667
- // **THE ENTRY'S OWN POSITIONS ARE THE ENCODED ARRAY BUILT ABOVE, APPLIED BY INDEX** — the SAME values
668
- // both routes carry, so the entry receives exactly what the kernel leg receives and **nothing is
669
- // decided twice** (`§2.5` item 5 (a)-(c)). **A POSITION THE CALL DID NOT SUPPLY IS HANDED AS THE
670
- // RUNTIME'S OWN `undefined`**, which is this boundary's declared protocol for a short call. **AND THE
671
- // LIST IS APPLIED AND NOT SPREAD** (`Reflect.apply` — see the `read` member's clause of 2026-10-24):
672
- // a spread consumes the encoded array through `Array.prototype[Symbol.iterator]` BEFORE the store is
673
- // ever reached, so a forged iterator dropped the tier and refused an admitted write.
674
- answer = Reflect.apply(entryOf().write, this, args);
675
- } catch (refusal) {
676
- // **⟶ AND THE RELEASE AN ABANDONED ADOPTION ONCE NEEDED IS GONE WITH THE MACHINERY, 2026-10-18.** The
677
- // catch this replaces released *"the adoption it was taken for"* — an identity `settle` had put in
678
- // flight and this write then failed to claim. **WITH `settle` REMOVED THERE IS NO ADOPTION TO RELEASE**
679
- // (`docs/specs/storeroom-js/surface.md §2.4` item 9's adoption-machinery clause; the three architect's rulings of that date), so the store's
680
- // own refusal crosses back UNCHANGED AND UNCONVERTED and this frame adds nothing to it.
681
- // **AND THE ONE DECLARED EXCEPTION IS TAKEN HERE** — the `writeCall` arm, moved not dropped.
682
- // **⟶ AND THE COMMIT'S OWN LOG TRAVELS WITH IT — `D-53`, 2026-10-28.** The record at the method's FOURTH
683
- // position is the commit's record when the kernel's own store leg made this call, and the kernel defines
684
- // the commit's list on it under a symbol key; **so a store verb refusing this write tells the caller what
685
- // the commit's log already carries** instead of the declared `[]`. A caller's own five-position write (or
686
- // any record this package did not build) carries no such key and answers `undefined`, which is `fail`'s
687
- // declared `[]` arm — unchanged on every one of those paths.
688
- // **AND THE WRITE'S OWN ADDRESS IS THE FOURTH MEMBER'S SUBJECT — `D-77`.** A store verb refusing this
689
- // write is the act at the address the caller spelled, carried in the caller's own domain.
690
- writeRefusal(refusal, fault, arguments.length >= 4 ? commit : undefined, address);
691
- throw refusal;
692
- }
693
- const watched = [];
694
- // **⟶ AND THE WATCH SET IS DECODED BY INDEX, NOT BY `.map`** (`contract.md §1`'s clause of 2026-10-24 on
695
- // `F-RA-3`, item `(3)`; and `§2.5` item 5 (e), a rejection is never a raw host error): a caller-side
696
- // `delete Array.prototype.map` reached this read through the reply array's own chain and threw a raw
697
- // `TypeError` out of a write the walk had ADMITTED.
698
- // **⟶ AND THE APPEND IS AN INDEX WRITE, NOT `Array.prototype.push`** (`contract.md §2.1`'s clause of
699
- // 2026-10-24 on `F8-1`, items `(1c)(i)` and `(2b)`'s row `57`; arm `(xviii)`, cell `JC-TC-64`): the loop
700
- // enclosing it was already the lawful form and the append was not, so a no-op `push` silently emptied
701
- // the record's watch set while the write itself stayed admitted and durable.
702
- for (let i = 0; i < answer.watched.length; i += 1) {
703
- appendOwn(watched, decodeSegments(answer.watched[i]));
704
- }
705
- const record = {
706
- op: decodeJournalOp(answer.op),
707
- watched,
708
- triggered: crossTriggered(state, answer.triggered),
709
- };
710
- // **AND THE RECORD IS LEFT IN THE SLOT THE KERNEL'S STORE LEG READS** (`state.leg`; `docs/specs/storeroom-js/surface.md §2.12` item 1's
711
- // stage 2): a kernel-driven write takes the record THIS VERY WRITE returned and not a copy of it, and the
712
- // slot is read before the pass that may write again, so a repair's own write can never be mistaken for it.
713
- state.leg = record;
714
- // **⟶ AND THE SAME RECORD'S RETURNED ELEMENTS ARE HANDED TO THE INVOCATION'S OWN LEG LIST — `D-104`,
715
- // 2026-11-01** (`docs/L1/repair-listener-delivery.md` §3.2, §8's `js-surface` row;
716
- // `strata/decisions.md` · `D-104` item `3`'s mechanism `(a)`). **THE LEG SLOT IS UNTOUCHED**: its four
717
- // readers — `delivery.mjs`'s `answer`, the save's gate and the triggering address, and `constraints.mjs`'s
718
- // `answer` — take no byte, and this line adds no fifth. **AND THE HAND-OVER IS TAKEN AT THIS SEAT ONLY,
719
- // INSIDE THE `n >= 4` ARM AND NEVER AT THE `n <= 3` ROUTE**: the kernel's store leg is this arm, so a
720
- // repair's write and a CONSTRAINT body's write are told apart by the KERNEL and not here (§3.1 fact 3) —
721
- // each appends to the leg list of the invocation it was made inside, and the kernel's repair arm is what
722
- // reads the latter and not the former. **WITH NO INVOCATION BRACKET STANDING THE APPEND GOES NOWHERE**
723
- // (`state.mjs`'s `appendRepairLeg`), which is a caller's own write and a direct `K-2` drive's store leg.
724
- appendRepairLeg(record);
725
- // **THE INVOCATION WINDOW** (`docs/specs/storeroom-js/surface.md §2.7` item 2, `DD-22`): the record above is COMPLETE before the window
726
- // opens, the invocation is SYNCHRONOUS, it happens AFTER the addon's call returned, and **its ONE
727
- // argument is the TRIGGERING ADDRESS** (`PAR-JS-12`).
728
- //
729
- // **⟶ AND THE DELIVERY DOES NOT HAPPEN IN THIS FRAME FOR A KERNEL-DRIVEN WRITE, 2026-10-18 — IT HAPPENS AT
730
- // THE KERNEL'S TERMINAL ARM, WHICH IS `docs/specs/storeroom-js/surface.md §2.7` ITEM `7`'s ONE HOME** (`§2.4` item 9's adoption-machinery
731
- // clause; `docs/specs/storeroom-js/surface.md §2.7`'s clause of that date, item `3`: *"so the entry stops DECIDING whether to honour a
732
- // delivery and SIMPLY PERFORMS THE ONE THE KERNEL TRIGGERS"*).
733
- //
734
- // **THE RULE IS THE WINDOW'S AND NOT A FLAG'S:** every write this file performs is now KERNEL-DRIVEN
735
- // (`docs/specs/storeroom-js/surface.md §2.12` item 1's amended stage `1`), and the kernel reaches this verb as ITS OWN STORE LEG — the
736
- // `n >= 4` arm above, whose `commit` is the kernel's own record. **SO THIS FRAME IS THE LEG AND ITS DELIVERY
737
- // IS WITHHELD BY THE DECLARED INSTANT AND NOT BY A WITHHOLD SET**: `docs/specs/storeroom-js/surface.md §2.7` item 7 declares that for a record
738
- // carrying a kernel evaluation set the package's delivery *"does NOT occur inside the store verb's window:
739
- // it follows the pass"*. **THE LEG THEREFORE INVOKES NOTHING, AND `terminalArm` PERFORMS THE ONE DELIVERY
740
- // THE KERNEL TRIGGERS** — `record.pending`'s residue plus the checked-off identities — where the pass has
741
- // completed and the discard and the check-off have already decided what the set holds.
742
- //
743
- // **⟶ RE-DERIVED 2026-11-01 — `D-104`: THAT RESIDUE GAINS A THIRD SOURCE, AND THIS SENTENCE ABOVE STANDS
744
- // BYTE-FOR-BYTE AND IS READ THROUGH THIS CLAUSE** (`docs/L1/repair-listener-delivery.md` §4, §8's
745
- // `js-surface` row; `strata/decisions.md` · `D-104` item `2`). The sentence above names the residue and the
746
- // checked-off identities; **from this date a handle the commit's own write never returned may also stand in
747
- // `record.pending`** — one that a REPAIR's write returned — because the kernel's repair arm MERGES a
748
- // repair's write's triggered listeners into that member at its own seat, after the credit and before the
749
- // re-run (`kernel-attempt.mjs`), de-duplicated by `handle` and never a pair's. **`triggered` IS UNMOVED**
750
- // (it stays the store's own returned set for THIS write, VERBATIM) and **this frame moves no byte**: the one
751
- // delivery, its one recipient snapshot and its one address are what they were.
752
- //
753
- // **AND A WRITE WHOSE `commit` THE KERNEL DID NOT SUPPLY IS STILL DELIVERED HERE, AT ITS OWN POST-VERB
754
- // INSTANT** (`docs/specs/storeroom-js/surface.md §2.7` item 2): that is the `n <= 3` caller path never reaching this frame at all, so THIS
755
- // frame is reached only as the kernel's leg and its silence is total. **THE ONE INVOCATION PER DISTINCT
756
- // IDENTITY RULE `deliver` enforces is thus never asked to dedupe two windows, because only one window
757
- // exists** (`docs/specs/storeroom-js/surface.md §2.4` rule 3; `deliver` below).
758
- return record;
759
- } finally {
760
- closeCommit(instance, opened);
761
- }
762
- },
763
- /// `PAR-JS-16`: `{address, tiers, triggered}` — `address` VERBATIM, `tiers` in the store's canonical order,
764
- /// and the in-domain no-op arm a SUCCESS returning `tiers: []`. **Its declared NAME is `delete`, and it is
765
- /// published under that name ALONE** (`package.md §1.3` item 3): `deleteOp` is a reserved-word workaround
766
- /// for the declaration and never a member of the package's namespace.
767
- ///
768
- /// **⟶ AND IT CARRIES THE DELETE'S OWN `op` FROM 2026-10-27** (`D-43` item 3; `index.d.ts`
769
- /// `DeleteRecord.op`): the member `write`'s record carries, at the same name, so `rollback(record.op.opId)`
770
- /// reverses the delete. `null` is the `D-3` arm that removed nothing — it appended no entry, so it names
771
- /// no op — and it crosses unchanged rather than folding to `undefined` (`crossing.md §1.3`).
772
- ///
773
- /// **⟶ AND IT CARRIES THE DISCARD'S WITNESS FROM 2026-10-28 — `D-49`, `strata/decisions.md`, THE ARCHITECT,
774
- /// VERBATIM: *"Make discard observable"*** (`index.d.ts` `DeleteRecord.discarded`; the use case's own
775
- /// foundation is the prefix rule the delivery already obeys: **a listener at `window.tabs` FIRES for a
776
- /// delete at `window.tabs.landingPage`, and the check it runs there is exactly the kind of act the
777
- /// `delete`-delivery window throws away**).
778
- ///
779
- /// **⟶ AND IT RUNS A PASS FROM 2026-10-29 — `D-55` ITEM 3, `DEF-X`. THE RULING, THE ARCHITECT, VERBATIM:
780
- /// *"A delete is an editing verb and must pass constraints. This includes all of the relevant commit and
781
- /// message logic."*** **THE BYTES THIS PARAGRAPH REPLACES READ *"`delete` IS THE ONE ACT WHOSE DELIVERY RUNS
782
- /// NO PASS"*, AND THEY WERE TRUE OF `1.3.0` AND FALSE OF THIS TREE**: a delete opens its own commit, and
783
- /// **⟶ AND THE SET IT ASKS IS NOW THREE-PART, `D-66` (2026-10-28): every ANCESTOR of the delete's address (`D-56`), the
784
- /// address itself, and EVERY DESCENDANT THE DELETE TOUCHED — for a delete, the whole subtree, because removing it
785
- /// changes what a read there returns (absent where it stood). A pair at an address the act did NOT touch is still
786
- /// not asked, which is the criterion: TOUCHED, not descendant.** **the delete-shaped attempt
787
- /// `constraints.mjs`'s `constraintDelete` builds asks every pair standing at the
788
- /// delete's own address **⟶ AND AT EVERY ANCESTOR OF IT, `D-56` (2026-10-28): THE PAIR'S ADDRESS BEING A PREFIX OF
789
- /// THE ACT'S IS THE MEMBERSHIP TEST NOW, because the value read at a prefix CONTAINS its subtree and a change at a
790
- /// descendant changes what that read returns** — against THE STATE THE DELETE LEFT**, appends the attempt's terminal entry to the
791
- /// commit's one list, and — where a pair refuses — undoes the delete before it refuses (`D-55` item 5's safe
792
- /// state). **NO PROBE WRITE IS LANDED TO HAVE SOMETHING TO JUDGE**: the thing judged is the delete's own
793
- /// journal op, whose after-state is absence.
794
- ///
795
- /// **AND THE DELIVERY MOVED WITH IT — IT NOW SITS AFTER THE PASS.** At `1.3.0` the `deliver` call stood
796
- /// immediately after the addon's return, so a listener fired by a delete saw a state no constraint had
797
- /// approved and that a refusal was about to undo. **A LISTENER FIRED BY A DELETE NOW SEES A JUDGED STATE**,
798
- /// and a refused delete delivers nothing at all. **THE POSITION IS THE WRITE'S OWN** (`surface.md §2.7` item
799
- /// 6: *"the surface runs the write's TRIGGERED CONSTRAINTS FIRST, and THE OTHER LISTENERS ARE REACHED ONLY
800
- /// ONCE EVERY CONSTRAINT HAS PASSED"*), and the delivery still stands inside this act's commit window, so a
801
- /// listener body's own verbs open their own commits (`D-46`).
802
- ///
803
- /// **WHAT THE WITNESS STILL SPEAKS FOR, SAID NARROWLY.** The request a LISTENER BODY raises inside the
804
- /// delivery — a `rollback`, stamped with this commit's identity by `reversalWatch` — is raised AFTER the
805
- /// pass, so nothing in this act judges it: it is read at the end of the delivery and reported **BESIDE** the
806
- /// record's four members, by the one rule `D-49` sets (`D-43` item 2's second window is a registration, whose
807
- /// answer is an opaque identity and carries nothing). **A request a PAIR BODY raises INSIDE the pass is no
808
- /// longer discarded**: it is consumed by the pass's own restart drain and judged at the state the delete
809
- /// left (`D-42`; `D-54` (b)) — the third host `D-54` measured and named undeclared.
810
- ///
811
- /// **THE MEMBER IS A NON-ENUMERABLE OWN `data` PROPERTY, AND THE CHOICE IS DECLARED.** It is **visible to the
812
- /// caller by its name** (`record.discarded`) and declared in `index.d.ts`, while the record's **enumerable
813
- /// member set stays the four its declaration and its cells assert** — `Object.keys`, every deep-equality over
814
- /// a receipt and every census of a record's members read exactly what they read before. **A witness added by
815
- /// moving the record's own declared ENUMERABLE shape would make the cells that assert that set's readings
816
- /// false to buy nothing a caller needs**; a `Symbol.for` key would be the family's other device (`A117` (D6))
817
- /// but is not declarable as a member of `DeleteRecord`, and `D-49` asks for the member to be declared.
818
- ///
819
- /// **THE VALUE IS `[]` WHERE NOTHING WAS DISCARDED AND ONE `{ opId, addresses }` ENTRY WHERE A REQUEST WAS**
820
- /// — the id the reversal named (the store's own echo) and **the addresses the refused act MOVED**, measured
821
- /// at the reversal's own instant (`constraints.mjs`'s `movedStanding`), not the whole watched registry:
822
- /// **a witness names what moved, because what did not move was not the act's** (`DEF-AM`, 2026-10-28).
823
- /// **THE WITNESS RUNS NO PASS OF ITS OWN, INVOKES NO BODY AND TAKES NO JUDGEMENT**: the request is consumed
824
- /// (reported) and its effect still stands.
825
- delete(address, tier) {
826
- // **⟶ `§4.1`: `delete` OPENS ONE.**
827
- const opened = openCommit(instance);
828
- // **THE WINDOW THIS ACT OWNS, TAKEN AT ITS OPENING** — the identity `reversalWatch` stamps a request with,
829
- // so that what the witness reads is the request THIS delivery raised and never another window's.
830
- const window = currentWindow(instance);
831
- try {
832
- const args = arguments.length >= 1 ? [encodeAddress(address, undefined, 'first argument')] : [];
833
- // `delete`'s tier is read as a VALUE and not by an arity fold: an ABSENT position is the whole-target
834
- // removal, and a supplied `undefined` answers row 4's `AddressMalformed` (`crossing.md §1.3`).
835
- appendOwn(args, encodeTier(tier, arguments.length >= 2, false, 'first argument'));
836
- // **THE STORE'S OWN LEG, THE DELETE-SHAPED ATTEMPT AND THE PASS, IN ONE CALL** (`constraints.mjs`'s
837
- // `constraintDelete`): the attempt is opened with this commit's list in hand and the address held, the
838
- // thunk below is INVOKED AS ITS STORE LEG — the addon's own `delete`, crossed exactly as it always was —
839
- // and the pass that follows asks every pair standing at THE DELETE'S OWN ADDRESS against the state the
840
- // delete left. **NO PROBE WRITE PRECEDES THE JUDGEMENT** (`K-2`'s store leg is a `write` and this act's
841
- // is not). **A REFUSAL LEAVES BY THROW, FROM INSIDE THAT CALL**, with the store already back at the
842
- // state this commit opened at (`D-55` item 5) — so nothing below is reached and nothing is delivered.
843
- let answer;
844
- // **⟶ THE ADOPTION, 2026-10-29 — `K-2`'S OWN SEMANTICS REACHED BY THE DELETE'S OWN ROUTE.** A write's
845
- // record reaches the entry at `write`'s FOURTH POSITION and that member stands it in `state.leg`, the
846
- // slot the TERMINAL ARM reads for the triggering address and for the `file`-tier save's own op. **A
847
- // delete's arity is the declared `delete(address, tier)`, so it has no such position** — the adoption is
848
- // therefore taken HERE, at the instant the store's own verb returned and BEFORE the pass, which is the
849
- // same instant and the same slot: the delete's own returned receipt stands where a write's record
850
- // stands, so the terminal arm saves the DELETE's op and delivers at the DELETE's address.
851
- // **AND THE ENTRY'S OWN LEG IS PUT BACK, BESIDE `closeCommit` AND IN THE SAME `finally`**: a leg left
852
- // standing would be read by an ENCLOSING write's terminal arm (`state.leg` is one slot and a nested act
853
- // is reached from a body — `D-53`), and the delete's record must not become the enclosing commit's.
854
- const standing = state.leg;
855
- const standingDelivery = state.legDelivery;
856
- // THE LEG'S DELIVERY IS THIS MEMBER'S FOR THE DURATION (`D-49`'s window, unmoved): the arm saves the
857
- // delete's op and delivers nothing, so the residue reaches each listener ONCE — from `deliver` below.
858
- state.legDelivery = 'member';
859
- try {
860
- const receipt = constraintDelete(instance, address, arguments.length >= 2 ? tier : undefined, () => {
861
- // THE ENTRY IS INVOKED BY `Reflect.apply`, NOT BY A SPREAD — see `read`'s clause of 2026-10-24 above.
862
- answer = carryRefusal(() => Reflect.apply(entryOf().delete, this, args), args);
863
- const crossed = {
864
- address: decodeSegments(answer.address),
865
- tiers: answer.tiers,
866
- triggered: crossTriggered(state, answer.triggered),
867
- op: answer.op === null ? null : decodeJournalOp(answer.op),
868
- };
869
- // THE ADOPTION ITSELF — one assignment, at the verb's own return.
870
- state.leg = crossed;
871
- return crossed;
872
- });
873
- // **⟶ AND THE DELIVERY NOW READS THE RECORD'S `pending` RESIDUE, 2026-10-29 — THE FOURTH MEMBER'S
874
- // OWN ACT, `K-2`'s SEMANTICS REACHED BY THE DELETE'S OWN INSTANT.** The delivery's position is
875
- // UNMOVED (`D-55` item `3` put it after the pass, and `D-49` declares this delivery the window whose
876
- // check never ran — a request raised here is the witness's, not the drain's, and this build changes
877
- // neither). **WHAT MOVES IS WHAT IT DELIVERS**: before the record existed this call handed the
878
- // store's WHOLE returned set, and it now hands `record.pending` — that set MINUS the handles this
879
- // delete's own pass checked off as it passed (`releasePending`), which is the write's own delivered
880
- // set (`surface.md §2.7` item 7 (a)). **A `D-3` DELETE HAS NO RECORD**, so it falls back to the
881
- // receipt's own `triggered` — the arm's set, empty by the store's own declaration.
882
- const owed = receipt.commit === null || receipt.commit === undefined
883
- ? receipt.triggered
884
- : receipt.commit.pending;
885
- // **THE RULE IS THE WRITE'S OWN** (`surface.md §2.7` item 6): constraints first, then the other
886
- // listeners. `A43`: a delete FIRES its own triggered set, on the same window as a write.
887
- deliver(state, owed, answer.triggeringAddress);
888
- // **⟶ `D-49`: THE WITNESS, READ AFTER THE DELIVERY AND REPORTED BESIDE THE RECORD** — the delivery is
889
- // the act's remaining body-invoking instant, so a request standing after it is one this window raised
890
- // from a LISTENER BODY. **A REQUEST A PAIR BODY RAISES INSIDE THE PASS IS NOT THIS WITNESS'S**: it is
891
- // consumed and judged by the pass's own restart drain (`D-42`; `D-54` (b)), and by the time this line
892
- // runs it has either passed or refused the delete outright.
893
- // **ONLY A DELETE THAT OPENED ITS OWN WINDOW REPORTS**: a call that joined an enclosing commit has no
894
- // window of its own to witness, and any request under that identity belongs to the act that opened it
895
- // (`witnessDiscardedReversal` clears a request of the window handed in and of no other). **A JOINED
896
- // DELETE THEREFORE ANSWERS `[]` AND MEANS IT ABOUT ITS OWN WINDOW — THE RAISES ITS DELIVERY MADE ARE IN
897
- // THE ENCLOSING WINDOW, AND THE ACT THAT OWNS THAT WINDOW IS THE ONE THAT REPORTS THEM** (`D-42` item
898
- // `3`; measured by `DW-09.2`).
899
- //
900
- // **⟶ AND THE LIST IS EVERY RAISE, AT ANY COUNT — `D-75`, 2026-10-29.** The bytes here read
901
- // `discarded === null ? [] : [discarded]`, which is the ONE-SLOT shape `D-49` declared and `D-75`
902
- // measures the cost of: two raises in one delivery answered `[]`. **`witnessDiscardedReversal` now
903
- // answers a LIST** — one entry per raise the delivery discarded, in raise order, each `{opId,
904
- // addresses}` — so this member IS that list and the length is the count.
905
- const discarded = opened === true ? witnessDiscardedReversal(instance, window) : [];
906
- Object.defineProperty(receipt, 'discarded', {
907
- value: discarded,
908
- enumerable: false,
909
- writable: false,
910
- configurable: true,
911
- });
912
- return receipt;
913
- } finally {
914
- state.leg = standing;
915
- state.legDelivery = standingDelivery;
916
- }
917
- } finally {
918
- closeCommit(instance, opened);
919
- }
920
- },
921
- /// `PAR-JS-9`: `{opId, undoneOps, restoredTo}` — the constraint pattern's reverse step (`docs/specs/storeroom-js/contract.md §2.6`).
922
- ///
923
- /// **⟶ AND THE REVERSAL IS JUDGED FROM 2026-10-26 — `DEF-W` OF `strata/decisions.md` · `D-38`, THE
924
- /// ARCHITECT, VERBATIM: *"Assert the constraints on rollback"*** (`docs/specs/storeroom-js/contract.md §2.6`'s
925
- /// clause of this date is the declaration; `surface.md §2.12`'s clause (D) and `package-use.md §5.4` name
926
- /// the same member). **THE TWO CALLS BELOW ARE THE WHOLE OF IT AND NEITHER IS A WALK:**
927
- /// * **`reversalWatch` TAKES THE PRE-REVERSAL STANDING** of every enabled pair's every address BEFORE
928
- /// the addon's entry is reached, and it answers `[]` where the entry carries no pair — so a store that
929
- /// registered no constraint reaches no read at all and this member is byte-for-byte what it was;
930
- /// * **`judgeReversal` ASKS THE STATE THE REVERSAL LEFT** (`D-38`: the TERMINAL state, never a per-step
931
- /// check — an unwinding composition passes through intermediate states no constraint would approve)
932
- /// and throws the surface's one plain form, `{status: 'ConstraintPassRefused', message, log}` at the
933
- /// set's rank `20`, where a pair the reversal TOUCHED refuses that state.
934
- /// **A LAWFUL REVERSAL IS UNCHANGED — same record, same three members, no throw** — **and `D-40`'s floor
935
- /// law is not re-walked: this member still performs the store's own calls, and the judgement is a judgement
936
- /// of the state those calls left and not a sequence of per-op approvals.** **THE SHAPE IS `(a)` AND IT WAS
937
- /// MEASURED: the refusal comes AFTER the reversal**, because `(b)` — computing the terminal state without
938
- /// applying it — is not computable from the thirteen names the artefact publishes (there is no journal read
939
- /// and no candidate-set query among them) and a JS guess at the store's temporally floored, all-or-nothing
940
- /// rollback scope (`src/store.rs:2374–2430`) is the one thing this pass refused to write. **⟶ AND ITS SECOND
941
- /// HALF — *"the reversal's effect STANDS"* — IS SUPERSEDED 2026-10-26 (`DEF-W`'s `(a)` discharged;
942
- /// `contract.md §2.6`'s second annotate-beside of that date): a refusal that reports the violation while
943
- /// leaving it is not a discharge, so `judgeReversal` RESTORES the pre-reversal standing of every address the
944
- /// reversal moved before it throws the one plain form, and the log says the reversal was undone.** **THE
945
- /// RESTORE IS NOT A JUDGED WRITE AND RECURSES INTO NOTHING**: it is the refusal's own compensating act,
946
- /// taken at the store's entry with no `K-2`, no pass, no listener delivery and no second judgement
947
- /// (`constraints.mjs`'s `restoreReversal`).
948
- rollback(opId) {
949
- const args = arguments.length >= 1 ? [encodeOpId(opId)] : [];
950
- // THE WATCH COMES FIRST, ON THIS SIDE OF THE STORE CALL: the standing it takes is the one the reversal
951
- // is about to move, and it is what makes "the address the reversal touched" MEASURED.
952
- const watched = reversalWatch(state, instance);
953
- // **AND THE RAISE THIS CALL MADE IS TAKEN HERE, BEFORE THE JUDGEMENT CONSUMES ITS MEASUREMENT — `D-75`.**
954
- // It is `null` on every arm that raises nothing (an at-rest judgement, the kernel's own compensation, a
955
- // store carrying no pair), and on a raise it is the record the witness speaks for: it names the id the
956
- // reversal answered, the addresses the reversal MOVED, and — once the window has decided — whether this
957
- // raise was DISCARDED or JUDGED.
958
- const raise = currentRaise(instance);
959
- // THE ENTRY IS INVOKED BY `Reflect.apply`, NOT BY A SPREAD — see `read`'s clause of 2026-10-24 above.
960
- const answer = carryRefusal(() => Reflect.apply(entryOf().rollback, this, args), args);
961
- // AND THE JUDGEMENT AFTER IT, keyed to the store's own echo of the id the reversal named.
962
- // **⟶ AND IT IS HANDED THIS INSTANCE'S OWN STATE FROM 2026-11-02 — `D-117` ITEM 2's DELIVERY**, whose one
963
- // recipient set is the caller's registry and whose receiver is this member's own: `deliver` is the
964
- // `surface.md §2.4` loop, so it takes the state that holds both (`§2.7` (iii) (a)). **NOTHING ELSE IN THIS
965
- // MEMBER MOVES** — not its record (`:702`–`:706`), not `carryRefusal`, not the witness — **and the
966
- // position is a private frame's fourth, not a member, an arity or a declared surface.**
967
- //
968
- // **⟶ AND FROM 2026-11-02 IT ANSWERS THE JUDGEMENT'S OWN LIST — `D-119`.** `judgeReversal` answers the
969
- // array its judgement appended to, frozen in place at that frame's end (`constraints.mjs`'s
970
- // `defineResolutionLog` clause), **and that list is what this record carries at `record.log`, installed at
971
- // the record's return below**: a reversal's judgement runs your pairs' repairs (`D-113` item 3) and
972
- // delivers the listeners those repairs fire (`D-117` item 1), so the `repair-run` entry a repair left is
973
- // the downstream edit this ruling exists to make readable. **EVERY ARM THAT ANSWERS `undefined` EARNS THE
974
- // FROZEN EMPTY LIST** — the compensating composition, the deferred arm and the at-rest judgement over an
975
- // empty watch own no list of their own — and `[]` means *this act appended nothing it can report*
976
- // (`resolution-log.md` §3.3, §4.3).
977
- const judgedLog = judgeReversal(instance, watched, answer.opId, state);
978
- const record = {
979
- opId: answer.opId,
980
- undoneOps: answer.undoneOps,
981
- restoredTo: decodeBaseState(answer.restoredTo),
982
- };
983
- // **⟶ AND THE RAISE'S OWN ANSWER CARRIES THE WITNESS FROM 2026-10-29 — `D-75`: *"on every path"*.** The bytes
984
- // this record answered with had **no `discarded` member**, so a body — a constraint body, a listener body —
985
- // that issued this call could not learn what became of it: **measured, absent on the raise's own answer and
986
- // absent on the triggering write's, at one raise and at two.** **WHAT IT ANSWERS, IN THE THREE ARMS ITS OWN
987
- // SENTENCE HAS**: an entry — `{opId, addresses}` — where this act's window has DISCARDED this raise; and
988
- // `[]` where the raise was CONSUMED and judged by a pass's own drain (`D-42`: nothing was discarded), where
989
- // no request was raised at all (an at-rest judgement is judged at its own instant), and while the raise still
990
- // stands and its window has not ended — at that instant nothing has been discarded YET. **IT IS A LIVE VIEW
991
- // AND NOT A SNAPSHOT**: the pass that judges a body's raise runs after the body returned, so a datum captured
992
- // here would answer `[]` about a window that then discards it. Read it once the act whose window it stands in
993
- // has returned and it is the settled answer.
994
- //
995
- // **AND THE RECORD'S THREE DECLARED MEMBERS ARE UNMOVED**: `discarded` is a NON-ENUMERABLE own accessor
996
- // (`index.d.ts`'s `RollbackRecord` clause; `defineDiscardWitness`), so `Object.keys`, every deep-equality
997
- // over the record and every census of its members read the three they read before.
998
- //
999
- // **⟶ AND `record.log` IS THE JUDGEMENT'S LIST, INSTALLED THE SAME WAY AND BESIDE IT — `D-119`.** The same
1000
- // device, the same name the failure form uses, `enumerable: false`, `configurable: true`, and **the read
1001
- // answers one captured reference** — the array the judgement's frame froze — where `discarded` beside it
1002
- // is a live read by necessity (§5.4's own note: the two members share a SHAPE and not a REASON). **THE
1003
- // FROZEN EMPTY LIST IS THE ANSWER ON EVERY ARM THE JUDGEMENT DID NOT JUDGE**, and the member is present on
1004
- // every passing answer, `[]` included.
1005
- return defineResolutionLog(defineDiscardWitness(record, () => witnessRaise(raise)), judgedLog);
1006
- },
1007
- /// **⟶ `listen(handle, addresses) -> undefined` — arity `2`, position `1` a caller-spelled string and
1008
- /// position `2` a SET of addresses** (`contract.md §2.2`; `listen-verb.md §1` item 1; `PAR-HL-1`,
1009
- /// `PAR-HL-2`, `PAR-HL-3`).
1010
- /// **⟶ `listen(handle, addresses) -> undefined` — `U-STOREROOM-HELD-LISTENER-IDENTITY` (`D-GP-SHLI`),
1011
- /// `contract.md §2.2` (`HL-2`).** **THE ARITY FIGURE MOVES `1 → 2`**: position `1` is `handle`, a non-empty
1012
- /// `string` in `HL-1`'s domain; position `2` is `addresses`, a SET of addresses. **THE RETURN IS `undefined`**
1013
- /// — *"the caller supplied the handle, so returning it would be a second spelling of the caller's own
1014
- /// datum"* (`contract.md §2.2` item 10; `PAR-HL-3`).
1015
- ///
1016
- /// **THE TWO CLASS TESTS PRECEDE EVERY STORE ACT** (`listen-verb.md §2.2` item 3: *"a refused `listen`
1017
- /// changes nothing: no entry, no mirror row, no purge"*), and **the order is PURGE THEN INSTALL, inside the
1018
- /// store's own verb** — so no observable instant holds both (`contract.md §2.2` item 4).
1019
- ///
1020
- /// **⟶ AMENDED 2026-10-24 (`D-29`, verbatim: *"Listen cannot overwrite constraint, only other listeners"*):
1021
- /// THE SENTENCE ABOVE IS NARROWED, NOT WITHDRAWN, AND IT IS STILL PRINTED — *"`listen` GAINS NO CONFLICT TEST
1022
- /// AT ALL"* READS **`listen` GAINS NO CONFLICT TEST AGAINST ANOTHER LISTENER, AND GAINS ONE AGAINST A
1023
- /// CONSTRAINT** (`docs/specs/storeroom-held-listener-identity/contract.md §2.2` item 7 stands as text read
1024
- /// THROUGH this clause). **Overwriting a listener with a listener stays LAWFUL** — that is `D-24`'s
1025
- /// same-kind rule — **and overwriting a constraint with a listener is REJECTED** (`B-6`; §2.2 item 7's
1026
- /// *"GAINS NO CONFLICT TEST AT ALL"* was written while a reserved `constraint@` namespace made `listen`'s
1027
- /// reach look anonymous; `D-23` makes the occupancy the caller's own word, so the residual `Q-1` named is
1028
- /// closed here rather than left legible).
1029
- ///
1030
- /// **AND `listen` ANSWERS THE HANDLE IT WATCHES UNDER ON SUCCESS** (`D-22`): the return moves `void →
1031
- /// `Handle`, a success signal that CARRIES the identity, and failure stays the one thrown form.
1032
- listen(handle, addresses) {
1033
- // **⟶ `§4.1`: `listen` OPENS ONE.**
1034
- const opened = openCommit(instance);
1035
- try {
1036
- // ── POSITION 1: THE HANDLE'S CLASS TEST ───────────────────────────────────────────────────────────────
1037
- // **`F-1`: the surface's ONE thrown form with `status` the store's `AddressMalformed`, and NO STATE
1038
- // CHANGED** (`contract.md §4` `F-1`; `§2.1` items 5–6). The predicate is a `typeof` read and a length read
1039
- // and nothing more — no object inspection and no trap (`identity-and-domain.md §2` item 1).
1040
- if (arguments.length < 1 || !inDomainHandle(handle)) {
1041
- boundaryReject(
1042
- 'AddressMalformed',
1043
- targetSpelling(handle),
1044
- `listen's first argument is ${classSpelling(handle)}, and a listener's handle is a non-empty string `
1045
- + 'this caller spells',
1046
- );
1047
- }
1048
- // ── POSITION 2: THE SET-POSITION CLASS TEST — A NEW DECLARED FORM ─────────────────────────────────────
1049
- // **`addresses` IS AN ARRAY WHOSE EVERY MEMBER IS AN ADDRESS IN THE STORE'S OWN DOMAIN; THE EMPTY ARRAY IS
1050
- // IN THE DOMAIN** (`listen-verb.md §2.2` item 1; `PAR-HL-2`). **THE DISCRIMINATOR IS THE MEMBER'S CLASS,
1051
- // READ ONCE PER MEMBER — never a length heuristic and never a coercion** (`listen-verb.md §2.2` item 4).
1052
- if (arguments.length < 2 || !isAdmittedArray(addresses)) {
1053
- boundaryReject(
1054
- 'AddressMalformed',
1055
- targetSpelling(addresses),
1056
- `listen's second argument is ${classSpelling(addresses)}, and this position is a SET of addresses — `
1057
- + 'an array of addresses, the empty array included',
1058
- );
1059
- }
1060
- for (let i = 0; i < addresses.length; i += 1) {
1061
- // **A BARE SEGMENT LIST IS OUTSIDE THE DOMAIN** — *"the position is a set and a segment list is a
1062
- // different shape"* (`P: docs/pending.md · P-7`'s set ruling, consequence (ii); `listen-verb.md §2.2`
1063
- // item 2, class (vi)). **THE MEMBER'S CLASS IS WHAT DECIDES IT AND NOT ITS LENGTH.**
1064
- if (!isAdmittedArray(addresses[i])) {
1065
- boundaryReject(
1066
- 'AddressMalformed',
1067
- targetSpelling(addresses[i]),
1068
- `listen's second argument carries ${classSpelling(addresses[i])} at member ${i}, and a set's member `
1069
- + 'is an address — an array of segments',
1070
- );
1071
- }
1072
- if (!inDomainAddress(addresses[i])) {
1073
- boundaryReject(
1074
- 'AddressMalformed',
1075
- targetSpelling(addresses[i]),
1076
- `listen's second argument carries an address outside the store's domain at member ${i}`,
1077
- );
1078
- }
1079
- }
1080
- // ── `B-6` — THE CROSS-KIND REJECTION: THE HANDLE, AND NOTHING ELSE (`D-98`) ──────────────────────────
1081
- // **⟶ RE-DERIVED 2026-11-01 (`D-98`, verbatim: *"A constraint and a listener can share an address … The
1082
- // restriction is that a listener and a constraint cannot have the same *handle*"*).** **THE ADDRESS-SET
1083
- // DIMENSION IS DELETED**: its ground — `D-29`'s *"the address dimension is NECESSARY, because the purge is
1084
- // address-reaching"* — is FALSE at this build and `D-98` item 3 withdraws it: the purge is BY HANDLE
1085
- // (`src/store.rs:476`–`:494`, `:2594`) and the mirror's is too (this file's own purge, in
1086
- // `delivery.mjs`'s `listenOn`), so an act under a different handle cannot reach a pair's rows. **What the
1087
- // dimension admitted was the defect.**
1088
- // **THE HANDLE DIMENSION IS THE WHOLE TEST**, and it is the SAME read `B-5` takes — one helper, one rule
1089
- // (§1.1). **NO STATE MOVES**: no store act, no mirror row, no registry write.
1090
- //
1091
- // **AND THE ONE ACT THE OLD TEST ALLOWED WENT WITH ITS INSTRUMENT** (`D-99`'s ANSWERED clause, `C-18`):
1092
- // the kernel's own re-listing is not exempted here — **it does not pass this test at all**, because `K-1`
1093
- // reaches the store through its own route (`LISTEN_ROUTE`, `delivery.mjs`'s `listenOn`) and this member is
1094
- // a CALLER's door. **THERE IS NO MARKER, NO BRACKET AND NO `state.establishing` LEFT TO READ**; a
1095
- // constraint body that calls `listen('<its own pair id>', …)` during its own registration is refused here
1096
- // exactly as any caller's act is.
1097
- //
1098
- // **AND THE MESSAGE'S GENERATED HALF IS THE STORE'S OWN QUALIFIED ARM, NOT THE SEGMENT TEMPLATE**
1099
- // (`D-98` item 4; `C-7`–`C-11`, §3.3 and §3.6): the `'handle'` arm token is supplied at
1100
- // `boundaryReject`'s appended FIFTH position and reaches the generator's fourth — so the sentence reads
1101
- // *"'<id>' is already a handle this instance carries, a listener's handle and a constraint's id are one
1102
- // string and one string only"* and **names no address and no placeholder container at all** (the
1103
- // fourth position is `undefined` ON PURPOSE: this arm passes NO container, §3.4).
1104
- const overwritten = constraintOverwrittenByListen(state, handle);
1105
- if (overwritten !== null) {
1106
- boundaryReject(
1107
- 'AddressMalformed',
1108
- overwritten.id,
1109
- `listen refuses: the constraint pair '${overwritten.id}' keeps that handle, and a listener and a `
1110
- + 'constraint do not share one handle',
1111
- undefined,
1112
- 'handle',
1113
- );
1114
- }
1115
- // ── THE POST-TEST BODY, EXTRACTED BY NAME — `D-99`'S ANSWERED CLAUSE, 2026-11-01 ──────────────────────
1116
- // **⟶ THE BYTES ABOVE ARE A CALL NOW** (`C-17`, §9.2): the address encode, the ONE store act, the home
1117
- // mirror's purge-and-install, the entry's registry reservation and the returned handle all moved
1118
- // BYTE-FOR-BYTE into `delivery.mjs`'s `listenOn`, which the kernel's own registration calls too. **THE
1119
- // MEMBER KEEPS WHAT IS THE MEMBER'S**: the commit bracket (`openCommit`/`closeCommit`), the two position
1120
- // class tests and `B-6` above — **so `listen` is a CALLER's door and the kernel's act is the kernel's own**,
1121
- // which is the whole of `D-99`'s route reading. **NO ANSWER MOVES**: the same handle, the same store act,
1122
- // the same mirror rows and the same registry entry, because it is the same function.
1123
- return listenOn(this, state, handle, addresses);
1124
- } finally {
1125
- closeCommit(instance, opened);
1126
- }
1127
- },
1128
- /// `docs/specs/storeroom-js/surface.md §2.3` item 4 / `PAR-JS-8`: **`unlisten` over ANY value outside the domain is a NO-OP SUCCESS** — a
1129
- /// foreign instance's value, a prior session's value, a fabricated value, a blank string, a non-string and
1130
- /// an absent handle are EACH a no-op success, no code is produced, and NO OTHER REGISTRATION IS REMOVED.
1131
- ///
1132
- /// **⟶ AND THE SAME VALUE THAT IS A SILENT SUCCESS HERE IS A THROWN FAILURE AT `removeListener` — TWO
1133
- /// DISPOSITIONS FOR ONE ARGUMENT IN ONE PRODUCT, and that reversal is RULED, not accidental**
1134
- /// (`P: docs/pending.md · P-5`'s `(R2)`, verbatim; `contract.md §2.1` item 5's closing clause).
1135
- ///
1136
- /// **THE WITHDRAWAL'S OWN MODEL, IN THIS CHANGE'S TERMS** (`P: docs/pending.md · P-5`'s A4 ruling, verbatim:
1137
- /// *"`unlisten` sets `off` only when the identity no longer stands anywhere, exactly as `:2320`'s survivor
1138
- /// re-scan decides today"*): **the store's entry is withdrawn and the MAP ENTRY IS KEPT with `off` set — a
1139
- /// reservation, not a deletion** (`identity-and-domain.md §3` item 2 (i); `listen-verb.md §4` state `1`).
1140
- unlisten(handle) {
1141
- // ═════════════════════════════════════════════════════════════════════════════════════════════════════
1142
- // **⟶ THE RECEIVER IS CONSULTED FIRST, BEFORE EITHER DOMAIN DISJUNCT — THIS IS `§3`'s ONE ARM AND IT IS
1143
- // THE ORDER ITS SEVEN SIBLINGS ALREADY KEEP** (`docs/specs/storeroom-addon-surface/receiver-and-refusal.md
1144
- // §3`: *"A CALL WHOSE RECEIVER NAMES NO LIVE STORE REFUSES, IN THE ONE DECLARED FORM."*; `§5`: *"The
1145
- // refusal fires only when the receiver names nothing at all."*).
1146
- //
1147
- // **THE DEFECT THIS ORDER CLOSES, NAMED AT ITS OWN MECHANISM:** the domain short-circuit below answers
1148
- // `undefined` on EITHER disjunct — a non-string/blank handle, or a well-formed string `state.registry`
1149
- // does not carry — and it did so BEFORE `carryRefusal` could hand the receiver to the entry. **SO A CALL
1150
- // WHOSE RECEIVER NAMES NO STORE ANSWERED INSTEAD OF REFUSING** whenever its handle was outside this
1151
- // instance's own map, which is the DETACHED CALL `§7` NAMES AS THIS UNIT'S ONE DECLARED COST (*"`const {
1152
- // read } = layout; read(…)` IS LEGAL TODAY AND THROWS AFTER THIS CHANGE"*) and is `P-SAS-4`'s failure
1153
- // list's third term, *"a success"*. **A CALLER WHO HAS LOST ITS OBJECT HAS NO WAY TO KNOW WHICH STORE'S
1154
- // HANDLE IT IS HOLDING**, so the fabricated-handle row is exactly the value a detached call carries —
1155
- // which is why the two clauses collided here and at no sibling.
1156
- //
1157
- // **AND `§2.3` ITEM 4 IS NOT OVERRIDDEN BY THIS ORDER — IT IS SERVED BY IT** (`docs/specs/storeroom-js/surface.md
1158
- // §2.3` item 4: *"`unlisten` OVER ANY VALUE OUTSIDE THE DOMAIN IS A NO-OP SUCCESS … no code is produced
1159
- // and NO OTHER REGISTRATION IS REMOVED"*). **Its subject is the HANDLE ARGUMENT and its effect clause
1160
- // PRESUPPOSES a live store whose registrations could be removed** — with no receiver there is no store to
1161
- // be a no-op *against*. **SO THE RECEIVER DECIDES THE STORE AND THE HANDLE'S DOMAIN DECIDES THE REST**,
1162
- // which is the one reading that keeps both clauses whole; no amendment is owed and NONE IS MADE HERE.
1163
- //
1164
- // **THE CHECK IS `§3`'s ONE ARM AND MINTS NO TOKEN AND NO SECOND FORM** — it is the same predicate
1165
- // `write` takes at its own first line for the same reason, and a receiver that is not the published one
1166
- // is handed on to the entry, which answers `§3`'s single observable.
1167
- // ═════════════════════════════════════════════════════════════════════════════════════════════════════
1168
- if (!isStoreReceiver(this)) return carryRefusal(() => entryOf().unlisten.call(this, handleWire(handle)), [handleWire(handle)]);
1169
- // **THE DOMAIN TEST IS A DIRECT MAP KEY CHECK** (`P: docs/pending.md · P-6`, fork (g), verbatim: *"the
1170
- // function lookup is now a direct map key check"*): a non-string, a blank string and a string the map does
1171
- // not carry are each the no-op success, and NO OTHER REGISTRATION IS REMOVED (`identity-and-domain.md §6`
1172
- // `O-3`). **IT STANDS BELOW THE RECEIVER CHECK AND NOT ABOVE IT** — a live receiver has established the
1173
- // store by this line, so the no-op success is answered over the HANDLE, exactly as item 4 declares.
1174
- if (!inDomainHandle(handle) || !state.registry.has(handle)) return undefined;
1175
- carryRefusal(() => entryOf().unlisten.call(this, handleWire(handle)), [handleWire(handle)]);
1176
- // THE STORE'S OWN FIRST-MATCH WITHDRAWAL, MIRRORED ENTRY FOR ENTRY (the home holds one row per store
1177
- // entry, so the mirror's own answer is the store's).
1178
- const mirror = state.home.findIndex((row) => row.handle === handle);
1179
- if (mirror === -1) return undefined;
1180
- state.home.splice(mirror, 1);
1181
- // **⟶ AND THE TWO STRUCTURES ARE RECONCILED ON THE MIRROR'S SURVIVORS, WHICH IS THE CLAUSE'S OWN GROUND**
1182
- // (`P: docs/pending.md · P-5`'s A4 ruling, verbatim: *"`unlisten` sets `off` only when the identity no
1183
- // longer stands anywhere, exactly as the survivor re-scan decides today. The flag is per-handle AND
1184
- // per-standing, **which is what the home mirror already computes**"*; `identity-and-domain.md §4` item 4).
1185
- //
1186
- // **THE STORE'S OWN WITHDRAWAL DROPS **ONE** ENTRY AND THE MIRROR DROPS **ONE** ROW** — the two agree
1187
- // entry for entry (`docs/specs/storeroom-native/write-and-read.md §6.5` item 12, cited: *"it drops ONE
1188
- // home-map entry"*; `identity-and-domain.md §6` `O-3`: *"`unlisten`'s no-op success removes no other
1189
- // registration"*). **WHERE SURVIVORS REMAIN, THE ENTRY'S STANDING IS THEREFORE THE SURVIVORS** — so
1190
- // `register`'s re-arm re-installs the addresses the handle STILL stands at and RESURRECTS NONE the caller
1191
- // withdrew. **WHERE NONE SURVIVES, THE ENTRY IS THE RESERVATION `S-6` DECLARES** — *"the entry EXISTS with
1192
- // `off` set; `register(h, fn)` SUCCEEDS and re-arms it"* — so its declared set stands whole and the re-arm
1193
- // re-installs it (`identity-and-domain.md §3` item 2 (i); `contract.md §3` `S-6`; `listen-verb.md §4`'s
1194
- // transition `1 → 2`).
1195
- const survivors = state.home.filter((row) => row.handle === handle);
1196
- // ⟶ REPOINTED 2026-10-18 (`RCA-8(g)`, gate-4 finding F-3): the line anchor `unlisten`'s own doc block carried the pre-merge number the merge left stale — a number that named the survivor re-scan in the pre-`P-8` file and names nothing of the kind after the merge. THE SUPERSEDED NUMBER ITSELF IS NOT RE-EMITTED HERE, and its exact bytes are recorded at archive/p8-merge/2026-10-18/post-gate4/README.md, because a re-emitted stale anchor is a citation a later sweep re-reads as live. It now carries the live line of that site, printed at the last line of this note, and the site is named in prose as well as by number so a future move cannot silently re-break it: THE SURVIVOR RE-SCAN IS THE LINE IMMEDIATELY ABOVE THIS NOTE — `const survivors = state.home.filter((row) => row.handle === handle);`, inside `unlisten`'s own body. Its live line number as this pass leaves the file is `:2320`.
1197
- const entry = state.registry.get(handle);
1198
- if (survivors.length > 0) {
1199
- if (entry !== undefined) entry.addresses = survivors.map((row) => row.address.slice());
1200
- return undefined;
1201
- }
1202
- if (entry !== undefined) entry.off = true;
1203
- return undefined;
1204
- },
1205
- /// `surface.md §2.12` item 2 (a): **`a.addConstraint(pair, constraint) -> constraint identity`** — the
1206
- /// ADD route, which carries the function and OVERWRITES at a pair the entry already holds.
1207
- /**
1208
- * **`docs/specs/storeroom-js/surface.md §2.12` ITEM 2 (a): `addConstraint(pair, constraint) -> constraint identity` — THE ADD ROUTE, WHICH
1209
- * CARRIES THE FUNCTION.**
1210
- *
1211
- * **ITS TARGET STATE AT THE PAIR IS *"the pair's element IS the supplied `constraint`, whether the pair was
1212
- * HELD or NOT"*, AND THE HELD ARM IS AN OVERWRITE AND NOT A THROW**: *"where the pair was already held, the
1213
- * supplied constraint OVERWRITES the held one … and the call REFUSES NOTHING and THROWS NOTHING for the mere
1214
- * fact that the pair was held"* — the SAME identity the pair was already added under is returned, and it is
1215
- * THE IDENTITY AND NOT THE ENTRY RECORD (`PAR-JS-25`'s opacity, `carryConstraint` above).
1216
- */
1217
- addConstraint(pair, constraint) {
1218
- // ═════════════════════════════════════════════════════════════════════════════════════════════════
1219
- // **⟶ THE RECEIVER IS CONSULTED FIRST — BEFORE ANY READ, BEFORE ANY EDIT, AND BEFORE THE COMMIT
1220
- // BRACKET.** This member reached every one of its arms off this factory's closure and never asked
1221
- // whether the CALL had a receiver, so a detached `addConstraint` ANSWERED and edited the real pair
1222
- // registry (measured 2026-10-26; `docs/guides/package-use.md §12.2`). **THE GUARD IS THE SEVEN
1223
- // STORE-REACHING VERBS' OWN, ITS FORM IS THEIRS BYTE FOR BYTE, and `constraintDetached` states both
1224
- // and why no constraint clause names a different arm** (`src/entry/constraints.mjs`; the architect's
1225
- // ruling: *"Run the fix by rejecting the detached functions."*). **NO STATE MOVES ON A REFUSED CALL:
1226
- // no `openCommit`, no `constraintSite`, no registry read, no `K-1`, no store act.**
1227
- // ═════════════════════════════════════════════════════════════════════════════════════════════════
1228
- constraintDetached(this);
1229
- // **⟶ AND THE DELIVERY'S SET AT THIS INSTANT IS THE REPAIR'S OWN `triggered` — `PIN-6` (ii), `D-125`
1230
- // item `1`.** The registration's passing close hands `delivery.mjs`'s channel the watched sets its repair's
1231
- // writes fired, and the channel reads this value to know which instant is speaking: **the creation's and the
1232
- // boot's set is `PIN-6` (i)'s and `storeCreate` delivers it at its own seat**, so the channel is silent
1233
- // there and speaks here. **IT IS A VALUE OF THE PACKAGE'S STATE AND NOT A MEMBER** (`A117` (D6)), restored
1234
- // on every arm by the `finally` below, and no code, record or attempt is minted with it.
1235
- const priorDelivery = state.registrationDelivery;
1236
- state.registrationDelivery = 'triggered';
1237
- state.listenerFailure = null;
1238
- // **⟶ `§4.1`: `addConstraint` OPENS ONE.**
1239
- const opened = openCommit(instance);
1240
- try {
1241
- const site = constraintSite(state, 'addConstraint', arguments.length, pair, constraint);
1242
- // ── `B-4` — `D-25`'S *"VICE VERSA"*: A PAIR WHOSE `id` EQUALS A LIVE LISTENER'S HANDLE ────────────────
1243
- // **⟶ THE FOURTH REFUSAL ARM, ADDED 2026-10-24 — A DIRECTION WITH NO TEST AT ALL UNTIL NOW.** The built
1244
- // surface tested one direction only (`register(handle, listener)` refuses where a constraint stands);
1245
- // `D-25`'s *"or vice versa"* requires the other. **THE INSTANT IS DECLARED AND LOAD-BEARING: AFTER
1246
- // `constraintSite`'s two position class tests have passed and BEFORE the held-pair branch — therefore
1247
- // before `withdrawStanding`'s purge, before `K-1` and before any store call.** **The seam is named
1248
- // because a purge that ran before a cross-kind refusal would destroy a standing registration and then
1249
- // refuse — *"a purge with no add"*, the state `(O-4)`'s ground exists to prevent.**
1250
- //
1251
- // **ITS MEMBER IS `AddressMalformed`**, on this surface's own reading of that member — *"the instance's
1252
- // domain is the domain"* (`R-B4`) — read with `D-24`'s instance-scoped handle: **an `id` that names a live
1253
- // listener is outside this instance's handle domain for a constraint.** It is also the status the
1254
- // register-side sibling answers for the adjacent fact, **so one namespace question does not print two
1255
- // codes.** **NO STATE MOVES.**
1256
- //
1257
- // **⟶ AND ITS MESSAGE RE-DERIVES 2026-11-01 (`D-98` item 4; `C-9`, `C-11`; §3.4, §3.6), WHILE ITS
1258
- // CONDITION, ITS STATUS AND ITS INSTANT ARE UNMOVED.** **`listenerStandingAt` ANSWERS `true`/`false` NOW**
1259
- // (its address loop existed for the message alone and the message names no address — §2's one deletion),
1260
- // and the refusal's subject is the HANDLE: the generated half is the store's own QUALIFIED
1261
- // `AddressMalformed` arm under the appended `'handle'` token, and the clause names the listener and the
1262
- // rule's re-spelt sentence. **NO ADDRESS APPEARS ANYWHERE IN IT** — the pair's own address belongs to the
1263
- // caller, and a listener's mirror address asserted which of its N rows "kept" the identity (§3.4) — so the
1264
- // refusal's `address` member stays `null` by construction. **The rule's sentence moves by ONE WORD, and its
1265
- // spelling is the anchor `bindings/js/README.md:233` already carries: *"a listener and a constraint do not
1266
- // share one HANDLE"*.**
1267
- const collided = listenerStandingAt(site.state, site.id);
1268
- if (collided === true) {
1269
- boundaryReject(
1270
- 'AddressMalformed',
1271
- site.id,
1272
- `addConstraint refuses: the listener '${site.id}' keeps that handle, and a listener and a `
1273
- + 'constraint do not share one handle',
1274
- undefined,
1275
- 'handle',
1276
- );
1277
- }
1278
- const held = site.state.constraints.get(constraintPairKey(site.addresses, site.id));
1279
- if (held === undefined) {
1280
- const carried = carryConstraint(site.state, instance, site.addresses, site.id, constraint);
1281
- // **DELIVER → THE ANSWER** (`PIN-2`): the registration's own passing close has already delivered, so a
1282
- // fired body's throwable refuses the act here and the identity is never returned (`PIN-10`; `Q-13`).
1283
- raiseListenerFailure(site.state);
1284
- return carried.identity;
1285
- }
1286
- // ═══════════════════════════════════════════════════════════════════════════════════════════════════
1287
- // **⟶ THE HELD-PAIR ARM IS `CHECK → PURGE → ADD`, AND IT IS THE ONE ORDER THE RULING GIVES**
1288
- // (`P: docs/pending.md · (O-3)`, verbatim: *"Writing a constraint to an existing handle purges everything
1289
- // of the old handle, then adds the new one. Everything, no exceptions, stop inventing ones. Override all
1290
- // conflicting decisions."*; `(O-4)`, verbatim: *"THAT THE ORDER IS CHECK → PURGE → ADD at every site that
1291
- // reaches `K-1` from a held pair"*; `contract.md §2.3` items 1–3).
1292
- //
1293
- // **STEP 1 — CHECK.** **A PURGE THAT RUNS BEFORE THE NEW ELEMENT IS KNOWN-GOOD DESTROYS THE OLD LISTENER AND
1294
- // THEN FAILS TO INSTALL, LEAVING THE ADDRESS BARE — *a purge with no add*** (`(O-4)`, its own ground;
1295
- // `A76`). **THE FOUR PRE-CHECKABLE CLASSES ARE ALREADY PASSED**, because `constraintSite` ran first and
1296
- // refused every outside pair, every out-of-domain address and every non-function (`contract.md §2.3`
1297
- // item 4's four classes; `constraint-sites.md §2` item 1). **THE CHECK'S FAILURE LEAVES THE OLD HANDLE WHOLE,
1298
- // AND THAT IS NOT AN EXCEPTION — it is the ABSENCE of a purge, since nothing was ever purged**
1299
- // (`(O-4)` item (ii), verbatim).
1300
- //
1301
- // **STEP 2 — PURGE.** **EVERYTHING OF THE OLD HANDLE, AT EVERY ADDRESS IT STOOD AT, ACROSS EVERY
1302
- // STRUCTURE.** **THE KERNEL'S OWN ADDRESS ROWS ARE PURGED WITH THE HANDLE** — which is what falsifies
1303
- // `surface.md:872`'s second sentence outright (`(O-3)` item (v): *"AND IT REPLACES NOTHING IN THE KERNEL'S
1304
- // OWN STRUCTURE"* — BOTH SENTENCES GO).
1305
- // **⟶ AND THE CALL CARRIES `K-6`'S DECLARED TWO POSITIONS AND NO THIRD** (`contract.md §2.9` item 3;
1306
- // `remove-member.md §3` item 2's two priced alternatives, both refused): **the former fourth position that
1307
- // suppressed the read-model delete is DROPPED**, because the re-add below writes the same pair identity
1308
- // back through `K-1` and `carryConstraint` (`P: docs/pending.md · (O-3)` item (iv)'s obligation; `(AA-2)`;
1309
- // `contract.md §2.6` item 2).
1310
- // **⟶ AMENDED 2026-10-22 (`DEF-2026-10-20-F` landed; the architect's ruling) — `K-6` IS CALLED WHERE A
1311
- // REGISTRATION STANDS, AND A DISABLED PAIR STANDS NONE.** **The disable arm is `remove`-only now, so a pair
1312
- // whose `entry.enabled` is `false` has NO kernel row for `K-6` to find — and `K-6` REFUSES `KC-2` (*"no
1313
- // constraint pair answers to …"*) rather than answering a no-op** (`contract.md §4` `F-12`). **So this
1314
- // overwrite arm purges the pair's OLD registration only where the pair was ENABLED and stands one**
1315
- // (`withdrawStanding` below, which states the rule once for every held-pair purge site). **NOTHING IS LEFT
1316
- // UNPURGED BY THE GUARD:** where the pair is disabled there is nothing to withdraw, and the ADD below lands
1317
- // the supplied element under the same identity either way — `K-1`'s own idempotence arm answers a row that
1318
- // survives a refused registration's wake (`kernel-surface.md §2.1` item 1; `CC-7`). **A DISABLED PAIR IS
1319
- // STILL A HELD PAIR, so this arm is still the overwrite arm and still answers the pair's own identity.**
1320
- withdrawStanding(instance, held);
1321
- // ═══════════════════════════════════════════════════════════════════════════════════════════════════
1322
- // **⟶ STEP 3 IS AN *EXTENSION PLUS AN OVERWRITE*, 2026-10-24 — AND THE EXTENSION HALF IS THE DEFECT
1323
- // THIS ARM SHIPPED WITHOUT.** The declaration is `docs/L1/surface-deltas.md` `Q-2`'s repair `(i)`, landed
1324
- // by `D-29`'s pair-key ruling (*"the pair's identity key becomes the `id` alone … it makes a second
1325
- // `addConstraint` at a new address an **extension plus an overwrite**"*), over
1326
- // `docs/specs/storeroom-held-listener-identity/contract.md §2.6` item 4 (*"one pair, N registry rows,
1327
- // removal clears all N"*). **ONLY THE OVERWRITE SHIPPED**: the bytes below replaced the pair's address set
1328
- // with the CALL's set (`held.addresses = site.addresses`), so a pair extended from `['a']` to `['b']`
1329
- // stopped existing at `['a']` — **its function was replaced, as `D-24` declares, and its ADDRESSES WERE
1330
- // DESTROYED, which no clause declares.** **AND THE TWO SIDES OF THAT ONE BUG ARE NAMED HERE BECAUSE THEY
1331
- // ARE ONE CHANGE:** the kernel's row and the store's home entry lost `['a']` (the pair no longer evaluated
1332
- // there), **and `constraints()` answered `address: [["b"]]` because it reads this very entry's
1333
- // `addresses`** — the read and the behaviour disagreed, and the read is the surface's own enumeration.
1334
- //
1335
- // **THE MECHANISM IS THE UNION, AND IT IS FORCED BY THE STORE'S OWN SET POSITION.**
1336
- // `docs/specs/storeroom-held-listener-identity/contract.md §2.2` item 3 makes `listen(h, S2)` after
1337
- // `listen(h, S1)` an ASSIGNMENT that *"destroys `S1` wholly and installs `S2`"*, **so the kernel cannot
1338
- // get an extension by passing only the new set — the set that must reach `store.listen(id, ·)` is
1339
- // `oldSet ∪ newSet`, and the store's assignment then installs exactly that** (`unionAddressSets` above,
1340
- // which states the rule once). **THE PURGE, ITS ORDER AND ITS GUARD ARE UNMOVED** — `CHECK → PURGE → ADD`
1341
- // stands, the purge is still `K-6` at every address the old pair stood at, and the pair's FUNCTION is
1342
- // still OVERWRITTEN and not merged (`D-24`). **WHAT MOVES IS WHICH MEMBERS THE ADD WALKS: the merged set,
1343
- // at the old set's order first**, so `K-1`'s own accumulated-set answer at its last call is the union and
1344
- // the store's assignment installs it whole.
1345
- const extended = unionAddressSets(held.addresses, site.addresses);
1346
- // **STEP 3 — ADD.** The supplied element is installed under **THE SAME IDENTITY**, because the identity now
1347
- // lives in the STORE and is returned with the pair, so the mechanism's change does not move the observable
1348
- // (`(O-3)` item (iv)'s obligation; `(AA-2)`; `contract.md §2.6` item 2).
1349
- // **⟶ AND A REFUSAL HERE HAS ALREADY TAKEN THE PAIR'S TWO ROWS WITH THE PURGE** — `constraintSite`'s check
1350
- // cannot reach the registration-time evaluation, so this is `docs/specs/storeroom-held-listener-identity/contract.md §2.3` item 4's own declared split — **and both
1351
- // are put back BEFORE the refusal crosses, because the second of that clause's two facts is the kernel's to
1352
- // keep: the pair still evaluates and `constraints()` is unmoved** (`restoreHeldPair` above;
1353
- // `constraint-sites.md §4` item 2; `§2.1` item 1). **`restoreHeldPair` READS `held`, WHICH IS UNMOVED ON
1354
- // EVERY REFUSING ARM**: the extension below is written to the entry only after this loop has passed.
1355
- let refusedAt = null;
1356
- try {
1357
- for (let position = 0; position < extended.length; position += 1) {
1358
- // **THE ADDRESS THIS REGISTRATION IS BEING MADE AT IS KEPT FOR THE REFUSAL'S FOURTH MEMBER —
1359
- // `D-77`.** The loop's own index is out of scope in the `catch` below (it is the `for` statement's),
1360
- // so the datum is taken where it stands rather than re-derived there.
1361
- refusedAt = extended[position];
1362
- constraintsKernel().register(instance, extended[position], site.id, constraint);
1363
- }
1364
- } catch (refusal) {
1365
- restoreHeldPair(site.state, instance, held);
1366
- // **`D-77`: the act refused is the registration at THIS address of the pair's own set.**
1367
- registrationCrossing(refusal, refusedAt);
1368
- }
1369
- // **AND THE READ MODEL CARRIES THE UNION, NOT THE CALL'S SET** — this is defect 2's whole fix and it is
1370
- // the other side of the same change: `enumerateConstraints` answers one row per carried pair with this
1371
- // entry's `addresses`, so a pair that evaluates at N addresses must be *reported* at N addresses
1372
- // (`contract.md §2.6` item 5; `PAR-HL-13`). **NO ROW IS ADDED AND NONE IS REMOVED**: the count is still
1373
- // one row per `id` (`D-29` item 2), and the member's type is unmoved.
1374
- held.addresses = extended;
1375
- held.addressKey = addressSetKey(extended);
1376
- held.fn = constraint;
1377
- held.enabled = true;
1378
- // **⟶ AND STEP 3 IS THE RE-ADD: THE SAME PAIR IDENTITY IS WRITTEN BACK UNDER ITS OWN KEY** (`(O-3)`
1379
- // item (iv)'s obligation; `(AA-2)`: *"Move the identity into the store"*). **THE PURGE DELETED THE
1380
- // READ-MODEL ROW AND THE RE-ADD PUTS IT BACK**, so the identity the caller held before the cycle is the
1381
- // identity after it, by VALUE, and the enumeration is unmoved (`contract.md §2.6` items 2–3;
1382
- // `constraint-identity.md §5` `IF-1`).
1383
- site.state.constraints.set(constraintPairKey(held.addresses, held.id), held);
1384
- // **DELIVER → THE ANSWER** (`PIN-2`): the overwrite arm's re-registration delivered at its own passing
1385
- // close, so a fired body's throwable refuses the act here (`PIN-10`; `Q-13`).
1386
- raiseListenerFailure(site.state);
1387
- return held.identity;
1388
- } finally {
1389
- state.registrationDelivery = priorDelivery;
1390
- closeCommit(instance, opened);
1391
- }
1392
- },
1393
- /// `surface.md §2.12` item 2 (a): **`a.constraintOn(pair, constraint) -> undefined`** — the ENABLE half.
1394
- /**
1395
- * **`docs/specs/storeroom-js/surface.md §2.12` ITEM 2 (a): `constraintOn(pair, constraint) -> undefined` / `constraintOff(pair, constraint) ->
1396
- * undefined` — THE TWO HALVES OF THE ONE TOGGLE, AND NEITHER STANDS IN THE KERNEL.**
1397
- *
1398
- * **THEIR THREE ANSWERS, AND THE TWO SHARED CLAUSES:**
1399
- * * **IDEMPOTENT SUCCESS WHERE THE PAIR ALREADY STANDS IN THE STATE IT ASKS FOR** (item 3's first answered
1400
- * question): `undefined`, the pair and its element EXACTLY as they stood, and NOTHING THROWN.
1401
- * * **THE SECOND POSITION IS REQUIRED AND IS A NO-OP ON EVERY SUCCESS** (`item 3`'s `constraintOn` row;
1402
- * `docs/specs/storeroom-js/surface.md §2.4` item 9 (f)'s method table: *"the third position is REQUIRED and is a no-op on success"*): a
1403
- * FUNCTION there is never refused on the pair's ground, the entry NEVER SUBSTITUTES ONE, and it is
1404
- * `entry.fn` — the element the entry carried — that is evaluated at the next write. **CARRIAGE IS
1405
- * PAIR-KEYED AND THE TOGGLE'S OWN ARGUMENTS DO NOT DECIDE IT.**
1406
- * * **AN OUTSIDE `pair` OR A SHORT ARITY TAKES `constraintSite`'s ONE `TypeError`**, and a WELL-FORMED PAIR
1407
- * THE ENTRY DOES NOT CARRY takes `constraintUncarried`'s (`A126`).
1408
- */
1409
- constraintOn(pair, constraint) {
1410
- // **⟶ THE RECEIVER, FIRST AND BEFORE ANY READ OR EDIT** — the guard `addConstraint` now takes, taken
1411
- // here for the same reason and in the same form (`constraintDetached`, `src/entry/constraints.mjs`).
1412
- // **A DETACHED TOGGLE THREW THE CONSTRAINT METHODS' `TypeError` BEFORE THIS LINE EXISTED**, which is
1413
- // neither the surface's one form nor a store code; it now refuses in the seven's one plain form and
1414
- // moves nothing — no `openCommit`, no pair read, no `K-1`.
1415
- constraintDetached(this);
1416
- // **⟶ AND THE DELIVERY'S SET AT THE RE-ARM IS THE REPAIR'S OWN `triggered` TOO — `PIN-6` (ii), `D-125`
1417
- // item `1`.** The re-registration's `K-1` reaches the same registration route and the same passing close, so
1418
- // the channel speaks here for the same reason and reads the same value; **the set is `PIN-6` (ii)'s
1419
- // *"THE STORE'S OWN `triggered`"***, one invocation per distinct handle, after the save and before this
1420
- // act's `undefined`.
1421
- const priorDelivery = state.registrationDelivery;
1422
- state.registrationDelivery = 'triggered';
1423
- state.listenerFailure = null;
1424
- // **⟶ `§4.1`: `constraintOn` OPENS ONE — ENABLING.**
1425
- const opened = openCommit(instance);
1426
- try {
1427
- const verb = 'constraintOn';
1428
- const site = constraintSite(state, verb, arguments.length, pair, constraint);
1429
- const entry = site.state.constraints.get(constraintPairKey(site.addresses, site.id));
1430
- if (entry === undefined) constraintUncarried(verb, pair);
1431
- if (entry.enabled !== true) {
1432
- // **⟶ AND THIS ARM ADDS — `entry.fn`, THE ELEMENT THE ENTRY CARRIED, WHICH IS BEING ENABLED.** **THE
1433
- // RULING'S CLAUSE, AT ITS OWN SITE: *"THE PROPOSAL MUST STATE THAT A TOGGLE AT A PAIR PURGES THE PAIR'S
1434
- // OLD STORE ENTRIES, because that is what `no exceptions` means at this site"*** (`P: docs/pending.md ·
1435
- // (O-3)` item (v), verbatim; `contract.md §2.3` item 7; `constraint-sites.md §1` rows 2–3).
1436
- //
1437
- // **⟶ AMENDED 2026-10-22 (`DEF-2026-10-20-F` landed; the architect's ruling) — THE QUOTED *"it is the
1438
- // same rule for `constraintOn`/`constraintOff`, which reach the same `K-1`: their re-registration is a
1439
- // purge-then-add too, and `constraintParked` is the new element added"* IS NOT TO BE READ AS A RULE ABOUT
1440
- // BOTH ARMS, AND THIS SITE NO LONGER READS IT AS ONE.** **`(O-3)` item (v)'s SUBJECT is *"a constraint
1441
- // written to an existing handle"* — the OVERWRITE/WRITE path, where a body genuinely REPLACES a body.**
1442
- // **THE ENABLE ARM WRITES A BODY AND THUS LEGITIMATELY ADDS ONE — `entry.fn`, because the pair is
1443
- // ENABLED; THE DISABLE ARM WRITES NOTHING, SO IT PURGES ONLY (`remove`) AND ADDS NOTHING** (ground 4;
1444
- // `constraintOff`'s own amended note below). **Item (v)'s shared-route observation is a fact about
1445
- // REACHABILITY — both arms DO reach `K-1` — and not an instruction to add on both.** **AND THE RULED
1446
- // ASYMMETRY AT `§4.1`: this arm brackets at entry (`:4034`) and is table `1`, while `constraintOff`
1447
- // brackets nowhere and is table `2`, so an identical nested `listen` here JOINS an extant commit and
1448
- // there OPENED one from zero — which is why only the disable arm's copy was the defect.** **`constraintParked`
1449
- // IS NOT ADDED BY EITHER TOGGLE: it remains the element a *disabled* pair's registry record carries for
1450
- // ENUMERATION purposes, at `restoreHeldPair`'s refusal wake (`:5597`).**
1451
- //
1452
- // **⟶ AND THE PURGE THIS ARM USED TO TAKE IS GONE WITH THE DISABLE ARM'S REGISTRATION — A CONSEQUENCE THE
1453
- // RULING DID NOT NAME AND THAT IS RECORDED HERE RATHER THAN DISCOVERED LATER.** The `remove` that stood
1454
- // below was `K-6` against the pair's OWN standing row — **the very row the disable arm's `register` used
1455
- // to leave behind. With the register half removed, a DISABLED pair stands NO kernel row at all** (ground
1456
- // 3: `remove` is already the complete act), **so `K-6` refuses `KC-2` — *"no constraint pair answers to
1457
- // …"* — and a re-enable would throw where `surface.md §2.12` item 3's clause 5 declares a toggle. THE
1458
- // PURGE-THEN-ADD SPANS THE TWO HALVES NOW AND NOT ONE ARM:** `constraintOff` purges (its `remove`), and
1459
- // `constraintOn` adds (`entry.fn` through `K-1`), **which is literally *"the old handle's entries are
1460
- // purged before the new one is added"* (`(O-3)` item (i))**. **NOTHING IS UNPURGED BY ITS ABSENCE:** a
1461
- // pair reaching this arm stands no store-side listener, since the only act that could have left one is
1462
- // the disable, which no longer performs it. **AND WHERE ONE DOES STAND — the declared residue of a
1463
- // REFUSED registration, which `restoreHeldPair` below writes back — `K-1`'s own idempotence arm is what
1464
- // answers it** (`kernel-surface.md §2.1` item 1; `CC-7`: *"a second registration under the SAME pair
1465
- // keeps the replaced registration's PLACE and replaces only its function"*), **so the pair is re-added
1466
- // under its own identity either way.**
1467
- //
1468
- // **THE CHECK PRECEDES ALL OF IT, AS AT EVERY HELD-PAIR SITE** (`constraintSite` has already run: the
1469
- // pair's shape, the id, the addresses' domain and the element's class), **and a refusal therefore
1470
- // changes nothing.** **AND THE IDENTITY STANDS THROUGH THE CYCLE — the toggle is a TOGGLE and not a
1471
- // removal** (`constraint-identity.md §3` item 3; `contract.md §5.6`'s `S-ID` family; `IF-5`).
1472
- // **⟶ AND THE REFUSAL WAKE BELOW IS THIS ARM'S AND STAYS: THIS ARM DOES RE-REGISTER A BODY THROUGH
1473
- // `K-1`, so a registration-time refusal is reachable here and its residue is the declared one**
1474
- // (`docs/specs/storeroom-held-listener-identity/contract.md §2.3` item 7; `constraint-sites.md §1` rows
1475
- // 2–3; `§4` item 2; `§2.1` item 1). **⟶ AND IT IS REACHABLE ON THIS ARM AND ON NO ARM OF `constraintOff`**
1476
- // (`DEF-2026-10-20-F` consequence (i): a `remove`-only arm cannot refuse a re-registration, so the disable
1477
- // arm's `try`/`catch` went with its loop — `:4113` onwards).
1478
- let refusedAt = null;
1479
- try {
1480
- for (const address of entry.addresses) {
1481
- // **THE ADDRESS THIS RE-REGISTRATION IS BEING MADE AT, KEPT FOR THE REFUSAL'S FOURTH MEMBER —
1482
- // `D-77`** (the loop's own binding is out of scope in the `catch`).
1483
- refusedAt = address;
1484
- constraintsKernel().register(instance, address, entry.id, entry.fn);
1485
- }
1486
- } catch (refusal) {
1487
- restoreHeldPair(site.state, instance, entry);
1488
- // **`D-77`: the act refused is the re-registration at THIS address.**
1489
- registrationCrossing(refusal, refusedAt);
1490
- }
1491
- entry.enabled = true;
1492
- // **⟶ AND THE PAIR'S STATE ROW STANDS UNDER THE SAME PAIR IDENTITY** (`P: docs/pending.md · (O-3)`
1493
- // item (iv)'s obligation; `(AA-2)`: *"Move the identity into the store"*, preserved *"equal to itself on
1494
- // a second `addConstraint` at the SAME pair"*). **THE TOGGLE IS NOT A REMOVAL, so the pair is carried
1495
- // UNDER THE SAME IDENTITY and the enumeration is unmoved** (`constraint-identity.md §3` item 3;
1496
- // `§5` `IF-5`; `removal-members.md §3` item 3): *"`constraintOff` is a TOGGLE and not a removal: a
1497
- // disabled pair is STILL CARRIED and STILL ENUMERATED"*.
1498
- // **⟶ AMENDED 2026-10-22 (same ruling): this row is not written back *after a purge* — this arm purges
1499
- // nothing now** (see the note above). The pair's record stands as it stood, which is what ``(AA-2)``'s
1500
- // *"equal to itself"* asks for at a re-enable, and the enumeration it feeds is unmoved either way.
1501
- site.state.constraints.set(constraintPairKey(entry.addresses, entry.id), entry);
1502
- }
1503
- // **DELIVER → THE ANSWER** (`PIN-2`): the re-registration's `K-1` delivered at its own passing close, so a
1504
- // fired body's throwable refuses the TOGGLE here and this act never answers (`PIN-10`; `Q-13`; `Q-15`'s
1505
- // *"the toggle refuses; the instance and every other pair stand"*).
1506
- raiseListenerFailure(site.state);
1507
- return undefined;
1508
- } finally {
1509
- state.registrationDelivery = priorDelivery;
1510
- closeCommit(instance, opened);
1511
- }
1512
- },
1513
- /// `surface.md §2.12` item 2 (a): **`a.constraintOff(pair, constraint) -> undefined`** — the DISABLE half.
1514
- constraintOff(pair, constraint) {
1515
- // **⟶ THE RECEIVER, FIRST AND BEFORE ANY READ OR EDIT** — `constraintOn`'s guard beside it, and the
1516
- // reason is the same one: this member reached `K-6` off this factory's closure, so a detached call
1517
- // would purge the pair's store-side entry. **IT REFUSES IN THE SEVEN'S ONE PLAIN FORM AND MOVES
1518
- // NOTHING** (`constraintDetached`, `src/entry/constraints.mjs`).
1519
- constraintDetached(this);
1520
- const verb = 'constraintOff';
1521
- const site = constraintSite(state, verb, arguments.length, pair, constraint);
1522
- const entry = site.state.constraints.get(constraintPairKey(site.addresses, site.id));
1523
- if (entry === undefined) constraintUncarried(verb, pair);
1524
- if (entry.enabled !== false) {
1525
- // **THE CHECK PRECEDES IT, AS AT EVERY HELD-PAIR SITE** (`constraintSite` has already run: the pair's
1526
- // shape, the id, the addresses' domain and the element's class), **and a refusal therefore purges
1527
- // nothing.** **AND THE IDENTITY STANDS THROUGH THE CYCLE — `constraintOff` is a TOGGLE and not a
1528
- // removal** (`constraint-identity.md §3` item 3; `contract.md §5.6`'s `S-ID` family; `IF-5`).
1529
- //
1530
- // **⟶ AMENDED 2026-10-22 (`DEF-2026-10-20-F` landed; the architect's ruling at the store/kernel code
1531
- // review) — THE DISABLE ARM PURGES ONLY (`remove`), AND ADDS NOTHING.** This block read *"THE TOGGLE IS A
1532
- // PURGE-THEN-ADD TOO"*, on the ground that `(O-3)` item (v) applies *"the same rule for
1533
- // `constraintOn`/`constraintOff`, which reach the same `K-1`"*. **THAT READING IS SUPERSEDED BY THE
1534
- // RULING, WHICH IS VERBATIM: *"Remove the register half, `constraintOff` removes the constraint."***
1535
- // **`(O-3)` item (v)'s SUBJECT is *"a constraint written to an existing handle"* — the OVERWRITE/WRITE
1536
- // path, where a body genuinely REPLACES a body — AND THE DISABLE ARM WRITES NOTHING**, so it has nothing
1537
- // to add; item (v)'s shared-route observation is a fact about REACHABILITY and not an instruction to add
1538
- // on both arms (`DEF-2026-10-20-F` ground 4; `docs/defects.md`).
1539
- //
1540
- // **SO THE RULED FORM IS ONE ACT: `remove` (`K-6`), WHICH IS ALREADY THE COMPLETE ACT** (ground 3;
1541
- // `contract.md §2.9` items 2–3). **THE PAIR'S IDENTITY AND ITS ENUMERATION SURVIVE THROUGH
1542
- // `entry.enabled = false` AND THE STATE ROW BELOW — NOT THROUGH A STORE-SIDE LISTENER.** **THE DELETED
1543
- // `register` LOOP WAS A DEFECT AND NOT A MANDATED BEHAVIOUR, ON THE RULING'S OWN MEASUREMENT:**
1544
- // `constraintParked` is a fresh `() => true` (`:5514`), so the arm stood a body that PASSES ALWAYS in
1545
- // the store's address slot for a disabled pair — **the mask is a passing function rather than an absent
1546
- // one** — and `K-1` calls `store.listen(home, set)` UNCONDITIONALLY (`constraint-kernel.mjs:561`), **so a
1547
- // table-`1` BRACKETING act happened inside a table-`2` verb's window**, falsifying
1548
- // `finalizer-and-teardown.md §4.1` table `2`'s *"disabling cannot fire — nothing runs"* at the mechanism
1549
- // level (grounds 1–2). **THE ASYMMETRY THAT MADE IT BITE:** `constraintOn` brackets at entry (`:4034`),
1550
- // so its identical nested `listen` FINDS AN EXTANT COMMIT AND JOINS IT, while `constraintOff` takes none
1551
- // and the same call OPENED FROM ZERO. **THE WITNESS IS `addon-adoption.test.mjs`'s COUNT WALK OVER ALL
1552
- // THIRTEEN VERBS** (`test-cases.md` `F-8`), which is GREEN after this note and was RED before it.
1553
- //
1554
- // **AND `DEF-2026-10-20-F`'S CONSEQUENCE (i) IS SETTLED HERE — THE `try`/`catch` GOES WITH THE LOOP, it
1555
- // is not kept as declared silence.** `restoreHeldPair`'s refusal wake is UNREACHABLE on this arm, because
1556
- // **a `remove`-only arm cannot refuse a re-registration**; a `catch` left standing over an act the arm no
1557
- // longer performs would claim to guard a body nothing can reach. **The one act that remains opens no
1558
- // commit and reaches no `K-1`**, so there is no residue for a wake to put back. **`constraintParked`
1559
- // REMAINS (`:5514`) AS THE ELEMENT A *DISABLED* PAIR'S REGISTRY RECORD CARRIES FOR ENUMERATION PURPOSES
1560
- // — its one remaining registration site is `restoreHeldPair`'s refusal wake (`:5597`) — AND IT IS NO
1561
- // LONGER REGISTERED AS A STORE LISTENER BY THIS ARM, NOR BY ANY SUCCESSFUL DISABLE.**
1562
- constraintsKernel().remove(instance, { address: entry.addresses, id: entry.id });
1563
- entry.enabled = false;
1564
- // **⟶ AND THE PAIR'S STATE ROW IS WRITTEN BACK UNDER THE SAME PAIR IDENTITY** (`P: docs/pending.md ·
1565
- // (O-3)` item (iv)'s obligation; `(AA-2)`: *"Move the identity into the store"*, preserved *"equal to
1566
- // itself on a second `addConstraint` at the SAME pair"*). **THE TOGGLE IS NOT A REMOVAL, so the row
1567
- // `K-6`'s `FORGET_PAIR` took is restored UNDER THE SAME IDENTITY and the enumeration is unmoved**
1568
- // (`constraint-identity.md §3` item 3; `§5` `IF-5`; `removal-members.md §3` item 3): *"`constraintOff` is
1569
- // a TOGGLE and not a removal: a disabled pair is STILL CARRIED and STILL ENUMERATED"*.
1570
- // **⟶ AMENDED 2026-10-22 (`DEF-2026-10-20-F` consequence (ii), same ruling): THIS WRITE-BACK IS THE
1571
- // WHOLE OF WHAT IS RESTORED, AND IT IS A *REGISTRY* RESTORATION AND NOT A RE-ADD OF A BODY.** **What a
1572
- // disabled pair must retain is its IDENTITY and its ENUMERATION — a registry fact — and this row beside
1573
- // `entry.enabled = false` above satisfies exactly that** (ground 3). **`enumerateConstraints` does not
1574
- // consult `enabled` at all**, so the pair keeps appearing in `constraints()` with no store-side listener
1575
- // anywhere (`:5653`; `surface.md §2.12` item 3 clause 5).
1576
- site.state.constraints.set(constraintPairKey(entry.addresses, entry.id), entry);
1577
- }
1578
- return undefined;
1579
- },
1580
- /// **`surface.md §2.4` item 9 (f)'s `constraints` clause of 2026-10-17: `a.constraints() -> Array<{ address,
1581
- /// id }>` — THE REGISTERED-PAIR READ, the thirteenth own member (`10 + 1 + 1 + 1 = 13` ✓; `PAR-JS-27`;
1582
- /// `docs/specs/storeroom-js/surface.md §2.12` item 2-bis).** **THE RECEIVER IS THE STORE, THE CALL TAKES NO ARGUMENT (arity `0`) AND IT
1583
- /// THROWS NOTHING** — there is no outside argument for the class test to refuse, and the call makes no
1584
- /// store call, mints no code, appends no journal entry and changes no node. **It is NOT a named export of
1585
- /// the entry** (`package.md §1.3` item 3; `docs/specs/storeroom-js/surface.md §2.9` item 1's `A127` clause, `11 → 1` ✓): it is reached
1586
- /// through the factory's own product alone.
1587
- constraints() {
1588
- return enumerateConstraints(state);
1589
- },
1590
- // ⟶ MOVED 2026-10-18 (`RCA-8(g)`, gate-4 finding F-2): the wrapper's duplicate `removeListener` header stood here, above the free function's own doc block that `P-8` moved in below. Bytes: archive/p8-merge/2026-10-18/post-gate4/removeListener-wrapper-header.md. `contract.md §2.7` item 9 is the operative member set.
1591
- /// **⟶ `removeListener(handle) -> undefined` — THE FIRST OF THE TWO NEW MEMBERS**
1592
- /// (`contract.md §2.7` items 1–2; `removal-members.md §2`; `P: docs/pending.md · P-5`'s explicit-delete ruling).
1593
- ///
1594
- /// **IT REMOVES THE ENTRY WHOLE AND WITHDRAWS THE STORE'S HOME ENTRIES THE HANDLE NAMED** — *"IT REMOVES THE
1595
- /// ENTRY WHOLE AND WITHDRAWS THE STORE'S HOME ENTRIES THE HANDLE NAMED"* — and **it is the ONLY route that
1596
- /// removes an entry** (`contract.md §2.2` item 5 (c)). **NO `unlisten` IS ISSUED AND NO SEPARATE WITHDRAWAL
1597
- /// VERB IS REACHED: the removal IS the purge, and the map entry's deletion follows it** (`removal-members.md
1598
- /// §2` item 3).
1599
- ///
1600
- /// **SUCCESS IS THE NORMAL RETURN (`undefined`) AND THE FAIL IS THE THROW** (`P: docs/pending.md · P-5`'s
1601
- /// `(R3)`, verbatim) — **and the throw is the DECLARED REVERSAL of `unlisten`'s no-op-success set**: every arm
1602
- /// that is not a real removal FAILS, with a verbose message (`(R2)`, verbatim; `contract.md §2.7` item 5).
1603
- /// **A REFUSAL CHANGES NOTHING**: all four structures stand as they stood (`removal-members.md §5`
1604
- /// obligation (iii)).
1605
- ///
1606
- /// **AND IT IS NOT A PUBLIC MEMBER YET** — the product's own member set is where it is declared
1607
- /// (`contract.md §2.7` item 9); this is its body, and the member is added below with the surface.
1608
- /// **⟶ CORRECTED 2026-10-18 (`P-8` landed): the sentence above is SUPERSEDED — `removeListener` IS a public member of this object as of this date (`bindings/js/index.mjs`'s member list; `contract.md §2.7` item 9: the set is `14`), so *"added below with the surface"* describes a state that no longer holds.** **The dissolved claim is recorded, not silently dropped, because it was theory-of-record when the free function's body was authored.**
1609
- removeListener(handle) {
1610
- // **THE CLASS TEST IS THE SURFACE'S ONE THROWN FORM WITH `status` THE STORE'S `AddressMalformed`**
1611
- // (`removal-members.md §6` item 1; `R-B4`, verbatim: *"`AddressMalformed` — the instance's domain is the
1612
- // domain"*, so *"a present argument outside its domain"* is read as *"outside THIS INSTANCE'S domain"*).
1613
- // **A WELL-FORMED STRING THE MAP DOES NOT CARRY IS THAT SAME ARM — the fabricated row** — and so is an
1614
- // already-deleted handle (`contract.md §2.1` item 5's fourth column).
1615
- if (!inDomainHandle(handle)) {
1616
- boundaryReject(
1617
- 'AddressMalformed',
1618
- targetSpelling(handle),
1619
- `removeListener's first argument is ${classSpelling(handle)}, and a listener's handle is a non-empty `
1620
- + 'string this caller spells',
1621
- );
1622
- }
1623
- if (!state.registry.has(handle)) {
1624
- boundaryReject(
1625
- 'AddressMalformed',
1626
- targetSpelling(handle),
1627
- `removeListener's first argument is '${handle}', and this instance holds no listener entry for it`,
1628
- );
1629
- }
1630
- // ── THE SUCCESS ARM: THE ENTRY GONE WHOLE AND THE STORE'S ENTRIES WITHDRAWN ────────────────────────────
1631
- // **THE ORDER IS THE FOUR REMOVALS' (`removal-members.md §4` item 2's `HL-DD-4`), read for a listener:**
1632
- // (1) validate — above; (2) withdraw the store's home entries the handle named — through the store's own
1633
- // purge; (3) delete the JS entry; (4) return `undefined`.
1634
- carryRefusal(() => entryOf().removeListener.call(this, handleWire(handle)), [handleWire(handle)]);
1635
- state.registry.delete(handle);
1636
- state.home = state.home.filter((row) => row.handle !== handle);
1637
- return undefined;
1638
- },
1639
- /// **⟶ `removeConstraint(pair) -> undefined` — THE SECOND OF THE TWO NEW MEMBERS**
1640
- /// (`contract.md §2.7` item 3; `removal-members.md §3`; `P: docs/pending.md · P-5`'s `(R4)`, verbatim:
1641
- /// *"removeConstraint REMOVES EVERYTHING — THE PAIR, ALL N ADDRESS ROWS, THE KERNEL'S REGISTRATION, AND THE
1642
- /// STORE-SIDE HOME ENTRY"*).
1643
- ///
1644
- /// **IT IS A THIRD AND STRONGER OPERATION**: neither `constraintOff` (a TOGGLE that PURGES ONLY and keeps the
1645
- /// pair CARRIED and ENUMERATED through its state row and `entry.enabled = false`) nor the kernel's
1646
- /// `withdrawRegistration` (which leaves the store's home entry standing). **AND IT IS THE ONE ACT THAT DELETES
1647
- /// AN IDENTITY** (`contract.md §2.6` item 3; `P: docs/pending.md · (AA-2)`, closing sentence).
1648
- /// **⟶ AMENDED 2026-10-22 (`DEF-2026-10-20-F` landed; the architect's ruling): the parenthetical above read
1649
- /// *"a TOGGLE re-registering a parked stub and keeping the pair carried"*. THAT IS SUPERSEDED — the disable
1650
- /// arm registers NOTHING** (a `remove`-only arm; `constraintOff`'s own amended note). **The DISTINCTION this
1651
- /// clause draws is unmoved: `constraintOff` keeps the pair's IDENTITY and its ENUMERATION and `removeConstraint`
1652
- /// DELETES them, and what the disable arm no longer does is stand a `constraintParked` body in the store's
1653
- /// address slot — which was never what made the pair carried.**
1654
- ///
1655
- /// **THE ORDER OF THE FOUR REMOVALS IS THIS CONTRACT'S DECLARED `HL-DD-4`** (`removal-members.md §4` item 2):
1656
- /// **(1) VALIDATE the pair and the call's class; (2) WITHDRAW the store's home entries the pair's addresses
1657
- /// hold, through `K-6`'s route; (3) DELETE the kernel's `pairs` row and its N address rows; (4) DELETE the JS
1658
- /// ENTRY — `state.constraints`'s value, its identity included; (5) RETURN `undefined`.**
1659
- /// **NO INTERMEDIATE STATE IS OBSERVABLE**: after any thrown arm the four structures stand as they stood, and
1660
- /// after the success return all four are gone (`removal-members.md §4` item 4).
1661
- ///
1662
- /// **AND THE TWO REFUSAL FORMS ARE TOLD APART BY `status`'s PRESENCE AND NOTHING ELSE**: a PAIR-SHAPED
1663
- /// outside value takes the constraint methods' `TypeError` with `status` ABSENT (`removal-members.md §6`
1664
- /// item 2; `contract.md §2.7` item 6), while a WELL-FORMED pair this instance holds no row for takes the
1665
- /// remove member's own thrown form with a verbose message (`contract.md §2.7` item 5; `removal-members.md §5`
1666
- /// row 1).
1667
- removeConstraint(pair) {
1668
- // ═════════════════════════════════════════════════════════════════════════════════════════════════
1669
- // **⟶ THE RECEIVER IS CONSULTED FIRST — A DETACHED `removeConstraint` DELETED A STANDING PAIR BEFORE
1670
- // THIS LINE EXISTED** (measured 2026-10-26; `docs/guides/package-use.md §12.2): the pair's row left
1671
- // `state.constraints`, its store-side entry was purged through `K-6`, and the call answered
1672
- // `undefined`. **THE GUARD IS THE SEVEN STORE-REACHING VERBS' OWN AND ITS FORM IS THEIRS BYTE FOR BYTE**
1673
- // (`constraintDetached`, `src/entry/constraints.mjs`) — **and it is taken BEFORE step 1's position
1674
- // tests, which is what makes the atomicity of a refused call its POSITION and not its care.**
1675
- // ═════════════════════════════════════════════════════════════════════════════════════════════════
1676
- constraintDetached(this);
1677
- // ── STEP 1: VALIDATE. ────────────────────────────────────────────────────────────────────────────────
1678
- // **⟶ THIS BLOCK IS `removeConstraint`'S OWN, AND THE SENTENCE BELOW IS A CONTINUATION OF ITS SUBJECT:
1679
- // ONE POSITION, THE PAIR — ITS `address` READ AT THE TWO DECLARED SPELLINGS AND AT NO THIRD** (`contract.md
1680
- // §2.7` item 3; `PAR-HL-16`; `constraint-identity.md §6`'s pair table).
1681
- // **THE PAIR'S SHAPE TEST IS THE CONSTRAINT METHODS' OWN — ONE THROWN `TypeError`, `status` ABSENT, the
1682
- // call changing nothing** (`surface.md:1063` rule (ii), which governs *"THE THREE CONSTRAINT METHODS' EVERY
1683
- // OUTSIDE VALUE"*; `contract.md §2.7` item 6; `constraint-sites.md §6` item 2). **IT IS TAKEN HERE RATHER
1684
- // THAN THROUGH `constraintSite` BECAUSE THIS MEMBER HAS NO `constraint` POSITION** — its arity is ONE
1685
- // (`removal-members.md §3` item 1; `PAR-HL-16`).
1686
- if (arguments.length < 1 || !isPlainObjectValue(pair) || !Object.hasOwn(pair, 'address') || pair.address === undefined) {
1687
- constraintRefuse(`${ARGUMENT_POSITION_FIRST} of \`removeConstraint\``, pair);
1688
- }
1689
- // **THE PAIR'S `address` IS READ AT THE TWO SPELLINGS THE CONTRACT DECLARES FOR THE CONSTRAINT'S PAIR AND
1690
- // AT NO THIRD** (`constraint-identity.md §6`'s pair table, verbatim: *"`address`: THE ADDRESS SET the pair
1691
- // was created with (`§4` item 3) — and, at the REGISTRATION act, a single address"*; `PAR-HL-8`;
1692
- // `PAR-HL-16`).
1693
- //
1694
- // **⟶ AND THE OUTSIDE SET THIS POSITION REFUSES IS `PAR-HL-8`'S OWN EIGHT ROWS AND NO NINTH**, because
1695
- // `PAR-HL-16`'s outside cell is *"every shape row of `PAR-HL-8`'s outside list, PLUS a well-formed pair the
1696
- // entry does not carry"*: a non-object · a `null` · an object carrying no `address` · **an `address` outside
1697
- // the store's domain** · an object carrying no `id` · a non-string `id` · an empty-string `id` · an ABSENT
1698
- // pair. **THE DISCRIMINATOR IS THE MEMBER'S CLASS, READ ONCE** — an array whose FIRST member is an array is
1699
- // the pair's SET; an array whose members are segments is the REGISTRATION ACT'S OWN single address. **THE
1700
- // SECOND IS NOT `listen`'S REFUSED SET-POSITION CLASS** (`listen-verb.md §2.2` item 2 (vi)) **BUT THE
1701
- // REGISTRATION FORM THIS PAIR WAS CREATED WITH**: the pair the caller hands to `removeConstraint` is the
1702
- // pair it handed to `addConstraint`, and `addConstraint` admits that spelling (`PAR-HL-8`'s domain read with
1703
- // `constraint-identity.md §6`'s registration clause) — so refusing it here would make a pair the caller
1704
- // added unremovable, which `contract.md §3` `S-12` forbids.
1705
- //
1706
- // **AND AN ADDRESS OUTSIDE THE STORE'S DOMAIN IS THIS POSITION'S OUTSIDE VALUE, ANSWERED BY RULE (ii)'s
1707
- // `TypeError`** (`contract.md §4` `F-7`; `removal-members.md §6` item 2: *"the constraint methods' `TypeError`,
1708
- // `status` ABSENT"* — never the store's form, and never a raw host value), which is the SAME class of answer
1709
- // `constraintSite` gives that value at the three constraint methods.
1710
- const addresses = [];
1711
- if (!isAdmittedArray(pair.address)) {
1712
- constraintRefuse(`${ARGUMENT_POSITION_FIRST} of \`removeConstraint\``, pair);
1713
- }
1714
- if (pair.address.length > 0 && Array.isArray(pair.address[0])) {
1715
- for (let i = 0; i < pair.address.length; i += 1) {
1716
- const each = isAdmittedArray(pair.address[i]) ? constraintAddress(pair.address[i]) : null;
1717
- if (each === null || typeof each === 'string') {
1718
- constraintRefuse(`${ARGUMENT_POSITION_FIRST} of \`removeConstraint\``, pair);
1719
- }
1720
- appendOwn(addresses, each.s);
1721
- }
1722
- } else {
1723
- const each = constraintAddress(pair.address);
1724
- if (typeof each === 'string') {
1725
- constraintRefuse(`${ARGUMENT_POSITION_FIRST} of \`removeConstraint\``, pair);
1726
- }
1727
- appendOwn(addresses, each.s);
1728
- }
1729
- if (!Object.hasOwn(pair, 'id')
1730
- || pair.id === undefined
1731
- || typeof pair.id !== 'string'
1732
- || pair.id === '') {
1733
- constraintRefuse(`${ARGUMENT_POSITION_FIRST} of \`removeConstraint\``, pair);
1734
- }
1735
- const entry = state.constraints.get(constraintPairKey(addresses, pair.id));
1736
- if (entry === undefined) {
1737
- // **A WELL-FORMED PAIR THIS INSTANCE HOLDS NO ROW FOR IS A THROW WITH A VERBOSE MESSAGE — and NOT a class
1738
- // refusal**, because the value is inside every class domain and it is the ROW that is absent
1739
- // (`contract.md §4` `F-8`; `removal-members.md §5` row 1: *"names the value and the reason"*).
1740
- throw withEmptyLog(new TypeError(
1741
- `the pair at the ${ARGUMENT_POSITION_FIRST} of \`removeConstraint\` is '${pair.id}' at `
1742
- + `${JSON.stringify(addresses)}, and this instance holds no constraint pair there`,
1743
- ));
1744
- }
1745
- // ── STEP 2–3: THE KERNEL'S ROW, ITS N ADDRESS ROWS, AND THE STORE'S HOME ENTRIES, THROUGH `K-6`. ─────
1746
- // **THE CHAIN IS `removeConstraint → K-6 → removeListener → the store's purge`, AND IT HAS NO CYCLE**
1747
- // (`contract.md §2.9` item 6; `remove-member.md §6` item 1). **`K-6`'S STORE-SIDE REFUSAL CROSSES
1748
- // UNCONVERTED** (`contract.md §4` `F-13`), so this frame converts nothing.
1749
- // **⟶ AMENDED 2026-10-22 (`DEF-2026-10-20-F` landed; the architect's ruling) — THE WITHDRAWAL IS REACHED
1750
- // WHERE A REGISTRATION STANDS, AND IT IS THIS ACT'S OWN TWO FACTS THAT MAKE THAT THE WHOLE OF THE DECLARED
1751
- // ANSWER.** **A DISABLED PAIR IS STILL CARRIED and this member is *"THE ONE ACT THAT DELETES AN
1752
- // IDENTITY"*** (`contract.md §2.6` item 3; `docs/specs/storeroom-js/surface.md §2.12` item 3 clause 5:
1753
- // *"the toggle is NOT a removal"*) — **so it MUST still succeed at a pair the disable left standing, and
1754
- // `K-6` CANNOT BE ITS ROUTE THERE: the disable arm purges only, so no kernel row survives it to be found,
1755
- // and `K-6` refuses `KC-2` for a pair it holds no row for** (`contract.md §4` `F-12`). **THE PURGE IS
1756
- // THEREFORE GUARDED BY THE PAIR'S OWN POLARITY** (`withdrawStanding` below: `enabled === true` is exactly
1757
- // *"a registration stands to be withdrawn"*), **and steps 3–4 — the address rows and the JS entry, its
1758
- // IDENTITY included — are taken exactly as declared**: with no row there is nothing for step 3 to delete,
1759
- // and step 4 deletes the entry and its identity either way. **A DISABLED PAIR'S REMOVAL IS THEREFORE A
1760
- // COMPLETE REMOVAL, and `removeConstraint` keeps its declared answer at every pair it can name.**
1761
- withdrawStanding(instance, entry);
1762
- // ── STEP 4: THE JS ENTRY, ITS IDENTITY INCLUDED. ─────────────────────────────────────────────────────
1763
- state.constraints.delete(constraintPairKey(entry.addresses, entry.id));
1764
- return undefined;
1765
- },
1766
- /// `surface.md §2.4` item 5 (b): `register(handle, listener) -> undefined` — the OPAQUE handle a verb
1767
- /// returned or the construction adopted, and ANY JS function. **It is NOT a named export of the entry**
1768
- /// (`package.md §1.3` item 3): it is reached through the factory's own product alone.
1769
- register(handle, listener) {
1770
- return registerOn(state, handle, listener);
1771
- },
1772
- /// **⟶ `settle` IS REMOVED FROM THIS PRODUCT, 2026-10-18 — THE MEMBER SET IS TWELVE, `10 + 1 + 1 = 12`
1773
- /// ✓** (`surface.md §2.4` item 9's `REMOVED-WHOLE` pointer and item 9 (f)'s clause of that date). **THE
1774
- /// ARCHITECT'S RULING, VERBATIM: *"Settle is redundant because the kernel is always in the loop."*** **NO
1775
- /// DRIVE MAY ASSERT A CALL OF IT FROM THIS DATE, ON ANY INSTANCE, FOR ANY ARGUMENT**: the member is not a
1776
- /// member of the product, so a call reaches a property no clause of this unit declares. **AND THE DELIVERY
1777
- /// IT ONCE MARSHALLED IS NOT LOST WITH IT**: it was never `settle`'s — it is `docs/specs/storeroom-js/surface.md §2.7` item `7`'s
1778
- /// terminal-arm act, taken inside the kernel's own act, and this entry PERFORMS the one the kernel
1779
- /// triggers. **The one member this factory does NOT expose and the kernel does NOT call from here.**
1780
- ///
1781
- /// **⟶ AND THE CHANNEL THAT MEMBER WAS IS REPLACED BY A SYMBOL-KEYED PROPERTY, NOT BY A NAMED MEMBER**
1782
- /// (`TERMINAL_ARM` above): the kernel still reaches this entry at its terminal arm, and **the product's
1783
- /// declared fourteen own members are UNMOVED** (`⟶ CORRECTED 2026-10-26`: this line printed `twelve`, the
1784
- /// figure the `12 → 14` move of the held-listener-identity unit superseded on 2026-10-19; the operative
1785
- /// figure is `index.d.ts`'s `StoreInstance` and `surface.md §2.4` item 9 (f)) because a symbol key is
1786
- /// invisible to `Object.keys` and to `Object.getOwnPropertyNames` — the precedent `A117` (D6) declares and `docs/specs/storeroom-js/surface.md §2.11` clause 9 prints
1787
- /// (*"a symbol-keyed own property is invisible to both"*). **IT IS NOT A MEMBER OF THE PRODUCT IN THE
1788
- /// SENSE `docs/specs/storeroom-js/surface.md §2.4` item 9 (f) COUNTS**, and no cell that counts members can see it.
1789
- [TERMINAL_ARM](record) {
1790
- return terminalArm(state, record);
1791
- },
1792
- /// **`K-6`'s READ-MODEL CHANNEL** (`FORGET_PAIR` above): the kernel's own removal drops the pair's row
1793
- /// from `state.constraints` after its own rows and the store's entries are gone, so the success arm leaves
1794
- /// the enumeration short by one (`contract.md §3` `S-19`; `docs/specs/storeroom-held-listener-identity/contract.md §2.7` item 8). **NO MEMBER IS ADDED** to the
1795
- /// product's declared fourteen — a symbol key is invisible to both enumerations (`A117` (D6)).
1796
- [FORGET_PAIR](id) {
1797
- for (const [key, entry] of state.constraints) {
1798
- if (entry.id === id) state.constraints.delete(key);
1799
- }
1800
- return undefined;
1801
- },
1802
- };
1803
- INSTANCES.set(instance, state);
1804
- // ═════════════════════════════════════════════════════════════════════════════════════════════════════
1805
- // THE RECEIVER'S OWN PUBLICATION — `receiver-and-refusal.md §1` AND THE TABLE'S RETIREMENT (`§6`; `OWED-2`)
1806
- //
1807
- // **THE STRUCTURE CHOSEN, AND WHY** (`contract.md §7` leaves the table's FORM and its RETIREMENT MECHANISM
1808
- // `OWED`; the requirement is decided and `P-SAS-5` drives it). **TWO PIECES, EACH NAMED FOR THE JOB IT DOES:**
1809
- //
1810
- // 1. **`STORE_INDEX` — A NON-ENUMERABLE OWN PROPERTY CARRYING THE INTEGER `storeCreate` MINTED.** It is
1811
- // the row the addon's own `instance_of` reads: element `0` of the receiver, read as a number. **A
1812
- // NON-ENUMERABLE OWN PROPERTY IS THE FORM CHOSEN BECAUSE IT IS INVISIBLE TO `Object.keys` AND TO
1813
- // `Object.getOwnPropertyNames`** — the same precedent `A117` (D6) declares for the symbol-keyed
1814
- // channels above — **so the product's declared member set is UNMOVED at fourteen** (`surface.md §2.4`
1815
- // item 9 (f); `⟶ CORRECTED 2026-10-26`: this line printed `twelve`, superseded by the held-listener-
1816
- // identity unit's `12 → 14` move of 2026-10-19) and no member-counting cell can see it. **AND A CLONED
1817
- // STORE OBJECT DOES NOT CARRY THE ROW** (`⟶ CORRECTED 2026-10-26`: this clause opened *"AND IT IS THE
1818
- // ROW A CLONED STORE OBJECT CARRIES TOO"*, which contradicted its own ground and its own conclusion),
1819
- // because `Object.assign`/spread copy own ENUMERABLE properties only and this row is published at
1820
- // `enumerable: false`: **a clone carries NO index and therefore resolves NO store**, which is the SAME
1821
- // one observable the detached call gets.
1822
- //
1823
- // 2. **A `FinalizationRegistry` REGISTERED ON THE STORE OBJECT, WHOSE CALLBACK RETIRES EXACTLY THAT
1824
- // OBJECT'S OWN ROW.** `§6`: *"the retirement removes EXACTLY ONE ENTRY — the freed instance's own —
1825
- // and NEVER THE TABLE."* The held value is the index ALONE and never the object (a strong reference
1826
- // would be the collection this mechanism exists to observe), and the callback removes THE ONE ROW THAT
1827
- // INDEX NAMES — so **a second store's entry cannot be touched**, which is the failure `P-SAS-5` names.
1828
- // **IT IS `FinalizationRegistry` RATHER THAN A NODE-API FINALIZER** because the store object is the
1829
- // package's own and the teardown must not race the sibling unit's declared mechanism (`§5`'s
1830
- // withdrawal of a `WeakMap` is about the RESOLUTION ROUTE and forbids no table).
1831
- //
1832
- // **AND A CALL ON A COLLECTED STORE NEEDS NO SECOND ARM**: once the row is retired the addon's
1833
- // `INSTANCE_IDS` no longer holds the index, so the call refuses in THE ONE DECLARED FORM — the same
1834
- // observable a detached call gets (`§3`: *"There is no second arm and no second observable."*)
1835
- // ═════════════════════════════════════════════════════════════════════════════════════════════════════
1836
- // **THE CARRIER IS A SYMBOL KEY AND NOTHING ELSE, AND THAT IS FORCED RATHER THAN PREFERRED.** The addon
1837
- // reads this row through `Symbol.for('provident-storeroom.storeIndex')` (`receiver-and-refusal.md §1`),
1838
- // and **a symbol key is the only form the clause's carrier may take**: the product's declared member set
1839
- // is asserted at EXACTLY fourteen own members read through `Object.getOwnPropertyNames`
1840
- // (`surface.md §2.4` item 9 (f)), and **that read COUNTS a string key AND a numeric index alike** — so
1841
- // publishing the row at element `0` moved the set `14 → 15`, which is `convenience.test.mjs`'s cell and
1842
- // is not this unit's to change. **A SYMBOL KEY IS INVISIBLE TO `Object.keys` AND TO
1843
- // `Object.getOwnPropertyNames` BOTH**, the precedent `A117` (D6) already declares for this package's own
1844
- // symbol-keyed channels, so the member set is unmoved and the cell is green on a correct landing.
1845
- //
1846
- // **AND IT IS `Symbol.for` RATHER THAN AN IDENTITY SYMBOL BECAUSE THE TWO SIDES NEVER SHARE AN OBJECT**:
1847
- // this file writes the key and the Rust layer reads it, and a registered symbol is the only spelling both
1848
- // can name without one holding the other's reference. **⟶ CORRECTED 2026-10-25 (`strata` L1 e2e pass,
1849
- // `role_test_writer`): this sentence read *"a cloned store object STILL CARRIES IT (a symbol-keyed own
1850
- // property survives `Object.assign` and spread), so a clone resolves the SAME store"* — AND IT IS FALSE OF
1851
- // BOTH HALVES. The row is published by the `Object.defineProperty` below at `enumerable: false`, and
1852
- // `Object.assign` and object spread copy OWN ENUMERABLE properties ONLY: SO A CLONE CARRIES NO INDEX AND
1853
- // NO SLOT, AND A CLONE RESOLVES NO STORE.** **That is the SAME one observable a detached call gets, which
1854
- // is what item 1 of this block already declares above (`:1233`).** **The reading this sentence cited
1855
- // (`receiver-and-refusal.md §5` — *"a deliberately re-bound receiver is still a receiver"*) governs a
1856
- // RE-BOUND receiver that still carries the row, and it never governed a CLONE, which carries nothing to
1857
- // re-bind: the receiver names the store and rebinding is unsupported breaking behaviour the package owes
1858
- // no guard for.**
1859
- Object.defineProperty(instance, STORE_INDEX, { value: id, enumerable: false, writable: false, configurable: false });
1860
- state.receiver = instance;
1861
- // **THE ROW IS REGISTERED FOR RETIREMENT IN THE SAME ACT THAT PUBLISHES IT**, so a store cannot be
1862
- // published without a retirement and the two cannot drift (`§6`: *"retired in the same act that frees the
1863
- // store"*). **THE CALLBACK IS PER-CONSTRUCTION AND CLOSES OVER THIS INSTANCE'S OWN INDEX ALONE** — it takes
1864
- // no scan, names no other row, and cannot reach the table as a whole, which is the requirement `§6` states
1865
- // and the failure `P-SAS-5` catches. **NO REFERENCE TO THE STORE OBJECT IS HELD** (it would be the strong
1866
- // reference that stops the collection this exists to observe): the closure holds the integer and nothing
1867
- // else, and the package's own hold on the instance is released with it.
1868
- STORE_RETIREMENT.register(instance, () => {
1869
- INSTANCES.delete(instance);
1870
- });
1871
- // ═════════════════════════════════════════════════════════════════════════════════════════════════════
1872
- // **⟶ AND `D-99`'S INTERNAL ROUTE, INSTALLED HERE AND NOT WITH THE OTHER TWO CHANNELS — 2026-11-01
1873
- // (`C-17` (iv), §9.2).** **THE INSTALL SITE IS `state.receiver = instance`'S NEIGHBOURHOOD AND NOT `:1693`'S,
1874
- // AND THE REASON IS A BYTE: THE CONSTRUCTION'S BATCH ARMING WALK BELOW REACHES `K-1` BEFORE
1875
- // `installRegistrationSeam` RUNS**, so a channel installed there would leave the construction's own arming walk
1876
- // as **the one kernel registration still passing through the caller's wrapper** — i.e. still through `B-6`,
1877
- // which is the test `D-99`'s ANSWERED clause says the kernel's act does not pass at all.
1878
- //
1879
- // **THE LATER SITE'S PRINTED REASON DOES NOT REACH THIS CHANNEL**: `installAttemptSeam` is installed after the
1880
- // batch *"so a `listen` the construction itself performs is not counted as a commit the caller opened"* — **a
1881
- // fact about the ATTEMPT COUNT, and this route opens no commit** (`C-17` (v)).
1882
- //
1883
- // **IT CHANGES NO ORDER OF ACTS**: the batch still arms `cfg.constraints` first and `cfg.listeners` are still
1884
- // applied afterwards through `listen` (`C-15`, unmoved), because installing a channel is not an act. **AND THE
1885
- // CHANNEL ADDS NO MEMBER** — `Symbol.for`-keyed and `enumerable: false`, so the product's declared FOURTEEN own
1886
- // members are unmoved (`A117` (D6)), exactly as the channels beside it.
1887
- // ═════════════════════════════════════════════════════════════════════════════════════════════════════
1888
- installListenRoute(instance, state);
1889
- // ═════════════════════════════════════════════════════════════════════════════════════════════════════
1890
- // **⟶ AND THE REGISTRATION'S OWN SAVE CHANNEL, INSTALLED HERE FOR THE SAME MEASURED REASON — `D-106` ARM 1,
1891
- // 2026-11-02.** **THE REGISTRATION'S CLOSE OWES A SAVE THE TERMINAL ARM NEVER PERFORMS**, and this is the
1892
- // channel it names the last `file`-tier op its route landed to (`delivery.mjs`'s `installRegistrationSave`,
1893
- // whose body is the SAME `commitFile` frame the terminal arm calls — one save path, two callers).
1894
- //
1895
- // **THE INSTALL SITE IS THIS NEIGHBOURHOOD AND NOT `:1709`/`:1715`'S, AND THE REASON IS THE SAME BYTE THE CLAUSE
1896
- // ABOVE PRINTS**: the construction's batch arming walk below reaches `K-1` BEFORE either of those two seams
1897
- // runs, so a save channel installed there would leave a `storeCreate` carrying `cfg.constraints` — and a boot
1898
- // carrying them — with no route to the save at all. **IT CHANGES NO ORDER OF ACTS AND ADDS NO MEMBER**:
1899
- // `Symbol.for`-keyed and `enumerable: false`, so the product's declared FOURTEEN own members are unmoved
1900
- // (`A117` (D6)).
1901
- // ═════════════════════════════════════════════════════════════════════════════════════════════════════
1902
- installRegistrationSave(instance, state);
1903
- // **⟶ AND THE REGISTRATION INSTANT'S DELIVERY CHANNEL, INSTALLED HERE FOR THE SAME MEASURED REASON —
1904
- // `D-125` item `1`, `PIN-2`, 2026-11-06.** It is the channel the registration's PASSING close reaches with the
1905
- // watched sets its repair's writes fired (`delivery.mjs`'s `installRegistrationDelivery`, whose loop is
1906
- // `deliver`'s own); **it is silent while the construction is the act in hand** — the creation and the boot
1907
- // deliver `PIN-6` (i)'s own set at their own seat below — and it speaks at `addConstraint` and at a re-arm.
1908
- // **IT CHANGES NO ORDER OF ACTS AND ADDS NO MEMBER**: `Symbol.for`-keyed and `enumerable: false`, so the
1909
- // product's own members are unmoved (`A117` (D6)), exactly as the three channels beside it.
1910
- installRegistrationDelivery(instance, state);
1911
- // **⟶ `docs/specs/storeroom-js/surface.md §2.12` ITEM 1 CLAUSE (b): `storeCreate` REGISTERS EACH OF `cfg.constraints`' ELEMENTS THAT CARRIES
1912
- // ITS OWN FUNCTION AT `K-1`, AT THE INSTANCE IT IS CONSTRUCTING** — the SAME call the ADD route makes, so
1913
- // a batch-populated pair is a pair the entry carries on the same footing (`docs/specs/storeroom-js/surface.md §2.12` item 3's preamble clause
1914
- // (a)). **⟶ AMENDED 2026-10-24 (`D-26` item 4; `D-27` item 1): EVERY BATCH ELEMENT IS CARRIED AND ITS
1915
- // FUNCTION IS ARMED — the *"well-formed pair carrying no function"* state this loop once skipped with a
1916
- // silent `continue` HAS NO PRODUCER ON THIS ROUTE, because step 2 refused it before the create.** **THE
1917
- // SILENT DROP IS DELETED, NOT MOVED**: a caller who supplied a function and got an unarmed pair was told
1918
- // nothing, which is the shape this project keeps filing (`D-26` item 1 calls it *"a DEFECT and not a
1919
- // design"*).
1920
- //
1921
- // **AND THE LIST ARMED HERE IS `batch` — THE ONE STEP 2 ALREADY WALKED, CHECKED AND ANSWERED**, so no
1922
- // element is re-read off the caller's array and no second validation decides a second time.
1923
- //
1924
- // **⟶ AND THIS SITE TAKES THE THREE-STATE REGISTRATION TOO** (`docs/specs/storeroom-js/surface.md §2.12` item 3's clause of 2026-10-16
1925
- // at its `A135` (3) mark; `docs/specs/storeroom-native/contract.md §7.3` (b)). **THE BATCH ROUTE AND THE
1926
- // ADD ROUTE REACH THE SAME `K-1`**, so a batch element the current state violates — with no repair
1927
- // standing, or with one that does not resolve it — refuses the CONSTRUCTION in this surface's one
1928
- // failure form, exactly as the ADD route refuses the call. **THE STATE 3 SUCCESS ARM IS THE ONE THAT
1929
- // MOVES THE STORE**: the repair's edit stands, the registration stands, and the construction returns
1930
- // its instance with no log crossing (`3-bis` (c)).
1931
- //
1932
- // **⟶ AND THE FIRST POSITION IS THE DECODED SEGMENT LIST AND NEVER THE ENCODER'S CARRIER — CORRECTED
1933
- // 2026-10-18, AND THIS IS THE WHOLE OF THE DEFECT.** `constraintAddress` answers `{k:'L', s:[…]}` — a
1934
- // CARRIER (`§1.5`'s segment array as `encodeAddress` declares it) — while `carryConstraint` hands its
1935
- // `addresses` to `K-1`'s `inDomainAddress`, which admits A LIST OF SEGMENTS AND NOTHING ELSE. **SO THE
1936
- // CARRIER IS READ BACK TO ITS SEGMENTS HERE** (`batch`'s `addresses` is already that list) and no new
1937
- // position, no new code and no new failure form is minted: the pair is its ONE-member set
1938
- // (`constraint-identity.md §6`'s pair table — a single address at the REGISTRATION act).
1939
- // ═════════════════════════════════════════════════════════════════════════════════════════════════════
1940
- // **⟶ THE SWEEP — `D-123` ITEM `1`, `D-124` ITEM `1`, `D-125` ITEMS `3`–`4`; `PIN-3`, `PIN-4`, `PIN-5`.**
1941
- // ═════════════════════════════════════════════════════════════════════════════════════════════════════
1942
- //
1943
- // **THE CARRY, THEN THE ROUNDS: EVERY ADMITTED PAIR IS CARRIED ONCE AND THEN ASKED AGAIN, ROUND BY ROUND,
1944
- // UNTIL A ROUND LANDS NO REPAIR** (`PIN-4` (i)–(iv)). **A round asks every admitted pair AT MOST ONCE**, and it
1945
- // asks it **through the registration route's own `carryConstraint`** — the same act the carry takes, at the same
1946
- // address, with the pair's own body — so **no attempt, no budget member and no `AttemptRef` is minted**: a
1947
- // construction has no attempt to count restarts in (`D-124` item `1`: *"THE SWEEP INHERITS THE MARKER AND NOT
1948
- // THE BUDGET"*).
1949
- //
1950
- // **THE SWEEP'S WHOLE NEW STATE IS ONE APPLIED-REPAIR BIT PER ADMITTED PAIR, AND IT IS THESE `markers` ROWS**
1951
- // (`PIN-4`: *"the applied-repair bit per admitted pair is the sweep's whole new state"*; `PIN-14` (i)). It is
1952
- // **NOT a member**: nothing is minted on the instance, on a record, on an op or on the kernel, and the bits are
1953
- // local to this construction and gone when it answers.
1954
- //
1955
- // **⟶ AND `sweep` IS THE ONE OBJECT THAT MAKES *"GONE WHEN IT ANSWERS"* TRUE OF THE GUARD ITSELF — GATE 4's
1956
- // DEFECT 1, CLOSED.** `sweepGuarded` installs a wrapper as the pair's element AND as the body the kernel's pass
1957
- // asks (`carryConstraint`'s `entry.fn`, `kernel-attempt.mjs`'s `pair.constraint`), so **the wrapper cannot be
1958
- // un-installed when the sweep ends**: re-registering the original body would ASK the body again at the state the
1959
- // sweep left, which can land a second repair and is therefore a second act and not a restoration. **THE SCOPE IS
1960
- // THEREFORE THE DEVICE**: this object is local to the construction, the wrapper consults it before it reads
1961
- // anything of the outcome, and it is cleared the instant the sweep's last round ends (below) — so **from that
1962
- // byte on the wrapper is a transparent identity over the caller's own body, and a pair that repaired inside the
1963
- // construction keeps its `repair` on every later refusal for the life of the instance.** **NO MEMBER IS MINTED**:
1964
- // it is a local row, exactly as the bits are.
1965
- const sweep = { live: true };
1966
- //
1967
- // **THE TERMINATOR IS ARITHMETIC AND NOT BUDGETARY** (`D-124` item `1`): every round that continues the sweep
1968
- // lands at least one repair, no pair repairs twice, so the repairs number at most the admitted pairs and the
1969
- // first round that lands none ends the sweep. **NO ROUND CAP IS MINTED AND NO COUNT IS COUNTED** — `PIN-4`'s
1970
- // `THREE` and `D-42`'s restart budget are RETIRED for this act, and no cell of this unit prints a round.
1971
- //
1972
- // **AND THE THREE REFUSING ARMS, EACH AT ITS OWN MEMBER:**
1973
- // * **THE CYCLE** (`D-125` item `4`; `PIN-4` (ii)) — a pair asked again that WOULD REPAIR AGAIN. Inside one
1974
- // registration call it is the re-run's own arm (`kernel-registration.mjs`'s `CYCLE_ARM`, rank `20`); across
1975
- // rounds it is `sweepGuarded`'s suppression below, whose rank `19` verdict this frame converts, because
1976
- // **`a pair's second repair attempt is an inconsistent result and refuses at rank `20`*** — the pair's
1977
- // repair is NOT performed a second time and no save reaches the bytes.
1978
- // * **THE POST-ROUND INCONSISTENCY** (`PIN-5`) — a pair that refuses in a round AFTER the first: the rounds
1979
- // have ended on a register that still violates a carried pair, and *"the construction **throws instead of
1980
- // returning an instance**"*. It crosses rank `20` `ConstraintPassRefused` and **no member is minted for
1981
- // it** (its trigger is arm-neutral by its own row, `contract.md:4652`).
1982
- // * **THE PAIR'S OWN FIRST VERDICT** — a refusal in the CARRY, or in the first round, is the registration
1983
- // instant's own and keeps rank `19` `ConstraintRefusedAtRegistration` (`PIN-11`: both ranks carry a
1984
- // constraints subject, and the shipped arm does not move).
1985
- //
1986
- // **A SKIPPED PAIR IS STILL SKIPPED** (`D-90`'s rule read THROUGH `D-123` item 1): `pairApplication` is asked
1987
- // before the body at every one of these asks, so a pair whose parent does not resolve is passed over in the
1988
- // carry and in every round, is not a refusal, and is still named by `constraints()` (`PIN-14` (ii) freezes
1989
- // `kernel-registration.mjs`'s skip by name).
1990
- //
1991
- // **THE SWEEP IS THE CREATION'S AND THE BOOT'S ALONE** (`D-125` item 3): `addConstraint` and a re-arm keep the
1992
- // registration instant's own single-pair scope, so no round runs at either of them.
1993
- const markers = [];
1994
- for (let i = 0; i < batch.length; i += 1) appendOwn(markers, { applied: false, cycled: false });
1995
- let roundIndex = 0;
1996
- let landedInRound = 0;
1997
- do {
1998
- landedInRound = 0;
1999
- for (let i = 0; i < batch.length; i += 1) {
2000
- const marker = markers[i];
2001
- const appliedBefore = marker.applied;
2002
- // **A PAIR THAT ALREADY LANDED ITS ONE REPAIR IS ASKED AGAIN AND ITS SECOND REPAIR IS NOT ATTEMPTED**
2003
- // (`PIN-4` (i), (ii)): the guard suppresses it, the registration refuses without repairing, and the
2004
- // conversion below makes that rank `20` — *"a cycle is an inconsistent result"* (`D-125` item 4).
2005
- // **IN THE CARRY ITSELF THE GUARD NEVER SUPPRESSES** (`roundIndex` `0`), so the re-run's own cycle arm is
2006
- // the kernel's and the shipped `KC` reading of every other refusing arm is unmoved.
2007
- const guarded = sweepGuarded(batch[i].constraint, marker, sweep, roundIndex > 0 && appliedBefore === true);
2008
- try {
2009
- carryConstraint(state, instance, batch[i].addresses, batch[i].id, guarded);
2010
- } catch (refusal) {
2011
- // **A LATER ROUND'S RANK-`19` VERDICT IS THE SWEEP'S POST-ROUND INCONSISTENCY AND CROSSES AT RANK `20`**
2012
- // (`PIN-5`); every other refusal — the carry's own, a body that threw (rank `18`), a store code — keeps
2013
- // its own member and its own form.
2014
- if (roundIndex > 0 && ownValue(refusal, 'status') === 'ConstraintRefusedAtRegistration') {
2015
- boundaryReject(
2016
- 'ConstraintPassRefused',
2017
- spellAddressBare(batch[i].addresses[0]),
2018
- marker.cycled === true
2019
- ? 'the pair had already landed its one repair and would repair a second time, and a pair may land AT MOST ONE REPAIR in a construction'
2020
- : 'the sweep ended on a register that still violates a carried pair, and the construction may not return an instance whose register still violates one of them',
2021
- 'constraints',
2022
- );
2023
- }
2024
- // **`D-77`: the batch element's own address — the construction's registration act is at it.**
2025
- registrationCrossing(refusal, batch[i].addresses[0]);
2026
- }
2027
- if (marker.applied === true && appliedBefore === false) landedInRound += 1;
2028
- }
2029
- roundIndex += 1;
2030
- } while (landedInRound > 0);
2031
- // ═════════════════════════════════════════════════════════════════════════════════════════════════════
2032
- // **⟶ AND THE SWEEP'S SCOPE ENDS HERE — ITS LAST ROUND HAS ANSWERED AND THE GUARD BECOMES THE CALLER'S
2033
- // BODY — GATE 4's DEFECT 1, CLOSED AT ITS OWN BYTE.**
2034
- // ═════════════════════════════════════════════════════════════════════════════════════════════════════
2035
- //
2036
- // **WHY THIS LINE IS THE FIX AND NOT A TIDY-UP.** The wrapper this loop installed stands in the entry
2037
- // (`entry.fn`) and in the kernel's pair row, so it is the body EVERY later instant asks — the pass over a
2038
- // caller's `write`, a `delete`, a `rollback`'s judgement and a re-arm. **A wrapper left suppressing would strip
2039
- // the `repair` from that pair's every later refusal, silently, for the life of the instance, and only a
2040
- // re-`addConstraint` would restore it** — measured: a construction whose pair repaired, then an ordinary
2041
- // `write` at its address, refused at rank `20` with the repair never run. **THE MARKER IS CONSTRUCTION-SCOPED
2042
- // AND THIS IS WHERE THE CONSTRUCTION'S PART OF IT ENDS**: `sweep.live` is cleared the instant the sweep has
2043
- // nothing left to ask — before the listeners are applied, before the delivery and before the answer — so the
2044
- // suppression is consulted ONLY while the sweep is the act in hand, and the pair's every later refusal runs its
2045
- // repair as its own body made it. **NO MEMBER MOVES AND NO ARM MOVES**: the bits, the three refusing arms and
2046
- // every rank above are the bytes they were.
2047
- sweep.live = false;
2048
- // **⟶ AND THE CONSTRUCTION'S OWN ADOPTION ENTERS THE PACKAGE'S HOME MIRROR** (`docs/specs/storeroom-js/surface.md §2.4` item 7 (b)'s dated
2049
- // narrowing reads TWO lawful duplicate states, and the ONE-ADDRESS one is `DD-39`'s CONSTRUCTION duplicate;
2050
- // `src/store.rs`'s own `adopt` keeps BOTH entries under one address and pushes the token's index entry for
2051
- // each). **THE MIRROR IS THE HOME'S OWN SHAPE AND NOT A SECOND DECISION**: an accepted entry's handle is
2052
- // adopted VERBATIM, in the caller's own spelling order ACROSS addresses and the bucket's own order WITHIN
2053
- // one — which is the order `DD-42` clause (2)'s *"FIRST match"* is defined by. **A REJECTED ARRAY ADMITS
2054
- // NOTHING** (`src/args.rs`), so a listeners list the store refused never reaches `storeCreate`'s return and
2055
- // no mirror entry is written for it.
2056
- //
2057
- // **⟶ AND ONE ENTRY IS PUSHED PER ADOPTED ELEMENT, WITH NO `some(key)` TEST HERE — CORRECTED 2026-10-17**
2058
- // (`docs/specs/storeroom-js/surface.md §2.4` item 7 (a) item 3; rules 1, 3 and 4 with `DD-39`'s *"both entries are KEPT"*): the store's own
2059
- // population calls `adopt` for EVERY admitted element, and two elements at ONE address stay TWO store
2060
- // entries (`src/store.rs`'s bucket, whose `first_at` answers the bucket's FIRST). **SO A PER-KEY DEDUPE
2061
- // HERE WOULD BE A SECOND DECISION THE STORE NEVER TAKES and the mirror would hold fewer entries than the
2062
- // home** — the `-1` absence route below is what that divergence breaks. **THE PREDICATE IS THE ONE THE
2063
- // STORE'S OWN ADMISSION AGREES WITH** (`isLawfulListenerElement`): a `cfg.listeners` array that reached
2064
- // this line was admitted WHOLE by `encodeListeners`, the facade and `src/args.rs`, so a lawful element is
2065
- // pushed and the two sides' element counts are the same number.
2066
- //
2067
- // **⟶ AND THE BOOT ROUTE GOES THROUGH THE SAME VERB — *"Boot goes through listen()"*** (`P: docs/pending.md ·
2068
- // P-5`, the boot ruling, verbatim; `contract.md §2.2` item 8; `listen-verb.md §6`). **THE CONSTRUCTION'S
2069
- // `listeners[]` ELEMENTS ARE APPLIED BY CALLING THE SAME `listen(handle, addresses)` THE CALLER WOULD CALL**,
2070
- // so every adopted handle gets its map entry with `off` set exactly as a runtime `listen` does. **THAT
2071
- // CLOSES THE REACHABLE STATE `(off=false, fn=—)` this block once produced by pushing into `state.home`
2072
- // directly** (`P: docs/pending.md · P-5`, the boot ruling's own ground), and it REPLACES `DD-39`'s
2073
- // verbatim-adoption rule rather than re-reading it (`(ii)`, verbatim).
2074
- //
2075
- // **WHAT SURVIVES, EACH NAMED SO IT IS NOT READ AS MOVING WITH `DD-39`:** the construction still admits
2076
- // `listeners` WHOLE — a refused element refuses the construction, exactly as today (`encodListeners` and
2077
- // `src/args.rs`, which this route does not reach); `surface.md:2118`'s *"A REJECTED ARRAY ADMITS NOTHING"*
2078
- // survives; and **the mirror holds N rows `{key, handle}` when ONE handle arrives at N addresses** (`(iv)`,
2079
- // verbatim) — which is why this loop calls the verb once per ELEMENT, an element carrying ONE address
2080
- // (`(v)`: *"a `listeners[]` element carries ONE `address` and not a set"*).
2081
- if (isPlainObjectValue(cfg) && isAdmittedArray(cfg.listeners) && arrayClass(cfg.listeners) !== 'class') {
2082
- // **⟶ AND THE SET IS ACCUMULATED PER HANDLE BEFORE THE VERB IS CALLED, WHICH IS WHAT MAKES THE BOOT
2083
- // PRODUCE THE STATE THE RULING REQUIRES: *"the mirror holding N rows `{key, handle}` when one handle
2084
- // arrives at N addresses"*** (`P: docs/pending.md · P-5`, the boot ruling's item (iv), verbatim;
2085
- // `contract.md §2.2` item 8; `PAR-HL-24`'s observable).
2086
- //
2087
- // **THE REASON IT MUST ACCUMULATE AND NOT SIMPLY LOOP IS `(R1)`'S**: a `listen` is a SET ASSIGNMENT and
2088
- // the second act PURGES the first (`P: docs/pending.md · (R1)`, verbatim: *"S1 gets purged wholesale"*),
2089
- // so N successive one-address acts would leave the handle standing at the LAST address alone. **THE BOOT'S
2090
- // ELEMENTS ARE NOT N SUCCESSIVE ACTS — they are the caller's ONE spelling of a handle at N addresses**, and
2091
- // the verb they are applied through is the same verb the caller calls, with the whole set.
2092
- //
2093
- // **AND THE ORDER IS THE CALLER'S OWN**: the handles are taken in the order `listeners[]` first names them,
2094
- // and each handle's addresses in the order the array names them — an order NO clause asserts and none is
2095
- // claimed here (`DD-22`: a drive compares sets, never sequences).
2096
- // **⟶ AND THE ACCUMULATION IS MADE OF LOCAL ARRAYS READ BY INDEX FROM 2026-10-24** (`contract.md §2.1`'s
2097
- // clause of this date on `F8-2`, items `(2a)`, `(2b)` and `(2c)`, and item `(2b)`'s row `64`; arm `(xix)`,
2098
- // cell `JC-TC-65`): the as-built seeding used `new Map()` — lawful to ALLOCATE by item `(1d)(iv)`, and its
2099
- // `get`/`set` were not — `for (const entry of cfg.listeners)` and `for (const [handle, set] of byHandle)`,
2100
- // whose pair destructuring is a third iterator, and `set.push(entry.address)`. **A skipping iterator made the
2101
- // construction's DECLARED SEEDING silently register nothing while `storeCreate` returned an instance whose
2102
- // mirror was empty, and a no-op `get`/`set`/`push` did the same with a success report.** The order is the one
2103
- // the comment above declares and no clause asserts: the handles in the order `listeners[]` first names them,
2104
- // and each handle's addresses in the order the array names them.
2105
- //
2106
- // **⟶ AND THE LIST IT WALKS IS `adopted` — STEP `2`'S OWN ANSWER — AND THE BODY IS ARMED BESIDE THE ADDRESSES,
2107
- // `PIN-8`, 2026-11-06.** The bytes this replaced re-read `cfg.listeners` and re-took `isLawfulListenerElement`
2108
- // per element; **the walk is now the one step 2 already took**, so no element is read off the caller's array
2109
- // twice and no second admission decides a second time (the shape `admittedConstraintBatch`'s own arming walk
2110
- // takes). **`listen` WRITES THE STORE-SIDE ENTRY AND THE RESERVATION, AND `register` ARMS THE FUNCTION INTO
2111
- // THIS INSTANCE'S REGISTRY** — `docs/specs/storeroom-js/surface.md §2.4` rule 2's replacement rule, so an
2112
- // element a later one supersedes under the same handle leaves the LAST body standing — **and it is the same
2113
- // two acts a caller performs at the boot ruling's own command (*"Boot goes through listen()"*), in the same
2114
- // order.** **NO MEMBER IS MINTED AND THE MIRROR'S ROWS ARE THE SAME ROWS**: `register` sets `off` false and
2115
- // the function, and adds no row.
2116
- const handles = [];
2117
- const addressSets = [];
2118
- for (let i = 0; i < adopted.length; i += 1) {
2119
- const entry = adopted[i];
2120
- let at = -1;
2121
- for (let h = 0; h < handles.length; h += 1) {
2122
- if (handles[h] === entry.handle) {
2123
- at = h;
2124
- break;
2125
- }
2126
- }
2127
- if (at === -1) {
2128
- appendOwn(handles, entry.handle);
2129
- appendOwn(addressSets, [entry.address]);
2130
- } else {
2131
- appendOwn(addressSets[at], entry.address);
2132
- }
2133
- }
2134
- for (let h = 0; h < handles.length; h += 1) {
2135
- instance.listen(handles[h], addressSets[h]);
2136
- }
2137
- // **THE SUBSTANCE, ARMED FROM THE INSTANT THE INSTANCE EXISTS** (`PIN-8`; `D-123` item `2`: *"THE PACKAGE
2138
- // ARMS THE SUBSTANCE"*). **ONE `register` PER ADOPTED HANDLE, AFTER ITS `listen`** — so the entry it replaces
2139
- // is the reservation that `listen` just wrote, exactly as a caller's own two acts do. **WHERE ONE HANDLE IS
2140
- // ADOPTED BY SEVERAL ELEMENTS THE LAST BODY WINS**, which is `register`'s own replacement rule (`§2.4` rule
2141
- // 2: *"one handle, one function — the previous entry is REPLACED"*), and the walk that finds it is a local
2142
- // index loop like every other read of this list.
2143
- for (let h = 0; h < handles.length; h += 1) {
2144
- let body;
2145
- for (let i = 0; i < adopted.length; i += 1) {
2146
- if (adopted[i].handle === handles[h]) body = adopted[i].listener;
2147
- }
2148
- if (typeof body === 'function') instance.register(handles[h], body);
2149
- }
2150
- }
2151
- // ═════════════════════════════════════════════════════════════════════════════════════════════════════
2152
- // **⟶ AND THE CREATION'S DELIVER — `PIN-2`, `PIN-6` (i), (iii), (iv); `D-123` item `2`, `D-125` item `1`.**
2153
- // ═════════════════════════════════════════════════════════════════════════════════════════════════════
2154
- //
2155
- // **THE SEAT IS AFTER EVERY REGISTRATION'S PASSING CLOSE — and therefore after their saves — AFTER THE
2156
- // LISTENERS ARE ARMED, AND BEFORE THE ANSWER** (`PIN-2`'s redrawn order: ASK → REPAIRS LAND → RE-RUN → SAVE →
2157
- // DELIVER → THE ANSWER). **IT IS REACHED ONLY WHERE THE SWEEP RETURNED AN INSTANCE**: a construction that
2158
- // refused left this frame above, so *"no delivery on a refusing arm"* is structural here and not a test.
2159
- //
2160
- // **THE SET IS `PIN-6` (i)'S: THE ADOPTED SET ∩ THE ADDRESSES THAT RESOLVE IN THE REGISTER**, delivered *"by the
2161
- // mechanism above"* — **one `deliver` call per address, in creation order, with the running handle list held
2162
- // ACROSS the calls** (`constraints.mjs:3009`–`:3037`), so an identity adopted at two existing addresses fires
2163
- // ONCE, at the first address that names it (`PIN-6` (iii)). **THE ONE ARGUMENT IS THAT ADDRESS** (`PIN-6` (iv);
2164
- // `Q-3`'s default: the listener's own watched address at this instant).
2165
- //
2166
- // **AN ADDRESS THAT DOES NOT RESOLVE IS SILENT AND IS NOT A REFUSAL** (`PIN-7`; `D-123` item 3): no invocation,
2167
- // no code, no log entry and no throw. **AND A FIRED BODY'S THROWABLE REFUSES THE CONSTRUCTION AT RANK `21`
2168
- // `ListenerBodyThrew`** (`PIN-10`; `D-124` item 2) — **the instance does not exist, no rollback composes (the
2169
- // saves above already stand, `PIN-12`), and the throwable itself is not rendered as a sentence of this
2170
- // package's.**
2171
- deliverAtTheCreation(state, adopted);
2172
- // **⟶ AND THE CONSTRUCTION'S OWN DELIVERY IS THE `'adopted'` SET AND NOT THE REPAIR'S** — the flag the channel
2173
- // reads is stated here as well as at the state's own declaration, because the two are one fact and this is the
2174
- // seat that owns it.
2175
- state.registrationDelivery = 'adopted';
2176
- // **⟶ THE SEAM IS INSTALLED ON THE OBJECT THIS FACTORY RETURNS, ONCE** (`finalizer-and-teardown.md
2177
- // `§4.2` item 4). **IT IS INSTALLED AFTER THE BATCH ROUTES ABOVE**, so a `listen` the construction itself
2178
- // performs is not counted as a commit the caller opened and leaves the count at `0` on the return.
2179
- installAttemptSeam(instance);
2180
- // **⟶ AND `D-69`'S REGISTRATION CHANNEL, ONCE, BY THE SAME RULE — 2026-10-29.** The registration entry admits a
2181
- // body of EITHER kind, and the kernel's `K-1` hands the pair's own constraint function through this channel after
2182
- // `listen` has written the home entry. **IT IS INSTALLED HERE BECAUSE THE REGISTRY IT FILLS IS THIS FACTORY'S
2183
- // `state`** (`delivery.mjs`'s `installRegistrationSeam` states the shape and the two places the kinds part
2184
- // company), **and it is symbol-keyed, so the product's FOURTEEN own members are unmoved** (`A117` (D6)).
2185
- installRegistrationSeam(instance, state);
2186
- return instance;
2187
- }
2188
-
2189
- // ⟶ MOVED 2026-10-18 (`RCA-8(g)`): the region header is moved — re-indented and otherwise unchanged —
2190
- // to sit above the member list it describes (P-8; archive/p8-merge/2026-10-18/blocks/region-header.md).
2191
-
2192
- // ⟶ MOVED 2026-10-18 (`RCA-8(g)`): read is deleted; its doc block and body are now the
2193
- // `read` member's own (P-8; archive/p8-merge/2026-10-18/blocks/read.md).
2194
-
2195
- // ⟶ MOVED 2026-10-18 (`RCA-8(g)`): readLiteral is deleted; its doc block and body are now the
2196
- // `readLiteral` member's own (P-8; archive/p8-merge/2026-10-18/blocks/readLiteral.md).
2197
-
2198
- // **THE MODULE NAMESPACE CARRIES ONE NAME, `storeCreate` ALONE** (`surface.md §2.9` item 1's `A127` clause;
2199
- // `11 → 1` ✓): `delete`'s reserved-word spelling, the ten store-reaching names and the three constraint
2200
- // functions are the product's own members above and have no export and no second spelling at any layer.