Skip to content

Commit 3e82c7d

Browse files
author
Dmitrii Vasilev
committed
feat(igla): Wave Loop 412 — measured-to-lean standalone + raw-ns + PVT context (Closes #1332)
- tri fpga measured-to-lean --standalone emits self-contained .lean stub - tri fpga measured-to-lean --raw-ns reads (period_ns, low_ns, high_ns) - Lean 4 raw-ns predicate + chain theorem + concrete example - Lean 4 PvtContext placeholder + PVT implication theorems - docs/BRANCHING_MODEL.md updated to Strategy P (master = integration+release) - W412 report, evidence, and W413 cooperation variants - Refresh all .trinity/seals after c4dc8ee gen-rust change
1 parent a795da1 commit 3e82c7d

587 files changed

Lines changed: 1950 additions & 1236 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/plans/wave-loop-412.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Decomposed Plan — Wave Loop 412
2+
3+
> Issue: #1332
4+
> Branch: `wave-loop-412`
5+
> Continues: W411 close-out (`docs/reports/WAVE_LOOP_411_REPORT.md`)
6+
7+
---
8+
9+
## Weak points inherited from W411
10+
11+
1. **Physical evidence gap.** `measured-to-lean` is implemented, but the input
12+
has been synthetic because P12 is not wired and the DLC10 cable is not
13+
detected.
14+
2. **PVT margin is a placeholder.** The 12 ns worst-case constants are a 2×
15+
derating, not derived from N25Q128 PVT characterization data.
16+
3. **Bench dependency.** All physical progress is gated by hardware access.
17+
4. **Relay CI gate missing.** Cold-POR automation is required before the SPI
18+
boot gate can be exercised in CI.
19+
20+
---
21+
22+
## Competitor scan (2026 formal-HDL / FPGA-boot space)
23+
24+
Same set as W411, with emphasis on the gap W412 is meant to close:
25+
26+
- **Sparkle HDL / VeriLean** — strong semantics, no public measured-to-formal
27+
pipeline for SPI flash timing.
28+
- **Kami / Kôika** — Coq hardware DSL; no 7-series configuration timing model.
29+
- **prjxray / OpenXC7** — bitstream-level knowledge; complementary.
30+
- **OpenTitan** — SoC boot security, not FPGA configuration stage.
31+
- **spispy / SPI flash emulators** — protocol analysis, not machine-checked
32+
timing bounds.
33+
- **Commercial SPI NOR VIP** — closed reference models, not tied to live
34+
measurement.
35+
36+
W412's relay CI gate + real capture would be hard to reproduce end-to-end.
37+
38+
---
39+
40+
## Chosen variant
41+
42+
**Primary: Bundle A + B** (when the bench becomes available).
43+
**Fallback: Variant C** (if P12/DLC10 remain blocked).
44+
45+
---
46+
47+
## Decomposed tasks
48+
49+
### A1 — Wire P12 and verify DLC10
50+
- Wire P12 to the nearest logic-analyzer channel.
51+
- Verify `dlc10 idcode` returns `0x13631093`.
52+
- Run `tri fpga measure-cclk --json` and save the JSON under
53+
`docs/fpga/evidence/w412_oscfsel6_cclk.json`.
54+
55+
### A2 — Real `OSCFSEL=6,7` boot
56+
- Program the bitstream with each `OSCFSEL` value.
57+
- Run cold POR and collect `tri fpga boot-log --json`.
58+
- Convert each measurement to a Lean theorem with
59+
`tri fpga measured-to-lean --name w412_oscfsel6`.
60+
- Paste the theorem into `proofs/lean4/Trinity/TernaryFPGABoot.lean` and verify
61+
`lake build`.
62+
63+
### B1 — Relay cold-POR automation
64+
- Add `fpga/src/relay.rs` with `PowerController` trait.
65+
- Implement `MockPowerController` for CI and `HardwareRelay` for a USB relay.
66+
- Add `tri fpga cold-por --oscfsel 6|7 --relay-port PORT`.
67+
- Add mock smoke test in `cargo test -p tri fpga::relay_tests`.
68+
- Document relay wiring in `fpga/HARDWARE_SSOT.md` §3.6.12.
69+
70+
### C1 — PVT refinement (fallback)
71+
- Find or document N25Q128 PVT derating curves.
72+
- If no data, strengthen the falsification plan for the 2× placeholder.
73+
74+
### C2 — Standalone `.lean` output (fallback)
75+
- Extend `measured_to_lean` to emit imports, namespace, and theorem block.
76+
77+
### C3 — Raw-ns input (fallback)
78+
- Add `--raw-ns` mode reading `(period_ns, low_ns, high_ns)`.
79+
- Add `measured_cclk_from_raw_ns_satisfies_flash_spec` and implication theorem.
80+
81+
### D — Close-out
82+
- Write `docs/reports/WAVE_LOOP_412_REPORT.md`.
83+
- Write `docs/reports/FPGA_LOOP_EVIDENCE_W412_2026-07-04.md`.
84+
- Write `docs/reports/FPGA_LOOP_COOPERATION_W413_2026-07-04.md`.
85+
- Update `docs/NOW.md` with W412 close-out / W13 setup.
86+
- Update `.trinity/experience.md`.
87+
- Commit, push `wave-loop-412`, open PR #1332, create issue/branch W13.
88+
89+
---
90+
91+
## Acceptance criteria
92+
93+
See `.trinity/current-issue.md` for the full checklist.
94+
95+
---
96+
97+
*φ² + φ⁻² = 3 | TRINITY*

.trinity/current-issue.md

Lines changed: 49 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,77 @@
1-
# Wave Loop 411real P12 + OSCFSEL 6/7 retry, relay CI gate, or auto-proof tooling
1+
# Wave Loop 412FPGA physical capture + relay CI gate or PVT refinement
22

3-
**Issue:** #1329
4-
**Branch:** `wave-loop-411`
5-
**Milestone:** W410 completed the measured-duty formal link but both physical
6-
paths (real P12 capture and DLC10-based `OSCFSEL=6,7` boot) remain blocked. W411
7-
either finally connects the bench or uses the extra cycle to build automation /
8-
formal tooling.
3+
**Issue:** #1332
4+
**Branch:** `wave-loop-412`
5+
**Milestone:** Continue the FPGA boot-evidence line from W411.
96

107
---
118

129
## Goal
1310

14-
1. **Variant A** — Real P12 CCLK capture + physical `OSCFSEL=6,7` cold-POR
15-
boot. Wire P12 to ADBUS4 (or a DSLogic/scope channel), connect the DLC10
16-
cable, capture the real CCLK, run the 6/7 sweep, and turn the measured
17-
values into a `measured_cclk_satisfies_flash_spec` proof.
18-
2. **Variant B** — Relay-controlled cold-POR hardware CI gate. Build the
19-
relay + tri-stateable JTAG automation infrastructure so the flash-boot gate
20-
can run unattended.
21-
3. **Variant C** — Auto-proof tooling + PVT margins. Add a subcommand that
22-
generates a Lean theorem from a `--json` measurement, and extend the formal
23-
model with conservative process/voltage/temperature margins.
24-
25-
Default recommendation: **Variant A + C bundle**. If the bench is still
26-
unavailable, pick **Variant B** or **Variant C alone**.
11+
1. **Variant A + B (preferred when bench is available):**
12+
- Wire P12 to a logic-analyzer channel and capture real CCLK for
13+
`OSCFSEL=6` and `OSCFSEL=7`.
14+
- Verify the Digilent DLC10 cable is detected with `dlc10 idcode`.
15+
- Boot from flash with both oscillator settings and collect boot logs.
16+
- Feed the measured `(frequency, duty)` into
17+
`tri fpga measured-to-lean --json` and commit the generated Lean theorems.
18+
- Add relay-controlled cold-POR automation (`tri fpga cold-por`) with a
19+
mock CI path.
20+
21+
2. **Variant C (fallback if bench still blocked):**
22+
- Replace the placeholder 2× PVT constants with real N25Q128 PVT derating
23+
data or document the assumption more precisely.
24+
- Extend `tri fpga measured-to-lean` to emit a self-contained `.lean` file.
25+
- Add raw-ns input mode (`period_ns`, `low_ns`, `high_ns`) and a
26+
corresponding Lean predicate.
2727

2828
---
2929

3030
## Decomposed plan
3131

32-
See `docs/reports/FPGA_LOOP_COOPERATION_W411_2026-07-04.md` for the full
33-
weak-point / competitor scan and detailed decomposition.
32+
See `.claude/plans/wave-loop-412.md` and
33+
`docs/reports/FPGA_LOOP_COOPERATION_W412_2026-07-04.md`.
3434

3535
| Step | File(s) | Deliverable |
36-
|---|---|---|
37-
| 1 | `docs/reports/FPGA_LOOP_COOPERATION_W411_2026-07-04.md` | Cooperation variants |
38-
| 2 | `fpga/HARDWARE_SSOT.md` §3.6.1/§3.6.9 (Variant A) | Real measured CCLK and 6/7 boot status |
39-
| 3 | `build/fpga/` + `docs/reports/` (Variant A) | Real capture CSV + boot-log JSON |
40-
| 4 | `proofs/lean4/Trinity/TernaryFPGABoot.lean` (Variant A/C) | `measured_*_satisfies_flash_spec` instance from real data |
41-
| 5 | `cli/tri/src/fpga.rs` (Variant B/C) | Relay trait + auto-power-cycle mode, or `measured-to-lean` subcommand |
42-
| 6 | `docs/reports/*` | W411 report, evidence, W412 cooperation |
43-
| 7 | `.trinity/experience.md` | W411 learnings |
44-
| 8 | `docs/NOW.md` | W411 entry |
45-
| 9 | git/PR | squash-merge to master, close #1329, open #W412 |
36+
|------|---------|-------------|
37+
| 1 | `.claude/plans/wave-loop-412.md` | Decomposed plan + weak points + competitor scan |
38+
| 2 | `fpga/HARDWARE_SSOT.md` §3.6.12 | Relay wiring and CI cold-POR protocol (A+B) |
39+
| 3 | `cli/tri/src/fpga.rs` + new `fpga/src/relay.rs` | `tri fpga cold-por` with mock + hardware backends (A+B) |
40+
| 4 | `proofs/lean4/Trinity/TernaryFPGABoot.lean` | Real-measurement theorems or PVT refinement (C) |
41+
| 5 | `docs/reports/*` | W412 report, evidence, W413 cooperation |
42+
| 6 | `.trinity/experience.md` | W412 learnings |
43+
| 7 | git/PR | squash-merge to `master`, close #1332, open #1333 |
4644

4745
---
4846

4947
## Acceptance criteria
5048

51-
- [ ] AC-A1: real P12 CCLK capture CSV exists (or blocker documented). **Blocked — P12 not wired.**
52-
- [ ] AC-A2: `OSCFSEL=6,7` boot logs exist (PASS or documented failure). **Blocked — DLC10 cable missing.**
53-
- [ ] AC-A3: a Lean theorem links the captured `(frequency, duty)` pair to
54-
`transaction_satisfies_flash_spec`. **Delivered via `measured-to-lean` generated theorems on synthetic data.**
55-
- [ ] AC-B1: relay auto-power-cycle mode exists behind a trait with a board-less
56-
mock path, or explicitly deferred. **Deferred to W412.**
57-
- [x] AC-C1: `measured-to-lean` subcommand generates a type-correct theorem
58-
skeleton from `--json`.
59-
- [x] AC-C2: PVT margin predicate exists in Lean 4 and implies
60-
`measured_cclk_satisfies_flash_spec`.
61-
- [x] AC-C3: A Lean theorem proves that the PVT margin predicate implies
62-
`transaction_satisfies_flash_spec`.
63-
- [x] AC-D1: `lake build Trinity.TernaryFPGABoot` passes.
64-
- [x] AC-D2: `cargo test -p tri fpga::tests` passes.
65-
- [x] AC-D3: `./scripts/tri test` parse/typecheck/gen/seal-verify phases pass.
66-
- [x] AC-D4: gen-verilog-yosys-smoke failures remain tracked separately.
67-
- [x] AC-D5: W411 report + evidence + W412 cooperation variants committed.
68-
69-
---
49+
### Bundle A + B (deferred — bench unavailable)
50+
- [ ] AC-A1: P12 is wired to a logic-analyzer channel and a real CCLK capture CSV exists for `OSCFSEL=6` and `OSCFSEL=7`.
51+
- [ ] AC-A2: `dlc10 idcode` returns the expected Artix-7 IDCODE.
52+
- [ ] AC-A3: Cold-POR boot logs exist for `OSCFSEL=6` and `OSCFSEL=7`.
53+
- [ ] AC-A4: Measured `(frequency, duty)` theorems are generated and `lake build` green.
54+
- [ ] AC-B1: `tri fpga cold-por --relay-port MOCK` runs in CI and returns a JSON boot log.
55+
- [ ] AC-B2: `fpga/HARDWARE_SSOT.md` documents the relay wiring.
7056

71-
## Close-out note
57+
### Bundle C (delivered)
58+
- [x] AC-C1: PVT placeholder model is documented in `fpga/HARDWARE_SSOT.md` §3.6.12 with falsification plan.
59+
- [x] AC-C2: `tri fpga measured-to-lean --standalone --out File.lean` emits a self-contained file.
60+
- [x] AC-C3: Raw-ns input predicate `measured_cclk_from_raw_ns_satisfies_flash_spec` is defined and implies `transaction_satisfies_flash_spec`.
7261

73-
W411 implemented **Variant C alone** because the bench blockers persisted. The
74-
`tri fpga measured-to-lean` subcommand and the PVT-margin predicate close two
75-
real weak points in the measured-to-formal pipeline. Variant A and the physical
76-
half of any bundle remain blocked until P12 is wired and the DLC10 cable is
77-
connected.
62+
### Invariant checks
63+
- [x] `./scripts/tri test` parse/typecheck/gen/seal-verify phases pass (16 pre-existing yosys-smoke failures remain).
64+
- [x] `lake build Trinity.TernaryFPGABoot` passes.
65+
- [x] `cargo test -p tri fpga::tests` passes (16/16).
7866

7967
---
8068

8169
## Default variant
8270

83-
**Variant A + C bundle**: physical measurement and 6/7 boot, with auto-proof
84-
tooling. If the bench is still unavailable, fall back to **Variant B** (relay
85-
CI gate) or **Variant C alone** (formal-tooling improvements).
71+
Execute **Variant A + B** when the bench becomes available. Otherwise fall back
72+
to **Variant C** to keep the formal tooling useful while the physical blockers
73+
persist.
8674

8775
---
8876

89-
*phi^2 + phi^-2 = 3 | TRINITY*
77+
*φ² + φ⁻² = 3 | TRINITY*

0 commit comments

Comments
 (0)