@ultimat3/cli 31.48.0 → 31.49.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/CLAUDE.md +30 -23
- package/README.md +96 -4
- package/package.json +29 -29
- package/src/api-registration.ts +28 -14
- package/src/app-load.ts +6 -1
- package/src/app-root.ts +7 -1
- package/src/clean-services.ts +142 -0
- package/src/cmd-auth.ts +3 -0
- package/src/cmd-clean-spec.ts +10 -3
- package/src/cmd-clean.ts +23 -9
- package/src/cmd-db-backfill.ts +6 -0
- package/src/cmd-db-branch.ts +10 -4
- package/src/cmd-db-recount.ts +5 -12
- package/src/cmd-db-rollback.ts +77 -0
- package/src/cmd-db-spec.ts +18 -2
- package/src/cmd-db-status.ts +5 -10
- package/src/cmd-db.ts +105 -33
- package/src/cmd-deploy-verify.ts +14 -6
- package/src/cmd-docs-topic.ts +94 -0
- package/src/cmd-docs.ts +15 -1
- package/src/cmd-doctor.ts +109 -41
- package/src/cmd-drill.ts +80 -18
- package/src/cmd-env.ts +30 -8
- package/src/cmd-errors-app.ts +63 -0
- package/src/cmd-errors.ts +50 -14
- package/src/cmd-generate.ts +17 -4
- package/src/cmd-heavy-spec.ts +9 -1
- package/src/cmd-heavy.ts +111 -27
- package/src/cmd-jobs.ts +27 -1
- package/src/cmd-merge-driver-spec.ts +12 -0
- package/src/cmd-merge-driver.ts +95 -0
- package/src/cmd-new.ts +23 -3
- package/src/cmd-policy-spec.ts +9 -1
- package/src/cmd-policy.ts +72 -17
- package/src/cmd-stop.ts +18 -4
- package/src/cmd-tasks-run.ts +87 -0
- package/src/cmd-tasks-spec.ts +10 -3
- package/src/cmd-tasks.ts +8 -5
- package/src/cmd-test.ts +2 -1
- package/src/cmd-upgrade-spec.ts +8 -1
- package/src/cmd-upgrade.ts +15 -1
- package/src/cmd-verify.ts +9 -41
- package/src/codemods/agents-doc-row.ts +73 -0
- package/src/codemods/define-error-leaf.ts +37 -12
- package/src/codemods/docs-many-agents.ts +11 -15
- package/src/codemods/docs-worker-commands.ts +26 -0
- package/src/codemods/index.ts +4 -0
- package/src/codemods/merge-drivers.ts +66 -0
- package/src/command.ts +3 -0
- package/src/db-applied-edits.ts +117 -0
- package/src/db-dev-wire.ts +18 -0
- package/src/db-diagnostics.ts +5 -10
- package/src/db-generate.ts +82 -7
- package/src/db-migrate-pass.ts +51 -0
- package/src/db-migrate-through-dev.ts +209 -0
- package/src/db-rollback-consent.ts +128 -0
- package/src/db-rollback-pass.ts +76 -0
- package/src/db-seed-generate.ts +5 -1
- package/src/db-seed.ts +7 -1
- package/src/deploy-verify-findings.ts +3 -0
- package/src/deploy-verify-grade.ts +3 -0
- package/src/deploy-verify-processes.ts +32 -0
- package/src/dev-boot.ts +3 -0
- package/src/dev-db-migrate.ts +155 -0
- package/src/dev-db-rollback.ts +33 -0
- package/src/dev-db-settled.ts +22 -0
- package/src/dev-lock-errors.ts +78 -0
- package/src/dev-lock-holder-dir.ts +64 -0
- package/src/dev-lock-live.ts +44 -0
- package/src/dev-lock.ts +59 -84
- package/src/dev-policy.ts +11 -8
- package/src/dev-rebuild-schema.ts +116 -13
- package/src/dev-rebuild.ts +13 -4
- package/src/dev-route-table.ts +7 -0
- package/src/dispatch.ts +21 -1
- package/src/doctor-api-listing.ts +114 -0
- package/src/doctor-guarded.ts +41 -0
- package/src/doctor-port.ts +90 -17
- package/src/doctor-probe.ts +36 -5
- package/src/doctor-processes-probe.ts +127 -0
- package/src/doctor-processes.ts +136 -0
- package/src/doctor-warnings.ts +17 -0
- package/src/error-codes-agents.ts +35 -0
- package/src/error-codes-processes.ts +30 -0
- package/src/error-codes-tooling.ts +2 -0
- package/src/error-codes.ts +12 -13
- package/src/errors-suite.ts +27 -0
- package/src/errors.ts +18 -22
- package/src/exercise-registration.ts +4 -3
- package/src/framework-env.ts +7 -3
- package/src/generate-files.ts +1 -0
- package/src/generate-grant-findings.ts +7 -5
- package/src/generate-grants.ts +9 -8
- package/src/generate-kinds.ts +30 -6
- package/src/generate-roles-file.ts +30 -0
- package/src/generate-slice-policy.ts +3 -3
- package/src/guards.ts +2 -2
- package/src/heavy-env.ts +2 -0
- package/src/heavy-errors.ts +18 -0
- package/src/heavy-holders.ts +78 -0
- package/src/heavy-ledger.ts +56 -14
- package/src/heavy-pressure.ts +104 -0
- package/src/heavy.ts +31 -13
- package/src/i18n-registration.ts +22 -2
- package/src/island-harness.ts +2 -2
- package/src/job-budget.ts +4 -2
- package/src/job-registration.ts +64 -8
- package/src/jobs-queue-known.ts +43 -0
- package/src/mcp-errors-agents.ts +20 -0
- package/src/mcp-errors-doctor.ts +27 -0
- package/src/mcp-errors-processes.ts +23 -0
- package/src/mcp-errors.ts +15 -29
- package/src/mcp-host.ts +2 -2
- package/src/merge-driver-catalog.ts +58 -0
- package/src/merge-driver-config.ts +43 -0
- package/src/merge-driver-lines.ts +140 -0
- package/src/merge-state.ts +105 -0
- package/src/messages-db.ts +22 -1
- package/src/messages-processes.ts +13 -0
- package/src/messages-upgrade.ts +6 -0
- package/src/messages.ts +54 -4
- package/src/output-findings.ts +48 -21
- package/src/parse.ts +37 -6
- package/src/policy-facts.ts +38 -21
- package/src/policy-row.ts +99 -0
- package/src/port-pair-free.ts +28 -0
- package/src/registry-lines.ts +110 -0
- package/src/registry.ts +2 -0
- package/src/retain-sweep.ts +1 -1
- package/src/role-replicator.ts +4 -1
- package/src/role-select.ts +86 -0
- package/src/role-start.ts +13 -55
- package/src/role-sync.ts +10 -5
- package/src/runtime-cache-frame.ts +46 -0
- package/src/runtime-cache-ttl.ts +23 -0
- package/src/runtime-cache.ts +33 -16
- package/src/runtime-database-ssl.ts +84 -0
- package/src/runtime-idempotency-scope.ts +16 -2
- package/src/runtime-jobs-share.ts +52 -0
- package/src/runtime-jobs.ts +43 -12
- package/src/runtime-queue.ts +18 -3
- package/src/runtime-services.ts +8 -1
- package/src/schema-drift.ts +19 -2
- package/src/schema-dump-drift.ts +4 -1
- package/src/serve-boot-probe.ts +30 -2
- package/src/serve-boot.ts +11 -1
- package/src/serve-env.ts +39 -3
- package/src/serve.ts +61 -10
- package/src/stop-run-start.ts +12 -0
- package/src/supervise-boot.ts +61 -0
- package/src/supervise-cgroup.ts +84 -0
- package/src/supervise-child.ts +206 -0
- package/src/supervise-count.ts +244 -0
- package/src/supervise-errors.ts +83 -0
- package/src/supervise-facts.ts +40 -0
- package/src/supervise-messages.ts +84 -0
- package/src/supervise-policy.ts +46 -0
- package/src/supervise-pool.ts +10 -0
- package/src/supervise-probe.ts +158 -0
- package/src/supervise-run.ts +54 -0
- package/src/supervise.ts +383 -0
- package/src/templates/generate-purge.ts +6 -6
- package/src/templates/guard-animated-layout-property.ts +2 -2
- package/src/templates/guard-bare-error.ts +1 -1
- package/src/templates/guard-error-declared.ts +2 -2
- package/src/templates/guard-focus-visible.ts +1 -1
- package/src/templates/guard-image-dimensions.ts +2 -2
- package/src/templates/guard-island-mount-clears.ts +1 -1
- package/src/templates/guard-native-confirm.ts +1 -1
- package/src/templates/guard-raw-breakpoint.ts +2 -2
- package/src/templates/guard-raw-colour.ts +2 -2
- package/src/templates/guard-raw-fetch.ts +1 -1
- package/src/templates/guard-raw-interval.ts +1 -1
- package/src/templates/guard-raw-length.ts +3 -3
- package/src/templates/guard-raw-motion.ts +1 -1
- package/src/templates/guard-raw-shadow.ts +1 -1
- package/src/templates/guard-raw-z-index.ts +1 -1
- package/src/templates/guard-released-forms.ts +54 -8
- package/src/templates/guard-repo-await-in-loop.ts +1 -1
- package/src/templates/guard-repo-raw-sql.ts +4 -4
- package/src/templates/guard-repo-unbounded.ts +1 -1
- package/src/templates/guard-runtime-pin.ts +1 -1
- package/src/templates/guard-semantic-interactive.ts +2 -2
- package/src/templates/guard-unbounded-fanout.ts +1 -1
- package/src/templates/guard-undeclared-custom-property.ts +3 -3
- package/src/templates/guard-undefined-style-class.ts +3 -3
- package/src/templates/guard-unzoned-date.ts +3 -3
- package/src/templates/query-slice.ts +82 -0
- package/src/templates/query.ts +76 -30
- package/src/templates/resource-page.ts +3 -2
- package/src/templates/scaffold-bin.ts +2 -0
- package/src/templates/scaffold-claude-commands.ts +6 -0
- package/src/templates/scaffold-claude.ts +4 -4
- package/src/templates/scaffold-container-compose.ts +47 -7
- package/src/templates/scaffold-docs.ts +7 -3
- package/src/templates/scaffold-gitattributes.ts +18 -1
- package/src/templates/scaffold-helm-templates.ts +9 -0
- package/src/templates/scaffold-repo.ts +4 -1
- package/src/templates/scaffold-test-services.ts +33 -11
- package/src/templates/shapes/offline.ts +0 -7
- package/src/templates/shapes/realtime.ts +2 -6
- package/src/templates/sign-in-action-tests.ts +6 -4
- package/src/templates/sign-in-challenge.ts +62 -0
- package/src/templates/sign-in-oidc-mfa.ts +31 -0
- package/src/templates/sign-in-oidc.ts +11 -3
- package/src/templates/sign-in-password.ts +18 -56
- package/src/test-shards.ts +114 -34
- package/src/test-verdict.ts +79 -0
- package/src/test-workers.ts +15 -0
- package/src/upgrade-gate-codemods.ts +5 -3
- package/src/upgrade-gate.ts +19 -1
- package/src/upgrade-merge-drivers.ts +25 -0
- package/src/upgrade-report.ts +18 -4
- package/src/upgrade-scope.ts +62 -0
- package/src/verify-checks.ts +2 -8
- package/src/verify-coverage-run.ts +4 -1
- package/src/verify-live.ts +38 -14
- package/src/verify-only.ts +67 -0
- package/src/verify-progress.ts +7 -3
- package/src/verify-run.ts +20 -2
- package/src/verify-services-stack.ts +165 -0
- package/src/verify-services.ts +84 -2
- package/src/verify-test-run.ts +6 -7
- package/src/verify-tests.ts +8 -2
- package/src/verify-typecheck.ts +25 -2
- package/wiki/Actions.md +2 -1
- package/wiki/Admin-Dashboard.md +2 -2
- package/wiki/Agents.md +5 -5
- package/wiki/Auth.md +15 -5
- package/wiki/Bare-VM.md +1 -1
- package/wiki/CI-Parallel-Gate.md +2 -1
- package/wiki/CLI-Reference.md +107 -40
- package/wiki/Caching-And-Invalidation.md +1 -1
- package/wiki/Client-Navigation.md +1 -1
- package/wiki/Configuration.md +10 -9
- package/wiki/Deployment.md +44 -4
- package/wiki/Entities-And-Migrations.md +5 -1
- package/wiki/FAQ.md +1 -1
- package/wiki/Getting-Started.md +2 -2
- package/wiki/Home.md +1 -1
- package/wiki/I18n.md +5 -3
- package/wiki/Installation.md +12 -11
- package/wiki/Jobs-And-Workflows.md +24 -4
- package/wiki/Known-Gaps.md +1 -1
- package/wiki/MCP-And-AI.md +8 -5
- package/wiki/Many-Agents.md +69 -2
- package/wiki/Migrations-And-Backfills.md +18 -0
- package/wiki/Notify.md +1 -1
- package/wiki/Observability.md +13 -0
- package/wiki/Queries-And-Live-Queries.md +2 -2
- package/wiki/Realtime.md +10 -1
- package/wiki/Routes-And-Render-Modes.md +1 -1
- package/wiki/Scheduled-Tasks.md +4 -1
- package/wiki/Testing.md +7 -4
- package/wiki/Timezones-And-Dates.md +5 -1
- package/wiki/Troubleshooting.md +1 -0
- package/wiki/Tutorial-01-First-App.md +3 -3
- package/wiki/Tutorial-02-First-Feature.md +1 -1
- package/wiki/Tutorial-03-Auth-And-Admin.md +7 -6
- package/wiki/Upgrading.md +37 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// Which test stack a compose file means on this machine, and whose it is. Compose names a project
|
|
2
|
+
// after the app, so two checkouts, or two unrelated apps with one name, land on the same containers;
|
|
3
|
+
// the labels compose writes on each one say which checkout started them.
|
|
4
|
+
|
|
5
|
+
// why: Bun ships no synchronous existence check or realpath primitive.
|
|
6
|
+
import { existsSync, realpathSync } from 'node:fs';
|
|
7
|
+
import type { Runner } from './exec';
|
|
8
|
+
import { TEST_COMPOSE_PATH } from './templates/scaffold-test-services';
|
|
9
|
+
|
|
10
|
+
const COMPOSE = ['docker', 'compose', '-f', TEST_COMPOSE_PATH] as const;
|
|
11
|
+
|
|
12
|
+
/** Every container of this file's project, stopped ones too, with its labels. */
|
|
13
|
+
export const SERVICES_LIST: readonly string[] = [...COMPOSE, 'ps', '--all', '--format', 'json'];
|
|
14
|
+
/** `--volumes`: the images declare anonymous volumes, and a stopped stack should leave none. */
|
|
15
|
+
export const SERVICES_STOP: readonly string[] = [...COMPOSE, 'down', '--volumes'];
|
|
16
|
+
/** Every compose project on the machine. */
|
|
17
|
+
export const STACKS_LIST: readonly string[] = [
|
|
18
|
+
'docker',
|
|
19
|
+
'compose',
|
|
20
|
+
'ls',
|
|
21
|
+
'--all',
|
|
22
|
+
'--format',
|
|
23
|
+
'json',
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
/** `1` says a stack another app started is shared on purpose. */
|
|
27
|
+
export const SHARED_ENV = 'ULTIMATE_TEST_SERVICES_SHARED';
|
|
28
|
+
|
|
29
|
+
export interface TestStack {
|
|
30
|
+
readonly project: string;
|
|
31
|
+
readonly services: readonly string[];
|
|
32
|
+
/** The checkouts whose compose file started these containers. */
|
|
33
|
+
readonly roots: readonly string[];
|
|
34
|
+
/** Whether any container is up: `ps --all` lists exited ones too, and those hold no server. */
|
|
35
|
+
readonly running: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type StackRead =
|
|
39
|
+
| { readonly answered: true; readonly stack?: TestStack }
|
|
40
|
+
| { readonly answered: false };
|
|
41
|
+
|
|
42
|
+
export type StackRelation =
|
|
43
|
+
| { readonly kind: 'own' }
|
|
44
|
+
| { readonly kind: 'shared'; readonly with: string; readonly why: 'same-app' | 'declared' }
|
|
45
|
+
| { readonly kind: 'collision'; readonly with: string; readonly running: boolean };
|
|
46
|
+
|
|
47
|
+
type Env = Readonly<Record<string, string | undefined>>;
|
|
48
|
+
|
|
49
|
+
const CONFIG_FILES = /(?:^|,)com\.docker\.compose\.project\.config_files=([^,]*)/;
|
|
50
|
+
const COMPOSE_SUFFIX = `/${TEST_COMPOSE_PATH}`;
|
|
51
|
+
|
|
52
|
+
/** The checkout a compose file sits in, or `undefined` for a file at any other path. */
|
|
53
|
+
export const rootOfCompose = (file: string): string | undefined =>
|
|
54
|
+
file.endsWith(COMPOSE_SUFFIX) ? file.slice(0, -COMPOSE_SUFFIX.length) : undefined;
|
|
55
|
+
|
|
56
|
+
const parseJson = (text: string): unknown => {
|
|
57
|
+
try {
|
|
58
|
+
return JSON.parse(text);
|
|
59
|
+
} catch {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/** One JSON document per line, or (older compose) one array. Anything else is no row. */
|
|
65
|
+
export function jsonRows(stdout: string): readonly Record<string, unknown>[] {
|
|
66
|
+
const text = stdout.trim();
|
|
67
|
+
const values: unknown[] = text.startsWith('[')
|
|
68
|
+
? [parseJson(text)].flat()
|
|
69
|
+
: text.split('\n').map(parseJson);
|
|
70
|
+
return values.filter(
|
|
71
|
+
(value): value is Record<string, unknown> => typeof value === 'object' && value !== null,
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const stringOf = (value: unknown): string => (typeof value === 'string' ? value : '');
|
|
76
|
+
|
|
77
|
+
/** Compose's states for a container that still holds its ports; `exited`/`created`/`dead` do not. */
|
|
78
|
+
const LIVE_STATES: ReadonlySet<string> = new Set(['running', 'restarting', 'paused']);
|
|
79
|
+
|
|
80
|
+
export function parseStack(stdout: string): TestStack | undefined {
|
|
81
|
+
const rows = jsonRows(stdout).filter((row) => stringOf(row['Project']) !== '');
|
|
82
|
+
const project = stringOf(rows[0]?.['Project']);
|
|
83
|
+
if (project === '') return undefined;
|
|
84
|
+
const roots = rows.flatMap((row) => {
|
|
85
|
+
const file = CONFIG_FILES.exec(stringOf(row['Labels']))?.[1];
|
|
86
|
+
const root = file === undefined ? undefined : rootOfCompose(file);
|
|
87
|
+
return root === undefined ? [] : [root];
|
|
88
|
+
});
|
|
89
|
+
return {
|
|
90
|
+
project,
|
|
91
|
+
services: [...new Set(rows.map((row) => stringOf(row['Service'])))].sort(),
|
|
92
|
+
roots: [...new Set(roots)],
|
|
93
|
+
running: rows.some((row) => LIVE_STATES.has(stringOf(row['State']))),
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** What compose says is up for this checkout's file. `answered: false` means it could not say. */
|
|
98
|
+
export async function readStack(root: string, runner: Runner): Promise<StackRead> {
|
|
99
|
+
try {
|
|
100
|
+
const result = await runner(SERVICES_LIST, { cwd: root });
|
|
101
|
+
if (!result.ok) return { answered: false };
|
|
102
|
+
const stack = parseStack(result.stdout);
|
|
103
|
+
return stack === undefined ? { answered: true } : { answered: true, stack };
|
|
104
|
+
} catch {
|
|
105
|
+
return { answered: false }; // No `docker` on PATH.
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const real = (path: string): string => {
|
|
110
|
+
try {
|
|
111
|
+
return realpathSync(path);
|
|
112
|
+
} catch {
|
|
113
|
+
return path;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
/** The checkouts other than `root` that started this stack and still exist. */
|
|
118
|
+
export const otherRoots = (stack: TestStack, root: string): readonly string[] =>
|
|
119
|
+
stack.roots.filter((other) => real(other) !== real(root) && existsSync(other));
|
|
120
|
+
|
|
121
|
+
async function gitFact(cwd: string, args: readonly string[], runner: Runner) {
|
|
122
|
+
try {
|
|
123
|
+
const result = await runner(['git', ...args], { cwd });
|
|
124
|
+
const text = result.stdout.trim();
|
|
125
|
+
return result.ok && text !== '' ? text : undefined;
|
|
126
|
+
} catch {
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** One app in two checkouts shares its first commit, or (a shallow clone) its origin. */
|
|
132
|
+
async function sameApp(one: string, two: string, runner: Runner): Promise<boolean> {
|
|
133
|
+
for (const args of [
|
|
134
|
+
['rev-list', '--max-parents=0', 'HEAD'],
|
|
135
|
+
['remote', 'get-url', 'origin'],
|
|
136
|
+
]) {
|
|
137
|
+
const [first, second] = await Promise.all([
|
|
138
|
+
gitFact(one, args, runner),
|
|
139
|
+
gitFact(two, args, runner),
|
|
140
|
+
]);
|
|
141
|
+
if (first !== undefined && first === second) return true;
|
|
142
|
+
}
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* What the stack is to this checkout. A checkout that no longer exists can use nothing, so its
|
|
148
|
+
* stack is simply there to reuse. One git cannot tie to this app is a collision: a shared name
|
|
149
|
+
* proves nothing, and the caller can still say the share is intended.
|
|
150
|
+
*/
|
|
151
|
+
export async function relationTo(
|
|
152
|
+
stack: TestStack,
|
|
153
|
+
root: string,
|
|
154
|
+
runner: Runner,
|
|
155
|
+
env: Env,
|
|
156
|
+
): Promise<StackRelation> {
|
|
157
|
+
let shared: StackRelation = { kind: 'own' };
|
|
158
|
+
for (const other of otherRoots(stack, root)) {
|
|
159
|
+
if (await sameApp(root, other, runner))
|
|
160
|
+
shared = { kind: 'shared', with: other, why: 'same-app' };
|
|
161
|
+
else if (env[SHARED_ENV] === '1') shared = { kind: 'shared', with: other, why: 'declared' };
|
|
162
|
+
else return { kind: 'collision', with: other, running: stack.running };
|
|
163
|
+
}
|
|
164
|
+
return shared;
|
|
165
|
+
}
|
package/src/verify-services.ts
CHANGED
|
@@ -13,6 +13,8 @@ import type { Finding } from './output';
|
|
|
13
13
|
import { quoteArg } from './shell-quote';
|
|
14
14
|
import { TEST_COMPOSE_PATH, TEST_ENV_PATH } from './templates/scaffold-test-services';
|
|
15
15
|
import { parseDotenvValues } from './test-dotenv';
|
|
16
|
+
import type { StackRelation, TestStack } from './verify-services-stack';
|
|
17
|
+
import { readStack, relationTo, SHARED_ENV } from './verify-services-stack';
|
|
16
18
|
|
|
17
19
|
/** The URL every live suite reads first; the one this file probes. */
|
|
18
20
|
export const TEST_DATABASE_KEY = 'TEST_DATABASE_URL';
|
|
@@ -145,6 +147,47 @@ const foreignFinding = (url: string): Finding => ({
|
|
|
145
147
|
at: TEST_ENV_PATH,
|
|
146
148
|
});
|
|
147
149
|
|
|
150
|
+
/**
|
|
151
|
+
* Another app under this project name: refused before `up` can touch its containers. A stopped
|
|
152
|
+
* one is said to be stopped — `ps --all` lists exited containers too, and calling them "running"
|
|
153
|
+
* sent a reader looking for a server that was not there — and its fix removes it by name: it held
|
|
154
|
+
* its data in RAM, so nothing is lost, and the other checkout's next `up` starts it again.
|
|
155
|
+
*/
|
|
156
|
+
const collisionFinding = (project: string, other: string, running: boolean): Finding =>
|
|
157
|
+
running
|
|
158
|
+
? {
|
|
159
|
+
code: 'X_TEST_SERVICES_UNAVAILABLE',
|
|
160
|
+
cause: `compose project ${project} is already running from ${other}, which is not a checkout of this app — the two share a name, so the live suites are not run against it`,
|
|
161
|
+
fix: `grep -n '^name:' ${TEST_COMPOSE_PATH} # give this app its own name: there, and its own ports there and in ${TEST_ENV_PATH}; if sharing is intended: ${SHARED_ENV}=1 bunx x verify --only live`,
|
|
162
|
+
at: TEST_COMPOSE_PATH,
|
|
163
|
+
}
|
|
164
|
+
: {
|
|
165
|
+
code: 'X_TEST_SERVICES_UNAVAILABLE',
|
|
166
|
+
cause: `compose project ${project} is stopped, and its containers belong to ${other}, which is not a checkout of this app — the two share a name, so this run does not take them over`,
|
|
167
|
+
fix: `docker compose -p ${quoteArg(project)} down --volumes # removes the stopped stack (its data was in RAM), then: x verify --only live; for good, give this app its own name: in ${TEST_COMPOSE_PATH}`,
|
|
168
|
+
at: TEST_COMPOSE_PATH,
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
/** The stack the suites got, for the one line the gate prints about it. */
|
|
172
|
+
export interface StackReport {
|
|
173
|
+
readonly project: string;
|
|
174
|
+
readonly state: 'started' | 'reused' | 'shared';
|
|
175
|
+
readonly with?: string;
|
|
176
|
+
readonly why?: 'same-app' | 'declared';
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const reportOf = (
|
|
180
|
+
stack: TestStack,
|
|
181
|
+
relation: StackRelation,
|
|
182
|
+
startedServices: readonly string[],
|
|
183
|
+
): StackReport => {
|
|
184
|
+
if (relation.kind === 'shared') {
|
|
185
|
+
const { with: other, why } = relation;
|
|
186
|
+
return { project: stack.project, state: 'shared', with: other, why };
|
|
187
|
+
}
|
|
188
|
+
return { project: stack.project, state: startedServices.length > 0 ? 'started' : 'reused' };
|
|
189
|
+
};
|
|
190
|
+
|
|
148
191
|
/** What `ensureTestServices` found: the env to hand the suites, and what happened on the way. */
|
|
149
192
|
export type ServicesVerdict =
|
|
150
193
|
/** Nothing to do: the caller's own URL, or a repo with no test stack to start. */
|
|
@@ -158,12 +201,14 @@ export type ServicesVerdict =
|
|
|
158
201
|
readonly env: Readonly<Record<string, string>>;
|
|
159
202
|
/** What this run's `up` started — compose's answer, never inferred from Postgres. */
|
|
160
203
|
readonly startedServices: readonly string[];
|
|
204
|
+
readonly stack?: StackReport;
|
|
161
205
|
}
|
|
162
206
|
/** This run started it, and left it running. */
|
|
163
207
|
| {
|
|
164
208
|
readonly kind: 'started';
|
|
165
209
|
readonly env: Readonly<Record<string, string>>;
|
|
166
210
|
readonly startedServices: readonly string[];
|
|
211
|
+
readonly stack?: StackReport;
|
|
167
212
|
}
|
|
168
213
|
/** It could not be started: the suites run as they would have, and this says why. */
|
|
169
214
|
| { readonly kind: 'unavailable'; readonly finding: Finding };
|
|
@@ -206,6 +251,27 @@ export async function ensureTestServices(input: ServicesInput): Promise<Services
|
|
|
206
251
|
probe(declared).then((up) => (up ? (input.login ?? postgresLogin)(declared) : 'down'));
|
|
207
252
|
const before = await login();
|
|
208
253
|
if (before === 'refused') return { kind: 'unavailable', finding: foreignFinding(declared) };
|
|
254
|
+
// Same name, same credentials: only the containers' own labels tell the apps apart.
|
|
255
|
+
const relate = async () => {
|
|
256
|
+
const read = await readStack(input.root, input.runner);
|
|
257
|
+
if (!read.answered || read.stack === undefined) return undefined;
|
|
258
|
+
const { stack } = read;
|
|
259
|
+
return { stack, relation: await relationTo(stack, input.root, input.runner, input.env) };
|
|
260
|
+
};
|
|
261
|
+
const collided = (found: Awaited<ReturnType<typeof relate>>): ServicesVerdict | undefined =>
|
|
262
|
+
found?.relation.kind === 'collision'
|
|
263
|
+
? {
|
|
264
|
+
kind: 'unavailable',
|
|
265
|
+
finding: collisionFinding(
|
|
266
|
+
found.stack.project,
|
|
267
|
+
found.relation.with,
|
|
268
|
+
found.relation.running,
|
|
269
|
+
),
|
|
270
|
+
}
|
|
271
|
+
: undefined;
|
|
272
|
+
const existing = await relate();
|
|
273
|
+
const refusedByName = collided(existing);
|
|
274
|
+
if (refusedByName !== undefined) return refusedByName;
|
|
209
275
|
// Always the idempotent `up`, even with Postgres answering: it may still be starting (`unknown`),
|
|
210
276
|
// and the env file names Redis, NATS and S3 too — a key handed on must have a service behind it.
|
|
211
277
|
const running = await runningServices(input);
|
|
@@ -213,13 +279,29 @@ export async function ensureTestServices(input: ServicesInput): Promise<Services
|
|
|
213
279
|
if (refused === undefined) {
|
|
214
280
|
const now = (await runningServices(input)) ?? new Set<string>();
|
|
215
281
|
const startedServices = [...now].filter((name) => running?.has(name) !== true).sort();
|
|
216
|
-
|
|
282
|
+
// Asked again: on a cold start another app's `up` can have won the name since the first look.
|
|
283
|
+
const found = await relate();
|
|
284
|
+
const lostTheName = collided(found);
|
|
285
|
+
if (lostTheName !== undefined) return lostTheName;
|
|
286
|
+
return {
|
|
287
|
+
kind: before === 'down' ? 'started' : 'reachable',
|
|
288
|
+
env,
|
|
289
|
+
startedServices,
|
|
290
|
+
...(found === undefined
|
|
291
|
+
? {}
|
|
292
|
+
: { stack: reportOf(found.stack, found.relation, startedServices) }),
|
|
293
|
+
};
|
|
217
294
|
}
|
|
218
295
|
// A failed `up` may be a concurrent run's container-name conflict: ask the database again.
|
|
219
296
|
const after = await login();
|
|
220
297
|
if (after === 'refused') return { kind: 'unavailable', finding: foreignFinding(declared) };
|
|
221
298
|
if (after !== 'ok') return { kind: 'unavailable', finding: refused };
|
|
222
|
-
return {
|
|
299
|
+
return {
|
|
300
|
+
kind: 'reachable',
|
|
301
|
+
env: await answering(env, probe),
|
|
302
|
+
startedServices: [],
|
|
303
|
+
...(existing === undefined ? {} : { stack: reportOf(existing.stack, existing.relation, []) }),
|
|
304
|
+
};
|
|
223
305
|
}
|
|
224
306
|
|
|
225
307
|
/**
|
package/src/verify-test-run.ts
CHANGED
|
@@ -15,7 +15,11 @@ import type { TestFile } from './test-select';
|
|
|
15
15
|
import { failureOf, TEST_TIMINGS_FILE, testArgs } from './test-shards';
|
|
16
16
|
import type { MachineLease } from './test-slots';
|
|
17
17
|
import { loadTimings, slowestOf } from './test-timings';
|
|
18
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
BATCH_FILES_PER_WORKER,
|
|
20
|
+
reachedWidth,
|
|
21
|
+
SHARED_BATCH_FILES_PER_WORKER,
|
|
22
|
+
} from './test-workers';
|
|
19
23
|
import type { MachinePace } from './verify-pace';
|
|
20
24
|
import { defaultTimeoutArgs, paceEnv } from './verify-pace';
|
|
21
25
|
import type { StepOutcome } from './verify-step';
|
|
@@ -108,18 +112,13 @@ export async function runParallel(options: ParallelRunOptions): Promise<StepOutc
|
|
|
108
112
|
// The width the run REACHED: a batch the machine pool narrowed ran narrower than planned, and a
|
|
109
113
|
// step line that printed the plan would name a width that never ran.
|
|
110
114
|
const reached = Math.max(1, ...result.widths);
|
|
111
|
-
const narrowed = reached < workers;
|
|
112
115
|
return {
|
|
113
116
|
ok: findings.length === 0,
|
|
114
117
|
findings,
|
|
115
118
|
workers: reached,
|
|
116
119
|
...(options.widthReason === undefined
|
|
117
120
|
? {}
|
|
118
|
-
: {
|
|
119
|
-
widthReason: narrowed
|
|
120
|
-
? `${String(reached)} of ${options.widthReason} — machine slots held by another run`
|
|
121
|
-
: options.widthReason,
|
|
122
|
-
}),
|
|
121
|
+
: { widthReason: reachedWidth(reached, workers, options.widthReason) }),
|
|
123
122
|
// Per batch: each process printed its own summary, and one parse of the joined text would
|
|
124
123
|
// read only the last one.
|
|
125
124
|
tests: countsOf(result.results),
|
package/src/verify-tests.ts
CHANGED
|
@@ -25,7 +25,13 @@ import { discoverTests } from './test-select';
|
|
|
25
25
|
import { TEST_TIMINGS_FILE } from './test-shards';
|
|
26
26
|
import { machineLease, suiteWeight } from './test-slots';
|
|
27
27
|
import type { WorkerPlan } from './test-workers';
|
|
28
|
-
import {
|
|
28
|
+
import {
|
|
29
|
+
availableCpus,
|
|
30
|
+
fileBoundWidth,
|
|
31
|
+
SERIAL_TYPES,
|
|
32
|
+
totalMemory,
|
|
33
|
+
workerPlan,
|
|
34
|
+
} from './test-workers';
|
|
29
35
|
import { runCovered } from './verify-coverage-run';
|
|
30
36
|
import { judgeE2eBrowser, withE2eApp } from './verify-e2e';
|
|
31
37
|
import { factoryFindings } from './verify-factories';
|
|
@@ -232,7 +238,7 @@ const runType = async (ctx: VerifyContext, type: TestType): Promise<StepOutcome>
|
|
|
232
238
|
plan === undefined
|
|
233
239
|
? `${String(Math.min(workers, files.length))} workers (--workers)`
|
|
234
240
|
: files.length < plan.workers
|
|
235
|
-
?
|
|
241
|
+
? fileBoundWidth(files.length, plan.reason)
|
|
236
242
|
: plan.reason;
|
|
237
243
|
// A subset cannot hold the whole tree's coverage floor: only a full unit run is judged.
|
|
238
244
|
if (type === 'unit' && isApp(ctx.root) && selected === undefined) {
|
package/src/verify-typecheck.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
// Which `tsc` invocation the `typecheck` step runs: `-p` with `incremental
|
|
1
|
+
// Which `tsc` invocation the `typecheck` step runs: `-p` with `incremental` for a root with no
|
|
2
|
+
// project references (every scaffolded app), `-b` for one that declares them — its only walker.
|
|
2
3
|
//
|
|
3
4
|
// `tsc -b` decides "up to date" by mtime, and Bun installs a package as HARDLINKS out of its cache,
|
|
4
5
|
// carrying the cache's old mtimes — so upgrading a dependency to a version already in the cache
|
|
5
6
|
// left every input older than the buildinfo, `-b` skipped the program and reported green while a
|
|
6
7
|
// cold CI went red (#450). `-p` with `incremental` re-reads every input and compares content
|
|
7
|
-
// hashes, so it cannot be fooled by a date.
|
|
8
|
+
// hashes, so it cannot be fooled by a date. A root WITH references still runs `-b` and keeps
|
|
9
|
+
// that exposure: after a dependency upgrade there, start over with a clean build.
|
|
8
10
|
|
|
11
|
+
import type { Finding } from './output';
|
|
9
12
|
import { checkRootReferences } from './tsconfig-references';
|
|
10
13
|
|
|
11
14
|
/**
|
|
@@ -28,3 +31,23 @@ export async function typecheckArgs(root: string, bin: string): Promise<readonly
|
|
|
28
31
|
const mode = (await usesProjectReferences(root)) ? ['-b'] : ['-p', '.'];
|
|
29
32
|
return [bin, ...mode, '--pretty', 'false'];
|
|
30
33
|
}
|
|
34
|
+
|
|
35
|
+
/** `apps/web/a.ts(3,7): error TS2322: …`, the first line of `tsc --pretty false` that names a place. */
|
|
36
|
+
const FIRST_ERROR = /^(.+?)\((\d+),\d+\): error TS/m;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The step's red finding. The errors are already printed under it, so the fix opens at the first of
|
|
40
|
+
* them and re-runs the step: a raw `tsc` repeats the list outside the machine ledger and this
|
|
41
|
+
* checkout's compiler lock.
|
|
42
|
+
*/
|
|
43
|
+
export function typecheckFinding(output: string): Omit<Finding, 'docs'> {
|
|
44
|
+
const first = FIRST_ERROR.exec(output);
|
|
45
|
+
return {
|
|
46
|
+
code: 'X_TYPECHECK_FAILED',
|
|
47
|
+
cause: 'the project does not typecheck',
|
|
48
|
+
fix:
|
|
49
|
+
first === null
|
|
50
|
+
? 'x verify --only typecheck --json # its output carries what tsc printed'
|
|
51
|
+
: `edit ${first[1]}:${first[2]} — and each other file(line) tsc listed under this finding, then: x verify --only typecheck`,
|
|
52
|
+
};
|
|
53
|
+
}
|
package/wiki/Actions.md
CHANGED
|
@@ -135,11 +135,12 @@ An action that answers in pieces declares `stream: <chunk schema>` and writes `h
|
|
|
135
135
|
|
|
136
136
|
| Caller | Gets |
|
|
137
137
|
|---|---|
|
|
138
|
-
| `accept: text/event-stream` on its route | `event: chunk` per yield (parsed by `stream` first), then one `event: done` (output) or `event: error` (problem document); `x-accel-buffering: no`, a `: keep-alive` every 15 s |
|
|
138
|
+
| `accept: text/event-stream` on its route | `event: chunk` per yield (parsed by `stream` first), then one `event: done` (output) or `event: error` (problem document). Each `chunk` and the `done` frame carry their instants on a `dates:` field, which a reader that does not know it ignores. A fault after the first chunk is recorded as the JSON path's is — monitor (5xx), `hooks.onError`, log line — once (`reportLateFault`, `@ultimat3/http`); a reader's cancel is not a fault; `x-accel-buffering: no`, a `: keep-alive` every 15 s |
|
|
139
139
|
| anything else — JSON, MCP, `.job()`, `.as()`, a direct call | the generator drained, the output alone: one contract |
|
|
140
140
|
| refused before the handler starts (policy, input, rate limit) | the ordinary problem response, never a stream |
|
|
141
141
|
| the client leaves mid-stream | `ctx.signal` aborts inside the handler |
|
|
142
142
|
| a browser | `clientStream({ url, body })` from `@ultimat3/core`: `fetch`, never `EventSource` |
|
|
143
|
+
| a `Date` in the output | a `Date` again in `clientStream` and the typed client: the server names each instant's path (`x-ultimate-dates` on the plain and the enveloped 200, `dates:` on each `chunk` and the `done` frame) and the client revives it. The body and OpenAPI are unchanged; a client ignoring the header reads the ISO string. `As of 2026-11-19` (`packages/action/src/record-wire.ts`, `packages/action/src/http-stream.ts`). The header is capped at 1,536 bytes (`WIRE_DATES_MAX_BYTES`): an answer whose instants need one path each — a `string \| Date` column, a `[label, instant]` tuple — past that is sent with no `x-ultimate-dates` (and no `dates:` line), the client reads those instants as ISO strings, and the operation is logged once at `warn` as `http.wire_dates_dropped`. `As of 2026-11-19`. |
|
|
143
144
|
|
|
144
145
|
A chunk its schema refuses, or `stream:` beside a handle that is not a generator, is `X_ACTION_STREAM_INVALID`. The OpenAPI 200 lists `text/event-stream` beside `application/json` for a streaming action only. `agent()` streams this way.
|
|
145
146
|
|
package/wiki/Admin-Dashboard.md
CHANGED
|
@@ -74,7 +74,7 @@ A count reads no row, so it is not audited. Upgrading from a release that counte
|
|
|
74
74
|
| `?f.<field>=<value>` | the field's default operator (`contains` for text, `eq` otherwise) |
|
|
75
75
|
| `?f.<field>.<op>=<value>` | `eq` `neq` `contains` `gt` `gte` `lt` `lte` `in` (repeat the parameter) `is-null` (`true` / `false`) — the ones the field's shape answers |
|
|
76
76
|
| `?scope=<name>` | a declared scope; absent is the default; `*` is no scope at all — what a related card's link opens. A scope may not be declared as `*` |
|
|
77
|
-
| `?sort=<field>:<asc\|desc>` | a sortable field |
|
|
77
|
+
| `?sort=<field>:<asc\|desc>` | a sortable field. A `money()` column sorts by currency, then minor (`As of 2026-11-19`): amounts compare only within a currency, so each currency is a group, and the id breaks ties; it answered 500 `X_INVARIANT_VIOLATED` before |
|
|
78
78
|
| `?cursor=<signed>` | keyset position on `(sort, id)`: any number of rows sharing a sort value, and NULLs (last ascending, first descending), are reached both ways |
|
|
79
79
|
|
|
80
80
|
An unknown field, operator, sort, scope or parameter — or a value that is not the column's type (a number is decimal digits: no blank, hex or exponent; a date is one the calendar has) — is `X_ADMIN_FILTER_INVALID`: a 400 naming what the list answers, never the unfiltered list. The MCP list tool takes the same grammar (`scope`, `where: [{ field, op?, value }]`).
|
|
@@ -98,7 +98,7 @@ Statements per list page: 1 for the rows (2 when the sort column is nullable, on
|
|
|
98
98
|
|---|---|
|
|
99
99
|
| `input: t.object({ … })` | the button is a link to the action's form; a refusal is a 422 with each issue on its field. No schema: a confirm only |
|
|
100
100
|
| `when: (row) => boolean` | decides the button on the detail and each list row, and is asked again before the handler: `X_ADMIN_ACTION_NOT_APPLICABLE` (409) |
|
|
101
|
-
| `batch: true` | in the list's batch bar: checked rows, or every row the list's URL matches (200 per request, continued from where it stopped). Each row through the button's gate and on the audit log; answered `done` / `refused` / `failed` / `remaining` |
|
|
101
|
+
| `batch: true` | in the list's batch bar: checked rows, or every row the list's URL matches (200 per request, continued from where it stopped). Each row through the button's gate and on the audit log; answered `done` / `refused` / `failed` / `remaining`. Only an "all matching" selection continues: a checked-rows batch past the bound answers `after: null` (screen and MCP) and the caller re-sends the remaining ids — `As of 2026-11-19`; its continuation used to widen to every row the list matched |
|
|
102
102
|
| `batch: { threshold, chunk? }` | past `threshold` rows, one `admin.batch` job per chunk, run by a worker as the operator; `queued` in the answer. The batch id is derived from actor, action, rows and input, so retrying a request whose enqueue failed part-way dedupes the chunks already queued |
|
|
103
103
|
| `matching: ({ where, input, ctx }) => { affected, remaining }` | "all matching" as ONE set-based call over the list's `where` (row scope, scope, filters) — a store's bounded bulk verb — decided and audited once; a destructive one types `<entity>:all matching`. Checked rows still run row by row |
|
|
104
104
|
| `readonly: true` | the action changes nothing (an export, a verification), so its admin-level gate is `admin:read`, not `admin:write`: a read-only staff role and an `admin:read` MCP token may run it. The action's own `permission` is still required beside it |
|
package/wiki/Agents.md
CHANGED
|
@@ -332,15 +332,15 @@ That matters because the transcript **is** the request: a loop that keeps going
|
|
|
332
332
|
|
|
333
333
|
| Surface | `ctx.signal` fires when |
|
|
334
334
|
|---|---|
|
|
335
|
-
| HTTP | the **request deadline** passes, **or the caller goes away** — the
|
|
335
|
+
| HTTP | the **request deadline** passes, **or the caller goes away** — one signal: the caller's abort is forwarded into the deadline's controller, and the first abort wins with its own reason ([`packages/http/src/deadline.ts`](https://github.com/developerz-ai/ultimate/blob/main/packages/http/src/deadline.ts)). The deadline is `requestTimeoutMs` (30s), or the shorter budget the caller sent as `x-request-timeout-ms`, and it bounds **time-to-headers**: once a streamed answer has started, only the caller going away fires the signal |
|
|
336
336
|
| Job / `agentJob()` | the attempt times out, or the job is cancelled — `x jobs cancel <id> --reason "…"`. The worker's own `ctx` is what `agentJob` forwards, so the abort reaches the turn loop |
|
|
337
337
|
| Your own code | a signal you pass: `withChildContext({ signal }, () => supportAgent(input, { ctx }))` |
|
|
338
338
|
|
|
339
|
-
**A closed browser tab DOES abort an in-flight agent, `As of 2026-08`.** `pipeline.ts` hands the inbound `Request.signal` to `startDeadline`, which
|
|
339
|
+
**A closed browser tab DOES abort an in-flight agent, `As of 2026-08`.** `pipeline.ts` hands the inbound `Request.signal` to `startDeadline`, which forwards its abort into the timer's controller — so a disconnect unwinds the turn loop instead of paying for every remaining turn. A handler that unwinds on that hang-up is answered `X_ABORTED` (499) and is not reported as a failure. This page said the opposite until 12.0.0, and it was true when it was written: nothing in `@ultimat3/http` read the inbound signal, so a closed tab held its handler, its pool slot and its vendor connection for the whole budget.
|
|
340
340
|
|
|
341
341
|
| Want | Do |
|
|
342
342
|
|---|---|
|
|
343
|
-
| every agent request bounded | call `configureHttp({ requestTimeoutMs: 120_000 })` at module scope in a file under `apps/*/` — `ctx.signal` fires there and `X_TIMEOUT` answers the socket either way |
|
|
343
|
+
| every non-streamed agent request bounded | call `configureHttp({ requestTimeoutMs: 120_000 })` at module scope in a file under `apps/*/` — `ctx.signal` fires there and `X_TIMEOUT` answers the socket either way. A streamed answer (SSE, a stream-declaring action) is bounded only until its headers leave; bound the stream itself with `withChildContext({ signal: AbortSignal.timeout(ms) }, …)` |
|
|
344
344
|
| this call bounded shorter | send `x-request-timeout-ms` with the milliseconds you will wait; a caller may only **shorten** the deadline, never lengthen it, and anything under 1ms falls back to the server's own budget |
|
|
345
345
|
| the next hop bounded by what is LEFT | nothing — both typed clients spread `traceHeaders()` before your own headers, and it sends the **remaining** budget as `x-request-timeout-ms`. A spent budget sends no header rather than `0`, because `0` reads one hop later as "the caller asked for nothing" |
|
|
346
346
|
| a run the user can actually stop | run it as a job — `agentJob()` — and cancel it by id: `x jobs cancel <id> --reason "user cancelled"` |
|
|
@@ -535,7 +535,7 @@ export async function writeThenFix(ctx: Ctx, problem: string): Promise<{ title:
|
|
|
535
535
|
|
|
536
536
|
**The handle is signed data.** `AgentTranscript` is plain JSON that the app stores; treat it as opaque. It holds what the model was sent (already redacted) and what the tools answered, so store it where tool results may live. It also carries the run's own ceilings — `turns` and `usage` — so it is **signed**: an HMAC-SHA256 over its canonical bytes with the framework's signing secret (`ULTIMATE_CURSOR_SECRET`, under a label of its own), and **bound** to the agent (`id@version` of its prompt: a bumped prompt starts a new run), the model the run is on, the set of tool names the run was offered (every declared one unless [`offerTools()`](#per-run-picks-offertools-model-limits) narrowed it), and the tenant (`orgId`) of the actor it was written for. On the way back, before anything is loaded or spent, `.continue()` checks: at most `MAX_TRANSCRIPT_CHARS` (2,000,000) of JSON; the signature; each binding (a handle written for org A is refused for an actor of org B); then its shape — roles alternating, only the three block kinds a loop writes, every tool call answered by the next message, every tool call naming a tool the agent declares. Anything else is `X_AGENT_TRANSCRIPT_INVALID` (422, `terminal` for a job). An edited handle is therefore refused, not trusted: zeroing `usage`, lowering `turns`, rewriting a message or fabricating a tool result all break the signature. Rotating the secret invalidates stored handles. In production a process still on the shipped development key refuses `.continue()` and names `ULTIMATE_CURSOR_SECRET`; in development and test the development key signs. What the signature does not do: it does not make the transcript an authority — tools still run as `ctx.actor` under their own policies — and it does not stop a holder of a **valid** handle from continuing it, so store it per tenant like any other row.
|
|
537
537
|
|
|
538
|
-
**A failed call leaves a handle too.** When `.run()` or `.continue()` throws after a provider answered, the error carries a signed handle — `transcriptOf(error)` — holding the transcript up to the request the failed turn was answering, with `turns` and `usage` counting everything the failed call was billed. **A job stores that handle, not the one it started with.** Continuing from the old handle forgets the failed call's spend: `maxTurns` and `budget.tokensPerRun` then count from the old figures, and only the actor and org ceilings bound the retries. A call aborted before it reported usage is not in the handle (its bill is unknown — `billedOf(error).unsettled`). A plain call keeps nothing and leaves no handle.
|
|
538
|
+
**A failed call leaves a handle too.** When `.run()` or `.continue()` throws after a provider answered, the error carries a signed handle — `transcriptOf(error)` — holding the transcript up to the request the failed turn was answering, with `turns` and `usage` counting everything the failed call was billed. **A job stores that handle, not the one it started with.** Continuing from the old handle forgets the failed call's spend: `maxTurns` and `budget.tokensPerRun` then count from the old figures, and only the actor and org ceilings bound the retries. A call aborted before it reported usage is not in the handle (its bill is unknown — `billedOf(error).unsettled`). A plain call keeps nothing and leaves no handle. **A handle cut inside a tool batch keeps every result the batch completed** (`As of 2026-11-19`; a throwing `onCheckpoint`, `X_AGENT_TOOL_LOOP`, the deadline or an abort): a completed call carries its real result, a call in flight when the run stopped is answered `Interrupted: … its outcome is unknown. Check whether it took effect before calling it again.`, and one never started `Not run: the run stopped before this call started.` — both `is_error`, so continuing never re-runs a tool that already charged. A failure before any tool started leaves the handle at the request, as before.
|
|
539
539
|
|
|
540
540
|
## Auto-compaction (`compact`)
|
|
541
541
|
|
|
@@ -544,7 +544,7 @@ export async function writeThenFix(ctx: Ctx, problem: string): Promise<{ title:
|
|
|
544
544
|
| Before | After |
|
|
545
545
|
|---|---|
|
|
546
546
|
| tools, system prompt (stable block, per-run block) | **the same bytes** — the provider's cached prefix survives |
|
|
547
|
-
| first user message: the rendered prompt | the prompt verbatim, then one `[compacted: N earlier turns …]` text block holding the summary |
|
|
547
|
+
| first user message: the rendered prompt | the prompt verbatim, then one `[compacted: N earlier turns …]` text block holding the summary, then the user's own text from summarised turns, ≤ 8,000 chars in total across every compaction (`KEPT_USER_CHARS`, newest kept first). `As of 2026-11-19` |
|
|
548
548
|
| turns 1 … N−k | gone — folded into the summary |
|
|
549
549
|
| the last `keepTurns` turns (each an assistant message and the user message answering its tool calls) | **the same bytes** — no tool call is ever separated from its result |
|
|
550
550
|
|
package/wiki/Auth.md
CHANGED
|
@@ -65,7 +65,7 @@ issuer, discovered on the first sign-in). Both write the sign-in page, the `dest
|
|
|
65
65
|
`auth.signInPath`, and a boot guard: outside `development` and `test` a `web` or `sync` role with
|
|
66
66
|
its sign-in keys unset refuses to start (`X_AUTH_SIGN_IN_UNCONFIGURED`). `--password` also writes
|
|
67
67
|
`createSession` / `confirmSession` and the second-factor page; `--oidc` writes the start and
|
|
68
|
-
callback routes and drops `x new`'s development viewer while its files are still `x new`'s own. What each writes:
|
|
68
|
+
callback routes, passes `mfaPath` and writes the second-factor page and its `confirmSession` action, so an MFA-enrolled user finishes SSO (`As of 2026-11-19`; an app generated before adds `mfaPath` by hand — [Upgrading](Upgrading)), and drops `x new`'s development viewer while its files are still `x new`'s own. What each writes:
|
|
69
69
|
[CLI reference](CLI-Reference#x-g).
|
|
70
70
|
|
|
71
71
|
## OAuth
|
|
@@ -129,9 +129,17 @@ export const sso = identityProviderRoutes(auth, {
|
|
|
129
129
|
oidcIdentityProvider({ provider: 'github' }),
|
|
130
130
|
],
|
|
131
131
|
successPath: '/app',
|
|
132
|
+
mfaPath: '/sign-in/mfa', // where a user with TOTP enrolled finishes; omitted, their callback is 401
|
|
132
133
|
});
|
|
133
134
|
```
|
|
134
135
|
|
|
136
|
+
A user with a second factor is sent to `mfaPath` (303) with the sealed challenge in the
|
|
137
|
+
`__Host-x_mfa` cookie; that page finishes with
|
|
138
|
+
`completeMfa(auth, readMfaChallenge(request) ?? '', code)`. `oauthLogin(auth, { mfaPath })` is the
|
|
139
|
+
same option. The write half is exported too — `mfaChallengeOf`, `mfaChallengeCookie`,
|
|
140
|
+
`MFA_CHALLENGE_COOKIE` — so a password sign-in holds its challenge in the same cookie
|
|
141
|
+
(`x g sign-in --password` does, `As of 2026-11-19`).
|
|
142
|
+
|
|
135
143
|
`defineAuth({ providers })` lists both ids; an unknown or not-enabled id is `X_IDENTITY_PROVIDER_UNKNOWN` (404).
|
|
136
144
|
|
|
137
145
|
**OIDC replay.** `oidcIdentityProvider` claims the handshake's `state` once in the shared replay store before it spends the code, keyed on when the handshake was issued: a callback lifted from a browser is `X_OAUTH_STATE_INVALID` even inside the cookie's lifetime, and so is any answer more than 10 minutes after `begin` (`DEFAULT_HANDSHAKE_TTL_MS`).
|
|
@@ -274,11 +282,11 @@ const resolveToken = oauthBearerResolver(oauth, { actor: (grant) => actorFor(gra
|
|
|
274
282
|
| Piece | What it does |
|
|
275
283
|
|---|---|
|
|
276
284
|
| `routes` | `GET /.well-known/oauth-authorization-server` (RFC 8414), `POST /oauth/token`, `/oauth/revoke` (RFC 7009), `/oauth/introspect` (RFC 7662), plus `/oauth/register` (RFC 7591, `registration: 'dynamic'`) and `/oauth/device` (RFC 8628). Plain `Route`s for `runtime.routes`, public, no cookie authenticates them. Every answer is `no-store` RFC 6749 JSON |
|
|
277
|
-
| consent | the page calls `readRequest(url, { callerKey })` (`callerKey`: the request's address) → `{ client, scopes, resource, redirectUri }` or a refusal; an unknown client or unregistered redirect has `redirectTo: null` — render it, never redirect. Its action calls `approve({ subject, request, scopes? })` / `deny({ request })` for the redirect URL (`code`, `state`, `iss`). A forged request is `X_AUTH_CONSENT_INVALID` (422) |
|
|
285
|
+
| consent | the page calls `readRequest(url, { callerKey })` (`callerKey`: the request's address) → `{ client, scopes, resource, redirectUri }` or a refusal; a metadata-document client carries `client.host`, its `client_id`'s host, beside the `name` its own document chose — show the host, since the name is the client's to write (`As of 2026-11-19`); an unknown client or unregistered redirect has `redirectTo: null` — render it, never redirect. Its action calls `approve({ subject, request, scopes? })` / `deny({ request })` for the redirect URL (`code`, `state`, `iss`). A forged request is `X_AUTH_CONSENT_INVALID` (422) |
|
|
278
286
|
| device | the verification page calls `readDevice({ userCode, key })`, `approveDevice` / `denyDevice`; `key` is the caller's bucket — 10 misses lock it (`X_ACCOUNT_LOCKED`) |
|
|
279
287
|
| `registerClient(...)` | a client the app creates itself — a partner's `client_credentials` client; the secret is shown once and stored hashed. A redirect URI, grant, scope or resource that is empty or holds whitespace is `X_AUTH_CLIENT_INVALID` (422, `meta.field`): the store keeps each list space-joined, so it would read back as a different list |
|
|
280
288
|
| `resolve(token)` | `{ subject, scopes, clientId, resource } \| null`. `oauthBearerResolver(server, { actor, resource? })` is the `resolveToken` a bearer mount and `defineAppMcp` take; `actor` runs per call, so a removed member loses access at once |
|
|
281
|
-
| `revoke({ subject, clientId? })` · `purge({ before })` | immediate; `purge` is the app's `task` to schedule, nothing here runs on a timer |
|
|
289
|
+
| `revoke({ subject, clientId? })` · `purge({ before })` | immediate; `purge` is the app's `task` to schedule, nothing here runs on a timer. `purge` also deletes a self-registered client (a `d_` id, minted by `/oauth/register`) created before the refresh idle window that no grant, code or device code names; its next call is `invalid_client` and an MCP client re-registers. A client from `registerClient` (`c_`), and any registered before `As of 2026-11-19`, is never reaped |
|
|
282
290
|
|
|
283
291
|
| Rule | Held by |
|
|
284
292
|
|---|---|
|
|
@@ -293,9 +301,11 @@ const resolveToken = oauthBearerResolver(oauth, { actor: (grant) => actorFor(gra
|
|
|
293
301
|
| `resource` (RFC 8707) binds the grant; one not in `resources` is `invalid_target` | `authorization-server-request.test.ts`, `oauth-bearer-resolver.test.ts` |
|
|
294
302
|
| tokens are opaque and stored hashed, never a JWT, so `revoke` holds on the next lookup | `token-endpoints.test.ts` |
|
|
295
303
|
| an `https://` `client_id` is a metadata document, fetched through `outbound({ dial: 'public' })`, 5 KiB, cached 5 minutes, public clients only | `authorization-server-clients.test.ts` |
|
|
296
|
-
| every metadata-document fetch is metered (`X_ACCOUNT_LOCKED` past 10 a minute): per `callerKey
|
|
304
|
+
| every metadata-document fetch is metered (`X_ACCOUNT_LOCKED` past 10 a minute): per `callerKey`'s network (`ipKey`: IPv4 whole, IPv6 per /64), or — when the consent page names none — on ONE shared bucket, so an unkeyed page is throttled as one caller | `authorization-server-clients.test.ts` |
|
|
297
305
|
| `client_credentials`: confidential only, no refresh token, subject is the client | `grant-client-credentials.test.ts` |
|
|
298
|
-
| dynamic registration never hands out `client_credentials` and is counted per
|
|
306
|
+
| dynamic registration never hands out `client_credentials` and is counted per network (`ipKey`, as login is) | `authorization-server-clients.test.ts` |
|
|
307
|
+
| dynamic registration takes at most 10 `redirect_uris` of at most 2,048 characters each, else 400 `invalid_client_metadata` and nothing stored; `scope` is deduplicated | `authorization-server-clients.test.ts` |
|
|
308
|
+
| `purge` reaps a `d_` client only when nothing names it, on both stores | `authorization-server-store.test.ts`, `authorization-server-postgres.test.ts`, `authServerStoreConformance` |
|
|
299
309
|
|
|
300
310
|
Bad configuration is `X_AUTH_SERVER_INVALID` naming the field; a grant not in `grants` answers
|
|
301
311
|
`unsupported_grant_type` and is logged `X_AUTH_GRANT_DISABLED`. The five tables (`x_oauth_*`) are
|
package/wiki/Bare-VM.md
CHANGED
|
@@ -15,7 +15,7 @@ bun run verify
|
|
|
15
15
|
|---|---|
|
|
16
16
|
| `bunx create-ultimate demo --no-git` | bun, and a network the npm registry answers on. `--no-git` skips `git init`, which is the form an automated provisioner uses; without it the scaffold is committed, and that is git's only job here |
|
|
17
17
|
| `cd demo` | — |
|
|
18
|
-
| `bun run setup` | bun.
|
|
18
|
+
| `bun run setup` | bun. Seven steps: `bun install`, `x merge-driver install`, an `.env.development.local` touch, `x db gen "initial"` when `packages/db/migrations` holds no `.sql`, `x db migrate`, `x db seed`, `x manifest` |
|
|
19
19
|
| `bun run verify` | bun. `x verify`, the whole gate: its `budgets` step runs `x build --target static` itself, because `.x/build-stats.json` does not exist yet on a fresh box (`As of 30.0`) |
|
|
20
20
|
|
|
21
21
|
`x new` installs nothing, so `bun run setup` is not optional and `cd demo && bun run verify` stops on
|
package/wiki/CI-Parallel-Gate.md
CHANGED
|
@@ -251,7 +251,8 @@ job's runner acquisition ahead of every other job, a few seconds.
|
|
|
251
251
|
## Width and memory, per job
|
|
252
252
|
|
|
253
253
|
Each job sizes its own test width the same way the laptop does (`x verify` prints it on the step
|
|
254
|
-
line, e.g. `3 workers (budget 4.0 GB)`
|
|
254
|
+
line, e.g. `3 workers (budget 4.0 GB)`; `ran 2 at once (peak), planned 3` when the machine held it
|
|
255
|
+
narrower): a budget of `max(2.75 GiB, 25% of the runner's RAM)`,
|
|
255
256
|
1.25 GiB planned per worker, never more workers than cores. On a 16 GB `ubuntu-latest` that is 3
|
|
256
257
|
workers; a 62 GB, 16-core workstation plans 12 (`As of 2026-11-07`, when the fixed 4 GiB cap went —
|
|
257
258
|
the [machine ledger](Many-Agents) is what keeps two runs on one box inside one budget). `ULTIMATE_TEST_MEMORY_BUDGET=6g` or `ULTIMATE_TEST_MAX_WORKERS=4` override it; `--workers`
|