1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
// Work Chain-of-Thought Proof Derivation checks (CB-1640..1649) — Component 31
//
// Sub-spec: docs/specifications/components/pmat-work-cot-proof-derivation.md
//
// Today's `ChainOfThoughtStep` is prose-only — `{ step, question, answer }`.
// Component 31 restructures each step as a typed node with `assumption`,
// `implication`, `evidence_method`, and `discharged_by`, then auto-derives
// proof obligations, falsification claims, and require/ensure clauses.
//
// The schema migration is substantial (new Rust types, `pmat work cot`
// CLI surface, derivation pipeline) and is deliberately deferred: these
// checks read hypothetical structured fields via `serde_json::Value`
// introspection so they run clean against today's contracts and light up
// automatically once authors start emitting the new shape.
//
// Functional checks (work today against contract.json Value introspection):
// CB-1640 (L3) — assumption.references resolve to prior step ids /
// implications, bound equation names, or axiomatic
// discharge (exact-string fallback per spec §Chain
// Integrity Rule when semantic-search vocabulary absent)
// CB-1641 (L3) — every step with structured fields has an `evidence_method`
// CB-1642 (L1) — `evidence_method = ExistingTest` path/name resolves on disk
// CB-1643 (L3) — L3+ tickets: every structured step has `assumption.expr`
// or `implication.expr`
// CB-1644 (L1) — `.pmat-work/<ID>/agent-runs/<run_id>.json` entries carry
// the replay schema (`prompt_sha`, `tool_calls`, `commit_sha`).
// Skip-if-absent until Component 10 writer lands.
// CB-1645 (L3) — derived `contracts/work/<ID>.yaml` is up-to-date with
// contract.json preconditions/postconditions
// CB-1646 (L1) — `.pmat-work/<ID>/cot-digest.json` SHA matches the
// canonical hash of `chain_of_thought` — detects manual
// edits that bypass `pmat work cot derive`. Skip-if-absent.
// CB-1647 (L3) — no orphan steps: every step chains via `discharged_by`
// CB-1648 (L4) — every `Axiomatic` discharge in an L4+ ticket is either
// a bound equation invariant (reason/lemma matches an
// `implements:` equation name) or a documented lemma
// (non-empty `reason` prose). Skip-if-absent.
// CB-1649 (L5) — every structured step in an L5 ticket carries a Lean
// theorem/lemma mapping via `lean_theorem`, `lean_lemma`,
// `evidence_method.LeanTheorem`/`LeanLemma`, or
// `discharged_by.Lean`. Skip-if-absent.
//
// All CB-164x checks are now active (skip-if-absent).
//
// ── Layout ──────────────────────────────────────────────────────────────────
// This file is the entry point. Per-check implementations and tests live in
// semantically named sibling files, brought in via `include!()` so they share
// this module's `use` imports without re-declaring them.
use Path;
use Value;
use ;
use *;
// ─── Helpers (shared across partitions) ──────────────────────────────────────
/// Load every `.pmat-work/<ID>/contract.json` as a raw `Value`. Schema-agnostic —
/// we look up fields by name so contracts built on the legacy `{ step, question,
/// answer }` shape round-trip without panicking on missing new fields.
/// Extract the `chain_of_thought` array from a contract Value, if present.
/// A step is "structured" if it carries any of the Component 31 fields. Used to
/// gate checks so the legacy `{ step, question, answer }` shape doesn't trip
/// assertions meant for the new schema.
/// Parse a `verification_level` string (`"L3"`, `"L3 (kani_proof)"`, etc.) to
/// its numeric level. Unknown shapes return 0 so checks gate conservatively.
// ─── Per-check implementations ───────────────────────────────────────────────
include!;
include!;
include!;
include!;
include!;
include!;
include!;
include!;
include!;
// ─── Tests ───────────────────────────────────────────────────────────────────
include!;
include!;
include!;