Skip to content

Commit 60be366

Browse files
committed
test(cloud-connection): pin the schema upgrade verdict at the install-local door (wip)
Claude-Session: https://claude.ai/code/session_017ihL2dvnT51fbSebUyE3zW Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 146ea6d commit 60be366

4 files changed

Lines changed: 217 additions & 17 deletions

File tree

‎packages/cli/src/commands/deploy.ts‎

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@
6161
* version against this build, printed; nothing is installed. A runtime
6262
* that refuses it, or does not serve install-local, stops the deploy here
6363
* with its sentence and exit 1;
64-
* 3. the install, with `--confirm-access-upgrade` passed through; the door's
65-
* refusals (an access upgrade to confirm, …) stop the deploy with exit 1;
64+
* 3. the install, with `--confirm-access-upgrade` and `--confirm-upgrade`
65+
* passed through; the door's refusals (an access upgrade or a schema
66+
* upgrade to confirm, …) stop the deploy with exit 1;
6667
* 4. the answer — install-local registers the package in the live kernel
6768
* before it answers, so the answer IS "live": `hotLoaded` ⇒ 0; a package
6869
* the running kernel could not load ⇒ 1, naming the restart it waits for.
@@ -102,6 +103,7 @@ export default class Deploy extends Command {
102103
'$ os deploy --env env_abc123 # your account reaches several environments',
103104
'$ os deploy --no-wait # return once the install is recorded',
104105
'$ os deploy --confirm-access-upgrade <finding-set> # self-hosted: confirm the findings the runtime printed',
106+
'$ os deploy --confirm-upgrade <finding-set> # self-hosted: confirm the schema findings the runtime printed',
105107
];
106108

107109
static override flags = {
@@ -140,6 +142,16 @@ export default class Deploy extends Command {
140142
'Self-hosted runtime target: confirm the access findings of this upgrade with the finding-set token the '
141143
+ "runtime's refusal printed (as `os package install --confirm-access-upgrade`)",
142144
}),
145+
// [epic cloud#3652 Q3, #30884] The schema findings' confirmation, passed
146+
// through to the install as `--confirm-access-upgrade` is: the embedded
147+
// install's refusal prints `os deploy --confirm-upgrade <token>` as its
148+
// retry, so this command must take it.
149+
'confirm-upgrade': Flags.string({
150+
description:
151+
'Self-hosted runtime target: confirm the schema findings of this upgrade (a suspected rename, a type change '
152+
+ "that is not safe) with the finding-set token the runtime's refusal printed (as `os package install "
153+
+ '--confirm-upgrade`)',
154+
}),
143155
};
144156

145157
async run(): Promise<void> {
@@ -151,12 +163,13 @@ export default class Deploy extends Command {
151163
// cloud environment was named.
152164
const runtime = flags.env ? undefined : await activeRuntimeTarget();
153165
if (runtime) {
154-
await this.deployToRuntime(runtime, flags['confirm-access-upgrade']);
166+
await this.deployToRuntime(runtime, flags['confirm-access-upgrade'], flags['confirm-upgrade']);
155167
return;
156168
}
157-
if (flags['confirm-access-upgrade'] !== undefined) {
169+
for (const flag of ['confirm-access-upgrade', 'confirm-upgrade'] as const) {
170+
if (flags[flag] === undefined) continue;
158171
printError(
159-
'`--confirm-access-upgrade` confirms a self-hosted runtime\'s refusal; the deploy target is ObjectOS Cloud. '
172+
`\`--${flag}\` confirms a self-hosted runtime's refusal; the deploy target is ObjectOS Cloud. `
160173
+ 'Drop the flag, or record the runtime with `os environments use-runtime <url> --token <key>`.',
161174
);
162175
this.exit(1);
@@ -285,7 +298,11 @@ export default class Deploy extends Command {
285298
* The self-hosted half (the header's "A self-hosted runtime target"):
286299
* build → dry run (plan printed) → install → the `hotLoaded` answer.
287300
*/
288-
private async deployToRuntime(runtime: RuntimeTarget, confirmAccessUpgrade: string | undefined): Promise<void> {
301+
private async deployToRuntime(
302+
runtime: RuntimeTarget,
303+
confirmAccessUpgrade: string | undefined,
304+
confirmUpgrade: string | undefined,
305+
): Promise<void> {
289306
printStep(`Deploying to the self-hosted runtime ${runtime.url} (os environments use-runtime)`);
290307

291308
printStep('Building...');
@@ -317,7 +334,10 @@ export default class Deploy extends Command {
317334
}
318335

319336
printStep(`Installing ${plan.manifestId} ${plan.version} into ${runtime.url}...`);
320-
const outcome = await install(confirmAccessUpgrade !== undefined ? ['--confirm-access-upgrade', confirmAccessUpgrade] : []);
337+
const outcome = await install([
338+
...(confirmAccessUpgrade !== undefined ? ['--confirm-access-upgrade', confirmAccessUpgrade] : []),
339+
...(confirmUpgrade !== undefined ? ['--confirm-upgrade', confirmUpgrade] : []),
340+
]);
321341
if (outcome?.kind !== 'installed') {
322342
printError(`${runtime.url} did not answer the install as a managed package install, so this cannot say ${plan.manifestId} is live (see above).`);
323343
this.exit(1);

‎packages/cli/src/commands/package/install.ts‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ export default class PackageInstall extends Command {
206206
'$ OS_RUNTIME_EMAIL=admin@local.test OS_RUNTIME_PASSWORD=… os package install com.acme.crm',
207207
'$ os package install ./dist/objectstack.json --url https://app.example.com --token osk_…',
208208
'$ os package install ./dist/objectstack.json --dry-run # print the upgrade plan, install nothing',
209+
'$ os package install ./dist/objectstack.json --confirm-upgrade <finding-set> # confirm the schema findings the runtime printed',
209210
];
210211

211212
static override args = {
@@ -287,6 +288,17 @@ export default class PackageInstall extends Command {
287288
"Confirm the access findings of this upgrade with the finding-set token the runtime's refusal printed "
288289
+ '(ACCESS_UPGRADE_CONFIRMATION_REQUIRED). It confirms exactly those findings; a changed set is refused again.',
289290
}),
291+
// [epic cloud#3652 Q3, #30884] The confirmation of an upgrade's schema
292+
// findings — an undeclared suspected rename, a type change that is not
293+
// `safe`. A TOKEN, as `--confirm-access-upgrade` is: the finding set's
294+
// digest the runtime's refusal printed, so it confirms exactly the
295+
// findings shown, and a set that changed since is refused again.
296+
'confirm-upgrade': Flags.string({
297+
description:
298+
"Confirm the schema findings of this upgrade with the finding-set token the runtime's refusal printed "
299+
+ '(SCHEMA_UPGRADE_CONFIRMATION_REQUIRED): a removed field with an unlinked added one (a suspected rename), '
300+
+ 'a type change that is not safe. It confirms exactly those findings; a changed set is refused again.',
301+
}),
290302
// [epic cloud#3652 Q3, #30884] The install-local body's `dryRun`.
291303
'dry-run': Flags.boolean({
292304
description:
@@ -411,6 +423,7 @@ export default class PackageInstall extends Command {
411423
printStep(`Installing ${label} into ${runtime}...`);
412424
if (flags['confirm-global-uniques']) body.confirmGlobalUniques = true;
413425
if (flags['confirm-access-upgrade'] !== undefined) body.confirmAccessUpgrade = flags['confirm-access-upgrade'];
426+
if (flags['confirm-upgrade'] !== undefined) body.confirmSchemaUpgrade = flags['confirm-upgrade'];
414427
const installMode = flags['install-mode'] as InstallMode | undefined;
415428
if (installMode !== undefined) body.installMode = installMode;
416429
if (flags['dry-run']) body.dryRun = true;
@@ -456,6 +469,22 @@ export default class PackageInstall extends Command {
456469
this.exit(1);
457470
return;
458471
}
472+
// [epic cloud#3652 Q3, #30884] The schema upgrade stop: every finding,
473+
// then both ways forward — declare the rename in the package, or
474+
// confirm exactly these findings.
475+
if (res.body?.error?.code === 'SCHEMA_UPGRADE_CONFIRMATION_REQUIRED') {
476+
const details = res.body.error.details ?? {};
477+
const findings: Array<{ describe?: string }> = Array.isArray(details.findings) ? details.findings : [];
478+
printError('Upgrade stopped — it would rename or retype stored fields without carrying their values');
479+
console.log('');
480+
for (const finding of findings) console.log(` • ${finding.describe ?? JSON.stringify(finding)}`);
481+
console.log('');
482+
console.log(" If a field was renamed, declare its old key in the new field's `renamedFrom` and rebuild.");
483+
console.log(' To upgrade anyway, accepting each finding as listed, confirm exactly these findings:');
484+
console.log(` ${retry} --confirm-upgrade ${details.findingSet}`);
485+
this.exit(1);
486+
return;
487+
}
459488
if (res.status === 401) {
460489
printError(
461490
'The runtime rejected the call as unauthenticated. Pass --token (or OS_RUNTIME_TOKEN) with a ' +

‎packages/cloud-connection/src/marketplace-install-local-plugin.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3803,12 +3803,13 @@ export class MarketplaceInstallLocalPlugin implements Plugin {
38033803
const rows = await this.readSchemaUpgradeRows(ctx, manifestId, installed, converted);
38043804
const findings = verdict.findings.map((f) => {
38053805
const installedKey = f.kind === 'type_change' ? (f.renamedFrom ?? f.field) : f.field;
3806-
const held = rows?.get(`${f.object}.${installedKey}`);
3807-
if (rows === undefined) return f;
3806+
const key = `${f.object}.${installedKey}`;
3807+
if (!rows?.has(key)) return f;
3808+
const held = rows.get(key) ?? null;
38083809
return {
38093810
...f,
3810-
rows: held ?? null,
3811-
...(typeof held === 'number' ? { describe: `${f.describe} ${held} row(s) hold a value in ${f.object}.${installedKey}.` } : {}),
3811+
rows: held,
3812+
...(held !== null ? { describe: `${f.describe} ${held} row(s) hold a value in ${key}.` } : {}),
38123813
};
38133814
});
38143815

@@ -3819,7 +3820,7 @@ export class MarketplaceInstallLocalPlugin implements Plugin {
38193820
to: r.to,
38203821
...(r.fromType !== undefined ? { fromType: r.fromType } : {}),
38213822
...(r.toType !== undefined ? { toType: r.toType } : {}),
3822-
...(rows !== undefined ? { rows: rows.get(`${r.object}.${r.from}`) ?? null } : {}),
3823+
...(rows?.has(`${r.object}.${r.from}`) ? { rows: rows.get(`${r.object}.${r.from}`) ?? null } : {}),
38233824
}));
38243825
ctx.logger?.warn?.(
38253826
`[MarketplaceInstallLocal] upgrade of ${manifestId} refused: ${renames.length} declared rename(s) this `

0 commit comments

Comments
 (0)