@ultimat3/cli 31.18.1 → 31.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +29 -29
- package/src/cmd-verify-spec.ts +3 -1
- package/src/cmd-verify.ts +3 -1
- package/src/templates/scaffold-auth.ts +35 -11
- package/src/templates/sign-in-authenticator.ts +33 -10
- package/wiki/CI-Parallel-Gate.md +3 -3
- package/wiki/Testing.md +1 -1
- package/wiki/Upgrading.md +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/cli",
|
|
3
|
-
"version": "31.
|
|
3
|
+
"version": "31.20.0",
|
|
4
4
|
"description": "The `x` binary: new, dev, build, verify, generate, db, mcp, doctor, deploy",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ultimate",
|
|
@@ -53,34 +53,34 @@
|
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@babel/core": "^8.0.9",
|
|
56
|
-
"@ultimat3/action": "31.
|
|
57
|
-
"@ultimat3/admin": "31.
|
|
58
|
-
"@ultimat3/ai": "31.
|
|
59
|
-
"@ultimat3/auth": "31.
|
|
60
|
-
"@ultimat3/cache": "31.
|
|
61
|
-
"@ultimat3/core": "31.
|
|
62
|
-
"@ultimat3/db": "31.
|
|
63
|
-
"@ultimat3/entity": "31.
|
|
64
|
-
"@ultimat3/flags": "31.
|
|
65
|
-
"@ultimat3/http": "31.
|
|
66
|
-
"@ultimat3/i18n": "31.
|
|
67
|
-
"@ultimat3/jobs": "31.
|
|
68
|
-
"@ultimat3/mail": "31.
|
|
69
|
-
"@ultimat3/manifest": "31.
|
|
70
|
-
"@ultimat3/mcp": "31.
|
|
71
|
-
"@ultimat3/money": "31.
|
|
72
|
-
"@ultimat3/notify": "31.
|
|
73
|
-
"@ultimat3/policy": "31.
|
|
74
|
-
"@ultimat3/pwa": "31.
|
|
75
|
-
"@ultimat3/query": "31.
|
|
76
|
-
"@ultimat3/realtime": "31.
|
|
77
|
-
"@ultimat3/render": "31.
|
|
78
|
-
"@ultimat3/schema": "31.
|
|
79
|
-
"@ultimat3/scraping": "31.
|
|
80
|
-
"@ultimat3/seo": "31.
|
|
81
|
-
"@ultimat3/storage": "31.
|
|
82
|
-
"@ultimat3/testing": "31.
|
|
83
|
-
"@ultimat3/time": "31.
|
|
56
|
+
"@ultimat3/action": "31.20.0",
|
|
57
|
+
"@ultimat3/admin": "31.20.0",
|
|
58
|
+
"@ultimat3/ai": "31.20.0",
|
|
59
|
+
"@ultimat3/auth": "31.20.0",
|
|
60
|
+
"@ultimat3/cache": "31.20.0",
|
|
61
|
+
"@ultimat3/core": "31.20.0",
|
|
62
|
+
"@ultimat3/db": "31.20.0",
|
|
63
|
+
"@ultimat3/entity": "31.20.0",
|
|
64
|
+
"@ultimat3/flags": "31.20.0",
|
|
65
|
+
"@ultimat3/http": "31.20.0",
|
|
66
|
+
"@ultimat3/i18n": "31.20.0",
|
|
67
|
+
"@ultimat3/jobs": "31.20.0",
|
|
68
|
+
"@ultimat3/mail": "31.20.0",
|
|
69
|
+
"@ultimat3/manifest": "31.20.0",
|
|
70
|
+
"@ultimat3/mcp": "31.20.0",
|
|
71
|
+
"@ultimat3/money": "31.20.0",
|
|
72
|
+
"@ultimat3/notify": "31.20.0",
|
|
73
|
+
"@ultimat3/policy": "31.20.0",
|
|
74
|
+
"@ultimat3/pwa": "31.20.0",
|
|
75
|
+
"@ultimat3/query": "31.20.0",
|
|
76
|
+
"@ultimat3/realtime": "31.20.0",
|
|
77
|
+
"@ultimat3/render": "31.20.0",
|
|
78
|
+
"@ultimat3/schema": "31.20.0",
|
|
79
|
+
"@ultimat3/scraping": "31.20.0",
|
|
80
|
+
"@ultimat3/seo": "31.20.0",
|
|
81
|
+
"@ultimat3/storage": "31.20.0",
|
|
82
|
+
"@ultimat3/testing": "31.20.0",
|
|
83
|
+
"@ultimat3/time": "31.20.0",
|
|
84
84
|
"babel-preset-solid": "^1.9.16"
|
|
85
85
|
}
|
|
86
86
|
}
|
package/src/cmd-verify-spec.ts
CHANGED
|
@@ -16,7 +16,9 @@ export const verifySpec: CommandSpec = {
|
|
|
16
16
|
summary: 'the gate: typecheck, lint, boundaries, all tests, drift, contract, budgets',
|
|
17
17
|
usage:
|
|
18
18
|
'x verify [--only <step>[,<step>…] [--shard i/n [--timings file]] | --changed [--base <ref>] [--dirty]] [--workers N] [--isolate] [--json] · x verify merge <part.json…> [--json] · x verify plan [--parts n] [--json]',
|
|
19
|
-
requiresApp
|
|
19
|
+
// No `requiresApp`: the dispatcher reads it per command, and `plan` reads nothing from an app —
|
|
20
|
+
// ci.yml runs it at the repo root. `run` and `merge` call `requireAppRoot` first, before any
|
|
21
|
+
// flag is read (`cmd-verify.ts`; `cmd-verify-plan.test.ts` holds both sides).
|
|
20
22
|
subcommands: VERIFY_SUBCOMMANDS,
|
|
21
23
|
defaultSubcommand: 'run',
|
|
22
24
|
// `--workers` and `--isolate` change how the test steps run, never which steps run. `--only`
|
package/src/cmd-verify.ts
CHANGED
|
@@ -44,9 +44,11 @@ export { runVerify } from './verify-run';
|
|
|
44
44
|
export const verifyCommand: CliCommand = {
|
|
45
45
|
spec: verifySpec,
|
|
46
46
|
async run(ctx: CommandContext): Promise<CommandResult> {
|
|
47
|
+
// The plan is the step list cut into parts and reads nothing from an app, so it answers before
|
|
48
|
+
// the root is required: ci.yml's `tested` job runs it at the repo root, where X_NOT_IN_APP is.
|
|
49
|
+
if (ctx.args.subcommand === 'plan') return verifyPlanCommand(ctx.args);
|
|
47
50
|
const root = requireAppRoot('verify', ctx.cwd).dir;
|
|
48
51
|
if (ctx.args.subcommand === 'merge') return mergeCommand(root, ctx.args.positionals, ctx.cwd);
|
|
49
|
-
if (ctx.args.subcommand === 'plan') return verifyPlanCommand(ctx.args);
|
|
50
52
|
// Every reader before the run: an unrunnable flag must be refused in milliseconds, not after
|
|
51
53
|
// `tsc -b` has spent fourteen seconds on a run the caller cannot use.
|
|
52
54
|
const workers = readWorkers(ctx.args);
|
|
@@ -138,7 +138,7 @@ const authenticatorModule =
|
|
|
138
138
|
// otherwise read as development too. \`x dev\` declares \`ULTIMATE_ENV=development\` for exactly this
|
|
139
139
|
// reason, and \`bun test\` sets \`NODE_ENV=test\`, where a fixture mints its own actor.
|
|
140
140
|
import { type Auth, authenticate } from '@ultimat3/auth';
|
|
141
|
-
import { type Actor, logger, tryResolveEnvironment } from '@ultimat3/core';
|
|
141
|
+
import { type Actor, isSessionRefusal, logger, tryResolveEnvironment } from '@ultimat3/core';
|
|
142
142
|
import { configureAuthenticator } from '@ultimat3/http';
|
|
143
143
|
import { appAuth } from './auth';
|
|
144
144
|
import {
|
|
@@ -161,18 +161,27 @@ export interface SessionAuthenticatorOptions {
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
/**
|
|
164
|
-
* A session cookie is that session's user, or
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
164
|
+
* A session cookie is that session's user, or nobody — never a fallback to anyone else. A session
|
|
165
|
+
* past its expiry, or one unknown, revoked or forged, or whose user is disabled, is a refusal
|
|
166
|
+
* \`authenticate()\` THROWS (\`isSessionRefusal\`: \`X_SESSION_EXPIRED\`, \`X_UNAUTHENTICATED\`), and it
|
|
167
|
+
* is answered \`null\`: a stale cookie is an anonymous visitor, so sign-in still opens and a live
|
|
168
|
+
* socket it opened is closed. Anything else it throws — a session store that is down — is not an
|
|
169
|
+
* answer about this visitor and propagates. No cookie is the development viewer or nobody.
|
|
168
170
|
*/
|
|
169
171
|
export const sessionAuthenticator =
|
|
170
172
|
(options: SessionAuthenticatorOptions) =>
|
|
171
173
|
async (request: SessionRequest): Promise<Actor | null> => {
|
|
172
174
|
const auth = options.auth();
|
|
173
175
|
const token = request.cookie(auth.sessions.policy.cookieName);
|
|
174
|
-
if (token
|
|
175
|
-
|
|
176
|
+
if (token === null || token.length === 0) {
|
|
177
|
+
return options.development ? devAuthenticate(request) : null;
|
|
178
|
+
}
|
|
179
|
+
try {
|
|
180
|
+
return await authenticate(auth, token);
|
|
181
|
+
} catch (error) {
|
|
182
|
+
if (isSessionRefusal(error)) return null;
|
|
183
|
+
throw error;
|
|
184
|
+
}
|
|
176
185
|
};
|
|
177
186
|
|
|
178
187
|
/**
|
|
@@ -283,7 +292,7 @@ unitTest('an undeclared role is answered as ANONYMOUS, and the log names what it
|
|
|
283
292
|
const authenticatorTest =
|
|
284
293
|
(): string => `// The real path and its one fallback: a session cookie is its user in every environment, a bad
|
|
285
294
|
// one is refused rather than replaced, and only development answers a request with no session.
|
|
286
|
-
import { defineAuth, login, memoryAuthAdapter, register } from '@ultimat3/auth';
|
|
295
|
+
import { defineAuth, login, logout, memoryAuthAdapter, register } from '@ultimat3/auth';
|
|
287
296
|
import { configuredAuthenticator, resetAuthenticator } from '@ultimat3/http';
|
|
288
297
|
import { expect, unitTest } from '@ultimat3/testing';
|
|
289
298
|
import { DEMO_ORG_ID } from '../../shared/demo-org';
|
|
@@ -326,12 +335,27 @@ unitTest('a session cookie is the user it was issued to, in every environment',
|
|
|
326
335
|
}
|
|
327
336
|
});
|
|
328
337
|
|
|
329
|
-
unitTest('a cookie naming no live session is
|
|
338
|
+
unitTest('a cookie naming no live session is nobody, never answered as the viewer', async () => {
|
|
330
339
|
const auth = memoryAuth();
|
|
331
340
|
const request = requestWith({ [auth().sessions.policy.cookieName]: 'forged.token' });
|
|
332
|
-
|
|
333
|
-
|
|
341
|
+
// \`null\`, not a throw: thrown, a stale cookie was a 401 on the sign-in page itself.
|
|
342
|
+
expect(await sessionAuthenticator({ auth, development: true })(request)).toBeNull();
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
unitTest('a signed-out cookie is nobody, so its socket is closed on re-check', async () => {
|
|
346
|
+
const auth = memoryAuth();
|
|
347
|
+
await register(auth(), {
|
|
348
|
+
email: 'ada@example.com',
|
|
349
|
+
password: PASSWORD,
|
|
350
|
+
orgId: DEMO_ORG_ID,
|
|
351
|
+
roles: ['member'],
|
|
334
352
|
});
|
|
353
|
+
const { token } = await login(auth(), { email: 'ada@example.com', password: PASSWORD });
|
|
354
|
+
await logout(auth(), token);
|
|
355
|
+
const request = requestWith({ [auth().sessions.policy.cookieName]: token });
|
|
356
|
+
for (const development of [true, false]) {
|
|
357
|
+
expect(await sessionAuthenticator({ auth, development })(request)).toBeNull();
|
|
358
|
+
}
|
|
335
359
|
});
|
|
336
360
|
|
|
337
361
|
unitTest('no session: the development viewer under x dev, anonymous anywhere else', async () => {
|
|
@@ -12,7 +12,7 @@ const authenticatorSource =
|
|
|
12
12
|
// live subscribers, MCP tools) reads the actor this returns. With no session the request is
|
|
13
13
|
// anonymous, everywhere: a developer signs in through \`/auth/sign-in\` like everyone else.
|
|
14
14
|
import { type Auth, authenticate } from '@ultimat3/auth';
|
|
15
|
-
import type
|
|
15
|
+
import { type Actor, isSessionRefusal } from '@ultimat3/core';
|
|
16
16
|
import { configureAuthenticator } from '@ultimat3/http';
|
|
17
17
|
import { appAuth } from './auth';
|
|
18
18
|
|
|
@@ -22,15 +22,24 @@ export interface SessionRequest {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
* A session cookie is that session's user, or
|
|
26
|
-
*
|
|
25
|
+
* A session cookie is that session's user, or nobody — never a fallback to anyone else. A session
|
|
26
|
+
* past its expiry, or one unknown, revoked or forged, is a refusal \`authenticate()\` THROWS
|
|
27
|
+
* (\`isSessionRefusal\`: \`X_SESSION_EXPIRED\`, \`X_UNAUTHENTICATED\`), answered \`null\`: a stale
|
|
28
|
+
* cookie is an anonymous visitor, so sign-in still opens and a live socket it opened is closed.
|
|
29
|
+
* Anything else it throws — a session store that is down — propagates.
|
|
27
30
|
*/
|
|
28
31
|
export const sessionAuthenticator =
|
|
29
32
|
(auth: () => Auth) =>
|
|
30
33
|
async (request: SessionRequest): Promise<Actor | null> => {
|
|
31
34
|
const resolved = auth();
|
|
32
35
|
const token = request.cookie(resolved.sessions.policy.cookieName);
|
|
33
|
-
|
|
36
|
+
if (token === null || token.length === 0) return null;
|
|
37
|
+
try {
|
|
38
|
+
return await authenticate(resolved, token);
|
|
39
|
+
} catch (error) {
|
|
40
|
+
if (isSessionRefusal(error)) return null;
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
34
43
|
};
|
|
35
44
|
|
|
36
45
|
/** Installs the session authenticator. */
|
|
@@ -44,8 +53,9 @@ installAuthenticator();
|
|
|
44
53
|
`;
|
|
45
54
|
|
|
46
55
|
const authenticatorTest =
|
|
47
|
-
(): string => `// A session cookie is the user it was issued to; a bad
|
|
48
|
-
|
|
56
|
+
(): string => `// A session cookie is the user it was issued to; a bad, expired or signed-out one is nobody, and
|
|
57
|
+
// so is none.
|
|
58
|
+
import { defineAuth, login, logout, memoryAuthAdapter, register } from '@ultimat3/auth';
|
|
49
59
|
import { configuredAuthenticator, resetAuthenticator } from '@ultimat3/http';
|
|
50
60
|
import { expect, unitTest } from '@ultimat3/testing';
|
|
51
61
|
import { DEMO_ORG_ID } from '../../shared/demo-org';
|
|
@@ -78,15 +88,28 @@ unitTest('a session cookie is the user it was issued to', async () => {
|
|
|
78
88
|
expect(actor?.roles).toEqual(['member']);
|
|
79
89
|
});
|
|
80
90
|
|
|
81
|
-
unitTest('a forged cookie is
|
|
91
|
+
unitTest('a forged cookie is nobody, and no cookie is anonymous', async () => {
|
|
82
92
|
const auth = memoryAuth();
|
|
83
93
|
const forged = requestWith({ [auth().sessions.policy.cookieName]: 'forged.token' });
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
});
|
|
94
|
+
// \`null\`, not a throw: thrown, a stale cookie was a 401 on the sign-in page itself.
|
|
95
|
+
expect(await sessionAuthenticator(auth)(forged)).toBeNull();
|
|
87
96
|
expect(await sessionAuthenticator(auth)(requestWith({}))).toBeNull();
|
|
88
97
|
});
|
|
89
98
|
|
|
99
|
+
unitTest('a signed-out cookie is nobody, so its socket is closed on re-check', async () => {
|
|
100
|
+
const auth = memoryAuth();
|
|
101
|
+
await register(auth(), {
|
|
102
|
+
email: 'ada@example.com',
|
|
103
|
+
password: PASSWORD,
|
|
104
|
+
orgId: DEMO_ORG_ID,
|
|
105
|
+
roles: ['member'],
|
|
106
|
+
});
|
|
107
|
+
const { token } = await login(auth(), { email: 'ada@example.com', password: PASSWORD });
|
|
108
|
+
await logout(auth(), token);
|
|
109
|
+
const cookie = requestWith({ [auth().sessions.policy.cookieName]: token });
|
|
110
|
+
expect(await sessionAuthenticator(auth)(cookie)).toBeNull();
|
|
111
|
+
});
|
|
112
|
+
|
|
90
113
|
unitTest('it installs', () => {
|
|
91
114
|
try {
|
|
92
115
|
installAuthenticator(memoryAuth());
|
package/wiki/CI-Parallel-Gate.md
CHANGED
|
@@ -111,9 +111,9 @@ green; `verify` downloads every part and runs `bun run verify merge`. An app sca
|
|
|
111
111
|
keeps its one-job workflow, which still works; to adopt, copy a fresh scaffold's
|
|
112
112
|
`.github/workflows/ci.yml`.
|
|
113
113
|
|
|
114
|
-
This repository's own `ci.yml`
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
This repository's own `ci.yml` reads the same plan: its `tested` job runs `x verify plan --parts 7`
|
|
115
|
+
and `jq` gives each row the test services its `needs` level names; `gate` is `fromJSON` of that.
|
|
116
|
+
`scripts/ci-workflow-shape.test.ts` runs the step and holds every row to `verifyPlan(7)`.
|
|
117
117
|
|
|
118
118
|
## A GitHub Actions workflow, by hand
|
|
119
119
|
|
package/wiki/Testing.md
CHANGED
|
@@ -1484,7 +1484,7 @@ Full list: [Error codes](Error-Codes).
|
|
|
1484
1484
|
- Never assert on wall-clock time. Advance the frozen clock.
|
|
1485
1485
|
- Never let a test reach the network unmocked — it fails by design.
|
|
1486
1486
|
- A flaky test is deleted or fixed the day it flakes. There is no `retry: 3`.
|
|
1487
|
-
- Hunting an order flake: `x test unit --filter <file> -- --rerun-each=30 --randomize` — the `--` hands the rest to `bun test`.
|
|
1487
|
+
- Hunting an order flake: `x test unit --filter <file> -- --rerun-each=30 --randomize` — the `--` hands the rest to `bun test`. A rerun forgets the `entity()` and `job()` calls the file's module body made on its last load, so they declare again. `As of 2026-11`, an `action()`, a mail template or an OAuth provider declared at module scope still fails its second load with `X_*_DUPLICATE`. Declare those inside the test, or put the file in its own run.
|
|
1488
1488
|
- Every framework package ships at least 2 tests that would catch a real regression. No `expect(true).toBe(true)`.
|
|
1489
1489
|
- Tests live next to their source as `<file>.test.ts`.
|
|
1490
1490
|
- A denial test per policy branch, not one happy-path test per action.
|
package/wiki/Upgrading.md
CHANGED
|
@@ -280,6 +280,8 @@ A setter still on a package's `.` barrel is `X_ADAPTER_PORT_INCOMPLETE` on the `
|
|
|
280
280
|
| a hand-written `AdminRepo` receives `caseSensitive: true` on each `contains` filter the app declared (`rows`, a scope's `where`), and a bare `contains` from what an operator typed (**31.18.0**). The admin's search also reads up to four resources at once instead of one after another | nothing for `adminRepoFor`. A custom repo that compiles `contains` itself: keep the exact, case-sensitive match where `filter.caseSensitive === true`, and fold case otherwise to match the entity repo. A custom repo must already allow concurrent reads, which every pool does |
|
|
281
281
|
| the framework's Helm chart (`docker/helm`) and `x new`'s chart request less memory for web and worker and more for the scheduler (**31.18.0**): web 256Mi → 128Mi, worker 256Mi → 160Mi, scheduler 128Mi → 160Mi. These are measured idle plus headroom. Limits are unchanged | nothing. To keep the old requests on the framework's chart: `--set roles.web.resources.requests.memory=256Mi` (and `roles.worker…`/`roles.scheduler…`). An app chart `x new` wrote keeps its own values until you edit them |
|
|
282
282
|
| the chart has six new alert rules (**31.18.0**): `UltimateErrorBudgetFastBurn` / `UltimateErrorBudgetSlowBurn` against `alerts.objective` (default 99.9), plus `UltimateJobFailures`, `UltimatePoolSaturated`, `UltimateEventLoopLag` and `UltimateMemoryNearLimit`. It also has an opt-in Grafana dashboard (`dashboard.enabled: false`). Every process on a memory-limited container now emits `process_memory_limit_bytes` | nothing; an older app chart keeps its rules. To adopt the new rules: `x g chart-alerts --force`. To add the dashboard: `x g chart-dashboard`, then set `dashboard.enabled: true` where a Grafana sidecar runs. `x doctor` lists the dashboard files while the chart lacks them. To disable one rule: `alerts: { rules: { UltimateEventLoopLag: { enabled: false } } }` |
|
|
283
|
+
| the reference app's and the demo's `docker/Dockerfile` (`examples/dummy`, `dummy/social-media-clone`) now match `x new`'s template (**31.19.0**): a `manifests` stage copies every workspace `package.json` and nothing else, the `deps` stage installs from it and `bun.lock`, the runtime stage is built `FROM deps`, and it runs as `USER 1000:1000` where it said `USER bun` | nothing for an app `x new` wrote: its Dockerfile already had this shape. An app that copied either tracked file: copy a fresh scaffold's (`x new <scratch> && cp <scratch>/docker/Dockerfile docker/`). `1000` is the base image's `bun` user, so a volume owned by `bun` still opens |
|
|
284
|
+
| the framework repo's `manifest` step prints `warning: X_PUBLIC_API_BREAK_UNDECLARED …` for an exported symbol whose declaration changed or that is gone with no `BREAKING —` entry naming it, and `X_PUBLIC_API_UNSCANNED` when the lock cannot be read (**31.19.0**). Report-only in 31.x: the step stays green, and only `bun run scripts/public-api.ts --strict` is red | nothing for an app. In this repo: revert the change, or land it on `next` with a `- **BREAKING —** (#N) <name> …` line under [Unreleased]; an addition is recorded with `bun run scripts/public-api.ts --write --json` |
|
|
283
285
|
|
|
284
286
|
## 29.x → 30.0.0, entry by entry
|
|
285
287
|
|