* feat(#3906): two terminators over one registry, with a versioned projection Adds terminateNow (write-then-terminate, for callers that cannot wait for the event loop) beside runMain (drain-then-exit), both projecting through one shared function so they cannot disagree - the parity the ADR makes mandatory. A failed write does not change the exit code: letting it propagate would fail a hook open, which is what the fail-closed branches exist to prevent. The projection is versioned. v1 reproduces today's integers, including keeping a payload-carried degraded result at exit 0 - ADR-2980 ratified that across 60 sites and declined normalizing it on measured blast radius. v2 applies the registry. --exit-contract=v2 or GSD_EXIT_CONTRACT=v2 selects it; an unrecognized version throws rather than silently defaulting. The registry is now emitted beside both copies of the exit module, so it resolves as a sibling in the built tree and in the committed scripts/ copy that must load on an unbuilt clone. * fix(#3906): actually restrict code 2 to terminateNow, and generate the registry's type The claim that terminateNow is the only place 2 can be produced was false: runMain's outcome arm applied no guard, so runMain(()=>'HOOK_DENY') set exitCode 2 through the drain path - and the parity matrix demonstrated it while calling it parity. runMain now refuses any outcome projecting to the hook-protocol code, gated on the code rather than the name so an alias cannot slip past, and the matrix asserts the restriction instead of contradicting it. The ambient type for the generated registry was hand-written with no gate against the generator's actual output - the declared-surface-diverges-from-runtime defect class this epic exists to close, reintroduced inside it. It is now a third generated artifact covered by the same --check. Also converts every test-body try/finally to t.after(). * test(#3906): derive the glossary fixture's dependencies instead of hand-listing them Adding a require to scripts/lib/cli-exit.cjs broke 31 tests in one suite that built its fixture from a hand-written dependency list, so the new sibling was absent and the copied script could not load. copyScriptWithDeps walks the require graph and exists for exactly this class - #3412 paid the same bill when one new require broke 82 tests across two suites. Migrating rather than adding another copyFileSync line keeps the class closed. The other nine suites referencing that path were triaged; none copies-and-spawns, so none needed migrating. * fix(#3906): enumerate the new shipped file, drop a vendor name from shipped data, and fix three test defects install: scripts/lib/exit-code-registry.cjs was missing from GSD_SCRIPTS_LIB_FILES, so it shipped to every install and orphaned on uninstall. The registry gave HOOK_DENY a meaning naming one harness, and that string ships into every runtime's tree - a guard correctly caught it leaking into the hermes and qwen installs. The registry is runtime-neutral infrastructure; the vendor name belongs in the ADR, not in shipped data. Two more fixture harnesses built their trees from hand-listed dependencies and broke on the new require; both migrated to the derived helper, and all 23 copy-and-spawn candidates were enumerated so the class is closed rather than patched. One generator test used a fixture code that collided with a real allocation, so the generator correctly reported a duplicate where the test expected drift. The large-payload test embedded a 256KB literal in the child's argv, exceeding Linux's 128KiB MAX_ARG_STRLEN so the child never started - it now builds the payload inside the child. * chore(#3906): backfill changeset pr number * docs(#3906): document the exit-code contract selector P2 is the first phase of this epic with a user-invocable surface, so the flag and env var owe a reference entry. Records what actually differs between v1 and v2 today (one outcome), that an unrecognized value is rejected rather than silently defaulted, and the fail-safe property that makes switching safe. --------- Co-authored-by: sim <sim@local>
43 lines
2.0 KiB
TypeScript
43 lines
2.0 KiB
TypeScript
// GENERATED FILE — DO NOT EDIT BY HAND.
|
|
// Source of truth: gsd-core/bin/shared/exit-codes.json + the ENTRY_FIELD_TYPES table in
|
|
// scripts/gen-exit-code-registry.cjs. Regenerate with:
|
|
// node scripts/gen-exit-code-registry.cjs --write
|
|
//
|
|
// Ambient type declaration for exit-code-registry.cjs — a GENERATED,
|
|
// committed artifact with no `.cts` source of its own (it is hand-serialized
|
|
// from gsd-core/bin/shared/exit-codes.json by scripts/gen-exit-code-registry.cjs,
|
|
// ADR-3889 §2, #3905/#3906), so tsc has nothing to compile for it. This file
|
|
// exists purely so `src/cli-exit.cts`'s `require('./exit-code-registry.cjs')`
|
|
// type-checks against the SAME shape the generated artifact actually exports
|
|
// at runtime — mirroring the src/vendor/*.d.cts pattern already used for
|
|
// other verbatim/generated JS this tree resolves types for without compiling.
|
|
//
|
|
// This declaration is generated from the same ENTRY_FIELD_TYPES table
|
|
// serializeRegistry()'s per-entry object literals iterate, and is
|
|
// byte-compared by `node scripts/gen-exit-code-registry.cjs --check`
|
|
// (the same check that already covers the two sibling .cjs artifacts) so a
|
|
// shape drift here fails the build instead of surfacing at a destructuring
|
|
// call site.
|
|
|
|
export interface ExitCodeEntry {
|
|
readonly code: number;
|
|
readonly name: string;
|
|
readonly meaning: string;
|
|
readonly owner: string;
|
|
readonly authorizedBy: string;
|
|
}
|
|
|
|
declare const exitCodeRegistry: {
|
|
readonly EXIT_CODES: readonly ExitCodeEntry[];
|
|
// Property-typed function signatures (`name: (args) => ret`), NOT method
|
|
// shorthand (`name(args): ret`) — the latter is a TS "method" and trips
|
|
// @typescript-eslint/unbound-method at every destructuring call site
|
|
// (`const { exitCodeFor } = ...`), since a method may implicitly use
|
|
// `this`. These are pure functions that never do, so they are typed as
|
|
// plain function-valued properties instead.
|
|
exitCodeFor: (name: string) => number;
|
|
nameForExitCode: (code: number) => string;
|
|
};
|
|
|
|
export = exitCodeRegistry;
|