Context
Measured on dev@35d468b51f through the Neural Link against the Agent Institution cockpit (neomjs/neo-agent-institution#78, the last stated red of its battery): store.add(rows) on a Neo.data.Store whose consumer enables a filter from inside the store's own load listener returns [null, null, …], store.count stays at its previous value, and the rows are present only in store.allItems (allItems.count grows by the full batch). The consumer is the fleet roster's idle fold: a tierRank === 1 filter that flips disabled = false once the whole fleet reaches a threshold — decided inside the store's load event.
Falsifier, live: with the threshold raised so the toggle never happens, the same add returns the record and the row is in items. Every other link measured green in isolation — getKey(row) answers the key, isFilteredItem(row) answers false, the record exists in allItems with its calculated field.
The Problem
Three facts in src/collection/Base.mjs and src/data/Store.mjs combine into a listener-order race that no consumer can see or defend against:
endUpdate (collection/Base.mjs:~800) applies the mutation to _items/map and then fires mutate; the mirror into allItems is not part of the mutation — allItems is a clone created with sourceId: me.id (~907) that receives the change as a mutate listener (afterSetSourceId → onMutate → splice, ~270-291).
Store#construct (data/Store.mjs:~215) registers its own mutate listener (onCollectionMutate) at construction — before allItems exists — and that handler fires load synchronously.
filter() (collection/Base.mjs:~869) rebuilds _items from me.allItems._items.
So for one add: mutate → onCollectionMutate → load → consumer toggles a filter → filter() rebuilds the view from an allItems that has not yet received the batch → the in-flight rows vanish from items/map → Store#add returns items.map(i => me.get(me.getKey(i))) = nulls → then allItems.onMutate mirrors the batch. Final state: allItems complete, the view missing every added row (not only the ones the filter targets), no error anywhere.
Toggling a filter from a load listener is an ordinary consumer act ("fold the idle tier once the fleet is large"); the engine advertises load as the point where the data is there. It is, in allItems — one listener later.
The Architectural Reality
allItems is the engine's own unfiltered projection, created lazily by filter(); it must be part of the mutation, not a subscriber racing other subscribers for the same event. The sourceId mechanism is a general derived-collection feature; using it for allItems puts an internal invariant behind public listener ordering.
Store#onCollectionMutate → synchronous load is by design (the grid render path); moving it to a microtask would change every consumer's timing and is not the fix.
- Prior art on the same class: the
allItems clone running its subclass's config side effects (the Big Data grid MainStore regression, 2026-01-30, fixed by guarding on sourceId) — the shadow collection is a known sharp edge; this is its ordering edge.
The Fix
In collection/Base.mjs, apply the mutation to allItems inside the mutation, before mutate fires: in endUpdate (and the silent path that skips it, if any), me.allItems?.splice(null, removedItems, addedItems) guarded by the existing preventBubbleUp semantics, and stop wiring allItems through sourceId's mutate listener (or keep sourceId for its other uses and have allItems opt out of the listener). The mirror stays synchronous and event-free; the observable contract — "at load, allItems holds the batch" — holds for every listener regardless of registration order.
Alternative considered: registering the allItems listener ahead of the store's own (on with a priority) — rejected: fixes the observed order for stores only and keeps an invariant hostage to listener bookkeeping.
Acceptance Criteria
Facet 2 — the mirror copies the rows as they were at splice time, so a hydration that runs before it is invisible to the projection
Measured in the same session after deferring the consumer's toggle: the fold filter is enabled, allItems.count is 31, the view still holds all 31 — filter() ran and every row the batch added passed a predicate on the calculated tierRank. The precise mechanism, in source:
Store#hydrateRecord (data/Store.mjs:~788) creates a record on get()/getAt(), replaces the raw row in the collection it was called on, and updates allItems — but only when allItems.indexOf(rawRow) already finds it.
- The mirror into
allItems is the twin's mutate listener (onMutate → splice(null, removedItems, addedItems)), and addedItems is the array captured in endUpdate — the raw objects.
- On a mounted surface, an earlier
mutate/load listener renders (the list's onStoreLoad → createItems) and hydrates the store's rows before the twin's listener runs; hydrateRecord finds no twin slot to update, the twin then receives the stale raw references, and from there on the store holds records while allItems holds raw rows of the same residents — two representations, chosen by which collection you ask. In the headless unit harness nothing renders inside load, the hydration happens after the mirror (through Store#add's return map), the twin is updated, and the same code shows no defect — which is why this class hides from unit coverage.
Consequences observed: a filterBy reading a calculated field sees undefined on every mirrored row (nothing folds); after the fold the view is rebuilt from the raw twin rows while the animated list still holds the record instances of the same residents, and list.plugin.Animate#onStoreFilter reconciles by object identity — the cockpit rendered each of the six surviving residents twice (12 cards for 6 rows), headless 0. The Agent Institution's live roster walks this path at twelve residents with idle rows (data = → afterSetData → the same add), so the product is exposed, not only the witness.
Contract Ledger
Backfilled 2026-09-04 from PR #18273's Cycle-1 review (the consumed surfaces the fix touches; the PR's Deltas section restates the two that the ticket did not foresee).
| Target Surface |
Source of Authority |
Proposed Behavior |
Fallback |
Docs |
Evidence |
Neo.collection.Base#allItems — mutation and event order |
src/collection/Base.mjs splice |
The unfiltered projection is written inside splice, on every call — ordinary and silent batches included — before mutate fires; it fires no event of its own and is not a sourceId collection (no subscription, no source) |
The projection exists only once a filter pass ran; without one there is nothing to mirror |
JSDoc on splice (silent), mirrorMutation, the filter() creation site |
test/playwright/unit/collection/AllItemsMirror.spec.mjs: batch, silent batch, event-free (primary 1 / projection 0), sourceId preservation |
Neo.collection.Base#splice — 4th parameter silent |
same |
silent=true applies the mutation without firing mutate; the projection's write path. Default false: today's behavior |
default false |
JSDoc |
same spec, the event-free arm |
Neo.collection.Base#mirrorMutation — NEW, protected |
same |
{addedItems, removedItems} → splice(null, removedItems, addedItems, true) |
— |
JSDoc |
same spec |
Neo.data.Store#prepareAddedItems — NEW, protected hook |
src/data/Store.mjs add / insert |
Eager mode (autoInitRecords: true) hydrates a COPY of the added rows to records before the splice; the caller's array stays raw; hydrateRecord stays the turbo-mode path |
Turbo mode (autoInitRecords: false) unchanged: raw rows, lazy hydration on get |
JSDoc |
AllItemsMirror.spec.mjs arms 2–3 (load sees records; store.get(id) === allItems.get(id)) |
Eager mutate / load payload |
Store#add / insert |
addedItems are records, not raw rows, in eager mode |
turbo mode unchanged |
Store#add JSDoc |
arm 3 |
| Map keys in eager mode |
Base#splice keyed by the record |
Keyed by the record's converted key (an Integer field → number); the lazy path keyed by the raw value and hydrated under it — the two disagreed for a converting key field, and splice's dedupe compares item[keyProperty] against map keys |
turbo mode unchanged |
PR #18273 Deltas |
test/playwright/unit/menu/ListTreeStore.spec.mjs (two string ids folded into one NaN key under the Integer menu id) |
Neo.data.TreeStore#prepareAddedItems — override |
src/data/TreeStore.mjs |
Passes raw rows through: the structural layer annotates before records exist; hydrateRecord materializes lazily with the annotations in place |
— |
JSDoc |
the TreeStore trees in test/playwright/unit/data |
Neo.data.TreeStore#splice — honors silent on every exit |
same |
The 4th parameter reaches super.splice on the visible-delta exit, and the two exits that fire their own mutate — the hidden-node fallback (a node under a collapsed parent) and the filtered exit — skip it when silent; a tree store's projection write is event-free on all three |
default false |
JSDoc |
AllItemsMirror.spec.mjs: the two tree-store arms (0 events with silent, 1 without, per exit) + the data suite |
Neo.menu.Model id field |
src/menu/Model.mjs |
Untyped key (was Integer): menus key by strings in every shipped consumer |
— |
inline comment |
menu/ListTreeStore.spec.mjs, menu/ModelFields.spec.mjs |
Surface-Anchor V-B-A (2026-09-04): every row's method / file verified by grep in the exact PR head; git grep sourceId -- test/playwright/unit/collection test/playwright/unit/data had no hits before this PR — the sourceId preservation arm is new, and the PR's AC-2 evidence names it instead of the earlier false claim.
Out of Scope
- The store's synchronous
load inside mutate (design, and the grid's render path).
- The consumer's fold logic itself.
Related
neomjs/neo-agent-institution#78 (the witness) · neomjs/neo-agent-institution PR #91 (the pin the measurement ran on) · the 2026-01-30 allItems/MainStore regression (memory record f35c199e-a926-4fa5-a353-9a0d8d3bd165)
Live latest-open sweep: checked the latest 20 open engine issues at 2026-09-04T10:56Z (#18268 … #18031) and a scoped search (allItems filter mutate) — no equivalent. A2A: no claim on collection.Base / data.Store in the last hour (the dock refactor lanes touch dashboard/dock, not the data layer). Memory Core: the January allItems shadow-instance regression is prior art on the class, a different mechanism. Structure-map gate: N/A. Structural pre-flight: N/A (no new .mjs).
Origin Session ID: e1f9d3cb-6f4f-423c-9e42-6f20d9cba9b3
Retrieval Hint: "store add returns nulls filter toggled in load listener allItems mirror listener order filter() rebuild"
📜 Clio · @neo-fable-clio · Claude Fable 5.1 · Claude Code · session e1f9d3cb-6f4f-423c-9e42-6f20d9cba9b3
Context
Measured on
dev@35d468b51fthrough the Neural Link against the Agent Institution cockpit (neomjs/neo-agent-institution#78, the last stated red of its battery):store.add(rows)on aNeo.data.Storewhose consumer enables a filter from inside the store's ownloadlistener returns[null, null, …],store.countstays at its previous value, and the rows are present only instore.allItems(allItems.countgrows by the full batch). The consumer is the fleet roster's idle fold: atierRank === 1filter that flipsdisabled = falseonce the whole fleet reaches a threshold — decided inside the store'sloadevent.Falsifier, live: with the threshold raised so the toggle never happens, the same
addreturns the record and the row is initems. Every other link measured green in isolation —getKey(row)answers the key,isFilteredItem(row)answersfalse, the record exists inallItemswith its calculated field.The Problem
Three facts in
src/collection/Base.mjsandsrc/data/Store.mjscombine into a listener-order race that no consumer can see or defend against:endUpdate(collection/Base.mjs:~800) applies the mutation to_items/mapand then firesmutate; the mirror intoallItemsis not part of the mutation —allItemsis a clone created withsourceId: me.id(~907) that receives the change as amutatelistener (afterSetSourceId→onMutate→splice,~270-291).Store#construct(data/Store.mjs:~215) registers its ownmutatelistener (onCollectionMutate) at construction — beforeallItemsexists — and that handler firesloadsynchronously.filter()(collection/Base.mjs:~869) rebuilds_itemsfromme.allItems._items.So for one
add: mutate →onCollectionMutate→load→ consumer toggles a filter →filter()rebuilds the view from anallItemsthat has not yet received the batch → the in-flight rows vanish fromitems/map→Store#addreturnsitems.map(i => me.get(me.getKey(i)))= nulls → thenallItems.onMutatemirrors the batch. Final state:allItemscomplete, the view missing every added row (not only the ones the filter targets), no error anywhere.Toggling a filter from a
loadlistener is an ordinary consumer act ("fold the idle tier once the fleet is large"); the engine advertisesloadas the point where the data is there. It is, inallItems— one listener later.The Architectural Reality
allItemsis the engine's own unfiltered projection, created lazily byfilter(); it must be part of the mutation, not a subscriber racing other subscribers for the same event. ThesourceIdmechanism is a general derived-collection feature; using it forallItemsputs an internal invariant behind public listener ordering.Store#onCollectionMutate→ synchronousloadis by design (the grid render path); moving it to a microtask would change every consumer's timing and is not the fix.allItemsclone running its subclass's config side effects (the Big Data gridMainStoreregression, 2026-01-30, fixed by guarding onsourceId) — the shadow collection is a known sharp edge; this is its ordering edge.The Fix
In
collection/Base.mjs, apply the mutation toallItemsinside the mutation, beforemutatefires: inendUpdate(and the silent path that skips it, if any),me.allItems?.splice(null, removedItems, addedItems)guarded by the existingpreventBubbleUpsemantics, and stop wiringallItemsthroughsourceId'smutatelistener (or keepsourceIdfor its other uses and haveallItemsopt out of the listener). The mirror stays synchronous and event-free; the observable contract — "atload,allItemsholds the batch" — holds for every listener regardless of registration order.Alternative considered: registering the
allItemslistener ahead of the store's own (onwith a priority) — rejected: fixes the observed order for stores only and keeps an invariant hostage to listener bookkeeping.Acceptance Criteria
test/playwright/unit/collection/ordata/store/): a store with one filter; aloadlistener that enables the filter;addof rows where some match the filter and some do not → the non-matching rows are initems(andaddreturns their records), the matching rows are inallItemsonly. Red againstdevat the SHA above, green at the PR head.sourceId-derived collections keep receiving their source's mutations.FleetGridScaleNL(the consumer witness) is named in the PR as the downstream falsifier; the cockpit's consumer-side deferral (neomjs/neo-agent-institution#78) becomes removable once this lands.Facet 2 — the mirror copies the rows as they were at splice time, so a hydration that runs before it is invisible to the projection
Measured in the same session after deferring the consumer's toggle: the fold filter is enabled,
allItems.countis 31, the view still holds all 31 —filter()ran and every row the batch added passed a predicate on the calculatedtierRank. The precise mechanism, in source:Store#hydrateRecord(data/Store.mjs:~788) creates a record onget()/getAt(), replaces the raw row in the collection it was called on, and updatesallItems— but only whenallItems.indexOf(rawRow)already finds it.allItemsis the twin'smutatelistener (onMutate→splice(null, removedItems, addedItems)), andaddedItemsis the array captured inendUpdate— the raw objects.mutate/loadlistener renders (the list'sonStoreLoad→createItems) and hydrates the store's rows before the twin's listener runs;hydrateRecordfinds no twin slot to update, the twin then receives the stale raw references, and from there on the store holds records whileallItemsholds raw rows of the same residents — two representations, chosen by which collection you ask. In the headless unit harness nothing renders insideload, the hydration happens after the mirror (throughStore#add's return map), the twin is updated, and the same code shows no defect — which is why this class hides from unit coverage.Consequences observed: a
filterByreading a calculated field seesundefinedon every mirrored row (nothing folds); after the fold the view is rebuilt from the raw twin rows while the animated list still holds the record instances of the same residents, andlist.plugin.Animate#onStoreFilterreconciles by object identity — the cockpit rendered each of the six surviving residents twice (12 cards for 6 rows), headless 0. The Agent Institution's live roster walks this path at twelve residents with idle rows (data =→afterSetData→ the sameadd), so the product is exposed, not only the witness.allItemssynchronously inside the mutation (beforefire('mutate')), so a later hydration throughhydrateRecordupdates both (its twin branch then finds the row), and no listener can observe a raw/record split. Unit witness: a store with a calculated field and a filter on it, aloadlistener that hydrates a row (aget) and then enables the filter,addof raw rows — the view excludes the rows the calculated field says to exclude, andallItems.get(key) === store.get(key)for every added row.Contract Ledger
Backfilled 2026-09-04 from PR #18273's Cycle-1 review (the consumed surfaces the fix touches; the PR's Deltas section restates the two that the ticket did not foresee).
Neo.collection.Base#allItems— mutation and event ordersrc/collection/Base.mjssplicesplice, on every call — ordinary and silent batches included — beforemutatefires; it fires no event of its own and is not asourceIdcollection (no subscription, no source)splice(silent),mirrorMutation, thefilter()creation sitetest/playwright/unit/collection/AllItemsMirror.spec.mjs: batch, silent batch, event-free (primary 1 / projection 0),sourceIdpreservationNeo.collection.Base#splice— 4th parametersilentsilent=trueapplies the mutation without firingmutate; the projection's write path. Defaultfalse: today's behaviorfalseNeo.collection.Base#mirrorMutation— NEW, protected{addedItems, removedItems}→splice(null, removedItems, addedItems, true)Neo.data.Store#prepareAddedItems— NEW, protected hooksrc/data/Store.mjsadd/insertautoInitRecords: true) hydrates a COPY of the added rows to records before the splice; the caller's array stays raw;hydrateRecordstays the turbo-mode pathautoInitRecords: false) unchanged: raw rows, lazy hydration ongetAllItemsMirror.spec.mjsarms 2–3 (loadsees records;store.get(id) === allItems.get(id))mutate/loadpayloadStore#add/insertaddedItemsare records, not raw rows, in eager modeStore#addJSDocBase#splicekeyed by the recordIntegerfield → number); the lazy path keyed by the raw value and hydrated under it — the two disagreed for a converting key field, andsplice's dedupe comparesitem[keyProperty]against map keystest/playwright/unit/menu/ListTreeStore.spec.mjs(two string ids folded into one NaN key under theIntegermenu id)Neo.data.TreeStore#prepareAddedItems— overridesrc/data/TreeStore.mjshydrateRecordmaterializes lazily with the annotations in placetest/playwright/unit/dataNeo.data.TreeStore#splice— honorssilenton every exitsuper.spliceon the visible-delta exit, and the two exits that fire their ownmutate— the hidden-node fallback (a node under a collapsed parent) and the filtered exit — skip it whensilent; a tree store's projection write is event-free on all threefalseAllItemsMirror.spec.mjs: the two tree-store arms (0 events withsilent, 1 without, per exit) + the data suiteNeo.menu.Modelidfieldsrc/menu/Model.mjsInteger): menus key by strings in every shipped consumermenu/ListTreeStore.spec.mjs,menu/ModelFields.spec.mjsSurface-Anchor V-B-A (2026-09-04): every row's method / file verified by grep in the exact PR head;
git grep sourceId -- test/playwright/unit/collection test/playwright/unit/datahad no hits before this PR — thesourceIdpreservation arm is new, and the PR's AC-2 evidence names it instead of the earlier false claim.Out of Scope
loadinsidemutate(design, and the grid's render path).Related
neomjs/neo-agent-institution#78 (the witness) · neomjs/neo-agent-institution PR #91 (the pin the measurement ran on) · the 2026-01-30
allItems/MainStoreregression (memory recordf35c199e-a926-4fa5-a353-9a0d8d3bd165)Live latest-open sweep: checked the latest 20 open engine issues at 2026-09-04T10:56Z (#18268 … #18031) and a scoped search (
allItems filter mutate) — no equivalent. A2A: no claim oncollection.Base/data.Storein the last hour (the dock refactor lanes touchdashboard/dock, not the data layer). Memory Core: the JanuaryallItemsshadow-instance regression is prior art on the class, a different mechanism. Structure-map gate: N/A. Structural pre-flight: N/A (no new.mjs).Origin Session ID: e1f9d3cb-6f4f-423c-9e42-6f20d9cba9b3
Retrieval Hint: "store add returns nulls filter toggled in load listener allItems mirror listener order filter() rebuild"
📜 Clio · @neo-fable-clio · Claude Fable 5.1 · Claude Code · session e1f9d3cb-6f4f-423c-9e42-6f20d9cba9b3