Files
Chris Tate 5eecd268ef Pin the sidecar contract: anti-alphabetical fixtures and the V1-V14 suite
- the contract fixture declares every order anti-alphabetically (type names, fields, enum members, union arms, msg arms, helpers) and the harness asserts the exact orders on both emissions
- its probe reads the identity getters before init and after a poisoning trap and the harness compares both reads to the sidecar's build_id (V12 plus the ratified exemption, end to end)
- V13 rides two independent identical invocations compared hash-equal; V11 rides nm both directions over the prefix
- the contract-attest fixture pins tuple-returning init/update, subscriptions presence, the default <out>.contract.json path, the empty absent forms, and Date.now demoting deterministic to false
- the validator suite passes a full-vocabulary conformance document and catches one targeted mutation per rule, plus SC4009 refusal coverage through compileLibrary
2026-07-23 14:44:57 -05:00

42 lines
1.2 KiB
TypeScript

// Contract-sidecar attestation fixture: pins the OTHER value of every
// shape flag (tuple-returning init/update, a subscriptions export), the
// absent forms of the optional conventions (no unbound consts, no channel
// consts — the sidecar states empty lists and nulls), the default sidecar
// path (<out>.contract.json), and the computed determinism attestation:
// Date.now() below reaches the live clock, so `deterministic` MUST come
// out false while the program still compiles and runs.
export interface Model {
stamp: number;
label: string;
}
export type Msg = { kind: "tick" } | { kind: "label_set"; value: string };
export function init(): [Model, string] {
return [{ stamp: Date.now(), label: "start" }, "boot-cmd"];
}
export function update(m: Model, msg: Msg): [Model, string] {
switch (msg.kind) {
case "label_set":
return [{ stamp: m.stamp, label: msg.value }, "noop"];
default:
return [{ stamp: m.stamp + 1, label: m.label }, "noop"];
}
}
export function subscriptions(m: Model): string {
return m.label;
}
let state: Model = init()[0];
export function boot(): number {
const pair = update(state, { kind: "tick" });
state = pair[0];
return state.stamp;
}
console.log("attest ready");