Skip to content

Commit 02ace2c

Browse files
ryansolidClaude via Cursor
andcommitted
test(signals): structural store states in the visibility oracle — in / Object.keys / descriptor under a held add and optimistic add/delete
The oracle and the posture matrix only ever read a VALUE; structure — a key's presence through `in`, Object.keys, getOwnPropertyDescriptor — rides presence nodes and the key-set node and had no state, so the class 'structure under a hold or override, by posture' was invisible (the review of #3523 found an optimistic add lost to committed structure the moment its only structural observer left; no cell could have shown it). Nine states now: the plain store's held add and the optimistic add and delete, each through the three structural channels. The matrix grows 851 -> 1184 cells; the gatedAway posture over these is the reviewer's shape, kept optimistic after the gate. Six pre-existing divergences between structure and value under the same rules, pinned as violations (suite green, red in the oracle report): - latest() over a held add sees the parked value of s.n but not the parked structure — none of the three structural channels has a latest() tunnel; - the descriptor trap reads no node: isPending() over it witnesses nothing, and a pre-existing render effect inspecting a key through getOwnPropertyDescriptor never re-runs for an optimistic add or delete. Co-authored-by: Claude via Cursor <[email protected]>
1 parent c410709 commit 02ace2c

1 file changed

Lines changed: 140 additions & 1 deletion

File tree

‎packages/signals/tests/visibility-oracle-store.states.ts‎

Lines changed: 140 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,5 +320,144 @@ export const STATES: State[] = [
320320
isPending: rule(false, "A16 / A19 exception (1): loading, not pending"),
321321
authoritative: rule(NOT_READY, "A17 carve-out: nothing landed")
322322
}
323-
}
323+
},
324+
// ── structural reads ──────────────────────────────────────────────────────
325+
// The same states read for STRUCTURE — `in`, Object.keys, a descriptor —
326+
// instead of a value. Structure rides presence nodes (getHasNode) and the
327+
// key-set node, not value slots: every rule above must hold for them too
328+
// (the review of #3523 found an optimistic add lost to committed structure
329+
// the moment its only structural observer left — a cell no value state
330+
// could show). One state per structural channel.
331+
...(
332+
[
333+
["in", (s: any) => "k" in s],
334+
["Object.keys", (s: any) => Object.keys(s).includes("k")],
335+
["descriptor", (s: any) => Object.getOwnPropertyDescriptor(s, "k") !== undefined]
336+
] as Array<[string, (s: any) => boolean]>
337+
).flatMap(([label, probe]): State[] => [
338+
{
339+
name: `plain store, structure via ${label}: key added under a live action (setStore inside action, yield forever)`,
340+
build(installStale) {
341+
const [s, set] = createStore<Record<string, number>>({});
342+
const x = () => probe(s);
343+
installStale(x);
344+
action(function* () {
345+
set(d => {
346+
d.k = 1;
347+
});
348+
yield never();
349+
})();
350+
flush();
351+
return { x, dispose() {} };
352+
},
353+
expect: {
354+
untracked: rule(false, "A19 (i) / CS-R33: committed structure while the add is held"),
355+
derivesFrom: rule(
356+
true,
357+
"A29: a tracked pass served the staged structure derives from the transaction's world"
358+
),
359+
published: rule(HELD, "A29 (born held)"),
360+
preexisting: rule(HELD, "A19 (i)"),
361+
staleForeign: rule(
362+
false,
363+
"A15 / A26: a stale reader of a parallel transaction shows committed structure"
364+
),
365+
childrenForbidden: rule(false, "A32"),
366+
latest: violation(
367+
true,
368+
false,
369+
"A11 for structure: latest() sees the parked VALUE of `s.n` (#3075) but not the parked STRUCTURE — the has-node / key-set / descriptor channels have no latest() tunnel (structural oracle, 2026-09-17)"
370+
),
371+
isPending:
372+
label === "descriptor"
373+
? violation(
374+
true,
375+
false,
376+
"the descriptor trap reads no node, so an isPending() probe over it witnesses nothing (structural oracle, 2026-09-17)"
377+
)
378+
: rule(true, "A19 (i) / CS-R33: a held add pends the key"),
379+
authoritative: rule(true, "A17 carve-out: staged structure is authoritative")
380+
}
381+
},
382+
{
383+
name: `optimistic store, structure via ${label}: key added inside a live action (override)`,
384+
build(installStale) {
385+
const [s, set] = createOptimisticStore<Record<string, number>>({});
386+
const x = () => probe(s);
387+
installStale(x);
388+
action(function* () {
389+
set(d => {
390+
d.k = 5;
391+
});
392+
yield never();
393+
})();
394+
flush();
395+
return { x, dispose() {} };
396+
},
397+
expect: {
398+
untracked: rule(true, "A17 / OS: the optimistic add is the displayed structure"),
399+
derivesFrom: rule(true, "A17"),
400+
published: observed(
401+
true,
402+
"as for the value slot: a fresh mainline memo's publish-or-hold is not stated"
403+
),
404+
preexisting:
405+
label === "descriptor"
406+
? violation(
407+
true,
408+
HELD,
409+
"the descriptor trap subscribes to nothing: a pre-existing render effect inspecting the key through getOwnPropertyDescriptor never re-runs for the optimistic add (structural oracle, 2026-09-17)"
410+
)
411+
: rule(true, "A17: no downstream async, nothing to wait for"),
412+
staleForeign: rule(true, "A17"),
413+
childrenForbidden: rule(true, "A32: the override is the frame"),
414+
latest: rule(true, "A17 / OL-R11"),
415+
isPending: rule(false, "A24 (3) / OS-R37: optimistic writes are verdict-inert"),
416+
authoritative: rule(
417+
false,
418+
"A17 carve-out / authoritativeServe(): never the caller's optimism"
419+
)
420+
}
421+
},
422+
{
423+
name: `optimistic store, structure via ${label}: key deleted inside a live action (override)`,
424+
build(installStale) {
425+
const [s, set] = createOptimisticStore<Record<string, number>>({ k: 1 });
426+
const x = () => probe(s);
427+
installStale(x);
428+
action(function* () {
429+
set(d => {
430+
delete d.k;
431+
});
432+
yield never();
433+
})();
434+
flush();
435+
return { x, dispose() {} };
436+
},
437+
expect: {
438+
untracked: rule(false, "A17 / OS: the optimistic delete is the displayed structure"),
439+
derivesFrom: rule(false, "A17"),
440+
published: observed(
441+
false,
442+
"as for the value slot: a fresh mainline memo's publish-or-hold is not stated"
443+
),
444+
preexisting:
445+
label === "descriptor"
446+
? violation(
447+
false,
448+
HELD,
449+
"the descriptor trap subscribes to nothing: a pre-existing render effect inspecting the key through getOwnPropertyDescriptor never re-runs for the optimistic delete (structural oracle, 2026-09-17)"
450+
)
451+
: rule(false, "A17: no downstream async, nothing to wait for"),
452+
staleForeign: rule(false, "A17"),
453+
childrenForbidden: rule(false, "A32: the override is the frame"),
454+
latest: rule(false, "A17 / OL-R11"),
455+
isPending: rule(false, "A24 (3) / OS-R37: optimistic writes are verdict-inert"),
456+
authoritative: rule(
457+
true,
458+
"A17 carve-out / authoritativeServe(): never the caller's optimism"
459+
)
460+
}
461+
}
462+
])
324463
];

0 commit comments

Comments
 (0)