Skip to content

Commit 2ef9def

Browse files
committed
Merge remote-tracking branch 'origin/main' into claude/project-thread-7t0m2i
2 parents e84701f + 6ed533f commit 2ef9def

16 files changed

Lines changed: 751 additions & 196 deletions
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
'@objectstack/cli': patch
3+
'@objectstack/runtime': patch
4+
---
5+
6+
fix(cli,runtime): the organization-ownership refusal from `os start --home` / `-d` names the database it refused
7+
8+
Clause-②: yes (widening) — `@objectstack/runtime`'s published `OrganizationOwnershipBootGuardOptions` gains one optional member, `databaseUrl`, and the refusal's two ceremony commands carry `--database-url` when the boot's database came from `os start`'s `-d` or a `--home` home. What `os start`, `os serve` and `os migrate organization-ownership` accept or refuse is unchanged.
9+
Metadata-protocol: none
10+
11+
`os start` resolves its database with two inputs the ceremony never sees: its `-d` flag and its `--home` flag. When a boot on such a database was refused for its organization-ownership shape, the refusal printed `os migrate organization-ownership --out PLAN` (and the `--apply` command) with no database, so run as printed in the same directory the ceremony planned the project's own database, or found none ("holds none of the platform tables"), and the database that was refused stayed as it was. On a tree that also holds a pre-18 project database, the printed apply would have upgraded that one instead.
12+
13+
`os start` now hands its `serve` child, on an internal channel, the database it resolved whenever `-d` or a `--home` home chose it, and the boot guard names it in both commands: `os migrate organization-ownership --database-url file:/srv/os/home/data/objectstack.db --out PLAN`. A database the ceremony already reaches on its own (`$OS_DATABASE_URL`, the project's declared datasource, the project's `.objectstack` or an exported `$OS_HOME`) is named as before, with no `--database-url`.
14+
15+
A database URL that carries a credential (a password, or a token in its query) is never printed: the commands read it as `--database-url "${OS_DATABASE_URL:?…}"`, the refusal says to export it, and the shell stops with that message when the variable is unset rather than planning another database. `OrganizationOwnershipBootGuardOptions` (`@objectstack/runtime`) gains the optional `databaseUrl` that carries it.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@objectstack/metadata-core': patch
3+
'@objectstack/cloud-connection': patch
4+
'@objectstack/spec': patch
5+
---
6+
7+
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.

‎.github/workflows/merge-queue-triage.yml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,14 @@ on:
182182
workflow_run:
183183
workflows: [CI]
184184
types: [completed]
185+
# Trigger-level narrowing (#31521): GitHub matches `branches` against the
186+
# branch the triggering CI run ran on, and every merge_group run runs on
187+
# `gh-readonly-queue/<base>/pr-…`. Without it every CI run of any event
188+
# started a run here that the job `if:` then skipped (about 757 a day over
189+
# 2026-11-01..07, against about 263 merge_group CI runs). The trigger
190+
# cannot filter on event or conclusion, so the job `if:` below stays the
191+
# authority and this line only stops runs it would skip anyway.
192+
branches: ['gh-readonly-queue/**']
185193

186194
permissions: {}
187195

‎.github/workflows/scheduled-full-run-card.yml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ on:
9595
# night files `nightly full run: red on main (UI Coverage)`.
9696
workflows: ['CI', 'Lint & Type Check', 'UI Coverage']
9797
types: [completed]
98+
# Trigger-level narrowing (#31521): GitHub matches `branches` against the
99+
# branch the triggering run ran on, so pull_request and merge_group runs
100+
# of the watched workflows no longer start a run here only for the job
101+
# `if:` to skip it (about 1,512 a day over 2026-11-01..07, against about
102+
# 269 runs on `main`). The trigger cannot filter on event or conclusion,
103+
# so `push` runs on `main` still arrive and the job `if:` below stays the
104+
# authority; its `head_branch == 'main'` guard is kept, not replaced.
105+
branches: [main]
98106

99107
permissions: {}
100108

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { mountsAiServicePlugin, resolveAiServiceLoad, resolveOptionalPluginLoad
1414
import { registerInstalledPlugins } from '../utils/installed-plugins-boot.js';
1515
import { readInternalArtifactPath, readInternalConfigOutputPath } from '../utils/internal-artifact-channel.js';
1616
import { readAuthSecretFileChannel } from '../utils/internal-auth-secret-channel.js';
17+
import { readCeremonyDatabaseChannel } from '../utils/internal-ceremony-database-channel.js';
1718
import { compileForDevBoot, devCompilesAtBoot } from '../utils/dev-compile-at-boot.js';
1819
import { makeDirectorySync } from '../utils/make-directory.js';
1920
// The precedence's last rung — whether the cwd config takes part — decided by
@@ -4215,10 +4216,14 @@ export default class Serve extends Command {
42154216
// ceremony boots the way this one did (its secret, .env* files and
42164217
// `telemetry` sibling). A boot `os start` supervises with the secret it
42174218
// persisted in its home names that file, so the ceremony runs with the
4218-
// secret this server composes its security plugin with.
4219+
// secret this server composes its security plugin with. A boot on a
4220+
// database the ceremony would not find by default (`os start -d` or
4221+
// `--home`, #31488) names it, so the commands plan this database.
4222+
const ceremonyDatabase = readCeremonyDatabaseChannel(process.env);
42194223
await kernel.use(new OrganizationOwnershipBootGuardPlugin({
42204224
dev: isDev,
42214225
authSecretFile: readAuthSecretFileChannel(process.env),
4226+
...(ceremonyDatabase ? { databaseUrl: ceremonyDatabase } : {}),
42224227
}));
42234228
trackPlugin('OrganizationOwnershipBootGuard');
42244229
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
import { ServeRestartCoordinator } from '../utils/dev-restart.js';
2424
import { readEnvWithDeprecation } from '@objectstack/types';
2525
import { writeAuthSecretFileChannel } from '../utils/internal-auth-secret-channel.js';
26+
import { ceremonyDatabaseUrl, writeCeremonyDatabaseChannel } from '../utils/internal-ceremony-database-channel.js';
2627
import { applyCryptoKeyFileChannel } from '../utils/internal-crypto-key-file-channel.js';
2728
import { resolveStartHome } from '../utils/start-home.js';
2829
// The ONE port contract, shared with `dev` and with the `serve` child this
@@ -501,6 +502,11 @@ export default class Start extends Command {
501502
AUTH_SECRET: authSecret,
502503
};
503504
writeAuthSecretFileChannel(localEnv, persistedAuthSecret?.file);
505+
// [#31488] A database reached through `-d` or a `--home` home is one the
506+
// ceremony the ownership refusal names does not find on its own: the
507+
// child names it in both commands, read from the resolution above — the
508+
// one this boot serves — never re-resolved.
509+
writeCeremonyDatabaseChannel(localEnv, ceremonyDatabaseUrl(resolvedDb, { homeFlag: flags.home }));
504510
// NODE_ENV is only forced to production when the user has not set it.
505511
// Allows `NODE_ENV=development objectstack start` to work for debugging.
506512
//
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* #31488 — which database `os start`'s ownership refusal must name, and the
5+
* channel that carries it to the `serve` child.
6+
*
7+
* The ceremony (`os migrate organization-ownership`) resolves its database the
8+
* way every CLI command does: `--database-url`, then `$OS_DATABASE_URL`, then
9+
* the project's declared datasource, then `<state dir>/data/objectstack.db`,
10+
* where the state dir is `$OS_HOME` or the project's `.objectstack`. `os start`
11+
* resolves the same ladder with two inputs the ceremony never sees: its
12+
* `-d` flag and its `--home` flag. A database reached through either is one
13+
* the ceremony, run bare in the same shell, does not find.
14+
*
15+
* - ⭐ `-d` → named; `--home` with the home's file → named;
16+
* - `--home` beside `$OS_DATABASE_URL` or a declared datasource → not named
17+
* (the ceremony reads those too); no flag → not named (the default and an
18+
* exported `$OS_HOME` reach the same file);
19+
* - the channel is owned by the parent: set when named, deleted otherwise.
20+
*/
21+
22+
import { describe, expect, it } from 'vitest';
23+
import {
24+
INTERNAL_CEREMONY_DATABASE_URL_ENV,
25+
ceremonyDatabaseUrl,
26+
readCeremonyDatabaseChannel,
27+
writeCeremonyDatabaseChannel,
28+
} from './internal-ceremony-database-channel.js';
29+
30+
const HOME_FILE = 'file:/srv/os/home/data/objectstack.db';
31+
32+
describe('ceremonyDatabaseUrl — the database the refusal names, or none', () => {
33+
it('⭐ a database from `-d` is named, whatever the home', () => {
34+
expect(ceremonyDatabaseUrl({ url: 'file:A.db', source: 'explicit' }, { homeFlag: undefined })).toBe('file:A.db');
35+
expect(ceremonyDatabaseUrl({ url: 'file:A.db', source: 'explicit' }, { homeFlag: '/srv/os/home' })).toBe('file:A.db');
36+
});
37+
38+
it('⭐ the file of a `--home` home is named', () => {
39+
expect(ceremonyDatabaseUrl({ url: HOME_FILE, source: 'unified-default' }, { homeFlag: '/srv/os/home' })).toBe(HOME_FILE);
40+
expect(ceremonyDatabaseUrl({ url: 'file:/srv/os/home/data/dev.db', source: 'legacy-file' }, { homeFlag: '/srv/os/home' }))
41+
.toBe('file:/srv/os/home/data/dev.db');
42+
});
43+
44+
it('a database the ceremony reaches by its own ladder is not named', () => {
45+
// `$OS_DATABASE_URL` / a declared datasource: the ceremony reads them too.
46+
expect(ceremonyDatabaseUrl({ url: 'postgres://db/os', source: 'env' }, { homeFlag: '/srv/os/home' })).toBeUndefined();
47+
expect(ceremonyDatabaseUrl({ url: 'file:/app/data.db', source: 'config-datasource' }, { homeFlag: '/srv/os/home' }))
48+
.toBeUndefined();
49+
// No flag: the project's `.objectstack`, or an exported `$OS_HOME`, is the ceremony's default too.
50+
expect(ceremonyDatabaseUrl({ url: HOME_FILE, source: 'unified-default' }, { homeFlag: undefined })).toBeUndefined();
51+
});
52+
});
53+
54+
describe('the ceremony-database channel to the serve child', () => {
55+
it('is set when there is a database to name, and deleted otherwise — an inherited copy never speaks', () => {
56+
const env: NodeJS.ProcessEnv = {};
57+
writeCeremonyDatabaseChannel(env, 'file:A.db');
58+
expect(env[INTERNAL_CEREMONY_DATABASE_URL_ENV]).toBe('file:A.db');
59+
expect(readCeremonyDatabaseChannel(env)).toBe('file:A.db');
60+
writeCeremonyDatabaseChannel(env, undefined);
61+
expect(INTERNAL_CEREMONY_DATABASE_URL_ENV in env).toBe(false);
62+
expect(readCeremonyDatabaseChannel(env)).toBeUndefined();
63+
expect(readCeremonyDatabaseChannel({ [INTERNAL_CEREMONY_DATABASE_URL_ENV]: '' })).toBeUndefined();
64+
});
65+
});
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* The CLI's INTERNAL parent-to-child channel for the database `os start`'s
5+
* ownership refusal must name (#31488).
6+
*
7+
* `os start` resolves its database on the shared ladder
8+
* (`resolveProjectDatabaseUrl`, `@objectstack/runtime`) with two inputs no
9+
* other command sees: its `-d` flag and its `--home` flag. The ceremony the
10+
* v18 ownership refusal names (`os migrate organization-ownership`) resolves
11+
* the same ladder WITHOUT them, so run bare in the operator's shell it plans
12+
* another database: the project's own, or none at all. The `serve` child sees
13+
* only the URL it was handed and cannot tell how the parent reached it; this
14+
* channel tells it, carrying the URL the child serves when, and only when,
15+
* the ceremony would not find it (`OrganizationOwnershipBootGuardOptions.databaseUrl`).
16+
*
17+
* Same naming and ownership rule as `OS_INTERNAL_AUTH_SECRET_FILE`
18+
* (`internal-auth-secret-channel.ts`): `INTERNAL` in the domain slot, a
19+
* private call between two processes the CLI owns both ends of, deliberately
20+
* not listed in `content/docs/deployment/environment-variables.mdx`. The
21+
* parent OWNS the variable in the child env: set when there is a database to
22+
* name, deleted otherwise, so an inherited copy never speaks for this run.
23+
*/
24+
25+
import type { ResolvedProjectDatabaseUrl } from '@objectstack/runtime';
26+
27+
export const INTERNAL_CEREMONY_DATABASE_URL_ENV = 'OS_INTERNAL_CEREMONY_DATABASE_URL';
28+
29+
/**
30+
* The database the refusal must name: `os start`'s resolved URL when its `-d`
31+
* flag chose it, or when the file of a `--home` home is the database (the
32+
* unified default or a legacy file under that home). `undefined` when the
33+
* ceremony's own ladder reaches the same database: `$OS_DATABASE_URL`, the
34+
* project's declared datasource, or the default file of the project's
35+
* `.objectstack` or an exported `$OS_HOME`.
36+
*/
37+
export function ceremonyDatabaseUrl(
38+
resolved: Pick<ResolvedProjectDatabaseUrl, 'url' | 'source'>,
39+
opts: { homeFlag: string | undefined },
40+
): string | undefined {
41+
if (resolved.source === 'explicit') return resolved.url;
42+
const homeFile = resolved.source === 'unified-default' || resolved.source === 'legacy-file';
43+
if (homeFile && opts.homeFlag !== undefined && opts.homeFlag.trim() !== '') return resolved.url;
44+
return undefined;
45+
}
46+
47+
/** Write the channel into a `serve` child's environment: the URL to name, otherwise no variable at all. */
48+
export function writeCeremonyDatabaseChannel(env: NodeJS.ProcessEnv, url: string | undefined): void {
49+
if (url) env[INTERNAL_CEREMONY_DATABASE_URL_ENV] = url;
50+
else delete env[INTERNAL_CEREMONY_DATABASE_URL_ENV];
51+
}
52+
53+
/** Read the channel in the `serve` child: the URL, or `undefined` when the parent set none. */
54+
export function readCeremonyDatabaseChannel(env: NodeJS.ProcessEnv): string | undefined {
55+
const url = env[INTERNAL_CEREMONY_DATABASE_URL_ENV];
56+
return url ? url : undefined;
57+
}

0 commit comments

Comments
 (0)