@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,104 @@
|
|
|
1
|
+
// The CPU half of admission: a run that fits in memory still waits while the machine's CPU is
|
|
2
|
+
// saturated and another heavy run is going. The thresholds, their measurement and the decision live
|
|
3
|
+
// here; `heavy-ledger.ts` asks it only for the queue's head, so first-come order is kept.
|
|
4
|
+
|
|
5
|
+
// why: Bun ships no synchronous file read, and `/proc/pressure/cpu` is read on every poll.
|
|
6
|
+
import { readFileSync } from 'node:fs';
|
|
7
|
+
// why: Bun exposes no available-parallelism primitive.
|
|
8
|
+
import { availableParallelism } from 'node:os';
|
|
9
|
+
import { runnableTasks } from './heavy-cores';
|
|
10
|
+
import type { HeavyEnv } from './heavy-env';
|
|
11
|
+
import { HEAVY_CPU_ENV, isCi } from './heavy-env';
|
|
12
|
+
import { msg } from './messages';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Measured on the 8-core shared box, 2026-11-18, `As of` Linux 7.0: four admitted runs held 14.3 of
|
|
16
|
+
* 15.9 GB while load was 74-94 with 69-84 runnable tasks, and `cpu some avg10` read 95.8. Memory was
|
|
17
|
+
* not the bound; CPU was, and every run on it slowed. `some` is the share of time at least one task
|
|
18
|
+
* waited for a CPU: an 8-core box running one 4-core typecheck stays far below 80, and at 80 most of
|
|
19
|
+
* every second already has a queue. avg10 is the shortest window the kernel keeps. ONE reading; a
|
|
20
|
+
* re-measure that moves it changes only these numbers.
|
|
21
|
+
*/
|
|
22
|
+
export const CPU_SOME_BUSY_PERCENT = 80;
|
|
23
|
+
/** No PSI (macOS, older kernels): 69 runnable on 8 cores was 8.6 a core; 2 a core is a run queue. */
|
|
24
|
+
export const RUNNABLE_PER_CORE_BUSY = 2;
|
|
25
|
+
/**
|
|
26
|
+
* How long the queue's head waits on CPU alone before it goes anyway. A holder can run for hours
|
|
27
|
+
* while outside work keeps the CPU busy; this bounds the wait to one admission per window.
|
|
28
|
+
*/
|
|
29
|
+
export const CPU_WAIT_LIMIT_MS = 5 * 60_000;
|
|
30
|
+
|
|
31
|
+
export interface CpuReading {
|
|
32
|
+
readonly source: 'psi' | 'runnable';
|
|
33
|
+
/** `cpu some avg10` in percent, or runnable tasks per core. */
|
|
34
|
+
readonly value: number;
|
|
35
|
+
readonly limit: number;
|
|
36
|
+
readonly busy: boolean;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** `some avg10=95.83 …` → 95.83. */
|
|
40
|
+
export function parseCpuSome(text: string): number | undefined {
|
|
41
|
+
const match = /^some avg10=(\d+(?:\.\d+)?)/m.exec(text);
|
|
42
|
+
return match === null ? undefined : Number(match[1]);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const readPsi = (): string => readFileSync('/proc/pressure/cpu', 'utf8');
|
|
46
|
+
|
|
47
|
+
/** PSI where the kernel has it, else runnable tasks per core. Never throws. */
|
|
48
|
+
export function readCpuPressure(
|
|
49
|
+
input: { readonly read?: () => string; readonly cores?: number; readonly runnable?: number } = {},
|
|
50
|
+
): CpuReading {
|
|
51
|
+
let some: number | undefined;
|
|
52
|
+
try {
|
|
53
|
+
some = parseCpuSome((input.read ?? readPsi)());
|
|
54
|
+
} catch {
|
|
55
|
+
some = undefined; // No PSI here.
|
|
56
|
+
}
|
|
57
|
+
if (some !== undefined) {
|
|
58
|
+
return {
|
|
59
|
+
source: 'psi',
|
|
60
|
+
value: some,
|
|
61
|
+
limit: CPU_SOME_BUSY_PERCENT,
|
|
62
|
+
busy: some >= CPU_SOME_BUSY_PERCENT,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
const cores = Math.max(1, input.cores ?? availableParallelism());
|
|
66
|
+
const perCore = Math.round(((input.runnable ?? runnableTasks()) / cores) * 10) / 10;
|
|
67
|
+
return {
|
|
68
|
+
source: 'runnable',
|
|
69
|
+
value: perCore,
|
|
70
|
+
limit: RUNNABLE_PER_CORE_BUSY,
|
|
71
|
+
busy: perCore >= RUNNABLE_PER_CORE_BUSY,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Whether the head may start on CPU grounds. Never `wait` with nothing admitted: pressure from work
|
|
77
|
+
* outside the ledger must not stop the only run, and a ledger with no holder cannot deadlock.
|
|
78
|
+
*/
|
|
79
|
+
export function cpuAdmission(input: {
|
|
80
|
+
readonly reading: CpuReading | undefined;
|
|
81
|
+
/** Reservations admitted now. */
|
|
82
|
+
readonly running: number;
|
|
83
|
+
/** How long the head has waited on CPU alone. */
|
|
84
|
+
readonly blockedMs: number;
|
|
85
|
+
}): 'admit' | 'wait' {
|
|
86
|
+
if (input.reading?.busy !== true || input.running === 0) return 'admit';
|
|
87
|
+
return input.blockedMs >= CPU_WAIT_LIMIT_MS ? 'admit' : 'wait';
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Off in CI (single-tenant), off inside a test run (a fixture must not wait on the machine it runs
|
|
92
|
+
* on; `ambient` is this process's own env), and off with `ULTIMATE_HEAVY_CPU=0`.
|
|
93
|
+
*/
|
|
94
|
+
export function cpuGateOn(env: HeavyEnv, ambient: HeavyEnv = Bun.env): boolean {
|
|
95
|
+
if (isCi(env) || env[HEAVY_CPU_ENV] === '0') return false;
|
|
96
|
+
return env['NODE_ENV'] !== 'test' && ambient['NODE_ENV'] !== 'test';
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** `CPU pressure 96% (new runs wait at 80%)`. */
|
|
100
|
+
export const cpuText = (reading: CpuReading): string =>
|
|
101
|
+
msg(reading.source === 'psi' ? 'cli.heavy.cpu.psi' : 'cli.heavy.cpu.runnable', {
|
|
102
|
+
value: reading.source === 'psi' ? Math.round(reading.value) : reading.value,
|
|
103
|
+
limit: reading.limit,
|
|
104
|
+
});
|
package/src/heavy.ts
CHANGED
|
@@ -10,12 +10,13 @@ import { isUltimateError } from '@ultimat3/core';
|
|
|
10
10
|
import { coreCap, nativeToolEnv } from './heavy-cores';
|
|
11
11
|
import type { HeavyEnv } from './heavy-env';
|
|
12
12
|
import { HEAVY_DIR_ENV, HEAVY_HOLD_ENV, isCi } from './heavy-env';
|
|
13
|
-
import { HeavyLedgerUnavailableError } from './heavy-errors';
|
|
13
|
+
import { HeavyLedgerUnavailableError, HeavyWaitExpiredError } from './heavy-errors';
|
|
14
14
|
import type { TryLock } from './heavy-flock';
|
|
15
15
|
import { flockBinding } from './heavy-flock';
|
|
16
16
|
import type { Held, LedgerEntry, LedgerWait, Reservation } from './heavy-ledger';
|
|
17
17
|
import { isHeld, lockPath, prepareLedger, reserve } from './heavy-ledger';
|
|
18
18
|
import { ledgerCapacityMb } from './heavy-memory';
|
|
19
|
+
import { cpuGateOn, cpuText, readCpuPressure } from './heavy-pressure';
|
|
19
20
|
import { msg } from './messages';
|
|
20
21
|
import { writeErrorLine } from './write-line';
|
|
21
22
|
|
|
@@ -61,9 +62,11 @@ export async function heavyState(env: HeavyEnv): Promise<HeavyState> {
|
|
|
61
62
|
if (isCi(env)) return { on: false, off: 'ci' };
|
|
62
63
|
const explicitDir = env[HEAVY_DIR_ENV];
|
|
63
64
|
// A fixture's `x test` runs inside `bun test`, whose NODE_ENV every child inherits: queueing it
|
|
64
|
-
// behind real work would turn a test's timeout into a machine-load verdict.
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
// behind real work would turn a test's timeout into a machine-load verdict. `Bun.env` as well: a
|
|
66
|
+
// fixture calling in-process with its own small env is just as much inside the test run, and a
|
|
67
|
+
// timed-out one left its ticket at the head of the machine's queue until the worker exited.
|
|
68
|
+
const inTestRun = env['NODE_ENV'] === 'test' || Bun.env['NODE_ENV'] === 'test';
|
|
69
|
+
if (inTestRun && explicitDir === undefined) return { on: false, off: 'test-run' };
|
|
67
70
|
const capacityMb = ledgerCapacityMb(env);
|
|
68
71
|
if (capacityMb === 0) return { on: false, off: 'disabled' };
|
|
69
72
|
const binding = await flockBinding();
|
|
@@ -105,15 +108,24 @@ export const describeEntry = (entry: LedgerEntry, now: number): string =>
|
|
|
105
108
|
|
|
106
109
|
/** The waiter's one line. Stderr always: stdout may be a `--json` document. */
|
|
107
110
|
export const waitLine = (label: string, wait: LedgerWait, now: number = Date.now()): string =>
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
111
|
+
// No holder to name is the instant between two admissions, not a mystery owner.
|
|
112
|
+
msg(
|
|
113
|
+
wait.cpu !== undefined
|
|
114
|
+
? 'cli.heavy.waitingCpu'
|
|
115
|
+
: wait.holds.length === 0
|
|
116
|
+
? 'cli.heavy.waitingAdmission'
|
|
117
|
+
: 'cli.heavy.waiting',
|
|
118
|
+
{
|
|
119
|
+
label: printable(label),
|
|
120
|
+
need: wait.needMb,
|
|
121
|
+
position: wait.position,
|
|
122
|
+
queued: wait.queued,
|
|
123
|
+
used: wait.usedMb,
|
|
124
|
+
capacity: wait.capacityMb,
|
|
125
|
+
holders: wait.holds.map((entry) => describeEntry(entry, now)).join('; '),
|
|
126
|
+
cpu: wait.cpu === undefined ? '' : cpuText(wait.cpu),
|
|
127
|
+
},
|
|
128
|
+
);
|
|
117
129
|
|
|
118
130
|
// Time this process has spent queued, so a gate step's deadline can stop counting it.
|
|
119
131
|
let finishedWaitMs = 0;
|
|
@@ -145,6 +157,8 @@ export interface HeavyRequest {
|
|
|
145
157
|
readonly baseMb?: number;
|
|
146
158
|
readonly units?: number;
|
|
147
159
|
readonly minUnits?: number;
|
|
160
|
+
/** Give up after this long in the queue (`x heavy run --max-wait`). */
|
|
161
|
+
readonly maxWaitMs?: number;
|
|
148
162
|
}
|
|
149
163
|
|
|
150
164
|
/** A reservation, or nothing when admission does not apply or could not work. */
|
|
@@ -160,12 +174,16 @@ async function enter(request: HeavyRequest, state: HeavyState): Promise<Reservat
|
|
|
160
174
|
...(request.baseMb === undefined ? {} : { baseMb: request.baseMb }),
|
|
161
175
|
units: request.units ?? 1,
|
|
162
176
|
minUnits: request.minUnits ?? request.units ?? 1,
|
|
177
|
+
...(request.maxWaitMs === undefined ? {} : { maxWaitMs: request.maxWaitMs }),
|
|
178
|
+
...(cpuGateOn(request.env) ? { cpu: () => readCpuPressure() } : {}),
|
|
163
179
|
label: request.label,
|
|
164
180
|
cwd: request.cwd,
|
|
165
181
|
onWait: (wait) => writeErrorLine(waitLine(request.label, wait)),
|
|
166
182
|
}),
|
|
167
183
|
);
|
|
168
184
|
} catch (error) {
|
|
185
|
+
// The caller set this bound: running anyway, unadmitted, is what it asked not to happen.
|
|
186
|
+
if (error instanceof HeavyWaitExpiredError) throw error;
|
|
169
187
|
warnOnce(describe(error));
|
|
170
188
|
return undefined;
|
|
171
189
|
}
|
package/src/i18n-registration.ts
CHANGED
|
@@ -166,6 +166,26 @@ export async function checkRegistration(input: RegistrationInput): Promise<Regis
|
|
|
166
166
|
export const unanswered = (catalog: Catalog, keys: readonly string[]): readonly string[] =>
|
|
167
167
|
keys.filter((key) => !Object.hasOwn(catalog, key) || isLoudMiss(catalog[key]));
|
|
168
168
|
|
|
169
|
+
/**
|
|
170
|
+
* What `x i18n sync <locale>` writes for a key source names, per locale (`cmd-i18n.ts`'s
|
|
171
|
+
* `runSync`). The code's own comment said "as ⟦key⟧" of every locale and every key: a non-default
|
|
172
|
+
* locale gets the default's string marked, and an admin key in the default locale gets a real
|
|
173
|
+
* label — a reader who went looking for the ⟦ it promised found none.
|
|
174
|
+
*/
|
|
175
|
+
const SOURCE_KEYS_WRITTEN =
|
|
176
|
+
'writes each key above as a placeholder to replace with the real string: ⟦key⟧ in the default locale, ⟦the default locale’s string⟧ in any other';
|
|
177
|
+
|
|
178
|
+
/** The same, for a key a mounted admin derives (`adminCatalog`, `adminKeyLabel`). */
|
|
179
|
+
const ADMIN_KEYS_WRITTEN =
|
|
180
|
+
'writes each key above: in the default locale the label x g resource --admin generates, a real string to keep or reword; in any other locale that label inside ⟦…⟧, to translate';
|
|
181
|
+
|
|
182
|
+
/** The finding with the code's own COMMAND and a comment that is true of what it writes. */
|
|
183
|
+
function missingKeysFinding(locale: Locale, missing: readonly string[], written: string): Finding {
|
|
184
|
+
const finding = findingFrom(catalogMissingKeys(locale, missing));
|
|
185
|
+
const [command = finding.fix] = finding.fix.split(' #');
|
|
186
|
+
return { ...finding, fix: `${command} # ${written}` };
|
|
187
|
+
}
|
|
188
|
+
|
|
169
189
|
/**
|
|
170
190
|
* `X_CATALOG_MISSING_KEYS` — the same fact, a catalog without keys it is asked for — with the
|
|
171
191
|
* cause naming who asks. The fix stays the code's own, `x i18n sync <locale>`: it writes these keys
|
|
@@ -177,7 +197,7 @@ function adminKeysFinding(locale: Locale, missing: readonly string[]): Finding {
|
|
|
177
197
|
const shown = missing.slice(0, 12).map((key) => `"${key}"`);
|
|
178
198
|
const more = missing.length > shown.length ? `, +${missing.length - shown.length} more` : '';
|
|
179
199
|
return {
|
|
180
|
-
...
|
|
200
|
+
...missingKeysFinding(locale, missing, ADMIN_KEYS_WRITTEN),
|
|
181
201
|
cause: `${path} is missing ${missing.length} key(s) the mounted admin renders (defineAdmin derives them, so no source file names one): ${shown.join(', ')}${more}`,
|
|
182
202
|
at: path,
|
|
183
203
|
};
|
|
@@ -289,7 +309,7 @@ export function missingKeyFindings(report: ExtractReport): readonly Finding[] {
|
|
|
289
309
|
const missing = report.locales
|
|
290
310
|
.filter((audit) => audit.missing.length > 0)
|
|
291
311
|
.map((audit) => ({
|
|
292
|
-
...
|
|
312
|
+
...missingKeysFinding(audit.locale, audit.missing, SOURCE_KEYS_WRITTEN),
|
|
293
313
|
at: catalogPath(audit.locale),
|
|
294
314
|
}));
|
|
295
315
|
// A select or ordinal family with no `_other` renders `⟦key⟧` for every value it does not name:
|
package/src/island-harness.ts
CHANGED
|
@@ -97,8 +97,8 @@ export function harnessPage(input: HarnessPageInput): string {
|
|
|
97
97
|
timeZone: input.target.timeZone,
|
|
98
98
|
})}</script>`,
|
|
99
99
|
'</head><body>',
|
|
100
|
-
|
|
101
|
-
emitIslandProps(directive)
|
|
100
|
+
// The props script INSIDE the island's element, as the render walk writes it for a page.
|
|
101
|
+
`<div id="x-shot-frame"><div ${emitIslandAttributes(directive)}>${emitIslandProps(directive)}</div></div>`,
|
|
102
102
|
hydrateRuntime([directive]),
|
|
103
103
|
'</body></html>',
|
|
104
104
|
].join('');
|
package/src/job-budget.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
DRAIN_DEADLINE_DEFAULT_MS,
|
|
9
9
|
finiteCount,
|
|
10
10
|
isUltimateError,
|
|
11
|
+
laterHooksReserveMs,
|
|
11
12
|
WORKER_DRAIN_DEADLINE_MAX_MS,
|
|
12
13
|
WORKER_RETIRE_DEFAULT_MS,
|
|
13
14
|
} from '@ultimat3/core';
|
|
@@ -27,7 +28,8 @@ type WorkerDrain = Pick<Partial<DrainConfig>, 'deadlineMs' | 'workerDeadlineMs'
|
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* The retire when on, for it aborts nothing; else when a SIGTERM drain CANCELS a held job, which is
|
|
30
|
-
* the cut-off's `cancelAt` (`worker-drain-cutoff.ts`)
|
|
31
|
+
* the cut-off's `cancelAt` (`worker-drain-cutoff.ts`): a margin before core's in-flight wait ends,
|
|
32
|
+
* which is itself the later hooks' reserve before the deadline (`ShutdownReason.inflightUntil`).
|
|
31
33
|
*/
|
|
32
34
|
export function workerBudgetMs(drain: WorkerDrain | undefined): number {
|
|
33
35
|
// Screened here, not trusted: `defineConfig` screens an app's config, but this is exported, and a
|
|
@@ -44,7 +46,7 @@ export function workerBudgetMs(drain: WorkerDrain | undefined): number {
|
|
|
44
46
|
drain?.workerDeadlineMs ?? drain?.deadlineMs ?? DRAIN_DEADLINE_DEFAULT_MS,
|
|
45
47
|
1,
|
|
46
48
|
);
|
|
47
|
-
return cutoffTimes(deadline, 0).cancelAt;
|
|
49
|
+
return cutoffTimes(deadline, 0, deadline - laterHooksReserveMs(deadline)).cancelAt;
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
function outlastsFinding(job: BudgetedJob, limitMs: number, budgetMs: number): Finding {
|
package/src/job-registration.ts
CHANGED
|
@@ -3,17 +3,27 @@
|
|
|
3
3
|
// and every dead-letter trace — moves with the import order (`X_JOB_UNREGISTERED`). And an entity
|
|
4
4
|
// declaring `partitionBy` with no `partitions()` job registered (`X_PARTITIONS_UNMAINTAINED`).
|
|
5
5
|
|
|
6
|
+
// why: Bun ships no path API; `posix` because the fix prints an import specifier on every OS.
|
|
7
|
+
import { join, posix } from 'node:path';
|
|
6
8
|
import { ERROR_DOCS_URL } from '@ultimat3/core';
|
|
7
9
|
import {
|
|
10
|
+
isJobHandle,
|
|
8
11
|
isPartitionsJob,
|
|
12
|
+
isTaskHandle,
|
|
9
13
|
partitionedEntities,
|
|
10
14
|
registeredJobs,
|
|
11
15
|
registeredTasks,
|
|
12
16
|
} from '@ultimat3/jobs';
|
|
13
17
|
import { loadApp } from './app-load';
|
|
14
18
|
import type { AppLoader } from './app-permissions';
|
|
19
|
+
import { API_INDEX } from './app-root';
|
|
15
20
|
import type { Finding } from './output';
|
|
16
21
|
|
|
22
|
+
/** The load, plus the modules it imported: where a positional job's file is looked up. */
|
|
23
|
+
type JobAppLoader = (
|
|
24
|
+
root: string,
|
|
25
|
+
) => Promise<Awaited<ReturnType<AppLoader>> & { readonly files?: readonly string[] }>;
|
|
26
|
+
|
|
17
27
|
/** What `job()` and `task()` name a declaration nobody named (`packages/jobs/src/job.ts`). */
|
|
18
28
|
const POSITIONAL = /^anonymous-(job|task)-\d+$/;
|
|
19
29
|
|
|
@@ -24,16 +34,59 @@ export function positionalNames(
|
|
|
24
34
|
return names.filter((name) => POSITIONAL.test(name)).sort();
|
|
25
35
|
}
|
|
26
36
|
|
|
27
|
-
|
|
28
|
-
|
|
37
|
+
/** `nudge-post` → `nudgePost`: the name the import line binds, a valid identifier either way. */
|
|
38
|
+
const moduleAlias = (file: string): string => {
|
|
39
|
+
const base = posix.basename(file).replace(/\.tsx?$/, '');
|
|
40
|
+
const [head = '', ...rest] = base.split(/[^A-Za-z0-9]+/).filter((word) => word !== '');
|
|
41
|
+
const alias = [head, ...rest.map((word) => word.charAt(0).toUpperCase() + word.slice(1))].join(
|
|
42
|
+
'',
|
|
43
|
+
);
|
|
44
|
+
return /^[A-Za-z_]/.test(alias) ? alias : `module${alias}`;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/** The import the API index needs, relative to it and without the extension. */
|
|
48
|
+
const importLine = (file: string, alias: string): string => {
|
|
49
|
+
const path = posix.relative(posix.dirname(API_INDEX), file).replace(/\.tsx?$/, '');
|
|
50
|
+
return `import * as ${alias} from '${path.startsWith('.') ? path : `./${path}`}';`;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* `file` is the module exporting the job, when one does: the positional name moves between runs, so
|
|
55
|
+
* the path is the only thing that tells several agents in one checkout whose job this is.
|
|
56
|
+
*/
|
|
57
|
+
export function unregisteredJobFinding(name: string, file?: string): Finding {
|
|
58
|
+
const task = name.startsWith('anonymous-task-');
|
|
59
|
+
const alias = file === undefined ? '<module>' : moduleAlias(file);
|
|
60
|
+
const line =
|
|
61
|
+
file === undefined ? `import * as ${alias} from '<its file>';` : importLine(file, alias);
|
|
62
|
+
const where = file === undefined ? '' : ` declared in ${file}`;
|
|
29
63
|
return {
|
|
30
64
|
code: 'X_JOB_UNREGISTERED',
|
|
31
|
-
cause: `${name} is a ${
|
|
32
|
-
fix:
|
|
33
|
-
at:
|
|
65
|
+
cause: `${name}${where} is a ${task ? 'task' : 'job'} no defineApi() call names, so it carries the positional name ${task ? 'task()' : 'job()'} minted — on the queue row, in the manifest and in every dead-letter trace, and it moves when the import order does`,
|
|
66
|
+
fix: `${line} // in ${API_INDEX}, and ${alias} added to ${task ? 'tasks' : 'jobs'}: [...] there — then x manifest`,
|
|
67
|
+
at: file ?? API_INDEX,
|
|
34
68
|
};
|
|
35
69
|
}
|
|
36
70
|
|
|
71
|
+
/**
|
|
72
|
+
* Which loaded module exports each positional handle. The imports answer from the module cache: the
|
|
73
|
+
* load just evaluated these files. A handle no module exports has no file to name.
|
|
74
|
+
*/
|
|
75
|
+
async function declaringFiles(
|
|
76
|
+
root: string,
|
|
77
|
+
files: readonly string[],
|
|
78
|
+
): Promise<ReadonlyMap<string, string>> {
|
|
79
|
+
const found = new Map<string, string>();
|
|
80
|
+
for (const file of files) {
|
|
81
|
+
const module = (await import(join(root, file))) as Record<string, unknown>;
|
|
82
|
+
for (const value of Object.values(module)) {
|
|
83
|
+
if (!isJobHandle(value) && !isTaskHandle(value)) continue;
|
|
84
|
+
if (POSITIONAL.test(value.name) && !found.has(value.name)) found.set(value.name, file);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return found;
|
|
88
|
+
}
|
|
89
|
+
|
|
37
90
|
/**
|
|
38
91
|
* The step's answer. Loads the app the way every other gate step does — the registries are only
|
|
39
92
|
* whole after the scan — and says nothing when the load failed: a short registry is the load's
|
|
@@ -41,11 +94,14 @@ export function unregisteredJobFinding(name: string): Finding {
|
|
|
41
94
|
*/
|
|
42
95
|
export async function unregisteredJobFindings(
|
|
43
96
|
root: string,
|
|
44
|
-
load:
|
|
97
|
+
load: JobAppLoader = loadApp,
|
|
45
98
|
): Promise<readonly Finding[]> {
|
|
46
|
-
|
|
99
|
+
const app = await load(root);
|
|
100
|
+
if (app.findings.length > 0) return [];
|
|
101
|
+
const names = positionalNames();
|
|
102
|
+
const files = names.length === 0 ? new Map() : await declaringFiles(root, app.files ?? []);
|
|
47
103
|
return [
|
|
48
|
-
...
|
|
104
|
+
...names.map((name) => unregisteredJobFinding(name, files.get(name))),
|
|
49
105
|
...unmaintainedPartitionFindings(
|
|
50
106
|
partitionedEntities().map((described) => described.table),
|
|
51
107
|
registeredJobs(),
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// `x jobs pause|resume <queue>` names a queue this app serves. A typo paused nothing and reported
|
|
2
|
+
// success, and the runbook's next step (poll the queue until it is empty) then passed at once
|
|
3
|
+
// while the real queue kept claiming. The set is `x deploy verify`'s: config plus registered jobs.
|
|
4
|
+
|
|
5
|
+
import { nearestName, renderCauseValue, UltimateError } from '@ultimat3/core';
|
|
6
|
+
import { expectedQueues } from './deploy-verify-queues';
|
|
7
|
+
import { quoteArg } from './shell-quote';
|
|
8
|
+
|
|
9
|
+
/** The queue positional names nothing this app's workers claim from. */
|
|
10
|
+
export class JobsQueueUnknownError extends UltimateError {
|
|
11
|
+
constructor(input: { sub: 'pause' | 'resume'; queue: string; known: readonly string[] }) {
|
|
12
|
+
const nearest = nearestName(input.queue, input.known);
|
|
13
|
+
super({
|
|
14
|
+
code: 'X_CLI_BAD_FLAG',
|
|
15
|
+
cause: `"x jobs ${input.sub}" was given queue ${renderCauseValue(input.queue)}, which is not a queue of this app (${input.known.map((queue) => renderCauseValue(queue)).join(', ')}) — no worker claims from it, so the ${input.sub} would change nothing`,
|
|
16
|
+
fix:
|
|
17
|
+
nearest === undefined
|
|
18
|
+
? 'x jobs list --json # data.depth.queues names what each queue holds'
|
|
19
|
+
: ['x', 'jobs', input.sub, quoteArg(nearest), '--json'].join(' '),
|
|
20
|
+
meta: { queue: input.queue, known: [...input.known] },
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Refuses before the pause row is written. An app that will not load is "cannot tell" — its jobs'
|
|
27
|
+
* queues are the half of the set a broken module hides — and is never refused on a guess. `resume`
|
|
28
|
+
* of a queue that IS paused always passes: that row is what the command exists to clear.
|
|
29
|
+
*/
|
|
30
|
+
export async function assertQueueServed(
|
|
31
|
+
root: string,
|
|
32
|
+
sub: 'pause' | 'resume',
|
|
33
|
+
queue: string,
|
|
34
|
+
paused: readonly string[],
|
|
35
|
+
): Promise<void> {
|
|
36
|
+
if (sub === 'resume' && paused.includes(queue)) return;
|
|
37
|
+
const expected = await expectedQueues(root);
|
|
38
|
+
// An app with no module at all hides nothing: its set is the configured queues, whole.
|
|
39
|
+
if (expected.findings.some((finding) => finding.code !== 'X_APP_EMPTY')) return;
|
|
40
|
+
// Nothing configured and nothing registered is the worker's own `default`.
|
|
41
|
+
const known = expected.queues.length === 0 ? ['default'] : expected.queues;
|
|
42
|
+
if (!known.includes(queue)) throw new JobsQueueUnknownError({ sub, queue, known });
|
|
43
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// `errors.explain`'s rows for the codes of agents sharing a machine and a repository (`error-codes-
|
|
2
|
+
// agents.ts`), split out of `mcp-errors.ts` under the 500-line ceiling. Spread into `CLI_FIXES`
|
|
3
|
+
// there, whose `Record<CliErrorCode, string>` is still what makes a code without a row a build error.
|
|
4
|
+
|
|
5
|
+
import type { CliErrorCode } from './error-codes';
|
|
6
|
+
|
|
7
|
+
export const AGENTS_FIXES = {
|
|
8
|
+
X_PORT_IN_USE: 'x dev --port 3001 --json',
|
|
9
|
+
X_DEV_ALREADY_RUNNING:
|
|
10
|
+
'x dev --json # after stopping the x dev that already owns this checkout',
|
|
11
|
+
// The path, not `x dev`: the boot has already refused and rerunning it refuses again. The
|
|
12
|
+
// error's own `fix:` carries the resolved `.x/dev.lock`; this table cannot know the state dir.
|
|
13
|
+
X_DEV_LOCK_UNREADABLE: 'rm .x/dev.lock # then: x dev --json',
|
|
14
|
+
X_UPGRADE_LOCKED: 'cat .x/upgrade.lock',
|
|
15
|
+
X_HEAVY_WAIT_EXPIRED: 'x heavy status --json',
|
|
16
|
+
X_MERGE_UNRESOLVED: 'git diff --name-only --diff-filter=U',
|
|
17
|
+
X_MERGE_DRIVER_UNSET: 'bunx x merge-driver install',
|
|
18
|
+
X_CATALOG_UNPARSEABLE: 'bunx biome check packages/i18n/catalogs',
|
|
19
|
+
X_DOCTOR_PROBE_FAILED: 'bunx x manifest --json',
|
|
20
|
+
} as const satisfies Partial<Record<CliErrorCode, string>>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// `errors.explain`'s rows for the codes `error-codes-doctor.ts` owns: `x doctor`'s warnings and
|
|
2
|
+
// the upgrade's, split out of `mcp-errors.ts` under the 500-line ceiling. Spread into `CLI_FIXES`
|
|
3
|
+
// there, whose `Record<CliErrorCode, string>` makes a code without a row a build error.
|
|
4
|
+
|
|
5
|
+
import type { CliErrorCode } from './error-codes';
|
|
6
|
+
|
|
7
|
+
export const DOCTOR_FIXES = {
|
|
8
|
+
X_EXERCISE_UNPROVEN_ABOVE_FLOOR:
|
|
9
|
+
'x exercise --json # re-measures at the constant seed the gate runs (a floor from before 31.47.0 was measured under random seeds); each unproven record in .x/exercise.json names the proof and its reason: fix the seed helper or override it names, assuming no order between sized calls; the floor only falls',
|
|
10
|
+
X_ENV_NAME_RESERVED:
|
|
11
|
+
'edit app.config.ts: add an APP_ prefix to the envSchema name the finding cites (or delete it where the value is meant for the framework); then: x env example --json && x doctor --json',
|
|
12
|
+
X_FRAMEWORK_PIN_RANGE:
|
|
13
|
+
'x doctor --json # each X_FRAMEWORK_PIN_RANGE names a package.json line and the exact version: write it there, then: bun install',
|
|
14
|
+
X_VERIFY_STEP_UNFLOORED:
|
|
15
|
+
'x doctor --json # its X_VERIFY_STEP_UNFLOORED fix names the steps: run that x verify --only, then add each step that passed, not skipped, to "steps" in x.verify.json',
|
|
16
|
+
X_DB_ROW_SECURITY_OFF:
|
|
17
|
+
'database: { rowSecurity: true } # in defineConfig, app.config.ts; then: x db gen "row security" --json && x db migrate --json && x doctor --json',
|
|
18
|
+
X_DB_INDEX_UNDECLARED:
|
|
19
|
+
'x verify --only drift --json # each X_DB_INDEX_UNDECLARED warning names the index: its DROP INDEX CONCURRENTLY IF EXISTS "<name>"; goes in a new hand-written migration (-- transaction: false), or declare it in the entity\'s indexes: [...] and x db gen "<change>"',
|
|
20
|
+
X_SHIPPED_GUARD_MISSING:
|
|
21
|
+
"x doctor --json # each X_SHIPPED_GUARD_MISSING warning's fix is the command that writes its guard, then x verify --only boundaries --json",
|
|
22
|
+
X_SUPERSEDED_WORKAROUND:
|
|
23
|
+
'x doctor --json # each finding names the file, the release that retired the workaround and its replacement',
|
|
24
|
+
X_GUARD_VENDORED: 'x upgrade --json',
|
|
25
|
+
X_ADVISORY_FLOOR_UNMET: 'bun update source-map-js immutable',
|
|
26
|
+
X_UPGRADE_CODEMODS_PENDING: 'x upgrade codemods --from 0.0.0 --json',
|
|
27
|
+
} as const satisfies Partial<Record<CliErrorCode, string>>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// `errors.explain`'s rows for processes per container (`ULTIMATE_PROCESSES`) — the supervisor's
|
|
2
|
+
// family, split out of `mcp-errors.ts` under the 500-line ceiling. Spread into `CLI_FIXES` there,
|
|
3
|
+
// whose `Record<CliErrorCode, string>` is still what makes a code without a row a build error.
|
|
4
|
+
|
|
5
|
+
import type { CliErrorCode } from './error-codes';
|
|
6
|
+
|
|
7
|
+
export const PROCESSES_FIXES = {
|
|
8
|
+
X_PROCESSES_INVALID:
|
|
9
|
+
'export ULTIMATE_PROCESSES=auto # in the deploy environment of this service, or a positive whole number such as 2',
|
|
10
|
+
X_PROCESSES_ROLE_SINGLETON:
|
|
11
|
+
'export ULTIMATE_PROCESSES=1 # in the environment of the scheduler, replicator and migrate services',
|
|
12
|
+
X_PROCESSES_UNSHARED_STATE:
|
|
13
|
+
"export ULTIMATE_PROCESSES=1 # or share the state: set NATS_URL (REDIS_URL or VALKEY_URL for the cache) and drop the per-process store from the app's runtime.ts; the error lists each",
|
|
14
|
+
X_PROCESSES_OVER_POOL:
|
|
15
|
+
'export ULTIMATE_PROCESSES=1 # or raise DATABASE_POOL_MAX to at least the count; the error names both numbers',
|
|
16
|
+
X_PROCESSES_UNBALANCED: 'export ULTIMATE_PROCESSES=1 # or run the image in a Linux container',
|
|
17
|
+
X_PROCESS_CRASH_LOOP:
|
|
18
|
+
'docker compose logs --tail 200 # the last error line with the crashing child index names the boot error to fix',
|
|
19
|
+
X_PROCESSES_CPU_UNDECLARED:
|
|
20
|
+
"cpus: '2' # on the role's service in docker/docker-compose.prod.yml",
|
|
21
|
+
X_PROCESSES_MIGRATE_REQ_OFF:
|
|
22
|
+
'sysctls: { net.ipv4.tcp_migrate_req: 1 } # uncomment it on web and sync in docker/docker-compose.prod.yml; Linux >= 5.14 only, an older kernel refuses to create the container',
|
|
23
|
+
} as const satisfies Partial<Record<CliErrorCode, string>>;
|
package/src/mcp-errors.ts
CHANGED
|
@@ -7,6 +7,9 @@ import type { ErrorExplanation } from '@ultimat3/mcp';
|
|
|
7
7
|
import type { CliErrorCode } from './error-codes';
|
|
8
8
|
import { CLI_ERROR_CODES } from './error-codes';
|
|
9
9
|
import { codeFixes, codeFixScan } from './error-fixes';
|
|
10
|
+
import { AGENTS_FIXES } from './mcp-errors-agents';
|
|
11
|
+
import { DOCTOR_FIXES } from './mcp-errors-doctor';
|
|
12
|
+
import { PROCESSES_FIXES } from './mcp-errors-processes';
|
|
10
13
|
import { SHOT_FIXES } from './mcp-errors-shot';
|
|
11
14
|
import { VERIFY_FIXES } from './mcp-errors-verify';
|
|
12
15
|
|
|
@@ -61,7 +64,12 @@ const CLI_FIXES: Readonly<Record<CliErrorCode, string>> = {
|
|
|
61
64
|
X_PACKAGE_DUPLICATED:
|
|
62
65
|
'x i18n check --json # the finding names both copies and the package.json to pin',
|
|
63
66
|
// `x shot` and the `ui.*` tools: their own family, in `mcp-errors-shot.ts`.
|
|
67
|
+
...AGENTS_FIXES,
|
|
64
68
|
...SHOT_FIXES,
|
|
69
|
+
// `x doctor`'s warnings and `x upgrade`'s: their own family, in `mcp-errors-doctor.ts`.
|
|
70
|
+
...DOCTOR_FIXES,
|
|
71
|
+
// `ULTIMATE_PROCESSES`: their own family, in `mcp-errors-processes.ts`.
|
|
72
|
+
...PROCESSES_FIXES,
|
|
65
73
|
// The gate's floor, run and split: their own family, in `mcp-errors-verify.ts`.
|
|
66
74
|
...VERIFY_FIXES,
|
|
67
75
|
X_GH_UNAVAILABLE: 'gh auth login # install first from https://cli.github.com',
|
|
@@ -77,8 +85,8 @@ const CLI_FIXES: Readonly<Record<CliErrorCode, string>> = {
|
|
|
77
85
|
'x verify --json # the finding names the file, the line and the name it could not resolve',
|
|
78
86
|
X_ERROR_CODE_UNTHROWN: 'x errors explain X_ERROR_CODE_UNTHROWN --json',
|
|
79
87
|
X_CLI_UNEXPECTED: 'x doctor --json',
|
|
80
|
-
//
|
|
81
|
-
X_TYPECHECK_FAILED: '
|
|
88
|
+
// The step and not raw `tsc`: it queues in the machine ledger and takes the compiler lock.
|
|
89
|
+
X_TYPECHECK_FAILED: 'x verify --only typecheck --json',
|
|
82
90
|
X_LINT_FAILED: 'bunx @biomejs/biome check .',
|
|
83
91
|
X_TEST_FAILED: 'x test --json # the finding carries the exact bun test invocation that failed',
|
|
84
92
|
X_FILE_TOO_LONG: 'x verify --json # the finding names the file to split',
|
|
@@ -137,12 +145,6 @@ const CLI_FIXES: Readonly<Record<CliErrorCode, string>> = {
|
|
|
137
145
|
'x new my-app --json # a name with letters or digits; it becomes the directory',
|
|
138
146
|
X_APP_EMPTY:
|
|
139
147
|
'x doctor --json # then check the app root: no module under apps/ or packages/ loaded',
|
|
140
|
-
X_PORT_IN_USE: 'x dev --port 3001 --json',
|
|
141
|
-
X_DEV_ALREADY_RUNNING:
|
|
142
|
-
'x dev --json # after stopping the x dev that already owns this checkout',
|
|
143
|
-
// The path, not `x dev`: the boot has already refused and rerunning it refuses again. The
|
|
144
|
-
// error's own `fix:` carries the resolved `.x/dev.lock`; this table cannot know the state dir.
|
|
145
|
-
X_DEV_LOCK_UNREADABLE: 'rm .x/dev.lock # then: x dev --json',
|
|
146
148
|
// `x doctor`, not `x db status`: generation failing is a reachability question, and `x db status`
|
|
147
149
|
// reads the migration ledger only. `x doctor` is already this table's answer for
|
|
148
150
|
// X_DB_STUDIO_FAILED.
|
|
@@ -327,7 +329,7 @@ const CLI_FIXES: Readonly<Record<CliErrorCode, string>> = {
|
|
|
327
329
|
X_REPRO_CAPTURE_OFF:
|
|
328
330
|
'x jobs list --json # a job id replays with capture off; for requests set failureCapture: { enabled: true } in app.config.ts',
|
|
329
331
|
X_ENTITY_RETAIN_UNSWEPT:
|
|
330
|
-
"add export const retention = purge({ entities: 'declared' }) to a jobs module named in jobs: [...] in apps/web/api/index.ts, then x
|
|
332
|
+
"add export const retention = purge({ entities: 'declared' }) to a jobs module named in jobs: [...] in apps/web/api/index.ts, then x manifest",
|
|
331
333
|
X_NEW_SHAPE_UNKNOWN: 'bunx @ultimat3/cli help new',
|
|
332
334
|
X_NEW_SHAPE_CONFLICT: 'bunx @ultimat3/cli new myapp --shape blog',
|
|
333
335
|
X_SEO_CARD_ROUTE_UNKNOWN:
|
|
@@ -368,24 +370,10 @@ const CLI_FIXES: Readonly<Record<CliErrorCode, string>> = {
|
|
|
368
370
|
"native: { success: (output) => '/where-it-lands' } in the action's declaration, then x verify --only manifest",
|
|
369
371
|
X_ASSET_RETAIN_UNDECLARED:
|
|
370
372
|
"edit app.config.ts: add assets: { retain: { disk: 'assets', builds: 3 } }, naming a disk your defineStorage({ disks }) declares that every web pod reads",
|
|
371
|
-
X_EXERCISE_UNPROVEN_ABOVE_FLOOR:
|
|
372
|
-
'x exercise --json # re-measures at the constant seed the gate runs (a floor from before 31.47.0 was measured under random seeds); each unproven record in .x/exercise.json names the proof and its reason: fix the seed helper or override it names, assuming no order between sized calls; the floor only falls',
|
|
373
|
-
X_ENV_NAME_RESERVED:
|
|
374
|
-
'edit app.config.ts: add an APP_ prefix to the envSchema name the finding cites (or delete it where the value is meant for the framework); then: x env example --json && x doctor --json',
|
|
375
|
-
X_FRAMEWORK_PIN_RANGE:
|
|
376
|
-
'x doctor --json # each X_FRAMEWORK_PIN_RANGE names a package.json line and the exact version: write it there, then: bun install',
|
|
377
|
-
X_VERIFY_STEP_UNFLOORED:
|
|
378
|
-
'x doctor --json # its X_VERIFY_STEP_UNFLOORED fix names the steps: run that x verify --only, then add each step that passed, not skipped, to "steps" in x.verify.json',
|
|
379
|
-
X_DB_ROW_SECURITY_OFF:
|
|
380
|
-
'database: { rowSecurity: true } # in defineConfig, app.config.ts; then: x db gen "row security" --json && x db migrate --json && x doctor --json',
|
|
381
373
|
X_DEV_DATA_UNOPENABLE:
|
|
382
374
|
'x db migrate --json # the fresh database has no tables yet; then x db seed --json if the app declares a seed. The moved directory (meta.aside) is kept: delete it once its rows are not needed',
|
|
383
375
|
X_EXPLAIN_PRODUCTION_DATABASE:
|
|
384
376
|
'env -u DATABASE_URL x queries list --json # then the same prefix on x explain <query> --json: it plans on the embedded dev database; for a copy of production data, point DATABASE_URL at a staging restore with ULTIMATE_ENV=staging',
|
|
385
|
-
X_DB_INDEX_UNDECLARED:
|
|
386
|
-
'x verify --only drift --json # each X_DB_INDEX_UNDECLARED warning names the index: its DROP INDEX CONCURRENTLY IF EXISTS "<name>"; goes in a new hand-written migration (-- transaction: false), or declare it in the entity\'s indexes: [...] and x db gen "<change>"',
|
|
387
|
-
X_SHIPPED_GUARD_MISSING:
|
|
388
|
-
"x doctor --json # each X_SHIPPED_GUARD_MISSING warning's fix is the command that writes its guard, then x verify --only boundaries --json",
|
|
389
377
|
X_DEV_LOG_ABSENT:
|
|
390
378
|
'x dev --json # the dev server writes the dev log as it boots; then: x logs tail --json',
|
|
391
379
|
X_DEV_PEER_REFUSED:
|
|
@@ -393,20 +381,18 @@ const CLI_FIXES: Readonly<Record<CliErrorCode, string>> = {
|
|
|
393
381
|
X_PROFILE_ROUTE_FAILED: 'x routes --json',
|
|
394
382
|
X_ROWS_SLICE_ENTITY:
|
|
395
383
|
'x help g --json # then generate a job with the name and feature the finding names, and declare exportRows/importRows in it over the table that entity.ts declares',
|
|
396
|
-
X_SUPERSEDED_WORKAROUND:
|
|
397
|
-
'x doctor --json # each finding names the file, the release that retired the workaround and its replacement',
|
|
398
|
-
X_GUARD_VENDORED: 'x upgrade --json',
|
|
399
384
|
X_GUARD_BUILT_IN:
|
|
400
385
|
'x verify --only boundaries --json # set its severity in guards/shipped.json, or generate an app guard under another name',
|
|
401
386
|
X_REPRO_BUNDLE_INVALID:
|
|
402
387
|
'x repro --json # lists the failing jobs and error groups; then run it again with one id and --bundle, and attach the file it writes',
|
|
403
|
-
X_ADVISORY_FLOOR_UNMET: 'bun update source-map-js immutable',
|
|
404
|
-
X_UPGRADE_CODEMODS_PENDING: 'x upgrade codemods --from 0.0.0 --json',
|
|
405
|
-
X_UPGRADE_LOCKED: 'cat .x/upgrade.lock',
|
|
406
388
|
X_APP_MIGRATIONS_UNAPPLIED: 'x db migrate --json',
|
|
407
389
|
X_HEAVY_LEDGER_UNAVAILABLE: 'x heavy status --json',
|
|
408
390
|
X_HEAVY_MEMORY_INVALID: 'export ULTIMATE_HEAVY_MEMORY=8g',
|
|
409
391
|
X_HEAVY_COMMAND_NOT_FOUND: 'x heavy run --json -- bun test',
|
|
392
|
+
// `X_SEED_ENVIRONMENT`'s form: which task to consent to is what this table cannot know, and the
|
|
393
|
+
// raised error's own `fix:` carries the named invocation; `ULTIMATE_TASK_RUN` stays in the cause.
|
|
394
|
+
X_TASK_RUN_PRODUCTION:
|
|
395
|
+
'x tasks list --json # then name the task: x tasks run <name> --production --json',
|
|
410
396
|
};
|
|
411
397
|
|
|
412
398
|
const isCliCode = (code: string): code is CliErrorCode =>
|
package/src/mcp-host.ts
CHANGED
|
@@ -40,7 +40,7 @@ import { appManifest, policyFacts } from './app-manifest';
|
|
|
40
40
|
import { loadAppRuntime } from './app-runtime';
|
|
41
41
|
import { loadAppGraph, resolveNode } from './cmd-graph-load';
|
|
42
42
|
import { declareDevEnvironment, needsDevEnvironmentDeclaration } from './dev-environment';
|
|
43
|
-
import {
|
|
43
|
+
import { liveDevLockChecked } from './dev-lock-live';
|
|
44
44
|
import { loadCodeFixes } from './error-fixes';
|
|
45
45
|
import type { Runner } from './exec';
|
|
46
46
|
import { assertExplainTarget, devNotRunning, narrowVerify, searchDocs } from './mcp-agent-host';
|
|
@@ -253,7 +253,7 @@ function capabilities(
|
|
|
253
253
|
|
|
254
254
|
async requestStatements(ask) {
|
|
255
255
|
// The lock `x dev` writes names its URL; a missing or stale one is no server to ask.
|
|
256
|
-
const lock =
|
|
256
|
+
const lock = await liveDevLockChecked(lazy.services.stateDir);
|
|
257
257
|
if (lock === undefined) throw devNotRunning();
|
|
258
258
|
return requestStatements({ devUrl: lock.url, ...ask });
|
|
259
259
|
},
|