Skip to content

Commit eb5bf1a

Browse files
committed
Merge remote-tracking branch 'origin/main' into claude/project-thread-jju3py
2 parents 0292183 + e343ab7 commit eb5bf1a

18 files changed

Lines changed: 1740 additions & 23 deletions
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
'@objectstack/plugin-auth': patch
3+
---
4+
5+
fix(auth)!: a boot outside development mode retires what the development seed issued
6+
7+
Clause-②: no (narrowing)
8+
Metadata-protocol: none
9+
10+
<!-- adr-0087: not-required (no-migration-prescription) No key of any schema is added, removed, renamed or re-shaped, and no export changes shape. What moves is what a boot outside development mode does to the credentials the development seed's accounts were issued: no metadata, registry key or authored value changes, so there is nothing for a migration to rewrite and no tombstone. -->
11+
12+
**BREAKING** for a deployment that serves a database `os dev` seeded. At every boot outside development mode (`NODE_ENV` is not `development`), before the server serves a request, the platform retires what each account the development seed created (its admin and the stack's `demoStaff`) was issued, while that account still has the password it was seeded with: its sessions (including any it opened acting as another account), its API keys, the apps authorized to it and its device sign-ins, its outstanding password-reset links, any sign-in account linked to it, the OAuth applications it registered (disabled) and the SCIM credentials it minted (revoked). It is the revocation `os user set-password` performs, plus the sessions the account opened as another account, without setting a password, and with a host `secondaryStorage` it also ends the sessions held there.
13+
14+
- FROM: a session, an API key or an authorized app the seed's admin or a demo account was issued under `os dev` kept working on a server outside development mode, until an operator ran `os user set-password` on that account.
15+
- TO: the boot retires them. A retired session's next request is unauthenticated, a retired key is refused `403 API_KEY_REVOKED`, and both carry the reason `admin_password_reset`, so only a platform administrator restores such a key. The log names each account and what was retired. When the retirement cannot complete, the boot fails with an error naming the accounts.
16+
17+
**Not moved.** A boot in development mode retires nothing. An account the seed did not create is never read. An account whose password was set since the seed (by `os user set-password`, by an administrator or by its own reset) holds a credential the seed did not issue and is untouched, and so is every credential it was issued after that. A database with no account the seed created costs one indexed read per boot.
18+
19+
The fix: set each seeded account's password with `os user set-password <email>` before serving the database outside development mode (the refusals added in the previous release already require it to sign in), then sign in and issue new keys.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@objectstack/runtime': patch
3+
---
4+
5+
fix(comments): unreact, resolve and own-comment delete answer on an `objectstack serve` / `objectstack dev` multi-tenant host instead of `404 ENDPOINT_NOT_FOUND`
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
On a multi-tenant host composed the way the framework CLI composes one (`HonoServerPlugin` + `DispatcherPlugin`, a `kernel-resolver`, and no `createHonoApp` catch-all), the three comment doors, `DELETE /api/v1/comments/reactions/:id`, `PUT /api/v1/comments/:id/resolution` and `DELETE /api/v1/comments/:id`, never reached the dispatcher's `/comments` domain: `AuditPlugin` runs on the per-environment kernel, which owns no `http.server`, and `DispatcherPlugin`'s fallback seam handed on only domain-decided and app-endpoint paths. So the transport answered its own `404 ENDPOINT_NOT_FOUND`.
11+
12+
`DispatcherPlugin`'s fallback now hands exactly those three method and path shapes (bare or environment-scoped) to `dispatch()` on a multi-tenant host, with the transport's request rebuilt as a Web `Request` carrying its original body, and writes the door's `Response` back unchanged. Any other shape still writes nothing, so the transport's own miss stands; a single-kernel host keeps today's answers; and the fallback runs only after every mounted route missed, so a kernel that mounts the doors itself is never reached here.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@objectstack/runtime': patch
3+
---
4+
5+
fix(runtime): an artifact boot names every code plugin of the app that it does not run
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
A compiled artifact carries an app's metadata and hook handlers, not its code plugins: `os build` writes each entry of the stack's `plugins` as a plain descriptor (`{ name, version, dependencies, options }`), and the runtime module beside the JSON exports `functions` only. So a boot from the artifact (`OS_ARTIFACT_URL`, the composed hosted boot, `os start` on a built app) runs none of them. That is the envelope-key rule: an artifact carries metadata, a host assembles plugins. It used to happen in silence, and every service those plugins register was simply absent, so whatever depended on them failed later and somewhere else.
11+
12+
The artifact boot now says so once, at `warn`, when the app's `AppPlugin` starts: `[AppPlugin] app 'APP_ID' lists N plugin(s) that are not running on this kernel: 'PLUGIN_NAME', …`, with the remedy (boot the app from its `objectstack.config.ts`, or from a host config that loads the artifact and lists the plugins in its own `plugins`, or package them with `os plugin build` and `os plugin install`). The structured fields are `{ appId, plugins }`. Each listed plugin is judged by name against the kernel's own plugin table, so a host that assembles the app's plugins itself hears nothing about the ones it runs. A package-specifier string entry is not judged: the name its plugin registers under is not in the specifier.
13+
14+
Only the artifact door judges: the `AppPlugin` that `createStandaloneStack` builds over the artifact it loaded (the one composed with `securityMetadataRegistrar: 'artifact-door'`). A config boot's `AppPlugin` does not, because its host materializes the stack's `plugins` itself. No option, export or artifact field is added, and nothing else changes: no plugin is mounted, refused or reordered, and the boot does not fail.

‎.changeset/dev-seed-credential-production-refusal.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ Metadata-protocol: none
2424

2525
**Not detected:** a database seeded before this release with a custom seed password carries no mark and no well-known password. Set a new password with `os user set-password` on each account it seeded before serving it outside development mode.
2626

27-
**Not ended at boot:** this release refuses the development seed password and every new session for a seeded account still on it. Sessions and API keys a seeded account was issued before the server left development mode are ended by `os user set-password`; run it on each seeded account before serving the database. Ending them at boot is follow-up #35184.
27+
**Ended by `os user set-password`, and at boot:** this release refuses the development seed password and every new session for a seeded account still on it. Sessions and API keys a seeded account was issued before the server left development mode are ended by `os user set-password`; run it on each seeded account before serving the database. In the same release, a boot outside development mode also retires them: see the note "a boot outside development mode retires what the development seed issued" (#36699).

‎content/docs/deployment/self-hosting.mdx‎

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ rotate. Two variables would make "URL updated, hash not" a state you can reach.
150150
| `#sha256=` present, artifact host unreachable | Falls back to the cached copy **only** if it still hashes to the pin, with a loud warning that the instance is running on cached content. |
151151
| Artifact's `engines.protocol` excludes this runtime | **Refuses to boot** — the safety belt of the two-axis split. Repoint the reference, or run a matching image version. |
152152
| The artifact needs a destructive schema change | Safe migrations run at boot; a destructive one **refuses to boot** and names each change. Run `os migrate apply --allow-destructive` deliberately, then restart. Never skipped in silence. |
153+
| The app's stack lists code plugins (`plugins: [new XPlugin()]`) | Boots **without them**: an artifact carries the app's metadata and hook handlers, not its code plugins, so nothing those plugins register exists. The boot warns once, naming each listed plugin the kernel does not run. To run them, boot a host config that loads the artifact and lists the plugins in its own `plugins`, or package them as a plugin (`os plugin build`, then `os plugin install`). |
153154

154155
**Recommended production discipline** (convention, not enforced by the runtime):
155156
publish immutable, version-named objects; give only CI write access to the
@@ -646,14 +647,28 @@ serve a database `os dev` wrote, set each seeded account's password on the
646647
server with [`os user set-password`](/docs/deployment/cli#os-user-set-password)
647648
first; the refusal names that command.
648649

649-
What this release refuses is the seed password and every new session for a
650-
seeded account still on it. Sessions and API keys a seeded account was issued
651-
before the server left development mode are ended by `os user set-password`
652-
(with any sign-in account linked to it and any app authorized to it; the
653-
OAuth applications it registered are disabled and the SCIM credentials it
654-
minted are revoked), so
655-
run it on each seeded account before serving the database; ending them at boot
656-
is follow-up #35184.
650+
Nothing the development seed issued keeps acting once the deployment leaves
651+
development mode. At every boot outside development mode, before the server
652+
serves a request, it retires what each seeded account still on its seed
653+
password was issued: its sessions, including any it opened acting as another
654+
account, its API keys, the apps authorized to it and
655+
its device sign-ins, its outstanding password-reset links, any sign-in account
656+
linked to it, the OAuth applications it registered (disabled) and the SCIM
657+
credentials it minted (revoked). A retired session or key answers exactly as a
658+
revoked one does, and the log names each account and what was retired. When
659+
the host supplies a `secondaryStorage` that holds the sessions, the server ends
660+
them there too, which `os user set-password` cannot reach. An
661+
account whose password was set since the seed (by `os user set-password`, by
662+
an administrator, or by its own reset) holds a credential the seed did not
663+
issue and is untouched, as is every account the seed did not create. A boot in
664+
development mode retires nothing. There is no switch.
665+
666+
If the retirement cannot complete (the database refuses a read or a write),
667+
the server does not start, and the error names the accounts; fix the database
668+
access, or run `os user set-password` on each of them, and start it again.
669+
`os user set-password` itself ends the account's own sessions, keys and
670+
grants when it sets the password, and from then on the boot leaves that
671+
account alone.
657672

658673
### A seeded directory opens no bootstrap window
659674

‎docs/audits/2026-08-tenant-audit-write-call-sites.counts/plugins/plugin-auth.md‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,26 @@ a row or a number here — fix the code, or the census, and regenerate.
1414

1515
| Measure | Value |
1616
|---|---:|
17-
| Write call sites | 108 |
17+
| Write call sites | 110 |
1818
| Object name statically decidable | 60 |
19-
| Object name chosen at run time | 48 |
19+
| Object name chosen at run time | 50 |
2020
| Object name spelled inline | 47 |
2121
| Object name spelled through a `const` | 13 |
22-
| Object name is an `object: string` parameter | 3 |
23-
| Object name is some other run-time expression | 45 |
22+
| Object name is an `object: string` parameter | 4 |
23+
| Object name is some other run-time expression | 46 |
2424
| Against a tenancy-enabled object | 58 |
2525
| Against an object declaring tenancy off | 2 |
26-
| Threading a tenant context | 64 |
26+
| Threading a tenant context | 66 |
2727
| Provably carrying none (options read, no context key) | 15 |
2828
| …and decidably tenancy-enabled | 3 |
2929
| Options argument unreadable | 29 |
3030
| …and decidably tenancy-enabled | 16 |
31-
| Threading a decidably elevated (`isSystem`) context | 46 |
31+
| Threading a decidably elevated (`isSystem`) context | 48 |
3232
| Threading a decidably non-elevated context | 0 |
3333
| Threading a context of undecidable elevation | 47 |
34-
| Receiver carried a readable engine type | 80 |
34+
| Receiver carried a readable engine type | 81 |
3535
| Receiver erased, placed by the object NAME | 26 |
36-
| Receiver erased, placed by an `object: string` PARAMETER | 1 |
36+
| Receiver erased, placed by an `object: string` PARAMETER | 2 |
3737
| Receiver erased, placed by an `UNTYPED_RECEIVERS` row | 1 |
3838

3939
## Subtractions the census could NOT defend — enforced
@@ -74,6 +74,8 @@ a row or a number here — fix the code, or the census, and regenerate.
7474
| `packages/plugins/plugin-auth/src/demo-staff.ts` | `update` | `sys_user` | enabled | elevated | 1 |
7575
| `packages/plugins/plugin-auth/src/demo-staff.ts` | `insert` | `sys_user_permission_set` | enabled | elevated | 1 |
7676
| `packages/plugins/plugin-auth/src/demo-staff.ts` | `insert` | `sys_user_position` | enabled | elevated | 1 |
77+
| `packages/plugins/plugin-auth/src/dev-seed-credential-retirement.ts` | `delete` | `object` | undecidable | elevated | 1 |
78+
| `packages/plugins/plugin-auth/src/dev-seed-credential-retirement.ts` | `update` | `SystemObjectName.SESSION` | undecidable | elevated | 1 |
7779
| `packages/plugins/plugin-auth/src/dev-seed-credential.ts` | `update` | `SystemObjectName.USER` | undecidable | elevated | 1 |
7880
| `packages/plugins/plugin-auth/src/ensure-default-organization.ts` | `insert` | `object` | undecidable | elevated | 1 |
7981
| `packages/plugins/plugin-auth/src/ensure-default-organization.ts` | `update` | `sys_member` | enabled | elevated | 1 |
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* #36647, end to end: a real `os build` of a stack that lists a code plugin,
5+
* then a real boot of the artifact it wrote. The boot runs none of the app's
6+
* code plugins, and says so, naming each one, once.
7+
*
8+
* The build half is the measured premise. `os build` writes the stack's
9+
* `plugins` into `objectstack.json` as plain JSON (the instance's own data, no
10+
* `init`), and nothing on the artifact path turns that back into a plugin:
11+
* `plugins` are artifact ENVELOPE keys, runtime assembly instructions a host
12+
* hands to `kernel.use()`, never metadata the artifact carries. The boot half
13+
* is the fix: the artifact door's `AppPlugin` names every listed plugin the
14+
* kernel's own table does not hold (`@objectstack/runtime`,
15+
* `artifact-declared-plugins.ts`), so the drop is no longer silent.
16+
*
17+
* The boot reaches `@objectstack/runtime` through its `exports` map, so it
18+
* measures `dist/`: rebuild the runtime before reading a result here.
19+
*/
20+
21+
import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest';
22+
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
23+
import { tmpdir } from 'node:os';
24+
import { join, resolve } from 'node:path';
25+
import { fileURLToPath } from 'node:url';
26+
import { createStandaloneStack, Runtime } from '@objectstack/runtime';
27+
import Compile from '../src/commands/compile';
28+
import { defineStackSourceFromLiteral, linkSpec } from './helpers/define-stack-fixture.js';
29+
30+
// Pay the first transform of these dist-resolved workspace deps at MODULE LOAD:
31+
// the build and the boot below import them lazily, inside a clocked hook
32+
// (`scripts/check-test-source-alias.mjs`, the clocked-window rule).
33+
import '@objectstack/objectql/core';
34+
import '@objectstack/plugin-security';
35+
36+
const CLI_ROOT = resolve(fileURLToPath(import.meta.url), '..', '..');
37+
const APP_ID = 'com.test.issue-36647-build';
38+
const VECTOR = 'com.test.issue-36647-build.vector';
39+
const INDEXER = 'com.test.issue-36647-build.indexer';
40+
const BOOT_TIMEOUT = 120_000;
41+
42+
/**
43+
* The stack as an author writes it: two code plugins, live instances with an
44+
* `init`, the shape `plugins: [new XPlugin()]` evaluates to.
45+
*/
46+
const CONFIG_LITERAL = `{
47+
manifest: { id: '${APP_ID}', name: 'Plugin Build Probe', version: '1.0.0', type: 'app', namespace: 'probeb' },
48+
objects: [{ name: 'probeb_clause', label: 'Clause', sharingModel: 'private', fields: { title: { type: 'text', label: 'Title' } } }],
49+
plugins: [
50+
{ name: '${VECTOR}', version: '1.0.0', dependencies: [], options: { dimensions: 1536 }, init: async () => {} },
51+
{ name: '${INDEXER}', version: '1.0.0', dependencies: ['${VECTOR}'], init: async () => {} },
52+
],
53+
}`;
54+
55+
let root = '';
56+
let artifactPath = '';
57+
58+
/** Runs `os build` in-process; answers the exit code (0 when the command returned) and what it printed. */
59+
async function build(configPath: string, output: string): Promise<{ code: number; stdout: string }> {
60+
const chunks: string[] = [];
61+
const spy = vi.spyOn(process.stdout, 'write').mockImplementation(((chunk: unknown, ...rest: unknown[]) => {
62+
chunks.push(String(chunk));
63+
const done = rest.find((a) => typeof a === 'function') as ((e?: Error | null) => void) | undefined;
64+
done?.(null);
65+
return true;
66+
}) as never);
67+
const exitCodeBefore = process.exitCode;
68+
try {
69+
await Compile.run([configPath, '--output', output], { root: CLI_ROOT });
70+
return { code: 0, stdout: chunks.join('') };
71+
} catch (error) {
72+
const exit = (error as { oclif?: { exit?: unknown } }).oclif?.exit;
73+
if (typeof exit !== 'number') throw error;
74+
return { code: exit, stdout: chunks.join('') };
75+
} finally {
76+
spy.mockRestore();
77+
process.exitCode = exitCodeBefore;
78+
}
79+
}
80+
81+
beforeAll(async () => {
82+
root = mkdtempSync(join(tmpdir(), 'os-36647-build-'));
83+
const dir = join(root, 'app');
84+
mkdirSync(dir, { recursive: true });
85+
const configPath = join(dir, 'objectstack.config.ts');
86+
writeFileSync(configPath, defineStackSourceFromLiteral(CONFIG_LITERAL));
87+
linkSpec(dir);
88+
mkdirSync(join(root, 'host'), { recursive: true });
89+
artifactPath = join(dir, 'dist', 'objectstack.json');
90+
const built = await build(configPath, artifactPath);
91+
expect(built.code, built.stdout).toBe(0);
92+
}, 60_000);
93+
94+
afterAll(() => {
95+
if (root) rmSync(root, { recursive: true, force: true });
96+
});
97+
98+
describe('#36647 — os build, then an artifact boot of what it wrote', () => {
99+
it('PREMISE: the artifact holds the plugins as inert descriptors, nothing that can start', () => {
100+
const artifact = JSON.parse(readFileSync(artifactPath, 'utf8')) as { plugins?: Array<Record<string, unknown>> };
101+
expect(artifact.plugins?.map((p) => p.name)).toEqual([VECTOR, INDEXER]);
102+
for (const p of artifact.plugins ?? []) expect(p).not.toHaveProperty('init');
103+
});
104+
105+
it('the boot runs neither plugin, and warns once naming both', async () => {
106+
let kernel: any;
107+
try {
108+
const standalone = await createStandaloneStack({
109+
artifactPath,
110+
// A directory of its own: the boot's root, apart from the source tree the build read.
111+
projectRoot: join(root, 'host'),
112+
databaseUrl: ':memory:',
113+
skipSeedData: true,
114+
runPlatformMigrations: false,
115+
});
116+
kernel = new Runtime({ cluster: false }).getKernel();
117+
const warn = vi.spyOn(kernel.logger, 'warn');
118+
for (const p of standalone.plugins) await kernel.use(p as never);
119+
await kernel.bootstrap();
120+
// CONTROL: the drop is real.
121+
expect(kernel.hasPlugin(VECTOR)).toBe(false);
122+
expect(kernel.hasPlugin(INDEXER)).toBe(false);
123+
const named = warn.mock.calls
124+
.map(([message, meta]) => ({ message: String(message), meta: meta as any }))
125+
.filter(({ meta }) => meta?.appId === APP_ID && Array.isArray(meta?.plugins));
126+
expect(named).toHaveLength(1);
127+
expect(named[0]!.meta).toEqual({ appId: APP_ID, plugins: [VECTOR, INDEXER] });
128+
expect(named[0]!.message).toContain(VECTOR);
129+
expect(named[0]!.message).toContain(INDEXER);
130+
} finally {
131+
try { await kernel?.shutdown(); } catch { /* noop */ }
132+
}
133+
}, BOOT_TIMEOUT);
134+
});

0 commit comments

Comments
 (0)