import { MarquetteDiagnostic, MarquetteDiagnosticSeverity } from "./validate.mjs"; import { TestRunAdmissionDecision, TestRunCandidate, TestRunDenialCode } from "./test-run-admission.mjs"; //#region src/test-run-transition-model.d.ts /** * Serialized `format` marker for release-transition records. * * Readers must reject any other value before trusting the record. */ declare const TEST_RUN_TRANSITION_FORMAT = "vize.test-run.transition"; /** * Current serialized release-transition format. * * Readers must reject a higher value until they explicitly support it. */ declare const TEST_RUN_TRANSITION_FORMAT_VERSION = 1; /** Maximum admission ids one transition may carry as accepted state. */ declare const TEST_RUN_TRANSITION_MAX_ACCEPTED = 4096; /** * One retained diagnostic inside a durable transition record. * * The shape and serialization match live diagnostics exactly; the retained * form is plain data so persisted records can be read back by any host. */ interface TestRunRetainedDiagnostic { /** Stable machine-readable diagnostic code. */ readonly code: string; /** Severity recorded for the diagnostic; any diagnostic denies. */ readonly severity: MarquetteDiagnosticSeverity; /** JSON-style path into the decided input. */ readonly path: string; /** Human-readable explanation recorded with the decision. */ readonly message: string; } /** * One retained allow-or-deny decision inside a durable transition record. * * The shape and serialization match live decisions exactly. Validation * rejects a retained decision whose `allowed` flag, denial codes, or * diagnostic ordering disagree with the published mapping, so a record * cannot claim an outcome its own diagnostics contradict. */ interface TestRunRetainedDecision { /** Whether the release decision admitted the candidate. */ readonly allowed: boolean; /** Deduplicated denial causes sorted lexicographically; empty if allowed. */ readonly denialCodes: readonly TestRunDenialCode[]; /** Complete diagnostics in the stable path, code, message order. */ readonly diagnostics: readonly TestRunRetainedDiagnostic[]; } /** * One durable atomic release transition. * * The record binds the decision, the exact candidate and evidence it * decided, and the complete accepted anti-replay state after the decision * into one canonical document. `sequence` grows by exactly one per * transition and `previous` names the predecessor's canonical SHA-256 * fingerprint, so a chain tip proves the entire decision history and the * accepted set can never drift from the decision that produced it. * * Host durability contract: write the complete canonical bytes to a * temporary location, flush them to durable storage, then atomically rename * or commit so exactly one complete chain tip exists at every instant; on * recovery, verify the tip against its retained predecessor with * {@link verifyTestRunTransition} before deciding anything new, and discard * — never repair — a torn or partial record. */ interface TestRunTransition { /** Serialized format marker; always {@link TEST_RUN_TRANSITION_FORMAT}. */ readonly format: typeof TEST_RUN_TRANSITION_FORMAT; /** * Serialized format version. * * Defaults to {@link TEST_RUN_TRANSITION_FORMAT_VERSION}. */ readonly formatVersion?: typeof TEST_RUN_TRANSITION_FORMAT_VERSION; /** One-based position of this transition in its chain. */ readonly sequence: number; /** Canonical fingerprint of the predecessor; `null` only at genesis. */ readonly previous: string | null; /** Millisecond-precision UTC instant the decision was made. */ readonly decidedAt: string; /** Exact candidate the decision was made for. */ readonly candidate: TestRunCandidate; /** Exact `test-run:` admission id the decision evaluated. */ readonly evidence: string; /** Retained decision exactly as it was produced. */ readonly decision: TestRunRetainedDecision; /** * Complete anti-replay state after this transition: every admission id * ever accepted in this chain, sorted and unique. */ readonly accepted: readonly string[]; } /** * Serializes a release transition canonically. * * Property order matches the record schema and the accepted state sorts * lexicographically after deduplication, so equivalent transitions produce * byte-identical JSON in every language. These are the exact bytes a host * must write atomically and the exact bytes the chain fingerprint covers. * Call validation before trusting the record; canonicalization does not * make an invalid record valid. */ declare function canonicalTestRunTransitionJson(transition: TestRunTransition): string; /** * Returns the lowercase SHA-256 fingerprint of the canonical transition. * * The fingerprint is the exact value the successor transition must name as * `previous`, forming the durable chain. Uses the Web Crypto API available * in every supported runtime. */ declare function testRunTransitionFingerprint(transition: TestRunTransition): Promise; //#endregion //#region src/test-run-transition.d.ts /** * Validates one release transition structurally. * * Diagnostics use `transition.` paths and are deterministic and sorted by * path, code, and message. Validation confirms the record alone is * internally coherent — grammar, decision consistency against the published * diagnostic mapping, and an allowed decision accepting its own evidence — * but only {@link verifyTestRunTransition} can confirm the record extends * the durable chain. Codes, paths, messages, and ordering are identical to * the native implementation. */ declare function validateTestRunTransition(transition: TestRunTransition): MarquetteDiagnostic[]; /** * Verifies one release transition against the durable chain tip. * * `previous` is the retained, already-verified predecessor — `null` only * when deciding the very first transition of a chain. The transition must * validate structurally, extend the predecessor's sequence, fingerprint, * scope, and decision time exactly, never re-accept evidence the * predecessor already accepted, and carry an accepted state equal to the * predecessor's state plus exactly the newly accepted evidence (unchanged * for a denial). Any diagnostic rejects the transition: a conforming host * must not persist it, and on recovery must discard a tip this function * rejects. Diagnostics, denial codes, and ordering are identical to the * native implementation, as pinned by the shared transition-decision * fixtures. */ declare function verifyTestRunTransition(transition: TestRunTransition, previous: TestRunTransition | null): Promise; //#endregion export { TEST_RUN_TRANSITION_FORMAT, TEST_RUN_TRANSITION_FORMAT_VERSION, TEST_RUN_TRANSITION_MAX_ACCEPTED, type TestRunRetainedDecision, type TestRunRetainedDiagnostic, type TestRunTransition, canonicalTestRunTransitionJson, testRunTransitionFingerprint, validateTestRunTransition, verifyTestRunTransition }; //# sourceMappingURL=test-run-transition.d.mts.map