@ultimat3/cli 31.47.1 → 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 +100 -19
- 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 +36 -0
- package/src/cmd-heavy.ts +244 -0
- 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 +15 -4
- package/src/cmd-upgrade-spec.ts +8 -1
- package/src/cmd-upgrade.ts +32 -5
- 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 +26 -0
- package/src/codemods/docs-worker-commands.ts +26 -0
- package/src/codemods/index.ts +6 -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-advisory-floors.ts +30 -8
- 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 +11 -3
- package/src/error-codes.ts +12 -13
- package/src/errors-suite.ts +27 -0
- package/src/errors.ts +18 -22
- package/src/exec.ts +11 -3
- 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-cores.ts +51 -0
- package/src/heavy-env.ts +21 -0
- package/src/heavy-errors.ts +54 -0
- package/src/heavy-flock.ts +73 -0
- package/src/heavy-holders.ts +78 -0
- package/src/heavy-ledger.ts +400 -0
- package/src/heavy-memory.ts +67 -0
- package/src/heavy-pressure.ts +104 -0
- package/src/heavy-weights.ts +47 -0
- package/src/heavy.ts +308 -0
- 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/local-cli.ts +6 -5
- 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 +18 -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 +62 -1
- 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 +4 -0
- package/src/retain-sweep.ts +1 -1
- package/src/role-replicator.ts +9 -4
- 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 +56 -18
- 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-overrides.ts +4 -2
- 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 +59 -13
- 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-agents.ts +9 -6
- package/src/templates/scaffold-claude-commands.ts +7 -1
- package/src/templates/scaffold-claude.ts +4 -4
- package/src/templates/scaffold-container-compose.ts +47 -7
- package/src/templates/scaffold-docs.ts +11 -6
- 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-batches.ts +9 -3
- package/src/test-shards.ts +117 -37
- package/src/test-slots.ts +35 -161
- 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 +6 -11
- package/src/verify-coverage-run.ts +9 -5
- package/src/verify-deadline.ts +18 -2
- package/src/verify-heavy-steps.ts +26 -0
- 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 +9 -9
- package/src/verify-tests.ts +35 -22
- 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/Building-Your-Own-Base.md +15 -2
- package/wiki/CI-Parallel-Gate.md +4 -4
- package/wiki/CLI-Reference.md +127 -48
- package/wiki/Caching-And-Invalidation.md +2 -2
- package/wiki/Client-Navigation.md +1 -1
- package/wiki/Configuration.md +32 -13
- 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 +2 -1
- package/wiki/I18n.md +5 -3
- package/wiki/Installation.md +12 -11
- package/wiki/Interface-Rules.md +1 -1
- package/wiki/Jobs-And-Workflows.md +24 -4
- package/wiki/Known-Gaps.md +2 -2
- package/wiki/MCP-And-AI.md +8 -5
- package/wiki/Mail.md +1 -1
- package/wiki/Many-Agents.md +127 -0
- 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 +12 -9
- package/wiki/Timezones-And-Dates.md +5 -1
- package/wiki/Troubleshooting.md +1 -0
- package/wiki/Tutorial-01-First-App.md +5 -5
- 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,54 @@
|
|
|
1
|
+
// The supervisor at work: `METRICS_PORT` opened for the whole container first, then the children,
|
|
2
|
+
// until they are gone — answering the container's exit code. Loaded by `runRole` only when the
|
|
3
|
+
// resolved count is more than one, so a lone process never evaluates it.
|
|
4
|
+
|
|
5
|
+
import type { Role } from '@ultimat3/core';
|
|
6
|
+
import { drainDeadlineMs, readinessGraceMs } from '@ultimat3/core';
|
|
7
|
+
import { containerBinding, metricsPortFor, portFromEnv } from './serve-env';
|
|
8
|
+
import type { ServeOptions } from './serve-types';
|
|
9
|
+
import type { SuperviseInput, Supervisor, SupervisorView } from './supervise';
|
|
10
|
+
import { supervise } from './supervise';
|
|
11
|
+
import { containerPool } from './supervise-pool';
|
|
12
|
+
import { childHealthy, startSupervisorProbe } from './supervise-probe';
|
|
13
|
+
|
|
14
|
+
/** The process seams `supervise()` defaults to the real ones: a test hands in fakes. */
|
|
15
|
+
export type SupervisedSeams = Pick<SuperviseInput, 'spawn' | 'signals' | 'timers'>;
|
|
16
|
+
|
|
17
|
+
/** Runs `count` children of this very entry point; answers the container's exit code. */
|
|
18
|
+
export async function runSupervised(
|
|
19
|
+
options: ServeOptions,
|
|
20
|
+
role: Role,
|
|
21
|
+
count: number,
|
|
22
|
+
seams: SupervisedSeams = {},
|
|
23
|
+
): Promise<number> {
|
|
24
|
+
let supervisor: Supervisor | undefined;
|
|
25
|
+
const view: SupervisorView = {
|
|
26
|
+
children: () => supervisor?.view.children() ?? [],
|
|
27
|
+
ready: () => supervisor?.view.ready() ?? false,
|
|
28
|
+
live: () => supervisor?.view.live() ?? true,
|
|
29
|
+
};
|
|
30
|
+
const port = options.port ?? portFromEnv(options.env);
|
|
31
|
+
// FIRST, as a lone process opens its own: the platform's probes find a socket from the start.
|
|
32
|
+
const probe = startSupervisorProbe({
|
|
33
|
+
port: metricsPortFor(options.env, port, options.metricsPort),
|
|
34
|
+
hostname: containerBinding(options.env, options.hostname).hostname,
|
|
35
|
+
role,
|
|
36
|
+
view,
|
|
37
|
+
});
|
|
38
|
+
try {
|
|
39
|
+
supervisor = supervise({
|
|
40
|
+
...seams,
|
|
41
|
+
count,
|
|
42
|
+
role,
|
|
43
|
+
// The role this process resolved, whatever `options.role` overrode: a child re-reads `ROLE`.
|
|
44
|
+
env: { ...options.env, ROLE: role },
|
|
45
|
+
pool: containerPool(options, role),
|
|
46
|
+
// Until each child reports its own: the framework default, which an app may only raise.
|
|
47
|
+
budgetMs: readinessGraceMs() + drainDeadlineMs(),
|
|
48
|
+
healthy: childHealthy,
|
|
49
|
+
});
|
|
50
|
+
return await supervisor.done;
|
|
51
|
+
} finally {
|
|
52
|
+
probe.stop();
|
|
53
|
+
}
|
|
54
|
+
}
|
package/src/supervise.ts
ADDED
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
// One production container as N child processes on one port: spawn them, restart a crashed one
|
|
2
|
+
// with backoff, forward the platform's signals, bound their drain, and answer one exit code. The
|
|
3
|
+
// shape is `dev-supervisor.ts`'s — `Bun.spawn` with an `ipc` child — plus what production needs.
|
|
4
|
+
|
|
5
|
+
import type { Role } from '@ultimat3/core';
|
|
6
|
+
import { childShare, logger } from '@ultimat3/core';
|
|
7
|
+
import { POOL_MAX_ENV } from '@ultimat3/db';
|
|
8
|
+
import { ProcessCrashLoopError } from './supervise-errors';
|
|
9
|
+
import type { DrainMessage, DrainSignal } from './supervise-messages';
|
|
10
|
+
import { drainMessage, readChildMessage } from './supervise-messages';
|
|
11
|
+
import {
|
|
12
|
+
afterCrash,
|
|
13
|
+
aggregateExit,
|
|
14
|
+
CRASH_WINDOW_MS,
|
|
15
|
+
type CrashHistory,
|
|
16
|
+
NO_CRASHES,
|
|
17
|
+
} from './supervise-policy';
|
|
18
|
+
|
|
19
|
+
/** Set on each child: `<index>/<count>` (`supervisedChild` in `@ultimat3/core` reads it). */
|
|
20
|
+
export const CHILD_ENV = 'ULTIMATE_CHILD';
|
|
21
|
+
/** Past a child's own drain bound, from its `draining` ack, before it is SIGKILLed. */
|
|
22
|
+
export const CHILD_DRAIN_SLACK_MS = 2_000;
|
|
23
|
+
/** Past the longest bound, from the signal: a CPU-saturated child acks up to 5.2 s late. */
|
|
24
|
+
export const OUTER_SLACK_MS = 6_000;
|
|
25
|
+
/** A child's loopback `/healthz`, asked this often once it is ready. */
|
|
26
|
+
export const HEALTH_POLL_MS = 5_000;
|
|
27
|
+
/**
|
|
28
|
+
* Failed polls in a row before a child is restarted by drain: three polls span 10 s, past the
|
|
29
|
+
* 1.9–5.2 s a CPU-saturated child was measured to answer late — busy is not dead.
|
|
30
|
+
*/
|
|
31
|
+
export const HEALTH_FAILURES = 3;
|
|
32
|
+
|
|
33
|
+
export interface ChildHandle {
|
|
34
|
+
readonly pid: number;
|
|
35
|
+
/** The exit code, or `null` for a child a signal killed. */
|
|
36
|
+
readonly exited: Promise<number | null>;
|
|
37
|
+
kill(signal: DrainSignal | 'SIGKILL'): void;
|
|
38
|
+
send(message: DrainMessage): void;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type SpawnChild = (input: {
|
|
42
|
+
readonly index: number;
|
|
43
|
+
readonly env: Record<string, string | undefined>;
|
|
44
|
+
readonly onMessage: (message: unknown) => void;
|
|
45
|
+
}) => ChildHandle;
|
|
46
|
+
|
|
47
|
+
export interface SupervisorTimers {
|
|
48
|
+
now(): number;
|
|
49
|
+
setTimeout(run: () => void, ms: number): unknown;
|
|
50
|
+
clearTimeout(handle: unknown): void;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export type SignalName = DrainSignal | 'exit';
|
|
54
|
+
export interface SignalHub {
|
|
55
|
+
on(signal: SignalName, listener: () => void): void;
|
|
56
|
+
off(signal: SignalName, listener: () => void): void;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export type ChildState = 'starting' | 'ready' | 'draining' | 'waiting' | 'exited';
|
|
60
|
+
|
|
61
|
+
export interface ChildView {
|
|
62
|
+
readonly index: number;
|
|
63
|
+
readonly state: ChildState;
|
|
64
|
+
readonly metricsUrl: string | undefined;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface SupervisorView {
|
|
68
|
+
children(): readonly ChildView[];
|
|
69
|
+
/** At least one child ready, every other one ready or draining, and the container not stopping. */
|
|
70
|
+
ready(): boolean;
|
|
71
|
+
/** Alive and not giving up on a crash loop. */
|
|
72
|
+
live(): boolean;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface SuperviseInput {
|
|
76
|
+
readonly count: number;
|
|
77
|
+
readonly role: Role;
|
|
78
|
+
readonly env: Readonly<Record<string, string | undefined>>;
|
|
79
|
+
/** The container's pool, split across the children (`childShare`). */
|
|
80
|
+
readonly pool: number;
|
|
81
|
+
/** A child's drain bound until it reports its own (`ready`/`draining`). */
|
|
82
|
+
readonly budgetMs: number;
|
|
83
|
+
readonly spawn?: SpawnChild;
|
|
84
|
+
readonly timers?: SupervisorTimers;
|
|
85
|
+
readonly signals?: SignalHub;
|
|
86
|
+
/** Whether a child's loopback `/healthz` answers 200 (`childHealthy` in `supervise-probe.ts`). */
|
|
87
|
+
readonly healthy?: (metricsUrl: string) => Promise<boolean>;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface Supervisor {
|
|
91
|
+
readonly view: SupervisorView;
|
|
92
|
+
/** The container's exit code: 0, 70 (a child's drain timed out or was killed), 1 (crash loop). */
|
|
93
|
+
readonly done: Promise<number>;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
interface Slot {
|
|
97
|
+
readonly index: number;
|
|
98
|
+
state: ChildState;
|
|
99
|
+
child: ChildHandle | undefined;
|
|
100
|
+
metricsUrl: string | undefined;
|
|
101
|
+
budgetMs: number;
|
|
102
|
+
startedAt: number;
|
|
103
|
+
history: CrashHistory;
|
|
104
|
+
timers: unknown[];
|
|
105
|
+
failures: number;
|
|
106
|
+
killed: boolean;
|
|
107
|
+
exit: number | null;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const spawnBun: SpawnChild = ({ env, onMessage }) => {
|
|
111
|
+
// A server child has no deadline of its own: its bound is the supervisor's, and a hard kill at
|
|
112
|
+
// that bound is this abort — the drain's ceiling, or a child that would not drain.
|
|
113
|
+
const bound = new AbortController();
|
|
114
|
+
const proc = Bun.spawn([process.execPath, ...process.argv.slice(1)], {
|
|
115
|
+
env,
|
|
116
|
+
stdin: 'ignore',
|
|
117
|
+
stdout: 'inherit',
|
|
118
|
+
stderr: 'inherit',
|
|
119
|
+
serialization: 'json',
|
|
120
|
+
ipc: (message) => onMessage(message),
|
|
121
|
+
signal: bound.signal,
|
|
122
|
+
killSignal: 'SIGKILL',
|
|
123
|
+
});
|
|
124
|
+
return {
|
|
125
|
+
pid: proc.pid,
|
|
126
|
+
exited: proc.exited.then(() => (proc.signalCode === null ? proc.exitCode : null)),
|
|
127
|
+
kill: (signal) => (signal === 'SIGKILL' ? bound.abort() : proc.kill(signal)),
|
|
128
|
+
send: (message) => {
|
|
129
|
+
proc.send(message);
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const realTimers: SupervisorTimers = {
|
|
135
|
+
now: () => performance.now(),
|
|
136
|
+
setTimeout: (run, ms) => setTimeout(run, ms),
|
|
137
|
+
clearTimeout: (handle) => clearTimeout(handle as ReturnType<typeof setTimeout>),
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const processSignals: SignalHub = {
|
|
141
|
+
on: (signal, listener) => process.on(signal, listener),
|
|
142
|
+
off: (signal, listener) => process.off(signal, listener),
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const say = (level: 'info' | 'warn' | 'error', msg: string, fields: Record<string, unknown>) =>
|
|
146
|
+
logger[level](msg, { child: 'supervisor', ...fields });
|
|
147
|
+
|
|
148
|
+
export function supervise(input: SuperviseInput): Supervisor {
|
|
149
|
+
const spawn = input.spawn ?? spawnBun;
|
|
150
|
+
const timers = input.timers ?? realTimers;
|
|
151
|
+
const signals = input.signals ?? processSignals;
|
|
152
|
+
const slots: Slot[] = Array.from({ length: input.count }, (_, index) => ({
|
|
153
|
+
index,
|
|
154
|
+
state: 'waiting',
|
|
155
|
+
child: undefined,
|
|
156
|
+
metricsUrl: undefined,
|
|
157
|
+
budgetMs: input.budgetMs,
|
|
158
|
+
startedAt: 0,
|
|
159
|
+
history: NO_CRASHES,
|
|
160
|
+
timers: [],
|
|
161
|
+
failures: 0,
|
|
162
|
+
killed: false,
|
|
163
|
+
exit: null,
|
|
164
|
+
}));
|
|
165
|
+
let stopping: DrainSignal | undefined;
|
|
166
|
+
let ceiling: unknown;
|
|
167
|
+
let killedAtCeiling = false;
|
|
168
|
+
let failure: ProcessCrashLoopError | 'fatal' | undefined;
|
|
169
|
+
let finished = false;
|
|
170
|
+
let resolve!: (code: number) => void;
|
|
171
|
+
const done = new Promise<number>((settle) => {
|
|
172
|
+
resolve = settle;
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
// Only PENDING handles stay on the slot: a fired one leaves it, or a healthy child's polls
|
|
176
|
+
// (one per HEALTH_POLL_MS) would pile up until its next exit.
|
|
177
|
+
const later = (slot: Slot, ms: number, run: () => void): void => {
|
|
178
|
+
const handle = timers.setTimeout(() => {
|
|
179
|
+
const at = slot.timers.indexOf(handle);
|
|
180
|
+
if (at !== -1) slot.timers.splice(at, 1);
|
|
181
|
+
run();
|
|
182
|
+
}, ms);
|
|
183
|
+
slot.timers.push(handle);
|
|
184
|
+
};
|
|
185
|
+
const clear = (slot: Slot): void => {
|
|
186
|
+
for (const handle of slot.timers.splice(0)) timers.clearTimeout(handle);
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
/** Once per child: both bounds can land on one tick. Only a stop's kill makes the exit 70. */
|
|
190
|
+
const killHard = (slot: Slot, msg: string): void => {
|
|
191
|
+
if (slot.child === undefined || slot.killed) return;
|
|
192
|
+
slot.killed = true;
|
|
193
|
+
if (stopping !== undefined) killedAtCeiling = true;
|
|
194
|
+
say('warn', msg, { index: slot.index });
|
|
195
|
+
slot.child.kill('SIGKILL');
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
const finishIfGone = (): void => {
|
|
199
|
+
if (finished || stopping === undefined || slots.some((slot) => slot.child !== undefined))
|
|
200
|
+
return;
|
|
201
|
+
finished = true;
|
|
202
|
+
for (const [signal, listener] of handlers) signals.off(signal, listener);
|
|
203
|
+
timers.clearTimeout(ceiling);
|
|
204
|
+
const code =
|
|
205
|
+
failure !== undefined
|
|
206
|
+
? 1
|
|
207
|
+
: aggregateExit(
|
|
208
|
+
slots.map((slot) => slot.exit),
|
|
209
|
+
killedAtCeiling,
|
|
210
|
+
);
|
|
211
|
+
say(code === 0 ? 'info' : 'warn', 'ultimate processes stopped', { code });
|
|
212
|
+
resolve(code);
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* One stop per container. A retire (SIGUSR2, worker only) may be followed by the platform's
|
|
217
|
+
* SIGTERM, which is forwarded and arms the ceiling; anything after that is the same stop.
|
|
218
|
+
*/
|
|
219
|
+
const stop = (signal: DrainSignal): void => {
|
|
220
|
+
const upgrade = stopping === 'SIGUSR2' && signal !== 'SIGUSR2';
|
|
221
|
+
if (stopping !== undefined && !upgrade) return;
|
|
222
|
+
stopping = signal;
|
|
223
|
+
for (const slot of slots) {
|
|
224
|
+
if (slot.child === undefined) {
|
|
225
|
+
clear(slot);
|
|
226
|
+
slot.state = 'exited';
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
slot.child.kill(signal);
|
|
230
|
+
}
|
|
231
|
+
// A retire (SIGUSR2) is bounded by the platform's own kill timer; a stop by ours.
|
|
232
|
+
if (signal !== 'SIGUSR2') {
|
|
233
|
+
const longest = Math.max(input.budgetMs, ...slots.map((slot) => slot.budgetMs));
|
|
234
|
+
ceiling = timers.setTimeout(() => {
|
|
235
|
+
for (const slot of slots) killHard(slot, 'ultimate child killed at the drain ceiling');
|
|
236
|
+
}, longest + OUTER_SLACK_MS);
|
|
237
|
+
}
|
|
238
|
+
finishIfGone();
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
const onMessage = (slot: Slot, raw: unknown): void => {
|
|
242
|
+
const message = readChildMessage(raw);
|
|
243
|
+
if (message === undefined) return;
|
|
244
|
+
if (message.event === 'ready') {
|
|
245
|
+
if (slot.state === 'starting') slot.state = 'ready';
|
|
246
|
+
slot.metricsUrl = message.metricsUrl;
|
|
247
|
+
slot.budgetMs = message.budgetMs;
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
if (message.event === 'draining') {
|
|
251
|
+
slot.state = 'draining';
|
|
252
|
+
slot.budgetMs = message.budgetMs;
|
|
253
|
+
// The child's own bound starts at its ack: a saturated child hears the signal seconds late.
|
|
254
|
+
later(slot, message.budgetMs + CHILD_DRAIN_SLACK_MS, () =>
|
|
255
|
+
killHard(slot, 'ultimate child killed past its drain bound'),
|
|
256
|
+
);
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
if (message.event === 'fatal') {
|
|
260
|
+
failure = 'fatal';
|
|
261
|
+
say('error', 'ultimate child refused to serve', { index: slot.index, code: message.code });
|
|
262
|
+
stop('SIGTERM');
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
const onExit = (slot: Slot, code: number | null): void => {
|
|
267
|
+
clear(slot);
|
|
268
|
+
slot.child = undefined;
|
|
269
|
+
slot.metricsUrl = undefined;
|
|
270
|
+
slot.exit = code;
|
|
271
|
+
if (stopping !== undefined) {
|
|
272
|
+
slot.state = 'exited';
|
|
273
|
+
finishIfGone();
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
const now = timers.now();
|
|
277
|
+
const decision = afterCrash(slot.history, now, now - slot.startedAt);
|
|
278
|
+
slot.history = decision.history;
|
|
279
|
+
if (decision.loop) {
|
|
280
|
+
const error = new ProcessCrashLoopError({
|
|
281
|
+
index: slot.index,
|
|
282
|
+
code,
|
|
283
|
+
crashes: decision.history.at.length,
|
|
284
|
+
windowMs: CRASH_WINDOW_MS,
|
|
285
|
+
});
|
|
286
|
+
failure = error;
|
|
287
|
+
say('error', error.code, { code: error.code, cause: error.cause, fix: error.fix });
|
|
288
|
+
stop('SIGTERM');
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
slot.state = 'waiting';
|
|
292
|
+
say('warn', 'ultimate child exited', {
|
|
293
|
+
index: slot.index,
|
|
294
|
+
exitCode: code,
|
|
295
|
+
restartInMs: decision.delayMs,
|
|
296
|
+
});
|
|
297
|
+
later(slot, decision.delayMs, () => start(slot));
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
const poll = (slot: Slot, child: ChildHandle): void => {
|
|
301
|
+
later(slot, HEALTH_POLL_MS, () => {
|
|
302
|
+
if (slot.child !== child || stopping !== undefined) return;
|
|
303
|
+
const url = slot.metricsUrl;
|
|
304
|
+
if (slot.state !== 'ready' || url === undefined || input.healthy === undefined) {
|
|
305
|
+
poll(slot, child);
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
void input.healthy(url).then((ok) => {
|
|
309
|
+
if (slot.child !== child) return;
|
|
310
|
+
slot.failures = ok ? 0 : slot.failures + 1;
|
|
311
|
+
if (slot.failures >= HEALTH_FAILURES) {
|
|
312
|
+
say('warn', 'ultimate child unhealthy, restarting it', { index: slot.index });
|
|
313
|
+
slot.state = 'draining';
|
|
314
|
+
child.send(drainMessage('SIGTERM'));
|
|
315
|
+
// A child too wedged to ack is bounded as a stop is: its exit is then restarted.
|
|
316
|
+
later(slot, slot.budgetMs + OUTER_SLACK_MS, () =>
|
|
317
|
+
killHard(slot, 'ultimate child killed: it did not drain after failing its health'),
|
|
318
|
+
);
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
poll(slot, child);
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
const start = (slot: Slot): void => {
|
|
327
|
+
if (stopping !== undefined) return;
|
|
328
|
+
const child = spawn({
|
|
329
|
+
index: slot.index,
|
|
330
|
+
env: {
|
|
331
|
+
...input.env,
|
|
332
|
+
[CHILD_ENV]: `${String(slot.index)}/${String(input.count)}`,
|
|
333
|
+
[POOL_MAX_ENV]: String(childShare(input.pool, slot.index, input.count)),
|
|
334
|
+
},
|
|
335
|
+
onMessage: (message) => onMessage(slot, message),
|
|
336
|
+
});
|
|
337
|
+
slot.child = child;
|
|
338
|
+
slot.state = 'starting';
|
|
339
|
+
slot.startedAt = timers.now();
|
|
340
|
+
slot.failures = 0;
|
|
341
|
+
slot.killed = false;
|
|
342
|
+
void child.exited.then((code) => {
|
|
343
|
+
if (slot.child === child) onExit(slot, code);
|
|
344
|
+
});
|
|
345
|
+
if (input.healthy !== undefined) poll(slot, child);
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
// Before the first spawn: Bun as PID 1 IGNORES a SIGTERM nobody handles (measured), and a
|
|
349
|
+
// signal landing between two spawns must still reach the child already running.
|
|
350
|
+
const handlers: [SignalName, () => void][] = [
|
|
351
|
+
['SIGTERM', () => stop('SIGTERM')],
|
|
352
|
+
['SIGINT', () => stop('SIGINT')],
|
|
353
|
+
['SIGUSR2', () => (input.role === 'worker' ? stop('SIGUSR2') : undefined)],
|
|
354
|
+
// An uncaught throw here: each child is asked to drain (a SIGKILL of this process is answered
|
|
355
|
+
// by the children themselves, on IPC disconnect — `supervise-child.ts`).
|
|
356
|
+
[
|
|
357
|
+
'exit',
|
|
358
|
+
() => {
|
|
359
|
+
for (const slot of slots) slot.child?.kill('SIGTERM');
|
|
360
|
+
},
|
|
361
|
+
],
|
|
362
|
+
];
|
|
363
|
+
for (const [signal, listener] of handlers) signals.on(signal, listener);
|
|
364
|
+
say('info', 'ultimate processes starting', { count: input.count, role: input.role });
|
|
365
|
+
for (const slot of slots) start(slot);
|
|
366
|
+
|
|
367
|
+
return {
|
|
368
|
+
done,
|
|
369
|
+
view: {
|
|
370
|
+
children: () =>
|
|
371
|
+
slots.map((slot) => ({
|
|
372
|
+
index: slot.index,
|
|
373
|
+
state: slot.state,
|
|
374
|
+
metricsUrl: slot.metricsUrl,
|
|
375
|
+
})),
|
|
376
|
+
ready: () =>
|
|
377
|
+
stopping === undefined &&
|
|
378
|
+
slots.some((slot) => slot.state === 'ready') &&
|
|
379
|
+
slots.every((slot) => slot.state === 'ready' || slot.state === 'draining'),
|
|
380
|
+
live: () => !(failure instanceof ProcessCrashLoopError),
|
|
381
|
+
},
|
|
382
|
+
};
|
|
383
|
+
}
|
|
@@ -67,16 +67,16 @@ jobTest('${name.camel} enqueues once, and dedupes a second sweep while one is li
|
|
|
67
67
|
|
|
68
68
|
const unitSuite = (
|
|
69
69
|
name: NameSet,
|
|
70
|
-
): string => `// ${name.camel}'s
|
|
71
|
-
//
|
|
70
|
+
): string => `// ${name.camel}'s DECLARATION: the durable name its rows are keyed by, and that it is a job. The
|
|
71
|
+
// pass itself deletes with SQL over whole tables, so it needs a migrated database and is not run
|
|
72
|
+
// here: the unit step has none, and \`x jobs show\` prints what a real pass removed.
|
|
72
73
|
|
|
73
74
|
import { expect, unitTest } from '@ultimat3/testing';
|
|
74
75
|
import { ${name.camel} } from './${name.kebab}';
|
|
75
76
|
|
|
76
|
-
unitTest('
|
|
77
|
-
|
|
78
|
-
expect(
|
|
79
|
-
expect(trace.executions[0]?.result).toMatchObject({ removed: 0 });
|
|
77
|
+
unitTest('${name.camel} is the job named ${name.kebab}', () => {
|
|
78
|
+
expect(${name.camel}.kind).toBe('job');
|
|
79
|
+
expect(${name.camel}.name).toBe('${name.kebab}');
|
|
80
80
|
});
|
|
81
81
|
`;
|
|
82
82
|
|
|
@@ -162,7 +162,7 @@ export function animatedLayoutProperties(files: readonly StyleFile[]): readonly
|
|
|
162
162
|
findings.push({
|
|
163
163
|
code: CODE,
|
|
164
164
|
cause: \`\${at} transitions every property of this element — \${animated === undefined ? \`\\\`\${property}: \${value}\\\` names none, and an omitted property is \\\`all\\\`\` : 'written out as \`all\`'} — so it animates properties nobody chose, the ones that cost a layout pass included, and no part of it can be composited\`,
|
|
165
|
-
fix: \`name the properties in \${at} — \\\`transition: transform tokens.duration('fast') tokens.easing('out')\\\` — then: x verify\`,
|
|
165
|
+
fix: \`name the properties in \${at} — \\\`transition: transform tokens.duration('fast') tokens.easing('out')\\\` — then: x verify --only boundaries\`,
|
|
166
166
|
at: file.path,
|
|
167
167
|
});
|
|
168
168
|
continue;
|
|
@@ -180,7 +180,7 @@ function layoutFinding(path: string, at: string, property: string, where: string
|
|
|
180
180
|
return {
|
|
181
181
|
code: CODE,
|
|
182
182
|
cause: \`\${at} animates \${property} in \${where} — only transform and opacity are compositor-only, so every frame of this costs a full layout or paint pass on the same main thread the app runs on, and a moving box feeds the layout-shift metric while it does it\`,
|
|
183
|
-
fix: \`animate \${instead} instead of \${property} at \${at}, then: x verify\`,
|
|
183
|
+
fix: \`animate \${instead} instead of \${property} at \${at}, then: x verify --only boundaries\`,
|
|
184
184
|
at: path,
|
|
185
185
|
};
|
|
186
186
|
}
|
|
@@ -59,7 +59,7 @@ export function bareThrows(files: readonly SourceFile[]): readonly Finding[] {
|
|
|
59
59
|
findings.push({
|
|
60
60
|
code: CODE,
|
|
61
61
|
cause: \`\${file.path}:\${line} throws a bare \${thrown} — it reaches its reader as a stack trace with no code, no cause and nothing to run\`,
|
|
62
|
-
fix: \`declare the failure in \${file.path} with defineError({ code, title, status, cause, fix }) from @ultimat3/core/page — an X_SCREAMING_SNAKE code and a fix naming a command — and throw its class, then: x verify\`,
|
|
62
|
+
fix: \`declare the failure in \${file.path} with defineError({ code, title, status, cause, fix }) from @ultimat3/core/page — an X_SCREAMING_SNAKE code and a fix naming a command — and throw its class, then: x verify --only boundaries\`,
|
|
63
63
|
at: file.path,
|
|
64
64
|
});
|
|
65
65
|
}
|
|
@@ -146,7 +146,7 @@ const finding = (file: SourceFile, line: number, what: string, declared: Declare
|
|
|
146
146
|
return {
|
|
147
147
|
code: CODE,
|
|
148
148
|
cause: \`\${file.path}:\${line} \${what} — the title, the HTTP status and the class are then declared apart, and a code with no status answers 500 and hides its cause\`,
|
|
149
|
-
fix: \`rewrite it in \${file.path} as one call per class, from @ultimat3/core/page: export const \${name} = defineError({ code: \${code}, title, status, cause, fix, problemMeta: ['<meta key>'] }) — it replaces the class and its registerErrorStatus / registerProblemMeta rows (offSocket: true instead of status for a code no response carries; publicCause: true for a 5xx whose cause a caller may read; drop problemMeta when its meta stays operator-only), then: x verify\`,
|
|
149
|
+
fix: \`rewrite it in \${file.path} as one call per class, from @ultimat3/core/page: export const \${name} = defineError({ code: \${code}, title, status, cause, fix, problemMeta: ['<meta key>'] }) — it replaces the class and its registerErrorStatus / registerProblemMeta rows (offSocket: true instead of status for a code no response carries; publicCause: true for a 5xx whose cause a caller may read; drop problemMeta when its meta stays operator-only), then: x verify --only boundaries\`,
|
|
150
150
|
at: file.path,
|
|
151
151
|
};
|
|
152
152
|
};
|
|
@@ -154,7 +154,7 @@ const finding = (file: SourceFile, line: number, what: string, declared: Declare
|
|
|
154
154
|
const barrelFinding = (file: SourceFile, line: number): Finding => ({
|
|
155
155
|
code: CODE,
|
|
156
156
|
cause: \`\${file.path}:\${line} takes defineError from the @ultimat3/core barrel — every island that throws the code then carries the framework's titles table, ~5.5 kB it never reads\`,
|
|
157
|
-
fix: \`import { defineError } from '@ultimat3/core/page' in \${file.path} — the same function, without the table — then: x verify\`,
|
|
157
|
+
fix: \`import { defineError } from '@ultimat3/core/page' in \${file.path} — the same function, without the table — then: x verify --only boundaries\`,
|
|
158
158
|
at: file.path,
|
|
159
159
|
});
|
|
160
160
|
|
|
@@ -153,7 +153,7 @@ export function unreplacedFocusRings(files: readonly StyleFile[]): readonly Find
|
|
|
153
153
|
findings.push({
|
|
154
154
|
code: CODE,
|
|
155
155
|
cause: \`\${file.path}:\${lineOf(scss, match.index)} removes the focus ring with \${property}: \${value} and nothing in the rule or beside it paints one back — a keyboard user loses every trace of where they are, and WCAG 2.2 asks for an indicator at least 2px around the control at 3:1 against what is behind it\`,
|
|
156
|
-
fix: \`add \\\`@include tokens.focus-ring;\\\` to the rule at \${file.path}:\${lineOf(scss, match.index)}, or a sibling \\\`:focus-visible\\\` rule with a box-shadow — which follows the border radius where an outline does not — then: x verify\`,
|
|
156
|
+
fix: \`add \\\`@include tokens.focus-ring;\\\` to the rule at \${file.path}:\${lineOf(scss, match.index)}, or a sibling \\\`:focus-visible\\\` rule with a box-shadow — which follows the border radius where an outline does not — then: x verify --only boundaries\`,
|
|
157
157
|
at: file.path,
|
|
158
158
|
});
|
|
159
159
|
}
|
|
@@ -124,7 +124,7 @@ export function unsizedImages(files: readonly SourceFile[]): readonly Finding[]
|
|
|
124
124
|
findings.push({
|
|
125
125
|
code: CODE,
|
|
126
126
|
cause: \`\${at} renders <\${tag.name}> with no width and height pair and no aspect-ratio — the browser reserves no box for it, so every element under it jumps the moment the bytes land\`,
|
|
127
|
-
fix: \`add width and height to the <\${tag.name}> at \${at} — the intrinsic pixel size, since CSS still decides what it is drawn at — or an aspect-ratio, then: x verify\`,
|
|
127
|
+
fix: \`add width and height to the <\${tag.name}> at \${at} — the intrinsic pixel size, since CSS still decides what it is drawn at — or an aspect-ratio, then: x verify --only boundaries\`,
|
|
128
128
|
at: file.path,
|
|
129
129
|
});
|
|
130
130
|
}
|
|
@@ -134,7 +134,7 @@ export function unsizedImages(files: readonly SourceFile[]): readonly Finding[]
|
|
|
134
134
|
findings.push({
|
|
135
135
|
code: CODE,
|
|
136
136
|
cause: \`\${at} marks <\${tag.name}> as the priority image AND loading="lazy" — a lazy image is fetched after layout, and this is the one the page's largest paint is measured on, so the attribute delays the metric it is the subject of\`,
|
|
137
|
-
fix: \`delete loading="lazy" from the <\${tag.name}> at \${at}, then: x verify\`,
|
|
137
|
+
fix: \`delete loading="lazy" from the <\${tag.name}> at \${at}, then: x verify --only boundaries\`,
|
|
138
138
|
at: file.path,
|
|
139
139
|
});
|
|
140
140
|
}
|
|
@@ -75,7 +75,7 @@ export function islandMountClears(files: readonly SourceFile[]): readonly Findin
|
|
|
75
75
|
findings.push({
|
|
76
76
|
code: CODE,
|
|
77
77
|
cause: \`\${at} empties the island's server markup outside mountOver, so a render that throws leaves a blank box where the server's HTML was, and the visitor sees nothing to retry\`,
|
|
78
|
-
fix: \`edit \${at} — delete the clear and end mount() with return mountOver(el, (root) => render(() => <Island {...props} />, root)), adding mountOver to the island's imports from '@ultimat3/render/client' — then: x verify\`,
|
|
78
|
+
fix: \`edit \${at} — delete the clear and end mount() with return mountOver(el, (root) => render(() => <Island {...props} />, root)), adding mountOver to the island's imports from '@ultimat3/render/client' — then: x verify --only boundaries\`,
|
|
79
79
|
at,
|
|
80
80
|
});
|
|
81
81
|
}
|
|
@@ -64,7 +64,7 @@ export function nativeConfirms(files: readonly SourceFile[]): readonly Finding[]
|
|
|
64
64
|
findings.push({
|
|
65
65
|
code: CODE,
|
|
66
66
|
cause: \`\${at} asks with confirm(), whose OK holds focus — a stray Enter confirms — and which cannot be translated or refused\`,
|
|
67
|
-
fix: \`replace the confirm() at \${at} with <ConfirmDialog> from '@ultimat3/ui' (action= for a native post, onConfirm= in an island) — or add a // why: comment on that line naming why it is not a destructive question — then: x verify\`,
|
|
67
|
+
fix: \`replace the confirm() at \${at} with <ConfirmDialog> from '@ultimat3/ui' (action= for a native post, onConfirm= in an island) — or add a // why: comment on that line naming why it is not a destructive question — then: x verify --only boundaries\`,
|
|
68
68
|
at,
|
|
69
69
|
});
|
|
70
70
|
}
|
|
@@ -97,7 +97,7 @@ export function rawBreakpoints(files: readonly StyleFile[]): readonly Finding[]
|
|
|
97
97
|
findings.push({
|
|
98
98
|
code: CODE,
|
|
99
99
|
cause: \`\${file.path}:\${line} defines its own \${match[1]} — @ultimat3/ui/tokens ships one, and a local definition silently shadows it, so the app has two breakpoint ladders\`,
|
|
100
|
-
fix: \`delete @mixin \${match[1]} from \${file.path}:\${line} and write @include \${ns}.\${match[1]}(…), then: x verify\`,
|
|
100
|
+
fix: \`delete @mixin \${match[1]} from \${file.path}:\${line} and write @include \${ns}.\${match[1]}(…), then: x verify --only boundaries\`,
|
|
101
101
|
at: \`\${file.path}:\${line}\`,
|
|
102
102
|
});
|
|
103
103
|
}
|
|
@@ -111,7 +111,7 @@ export function rawBreakpoints(files: readonly StyleFile[]): readonly Finding[]
|
|
|
111
111
|
findings.push({
|
|
112
112
|
code: CODE,
|
|
113
113
|
cause: \`\${file.path}:\${line} writes \\\`@media\${prelude.trimEnd()}\\\` — a viewport width of its own, off the breakpoint ladder every other sheet shares\`,
|
|
114
|
-
fix: \`\${include} — at \${file.path}:\${line}, then: x verify\`,
|
|
114
|
+
fix: \`\${include} — at \${file.path}:\${line}, then: x verify --only boundaries\`,
|
|
115
115
|
at: \`\${file.path}:\${line}\`,
|
|
116
116
|
});
|
|
117
117
|
}
|
|
@@ -156,7 +156,7 @@ export function rawColours(files: readonly StyleFile[]): readonly Finding[] {
|
|
|
156
156
|
findings.push({
|
|
157
157
|
code: CODE,
|
|
158
158
|
cause: \`\${file.path}:\${lineOf(scss, index)} sets \${property} to the raw colour \${literal} — a value no theme can restate, so dark theme renders it unchanged\`,
|
|
159
|
-
fix: \`replace \${literal} in \${file.path} with tokens.role('fg'), tokens.role('bg') or the role this element means, then: x verify\`,
|
|
159
|
+
fix: \`replace \${literal} in \${file.path} with tokens.role('fg'), tokens.role('bg') or the role this element means, then: x verify --only boundaries\`,
|
|
160
160
|
at: file.path,
|
|
161
161
|
});
|
|
162
162
|
}
|
|
@@ -197,7 +197,7 @@ export function inlineColours(
|
|
|
197
197
|
findings.push({
|
|
198
198
|
code: CODE,
|
|
199
199
|
cause: \`\${file.path}:\${lineOf(text, attribute.index)} sets \${property} to the raw colour \${literal} in an inline style — a value no theme can restate, so dark theme renders it unchanged\`,
|
|
200
|
-
fix: \`replace \${literal} in \${file.path} with rgb(var(--color-fg)), rgb(var(--color-bg)) or the role this element means — or a class whose stylesheet sets tokens.role('fg') — then: x verify\`,
|
|
200
|
+
fix: \`replace \${literal} in \${file.path} with rgb(var(--color-fg)), rgb(var(--color-bg)) or the role this element means — or a class whose stylesheet sets tokens.role('fg') — then: x verify --only boundaries\`,
|
|
201
201
|
at: file.path,
|
|
202
202
|
});
|
|
203
203
|
}
|
|
@@ -92,7 +92,7 @@ export function rawFetches(files: readonly SourceFile[]): readonly Finding[] {
|
|
|
92
92
|
findings.push({
|
|
93
93
|
code: CODE,
|
|
94
94
|
cause: \`\${at} calls fetch with no signal in its own options, so the call outlives the request that made it: a stalled vendor holds the handler, the drain and a socket\`,
|
|
95
|
-
fix: \`call outbound({ url, vendor, dial: 'public', deadlineMs: 10_000 }) from @ultimat3/core/outbound in place of the fetch at \${at}, or pass { signal: ctx.signal } in its options — then: x verify\`,
|
|
95
|
+
fix: \`call outbound({ url, vendor, dial: 'public', deadlineMs: 10_000 }) from @ultimat3/core/outbound in place of the fetch at \${at}, or pass { signal: ctx.signal } in its options — then: x verify --only boundaries\`,
|
|
96
96
|
at,
|
|
97
97
|
});
|
|
98
98
|
}
|
|
@@ -65,7 +65,7 @@ export function rawIntervals(files: readonly SourceFile[]): readonly Finding[] {
|
|
|
65
65
|
findings.push({
|
|
66
66
|
code: CODE,
|
|
67
67
|
cause: \`\${at} polls with setInterval, which keeps asking from a hidden tab and asks for a 401 forever once the session is gone\`,
|
|
68
|
-
fix: \`re-read a query with useQuery(ref, input, { poll: pollEvery(ms) }) (pollEvery is exported by @ultimat3/realtime) at \${at}; any other read: import { visibleInterval } from '@ultimat3/core/page' and call visibleInterval(run, ms) there, disposing it on cleanup — or add a // why: comment on that line naming why this interval is not a read — then: x verify\`,
|
|
68
|
+
fix: \`re-read a query with useQuery(ref, input, { poll: pollEvery(ms) }) (pollEvery is exported by @ultimat3/realtime) at \${at}; any other read: import { visibleInterval } from '@ultimat3/core/page' and call visibleInterval(run, ms) there, disposing it on cleanup — or add a // why: comment on that line naming why this interval is not a read — then: x verify --only boundaries\`,
|
|
69
69
|
at,
|
|
70
70
|
});
|
|
71
71
|
}
|
|
@@ -164,7 +164,7 @@ export function rawLengths(files: readonly StyleFile[]): readonly Finding[] {
|
|
|
164
164
|
findings.push({
|
|
165
165
|
code: CODE,
|
|
166
166
|
cause: \`\${file.path}:\${line} defines its own \${match[1]}() — @ultimat3/ui/tokens ships one, and a local definition silently shadows it, so two sheets can disagree about what a px is\`,
|
|
167
|
-
fix: \`delete @function \${match[1]} from \${file.path}:\${line} and call \${ns}.\${match[1]}(), then: x verify\`,
|
|
167
|
+
fix: \`delete @function \${match[1]} from \${file.path}:\${line} and call \${ns}.\${match[1]}(), then: x verify --only boundaries\`,
|
|
168
168
|
at: \`\${file.path}:\${line}\`,
|
|
169
169
|
});
|
|
170
170
|
}
|
|
@@ -196,7 +196,7 @@ export function rawLengths(files: readonly StyleFile[]): readonly Finding[] {
|
|
|
196
196
|
findings.push({
|
|
197
197
|
code: CODE,
|
|
198
198
|
cause: \`\${file.path}:\${line} writes \\\`\${statement}\\\` — a px length off the scale: it does not grow with the reader's text size, and no token names it\`,
|
|
199
|
-
fix: \`\${rewritten} — at \${file.path}:\${line}, then: x verify\`,
|
|
199
|
+
fix: \`\${rewritten} — at \${file.path}:\${line}, then: x verify --only boundaries\`,
|
|
200
200
|
at: \`\${file.path}:\${line}\`,
|
|
201
201
|
});
|
|
202
202
|
}
|
|
@@ -223,7 +223,7 @@ export function rawInlineLengths(files: readonly MarkupFile[]): readonly Finding
|
|
|
223
223
|
findings.push({
|
|
224
224
|
code: CODE,
|
|
225
225
|
cause: \`\${file.path}:\${line} sets \${px}px in an inline style — a length off the scale, in the one stylesheet nothing else reads\`,
|
|
226
|
-
fix: \`\${written} in place of \${px}px — at \${file.path}:\${line}; better, move the declaration into the element's .module.scss, then: x verify\`,
|
|
226
|
+
fix: \`\${written} in place of \${px}px — at \${file.path}:\${line}; better, move the declaration into the element's .module.scss, then: x verify --only boundaries\`,
|
|
227
227
|
at: \`\${file.path}:\${line}\`,
|
|
228
228
|
});
|
|
229
229
|
}
|
|
@@ -127,7 +127,7 @@ export function rawMotion(files: readonly StyleFile[]): readonly Finding[] {
|
|
|
127
127
|
findings.push({
|
|
128
128
|
code: CODE,
|
|
129
129
|
cause: \`\${file.path}:\${line} writes \\\`\${property}: \${value}\\\` — \${literals.join(' and ')} off the motion scale, a tempo of this file's own\`,
|
|
130
|
-
fix: \`\${property}: \${written} — at \${file.path}:\${line} (durations: \${DURATIONS.map(([name]) => name).join(' ')}; a longer one is calc(#{\${ns}.duration(slower)} * 2)), then: x verify\`,
|
|
130
|
+
fix: \`\${property}: \${written} — at \${file.path}:\${line} (durations: \${DURATIONS.map(([name]) => name).join(' ')}; a longer one is calc(#{\${ns}.duration(slower)} * 2)), then: x verify --only boundaries\`,
|
|
131
131
|
at: \`\${file.path}:\${line}\`,
|
|
132
132
|
});
|
|
133
133
|
}
|