Skip to content

A stored field's expression is not filled in for existing rows on a hosted tenant: switching a formula to a stored number leaves old rows NULL and a dataset sum silently reads 0 (#32443 follow-up) #32527

Closed
1 of 1 issue completed

Description

@objectstack-fleet

domain:spec#4 · marchtian · session_017ihL2gENvvRYHmL5nFTF5x

Filing gate: ① product defect (user-visible), measured by the #32443 card thread (step-1 measurement, tree 1ff9f80d, sqlite, real ObjectQL + AnalyticsServicePlugin). ⛔ Not a claim. Triage sets the grade and the lane.
Reader: the server / CLI owner of os migrate stored-expressions (packages/cli/src/commands/migrate/stored-expressions.ts) and the metadata save path that adds or changes a stored field's expression.
Dedupe: is:issue is:open stored-expressions backfill → 1 hit (a seat post); none on this.
reach: #32443 (maintainer ruling B, "a computed value can be totalled") is delivered by a stored field that carries an expression (computed on every write and kept in a column). The refusal's remedy now points authors there. An author following it on an app that already has data replaces a formula with type: 'number' + the same expression. In the measurement every existing row stayed NULL, so the dataset sum read 0 where the true value was 6, with no error. Changing an existing stored expression likewise leaves old values uncomputed. A boot warning exists, and os migrate stored-expressions --apply (and --changed) fills them, but it needs a direct database URL, which a hosted tenant does not have. The metadata save door gives no warning either.
Related: #32443 (Blocked-by only for the wording; the defect stands on main today for any stored expression added to a populated object)

Ask

Give a hosted tenant a way to fill a stored expression for existing rows when the field is added or its expression changes: at save time (a job the save starts), or through an entry the hosted tier can reach. Until rows are filled, the field's aggregates should not read as complete numbers: a warning at save, or the read path refusing or marking them. The lane rules the shape. Pin the card's case: formula → stored number on a populated object, then sum.

Sub-issues

Sub-issues

1 of 1 Issues completed
Loading 1 sub-issues

Activity

  1. removed
    pm:queue
    on Nov 12, 2026
  2. objectstack-fleet commented on Nov 12, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:skills#2 · sunhaolin · session_017xRBcTAJajXtiVBRiECvT6

    Skills follow-up owed when this card lands. This note is a pointer: no claim and no edit to this card's scope.

    PR #32635 (card #32532, Tier H, awaiting the maintainer's merge) teaches the stored-expression total in skills/objectstack-ui/rules/dashboards.md, with the limit in the published skill's own words: "existing rows stay empty until rewritten, no hosted backfill yet". Product PRs never edit skills/**, so when this card's fix lands, its PR body should name a domain:skills sub-card. That sub-card would carry three things:

    • Remove or rewrite "no hosted backfill yet", and name the backfill door an author can use.
    • Optionally, in the bytes that frees: the expression is evaluated once, at the write, so a stored field that reads today(), now(), the current user or can() keeps the value it had then (contract review 6819331213 on PR docs(skills): a total over a computed value is taught through a stored computed field, not a hook #32635, N4).
    • Optionally, the self-hosted backfill command (os migrate stored-expressions --apply), which the skill does not name today (same review, N3).
  3. objectstack-fleet commented on Nov 12, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#1 · sunhaolin · session_017xRBcSZ51q2s3nMfakhdJ3
    os-dev-report

    {
      "issue": 32527,
      "status": "done",
      "branch": "claude/issue-32527-stored-expression-fill-at-save",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/32690",
      "session": "session_017xRBcSZ51q2s3nMfakhdJ3",
      "premise_still_valid": true,
      "summary": "Ruling A delivered: the three authoring doors that make a changed object/object_extension definition live (saveMetaItem in publish mode and the doors that save through it, publishMetaItem, publishPackageDrafts) capture the object's stored computed fields before their registry write-through (the batch door before registerAdmittedBatchRows, which registers the batch ahead of its side effects) and, once the object is served and its storage synced, fill every stored row of each field that is new, turned from a formula, or has a changed expression/stored type/scale, through ObjectQL#captureStoredExpressions -> backfillStoredExpressions(fields, changed, apply, no cap): the walk os migrate stored-expressions --changed --apply runs, written as the platform under preserveAudit. Each changed field is reported on the doors' existing advisories (stored-expression-filled info with 'N rows of M written', or stored-expression-fill-incomplete warning naming what is left and the command); no new published field, so no Clause-2 stop. Measured gaps: doors as listed (rollbackMetaItem/revertCommit write a changed definition through without storage sync or fill, noted); fill time ~0.7 ms/row on SQLite bare engine (1k 1.26 s, 5k 4.7 s, 20k 14.1 s, 100k 67.6 s), one synchronous walk inside the answer, no background continuation. Deviation from the suggested route: writes as the platform, not the caller (save and single publish doors carry no caller context; caller-scoped writes leave unreadable rows unfilled).",
      "tests": "HEAD 825dc866bd. objectql: pnpm --filter @objectstack/objectql exec vitest run --maxWorkers=2 -> exit 0, Test Files 588 passed (588), Tests 12377 passed (12377). metadata-protocol: same form -> exit 0, Test Files 336 passed | 7 skipped (343), Tests 22738 passed | 36 skipped (22774). New/extended file src/stored-expression-backfill.test.ts: 43/43. Dogfood: pnpm --filter '@objectstack/dogfood^...' build exit 0, then test/stored-expression-fill-at-change.dogfood.test.ts exit 0, Tests 2 passed (2) (real stack, SQLite: PUT formula -> 3 rows -> PUT type number + same expression -> advisory '3 rows of 3 written' -> POST /analytics/dataset/query sum = 6; draft + POST /meta/object/NAME/publish same). Ablations via scripts/ablation-replace.mjs (anchor 1->0, restored to HEAD blob, git diff HEAD empty); metadata-protocol legs rebuilt and proved in dist/ with scripts/ablation-dist-preflight.mjs, absent after restore build: A1 save fill call removed -> 'the card' red (expected [null,null,null] to deeply equal [1,2,3]); A2 change detection always-changed -> 2 red; A3 empty-object early return removed -> red (expected true to be false); A4 storage refusal passed as not refused -> red (3 rows written); A5 fields unknown refusal disabled -> red; A6 signature key sort removed -> red (expected ['qty_double'] to deeply equal []); A8 single publish fill call removed -> red; A9 batch fill call removed -> red (expected +0 to be 6); A7 save door publish-mode guard on capture removed -> STAYED GREEN (expected: a draft save writes nothing through, capture diffs to nothing; the draft pin is held by the publish-only write-through). Dogfood ablation (both single-object door fill calls removed, metadata-protocol rebuilt, marker in dist): 2 failed (2); restored, rebuilt, marker absent, 2 passed. First metadata-protocol ablation round ran without rebuild (read unmutated dist), stayed green on every leg, measured nothing, not counted.",
      "gates": "Local, HEAD 825dc866bd: node scripts/pm/dispatch-gates.mjs --commands -> 77 families; all 77 run, exit 0 each (exit captured before any pipe, runner writes ex=$? per command), except pnpm check:dual-build-cjs-loads first run exit 1 on a partial build (mcp/trigger-api d.ts not yet emitted while the dogfood closure built), re-run after the full build exit 0; pnpm check:type-check-debt first run exit 3 PREREQUISITE NOT MET (lock not acquired), re-run under os-verify-lock exit 0. --ran reconciliation: 77 derived, 77 run, 0 NOT-MEASURED, 0 UNRUN. pnpm lint (eslint . --no-inline-config) exit 0. typecheck objectql exit 0, metadata-protocol exit 0. check-platform-checklist not owed (no export renamed or removed). CI on PR #32690 head 825dc866bd at report time: Check Changeset, Lint (ESLint, PM dispatch-gates, docs & code guards, repo & tooling gates, CI/release/engine gates, scoped x3), Type Check (workspace, source gates, consumer gates, debt ledger), Governed Surface Queue Guard, PR-body guards, Spec property liveness, Check PR Size: in_progress; opt-in/queue rows skipped. Test Core, Build Core, Dogfood Regression Gate: not yet listed.",
      "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm",
      "line_budget": "n/a — no skills/** file touched",
      "files_changed": [
        ".changeset/32527-stored-expression-fill-at-change.md (+16)",
        "packages/metadata-protocol/src/host-engine.ts (+10)",
        "packages/metadata-protocol/src/protocol-history-and-publish.ts (+35 -1)",
        "packages/metadata-protocol/src/protocol-save.ts (+16)",
        "packages/metadata-protocol/src/protocol-stored-expression-fill.ts (+209, new)",
        "packages/objectql/src/engine.ts (+15)",
        "packages/objectql/src/index.ts (+2)",
        "packages/objectql/src/stored-expression-backfill.test.ts (+353)",
        "packages/objectql/src/stored-expression-backfill.ts (+152)",
        "packages/qa/dogfood/test/stored-expression-fill-at-change.dogfood.test.ts (+148, new)"
      ],
      "deviations": [
        "Fill writes as the platform (system context, preserveAudit), not as the caller the PM route suggested: saveMetaItem and publishMetaItem receive no caller execution context, and a caller-scoped write leaves rows the caller cannot read unfilled; the ruling says the platform fills.",
        "File surface: packages/metadata-protocol/src/host-engine.ts (optional engine member typing) and packages/objectql/src/engine.ts (one delegating method) and objectql/src/index.ts (one type export) are beyond the files the claim names, inside its packages and the computeStoredExpressionsOver seam it names.",
        "Door tests live as top-level describes in the existing harness file stored-expression-backfill.test.ts (ruling record 6583487846), with their own in-file driver, not in a new file.",
        "Branch merged with origin/main once before the PR (825dc866bd); main moved again after (9 commits, none in metadata-protocol or objectql) and was not merged again, per AGENTS §10 (merge after open only on conflict, main-caused red or queue removal).",
        "Dispatch asked to also run pnpm lint: run, exit 0."
      ],
      "mcp_calls": "0",
      "api_writes": "3 — via the fleet-write relay: pr_create stroke fw-20261112T101345Z-565c75 (POST /repos/objectstack-ai/objectstack/pulls, POST /repos/objectstack-ai/objectstack/issues/32690/assignees), and post-stamped comment POST /repos/objectstack-ai/objectstack/issues/32527/comments (this report). git push is not counted.",
      "open_questions": [
        {
          "question": "Clause-② line: the claim declares `no`, copied verbatim into the PR body and changeset. The diff adds a public method (ObjectQL#captureStoredExpressions), an exported type (StoredExpressionCapture) and an option (backfillStoredExpressions `fields`) to @objectstack/objectql, which by the Clause-② question reads as `yes (widening)`.",
          "options": [
            "A keep `no` (the additions are a seam the metadata protocol reaches, not an authoring surface)",
            "B the seat corrects both lines to `Clause-②: yes (widening)` before landing"
          ],
          "recommendation": "B, because the line answers whether the public surface grew, and it did; level stays patch since Metadata-protocol is none."
        },
        {
          "question": "History doors: rollbackMetaItem and revertCommit write a changed definition through to the registry with no storage sync and no fill, so a rollback that changes a stored expression leaves rows on the expression rolled away from (read from their host Pick lists, not reproduced).",
          "options": [
            "A a follow-up card in this family covering the history doors (sync + fill)",
            "B leave as is: the ruling names save and publish only"
          ],
          "recommendation": "A, because a rollback makes a changed definition live exactly as a publish does; it needs a reproduction first."
        },
        {
          "question": "Large objects: the fill is one synchronous walk inside the answer (~0.7 ms/row on SQLite bare engine; 100k rows ~68 s). No background continuation was built.",
          "options": [
            "A keep synchronous (precedent: the #24253 publish backfill is unbounded and synchronous)",
            "B a follow-up: continue past a row budget after the answer, with the receipt saying so"
          ],
          "recommendation": "A until a real object outgrows it; B needs a durable job (an in-process continuation is lost on restart, and a changed expression is invisible to the boot advisory)."
        }
      ],
      "security_findings": "none",
      "out_of_scope_findings": [
        "carrier: none · noted, not filed — rollbackMetaItem/revertCommit make a changed object definition live without storage sync or stored-expression fill (read-only inference from host Pick lists; same family as this card; in PR Acceptance notes and open_questions)",
        "carrier: none · noted, not filed — keysetWalk reports truncated when an object holds exactly `max` rows (measured: 100,000 rows under the CLI default cap 100,000); the door passes no cap",
        "carrier: none · noted, not filed — the spec's advisories description does not name the door notices (object-storage-sync-refused, and now stored-expression-filled / stored-expression-fill-incomplete); packages/spec is outside this card's fence"
      ]
    }
  4. objectstack-fleet commented on Nov 12, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#1 · sunhaolin · session_017xRBcSZ51q2s3nMfakhdJ3

    Claim amendment to 6816661444 · 2026-11-12T10:19Z: PR #32690 widens a published face of @objectstack/objectql: the public ObjectQL#captureStoredExpressions, the exported type StoredExpressionCapture, and the fields option of backfillStoredExpressions. No new field is added to a published door answer; the per-field count rides the doors' existing advisories. The declaration is corrected:

    Clause-②: yes (widening)
    Metadata-protocol: none

    The changeset line is fixed by the dev and the PR body line by the seat. A TIER_DEFAULT contract review of the declaration face is under way before ACCEPT.

  5. objectstack-fleet commented on Nov 12, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#1 · sunhaolin · session_017xRBcSZ51q2s3nMfakhdJ3
    Release: session_017xRBcSZ51q2s3nMfakhdJ3 / ruling A is built in draft PR #32690 and owes the delta contract review of patch round 2, the PR-body fixes, ACCEPT and landing / maintainer 「后续契约复审留给下一任」, 「本轮开发完就收工」 (this session, 2026-11-12)
    Resume-from: claude/issue-32527-stored-expression-fill-at-save@5c740006c8

    Hand-over · 2026-11-12T11:55Z

    Built (PR #32690, Fixes #32527, draft, head 5c740006). The three save and publish doors fill the changed stored computed fields after the storage sync, and report per field on the existing advisories. Contract review PASS 6821120243 (TIER_DEFAULT) at dd8df6b3; claim amendment 6820941403 (Clause-②: yes (widening)). CI on 5c740006 completed with no failure reported, which is the reading at hand-over.

    Patch round 2, carried out by the dev (dd8df6b3..5c740006):

    • S2. Each fill write is conditional on the row's stored updated_at: the engine's by-id write precondition (ADR-0142 D4), module-internal and not re-exported. A row an engine write moved mid-walk is not written over, and it is counted as concurrentRows, in the per-field notice too. A row with no stamp, or on a driver with no updateMany, is written unconditionally (one warning). The CLI walk shares the code and gets the same guard.
    • Pin and ablation. A write landing mid-walk keeps 2099-01-01T00:00:00.000Z and its own computed value. Ablating the guard turns it red (expected '2026-01-02T00:00:00.000Z' to be '2099-01-01T00:00:00.000Z'); the blob was restored.
    • Measured on SQLite. 1,000 rows take 1.34 s and 5,000 rows 4.9 s, with every conditional write matching (before the guard: 1.26 s and 4.7 s). With an edit landing mid-walk over 600 rows, 599 were written and 1 was counted concurrent.
    • The rest of the round.
    • Test Core (4/8) red on 065bc54f and 169ffde5, now fixed. Both failures were this PR's: the missing ledger row, and the door fixture's rows carrying no stamp.
    • Dev's local gates.
      • objectql: 588 files and 12378 tests pass at 5c740006.
      • metadata-protocol (22738 tests), the typechecks and the dogfood file pass at 169ffde5; only objectql test files changed after that.
      • pnpm lint: exit 0.
      • dispatch-gates: 104 derived, 102 exit 0, and 2 NOT MEASURED locally (check:skill-examples and check:dual-build-cjs-loads, exit 3, unbuilt prerequisites), which are left to CI.

    Owed by the next seat, in order:

    1. A TIER_DEFAULT delta contract review of dd8df6b3..5c740006. It covers the S2 guard (the conditional-write precondition, its fallback paths, and the CLI path now sharing it) and the per-field notice text.
    2. Rewrite the PR body (the dev does not patch it):
      • Its Acceptance notes still say Clause-② was "declared no" (nit N2). The top line already reads yes (widening).
      • Add the S2 note. The dev's wording: "A write that lands while the fill runs is not written over. The fill keeps each row's updated_at (preserveAudit), so a plain write would put the stamp from its page read back over a user's edit made in between. Each fill write is therefore conditional on that stamp: it uses the engine's by-id write precondition (ADR-0142 D4, the driver's conditional update over { id, updated_at }). When the condition matches no row, the row is read again. If it holds another stamp, or is gone, an engine write moved it and already computed every stored field under the definition now live, so the fill leaves it alone and counts it (concurrentRows, and in the per-field notice: "N rows written by another write while the fill ran computed it there, and were not written over"). If it still holds the same stamp, nothing moved it, and it is written unconditionally. A row with no stamp, including any row of a federated object, is written unconditionally. On a driver with no updateMany the engine falls back to the unconditional write and warns once. os migrate stored-expressions --apply shares the walk and gets the guard too."
    3. ACCEPT, then landing.

    Accepted and left for the maintainer to see: the fill is one synchronous walk inside the request (about 0.7 ms per row, so 100k rows take about 68 s). This answers the ruling's confidence gap (1).

    State change: pm:dispatched → pm:queue, sunhaolin unassigned. The PR stays a draft and is labelled needs:contract-review.

  6. added
    pm:queue
    and removed
    pm:dispatched
    on Nov 12, 2026
  7. objectstack-fleet commented on Nov 12, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#1 · os-sales · session_01L6bhgVaKJ9TPfXPRhdqx3e

    Claim: PM loop round 1 · resume of a released card (review and landing leg)
    Session: session_01L6bhgVaKJ9TPfXPRhdqx3e (seat)
    Account: os-sales
    Branch: claude/issue-32527-stored-expression-fill-at-save
    Worktree: objectstack-issue-32527
    Domain: domain:server
    Seat: domain:server#1
    File surface: packages/metadata-protocol/src/ (the save door protocol-save.ts and the publish door protocol-history-and-publish.ts / protocol-publish-backfill.ts, plus protocol.ts only for wiring), packages/objectql/src/stored-expression-backfill.ts and the computeStoredExpressionsOver seam, their tests, packages/qa/dogfood/test/** for the door-level pin, root .changeset/. ⛔ Not packages/spec/**, not packages/cli/src/commands/migrate/stored-expressions.ts beyond reuse, not the boot advisory. Stop on breach; explain in the report.
    Container & model: M, mode:subagent (review leg: the owed TIER_DEFAULT delta contract review of dd8df6b3..5c740006 runs in an isolated subagent; a must-fix returns as a fix round on the same branch), model: TIER_DEFAULT (dispatch-gates --tier: no path-derived mandate), effort: xhigh (p1)
    Clause-②: yes (widening)
    Metadata-protocol: none
    Responsibility: the metadata save and publish doors (objectstack: metadata-protocol + objectql), which make a stored expression live without filling existing rows | os migrate stored-expressions --apply and the boot warning, which need a direct database URL a hosted tenant does not have | every author who adds a stored computed field or changes its expression on a populated object, today, and the remedy #32443 now prescribes
    Thread-read: 6822919230
    Premise: holds (read-only premise reading 2026-11-12T06:37Z on origin/main 0f9b5653: backfillStoredExpressions( has 2 non-test lines, the definition and the CLI call; the publish backfill handles defaultValue only)
    Serial constraints cleared: PR #32447 (#32366, seat 2) and PR #32513 (#31985, epic seat) touch protocol-history-and-publish.ts / protocol.ts / objectql/src/plugin.ts: ordinary concurrency (not a SINGLE_CLAIM_PATHS file), the later lander merges; no live claim holds protocol-save.ts or stored-expression-backfill.ts.

    Ruling-ref: 6816429574 (letter A, maintainer 「同意」). Clause-② note: the seat cannot settle from paths whether the per-field count needs a new field on a published receipt; the dev measures it, and a new published field is a stop (needs_decision), not a build.
    Resume-from: claude/issue-32527-stored-expression-fill-at-save@5c740006c8

    Resumes release 6822919230 (domain:server#1 · sunhaolin, clock-out). The Clause-②: / Metadata-protocol: lines above are the corrected reading the release and its claim amendments carry. Owed on this claim: PR #32690 (draft, head 5c740006): delta contract review, the two PR-body fixes listed in release 6822919230, ACCEPT, landing. Order: the maintainer 「server#1 下班了,他的任务你也全部接手」 (project "Objectstack security ui", 2026-11-12T12:26:50Z). Original claim: 6816661444.

  8. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 12, 2026
  9. objectstack-fleet commented on Nov 12, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#1 · os-sales · session_01L6bhgVaKJ9TPfXPRhdqx3e

    Landed: PR #32690 merged as af90f307c (ACCEPT 6827912158, delta PASS 6824769994), on the maintainer's exception for this non-epic p1. The card closed with the merge (Fixes #32527). Follow-up #32732 stays open under this card.

    State: pm:dispatched removed; card closed.

  10. removed
    pm:dispatched
    on Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:formuladomain:serverpriority:p1

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions