LearnNewsExamplesConnect
Frontmatter
assigneesneo-opus-grace
createdAtNov 15, 2026, 4:14 PM
updatedAtNov 15, 2026, 6:23 PM
githubUrlhttps://github.com/neomjs/neo/issues/21029
authorneo-opus-grace
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtNov 15, 2026, 6:23 PM

A row batch admits every record its store holds

neo-opus-grace
neo-opus-grace commented on Nov 15, 2026, 4:14 PM

Context

Neo.data.Store#updateRows() finds a batch's rows through getRow(), "the row the store holds under a key, as it holds it, hydrating none". writeRows() then hands the records to one Neo.data.RecordFactory#applyPreparedFields() call, so "a record that refuses its values leaves every row as it was". But applyPreparedFields() admits a record only when (store.allItems || store).get(key) === record (src/data/RecordFactory.mjs:461). The lookup that finds a row and the check that admits it can disagree.

Design authority: applyPreparedFields()' own JSDoc, "Distinct current records of this model. The store owner manages membership." And Neo.data.Store#writeRows: "The records adopt their values through one RecordFactory#applyPreparedFields call […]: a record that refuses its values leaves every row as it was." For which rows a store holds, Store#shouldReapplySorters already reads getRow(key) === record ("any other store every row it holds"). D#20857 placed "which rows its readers see" on the Store.

The problem

getRow() is the protected seam a subclass widens to hold rows that get() does not answer: Neo.data.TreeStore#getRow answers a row "under a collapsed parent or one the filters hide". A subclass that keeps filtered-out rows in its own structure, outside allItems, while its get() answers only visible rows, has its batch find a hydrated hidden record that the transaction then refuses with TypeError: Expected non-key fields on a record of this model.

Its only way through is to write such records with set() before super.writeRows(), outside the transaction. A batch that then refuses (a row of another model, a converter that throws) leaves those records written and their recordChange published: a partial write, the thing writeRows() promises cannot happen. TreeStore escapes this only because its get() also answers hidden nodes.

The architectural reality

  • Store#getRow(key) reads (this.allItems || this).map with the canonical-key fallback (Store.mjs:914). TreeStore#getRow adds its Structural Layer.
  • applyPreparedFields()'s check uses get(), which on a Turbo Mode store can hydrate a raw row. A membership check should not create a record.
  • Store#writeRows is applyPreparedFields()' only caller in the engine.

The fix

  1. RecordFactory#applyPreparedFields() (src/data/RecordFactory.mjs) admits a record when store.getRow(store.getKey(record)) === record: the store owner's own lookup of what it holds, the one the batch found the row with. A record the store does not hold (removed, never added, or a stale instance) is refused as before.
  2. Specs (test/playwright/unit/data/StoreUpdateRowsHeld.spec.mjs, new): a Store subclass whose getRow() holds a record that get() does not answer:
    • writes that record in updateRows() and publishes once;
    • mixed with a row of another model, the batch refuses, and every row, the held record included, keeps its values, with no recordChange or rowsChange published;
    • a record the store does not hold is still refused.

Contract Ledger

Target surface Source of authority Proposed behaviour Fallback Docs Evidence
Neo.data.RecordFactory#applyPreparedFields admission Its JSDoc ("the store owner manages membership"); Store#writeRows; Store#shouldReapplySorters A record is admitted when its store's getRow() answers it A record the store does not hold throws the existing TypeError Method JSDoc names the predicate Unit

Acceptance criteria

  • A record a store's getRow() holds, but its get() does not answer, is written inside updateRows()'s one transaction (unit).
  • Mixed with a refused row, that batch leaves every row unchanged and publishes nothing (unit).
  • A record the store does not hold is still refused (unit).
  • Each new arm is red on dev and green at the head; the full unit suite passes on both.

Out of scope

  • What a subclass does with its own derived state (#20968's exclusion stands).
  • TreeStore row identity after a re-add: #21008, PR #21009. That PR touches collection/Base.mjs and TreeStore.mjs, not this file.
  • get() itself: what a store's get() answers is unchanged.

Avoided traps

  • Widening a subclass's get() to answer hidden rows: it changes every reader of get() to fix one writer.
  • A dry-run of the batch in the subclass, validating before writing: it copies the engine's admission rules into every subclass.
  • Rolling hidden writes back by hand: their recordChange has already published.

Related

#20968 (the batch primitive) · D#20857 (its design) · #21008 / PR #21009 (adjacent, no shared file).

Ownership: self-assigned (Grace). It blocks one of my reviewed pull requests, so good first issue / help wanted do not apply.

Live latest-open + closed sweep: latest 20 open (54 open, red band; no owning epic for store write paths), open search (applyPreparedFields, updateRows, writeRows, "row batch": #21008, #20974, #21028, none equivalent) and closed search (applyPreparedFields, writeRows hidden: #20848, #20968, #20855; #20968's scope read) at 2026-11-15T15:13Z; A2A claims of the last hour checked, none on store write paths. MC sweep: "a refused row batch leaves a hidden record already written; partial write; applyPreparedFields refuses a record get() does not answer", 5 results: the #20968 design and D#20857, which place row visibility on the Store; no prior decision on admission. Own-assignment sweep: 5 open (#21028, #20986, #20911, #20884, #20790), none overlapping.

Origin Session ID: 42a76101-e5aa-4c83-8513-8709e3a84ec4

Retrieval Hint: "row batch admission: applyPreparedFields get() vs getRow(), hidden record written outside the transaction"

tobiu referenced in commit 9575d26 - "fix(data): a row batch admits every record its store holds (#21029) (#21030) on Nov 15, 2026, 6:23 PM
tobiu closed this issue on Nov 15, 2026, 6:23 PM