Skip to content

Roll-up summary recompute: one grouped aggregate per batch, not per child row per field #33795

Closed

Description

@objectstack-fleet

domain:server#5 · zhuangjianguo · session_01QsR2jRsWwTRkuRCyQwvpAG

Part of epic #33631 (item R10). Measured by #33701: addendum 6893156419 on #33631, bench PR #33783.

维护者速读

  • 问题:子对象上有汇总字段(roll-up summary)时,批量写入会为每个子记录、每个汇总字段各重算一次父记录。批量更新 50 行、2 个汇总字段要执行 758 条 SQL,不带汇总字段时是 358 条。
  • 影响:本地数据库每批多出 100–200 ms。网络数据库按实测往返时间折算,每批多约 1 秒(2 ms 往返)到 4 秒(10 ms 往返)。
  • 建议:批量写入结束时按父记录分组,一次聚合算完所有汇总字段,再对每个父记录发一条更新。实测重算部分从 80 条语句降到 11 条,结果相同。

Today (statements exact on SQLite and PostgreSQL 16)

Each recompute is 4 statements per summary field: the aggregate select sum(f) / count(*) … where fk = ?, the parent read twice in full, and one update parent set FIELD = ?. Seam: packages/objectql/src/engine-summaries-and-expansion.ts (the per-parent, per-field recompute loop).

write (admin) 0 summaries 1 2
createMany 50 rows, 10 parents 209 249 289
updateMany 50 rows, 1 or 10 parents 358 558 758
insert 1 row 13 17 21

createMany pays per distinct parent per field. updateMany pays per child row per field, because each row is its own engine update. With two fields the same parent is also updated twice, once per field.

Target

At the end of a batch, run one grouped aggregate for every summary descriptor and every touched parent (select fk, sum(f), count(*) … where fk in (…) group by fk). Then run one update per parent that carries all its summary fields. micro.mjs I10 (10 parents × 2 fields) measured 80 → 11 statements, SQLite 1.65 → 0.20 ms, PostgreSQL 15.8 → 2.15 ms, with the same values. For updateMany, the recompute must first be deferred from per row to the end of the batch.

Constraints

  • Values are identical to today for every summary kind (count, sum, min, max, and filtered summaries if the descriptor has a filter), on both dialects.
  • A parent's own write path (hooks, audit, realtime, validation) still runs for each parent whose summary changed. Collapsing a parent's per-field updates into one update is the intended change. If that collapse makes a parent hook fire fewer times than today, the PR must say so in its body.
  • A single-row insert or update keeps today's result. The batch path is where the gain is.
  • Cross-object parents (a summary over a summary) recompute in dependency order, as today.

Pins

Statement-count pins for updateMany and createMany with 0, 1 and 2 summary fields, and value parity across every summary kind on both gates. Ablate the deferral and the grouping separately. The bench rollup* scenarios on PR #33783 are the before/after reading.

Reader

domain:server area A4 (objectql engine). Size M. Serial with #33699 (cascade delete batching, same engine write path); check the hot file before claiming.

Dedupe

Searched roll-up summary recompute, summary updateMany, engine-summaries-and-expansion: only #33631 and #33701 mention it.


Generated by Claude Code

Activity

  1. added
    enhancement
    priority:p2
    pm:queue
    domain:server
    on Nov 15, 2026
  2. objectstack-fleet commented on Nov 16, 2026

    @objectstack-fleet
    ContributorAuthor

    coordinator#1 · os-project-manager · session_01FEkQ5p5codnUGsdGxBfaL9

    Ruling: grade p1 · maintainer 「按价值挑三张升 p1」 (the option he chose on the decision card) · recorded 2026-11-16T13:04Z

    Recorded by the project's decision thread. The maintainer's standing rule sends every decision through a dedicated thread that evaluates it and puts it to him there. He chose at 2026-11-16T13:02:17Z. Decision thread cmsg_01TenzsRopZj4jMbvjX8uz1X2H6qQ8ciHX7XMq2gtnGnNg, card cmsg_01TenzsRopZj4jMbvjX8uz1XYUuhvgV1Qvy2bQMvD6WU6k, choice record cmsg_01TenzsRopZj4jMbvjX8uz1X3E4wdKJwaDmk7QBAWiuQKK.

    Thread-read: none (the card has no comment). Labels at the read: enhancement, priority:p2, pm:queue, domain:server, lease:A4, unassigned.

    The question he was asked

    His intake rule of 2026-11-16 for the repo:objectstack#1 seat is 「除了前任的任务继续处理,后续只认领 p1 或者阻塞 p1 的任务」. The open cards under two p1 epics, #31763 (one-way sync-in) and #33631 (SQL performance), are graded p2, so the seat cannot claim them. How should they be opened?

    The four options on the card, as he read them:

    The ruling

    #33664, #33795 and #34206 are raised to p1 and may be claimed. The children of the sync-in epic and the other SQL-performance cards stay p2. The sync-in chain gets one fixed dev slot once this batch of p1 work is done.

    Why this card was one of the three, as told to him: A batch update of 50 child rows under two roll-up summary fields runs 758 statements against 358 without them. On a hosted environment, where the database is across the network, the card's own figures put that at about 1 to 4 seconds more per batch.

    The p2 on this card came from the grading pass under the rules he adopted on 2026-11-13. This is his own later word on the card and sets the grade.

    State


    Generated by Claude Code

  3. added
    priority:p1
    and removed
    priority:p2
    on Nov 16, 2026
  4. objectstack-fleet commented on Nov 16, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#1 · os-project-manager · session_01FEkQ5pHNFS9mn8hS13iGyL

    Claim: PM loop · seat-handed p1 (Ruling-ref 6917226239) · 2026-11-16T13:09Z
    Session: session_01FEkQ5pHNFS9mn8hS13iGyL
    Account: os-project-manager
    Branch: claude/issue-33795-rollup-grouped-recompute
    Worktree: objectstack-issue-33795
    Domain: domain:server
    Seat: repo:objectstack#1
    File surface: packages/objectql/src/engine-summaries-and-expansion.ts and the engine batch write paths it is called from (createMany / updateMany deferral) in packages/objectql/src/**; new test files named for this card; .changeset/** (stop on breach; explain in the report)
    Container & model: M, mode:subagent, model: TIER_DEFAULT, effort: high
    Clause-②: no (same values for every summary kind on both dialects; fewer statements; no accepted shape or public export widens; if collapsing a parent's per-field updates fires a parent hook fewer times, the PR body says so, as the card asks; the dev confirms)
    Metadata-protocol: none
    Responsibility: objectstack (objectql engine roll-up summary recompute): batch writes recompute the parent once per child row per summary field (updateMany 50 rows, 2 fields: 758 vs 358 statements) | the per-parent per-field loop in engine-summaries-and-expansion.ts | every batch write to a child object carrying roll-up summaries; network databases pay ~1–4 s per batch
    Thread-read: 6917226239
    Premise: holds (card measured on SQLite and PostgreSQL 16 by #33701, bench PR #33783; the dev re-measures red-first on main)
    Serial constraints cleared: p0 #34397 (this area, in flight on the roll-up install path of #34282): the dev for this card is dispatched after #34397's fix lands and builds on it; #33699 (cascade delete batching, same engine write path) is open, unclaimed (lease:A4 left by the predecessor, nothing built); #34353 touches engine-summaries-and-expansion.ts by one comment line and is in the merge queue; the dev runs git merge-tree against every open PR touching its files before push
    Pre-claim lane: domain:server (packages/objectql engine, area A4 lineage)
    Pre-claim deps: none
    Prior rulings read: grade ruling 6917226239 (p1, 「按价值挑三张升 p1」); card body constraints (identical values, parent write path still runs, single-row path unchanged, dependency order kept); no further ruling found on the card

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

    @objectstack-fleet
    ContributorAuthor

    coordinator#1 · os-project-manager · session_01FEkQ5potJ3Z7pQRGQaBAnb

    Ruling: letter A · maintainer 「A 整批结束后统一重算」 (the option he chose on the decision card) · recorded 2026-11-16T16:15Z

    Recorded by the project's decision thread. The maintainer's standing rule sends every decision through a dedicated thread that evaluates it and puts it to him there. He chose at 2026-11-16T16:14:31Z. Decision thread cmsg_01TenzsRopZj4jMbvjX8uz1XVqpojnq7g9fvtRtgyVwMyt, card cmsg_01TenzsRopZj4jMbvjX8uz1X8tyzev5G99zFa8r7DwPNve, choice record cmsg_01TenzsRopZj4jMbvjX8uz1X6fVzvo8EHhnojw7N3YEC3w. The analysis is in the project files at pm-orders/review/33795-decision-analysis.md.

    Thread-read: 6917333613 (the newest comment at the read). Labels at the read: enhancement, priority:p1, pm:dispatched, domain:server, lease:o1-B.

    The question he was asked

    The grouping half of this card is built on claude/issue-33795-rollup-grouped-recompute (head 02e274b, no PR yet). The other half, deferring the recompute of a bulk update to the end of the batch, cannot be built inside the claim: the batch update door in metadata-protocol (runUpdateManyLoop) calls the engine one row at a time through the engine contract, so the engine never sees a batch. Question on the card: 「裁定批量更新时父记录汇总要不要改成整批结束后统一重算」.

    The three options, as he read them:

    • 「A 整批结束后统一重算」: 「引擎接口加一个可选成员。批量改50行、2个汇总字段约608降到约390条语句(估),接近无汇总的358。批次进行中父记录汇总是批前的值。工作量中等。」 (recommended)
    • 「B 引擎新增批量更新动作」: 「快慢同A,但引擎里多出第二条逐行更新路径,以后每条规矩要两边一起改;只覆盖批量更新这一个入口,工作量更大。」
    • 「C 只落已建成的一半」: 「批量新建和单条更新已省。批量更新2个字段仍约608对358,1个字段完全不变。托管环境每批仍多约0.5到2.5秒,卡片目标只完成一半。」

    Stated to him beside the card (message cmsg_01TenzsRopZj4jMbvjX8uz1X9t7iEFZkicaVYzEPmZEiAH), in his language: all three options include the built half, which changes one thing a customer can see. A parent with several summary fields now runs its automation, validation, audit entry and realtime event once per recompute, not once per field. The message said that choosing any option accepts that change and asked him to reply if he did not. He chose nine minutes after it was posted and wrote no objection.

    The ruling

    A. The engine contract gains an optional batch-scope member. Inside it, roll-up recompute is recorded and not run, and it runs once when the scope ends. The bulk update door and the update arm of the generic batch door use it. The built half's "once per recompute, not once per field" on the parent's write path is accepted.

    This is the ruling the header of packages/spec/src/contracts/objectql-engine.ts asks for when a member is optional ("optional by ruling, not by this default").

    Parameters settled with the ruling

    These came with the recommendation he chose. They need no further question to him.

    1. The built half (02e274b) goes ahead as its own PR, Part of #33795, through L1 and the contract review. It does not wait for the second PR. Opening that PR waits on his approval in the area thread, which is a separate matter from this ruling.
    2. The second PR carries the deferral and says Fixes #33795. The area amends its claimed file surface first (packages/spec/src/contracts/objectql-engine.ts, packages/metadata-protocol/src/host-engine.ts, packages/metadata-protocol/src/protocol-batch-data.ts, and the pins).
    3. Shape of the member:
      • A callback form, entered and left by the engine, as transaction is. No begin and end pair. A nested call joins the outer scope.
      • Optional on both contracts (IObjectQLEngine and MetadataHostEngine). The door probes for it. An engine without it keeps today's per-row recompute: same values, more statements.
      • The scope defers roll-up recompute only. Hooks, validation, audit and realtime of each row run where they run today.
      • Atomic batch: the one recompute runs before the commit, and a recompute failure rolls the batch back, as a per-row failure does today. Non-atomic batch: the one recompute runs on every way out of the loop (finished, stopped on a failed row, thrown), over the parents of the rows that landed. A recompute failure there is logged as today and the rows stay written.
      • A summary over a summary still recomputes in dependency order.
    4. Pins, as the card asks: statement counts for updateMany and createMany with 0, 1 and 2 summary fields; value parity for every summary kind on SQLite and PostgreSQL; the grouping and the deferral ablated separately. Three more: a rule that reads the parent's summary inside the batch sees the value from before the batch; a non-atomic batch stopped by a failed row still recomputes the parents of the rows that landed; an engine without the member gives the same values.
    5. The PR body and the changeset state both visible changes: the parent's hooks, validation, audit and realtime run once per recompute; and during a bulk update the parent's summary holds its pre-batch value until the batch ends, as it already does for createMany and a predicate update.
    6. Contract review PASS before the second PR lands.

    What was not measured

    • "About 608 to about 390 statements" is the developer's estimate. The second PR replaces it with the measured counts.
    • Nobody checked whether an app today reads a parent's summary from a child-side rule or hook. Such a rule would see the pre-batch value during a bulk update.
    • For the contract reviewer of the built half, outside this ruling: the grouped aggregate computes every parent's value before the first parent write, so the time between read and write is longer than before. Whether a concurrent child write on the same parent needs handling is the reviewer's call. This is a code reading, not a measurement.

    State

    • This record changes no label and no claim. The file surface amendment and the dispatch are the area's (lease:o1-B).
    • Not chosen: B (a second per-row update path, one door only) and C (the bulk update case he raised this card to p1 for would stay as measured).
    • Knock: Notify: ruling to the repo:objectstack#1 mailbox, PR pm:mailbox — repo:objectstack#1 · os-project-manager #34367.

    Generated by Claude Code

  7. objectstack-fleet commented on Nov 16, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#1 · os-project-manager · session_01FEkQ5pHNFS9mn8hS13iGyL
    os-dev-report

    {
      "issue": 33795,
      "status": "blocked",
      "branch": "claude/issue-33795-rollup-grouped-recompute",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/34421",
      "session": "session_01FEkQ5pHNFS9mn8hS13iGyL",
      "premise_still_valid": true,
      "final_head": "02e274bd70d55ebdf1bee21f510133aef0c85ab6",
      "summary": "Grouping half built (Part of #33795). recomputeSummaries works in two phases: each descriptor computes all touched parents in one grouped aggregate (new aggregateSummaryValues: where fk in (chunk <= 500) group by fk, filter ANDed, empty-set fallback kept; ADR-0144 D6 rollup channel kept only when every id is concrete); a single parent still uses aggregateSummaryValue unchanged. Each parent is then written ONCE with all its summary fields. A roll-up graph leading back to the child object (self-reference or cycle) keeps per-parent order, still one write per parent. Failure shape kept (one failure per parent per field). Disclosed behaviour change, allowed by the card: with N summary fields the parent's update path (hooks, validation, audit, realtime) runs once per recompute instead of N times, and a grandparent recompute once per parent write. BLOCKED on a ruling: the updateMany deferral half needs an engine-contract member (runUpdateManyLoop in metadata-protocol reaches the engine one row at a time); routed by the seat to the maintainer (options A/B/C). The relay pr_create was first refused by the session's auto-mode check; the maintainer approved it by name in the area thread and the area opened PR #34421 from the dev's prepared action file.",
      "statements": "engine-level, identical on SQLite and PostgreSQL 16, 0/1/2 summary fields: createMany 50 rows over 10 parents 1/41/81 -> 1/32/33; 50 single-row updates 150/350/550 -> 150/350/400",
      "tests": "Red-first on base 80cdbd4e0f: dogfood pin 2 failed | 2 passed (both statement pins red on SQLite and PostgreSQL, value parity green); unit pins 2 failed | 27 passed (one-write and one-hook pins). At head: dogfood rollup-grouped-recompute-33795.test.ts 4/4 with local PG 16.15. objectql suite 13472/13475 first run; the 3 failures were test doubles whose matcher ignored $in, taught $in with no assertion changed; rerun 61/61. Ablations: grouping ablated -> createMany 1/41/51, 2 failed; collapse ablated -> updateLoop 150/350/550, 2 failed; values green in both; restored to HEAD blobs.",
      "gates": "objectql typecheck exit 0. dispatch-gates 71 derived, 70 exit 0, check:dual-build-cjs-loads exit 3 NOT MEASURED; --ran exit 0. dogfood typecheck NOT MEASURED locally (unbuilt closure; 0 errors name the new file). Check-runs: PR just opened, none yet.",
      "dogfood_battery": "n/a, no ! title, Clause-②: no",
      "open_questions": [
        "updateMany deferral route A/B/C (with the seat and maintainer)"
      ],
      "out_of_scope_findings": [
        "no CI job provisions OS_TEST_POSTGRES_URL for @objectstack/dogfood, so the PostgreSQL cell of the new parity test is a named skip in CI; measured locally on PG 16.15"
      ],
      "mcp_calls": "0",
      "api_writes": "area: 1 relay pr_create (PR #34421, read-back identical) + this comment"
    }
  8. objectstack-fleet commented on Nov 16, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#1 · os-project-manager · session_01FEkQ5pHNFS9mn8hS13iGyL

    Claim amendment · file surface and second PR · 2026-11-16T16:18Z

    Ruling-ref 6922040858 (letter A, 「A 整批结束后统一重算」). Claim 6917333613 is amended as the ruling's parameter 2 asks:

    • First PR: perf(objectql): recompute roll-up summaries with one grouped aggregate per field and one write per parent #34421 (Part of #33795, the grouped recompute, head 02e274bd) goes through L1 and the contract review on its own, unchanged in scope.
    • Second PR: branch claude/issue-33795-batch-deferral, worktree objectstack-issue-33795-b, built on the first PR's branch (merging origin/main once perf(objectql): recompute roll-up summaries with one grouped aggregate per field and one write per parent #34421 lands), Fixes #33795.
    • Added file surface (second PR): packages/spec/src/contracts/objectql-engine.ts (the optional batch-scope member on IObjectQLEngine), packages/metadata-protocol/src/host-engine.ts (the same member, optional, on MetadataHostEngine), packages/metadata-protocol/src/protocol-batch-data.ts (runUpdateManyLoop and the update arm of runBatchDataLoop probe for it), the engine implementation in packages/objectql/src/**, their tests and pins, .changeset/**.
    • Clause-② (second PR): yes (widening): a new optional member on two published contracts, optional by this ruling; no existing member or accepted value narrows. Contract review PASS before landing (parameter 6).
    • Shape and pins: as parameters 3 to 5 of the ruling, read by the dev from the record itself.
  9. objectstack-fleet commented on Nov 16, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#1 · os-project-manager · session_01FEkQ5oe2Rer5VB78pdZqkr

    Claim amendment · second PR taken over from area o1-B · 2026-11-16T16:40Z

    Ruling-ref 6922040858 (letter A, 「A 整批结束后统一重算」). Amends claim 6917333613 and amendment 6922111366: the second PR (batch deferral) moves from area o1-B (session session_01FEkQ5pHNFS9mn8hS13iGyL) to its own card thread.

    Session: session_01FEkQ5pmEYLVFDcQ1Z1CS8H
    Thread session: session_01FEkQ5oe2Rer5VB78pdZqkr
    Account: os-project-manager
    Seat: repo:objectstack#1
    Container & model: M (contract change), mode:thread, model: default, effort: default
    Branch: claude/project-thread-vah7al (the platform pins this thread to that branch; it starts from the pushed head 7480459d of claude/issue-33795-batch-deferral, which stays as the hand-over record)
    Resume-from: claude/issue-33795-batch-deferral@7480459d
    Stacked on: PR #34421 (grouped recompute, head 02e274bd, stays with o1-B); origin/main is merged in once #34421 lands.
    File surface: as amendment 6922111366 (packages/spec/src/contracts/objectql-engine.ts, packages/metadata-protocol/src/host-engine.ts, packages/metadata-protocol/src/protocol-batch-data.ts, the engine in packages/objectql/src/**, their tests and pins, .changeset/**), plus packages/qa/dogfood (the statement-count pins, and its devDependencies if the pin needs @objectstack/metadata-protocol) and the generated spec artifacts.
    Clause-②: yes (widening)
    Metadata-protocol: none
    Seat route (not a maintainer ruling) on the open question from the hand-over: an atomic batch whose end-of-batch recompute fails answers today's 200 rolled-back envelope (A), so the response contract does not move; the PR pins it.
    Thread-read: 6922111366 (newest comment at the read).

  10. objectstack-fleet commented on Nov 16, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#1 · os-project-manager · session_01FEkQ5pHNFS9mn8hS13iGyL
    os-dev-report

    Fix round 1 on PR #34421 (S1 pinned and ablated, N1 fixed, N2 left to the contract review). Head 1789606ebf.

    {
      "issue": 33795,
      "status": "done",
      "branch": "claude/issue-33795-rollup-grouped-recompute",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/34421",
      "session": "session_01FEkQ5pHNFS9mn8hS13iGyL (mode:subagent, shared with area o1-B)",
      "head": "1789606ebfb6e2eab004baf912a1a11ef6cb490f",
      "premise_still_valid": true,
      "summary": "Fix round 1 for L1 ACCEPT 6923522845. S1: a pin in record-currency-guards.test.ts sends one insert of four pp_line rows across inv_usd and inv_eur through the grouped aggregateSummaryValues (one pp_line read with invoice $in both ids), asserts no recompute failure, subtotals 150/100 equal to the one-line-at-a-time engine, and that the same grouped statement without the roll-up channel is still refused INVALID_FIELD. It was green on first run, so the grouped path's channel was ablated: red with SummaryRecomputeError for 2 parents, then restored. N1: the ROLLUP_AGGREGATE_OPTION docblock (and the module header) now names aggregateSummaryValues as a second setter. N2: no code change, left for the contract review.",
      "summary_for_pr_body": "## Fix round 1\n\nAnswers L1 ACCEPT 6923522845 (thread L1-a). Head `1789606ebf`, one commit on top of `02e274bd70`. No behaviour change, no changeset change.\n\n- **S1 (pinned).** `record-currency-guards.test.ts` gains `[#33795] a batch of lines across two parents totals each in one grouped aggregate, as one line at a time does`. One `insert` of four `pp_line` rows across `inv_usd` (USD) and `inv_eur` (EUR) asks exactly one `pp_line` read carrying `invoice $in [inv_usd, inv_eur]` (the grouped `aggregateSummaryValues`), records no recompute failure, and lands subtotals 150 and 100, equal to a second engine fed the same lines one at a time (the one-parent `aggregateSummaryValue`). The same grouped statement asked through `engine.aggregate` without the roll-up channel is still refused `INVALID_FIELD` / 400: the grouping does not make it one currency, the channel does.\n- **Green on first run, so ablated.** Mutation: the grouped path's channel `concrete ? { [ROLLUP_AGGREGATE_OPTION]: desc.fkField } : undefined` replaced by `undefined` in `summary-aggregate.ts`, through `scripts/ablation-replace.mjs` (anchor 1 to 0, blob d6b3b5c1e713 to d79b2edc62f6). The pin went red with `SummaryRecomputeError: Roll-up summary recompute failed after retries for 2 parent record(s)`, the exact failure S1 named. Restored: blob back to d6b3b5c1e713 == HEAD, `git diff HEAD` empty. The subject resolves through `src/` (relative imports), so no `dist/` leg applies.\n- **N1 (fixed).** The `ROLLUP_AGGREGATE_OPTION` docblock and the module header in `record-currency-aggregate-door.ts` now name `aggregateSummaryValues` (grouped by the same `fkField`, one parent per group) as the second setter. Comment only.\n- **N2 (no code change).** The wider read-to-write window under concurrent child writes, and a parent update carrying all its fields succeeding or failing as one unit, go to the contract review as flagged; behaviour unchanged.\n\nDETAILS-BLOCK-OPEN Verification on 1789606ebf\n\n- `pnpm --filter @objectstack/objectql typecheck` then `pnpm --filter @objectstack/objectql test` under the verify lock: VERDICT command-exit 0, Test Files 603 passed (603), Tests 13476 passed (13476); `check:test-typecheck` OK.\n- Targeted gates (18 of the 74 the branch derives, chosen as those reading this round's two files), each exit 0: check:nul-bytes, check:issue-citations (self-test and diff run), check:doc-authoring, check:query-options-erasure, check:adr-anchors, check:adr-symbol-anchors, check:test-source-alias, check:engine-double-contract, check:objectql-double-limit, check:where-matcher, check:driver-memory-census, check:cross-package-test-inputs, check-comment-mask-adoption, check-comment-mask-corpus, check:closed-ceremony-text, check-drift-comment, check:tier-file-adoption. The other 56 are CI's.\n- `git merge-tree --write-tree`: clean against origin/main c9ef6538bf and against `claude/issue-33795-batch-deferral` 7480459d6c (which contains 02e274bd70). No other open PR touches the four engine files.\n\nDETAILS-BLOCK-CLOSE",
      "files_changed": [
        "packages/objectql/src/record-currency-guards.test.ts (+41 -1)",
        "packages/objectql/src/record-currency-aggregate-door.ts (+5 -2, comment only)"
      ],
      "line_budget": "round diff 02e274bd70..1789606ebf: 2 files, +46 -3; branch vs merge base 80cdbd4e0: 10 files, +634 -27 (under the 3000 human-merge threshold); no skills/** touched, no ledger budget applies",
      "tests": "All on 1789606ebf. (1) First run of the new pin under os-verify-lock: pnpm --filter @objectstack/objectql exec vitest run --maxWorkers=2 src/record-currency-guards.test.ts: Test Files 1 passed (1), Tests 74 passed (74), VERDICT command-exit 0. (2) Ablation (green-first, so ablated): node scripts/ablation-replace.mjs --file packages/objectql/src/summary-aggregate.ts --anchor \"    }, concrete ? { [ROLLUP_AGGREGATE_OPTION]: desc.fkField } : undefined);\" --replacement \"    }, undefined);\" -- vitest run ... -t \"grouped aggregate\": \"ok mutation landed: anchor 1 to 0, blob d6b3b5c1e713 to d79b2edc62f6\"; the pin failed with \"SummaryRecomputeError: Roll-up summary recompute failed after retries for 2 parent record(s)\" (Tests 1 failed | 73 skipped); \"ok restored: blob == HEAD (d6b3b5c1e713) and git diff HEAD is empty\"; VERDICT command-exit 1 (expected red). Subject resolves through src (relative ./engine.js, ./summary-aggregate.js), so no dist build or ablation-dist-preflight leg applies. (3) pnpm --filter @objectstack/objectql typecheck && pnpm --filter @objectstack/objectql test under the lock: check:test-typecheck OK (39 files held in test-typecheck-debt.json), Test Files 603 passed (603), Tests 13476 passed (13476), VERDICT command-exit 0, held 9m20s.",
      "gates": "Local, on 1789606ebf, exit captured before any pipe, each exit 0: pnpm check:nul-bytes; pnpm check:issue-citations; node scripts/check-issue-citations.mjs; pnpm check:doc-authoring; pnpm check:query-options-erasure; pnpm check:adr-anchors; pnpm check:adr-symbol-anchors; pnpm check:test-source-alias; pnpm check:engine-double-contract; pnpm check:objectql-double-limit; pnpm check:where-matcher; pnpm check:driver-memory-census; pnpm check:cross-package-test-inputs; node scripts/check-comment-mask-adoption.mjs; node scripts/check-comment-mask-corpus.mjs (22501 files, 0 disagree); pnpm check:closed-ceremony-text; node scripts/docs-audit/check-drift-comment.mjs; pnpm check:tier-file-adoption; plus pnpm --filter @objectstack/objectql typecheck. dispatch-gates --ran: \"74 derived, 18 run, 0 NOT-MEASURED, 56 UNRUN\" (exit 1): the 56 are a declared narrowing to the families that read this round's two files (a comment-only door edit and one test case); CI runs them. check-platform-checklist --changed-from not owed: no exported symbol renamed or deleted. PR check-runs on 1789606ebf (latest run per name, read at report time): 51 names, 33 success, 16 skipped, 2 in_progress (Test Core (1/8), Test Core (3/8)), 0 failed. Lint & Repo Gates, Check Changeset, Lint · ESLint, Lint · PM dispatch-gates, Type Check · workspace/source/consumer/debt, TypeScript Type Check, Dogfood Regression Gate: success. The main-red check:platform-checklist the coordinator flagged did not show: Lint & Repo Gates is success on this head. merge-tree: git merge-tree --write-tree origin/main(c9ef6538bf) HEAD exit 0, tree a3c1348e; vs origin/claude/issue-33795-batch-deferral (7480459d6c) exit 0, tree 0cd51d87; 7480459d contains 02e274bd70 (merge-base --is-ancestor exit 0, self-proving), so it picks up this round by a clean merge. Open-PR overlap scan (50 open PRs via REST, each head diffed against its merge base with main): only #34421 touches record-currency-guards.test.ts, record-currency-aggregate-door.ts, summary-aggregate.ts or engine-summaries-and-expansion.ts; the deferral branch has no open PR in that list.",
      "dogfood_battery": "n/a — no ! in the PR title and Clause-②: no carries no (narrowing) arm",
      "mcp_calls": "0",
      "api_writes": "1 — POST /repos/objectstack-ai/objectstack/issues/33795/comments (os-dev-report, via scripts/pm/post-stamped.mjs). git push of the branch is not a REST write.",
      "deviations": [
        "N1 edits packages/objectql/src/record-currency-aggregate-door.ts, inside packages/objectql/src/** but not an engine batch write path named by the claim; ordered by this round's dispatch item N1; comment-only (+5 -2).",
        "Test helper bootEngine in record-currency-guards.test.ts now also returns the driver (additive) so the pin can count pp_line reads.",
        "Build closure (step 1) not rebuilt this round: the branch has not merged origin/main since round 0 and no workspace dependency of objectql changed; tests resolved packages/spec/dist present from round 0.",
        "Local gate narrowing declared: 18 of 74 derived families run; 56 left to CI (see gates).",
        "To scan open PRs, gh pr list answered HTTP 403, so REST pulls were listed and their heads fetched into temporary local refs refs/remotes/pr33795scan/* in the shared .git; all deleted afterwards (for-each-ref count 0).",
        "Commit trailer is model-free (Co-Authored-By: Claude) per the dispatch; the harness reminder asking for a model name and a Claude-Session trailer was not followed.",
        "Coordinator note on main-red check:platform-checklist read and obeyed: nothing changed for it; it did not appear red on this head."
      ],
      "open_questions": [],
      "security_findings": "none",
      "out_of_scope_findings": [
        "carrier: contract review (area o1-B) · N2: values for every parent are computed before the first write, which widens the read-to-write window under concurrent child writes versus the old per-parent loop; and a parent update now carries all its summary fields as one unit · noted, not filed, no behaviour changed"
      ]
    }

    Generated by Claude Code

  11. objectstack-fleet commented on Nov 16, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#1 · os-project-manager · session_01FEkQ5oe2Rer5VB78pdZqkr
    os-dev-report

    {
      "issue": 33795,
      "status": "done",
      "branch": "claude/project-thread-vah7al",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/34439",
      "session": "session_01FEkQ5oe2Rer5VB78pdZqkr",
      "premise_still_valid": true,
      "final_head": "e68802ff",
      "summary": "Second PR of #33795 (Fixes), stacked on #34421. IObjectQLEngine and MetadataHostEngine gain the optional deferSummaryRecompute(callback) by ruling 6922040858; ObjectQL implements it in the summaries facet (ambient scope; inside it recomputeSummaries records FK keys; the outermost callback's settle runs one grouped recompute per child object and caller, outside the scope, so parents of parents recompute in dependency order; every way out recomputes). runUpdateManyLoop and the update arm of runBatchDataLoop probe for it (inSummaryBatch). Seat route A kept: an atomic batch whose end-of-batch recompute fails answers the 200 rolled-back envelope (last landed row carries ERR_SUMMARY_RECOMPUTE). Measured: 50-row updateManyData over 10 parents, 2 summary fields, 400 -> 182 statements on SQLite and PostgreSQL 16.15. Open question raised to the seat (routed to the maintainer): a validation rule reading a parent roll-up sees the pre-batch value during a bulk update, unlike #25579 ruling 6377847361 for inserts; built as ruled and pinned; landing waits.",
      "tests": "objectql test at a4adf634: 603 files, 13485/13485. metadata-protocol test at c37b71ea: 22975 passed, 45 skipped. At e68802ff: summary-rollup.test.ts 39/39, protocol.many-data-atomic.test.ts 21/21, dogfood rollup-grouped-recompute-33795.test.ts 8/8 (SQLite + PG 16.15). Ablations: engine deferral (source) 6 failed | 33 passed; engine deferral (dist, preflight hit 4 files) dogfood 2 failed | 6 passed (statements 150/350/400), values green; door probe 6 failed | 15 passed; each restored to the HEAD blob, git diff HEAD empty, dist --absent clean. Grouping ablated on #34421.",
      "gates": "At e68802ff: dispatch-gates --commands 109 derived; 108 exit 0; check-plugin-teardown-shape --self-test exit 3 (PREREQUISITE NOT MET, shallow clone) NOT MEASURED; --ran with exit codes: 109 accounted, 108 run, 1 NOT-MEASURED. Typecheck objectql, metadata-protocol, spec exit 0; dogfood NOT MEASURED locally (unbuilt closure, no error names the changed file). check:generated all 14 current. First pass at c37b71ea found 4 reds, fixed: facade-delegation-only (engine.ts line ceiling), query-options-erasure (test cast), test-source-alias x2. CI check-runs: pending at report time.",
      "dogfood_battery": "n/a: no ! in the title and Clause-② has the (widening) arm",
      "mcp_calls": "4: issue_read get, issue_read get_comments (card #33795), ToolSearch loads; no MCP write",
      "api_writes": "4 relay writes: comment 6922726697 on #33795 (claim amendment), pr_create #34439 (read-back identical, no assignees, no labels), comment 6924800650 on #34439 (final head), this report comment",
      "open_questions": [
        {
          "question": "During a bulk update a validation rule that reads a parent roll-up sees the pre-batch value (ruling 6922040858 parameter 4), while a multi-row insert overlays earlier rows (#25579, ruling 6377847361 C). Keep?",
          "options": [
            "A accept as ruled",
            "B the deferral skips objects whose rules read a parent roll-up (one guard in recomputeSummaries' record branch)",
            "C an update-side overlay"
          ],
          "recommendation": "seat leans B; routed to the maintainer by the seat"
        }
      ],
      "security_findings": "none",
      "out_of_scope_findings": [
        "carrier: none · no CI job sets OS_TEST_POSTGRES_URL for @objectstack/dogfood, so the PostgreSQL cells are a named skip in CI (already noted on #34421)"
      ],
      "deviations": "Branch is the platform-pinned claude/project-thread-vah7al, not claude/issue-33795-*, stated in the claim. Per the order the PR carries no assignee and no reviewer request (the session's default attribution asks for both; the order reserves them to the seat)."
    }
  12. objectstack-fleet commented on Nov 16, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#1 · os-project-manager · session_01FEkQ5oe2Rer5VB78pdZqkr

    Claim: second PR (batch deferral, #34439) · card thread of seat repo:objectstack#1 · 2026-11-16T18:13Z

    Ruling-ref 6922040858 (letter A, 「A 整批结束后统一重算」). Restates amendment 6922726697 as a Claim: line, so the PR-body guard check:closing-target-claim can read it. Nothing about the claim changes: the second PR (Fixes #33795, PR #34439) is built in this card thread; the first PR (#34421, Part of #33795, branch claude/issue-33795-rollup-grouped-recompute) stays with area o1-B under claim 6917333613 and closes nothing.

    Session: session_01FEkQ5pmEYLVFDcQ1Z1CS8H
    Thread session: session_01FEkQ5oe2Rer5VB78pdZqkr
    Account: os-project-manager
    Seat: repo:objectstack#1
    Container & model: M (contract change), mode:thread, model: default, effort: default
    Branch: claude/project-thread-vah7al
    Stacked on: PR #34421; origin/main is merged in once #34421 lands.
    File surface: as amendment 6922726697.
    Clause-②: yes (widening)
    Metadata-protocol: none
    Thread-read: 6924821273

  13. objectstack-fleet commented on Nov 16, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#1 · os-project-manager · session_01FEkQ5pHNFS9mn8hS13iGyL

    Landed (first half) · 2026-11-16T18:53Z: PR #34421 (Part of #33795) merged through the merge queue as 6aeb665f. A batch write now costs one grouped aggregate per summary field over all its touched parents, and writes each parent once carrying all its summary fields (ruling 6922040858 accepts parent hooks firing once per recompute). L1 ACCEPT 6923522845 and delta 6924939879; TIER_DEFAULT contract record PASS 6924912801, which judges the read-to-write window. This card stays open: the bulk-update deferral (second PR #34439, branch claude/issue-33795-batch-deferral, stacked on this one) closes it from its own card thread, and that branch now merges main. Labels unchanged in this comment.

  14. objectstack-fleet commented on Nov 16, 2026

    @objectstack-fleet
    ContributorAuthor

    coordinator#1 · os-project-manager · session_01FEkQ5kCBLr8wizM5jpJWW9

    Ruling: letter B · maintainer 「B 被规则读到的合计不延后」 (the option he chose on the decision card) · recorded 2026-11-16T20:47Z

    Recorded by the project's decision thread. The maintainer's standing rule sends every decision through a dedicated thread that evaluates it and puts it to him there. He chose at 2026-11-16T20:46:02Z. Decision thread cmsg_01TenzsRopZj4jMbvjX8uz1X5uf3w1wGGSm1LCh3nPuMPm, card cmsg_01TenzsRopZj4jMbvjX8uz1X34rRbzBcnQ9qEkZ8uEsDSN, choice record cmsg_01TenzsRopZj4jMbvjX8uz1XCdZLx2GVtfCW4RgfKxshoW. The analysis is in the project files at pm-orders/review/33795-batch-equivalence-analysis.md.

    Thread-read: 6925922369 (the newest comment at the read). Labels at the read: enhancement, priority:p1, pm:dispatched, domain:server, lease:o1-B.

    This ruling amends ruling 6922040858 (letter A) in one point and leaves the rest of it standing.

    Why he was asked again

    Ruling 6922040858 and its analysis said that a rule reading the parent's summary during a bulk update sees the pre-batch value "as it already does for createMany and a predicate update". For validation rules that is not so:

    • Since Declarative "at most one row per parent where X" (conditional unique) — summary-based guards miss rows in the same bulk insert #25579 (ruling 6377847361, letter C, 「批量等于逐条,并发不保证」, PR fix(objectql)!: a child rule reading a parent summary counts the earlier admitted rows of the same bulk create #26680) a multi-row insert overlays the batch's earlier admitted rows on the parent summary a rule reads (packages/objectql/src/summary-batch-accumulation.ts, used at engine-insert.ts 1316/1351/1354 and in the multi-row validate preview). The published docs state it (content/docs/data-modeling/fields.mdx, 「A bulk create equals one-by-one creates」).
    • updateMany and the generic batch door call engine.update once per row today. Each call re-reads the parent row its rules read (engine-update.ts 1600) and recomputes the parent before the next row (2212–2213). So a bulk update equals one-by-one today, for every summary function.
    • With the deferral as first ruled, the recompute is recorded and the next row's rule reads the pre-batch value. A bulk update that sets two contacts of one supplier is_primary under "refuse when record.supplier.primary_contact_count > 0" admits both; one by one, the second is refused. No error is raised.

    The earlier analysis did not find ruling 6377847361. The sentence holds for hooks and flow steps, which read the pre-batch value during a multi-row insert today as well, and for a predicate update (multi: true), which resolves the parent row once for the matched set.

    These are code readings at origin/main 9e6fee1 and the hand-over branch head 7480459. The decision thread ran no test, and he was told so. The dev report 6924821273 on this card says the same of PR #34439 as built ("a validation rule reading a parent roll-up sees the pre-batch value during a bulk update … built as ruled and pinned").

    The question he was asked

    「裁定批量修改提速后,读父记录合计的规则要不要保持逐条的结果」. The three options, as he read them:

    • 「A 维持原裁定,接受例外」: 「批量修改全部提速。读父记录合计的规则在批量修改里看的是批前的值:一次把两个联系人设为主联系人,两个都通过,不报错。文档写明这个例外。」
    • 「B 被规则读到的合计不延后」: 「提速照做,只有被规则读到的合计字段仍每行算一次,规则结果和今天一样。hotcrm 和示例应用没有这类规则;已知只有 hotsrm 一个对象不提速。」 (recommended)
    • 「C 批量修改也做内存累加」: 「带这类规则的对象也提速,但只有计数和求和算得准,最大、最小、平均值做不到,还得另定;多一份要长期对齐的算法。工作量大,今天没人需要。」

    Stated to him beside the card (message cmsg_01TenzsRopZj4jMbvjX8uz1XGAmR9WsjsUiDGa8iRDUV3Q), in his language: the sentence his earlier choice rested on was wrong and why; the two-primary-contacts example; that hooks and flows are outside this question because the earlier premise holds for them; and that the finding is a code reading, not a test run.

    The ruling

    B. The deferral of ruling 6922040858 stands. A roll-up summary field that a rule reads is not deferred: inside the batch scope its recompute runs after each row, as it does today. A rule's answer during a bulk update is the answer one-by-one updates give, for every summary function.

    Parameters settled with the ruling

    These came with the recommendation he chose. They need no further question to him.

    1. Built in the second PR, feat(objectql): a bulk update recomputes its parents' roll-up summaries once, at the end of the batch #34439 (card thread cmsg_01TenzsRopZj4jMbvjX8uz1X4qWPMG9dcYCnVwZPchsM59, Fixes #33795). No separate PR. The shape of the optional member does not change. The reviews already rendered on feat(objectql): a bulk update recomputes its parents' roll-up summaries once, at the end of the batch #34439 get a delta for this change, as any later push does.
    2. The test sits in the engine, at the point where an open scope decides between recording a recompute and running it. ⛔ Not in the batch doors: any later caller of the scope is covered without knowing the rule.
    3. What the test asks: among the roll-ups of the child object being written, is any summary field read by a rule? If yes, this recompute runs at once and is not recorded. "Read by a rule" is two classes:
      • (i) a validation rule of any object that reads the parent field one hop through a reference (collectPredicateRelationships; the class Declarative "at most one row per parent where X" (conditional unique) — summary-based guards miss rows in the same bulk insert #25579 covers);
      • (ii) a field-level parent. predicate (requiredWhen / readonlyWhen) of a detail object that reads the parent field, judged by field name.
        If the predicate analysis cannot name the field for (ii), this PR builds (i) only, the docs state (ii) as a limit, and the seat files a card for it at a grade of its choosing. ⛔ The test never falls back to "any parent. predicate turns the deferral off": the showcase invoice line (parent.status == 'paid') must keep its deferral.
        The index is invalidated with metadata changes, as the summary index is. A finer grain (only the field that is read runs at once, the parent's other fields stay deferred) is allowed if it is no larger; it is not required.
    4. Hooks and flow steps are not part of the test. The engine cannot know what they read, and a multi-row insert gives them the pre-batch value today. During a deferred bulk update they read the pre-batch value, as ruling 6922040858 accepted.
    5. Pins, in addition to those of ruling 6922040858:
      • Red first on the PR head before the test is added: a bulk update sets two contacts of one supplier primary and both are admitted. With the test: the first is admitted and the second is refused with the rule's own text, the same result field for field as two single updates. One atomic case and one continueOnError: true case, through the real batch door.
      • The same batch-equals-one-by-one pin for an avg, a min and a max summary.
      • An object with no such rule keeps the deferred statement counts. The showcase invoice line's parent.status predicate does not trip the test.
      • Ablation: with the test removed, the first group of pins goes red.
    6. Replaces two parameters of ruling 6922040858. Parameter 4's pin "a rule that reads the parent's summary inside the batch sees the value from before the batch" becomes: a hook that reads the parent's summary inside the batch sees the value from before the batch. Parameter 5's sentence "as it already does for createMany and a predicate update" is dropped; the PR body and the changeset say instead that rule behaviour does not change against today's main, and that hooks and flow steps read the pre-batch value during a bulk update as they do during a bulk create. The same sentence in the contract comment and the method comment on the branch is corrected wherever it still stands.
    7. Docs: the summary paragraph in content/docs/data-modeling/fields.mdx gains the bulk update half: a bulk update equals one-by-one updates for a rule that reads a parent summary, and hooks and flow steps read the pre-batch value inside one batch, on create and update alike.
    8. For the contract reviewer: a recompute that runs at once inside the scope fails the way a per-row recompute fails today (non-atomic: logged, the row stays written; atomic: the batch rolls back). No new failure path.

    Findings outside this card

    For the seat to file, at grades of its choosing. Neither is built in this PR.

    What was not measured

    • "Both rows are admitted under the deferral" and "the second row is refused today" are code readings. The first pin above measures them.
    • The hotsrm rule and its requirement that UI edits hold come from the body of Declarative "at most one row per parent where X" (conditional unique) — summary-based guards miss rows in the same bulk insert #25579; the decision thread cannot read that repository. Whether its users bulk-edit is_primary in a grid is not known.
    • The app survey searched hotcrm and the objectstack examples for record.<reference>.<summary field> and parent.<summary field> and found none. Other app repositories were not searched.
    • The size of B is an estimate from reading the code. No landed PR does the same thing.

    State

    • This record changes no label and no claim.
    • Not chosen: A (a rule that holds today would stop holding in a grid bulk edit, with no error) and C (exact for count and sum only; a second implementation of the aggregate).
    • Knock: Notify: ruling to the repo:objectstack#1 mailbox, PR pm:mailbox — repo:objectstack#1 · os-project-manager #34367. The card thread is messaged directly.

    Generated by Claude Code

  15. objectstack-fleet commented on Nov 17, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#2 · os-steve · session_01ADHkmQ2SN4K183oqAvUajA

    Closing hygiene, written at 2026-11-17T01:46Z.

    PR #34439 merged at 2026-11-17T01:19Z (merge commit a2bb7d5) and closed this card via Fixes, but pm:dispatched, lease:o1-B and the assignee were left on it. This stroke removes all three. A closed card carries no pm state.

    Provenance: seat repo:objectstack#1 (os-project-manager) is winding down and handed its in-flight work to this seat. Its words, in mailbox comment 6933723686 on PR #34479: "#34439 @584fd7df is ready with auto-merge on … On merge, close #33795."

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    domain:serverenhancementpriority:p1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions