Skip to content
Source
Sign inSign up
TanStack/db

Revalidate live-query mutation inputs that require virtual read metadata #2340

Send to my agent
OpenKyleAMathews(GitHub profile, opens in a new tab) opened this issue 1 comment

Problem and historical evidence

The retained release record documents a read/write type conflation on release source 180b920edd6c88a7024ed407cd04934678c7d5bf and main 95460bc875a2259b34eea534e5592a9d0394e73f, checked with TypeScript 5.9.3.

A no-select live-query Collection carries required virtual metadata from its published read result into its default mutation input. With onInsert configured, inserting the authored business row:

collection.insert({ id: 'one', label: 'new', rank: 1 })

was rejected with TS2345 because computed virtual fields were absent. Required readonly metadata on published read rows remains the accepted law; removing that read contract is not the proposed repair.

These are historical results. Reproduce on current main before changing production.

Secondary receiving evidence

The same record preserves reusable UpdateMutationFn<Row> admission through explicit live configs, core creation and React config hooks. These failed with TS2322/TS2769 after observing context/published aliases, but passed when a fresh Program requested diagnostics first. This checking-order sensitivity is not a stable CLI RED and must not be presented as one.

Ordinary source handlers, contextual live handlers and the free-result options factory were positive controls. All 26 final independent Programs had no setup errors. The record includes the exact diagnostic-matrix and classification hashes.

Acceptance

  1. Restore the original business-row witness and determine which failures survive on current main.
  2. Extend the public metadata type owner and mutation-handler admission owner across live-query factories and framework configs.
  3. Compare plain mutation input and reusable full-handler admission while retaining required metadata on published reads.
  4. Preserve ordinary diagnostics and observed-type checking orders, or establish a stable source discriminator for the secondary symptom.
  5. Add source-public, built/installed and framework receiving checkpoints, then show parent RED, repaired GREEN and a hostile mutation rejected by the same type law.

The runtime schema receiver's internal recorder annotation makes no public mutation-type claim. Its GREEN cannot close this issue. #2264 separately tracks restoration of the demoted mutation-handler type tests.

  1. Fresh revalidation against fetched main baabf57a0f110d57ad9bb7b81148466b18fbe0d1 reproduces the mutation-input defect. Keep open. TypeScript 5.9.3 still rejects the original no-select live-query Collection's authored insert, with onInsert configured:

    const collection = createLiveQueryCollection({
      query, onInsert: async () => {},
    })
    collection.insert({ id: 'one', label: 'new', rank: 1 })

    TS2345 says the row lacks $hasPendingWrites, $origin, $key and $collectionId. Published read rows still have these required readonly fields; no read-contract weakening or production repair was made.

    The original source-public ESNext/Bundler matrix also retains its checking-order sensitivity: raw UpdateMutationFn<Row> accepts in explicit core config, core creation and React config hooks when fresh Programs request diagnostics first; observing C/Published aliases first produces TS2322/TS2769. The free-result options factory, contextual live handler and ordinary source handler remain positive controls. All 13 final independent source Programs have zero setup/dependency diagnostics. This historical source symptom is still not a stable CLI RED.

    A distinct receiving cut now has ordinary CLI evidence: actual built/installed frozen-main DB/IVM tarballs, strict NodeNext .mts and .cts, TypeScript 5.9.3. In both formats, separate tsc invocations reject explicit raw full-handler config (TS2322), raw core creation (TS2769) and plain insert (TS2345); free-result options, contextual handlers and ordinary source handlers compile. That is 12 CLI Programs, six intended rejection cases and six passing controls. Package files match the packed artifacts. Source/Bundler and installed/NodeNext differ in both receiving boundary and compiler settings, so this does not isolate packaging as the cause.

    Installed React, mounted framework behavior, arbitrary generated mutation-row shapes and other compiler versions remain outside this revalidation. The runtime schema receiver's GREEN still cannot close these type boundaries.

Sign in to join this conversation.