Skip to content

fix(objectql): recompute a disabled package's extension roll-ups when it is enabled again - #30587

Merged
objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/project-thread-05m8y6
Nov 5, 2026
Merged

objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/project-thread-05m8y6

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Bill · project thread
domain:server#4 · os-bill · session_01Utp6CZMkHvuDeVYgTD73qF

维护者速读

  • 改了什么:一个模块用扩展给别的模块的对象加了汇总字段(例如给客户加「拜访金额合计」),汇总的子记录属于仍启用的应用。模块停用期间子记录照常写入,但汇总不重算;现在模块重新启用时会把这些汇总按每条父记录重算一遍,只改值不一致的行。
  • 为什么改:objectql: the roll-up summary index is built from the served fold, so a disabled package's summary over a child in an enabled package is stale after re-enable #30377。PR fix(objectql)!: withhold a disabled package's objectExtensions fields from the object they extend, and keep their columns #30362 停用时隐藏模块加的字段,汇总索引也跟着少了这个汇总,于是重新启用后汇总显示停用那一刻的旧值,直到下一次子记录写入。
  • 风险与回滚:启用接口(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 summary fields its objectExtensions add to another package's object are withheld from the served fold (#30304), and ObjectQL.buildSummaryIndex reads 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:

Changes:

  • registry.ts: new SchemaRegistry.onPackageEnabled(listener), announced by enablePackage only when the package was disabled (never for an enable of an enabled package, e.g. a fresh enableOnInstall: true). Same shape as onPackageUninstalled (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 at error and never fails the enable.
  • summary-enable-refresh.ts (new): refreshSummariesExtendedBy takes the roll-ups the package adds by extension (getObjectExtensionsOf, matched to the engine's own getOwnedSummaryDescriptors index), walks every parent row in keyset order, recomputes each one with aggregateSummaryValue, 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 at error with consequence and fix. startSummaryRefreshOnEnable is the listener (tracks the run, never rejects); summaryRefreshesSettled waits for the runs in flight.
  • registry-module-mock.ts: the shared registry double answers onPackageEnabled (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) and summaryRefreshSettled().
  • runtime/src/domains/packages.ts: PATCH /packages/:id/enable and the install door's enableOnInstall: true arm answer after summaryRefreshSettled(), 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 a sum over 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 at error naming the row, and refreshSummariesEnabledBy re-runs it; onPackageEnabled fires 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, /data writes 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

  • Second item of seat note 6654197160 (os migrate value-rewrite commands under packages/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.find refuses a withheld field by design). Not taken here.
  • The enable doors now wait for the walk: its cost is one aggregate per parent row of each extending roll-up (keyset pages of 500). A deployment with a very large parent table pays that once per enable.
  • The refresh runs on the onPackageEnabled signal, 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, enablePackage on install) gets the refresh too, but answers without waiting for it.
  • The walk reads and writes as system ({ isSystem: true }), the context backfillSummaryNulls (summary count/sum 存量 NULL 行的一次性回填 —— #5749 方案 1 落地后的遗留半边(原地升级的库仍漏行) #6063) already uses for the same aggregate.

Verification

All on head 4ca13802 (origin/main 35a8f088 merged once; main has moved since and git merge-tree against it is clean).

Red on main, green on the fix, two ablations
  • Red on main 8e5fabe5 (the new objectql pin, tests only): AssertionError: expected 10 to be 25 — the parent serves the value it held at the disable.
  • Green: engine-summary-disabled-extension-reenable.test.ts 4/4; packages-disable-module-extension-fields.test.ts 12/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).
  • Ablation 1, the engine's subscription (scripts/ablation-replace.mjs --delete of the this._registry.onPackageEnabled(…) line in engine.ts; the objectql suite imports src/, no build between): anchor 1 to 0, blob 09031204d5df to 0e83c65fd80e; 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 HEAD empty.
  • Ablation 2, the door's wait (--delete of await summaryRefreshSettled(qlService); in the PATCH /packages/:id/enable arm; the runtime suite imports the dispatcher from src/): anchor 1 to 0, blob 8d43ff30f3e1 to ae9427714d6b; Tests 1 failed | 11 passed (12), the new describe reads the pre-recompute row; restored, blob equals HEAD, git diff HEAD empty. So the answer-after-recompute is pinned, not only the recompute.
Package suites, typecheck, lint, gates
  • pnpm --filter @objectstack/objectql test under the verify lock: Test Files 553 passed (553) · Tests 11009 passed (11009) · VERDICT command-exit 0. (A first run before the registry double gained onPackageEnabled was red in 19 files that mock ./registry; that is the registry-module-mock.ts change.)
  • pnpm --filter @objectstack/runtime test: Test Files 543 passed (543) · Tests 8656 passed | 19 skipped (8675).
  • pnpm --filter @objectstack/objectql run typecheck and @objectstack/runtime: exit 0, test layers included (check:test-typecheck: OK, ledgers unchanged).
  • eslint --no-inline-config on the seven changed source and test files: exit 0. The repo-wide pnpm lint is CI's Lint job.
  • node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack on 4ca13802: 63 commands, each run with its exit code captured before any pipe, plus check: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 is node scripts/check-plugin-teardown-shape.mjs --self-test (exit 3, needs an unshallow clone; checker health only), which CI runs.
  • Fixed on the way: check:objectql-double-limit (the new find double now slices by limit before touching rows) and check:query-options-erasure (no as any on the new test's query options).
  • Dogfood battery: n/a, no ! in the title and no (narrowing) arm.

Generated by Claude Code

… 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
@github-actions github-actions Bot added size/l documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 2 package(s): @objectstack/objectql, @objectstack/runtime, touching 29 documentable anchor(s).

43 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json 2ffdb649775d20313707d88a8388275f280a0a7f.

⛔ 8 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 2 cross-cutting symbol(s) contributed no route anchor: recordId (4 routes), packageId (4 routes)
  • 1 anchor(s) matched too much of the corpus to be a work list: ObjectQL (symbol, 80 pages)
  • 9 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 61 of 219 client-bound route-ledger rows — the other 158 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 158: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 55 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 103 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 38 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 2ffdb649775d20313707d88a8388275f280a0a7f → packageMentionDocs.

Which tree this was computed on

This run read content/docs from bb6eaaeb0ea24daeebc2149fa11bb63331deffe5 — the merge of head 4ca138026913186ee5d4b50b58c6d462e3b44b59 into base 2ffdb649775d20313707d88a8388275f280a0a7f, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# 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

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 2ffdb649775d20313707d88a8388275f280a0a7f → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#4 · os-bill · session_01Utp6CZMkHvuDeVYgTD73qF

维护者速读

  1. 改了什么:一个包停用期间,它以扩展方式加到别的包对象上的汇总字段(summary)不跟着子记录更新;现在包重新启用时,把这些汇总在每条父记录上重算一遍,只写值变了的行。PATCH /packages/:id/enable 和安装时 enableOnInstall: true 等重算完再回答。
  2. 为什么改:之前停用期间写子记录,启用后父记录读到停用时的旧值(复现:应 25 读到 10),直到再有子记录写入。
  3. 风险:低到中。启用一个带扩展汇总的包时,会扫一遍父对象全表(每页 500 行,只写有差异的行),父表很大时启用请求会变慢。单行失败只记 error 日志不中断,可用 ObjectQL.refreshSummariesEnabledBy(id) 重跑。保存/读取的接受与拒绝都不变(Clause-② no)。回滚即 revert。
  4. 先看:packages/objectql/src/summary-enable-refresh.ts(新文件),以及 registry.ts 里 enablePackage 只在「停用→启用」时触发的 onPackageEnabled。
  5. 两分钟验证:pnpm --filter @objectstack/objectql exec vitest run engine-summary-disabled-extension-reenable。
  6. 需要你做的:无,席位落地。非 BREAKING,不属 Tier H,不超 3000 行。

席位意见:ACCEPT(#30377)。包停用再启用后,它加在别处的汇总字段马上是对的,不用等下一次子记录写入。

席位核对

Head-sha: 4ca138026913186ee5d4b50b58c6d462e3b44b59 · read 2026-11-05T17:40Z

Item Reading
Shape Draft → main via relay pr_create; Fixes #30377. 8 files, +610/−6. ⛔ packages/spec/**, ui/** untouched.
Route Recompute on enable, not an index over the storage fold: ObjectQL.update takes the served fold, which refuses a withheld column (INVALID_FIELD, #30304 by design), so a storage-fold index would 500 every committed child write. Seat note 6654197160's second item (os migrate on the served fold) is owed as a follow-up in another package.
Seat diff read Listener fires only when isPackageDisabled was true before the enable, after invalidateAll(); a throwing listener is caught and logged. The walk reads only the package's extension summaries (owned summaries stay indexed while disabled), keyset pages of 500, withTransientRetry per row, patch only on difference (numeric-string tolerant). Doors await summaryRefreshSettled and fall through when the engine lacks it. Registry mock gains onPackageEnabled.
Evidence objectql 553 files / 11009 tests green, runtime 543 / 8656 green, both typecheck green; two ablations red then restored; #30304 cases unchanged.
Gates (check-runs on this head) 48 completed: 35 success, 13 skipped, 0 failed; mergeable clean.
Semver @objectstack/objectql: patch, @objectstack/runtime: patch, Clause-②: no, Metadata-protocol: none.
Landing Not governed (check-governed-merges --pr 30587: 0 of 8 paths), 616 lines ≤ 3000, not BREAKING, so per pm-dispatch the seat lands it: pr_ready + automerge_enable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/l tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

1 participant