Skip to content

Commit 14680d0

Browse files
feat(cli): os deploy and os package publish --install stop on the hosted schema upgrade refusal and take --confirm-upgrade (#30887) (#39286)
Part of #30887 The remaining items (the full plan before install, declared renames in the result, `os deploy --dry-run` on cloud) wait on objectstack-ai/cloud#5409, the dry run on cloud's publish install arm (PM ruling, claim amendment 7372140636). Clause-②: yes (widening) Metadata-protocol: none ## 维护者速读 - 开发者用部署命令(含开发模式里按 d 键)或带安装的发布命令把软件包装进云端环境时:只新增字段或已声明改名的照常直接装;遇到没声明的改名或改类型,会先停下、列出每一项发现,并给出两条路(在新字段上声明旧字段名再部署,或确认后放行),提示的确认命令会写明被拦下的那个环境,且从不打印密钥。 - 这是“受管软件包开发循环”这个大目标里云端那一半:按维护者“默认拒绝,需显式映射”的裁决,避免一次部署悄悄把客户的数据留在旧列里。 - 出错时最多是一次本该放行的部署被拦下(可用确认参数放行),或一次本该拦下的被放行(云端的安装检查仍会拒绝,本改动只是把拒绝说清楚);只改命令行输出和参数,回退即可撤回。 - 要你做:无;部署前预览完整变更清单要等云端那张“发布安装先试运行、什么都不存”的卡(objectstack-ai/cloud#5409)做完后再补。 ## What changes The hosted half of #30887, built against the five cloud readings posted on the card (comment 7370246763, cloud `origin/main` `19dbb424925b`). - `os package publish --install` reads the control plane's Q3 refusal (409 `SCHEMA_UPGRADE_CONFIRMATION_REQUIRED`, `details.findings` / `details.findingSet`) and prints it through the shared printer: each finding, then both ways forward (`renamedFrom` on the new field, or the same command with `--confirm-upgrade TOKEN`). Exit 1. The control plane stores no version for a refused install (reading 5), so the text says nothing was published. - New flag `--confirm-upgrade TOKEN` on `os package publish`, sent as `confirm_schema_upgrade` (reading 3). It requires `--install`, and without it the command refuses before any request. The card's Expected 4 rules this flag. - `os deploy` on the ObjectOS Cloud target now accepts `--confirm-upgrade` and `--json`. On a terminal, the Q3 stop asks the same question as the self-hosted path, and a yes re-sends the same version with the refusal's token. `--json` emits the ruled document with `target: cloud`, and `plan` and `environment` stay `null` because the hosted refusal carries no plan (reading 4). The cloud path moved into `deployToCloud`, unchanged apart from these points. - `os deploy --dry-run` stays refused on the cloud target, before anything is built or sent. The message now says why: the hosted preview (`GET /api/v1/cloud/packages/:id/upgrade-plan`) reads only a stored version, and a deploy always publishes a new one (readings 1 and 2). - New module `packages/cli/src/utils/publish-confirm-upgrade.ts`, because `publish.ts` is over 1,000 lines. The shared `renderSchemaUpgradeRefusal` gains an optional `judge` word ("the control plane" vs "the runtime"). - Docs: `content/docs/deployment/cli.mdx` (`os deploy` flags, the cloud stop and the `--json` keys; `os package publish --confirm-upgrade` and its example). **Not built, and why this says `Part of`:** the hosted door does not serve a full plan or a dry run for an unpublished version. So the card's "plan printed before install, grouped by change", "declared renames printed in the result" and a cloud `--dry-run` are open. The seat ruled A (claim amendment 7372140636): these wait on objectstack-ai/cloud#5409, which is why this PR says `Part of`. **Read first (riskiest first):** 1. `packages/cli/src/commands/deploy.ts`, `deployToCloud`: the question and the re-send (same version, refusal token), and `finish` under `--json`. 2. `packages/cli/src/commands/package/publish.ts`, the `!verRes.ok` branch and the `--confirm-upgrade` guard. 3. `packages/cli/src/utils/publish-confirm-upgrade.ts`, `retryCommandOf`: an allowlist walker over the command's own flag specs. A dropped flag goes with its value, so `--token` never reaches the printed line, and a stale `--confirm-upgrade` is replaced. `deploy.ts` `CLOUD_RETRY_FLAGS` plus the appended `--env ENV` pin the refused environment. **Two-minute check:** `pnpm --filter @objectstack/cli exec vitest run --maxWorkers=2 test/deploy.test.ts test/package-publish-error-envelope.test.ts`. Expect all green, including the `#30887` hosted cases. ## Tests - `test/deploy.test.ts` adds a judging control-plane stub. Its refusal is the exact `schemaUpgradeConfirmationRefusal` shape, with findings and token from the framework's `schemaUpgradeVerdict`. Cases: no-risk installs with no question and no key; the Q3 stop off a terminal (finding, `renamedFrom` hint, `os deploy --confirm-upgrade TOKEN`, exit 1, one POST, no wait); a terminal yes (second POST, same version, token); a terminal decline; `--confirm-upgrade` on the first POST; a non-Q3 refusal asks nothing; `--json` refusal and clean documents; `--dry-run` refused with nothing built or sent. The two old cases that pinned "`--confirm-upgrade` / `--json` refused on cloud" were removed, because that behaviour is the one this PR replaces. - `test/package-publish-error-envelope.test.ts`, new describe: the publish stop and its retry line, `--confirm-upgrade` sending the key, a stale token re-refused with only the current token named, and `--confirm-upgrade` without `--install` refused with zero requests. - Round 2 (review 7373269516): deploy `--env` retry and `--json` `confirm` name `--env env_b` and never the `--token` value; an environment resolved without `--env` is pinned all the same; a terminal yes re-sends into the same environment; a stale `--confirm-upgrade` is re-refused and the retry names only the current token; the `os dev` d key on the cloud target asks and a decline deploys nothing; `--json` reports `target: runtime` when reading the deploy target fails; publish never prints the key given as `--token KEY`, `--token=KEY`, `-t KEY` or `-tKEY`; the builder drops a dropped flag with its value. ## Verification Round 2 readings at head `0171f212e9`. Targeted: `Tests 96 passed (96)`. Ablations add B1 (6 red), B2 (5 red), B2-deploy (2 red), B2-arity (7 red) and N2 (1 red), each restored to the HEAD blob. Gates: 102 derived, 102 run, 0 NOT-MEASURED, 0 UNRUN (dual-build-cjs-loads re-ran after its dist prerequisites; query-options-erasure re-ran on a longer bound). CI: 59 check-runs, 42 success, 17 skipped, 0 failure. Round 1 readings follow. Readings at head `f0b2842003` (objectstack-ai/objectstack). <details><summary>Targeted tests, typecheck, lint</summary> - `pnpm --filter @objectstack/cli exec vitest run --maxWorkers=2 test/deploy.test.ts test/package-publish-error-envelope.test.ts test/package-install-dry-run.test.ts test/dev-deploy-key.test.ts`: exit 0, `Test Files 4 passed (4)`, `Tests 84 passed (84)`. - `pnpm --filter @objectstack/cli typecheck`: exit 0 (`check:test-typecheck: OK`). - Root `eslint --no-inline-config` on the 6 changed source and test files: exit 0. - CLI `unit` project in full: NOT MEASURED, reason: it did not finish inside the container's 10-minute foreground bound under the verify lock (`timeout 590` answered 124). CI's `Test Core` runs it. The `integration` tier is declared to CI as well. </details> <details><summary>Ablations (5), each turned its pin red and was restored to the HEAD blob</summary> Each mutation went through `scripts/ablation-replace.mjs`: anchor hit 1 to 0, blob changed, then restored with blob equal to HEAD and an empty `git diff HEAD`. Tests import `src` directly, so there is no build leg. - A: drop the `confirm_schema_upgrade` send in `publish.ts`. 3 red: publish `--confirm-upgrade`, deploy terminal yes, deploy `--confirm-upgrade`. - B: ask under `--json` on the cloud path. 1 red: the `--json` refusal case. - C: the terminal yes re-sends without the token. 1 red: the terminal yes case. - D: skip the Q3 branch in `publish.ts`. 3 red: publish stop, stale token, deploy off-terminal stop. - E: accept `--dry-run` on the cloud target. 2 red: both cloud `--dry-run` cases. </details> <details><summary>Gates: dispatch-gates --commands (102 families) and --ran</summary> - `node scripts/pm/dispatch-gates.mjs --commands` derived 102 families against merge base `f5edfb82d`. All 102 exit 0. - Seven of them first refused on prerequisites (`check:skill-examples`, `check:dual-build-cjs-loads` and the three `check:i18n*` families exited 3 on an unbuilt CLI, client-react or examples), and `check:query-options-erasure` outran a 280 s bound. `check:cli-examples-parity` was a real finding (exit 1): the new publish example was missing from the docs block, fixed in `f0b2842003`. After the prerequisites were built, all seven re-ran to exit 0. - The 27 doc-family gates re-ran on `f0b2842003`: all exit 0. - `node scripts/pm/dispatch-gates.mjs --ran`: exit 0, `102 derived, 102 run, 0 NOT-MEASURED, 0 UNRUN` (a derived zero: every line records its exit code). - CI-owned families are read from this PR's check-runs, not re-run locally. </details> ## Acceptance notes - `PackagePublishCommand` (published from `@objectstack/cli`) gains the public members `refusal` and `retryCommand`, which `os deploy` reads in-process. This is the same seam `PackageInstall.outcome` / `retryCommand` gave the self-hosted half, and the changeset declares it. When `retryCommand` is unset, the retry is the run's own arguments without `--token` or `--confirm-upgrade`. - Clause-② is `yes (widening)`, per the seat's ruling in claim amendment 7372140636, and the changeset carries the same line. The level is `patch`, because a non-protocol change ships `patch` (AGENTS.md). - A hosted stop's printed retry never contains the API key: it is built from an allowlist of flags. `os deploy`'s retry and its `--json` `confirm` always name the environment that refused, because the confirming token names no environment (review 7373269516, B1 and B2). - Pre-existing, unchanged (review N3): 'Nothing was published' holds for versions. The package-row upsert runs before the version POST, as it does on main. - The docs edit is outside the claim's first file surface and is in the claim amendment. It is there because the old docs said `--confirm-upgrade` and `--json` were refused on ObjectOS Cloud, which this PR makes false. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01TsNV8Bsjqmw7aXCo2QuLU1 <!-- signed: repo:cloud@zhuangjianguo · zhuangjianguo · session_01TsNV8Bsjqmw7aXCo2QuLU1 --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent f808641 commit 14680d0

8 files changed

Lines changed: 976 additions & 155 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@objectstack/cli': patch
3+
---
4+
5+
feat(cli): `os deploy` to ObjectOS Cloud and `os package publish --install` stop on an undeclared rename or a risky type change, print both ways forward, and take `--confirm-upgrade`
6+
7+
Clause-②: yes (widening)
8+
Metadata-protocol: none
9+
10+
Who sees it: a developer deploying to their ObjectOS Cloud environment with `os deploy` (or the `d` key in `os dev`), or publishing with `os package publish --install`.
11+
12+
- **A plain upgrade is not interrupted.** The control plane judges the install inside the publish, before it stores anything, with the framework's own verdict. A version with only additions and renames declared with `renamedFrom` installs with no question, so the `d` key stays one key press.
13+
- **An undeclared suspected rename or a type change that is not safe stops before anything is published.** The command prints each finding the control plane listed and the two ways forward: declare the old key in the new field's `renamedFrom` and deploy (or publish) again, or confirm the findings as listed with `os deploy --env <environment> --confirm-upgrade <token>` (or the same `os package publish` command with `--confirm-upgrade <token>`). It exits 1. The printed command always names the environment that refused, because the token confirms the findings and names no environment, and it never prints your API key: `--token` is left out, so pass the key again (or use `OS_CLOUD_API_KEY` or `os cloud login`). The control plane stores no version for a refused install, so the confirmed run publishes the same version. There is no `--rename` flag: a rename is declared in the package.
14+
- **On a terminal**, `os deploy` (and so the `d` key) asks "Deploy anyway, accepting each finding as listed?" after the stop, as it already did for a self-hosted runtime. Yes publishes the same version again with the refusal's token; anything else deploys nothing and exits 1. Off a terminal or with `--json`, nothing is asked.
15+
- **`--confirm-upgrade <token>`** is now accepted by `os deploy` on the ObjectOS Cloud target and is new on `os package publish`, where it needs `--install` (without it the command refuses before sending anything). The token is sent as the control plane's `confirm_schema_upgrade`.
16+
- **`os deploy --json`** now works on the ObjectOS Cloud target too: the same one document, with `target: cloud`, the control plane's refusal verbatim in `refusal`, its findings in `wouldStop` and the confirming command in `confirm`. `plan` and `environment` are `null` there, because the control plane's refusal carries the findings and not the plan.
17+
- **`os deploy --dry-run` stays refused on ObjectOS Cloud**, before anything is built or sent, now saying why: the control plane previews only a version it already stores, and a deploy publishes a new one.
18+
- For code that runs the publish command in-process: `PackagePublishCommand` gains `refusal` (`status`, `code`, `message`, `details`, and `schemaUpgrade` when the refusal is a schema upgrade stop, set whenever the version POST is refused) and `retryCommand` (the command a schema upgrade stop names as its retry; unset, the run's own `os package publish` arguments without `--token` or `--confirm-upgrade`).

‎content/docs/deployment/cli.mdx‎

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3908,6 +3908,24 @@ so and does not claim the new version is live.
39083908
There is no deploy on save: on ObjectOS Cloud your organization's environment
39093909
is its production, so a deploy is always a deliberate act.
39103910
3911+
**A schema upgrade stops before anything is published.** The control plane
3912+
judges the install inside the publish, before any write, with the framework's
3913+
own verdict. A version with only additions and renames declared with
3914+
`renamedFrom` installs without a question. An undeclared suspected rename or a
3915+
type change that is not safe is refused: the deploy prints each finding and
3916+
the two ways forward (declare the old key in the new field's `renamedFrom` and
3917+
deploy again, or `os deploy --env <environment> --confirm-upgrade <token>` to
3918+
accept the findings as listed), stores no version, and exits `1`. The printed
3919+
command always names the environment that refused, with the `--server`,
3920+
`--wait`/`--no-wait`, `--wait-timeout` and `--json` you typed, and never your
3921+
`--token`: the token confirms the findings, not an environment, so a re-run
3922+
without `--env` could install them somewhere they were never shown. On a terminal (so also under the `d`
3923+
key) it asks `Deploy anyway, accepting each finding as listed? [y/N]` instead;
3924+
yes publishes the same version again with the refusal's token. The control
3925+
plane previews only a version it already stores, and a deploy publishes a new
3926+
one, so on ObjectOS Cloud there is no plan to print before the install and
3927+
`--dry-run` is refused.
3928+
39113929
| Flag | Env equivalent | Purpose |
39123930
|---|---|---|
39133931
| `--env <id>` | `OS_ENVIRONMENT_ID` | Environment to deploy into (default: the active one for this control plane, then your organization's only one) |
@@ -3917,9 +3935,9 @@ is its production, so a deploy is always a deliberate act.
39173935
| `-t, --token <key>` | `OS_CLOUD_API_KEY` | Bearer token; `$OS_TOKEN` and `~/.objectstack/cloud.json` are the fallbacks |
39183936
| `--confirm-global-uniques` | — | Self-hosted target only: confirm the app's installation-wide `unique` constraints are genuinely platform-wide when the runtime's refusal asks (as [`os package install`](#os-package-install)). Refused when the target is ObjectOS Cloud |
39193937
| `--confirm-access-upgrade <token>` | — | Self-hosted target only: confirm the upgrade's access findings with the finding-set token the runtime's refusal printed (as [`os package install`](#os-package-install)). Refused when the target is ObjectOS Cloud |
3920-
| `--confirm-upgrade <token>` | — | Self-hosted target only: confirm the upgrade's schema findings (a suspected rename, a type change that is not safe) with the finding-set token the runtime's refusal printed (as [`os package install`](#os-package-install)). Refused when the target is ObjectOS Cloud |
3921-
| `--dry-run` | — | Self-hosted target only: build, print the upgrade plan, say whether the install would stop for a confirmation, and install nothing. Refused when the target is ObjectOS Cloud |
3922-
| `--json` | — | Self-hosted target only: print one JSON document on stdout (see below); progress goes to stderr. Refused when the target is ObjectOS Cloud; the document then says so (`target: cloud`, `result: failed`) |
3938+
| `--confirm-upgrade <token>` | — | Confirm the upgrade's schema findings (a suspected rename, a type change that is not safe) with the finding-set token the refusal printed: the self-hosted runtime's (as [`os package install`](#os-package-install)) or the control plane's (as [`os package publish --install`](#os-package-publish)) |
3939+
| `--dry-run` | — | Self-hosted target only: build, print the upgrade plan, say whether the install would stop for a confirmation, and install nothing. Refused when the target is ObjectOS Cloud, before anything is built or sent |
3940+
| `--json` | — | Print one JSON document on stdout (see below); progress goes to stderr |
39233941

39243942
`os package publish` stays the command for a **release**: it publishes the
39253943
version the manifest declares, with `--install` optional.
@@ -3976,14 +3994,14 @@ stderr. A refusal or a failure exits `1`; a dry run or a live install exits `0`.
39763994
39773995
| Key | Value |
39783996
|---|---|
3979-
| `target` | `runtime` (or `cloud` when the flag is refused there) |
3980-
| `url` | The runtime's URL |
3997+
| `target` | `runtime` or `cloud` |
3998+
| `url` | The runtime's URL, or the control plane's |
39813999
| `result` | `planned` (`--dry-run`), `installed`, `refused` or `failed` |
3982-
| `package` | `{ manifestId, version, installedVersion }` from the dry run |
3983-
| `plan`, `environment` | The runtime's dry-run reading, verbatim |
3984-
| `wouldStop` | The schema findings the install would ask to confirm, previewed from the plan (`[]`: none; `null`: not read) |
3985-
| `refusal` | The runtime's refusal, verbatim: `{ status, code, message, details }` |
3986-
| `confirm` | `os deploy --confirm-upgrade <token>` when the refusal is a schema upgrade stop |
4000+
| `package` | `{ manifestId, version, installedVersion }` from the dry run, or from the control plane's refusal or install |
4001+
| `plan`, `environment` | The runtime's dry-run reading, verbatim; `null` on ObjectOS Cloud, whose refusal carries the findings and not the plan |
4002+
| `wouldStop` | The schema findings the install asks to confirm: on a runtime previewed from the plan (`[]`: none; `null`: not read); on ObjectOS Cloud the ones its refusal listed, and `null` when the install was not refused with a schema stop |
4003+
| `refusal` | The refusal, verbatim: `{ status, code, message, details }` |
4004+
| `confirm` | The command that confirms exactly the refused findings, when the refusal is a schema upgrade stop: on ObjectOS Cloud `os deploy --env <environment> --confirm-upgrade <token>` (with the target flags you typed, never `--token`) |
39874005
| `error` | What stopped the deploy, when something did |
39884006
39894007
```bash
@@ -4258,6 +4276,7 @@ os package publish --manifest-id com.acme.crm --version 1.2.0
42584276
os package publish dist/objectstack.json --visibility org --note "first cut"
42594277
os package publish --env env_abc123 --install # publish, then install into an environment
42604278
os package publish --install # into the active environment (os environments switch)
4279+
os package publish --install --confirm-upgrade <finding-set> # confirm the schema findings the refusal printed
42614280
OS_CLOUD_URL=http://localhost:4000 os package publish # against a local control plane
42624281
```
42634282

@@ -4287,6 +4306,17 @@ None, several, or a list that cannot be read is a refusal: the command exits
42874306
`1` before it registers the package or publishes a version, and lists the
42884307
candidates with how to pass `--env`.
42894308

4309+
**An upgrade that renames or retypes a stored field stops.** With `--install`,
4310+
the control plane judges the install before it stores anything. A version with
4311+
only additions and renames declared with `renamedFrom` installs as before. An
4312+
undeclared suspected rename, or a type change that is not safe, is refused: the
4313+
command prints each finding and the two ways forward (declare the old key in the
4314+
new field's `renamedFrom` and publish again, or re-run the same command with
4315+
`--confirm-upgrade <token>` to accept the findings as listed), and exits `1`.
4316+
The printed command repeats your arguments except `--token`, which it never
4317+
prints: pass the key again the way you did, or through `OS_CLOUD_API_KEY`.
4318+
Nothing is published, so the confirmed run publishes the same version.
4319+
42904320
**Options:**
42914321
42924322
| Flag | Env equivalent | Purpose |
@@ -4302,6 +4332,7 @@ candidates with how to pass `--env`.
43024332
| `--org <id>` | `OS_ORG_ID` | `owner_org_id`. Required with a bearer key in service mode; ignored in user mode |
43034333
| `--env <id>` | `OS_ENVIRONMENT_ID` | Environment to install the new version into. Defaults to the environment [`os environments switch`](#cloud-environments) — or `os environments create --activate` — recorded **for this control plane** in `~/.objectstack/cloud.json`, then to your organization's only environment |
43044334
| `--install` | — | Install the new version after publishing, into `--env` or the environment it defaults to. With no environment to name — none, several, or a list the control plane would not give — it exits `1` **before publishing anything**, naming how to pass one |
4335+
| `--confirm-upgrade <token>` | — | With `--install`: confirm the upgrade's schema findings (a suspected rename, a type change that is not safe) with the finding-set token the control plane's refusal printed. Without `--install` it is refused before anything is sent |
43054336
| `--seed-sample-data` | — | Include sample data in that auto-install |
43064337
| `--pre-release` | — | Mark the version as a pre-release (also inferred — see below) |
43074338
| `--submit` | — | Submit the new version for marketplace review. Needs the package's visibility to be `marketplace` (already stored, or set with `--visibility marketplace`) and a complete listing |

0 commit comments

Comments
 (0)