Repository navigation
Commit 2211bb1
fix(cloud-connection): a managed install or upgrade fills the stored computed fields it makes live (#35514)
Fixes #35390
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
用户能看到什么变化:应用包升级时,如果新版本把"随读随算"的公式字段改成"存起来的计算字段"(或新增了这样的字段),已有记录会在升级时一次性补算填好,所有组织都补,记录的最后修改时间不变。
- 为什么做:HotCRM 想把线索姓名改成存储字段以便搜索、排序和报表;此前升级后所有已有线索的姓名都是空的,云端租户无法自行补救。
- 出错会怎样:升级耗时随记录数增加;补算失败不会让升级失败,结果里会说明剩下多少行和补救办法;撤销这个改动即可回滚。
- 要你做什么:无。
## 席位核对
- Read first: the new capture step (2g, before register) and fill step
(4d, after schema sync) in
`packages/cloud-connection/src/marketplace-install-local-plugin.ts`, and
`marketplace-install-local-stored-expression-fill.test.ts`.
- Two-minute check: run that test file; expect 7 passed (two
organizations filled, `updated_at` unchanged).
- Seat landing: L1-a, then the area lands; no contract review owed
unless L1-a reads the additive `advisories` answer key as a
published-surface widening (see "Answer shape" below).
## What changes
The managed install-local door (`POST
/api/v1/marketplace/install-local`, `os package install`) now executes
the #32527 ruling (6816429574, letter A) at the install/upgrade door:
- **2g (new), before the register:** for every object the incoming body
contributes to (its own objects and the objects its `objectExtensions`
extend, every unit of a composed artifact, through the door's existing
`contributionsOf`), the door asks the data engine for
`captureStoredExpressions(object)` (an engine method; no
metadata-protocol or objectql export changed).
- **4b:** a failed schema sync is now recorded (still a `warn`, as
before).
- **4d (new), after the sync, the NOT NULL relax, the datasource connect
and the handler bind, before the seed:** each capture's `fillChanged()`
runs the engine's own walk (the one `os migrate stored-expressions
--changed --apply` runs): every row, every organization,
`preserveAudit`. A failed sync fills nothing and reports each changed
field incomplete; a fill that throws is reported, never fails the
install.
- **Answer:** a new `advisories` key, omitted when empty, with the
metadata doors' rule ids (`stored-expression-filled` /
`stored-expression-fill-incomplete`) and element shape (`rule`,
`severity`, `where`, `path`, `message`, `hint`).
- **Docs:** `content/docs/deployment/publish-and-preview.mdx` gains
"What an install or upgrade does with existing rows".
Answer shape: the install-local answer is the door's own JSON, not a
Zod-declared response in `packages/spec` (no schema names `hotLoaded`,
`renamesCarried` or any of its keys); `advisories` is one more additive
key, omitted when empty, the pattern the answer's other optional keys
follow. A widening of an undeclared HTTP answer, not of a published
contract shape.
## Tests
New file
`packages/cloud-connection/src/marketplace-install-local-stored-expression-fill.test.ts`,
on a real `ObjectKernel` + `ObjectQLPlugin` + `SqlDriver` (SQLite
`:memory:`):
1. v1 `formula` → v2 stored `full_name`: rows in `org_a` and `org_b` are
filled, `updated_at` unchanged, one `stored-expression-filled` advisory
("3 rows of 3 written").
2. An upgrade adding a second stored field fills it; the unchanged
stored field beside it is not reported.
3. CONTROL: an upgrade changing no stored computed field writes no row
of the object and the answer has no `advisories` key.
4. CONTROL: a refused upgrade (`422 PLUGIN_REGISTER_FAILED`) writes no
row.
5. CONTROL: a fresh install over a new empty table: no `advisories` key.
6. A composed artifact (`packages[]`) whose unit turns the formula into
a stored field: filled.
7. A fresh install over a table that already holds rows: filled.
<details><summary>Runs: the new file 7/7 on 43fbfe4; after merging
origin/main, on b1c6a5b: closure rebuilt, typecheck exit 0, package
suite 92 files / 1348 tests</summary>
```
Test Files 1 passed (1)
Tests 7 passed (7)
os-verify-lock: VERDICT command-exit 0
pnpm --filter @objectstack/cloud-connection test
Test Files 92 passed (92)
Tests 1348 passed (1348)
os-verify-lock: VERDICT command-exit 0
pnpm --filter @objectstack/cloud-connection typecheck (tsc --noEmit && tsc --noEmit -p tsconfig.test.json)
os-verify-lock: VERDICT command-exit 0
```
</details>
<details><summary>Ablation: the plugin file restored to origin/main
5bd7257 (the A1 red reproduction)</summary>
The test imports the plugin from `src` (relative import), so no `dist`
is involved. The mutation was proved on disk (fill-step occurrences 3
then 0), the restore by `git checkout HEAD --` with the HEAD blob hash
compared (d1ff868) and `git diff HEAD` empty.
```
× v1 formula → v2 stored: every existing row of both organizations is filled once ...
AssertionError: expected { l1: [ 'org_a', null, …(1) ], … } to deeply equal { l1: [ 'org_a', …(2) ], … }
× an upgrade adding a stored field fills it ...
× a composed artifact (ADR-0130 D4): the unit that turns the formula into a stored field has its rows filled
× a fresh install whose object already holds rows ... fills them
Tests 4 failed | 3 passed (7)
```
The three CONTROL cases are green both ways, as controls are.
</details>
## Acceptance notes
- **Hosted face:** a live hosted tenant is out of reach from this seat;
the door was measured in-process, on the real engine and driver. A
hosted tenant installs through the same door, so the measurement covers
it unless a host composes its own install door.
- **Lenient path:** when a cloud-fetched register throws without a 4xx,
the door fills whatever the registry now serves that the capture did
not; a register that served none of the new version fills nothing, and
the restart that loads it is a boot, which never fills. Those rows are
left to the boot's warning and `os migrate stored-expressions`.
- **Customization-pair installs** already write through `saveMetaItem`
in publish mode, which fills; untouched here. **Unmanaged installs**
copy into a new base and were not measured.
- **Duplication:** the advisory composer here mirrors
`fillStoredExpressionChange` in metadata-protocol, which is not
exported; exporting it was a stop-and-report per the dispatch. Carrier:
none.
- **CLI print:** `os package install` does not print `advisories` yet
(outside this card's file surface). Carrier: none.
- The `os migrate stored-expressions` row in
`content/docs/deployment/cli.mdx` lists the metadata doors but not this
one; still true, now incomplete. Carrier: none.
## Verification
Gate list derived with `node scripts/pm/dispatch-gates.mjs --commands`;
local results and the CI check-runs are in the report on the card.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01Utp6CaysxGzF62ACvZ1x9x)_
<!-- signed: repo:objectstack#5 · os-bill ·
session_01Utp6CaysxGzF62ACvZ1x9x -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent fca72df commit 2211bb1
4 files changed
Lines changed: 532 additions & 0 deletions
File tree
- .changeset
- content/docs/deployment
- packages/cloud-connection/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
229 | 259 | | |
230 | 260 | | |
231 | 261 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
370 | 370 | | |
371 | 371 | | |
372 | 372 | | |
| 373 | + | |
373 | 374 | | |
374 | 375 | | |
375 | 376 | | |
376 | 377 | | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
377 | 382 | | |
378 | 383 | | |
379 | 384 | | |
| |||
1453 | 1458 | | |
1454 | 1459 | | |
1455 | 1460 | | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
| 1621 | + | |
| 1622 | + | |
| 1623 | + | |
| 1624 | + | |
1456 | 1625 | | |
1457 | 1626 | | |
1458 | 1627 | | |
| |||
3527 | 3696 | | |
3528 | 3697 | | |
3529 | 3698 | | |
| 3699 | + | |
| 3700 | + | |
| 3701 | + | |
| 3702 | + | |
| 3703 | + | |
| 3704 | + | |
| 3705 | + | |
| 3706 | + | |
| 3707 | + | |
3530 | 3708 | | |
3531 | 3709 | | |
3532 | 3710 | | |
| |||
3628 | 3806 | | |
3629 | 3807 | | |
3630 | 3808 | | |
| 3809 | + | |
| 3810 | + | |
| 3811 | + | |
3631 | 3812 | | |
3632 | 3813 | | |
3633 | 3814 | | |
3634 | 3815 | | |
3635 | 3816 | | |
3636 | 3817 | | |
3637 | 3818 | | |
| 3819 | + | |
3638 | 3820 | | |
3639 | 3821 | | |
3640 | 3822 | | |
| |||
3665 | 3847 | | |
3666 | 3848 | | |
3667 | 3849 | | |
| 3850 | + | |
| 3851 | + | |
| 3852 | + | |
| 3853 | + | |
| 3854 | + | |
| 3855 | + | |
| 3856 | + | |
| 3857 | + | |
| 3858 | + | |
| 3859 | + | |
| 3860 | + | |
| 3861 | + | |
| 3862 | + | |
| 3863 | + | |
| 3864 | + | |
| 3865 | + | |
| 3866 | + | |
| 3867 | + | |
3668 | 3868 | | |
3669 | 3869 | | |
3670 | 3870 | | |
| |||
3745 | 3945 | | |
3746 | 3946 | | |
3747 | 3947 | | |
| 3948 | + | |
| 3949 | + | |
| 3950 | + | |
| 3951 | + | |
| 3952 | + | |
| 3953 | + | |
3748 | 3954 | | |
3749 | 3955 | | |
3750 | 3956 | | |
| |||
0 commit comments