@tiphys/kernel 0.0.0 → 0.2.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/AGENTS.md +663 -0
- package/LICENSE +202 -0
- package/assurance-modes.yaml +299 -0
- package/checklists/clean-room.yaml +325 -0
- package/checklists/env-failure-diagnosis.yaml +68 -0
- package/checklists/flake-playbook.yaml +68 -0
- package/checklists/hazard-review.yaml +144 -0
- package/checklists/plan-review.yaml +103 -0
- package/dist/bin/tiphys.d.ts +2 -0
- package/dist/bin/tiphys.js +92 -0
- package/dist/src/adapters/load.d.ts +202 -0
- package/dist/src/adapters/load.js +440 -0
- package/dist/src/brief.d.ts +32 -0
- package/dist/src/brief.js +66 -0
- package/dist/src/checklists.d.ts +169 -0
- package/dist/src/checklists.js +310 -0
- package/dist/src/checks.d.ts +1539 -0
- package/dist/src/checks.js +5025 -0
- package/dist/src/cli.d.ts +9 -0
- package/dist/src/cli.js +68 -0
- package/dist/src/commands/brief.d.ts +92 -0
- package/dist/src/commands/brief.js +343 -0
- package/dist/src/commands/checklist.d.ts +42 -0
- package/dist/src/commands/checklist.js +168 -0
- package/dist/src/commands/cutover.d.ts +35 -0
- package/dist/src/commands/cutover.js +448 -0
- package/dist/src/commands/doctor.d.ts +264 -0
- package/dist/src/commands/doctor.js +1546 -0
- package/dist/src/commands/gates.d.ts +9 -0
- package/dist/src/commands/gates.js +360 -0
- package/dist/src/commands/init.d.ts +30 -0
- package/dist/src/commands/init.js +177 -0
- package/dist/src/commands/lock.d.ts +34 -0
- package/dist/src/commands/lock.js +340 -0
- package/dist/src/commands/mode.d.ts +40 -0
- package/dist/src/commands/mode.js +134 -0
- package/dist/src/commands/next.d.ts +130 -0
- package/dist/src/commands/next.js +597 -0
- package/dist/src/commands/plan.d.ts +20 -0
- package/dist/src/commands/plan.js +105 -0
- package/dist/src/commands/pool.d.ts +1 -0
- package/dist/src/commands/pool.js +139 -0
- package/dist/src/commands/resume.d.ts +1 -0
- package/dist/src/commands/resume.js +88 -0
- package/dist/src/commands/spawn.d.ts +1 -0
- package/dist/src/commands/spawn.js +195 -0
- package/dist/src/commands/status.d.ts +21 -0
- package/dist/src/commands/status.js +122 -0
- package/dist/src/commands/sync.d.ts +47 -0
- package/dist/src/commands/sync.js +341 -0
- package/dist/src/commands/teardown.d.ts +1 -0
- package/dist/src/commands/teardown.js +87 -0
- package/dist/src/commands/tuition.d.ts +21 -0
- package/dist/src/commands/tuition.js +218 -0
- package/dist/src/commands/validate.d.ts +78 -0
- package/dist/src/commands/validate.js +430 -0
- package/dist/src/commands/watch.d.ts +1 -0
- package/dist/src/commands/watch.js +172 -0
- package/dist/src/cutover.d.ts +584 -0
- package/dist/src/cutover.js +1444 -0
- package/dist/src/exclusion.d.ts +389 -0
- package/dist/src/exclusion.js +843 -0
- package/dist/src/exec/env.d.ts +278 -0
- package/dist/src/exec/env.js +334 -0
- package/dist/src/fleet.d.ts +223 -0
- package/dist/src/fleet.js +298 -0
- package/dist/src/gates/adapters/http-json.d.ts +5 -0
- package/dist/src/gates/adapters/http-json.js +283 -0
- package/dist/src/gates/adapters/migrations-command.d.ts +1 -0
- package/dist/src/gates/adapters/migrations-command.js +373 -0
- package/dist/src/gates/citations.d.ts +408 -0
- package/dist/src/gates/citations.js +1169 -0
- package/dist/src/gates/coverage.d.ts +375 -0
- package/dist/src/gates/coverage.js +836 -0
- package/dist/src/gates/credentials.d.ts +233 -0
- package/dist/src/gates/credentials.js +752 -0
- package/dist/src/gates/deploy.d.ts +1 -0
- package/dist/src/gates/deploy.js +33 -0
- package/dist/src/gates/gate-classes.d.ts +56 -0
- package/dist/src/gates/gate-classes.js +633 -0
- package/dist/src/gates/manifest.d.ts +99 -0
- package/dist/src/gates/manifest.js +208 -0
- package/dist/src/gates/merge-preconditions.d.ts +319 -0
- package/dist/src/gates/merge-preconditions.js +932 -0
- package/dist/src/gates/migrations.d.ts +1 -0
- package/dist/src/gates/migrations.js +36 -0
- package/dist/src/gates/pin.d.ts +114 -0
- package/dist/src/gates/pin.js +154 -0
- package/dist/src/gates/red-witness.d.ts +22 -0
- package/dist/src/gates/red-witness.js +482 -0
- package/dist/src/gates/release.d.ts +283 -0
- package/dist/src/gates/release.js +820 -0
- package/dist/src/gates/result.d.ts +116 -0
- package/dist/src/gates/result.js +91 -0
- package/dist/src/gates/run.d.ts +614 -0
- package/dist/src/gates/run.js +1614 -0
- package/dist/src/gates/schemas/citation-config.schema.json +59 -0
- package/dist/src/gates/schemas/coverage-config.schema.json +77 -0
- package/dist/src/gates/schemas/gate-manifest.schema.json +125 -0
- package/dist/src/gates/schemas/gate-result.schema.json +160 -0
- package/dist/src/gates/schemas/phase-declaration.schema.json +87 -0
- package/dist/src/gates/schemas/release-record.schema.json +119 -0
- package/dist/src/gates/schemas/verifier-config.schema.json +101 -0
- package/dist/src/gates/schemas/witness-spec.schema.json +110 -0
- package/dist/src/gates/scope.d.ts +131 -0
- package/dist/src/gates/scope.js +1018 -0
- package/dist/src/gates/suite.d.ts +217 -0
- package/dist/src/gates/suite.js +968 -0
- package/dist/src/gates/validate.d.ts +121 -0
- package/dist/src/gates/validate.js +414 -0
- package/dist/src/hooks.d.ts +84 -0
- package/dist/src/hooks.js +125 -0
- package/dist/src/index.d.ts +31 -0
- package/dist/src/index.js +30 -0
- package/dist/src/liveness.d.ts +321 -0
- package/dist/src/liveness.js +396 -0
- package/dist/src/lock.d.ts +256 -0
- package/dist/src/lock.js +792 -0
- package/dist/src/model-resolution.d.ts +159 -0
- package/dist/src/model-resolution.js +307 -0
- package/dist/src/modes.d.ts +149 -0
- package/dist/src/modes.js +258 -0
- package/dist/src/path-identity.d.ts +34 -0
- package/dist/src/path-identity.js +48 -0
- package/dist/src/plan.d.ts +73 -0
- package/dist/src/plan.js +153 -0
- package/dist/src/pool.d.ts +326 -0
- package/dist/src/pool.js +988 -0
- package/dist/src/roles.d.ts +461 -0
- package/dist/src/roles.js +776 -0
- package/dist/src/spawn.d.ts +482 -0
- package/dist/src/spawn.js +1003 -0
- package/dist/src/status.d.ts +116 -0
- package/dist/src/status.js +148 -0
- package/dist/src/task.d.ts +504 -0
- package/dist/src/task.js +307 -0
- package/dist/src/teardown.d.ts +39 -0
- package/dist/src/teardown.js +422 -0
- package/dist/src/tuition.d.ts +159 -0
- package/dist/src/tuition.js +311 -0
- package/dist/src/validate.d.ts +263 -0
- package/dist/src/validate.js +742 -0
- package/dist/src/version.d.ts +3 -0
- package/dist/src/version.js +38 -0
- package/dist/src/watcher.d.ts +275 -0
- package/dist/src/watcher.js +849 -0
- package/dist/src/witness/run.d.ts +299 -0
- package/dist/src/witness/run.js +1373 -0
- package/dist/src/witness/spec.d.ts +270 -0
- package/dist/src/witness/spec.js +475 -0
- package/dist/tsconfig.src.tsbuildinfo +1 -0
- package/gate-registry.yaml +526 -0
- package/gates.manifest.json +257 -0
- package/package.json +72 -3
- package/role-model-config.yaml +88 -0
- package/roles/README.md +128 -0
- package/roles/_shared-dispatch-contract.md +87 -0
- package/roles/adversarial-plan-reviewer.md +80 -0
- package/roles/clean-room-reviewer.md +140 -0
- package/roles/implementer.md +463 -0
- package/roles/investigator.md +138 -0
- package/roles/plan-writer.md +95 -0
- package/schemas/README.md +82 -0
- package/schemas/assurance-modes.schema.json +264 -0
- package/schemas/charter.schema.json +185 -0
- package/schemas/checklist.schema.json +114 -0
- package/schemas/cutover-state.schema.json +64 -0
- package/schemas/decision-record.schema.json +88 -0
- package/schemas/executor-record.schema.json +36 -0
- package/schemas/final-report.schema.json +90 -0
- package/schemas/finding.schema.json +106 -0
- package/schemas/gate-registry.schema.json +260 -0
- package/schemas/mechanism-index.schema.json +94 -0
- package/schemas/model-resolution.schema.json +362 -0
- package/schemas/plan.schema.json +300 -0
- package/schemas/report.schema.json +579 -0
- package/schemas/role-brief.schema.json +105 -0
- package/schemas/role-model-config.schema.json +90 -0
- package/schemas/status-line.schema.json +40 -0
- package/schemas/tuition.schema.json +191 -0
- package/schemas/verdict.schema.json +295 -0
- package/schemas/work-history.schema.json +183 -0
- package/schemas/write-bypass.schema.json +69 -0
- package/templates/charter.example.yaml +54 -0
- package/templates/decision-record.example.yaml +27 -0
- package/templates/final-report.example.yaml +80 -0
- package/templates/plan.example.yaml +87 -0
- package/templates/report.example.yaml +236 -0
- package/templates/warnings.md +74 -0
- package/templates/work-history.example.yaml +185 -0
- package/tuition/README.md +76 -0
- package/tuition/T-001.yaml +48 -0
- package/tuition/T-002.yaml +51 -0
- package/tuition/T-003.yaml +100 -0
- package/tuition/T-004.yaml +52 -0
- package/tuition/T-005.yaml +72 -0
- package/tuition/T-006.yaml +81 -0
- package/tuition/T-007.yaml +56 -0
- package/tuition/T-008.yaml +111 -0
- package/tuition/T-009.yaml +50 -0
- package/tuition/T-015.yaml +36 -0
- package/tuition/T-016.yaml +36 -0
- package/tuition/T-017.yaml +46 -0
- package/tuition/T-018.yaml +84 -0
- package/tuition/T-021.yaml +40 -0
- package/tuition/T-022.yaml +36 -0
- package/tuition/mechanism-index.yaml +256 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { Pin } from "./pin.ts";
|
|
2
|
+
/**
|
|
3
|
+
* THE GATE RESULT RECORD (kernel plan M2, M2-P1 step 2).
|
|
4
|
+
*
|
|
5
|
+
* Every gate this milestone ships emits exactly one of these, and the exit
|
|
6
|
+
* test counts them. Nine phases build against this shape, so it is written
|
|
7
|
+
* once here and never re-derived: a gate that invents its own record is a
|
|
8
|
+
* review finding.
|
|
9
|
+
*
|
|
10
|
+
* THE STATUS VOCABULARY IS FOUR WORDS AND THEY ARE NOT INTERCHANGEABLE.
|
|
11
|
+
*
|
|
12
|
+
* green the gate did its work and the property holds
|
|
13
|
+
* red the gate did its work and the property does not hold
|
|
14
|
+
* not-applicable the gate's precondition WAS EVALUATED and found unmet
|
|
15
|
+
* error the gate could not reach a verdict
|
|
16
|
+
*
|
|
17
|
+
* `not-applicable` is the one most easily abused, and SC-011 is why it is
|
|
18
|
+
* spelled out: it ASSERTS that a precondition was evaluated. A gate that
|
|
19
|
+
* could not evaluate its precondition, could not find its input, or was
|
|
20
|
+
* invoked without a parameter it needs is `error` and never
|
|
21
|
+
* `not-applicable` and never green (M2-C-3, fail closed). "Never green by
|
|
22
|
+
* omission" is the whole point of the vocabulary.
|
|
23
|
+
*
|
|
24
|
+
* M2-C-2, ENFORCED HERE RATHER THAN REMEMBERED. A record with status
|
|
25
|
+
* `green` and `units` 0 claims a property holds while having examined
|
|
26
|
+
* nothing. `makeGateResult` rewrites it to `error` naming M2-C-2 and marks
|
|
27
|
+
* it `vacuous`, and there is no other constructor, so a gate built on this
|
|
28
|
+
* module cannot emit one. The runner applies the SAME rule again when it
|
|
29
|
+
* ingests a record, because a gate written in another language or by hand
|
|
30
|
+
* does not go through this constructor and must not be able to smuggle a
|
|
31
|
+
* vacuous green past the runner (see `ingestRecord` in run.ts).
|
|
32
|
+
*
|
|
33
|
+
* WHY `vacuous` IS A FIELD AND NOT A STRING TO GREP FOR. Step 8 requires
|
|
34
|
+
* the summary to count `vacuous` as a strict subset of `error`. Once the
|
|
35
|
+
* rewrite has happened, a vacuous error and an ordinary error are the same
|
|
36
|
+
* status, so the runner would have to recover the distinction by
|
|
37
|
+
* pattern-matching the detail text of a record another program wrote.
|
|
38
|
+
* MECHANISMS.md's row "Deciding what another program will do by
|
|
39
|
+
* pattern-matching the text of a file it consumes" is exactly that
|
|
40
|
+
* mechanism and it cost this project four rounds. So the distinction is
|
|
41
|
+
* carried structurally. This is an addition to the plan's field list and is
|
|
42
|
+
* declared as such in the work history.
|
|
43
|
+
*/
|
|
44
|
+
/** The four words. Nothing else is a status. */
|
|
45
|
+
export type GateStatus = "green" | "red" | "not-applicable" | "error";
|
|
46
|
+
export declare const GATE_STATUSES: readonly GateStatus[];
|
|
47
|
+
/**
|
|
48
|
+
* The gate subprocess exit-code table, and the runner's own aggregate exit
|
|
49
|
+
* codes. One table, used by both ends of the pipe, so a gate and the runner
|
|
50
|
+
* can never disagree about what 20 means.
|
|
51
|
+
*
|
|
52
|
+
* 64 is EX_USAGE and is the CLI's, not a gate status: a gate that exits 64
|
|
53
|
+
* was invoked wrongly, which means it measured nothing, which the runner
|
|
54
|
+
* records as `error`.
|
|
55
|
+
*/
|
|
56
|
+
export declare const EXIT_GREEN = 0;
|
|
57
|
+
export declare const EXIT_RED = 1;
|
|
58
|
+
export declare const EXIT_NOT_APPLICABLE = 20;
|
|
59
|
+
export declare const EXIT_GATE_ERROR = 21;
|
|
60
|
+
export declare function exitCodeForStatus(status: GateStatus): number;
|
|
61
|
+
export declare function statusForExitCode(code: number): GateStatus | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* What a precondition evaluation concluded. `met` false means EVALUATED AND
|
|
64
|
+
* UNMET; an evaluation that could not conclude produces no PreconditionRecord
|
|
65
|
+
* at all, because the gate is `error` and the reason says so.
|
|
66
|
+
*/
|
|
67
|
+
export interface PreconditionRecord {
|
|
68
|
+
id: string;
|
|
69
|
+
met: boolean;
|
|
70
|
+
reason: string;
|
|
71
|
+
evidence?: string[];
|
|
72
|
+
}
|
|
73
|
+
/** Start and end pins for the gates M2-C-5 binds. */
|
|
74
|
+
export interface PinPair {
|
|
75
|
+
start: Pin;
|
|
76
|
+
end: Pin;
|
|
77
|
+
}
|
|
78
|
+
export interface GateResult {
|
|
79
|
+
gate: string;
|
|
80
|
+
status: GateStatus;
|
|
81
|
+
units: number;
|
|
82
|
+
unitLabel: string;
|
|
83
|
+
startedAt: string;
|
|
84
|
+
endedAt: string;
|
|
85
|
+
/** Set only when the M2-C-2 rewrite fired. See the module comment. */
|
|
86
|
+
vacuous?: boolean;
|
|
87
|
+
precondition?: PreconditionRecord;
|
|
88
|
+
pin?: PinPair;
|
|
89
|
+
detail: string;
|
|
90
|
+
/** Paths relative to the evidence directory. */
|
|
91
|
+
evidence: string[];
|
|
92
|
+
}
|
|
93
|
+
/** The fields a caller supplies; the constructor owns `vacuous`. */
|
|
94
|
+
export interface GateResultFields {
|
|
95
|
+
gate: string;
|
|
96
|
+
status: GateStatus;
|
|
97
|
+
units: number;
|
|
98
|
+
unitLabel: string;
|
|
99
|
+
startedAt: string;
|
|
100
|
+
endedAt: string;
|
|
101
|
+
precondition?: PreconditionRecord;
|
|
102
|
+
pin?: PinPair;
|
|
103
|
+
detail: string;
|
|
104
|
+
evidence?: string[];
|
|
105
|
+
}
|
|
106
|
+
export declare const M2_C_2_DETAIL: string;
|
|
107
|
+
/**
|
|
108
|
+
* THE ONLY CONSTRUCTOR. Applies the M2-C-2 rewrite, so a green record with
|
|
109
|
+
* zero units cannot be constructed. `units` is coerced to a non-negative
|
|
110
|
+
* integer: a negative or fractional unit count is not a smaller measurement,
|
|
111
|
+
* it is an unusable one, so it is treated as zero and therefore triggers the
|
|
112
|
+
* same rewrite when the status was green.
|
|
113
|
+
*/
|
|
114
|
+
export declare function makeGateResult(fields: GateResultFields): GateResult;
|
|
115
|
+
/** Serialize a record the way every kernel JSON state file is written. */
|
|
116
|
+
export declare function renderGateResult(result: GateResult): string;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
export const GATE_STATUSES = [
|
|
2
|
+
"green",
|
|
3
|
+
"red",
|
|
4
|
+
"not-applicable",
|
|
5
|
+
"error",
|
|
6
|
+
];
|
|
7
|
+
/**
|
|
8
|
+
* The gate subprocess exit-code table, and the runner's own aggregate exit
|
|
9
|
+
* codes. One table, used by both ends of the pipe, so a gate and the runner
|
|
10
|
+
* can never disagree about what 20 means.
|
|
11
|
+
*
|
|
12
|
+
* 64 is EX_USAGE and is the CLI's, not a gate status: a gate that exits 64
|
|
13
|
+
* was invoked wrongly, which means it measured nothing, which the runner
|
|
14
|
+
* records as `error`.
|
|
15
|
+
*/
|
|
16
|
+
export const EXIT_GREEN = 0;
|
|
17
|
+
export const EXIT_RED = 1;
|
|
18
|
+
export const EXIT_NOT_APPLICABLE = 20;
|
|
19
|
+
export const EXIT_GATE_ERROR = 21;
|
|
20
|
+
export function exitCodeForStatus(status) {
|
|
21
|
+
if (status === "green") {
|
|
22
|
+
return EXIT_GREEN;
|
|
23
|
+
}
|
|
24
|
+
if (status === "red") {
|
|
25
|
+
return EXIT_RED;
|
|
26
|
+
}
|
|
27
|
+
if (status === "not-applicable") {
|
|
28
|
+
return EXIT_NOT_APPLICABLE;
|
|
29
|
+
}
|
|
30
|
+
return EXIT_GATE_ERROR;
|
|
31
|
+
}
|
|
32
|
+
export function statusForExitCode(code) {
|
|
33
|
+
if (code === EXIT_GREEN) {
|
|
34
|
+
return "green";
|
|
35
|
+
}
|
|
36
|
+
if (code === EXIT_RED) {
|
|
37
|
+
return "red";
|
|
38
|
+
}
|
|
39
|
+
if (code === EXIT_NOT_APPLICABLE) {
|
|
40
|
+
return "not-applicable";
|
|
41
|
+
}
|
|
42
|
+
if (code === EXIT_GATE_ERROR) {
|
|
43
|
+
return "error";
|
|
44
|
+
}
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
export const M2_C_2_DETAIL = "M2-C-2 (never green by omission): a gate reporting green with units 0 " +
|
|
48
|
+
"examined nothing, so this record is error";
|
|
49
|
+
/**
|
|
50
|
+
* THE ONLY CONSTRUCTOR. Applies the M2-C-2 rewrite, so a green record with
|
|
51
|
+
* zero units cannot be constructed. `units` is coerced to a non-negative
|
|
52
|
+
* integer: a negative or fractional unit count is not a smaller measurement,
|
|
53
|
+
* it is an unusable one, so it is treated as zero and therefore triggers the
|
|
54
|
+
* same rewrite when the status was green.
|
|
55
|
+
*/
|
|
56
|
+
export function makeGateResult(fields) {
|
|
57
|
+
const units = Number.isFinite(fields.units) && Number.isInteger(fields.units) && fields.units > 0
|
|
58
|
+
? fields.units
|
|
59
|
+
: 0;
|
|
60
|
+
const base = {
|
|
61
|
+
gate: fields.gate,
|
|
62
|
+
status: fields.status,
|
|
63
|
+
units,
|
|
64
|
+
unitLabel: fields.unitLabel,
|
|
65
|
+
startedAt: fields.startedAt,
|
|
66
|
+
endedAt: fields.endedAt,
|
|
67
|
+
detail: fields.detail,
|
|
68
|
+
evidence: fields.evidence === undefined ? [] : [...fields.evidence],
|
|
69
|
+
};
|
|
70
|
+
if (fields.precondition !== undefined) {
|
|
71
|
+
base.precondition = fields.precondition;
|
|
72
|
+
}
|
|
73
|
+
if (fields.pin !== undefined) {
|
|
74
|
+
base.pin = fields.pin;
|
|
75
|
+
}
|
|
76
|
+
if (base.status === "green" && base.units === 0) {
|
|
77
|
+
return {
|
|
78
|
+
...base,
|
|
79
|
+
status: "error",
|
|
80
|
+
vacuous: true,
|
|
81
|
+
detail: base.detail === ""
|
|
82
|
+
? M2_C_2_DETAIL
|
|
83
|
+
: `${M2_C_2_DETAIL}; the gate reported: ${base.detail}`,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return base;
|
|
87
|
+
}
|
|
88
|
+
/** Serialize a record the way every kernel JSON state file is written. */
|
|
89
|
+
export function renderGateResult(result) {
|
|
90
|
+
return `${JSON.stringify(result, null, 2)}\n`;
|
|
91
|
+
}
|