{
  "protocol": "DIRECTION_D2_REPLAY_CLOSURE_001",
  "version": "1.1.0",
  "status": "proposed; frozen on merge to risk.neverthought.org. Any change is a new version, recorded in amendments, and data or cases produced under one version are never analysed under another.",
  "direction": "D2 · Replay as a closure test",
  "governing_question": "Does replaying a declared crossing against a recorded execution trace catch divergences that self-replay cannot, and does a match license only the rung at which it was made?",
  "warrant": {
    "grounds": [
      "Replay today recomputes a determination from the same inputs and establishes internal consistency only (NC-08).",
      "The post-state test compares one observed end state with s_proposed. It cannot see what happened between, such as an undeclared intermediate step or steps in the wrong order.",
      "In reverse engineering, rebuilding a routine and comparing it with the original bytes is the step that turns a reconstruction back into something checkable."
    ],
    "gap": "Nothing on the site compares the steps a crossing declared with the steps it executed.",
    "why_now": "It can be built and run entirely on the site's own synthetic fixtures, so it is the cheapest of the four directions to settle."
  },
  "unit": {
    "case": "One recorded execution trace of a crossing whose determination was EXECUTE: an ordered list of (step, field, value) entries.",
    "declared_trace": "The ordered steps a crossing declares, derived from its class's paths and its s_before and s_proposed."
  },
  "materials": {
    "bases": "Four warranted examples, one per domain: INS-001, LED-001, MOD-001 and the ops.agent-action base proposal, at their versions on the day this protocol is frozen, pinned by proposal digest.",
    "divergence_types": {
      "NONE": "Executed exactly as declared.",
      "OMIT": "A declared step is missing.",
      "EXTRA": "A step not declared is present.",
      "ORDER": "Declared steps occur in a different order.",
      "VALUE": "A declared step writes a different value.",
      "EQUIV": "Different intermediate steps that reach the same end state and outputs as declared."
    },
    "cases": "Four cases of each type per base: 96 cases. Every case, with its type and expected verdicts at each rung, is written and committed before the checker exists, as the post-state test was."
  },
  "roles": {
    "case_author": "Writes and commits the cases and predictions.",
    "checker_author": "Writes the closure checker after the cases are committed.",
    "declared_limit": "These may be the same person, as in the post-state test. The commit order shows predictions came first; it does not make them independent."
  },
  "procedure": [
    "Commit this protocol and the 96 cases with their predicted verdicts.",
    "Write the closure checker. It compares the declared trace with the recorded trace at two rungs: OUTPUT (end state and outputs only) and PATH (every step, in order).",
    "Run the closure checker, the existing self-replay and the existing post-state check on every case.",
    "Publish all verdicts beside the predictions, including misses."
  ],
  "definitions": {
    "verdicts": "At each rung: MATCH, DIVERGED, or INCOMPLETE when the recorded trace lacks entries needed to decide. An absent entry is never read as a match.",
    "rung_license": "A MATCH at OUTPUT licenses only 'executed with the declared outputs'. Only a MATCH at PATH licenses 'executed as declared'."
  },
  "hypotheses": {
    "H1": {
      "statement": "Closure replay detects every seeded divergence that changes the path.",
      "measure": "PATH-rung verdicts on OMIT, EXTRA, ORDER and VALUE cases, and on NONE controls.",
      "falsifier": "Any OMIT, EXTRA, ORDER or VALUE case reported MATCH at PATH, or any NONE case reported DIVERGED at either rung."
    },
    "H2": {
      "statement": "Closure replay adds information beyond self-replay and the post-state check.",
      "measure": "For each divergent case, which of the three checks flags it.",
      "falsifier": "Every case the closure checker flags is also flagged by self-replay or by the post-state check."
    },
    "H3": {
      "statement": "A match licenses only its rung.",
      "measure": "Verdicts on EQUIV cases, and the licence statement the checker emits for them.",
      "falsifier": "Any EQUIV case reported MATCH at PATH, or reported at OUTPUT with a licence that says 'executed as declared'."
    }
  },
  "analysis": {
    "counts": "Counts per type, base and check. With constructed cases there is no sampling, so no intervals are reported.",
    "misses": "Every missed prediction is published with its cause, and is not rerun under a fix. A fix ships as a new checker version, as PS-F1 did."
  },
  "stopping": "One run of the 96 cases. New case types need a new version.",
  "licenses": {
    "H1 and H3 hold": {
      "licensed": "That on these synthetic cases, closure replay separates path divergence from output equivalence.",
      "not": "That executions in real systems produce traces this complete, or how often they diverge."
    },
    "H2 holds": {
      "licensed": "That closure replay is a distinct check from self-replay and the post-state check.",
      "not": "That it is a new idea. Differential testing and reconciliation are established practice."
    },
    "H2 falsified": {
      "licensed": "Dropping D2 as redundant with the post-state check.",
      "not": "Anything about replay in general."
    }
  },
  "threats": [
    "Constructed cases show the categories exist and that the checker separates them, not their frequency.",
    "Real traces are incomplete. INCOMPLETE may dominate in practice, which this study cannot show.",
    "Same-author cases and checker."
  ],
  "data_boundary": [
    "Public synthetic fixtures only, unless a section below says otherwise.",
    "No private workspace evidence, exports, enquiries or human-review records are used.",
    "Every input, sealed file, reveal and result is committed to a public repository with its SHA-256 before it is used."
  ],
  "dependencies": [
    "A declared-trace derivation for each of the four base classes, committed with the cases."
  ],
  "amendments": [
    {
      "version": "1.1.0",
      "date": "2026-10-23",
      "made_before": "any case was written, and before the checker existed",
      "change": "Cases are distinct. For each base and type, up to four distinct cases are constructed; where a base's declared trace admits fewer, fewer are constructed and the shortfall is reported, never filled with duplicates. NONE admits one case per base; ORDER needs at least two declared steps; OMIT admits at most 2^n - 1 cases for n declared steps.",
      "reason": "Writing the declared traces showed that the agent-action base declares a single step, so ORDER cannot be constructed for it, and that NONE and OMIT have fewer than four distinct cases for every base. Four cases of each type would have required duplicates, which add count without coverage.",
      "effect": "The case count falls from 96 to the number constructed, stated in the cases file. H1 to H3, their measures and falsifiers are unchanged."
    }
  ],
  "label": {
    "is": "A preregistered, synthetic test of whether comparing declared steps with executed steps catches what self-replay and end-state checks miss.",
    "isnt": "A measure of how often real crossings diverge, a security control, or independent replay.",
    "stops": "At the trace. It checks what the record shows was executed, and says nothing about why or about consequences outside the system."
  },
  "run_order": 1
}
