Repository navigation
Commit 50d6da8
fix(objectql): a package registered again stops serving an object extension its new manifest dropped (#36325)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbCxiFE11rsKwyNffJZKYqJs)_
Fixes #35609
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
用户能看到什么变化:开发者在本地开发热重载时删掉扩展包给别人对象加字段的声明、或升级/重装一个不再加这些字段的扩展包后,这些字段会立刻从对象上消失,不再需要重启。
- 为什么做:修复「扩展包升级后旧字段还挂在对象上」的数据配置错误,替做扩展包升级和本地开发热重载的构建者解决。
- 出错会怎样:最坏情况是某个包重新注册时误撤了它仍声明的扩展字段,字段在界面和接口上暂时消失;已存数据不受影响,回滚此改动或重启即可恢复。
- 要你做什么:无。
## What changes
`SchemaRegistry.replacingPackageBody` (the wrapper around every
`ObjectQL.registerApp` body registration, which since #33050 withdraws
the items a new body no longer ships) now does the same for object
extensions:
- Before the body registers, it notes the package's current `extend`
layer of each object. After it registers, a layer that is a new
contributor is one this body wrote (the extend splice always replaces
the package's layer with a new contributor).
- The layers the previous body wrote, for objects the new body no longer
extends, are withdrawn through `withdrawObjectExtension`, the existing
per-object withdrawal the `object_extension` item delete uses
(uninstall's package-wide walk is not reused: it also removes owned
objects). Only the very layer the previous body wrote is withdrawn, so a
layer another door registered under the package id since (the
`object_extension` item door) is kept.
- `withdrawObjectExtension` now records the object's layers in an open
registration run before it removes one (`noteObjectEntry`), so a refusal
later in the run (a later artifact member, the run-end follow door) puts
the extension back. Outside a run this is a no-op, so the item-delete
caller is unchanged.
- The record (`packageBodyExtensions`) is put back on refusal and
forgotten by `uninstallPackage`, beside `packageBodyItems`.
Everything an extension contributes rides on its one contributor layer
(fields, `fieldPatches`, label texts, validations, indexes), so all of
it leaves together. Stored data is untouched: the column keeps its
values and schema sync drops nothing; the field is no longer served.
## Measure first (the card's steps), on main `c30ce97cd7`
| Path | Re-registers without uninstalling? | Dropped extension's field
still served on main? | What said anything |
|:--|:--|:--|:--|
| Bare `registerApp` (card repro) | yes | yes: field, validation and
index all served, `com.t.mod:extend` layer kept | nothing |
| `os dev` reload: `metadata:reloaded` →
`ObjectQLPlugin.refreshReloadedPackages` → `registerApp` | yes (refresh,
never uninstall) | yes | nothing: no warn, schema sync adds only |
| `os dev` reload, full standalone composition (`createStandaloneStack`,
the artifact door's `_reloadAndAnnounce`) | yes | NOT MEASURED on this
composition: neither the first run nor the hand-over round got the
shared verify lock (the round queued about 80 minutes behind two dogfood
batteries). The probe is written (a two-package composed artifact, the
extension dropped by the door's own reload, plus a CONTROL reload) and
is held by the seat; it reaches the same `metadata:reloaded` hook
measured in the row above | nothing |
| install-local upgrade 1.0.0 → 1.0.1 dropping the extension
(`manifest.register`, no uninstall) | yes | yes: `crm_line` served and
`find` returned `cb_account` | the dry run's plan DID say so:
`plan.fields.removed` names `crm_line.cb_account`, `environment.columns`
`reasons: ['removed'], rows: 1`; removed fields need no confirmation
(`schemaUpgradeVerdict`: reported, refused by nothing), so the upgrade
answered 200 and then kept serving the field the plan said was removed |
| install-local re-install of the same id and version without the
extension | yes | yes | nothing |
Stored column, both before and after the fix: `crm_line.cb_account`
keeps its column and its value `ACME` (schema sync drops no column).
After the fix every row above reads "no": the object serves `name` only,
`find` no longer returns `cb_account`, the column still holds `ACME`,
and the dry run's plan is unchanged (it already named the field as
removed; now the runtime agrees with it).
## Tests
- `packages/objectql/src/reregister-extension-withdraw-35609.test.ts`
(new): re-register without the extension (fields, validation and index
gone, owner kept); CONTROL rename; another package's extension of the
same target untouched; same body again keeps it; an extension registered
under the id outside a body kept; a refusal later in the run puts it
back (and the record with it); the reload door drops it, CONTROL reload
keeps it.
-
`packages/cloud-connection/src/marketplace-install-local-reregister-extension-withdraw-35609.test.ts`
(new): real kernel, SQL driver, real schema sync, the install-local
door: upgrade dropping the extension (plan names the field, object no
longer serves it, column keeps its value), same-version re-install,
CONTROL upgrade keeping it.
<details><summary>Readings (ablation: the four fixed objectql files put
back to main, then restored byte-identical to HEAD)</summary>
One locked run, `unfixed-vs-fixed` legs over the same two commands. The
objectql and cloud-connection suites both resolve
`@objectstack/objectql` to `packages/objectql/src` (stack frames read
`../objectql/src/...`), so no dist rebuild was involved; the on-disk
proof is the marker count (`packageBodyExtensions` in
`registry-items.ts`: 0 in the unfixed leg, 9 in the fixed leg) and the
restore was proven by an empty `git diff HEAD` and matching `git
hash-object` = `HEAD:path` for each file.
- UNFIXED (main's four files):
`reregister-extension-withdraw-35609.test.ts` 5 failed / 3 passed (the
controls pass), `package-refused-upgrade-keeps-installed` and
`manifest-service-artifact-refusal-restores` green: `Tests 5 failed | 76
passed (81)`. Install-local readings: `served after upgrade [
'cb_account', 'name' ]`, `find` returns `"cb_account":"ACME"`,
re-install without the extension `[ 'cb_account', 'name' ]`.
- FIXED (HEAD): `Test Files 3 passed (3) · Tests 81 passed (81)`;
install-local `served after upgrade [ 'name' ]`, `find` row has no
`cb_account`, `column after upgrade
{"hasColumn":true,"values":["ACME"]}`, re-install without the extension
`[ 'name' ]`.
- `pnpm --filter @objectstack/objectql test` at the fix (objectql src as
on head `555ef3e2c7`): `Test Files 627 passed (627) · Tests 14240 passed
(14240)`.
- `pnpm --filter @objectstack/objectql typecheck`: exit 0 (`tsc
--noEmit`, then `check:test-typecheck: OK`, debt held).
</details>
## Acceptance notes
- Clause-②: no. Nothing is refused: a body registered again is never
refused over an extension it drops; the dropped layer is withdrawn.
- Owned objects a re-registered body no longer ships are still kept
until a restart; `ingestReloadedObjects`' docblock calls that deliberate
("same lifecycle as their tables"). Not touched here.
- `ObjectQLPlugin.refreshReloadedPackages`' docblock still says items
removed from the artifact stay registered until restart; that has been
out of date since the item withdrawal landed and is now out of date for
extensions too. Not edited (outside this card's file surface). Carried
by #36328.
- Inferred, not exercised: a withdrawal (this one, an uninstall, an
`object_extension` item delete) is not asked the run-end record-currency
follow door, which judges registered layers only. A withdrawn extension
carrying a currency code field another package's amount follows would
leave that pair unjudged until the follower re-registers. Same gap for
the two existing withdrawal doors; not filed. Carried by #36328.
- Inferred edge: if a withdrawn layer was the object's last contributor
(an extension with no owner, already an ADR-0029 violation), the entry
is closed and a refusal later in the run restores the contributor list
without reopening the entry. Unreachable through a valid registration.
- Serial constraint: #36236 (shares `registry.ts`, and places extension
items in the fold) has since landed on `main` as `d33bf5a2`.
`overlap-check` against `origin/main` `d8599c2ca2` reads clean, and
GitHub reports the PR mergeable. This PR's CI ran on the merge with
`99fbaa6d`, before #36236 landed, so the joint tree is first tested in
the merge queue. Read, not run: a placement rides on its extension's
contributor layer and is applied in the fold, so a withdrawn layer takes
its placements with it. `registry-object-registration.ts` is not
touched.
- Prior rulings: `check-prior-rulings --card 35609` over the four files
read; no conflict. The closest precedents are the item withdrawal this
extends (same wrapper, same restore discipline), ADR-0144 D2/D6 (the
run-end follow door, unchanged), ruling A on #35228 (one extension per
target per package, unchanged) and ruling 6624345766 (facade form:
`registry.ts` gains only a state field, docblocks and host wiring;
`check:facade-delegation-only` green). Since main grew `registry.ts`,
the file also sits under its facade line ceiling (6426, ruling
6897467376): the long #35609 prose lives in the facet docblock in
`registry-items.ts`, and the ceiling is not raised.
## Verification
<details><summary>Merge-queue red at 555ef3e, fixed at 368b000
(repo:objectstack#7)</summary>
- What failed: the merge queue dequeued this PR (merge-group run
45007098161, job 137160994478, `Lint · repo & tooling gates`).
`check-facade-delegation-only --self-test` case N6 printed: `the
committed registry is red: is 6441 lines, over its line ceiling of 6426
by 15`. The PR was green on its own head. Main had grown `registry.ts`
to 6409 lines, and this PR's +32 went over the ceiling.
- Fix (`53d2506ddb`, `368b000bed`): merged `origin/main` `4e55e4eb72` (a
merge, no rebase, no force-push). Then I did what the rule says to do:
"a file in facade form does not grow". The detailed extension-withdrawal
prose moved from the facade docblocks to the facet docblock on
`ItemsFacet.replacingPackageBody` (`registry-items.ts`). The facade
keeps a short contract paragraph, and the field doc is one line. The
ceiling row is untouched, so the check is not weakened.
- Comment-only proof: both files were transpiled with `removeComments`,
before and after `368b000bed`. Each pair is byte-identical
(`registry.ts` sha256 prefix `b87e53ad1efa` both sides,
`registry-items.ts` `afb1b850be15` both sides). A control leg with one
injected token compared different (cmp exit 1).
- `pnpm check:facade-delegation-only`: exit 0. `N6 the committed
registry is well-formed against this checkout` passes, and the check
prints `packages/objectql/src/registry.ts: 6421 lines, ceiling 6426 (5
left; ruling 6897467376)`.
- `dispatch-gates --commands` at `368b000bed`: 73 derived. 71 exit 0.
`check:dual-build-cjs-loads` and `check:type-check-debt` exit 3
(PREREQUISITE NOT MET: no full `dist/`), so NOT MEASURED locally and
carried by CI's Build Core and debt-ledger lanes. `--ran` with exit
codes: 73 derived, 71 run, 2 NOT-MEASURED, 0 unrun. Gate derivation read
a tree 7 commits behind the newest `origin/main` `ff60149900`. None of
this PR's files moved there, so I did not merge again.
- `overlap-check --branch`: `VERDICT clean exit 0` against `origin/main`
`ff60149900`.
- NOT MEASURED locally: the `@objectstack/objectql` test suite and
typecheck at the merged head. Reason: the shared verify lock. Three
9-minute tries all ended in queue-timeout behind a dogfood battery
(holder pid 13599, more than 39 minutes). This is a declared narrowing.
The fix commit compiles to identical JS (proof above), and CI's Test
Core and Type Check lanes run both on the merge. The objectql dependency
closure did build under the lock (`VERDICT command-exit 0`).
</details>
<details><summary>Local gates at 555ef3e</summary>
- `dispatch-gates --commands`: 73 commands derived; all run. 70 exit 0.
`check:query-options-erasure` went red (test surface 236 to 237) on a
cast in the new cloud-connection pin; fixed in `555ef3e2c7` and re-run
green (236). `check:dual-build-cjs-loads` and `check:type-check-debt`
exited 3 (PREREQUISITE NOT MET: no full `dist/`, and the closure build
never got the shared lock): NOT MEASURED locally, CI's `Lint & Repo
Gates` carries both.
- Re-run on the final head after the last edit:
`cross-package-test-inputs`, `test-source-alias`, `nul-bytes`,
`refd-timer-probe`, `tier-file-adoption`, `issue-citations`,
`doc-authoring`, `facade-delegation-only`: all exit 0.
- `dispatch-gates --ran`: 73 derived, 73 run, 0 unrun.
- `overlap-check --branch=HEAD`: clean against origin/main and #36236.
- Not run locally, declared to CI: `test:repo`, the full
cloud-connection suite (only the new file was run), and the Build Core /
Type Check workspace lanes. CI has since run all of them at this head
(round below).
- Dogfood battery: not owed (no `!`, no narrowing arm).
</details>
<details><summary>Hand-over round (repo:objectstack#7) at the same head
555ef3e: the local gaps closed</summary>
No commit in this round; the head declared final stays `555ef3e2c7`. CI
ran this head on the merge with `99fbaa6d` (`b97f554d`), and every
gate-carrying check-run concluded `success`.
- Cloud-connection new file, rerun after the cast removal: `Test Core`
at this head, `@objectstack/cloud-connection:test` printed
`src/marketplace-install-local-reregister-extension-withdraw-35609.test.ts
(3 tests)` passed. The objectql file printed
`src/reregister-extension-withdraw-35609.test.ts (8 tests)` passed. All
10 `Test Core` shards: success.
- Cloud-connection typecheck: `Type Check · workspace` ran
`@objectstack/cloud-connection:typecheck`; `Tasks: 124 successful, 124
total`; success.
- `check:dual-build-cjs-loads`: `Build Core` step "Every published
require entry point actually loads": success.
- `check:type-check-debt`: `Type Check · debt ledger` step "Re-measure
the type-check DEBT / TEST_DEBT ledger": success, lane verdict success.
- Derived gates re-run locally at `555ef3e2c7`, against `origin/main`
`c448c615`: `dispatch-gates --commands` derived 73 commands. 68 exited
0. Five exited 3, PREREQUISITE NOT MET (no built `dist/`; the closure
build never got the lock). CI carries all five at this head with
success: `dts-closure` (Build Core "Sweep the built closure for vanished
declarations"), `dual-build-cjs-loads`, `lean-entry-closure` (Build Core
"The lean engine entry loads no forbidden or unlisted package"),
`sourcemap-no-sources-content` (Build Core "No published source map
embeds source text") and `type-check-debt` (above). `dispatch-gates
--ran` with the exit codes recorded: 73 derived, 68 run, 5 NOT-MEASURED
(derived from exit 3), 0 unrun.
- Still NOT MEASURED: the full `createStandaloneStack` reload probe.
Reason: the shared verify lock. This round queued about 80 minutes
behind two dogfood batteries (holder pid 5424 over 67 minutes), and
retaking the same slot after each exit 99 put the call back behind newer
arrivals. No CI job runs this probe.
</details>
Two-minute check: `pnpm --filter @objectstack/objectql exec vitest run
--maxWorkers=2 src/reregister-extension-withdraw-35609.test.ts` prints 8
passed; revert `registry-items.ts` to `origin/main` and the same command
prints 5 failed.
Read first, by risk: `packages/objectql/src/registry-items.ts`
(`replacingPackageBody`, the identity test that decides which layers the
body wrote), `packages/objectql/src/registry-platform-global.ts`
(`withdrawObjectExtension` now notes the run),
`packages/objectql/src/registry.ts` (host wiring and the record).
Written by repo:objectstack#4 · os-project-manager ·
session_01FEkQ5miLqNucRZevceHwNh (PM-dispatched dev run); continued
after the hand-over by repo:objectstack#7 · zhuangjianguo ·
session_01QsR2jTeURPvEm465RcoYEC.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01QsR2jTeURPvEm465RcoYEC
<!-- signed: repo:objectstack#7 · zhuangjianguo ·
session_01QsR2jTeURPvEm465RcoYEC -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent e9da898 commit 50d6da8
7 files changed
Lines changed: 545 additions & 6 deletions
File tree
- .changeset
- packages
- cloud-connection/src
- objectql/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| 62 | + | |
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
64 | 66 | | |
65 | 67 | | |
66 | 68 | | |
| 69 | + | |
67 | 70 | | |
68 | 71 | | |
69 | 72 | | |
70 | 73 | | |
| 74 | + | |
71 | 75 | | |
72 | 76 | | |
73 | 77 | | |
74 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
75 | 95 | | |
76 | 96 | | |
77 | 97 | | |
| |||
202 | 222 | | |
203 | 223 | | |
204 | 224 | | |
205 | | - | |
206 | | - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
207 | 240 | | |
208 | 241 | | |
209 | 242 | | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
210 | 248 | | |
211 | 249 | | |
212 | 250 | | |
213 | 251 | | |
214 | 252 | | |
215 | 253 | | |
216 | 254 | | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
217 | 259 | | |
218 | 260 | | |
219 | 261 | | |
220 | 262 | | |
221 | 263 | | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
222 | 290 | | |
223 | 291 | | |
224 | 292 | | |
| |||
0 commit comments