Repository navigation
fix(objectql): a roll-up recompute stamps the master as the system, not the child's writer - #34242
Conversation
Claude-Session: https://claude.ai/code/session_01QsR2jTEivi2wogPpeo3xd5 Co-authored-by: Claude <noreply@anthropic.com>
The master update recomputeSummaries issues carries an engine-only symbol option; the audit stamp then writes updated_by = null (ADR-0118 D1) and a fresh updated_at instead of the child writer's userId. Claude-Session: https://claude.ai/code/session_01QsR2jTEivi2wogPpeo3xd5 Co-authored-by: Claude <noreply@anthropic.com>
…ase boot Claude-Session: https://claude.ai/code/session_01QsR2jTEivi2wogPpeo3xd5 Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QsR2jTEivi2wogPpeo3xd5 Co-authored-by: Claude <noreply@anthropic.com>
…s bound Claude-Session: https://claude.ai/code/session_01QsR2jTEivi2wogPpeo3xd5 Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 10 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 2 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 21 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 988e5a6c1b477d369bb0aa85c0f791d36ae047f5 && git checkout 988e5a6c1b477d369bb0aa85c0f791d36ae047f5
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 7be32d39fa62bd6e0f7c0a0054569b22bfb3dfd3 24f850943a80d0c6fd2cfe46a4727bf5a85c0a8f && git checkout -B drift-repro 7be32d39fa62bd6e0f7c0a0054569b22bfb3dfd3 && git merge --no-ff 24f850943a80d0c6fd2cfe46a4727bf5a85c0a8f
node scripts/docs-audit/affected-docs.mjs --json 7be32d39fa62bd6e0f7c0a0054569b22bfb3dfd3
|
|
domain:server#5 · zhuangjianguo · session_01QsR2jTjrNnh6b2BkCXFugM |
|
domain:server#5 · zhuangjianguo · session_01QsR2jTjrNnh6b2BkCXFugM Review — PASSHead-sha: Contract face: none applies. No What holds
Nits (no re-review needed)
Gates: at review time 36 success, 16 skipped, none red or pending. Can land. |
|
domain:server#5 · zhuangjianguo · session_01QsR2jTEivi2wogPpeo3xd5 席位核对ACCEPT and landing · area S3 · 2026-11-16T03:20Z · head
Ready + auto-merge under the area S3 landing line (maintainer, project thread, 2026-11-15T11:06Z) and the pm-dispatch landing procedure (maintainer, 2026-11-15T15:56Z). Generated by Claude Code |
domain:server#5 · zhuangjianguo · session_01QsR2jTEivi2wogPpeo3xd5
Requested by Steedos · project thread
Fixes #33950
Clause-②: no
Metadata-protocol: none (runtime audit stamping; no authorable key changes; the dev confirms against the diff)
维护者速读
updated_by = null,界面显示「系统」),「修改时间」刷新;不再记成写子记录的人。packages/objectql/src/plugin.ts(审计戳钩子里新增的系统分支),packages/objectql/src/engine-summaries-and-expansion.ts(重算写入带上引擎内部标记)。pnpm --filter @objectstack/objectql exec vitest run src/engine-summary-recompute-audit-actor.test.ts,预期 5 个用例全绿(插入/修改/删除/换父 + 对照)。What changes
recomputeSummarieswrites a child's roll-up onto the master through an ordinary engineupdate, under asudo()-shaped context ({ ...caller, isSystem: true }). The caller'suserIdrides that context on purpose, so the master's hooks and record-triggered flows still know who triggered the write. Thesys_stamp_audit_updatehook read the sameuserIdand stamped it into the master'supdated_by.engine-summaries-and-expansion.ts: the master update now carriesSUMMARY_RECOMPUTE_WRITE, an engine-onlySymbol.foroption key. It reaches only that one update: the master's hooks keep the caller's context, and a write a hook issues throughctx.apicarries the context, not this options bag. No door can build it from a request:rejectUnknownEngineOptionsreads string keys only, and JSON carries no symbols.WRITE_PRECONDITION_OPTIONalready uses this precedent.plugin.ts: the update stamp reads the key offinput.options. When it is present, it stampsupdated_by = null(ADR-0118 D1, only when the object has the column) and a freshupdated_at, whoever the session is. Every other write stamps exactly as before.A child insert, update and delete, and a re-parent (both the old and the new master), all reach the master through this one write.
Ruling recorded on the card (comment 6902001862): 「确定汇总字段自动重算时主记录的修改人和修改时间怎么记」 → 「记为系统并刷新时间」.
Tests
packages/objectql/src/engine-summary-recompute-audit-actor.test.tsboots the realObjectQLPluginstamp hook over a fake driver. It has rows for child insert, update, delete and re-parent (both masters) by user B on a master that user A last edited. Each assertsupdated_by === nulland a refreshedupdated_at. CONTROL: B's direct edit of the master still stamps B.packages/qa/dogfood/test/summary-recompute-system-stamp.dogfood.test.tsruns a real showcase boot (SQL driver, the app's own security profile,AuditPlugin). A signed-up member, who may createshowcase_taskbut is refused a PATCH ofshowcase_project, adds a task. The project'stask_countmoves, itsupdated_byisnull,updated_atmoves, and nosys_audit_logrow on the project names the member. CONTROL: the admin's own PATCH stamps the admin.Acceptance notes
diff()skips computed field types and the audit noise fields. So a recompute writes no ledger row at all. The dogfood pin asserts that no row on the master names the child writer.runAs: 'system'rule ("elevation is not anonymity,updated_bystill names the operator") is unchanged. This PR scopes the system stamp to the recompute's own write, not toisSystemwrites in general.engine.tsdocblock onScopedRepo.executeelevation still saysrecomputeSummaries'ssystemCtxstampsupdated_byfromuserId. That file is outside this card's file surface, so the sentence is left as is. It is now stale for the recompute only.backfillSummaryNulls(os migrate summary-nulls) is a separate one-off writer and is not touched.Verification
Readings were taken at
f89df01cd3(same source as the head, before theorigin/mainmerge and the double's bound fix). Every run went throughscripts/pm/os-verify-lock.sh.Unit pin: green, then ablated red, then restored
pnpm --filter @objectstack/objectql exec vitest run --maxWorkers=2 src/engine-summary-recompute-audit-actor.test.tsgaveTests 5 passed (5)(VERDICT command-exit 0).scripts/ablation-replace.mjs, anchor{ context: systemCtx, [SUMMARY_RECOMPUTE_WRITE]: true } as anyreplaced by{ context: systemCtx } as any. This is the recompute write as it stands onorigin/main. The mutation landed (anchor 1 to 0). Result:Tests 4 failed | 1 passed (5). Insert, update, delete and re-parent each failed withexpected 'u_child_writer_b' to be null, and the CONTROL passed. This also re-measures the card's premise on main: the child writer is stamped on the master.git diff HEADempty.Dogfood pin (real driver, dist): green, then ablated red, then restored
pnpm --filter '@objectstack/dogfood^...' build:Tests 3 passed (3).plugin.ts:hookCtx?.input?.options?.[SUMMARY_RECOMPUTE_WRITE] === truewas replaced by a never-true marker expression, then@objectstack/objectqlwas rebuilt.ablation-dist-preflightreported the marker present in 2 built files. Result:Tests 1 failed | 2 passed (3), withexpected 'Cn8RZN9WCVK0GCCNpkmfRXg6YsOd4y1m' to be null: the member's id was stamped on the project.--absentfound the marker absent from all 14 built files, and the run was back toTests 3 passed (3).hookCtxunread, so the DTS build failed (TS6133) and the suite never ran. It was redone with the expression above.Gates (dispatch-gates --commands, derived for this diff)
76 derived commands were run locally, each with its exit code captured before any pipe.
check:objectql-double-limitfirst found the new test's driver double limit-blind. The double now applies the caller's bound after the filter and before the row copy, and the gate readsOK(754 graded, none new).check:dual-build-cjs-loads: PREREQUISITE NOT MET. It needsdist/of packages outside this diff's closure. NOT MEASURED locally; CI runs it.check:type-check-debt: PREREQUISITE NOT MET. Its closure build never got a turn on the shared lock. NOT MEASURED locally; CI runs it.Declared narrowing: objectql typecheck and full suite go to CI
pnpm --filter @objectstack/objectql typecheckandpnpm --filter @objectstack/objectql testwere queued on the shared verify lock four times. Each attempt endedqueue-timeout (exit 99)behind a sibling's full dogfood battery, which held the lock for over 50 minutes. NOT MEASURED locally:TypeScript Type CheckandTest Coreon this PR carry them.Measured later at the final head
24f850943a(dev report, card comment 6906249947): objectql typecheck exit 0;pnpm --filter @objectstack/objectql test599 files, 13285 tests passed; dogfood pin 3/3.No public export of
@objectstack/objectqlchanges: the new symbol is not re-exported fromindex.tsorcore.ts. So importers owe no tests of their own (the os-dev local-scope rule).git merge-treeagainstorigin/main, #33887 and #33652 (the open PRs in neighbouring objectql files) is clean. No open PR touches either source file this PR edits.Generated by Claude Code
🤖 Generated with Claude Code