You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 3b7219e
Browse filesBrowse the repository at this point in the historyBrowse files
feat(metadata-core): export the schema upgrade verdict and its finding set token, so a host's install door forwards the platform's own verdict (#31529)
<!-- claude-projects-attribution: {"github_login":"os-zhuang"} -->
_Requested by **Sam** · [project
thread](https://claude.ai/code/project/chan_01GsBogozeZG5sdpAARrN7HP?thread=cmsg_01GsBogozeZG5sdpAARrN7HP1hxu6zzAV6eVFttJkDXKPW)_Fixes#31526
## What changes
- **`@objectstack/metadata-core`** gains
`src/package-upgrade-verdict.ts`, exported from the index next to
`package-upgrade-plan.ts`. It contains:
- `schemaUpgradeVerdict(packageId, plan)` → `{ findings, findingSet }`.
These need confirming:
- a suspected rename, always;
- a type change in the `needs_confirm` or `destructive` drift category,
including on a declared rename.
These are not findings: a declared rename, a removed field or object, a
`safe` type change, a seed change.
- `installedRecordUnavailableVerdict(packageId, finding)`: the verdict
for a door that has no installed side to compare. It returns one
confirmable finding, never "no finding". The finding's sentence stays
the door's own.
- `schemaUpgradeFindingSet(packageId, findings)`: the token. It is
`schema-upgrade:` followed by 32 hex characters of a SHA-256 over the
package id and the findings' sorted identities.
- Constants: `SCHEMA_UPGRADE_CONFIRMATION_REQUIRED`,
`SCHEMA_UPGRADE_CONFIRMATION_STATUS`, `SCHEMA_UPGRADE_TOPIC`,
`SCHEMA_UPGRADE_CONFIRMED_CATEGORIES`.
- Types: `SchemaUpgradeFinding`, `SchemaUpgradeUnavailableFinding`,
`SchemaUpgradeVerdict`.
- **`@objectstack/cloud-connection`**: the install-local door now
imports all of the above, and the moved code is verbatim. The door keeps
only `ledgerRecordUnavailableVerdict`, its sentence for an install
record that is unreadable or missing; that function now calls the
exported `installedRecordUnavailableVerdict`. `createHash` and three
type imports the door no longer uses are dropped.
- **`@objectstack/spec`**: one `PROVENANCE_WAIVERS` entry, because the
provenance gate attributes a constant to the package that defines it.
`SCHEMA_UPGRADE_CONFIRMATION_REQUIRED` is now defined in metadata-core
but stays registered under `@objectstack/cloud-connection`, whose door
puts it on the wire. This follows the `UPDATE_ID_MISMATCH` shape. No
ledger row is added or moved.
## Why
cloud#3654 (epic cloud#3652, ruling Q3 「默认拒绝,需显式映射(推荐)」) has the hosted
install door refuse an undeclared rename or a type change "with the
framework's code and finding-set token". Its card forbids cloud from
re-judging.
Before this PR, the verdict and the token were private to
`marketplace-install-local-plugin.ts`, so the hosted door could only
copy the judgement or refuse nothing. With the export, both doors apply
one rule and mint one token: the same pair of versions gets the same
findings and the same token, whichever door installs it.
The hosted consumer is cloud#3861.
## Verification
Run in a worktree at `origin/main` `4cd48e27` plus this branch. The
workspace dependencies' `dist/` were borrowed from a build of
objectstack `3c380253` (27 commits behind main), and `metadata-core` was
rebuilt from this branch.
- `packages/metadata-core`: `vitest run
src/package-upgrade-verdict.test.ts src/package-upgrade-plan.test.ts`
gives 2 files, 27 tests passed. The new test file pins two token values,
both computed with the door's original digest before the move, so the
test pins byte identity:
- `schema-upgrade:a168d8927e7a5afc25f947ee715fa848`: a one-field
suspected rename on `com.acme.deals`;
- `schema-upgrade:c29494e0b3b3e33a84adf0c2188baa37`: the empty set.
- `packages/cloud-connection`: `vitest run` on the three install-local
suites that exercise the gate (`marketplace-install-local-upgrade-plan`,
`-corrupt-ledger`, `-declared-rename`) gives 3 files, 47 tests passed,
unchanged.
- `packages/spec`: `check:error-code-provenance` OK (11 waivers, all
live). `src/api/error-code-ledger.test.ts` gives 26 tests passed.
- `tsc --noEmit` is clean in `metadata-core` (both configs) and in
`cloud-connection`. eslint is clean on the changed source files.
- `check-changeset-fixed`, `check-empty-changeset`,
`check-adr-0087-registration`, `check-changeset-no-major` and
`check-doc-authoring` all pass.
- Docs drift comment: the two pages it names (`data-modeling/fields.mdx`
and `deployment/cli.mdx`) describe the install-local refusal and
`renamedFrom`. Their behaviour is unchanged by a verbatim move, so
neither needs an edit.
Clause-②: yes (widening)
Metadata-protocol: none
This is widening only: `@objectstack/metadata-core` gains the exports
listed above. No request, answer, key or error code changes on any door.
The changeset is graded `patch`, since the protocol kind is none.
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(`packages/spec` gains one data entry in `PROVENANCE_WAIVERS`.)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes. (eslint on the changed
files)
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: one ledger waiver entry. No schema,
key or export changes.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [ ] The *Before Submitting* list in CONTRIBUTING.md is done. (A full
`pnpm test` was not run in this container; CI carries it.)
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QUs3BsJ2E2byCWsBstMjAJ)_
---------
Co-authored-by: Claude <noreply@anthropic.com>
feat(metadata-core): export the schema upgrade verdict and its finding set token, so a host's install door forwards the platform's own verdict
8
+
9
+
Clause-②: yes (widening) — `@objectstack/metadata-core` gains exports and nothing else: `schemaUpgradeVerdict`, `installedRecordUnavailableVerdict`, `schemaUpgradeFindingSet`, `SCHEMA_UPGRADE_CONFIRMATION_REQUIRED`, `SCHEMA_UPGRADE_CONFIRMATION_STATUS`, `SCHEMA_UPGRADE_TOPIC`, `SCHEMA_UPGRADE_CONFIRMED_CATEGORIES` and the types `SchemaUpgradeFinding`, `SchemaUpgradeUnavailableFinding` and `SchemaUpgradeVerdict`. No request, answer, key or code changes on any door.
10
+
Metadata-protocol: none
11
+
12
+
The verdict that decides which findings of a package upgrade plan stop a managed upgrade until the installer confirms them (a suspected rename; a type change in the `needs_confirm` or `destructive` drift category, on a declared rename too) and the token that confirmation must echo were private to the install-local door. They now live in `@objectstack/metadata-core` beside `comparePackageVersions`, and the install-local door imports them. A host that installs a package version from its own stored versions, such as the hosted control plane installing into an environment, applies the same rule and mints the same token, so the same pair of versions is refused with the same findings and the same token whichever door installs it.
13
+
14
+
-**`@objectstack/metadata-core`:** the exports above. `schemaUpgradeVerdict(packageId, plan)` answers `{ findings, findingSet }`; `installedRecordUnavailableVerdict(packageId, finding)` is the verdict of a door with no installed side to compare (one confirmable finding, never "no finding"), the finding's sentence being the door's own.
15
+
-**`@objectstack/spec`:** one `PROVENANCE_WAIVERS` entry: `SCHEMA_UPGRADE_CONFIRMATION_REQUIRED` is now defined in metadata-core and still registered under `@objectstack/cloud-connection`, the package whose door puts it on the wire (the `UPDATE_ID_MISMATCH` shape). No row is added or moved.
16
+
-**`@objectstack/cloud-connection`:** the install-local door's `409 SCHEMA_UPGRADE_CONFIRMATION_REQUIRED` refusal, its findings, its sentences and its token are unchanged. The token for a given plan is byte-identical before and after, pinned by a test with values the door's own digest minted.
0 commit comments