Repository navigation
fix(objectql): recompute a disabled package's extension roll-ups when it is enabled again - #30587
Conversation
… it is enabled again (WIP) Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6Cb5eUJ2R5ZJdA6U46A
…in the card's scenario through the real routes Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6Cb5eUJ2R5ZJdA6U46A
… find double holds the caller's bound Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6Cb5eUJ2R5ZJdA6U46A
📓 Docs Drift CheckThis PR changes 2 package(s): 43 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 8 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 38 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 bb6eaaeb0ea24daeebc2149fa11bb63331deffe5 && git checkout bb6eaaeb0ea24daeebc2149fa11bb63331deffe5
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 2ffdb649775d20313707d88a8388275f280a0a7f 4ca138026913186ee5d4b50b58c6d462e3b44b59 && git checkout -B drift-repro 2ffdb649775d20313707d88a8388275f280a0a7f && git merge --no-ff 4ca138026913186ee5d4b50b58c6d462e3b44b59
node scripts/docs-audit/affected-docs.mjs --json 2ffdb649775d20313707d88a8388275f280a0a7f
|
|
domain:server#4 · os-bill · session_01Utp6CZMkHvuDeVYgTD73qF 维护者速读
席位意见:ACCEPT(#30377)。包停用再启用后,它加在别处的汇总字段马上是对的,不用等下一次子记录写入。 席位核对Head-sha:
|
Requested by Bill · project thread
domain:server#4 · os-bill · session_01Utp6CZMkHvuDeVYgTD73qF
维护者速读
PATCH /packages/:id/enable、安装时enableOnInstall: true)现在等重算完成再回答,父记录多时启用会变慢;某行重算失败只记 error 日志,不让启用失败。回滚即还原本 PR。packages/objectql/src/summary-enable-refresh.ts(整文件,重算逻辑);packages/objectql/src/registry.ts的enablePackage与新onPackageEnabled;packages/runtime/src/domains/packages.ts两处await summaryRefreshSettled(qlService)。pnpm --filter @objectstack/objectql exec vitest run --maxWorkers=2 src/engine-summary-disabled-extension-reenable.test.ts,预期 4 个全绿(第一个用例停用期间写子记录,启用后汇总读到 25 而不是 10)。Fixes #30377
Clause-②: no — a stored summary column stays current across a disable; nothing a caller sends is refused
Metadata-protocol: none
What changes
While a package is disabled, the
summaryfields itsobjectExtensionsadd to another package's object are withheld from the served fold (#30304), andObjectQL.buildSummaryIndexreads that fold, so the summary is not in the roll-up index. When the summary's child belongs to an enabled package, the child writes made during the disable land and recompute nothing. After the enable the parent serves the value the summary held at the disable, until a child write names it.Route chosen: recompute the withheld summaries on enable (the card's second option), not an index over the storage fold. Why:
ObjectQL.update, whose field map is the served fold. A withheld column is refused there as an unknown field (INVALID_FIELD), by package disable: a disabled package's objectExtensions fields stay in /meta/object, /data and on the record page, while its objects answer 404 OBJECT_PACKAGE_DISABLED #30304's design. An index over the storage fold would turn each such child write into aSummaryRecomputeError(a 500 on a committed write), unless the write path grew a second, storage-level door for one kind of column.aggregateSummaryValue) the engine already uses.Changes:
registry.ts: newSchemaRegistry.onPackageEnabled(listener), announced byenablePackageonly when the package was disabled (never for an enable of an enabled package, e.g. a freshenableOnInstall: true). Same shape asonPackageUninstalled(install-local: an uninstalled package still reads read-only until a restart, because engine.manifests keeps its id #30215): one signal for every enable door, never per door; a throwing listener is logged aterrorand never fails the enable.summary-enable-refresh.ts(new):refreshSummariesExtendedBytakes the roll-ups the package adds by extension (getObjectExtensionsOf, matched to the engine's owngetOwnedSummaryDescriptorsindex), walks every parent row in keyset order, recomputes each one withaggregateSummaryValue, and updates a row only where a value differs (an enable over unchanged children writes nothing). A failed row is recorded and the walk goes on; failures are logged once aterrorwith consequence and fix.startSummaryRefreshOnEnableis the listener (tracks the run, never rejects);summaryRefreshesSettledwaits for the runs in flight.registry-module-mock.ts: the shared registry double answersonPackageEnabled(the engine's constructor subscribes; the double never enables a disabled package, so it never announces).engine.ts: the constructor subscribes the listener; two public delegations:refreshSummariesEnabledBy(packageId)(the operator's re-run after a logged failure) andsummaryRefreshSettled().runtime/src/domains/packages.ts:PATCH /packages/:id/enableand the install door'senableOnInstall: truearm answer aftersummaryRefreshSettled(), so the first read after the answer serves current values. An engine without the member (a test double) answers at once, as before.Only summaries added by extension are walked. A summary on an object the disabled package OWNS stays in the index during the disable (its objects are refused on the data plane, not withheld from the fold) and kept tracking an enabled child; measured with a probe before writing this (the parent read 7 during the disable after a child write of 4 over 3).
Tests
packages/objectql/src/engine-summary-disabled-extension-reenable.test.ts(new): the card's scenario (module B extends app A's parent with asumover A's child; disable B; insert, update and insert children of two parents; enable B; the parents read 25 and 7 with no further child write); an enable with no child moved writes no parent row; one parent's failing recompute leaves the others current, logs one[summary-refresh]line aterrornaming the row, andrefreshSummariesEnabledByre-runs it;onPackageEnabledfires for a disabled-to-enabled switch only, and not after unsubscribe.packages/runtime/src/domains/packages-disable-module-extension-fields.test.ts: new describe through the real routes on SQLite (PATCH /packages/:id/disable,/datawrites of the app's child, one under a parent created during the disable,PATCH /packages/:id/enable,GET /data), with a third module added only for that describe (suiteArtifact(…, withRollup)). package disable: a disabled package's objectExtensions fields stay in /meta/object, /data and on the record page, while its objects answer 404 OBJECT_PACKAGE_DISABLED #30304's own case (child in the same disabled module) is unchanged and still green.Acceptance notes
os migratevalue-rewrite commands underpackages/cli/src/commands/migrate/scope by the served fold): follow-up owed. Not the same package (packages/cli), and the smallest honest answer the note names (the plan names the columns it skipped, or the run refuses while an extending module is disabled) is a CLI output change, while switching the reads to the storage fold needs engine support (engine.findrefuses a withheld field by design). Not taken here.onPackageEnabledsignal, so a package that comes back enabled WITHOUT an enable (a state file edited or removed between two boots) gets no refresh; its summaries correct on the next child write, as before this PR. The protocol's install door (metadata-protocol,enablePackageon install) gets the refresh too, but answers without waiting for it.{ isSystem: true }), the contextbackfillSummaryNulls(summary count/sum 存量 NULL 行的一次性回填 —— #5749 方案 1 落地后的遗留半边(原地升级的库仍漏行) #6063) already uses for the same aggregate.Verification
All on head
4ca13802(origin/main35a8f088merged once; main has moved since andgit merge-treeagainst it is clean).Red on main, green on the fix, two ablations
8e5fabe5(the new objectql pin, tests only):AssertionError: expected 10 to be 25— the parent serves the value it held at the disable.engine-summary-disabled-extension-reenable.test.ts4/4;packages-disable-module-extension-fields.test.ts12/12 (the new describe plus package disable: a disabled package's objectExtensions fields stay in /meta/object, /data and on the record page, while its objects answer 404 OBJECT_PACKAGE_DISABLED #30304's own cases unchanged).scripts/ablation-replace.mjs --deleteof thethis._registry.onPackageEnabled(…)line inengine.ts; the objectql suite importssrc/, no build between): anchor 1 to 0, blob09031204d5dfto0e83c65fd80e;Tests 2 failed | 2 passed (4)(expected 10 to be 25,expected +0 to be 7; the no-write control and the registry case stay green, as predicted); restored, blob equals HEAD,git diff HEADempty.--deleteofawait summaryRefreshSettled(qlService);in thePATCH /packages/:id/enablearm; the runtime suite imports the dispatcher fromsrc/): anchor 1 to 0, blob8d43ff30f3e1toae9427714d6b;Tests 1 failed | 11 passed (12), the new describe reads the pre-recompute row; restored, blob equals HEAD,git diff HEADempty. So the answer-after-recompute is pinned, not only the recompute.Package suites, typecheck, lint, gates
pnpm --filter @objectstack/objectql testunder the verify lock:Test Files 553 passed (553)·Tests 11009 passed (11009)·VERDICT command-exit 0. (A first run before the registry double gainedonPackageEnabledwas red in 19 files that mock./registry; that is theregistry-module-mock.tschange.)pnpm --filter @objectstack/runtime test:Test Files 543 passed (543)·Tests 8656 passed | 19 skipped (8675).pnpm --filter @objectstack/objectql run typecheckand@objectstack/runtime: exit 0, test layers included (check:test-typecheck: OK, ledgers unchanged).eslint --no-inline-configon the seven changed source and test files: exit 0. The repo-widepnpm lintis CI's Lint job.node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackon4ca13802: 63 commands, each run with its exit code captured before any pipe, pluscheck:facade-delegation-only,check:error-code-casing,check:route-ledger-census,check:filter-alias-parity,check:authz-resolver,check:changeset-fixed(rosters under the touched trees): all exit 0.--ran:63 derived, 62 run, 1 NOT-MEASURED, 0 UNRUN; the one isnode scripts/check-plugin-teardown-shape.mjs --self-test(exit 3, needs an unshallow clone; checker health only), which CI runs.check:objectql-double-limit(the newfinddouble now slices bylimitbefore touching rows) andcheck:query-options-erasure(noas anyon the new test's query options).!in the title and no(narrowing)arm.Generated by Claude Code