Skip to content

Commit fc2b758

Browse files
Dmitrii Vasilevclaude
andcommitted
feat(igla): Wave Loop 420 — VCD exact-terminator + real-net auto-threshold, PVT process-corner monotonicity
Closes #1361 Variant C fallback (bench still blocked: P12 unwired, DLC10 cable missing, no relay). Instrument-import depth and formal guarding only. - cli/tri/src/fpga.rs: - exact-token VCD $date/$version/$comment terminator with regression test for embedded $end-like tokens (closes W419 report/actual gap) - real-valued VCD net auto-threshold from observed voltage swing - PVT half-period process-corner monotonicity regression test - proofs/lean4/Trinity/TernaryFPGABoot.lean: - pvt_half_ns_monotone_in_process_corner (ff ≤ tt ≤ ss) - fpga/HARDWARE_SSOT.md: §3.6.17 documenting W420 VCD/PVT improvements - .trinity/experience.md: W420 learnings - docs/reports: W420 report, evidence, and W421 cooperation variants Verification: - cargo test -p tri vcd: 13/13 PASS - cargo test -p tri pvt: 10/10 PASS - cargo test -p tri fpga::tests: 48/48 PASS - lake build Trinity.TernaryFPGABoot: PASS (2967 jobs) - ./scripts/tri test: 16 pre-existing yosys failures (#1245), no new ones Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 37e8496 commit fc2b758

11 files changed

Lines changed: 713 additions & 54 deletions

File tree

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

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Wave Loop 420 — Decomposed Plan
2+
3+
**Issue:** #1361
4+
**Branch:** `wave-loop-420`
5+
**Default variant:** C (physical bench still blocked: DLC10 cable not found, P12 unwired, no relay)
6+
7+
---
8+
9+
## 1. Weak points identified
10+
11+
1. **Missing VCD `$comment` exact-token terminator.** The W419 report claimed this
12+
hardening landed, but the merged commit (`101fd0748`) did not touch the VCD
13+
parser. The current code still uses `ends_with("$end")` / `contains(" $end")`
14+
heuristics, so a `$comment` block containing the literal substring `$end`
15+
terminates early and corrupts the signal dictionary.
16+
2. **Real-valued VCD nets require an explicit `--vcd-threshold-v`.** There is no
17+
auto-threshold fallback for analog VCD exports; users must know the voltage
18+
swing up-front.
19+
3. **PVT half-period bound lacks a process-corner monotonicity lemma.** We have
20+
temperature monotonicity and VCCINT antitonicity from W419, but no formal
21+
statement that `ff ≤ tt ≤ ss` is preserved by the half-period bound itself.
22+
23+
---
24+
25+
## 2. Competitor landscape (high-level)
26+
27+
The closest formal-HDL competition is **Sparkle / Verilean** (Lean 4 native,
28+
binary RTL). Other credible players: **Clash** (Haskell, external formal),
29+
**Chisel/FIRRTL/CIRCT** (mainstream, SVA/model-checking oriented),
30+
**Bluespec** (rule-based, Coq bridge via Kami), **Coq Kami / Silver Oak**
31+
(dependent-type hardware), **ACL2** (specification/proof layer only).
32+
33+
None combine Lean 4 native proof, a ternary compute stack, spec-first sealed
34+
`*.t27 → gen/` code generation, and physical boot-evidence instrumentation.
35+
That intersection is the gap t27 fills.
36+
37+
---
38+
39+
## 3. Implementation steps
40+
41+
| Step | Files | Deliverable | Acceptance |
42+
|------|-------|-------------|------------|
43+
| 3.1 | `cli/tri/src/fpga.rs` | Replace VCD `$date`/`$version`/`$comment` terminator heuristics with exact-token check; clear state immediately on same-line termination. | `test_parse_vcd_comment_with_embedded_end_token` PASS |
44+
| 3.2 | `cli/tri/src/fpga.rs` | Add VCD auto-threshold for real-valued nets: compute `50% (vmin + vmax)` when `--vcd-threshold-v` is omitted; warn user. | `test_parse_vcd_real_auto_threshold` PASS |
45+
| 3.3 | `proofs/lean4/Trinity/TernaryFPGABoot.lean` | Add `pvt_half_ns_monotone_in_process_corner` lemma: `c1.worse_than c2 → bound c1 ≤ bound c2`. | `lake build` PASS |
46+
| 3.4 | `cli/tri/src/fpga.rs` | Add Rust test `test_pvt_half_ns_monotone_in_process_corner`. | `cargo test` PASS |
47+
| 3.5 | `fpga/HARDWARE_SSOT.md` | Document VCD `$comment` exact-terminator behavior and real-net auto-threshold. | docs render clean |
48+
| 3.6 | `.trinity/experience.md` | Capture W420 learnings. | committed |
49+
| 3.7 | `docs/reports/*` | W420 report, evidence, W421 cooperation variants. | committed |
50+
51+
---
52+
53+
## 4. Verification plan
54+
55+
- `cargo test -p tri vcd` — expect 12 tests (was 11).
56+
- `cargo test -p tri pvt` — expect 10 tests (was 9).
57+
- `cargo test -p tri fpga::tests` — expect 47 tests (was 45).
58+
- `lake build Trinity.TernaryFPGABoot` — must PASS.
59+
- `./scripts/tri test` — must PASS except 16 pre-existing gen-verilog yosys failures.
60+
61+
---
62+
63+
## 5. Land
64+
65+
- Commit with `Closes #1361`.
66+
- Open PR #? from `wave-loop-420``master`.
67+
- After merge, create issue #? and branch `wave-loop-421`.
68+
69+
*φ² + φ⁻² = 3 | TRINITY*

.trinity/current-issue.md

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
# Wave Loop 425FPGA board evidence / relay gate / PVT falsification
1+
# Wave Loop 420physical CCLK capture, real relay gate, or instrument-import depth
22

3-
**Issue:** #1374
4-
**Branch:** `wave-loop-425`
5-
**Milestone:** Continue the FPGA boot-evidence line from W424.
3+
**Issue:** #1361
4+
**Branch:** `wave-loop-420`
5+
**Milestone:** Continue the FPGA boot-evidence line from Wave Loop 419.
66

77
---
88

99
## Goal
1010

11-
Wave 424 hardened the FPGA tooling around instrument import, PVT context, CSV
12-
voltage units, and non-blocking auto-continue. Wave 425 must produce real
13-
boot evidence by executing the first available variant:
11+
Wave 419 closed the Variant C fallback (instrument-import parity, PVT
12+
monotonicity, standalone lake workflow). Wave 420 re-evaluates the bench state
13+
and executes the first available variant.
1414

1515
1. **Variant A (preferred when bench becomes available):**
1616
- Confirm P12 is wired to a logic-analyzer channel.
@@ -29,27 +29,33 @@ boot evidence by executing the first available variant:
2929
- Document the import recipe and PVT-context checklist in
3030
`fpga/HARDWARE_SSOT.md`.
3131

32-
3. **Variant C (fallback if bench still fully blocked):**
33-
- Implement or defer real XADC readout in `tri fpga boot-log` / `cclk-sweep`.
34-
- Land the next safe gen-verilog #1245 sub-fix if one is narrow and
35-
regression-free; otherwise explicitly defer.
36-
- Harden boot-log / cold-por / cclk-sweep JSON schema and update the
37-
competitor snapshot.
32+
2. **Variant B (if relay hardware is available, no CCLK probe):**
33+
- Implement a real `--relay-port` backend for `tri fpga cold-por`
34+
(e.g. serial or TCP relay controlling board power).
35+
- Perform an automated cold-POR power-cycle and capture STAT without
36+
operator intervention.
37+
- Document relay wiring and port syntax in `fpga/HARDWARE_SSOT.md`.
38+
39+
3. **Variant C (fallback if bench still blocked):**
40+
- Extend instrument-import depth: VCD auto-threshold, CSV sample-rate
41+
auto-detection, or additional vendor header aliases.
42+
- Refine the PVT envelope if real N25Q128_3V timing curves become available,
43+
otherwise add another shape-preservation lemma.
44+
- Land one safe gen-verilog #1245 sub-fix that does not destabilize the
45+
existing 16-failure yosys smoke baseline.
3846

3947
---
4048

4149
## Decomposed plan
4250

43-
See `docs/reports/FPGA_LOOP_COOPERATION_W425_2026-07-05.md`.
44-
4551
| Step | File(s) | Deliverable |
4652
|------|---------|-------------|
47-
| 1 | `cli/tri/src/fpga.rs` | Variant A capture import, B dry-run + PVT context, or C XADC/schema hardening |
48-
| 2 | `proofs/lean4/Trinity/TernaryFPGABoot.lean` | New measured theorems or PVT helpers |
49-
| 3 | `fpga/HARDWARE_SSOT.md` | Updated capture / import / PVT protocol |
50-
| 4 | `docs/reports/*` | W425 report, evidence, W426 cooperation |
51-
| 5 | `.trinity/experience.md` | W425 learnings |
52-
| 6 | git/PR | squash-merge to `master`, close #1374, open next issue for W426 |
53+
| 1 | `cli/tri/src/fpga.rs` | Variant A import, B relay backend, or C instrument-import depth / gen-verilog sub-fix |
54+
| 2 | `proofs/lean4/Trinity/TernaryFPGABoot.lean` | New measured theorems or PVT shape lemma |
55+
| 3 | `fpga/HARDWARE_SSOT.md` | Updated capture / relay / integration protocol |
56+
| 4 | `docs/reports/*` | W420 report, evidence, W421 cooperation |
57+
| 5 | `.trinity/experience.md` | W420 learnings |
58+
| 6 | git/PR | squash-merge to `master`, close #1361, open #? for W421 |
5359

5460
---
5561

@@ -67,9 +73,9 @@ See `docs/reports/FPGA_LOOP_COOPERATION_W425_2026-07-05.md`.
6773
- [ ] AC-B3: `fpga/HARDWARE_SSOT.md` documents the import recipe and PVT-context checklist.
6874

6975
### Bundle C
70-
- [ ] AC-C1: Real XADC readout is implemented or a documented deferral explains why it remains placeholder.
71-
- [ ] AC-C2: `gen-verilog-yosys-smoke` failure count does not increase; any deferred #1245 sub-fix is explained.
72-
- [ ] AC-C3: Boot-log / cold-por / cclk-sweep JSON schema is measurably more robust or better documented.
76+
- [x] AC-C1: VCD instrument-import unit tests land: exact `$end` token terminator regression and real-valued net auto-threshold.
77+
- [x] AC-C2: New PVT envelope shape lemma/test lands: process-corner monotonicity (`ff ≤ tt ≤ ss`).
78+
- [ ] AC-C3: One safe gen-verilog #1245 sub-fix lands without increasing the 16-failure yosys smoke count. (Deferred; the remaining tracked gap is RAM style inference, which is not a safe narrow sub-fix for a Variant C wave.)
7379

7480
### Invariant checks
7581
- [ ] `./scripts/tri test` parse/typecheck/gen/seal-verify phases pass.
@@ -81,10 +87,11 @@ See `docs/reports/FPGA_LOOP_COOPERATION_W425_2026-07-05.md`.
8187
## PR
8288

8389
- Target: `master`
84-
- Body: `Closes #1374`
85-
- Report: `docs/reports/WAVE_LOOP_425_REPORT.md`
86-
- Evidence: `docs/reports/FPGA_LOOP_EVIDENCE_W425_2026-07-05.md`
87-
- Cooperation W426: `docs/reports/FPGA_LOOP_COOPERATION_W426_2026-07-05.md`
90+
- PR: to open after work
91+
- Body: `Closes #1361`
92+
- Report: `docs/reports/WAVE_LOOP_420_REPORT.md`
93+
- Evidence: `docs/reports/FPGA_LOOP_EVIDENCE_W420_2026-07-06.md`
94+
- Cooperation W421: `docs/reports/FPGA_LOOP_COOPERATION_W421_2026-07-06.md`
8895

8996
---
9097

.trinity/current_task/activity.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,7 +1464,15 @@
14641464
- **Commit:** docs(w420): set W420 issue number to #1361 and record W419 PR #1360 (Closes #1357, Refs #1361)
14651465
- **Files:** .trinity/current-issue.md,.trinity/experience.md,cli/tri/src/fpga.rs,docs/NOW.md,docs/reports/FPGA_LOOP_COOPERATION_W420_2026-07-05.md,docs/reports/FPGA_LOOP_EVIDENCE_W419_2026-07-05.md,docs/reports/WAVE_LOOP_419_REPORT.md,fpga/HARDWARE_SSOT.md,proofs/lean4/Trinity/TernaryFPGABoot.lean
14661466

1467-
## 2026-07-05T07:14:41Z — wave-loop-425
1468-
- **Commit:** chore(tri): update session log and commit count after W424 close-out
1469-
- **Files:** .trinity/current-issue.md,docs/NOW.md
1467+
## 2026-07-04T18:36:50Z — wave-loop-420
1468+
- **Commit:** feat(igla): Wave Loop 419 — Variant C VCD/CSV hardening, PVT monotonicity, standalone lake workflow
1469+
- **Files:** .trinity/current-issue.md
1470+
1471+
## 2026-07-04T18:37:55Z — wave-loop-420
1472+
- **Commit:** setup(igla): initialize Wave Loop 420 current issue (#1361)
1473+
- **Files:** .trinity/current-issue.md,.trinity/current_task/activity.md,docs/NOW.md
1474+
1475+
## 2026-07-04T19:27:38Z — wave-loop-420
1476+
- **Commit:** setup(igla): initialize Wave Loop 420 current issue and NOW.md update
1477+
- **Files:** .claude/plans/wave-loop-420.md,.trinity/current-issue.md,.trinity/current_task/activity.md,.trinity/experience.md,cli/tri/src/fpga.rs,docs/NOW.md,docs/reports/FPGA_LOOP_COOPERATION_W421_2026-07-06.md,docs/reports/FPGA_LOOP_EVIDENCE_W420_2026-07-06.md,docs/reports/WAVE_LOOP_420_REPORT.md,fpga/HARDWARE_SSOT.md,proofs/lean4/Trinity/TernaryFPGABoot.lean
14701478

.trinity/experience.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,55 @@
11
# t27 / Trinity Agent Experience Log
22

3+
## 2026-07-06 — Wave Loop 420 (Variant C fallback: VCD exact-terminator + auto-threshold, PVT corner monotonicity)
4+
5+
### What worked
6+
- Re-reading the merged W419 code revealed that the reported VCD `$comment`
7+
exact-token hardening had **not actually landed** in the committed diff. The
8+
heuristic `ends_with("$end")` / `contains(" $end")` was still in place. Fixing it
9+
for W420 and adding a regression test (`test_parse_vcd_comment_with_embedded_end_token`)
10+
closed the gap. This shows that **report claims must be verified against the
11+
actual tree**, not just the intended patch.
12+
- Adding **auto-threshold for real-valued VCD nets** removes a manual step for
13+
oscilloscope imports: when `--vcd-threshold-v` is omitted, the parser computes
14+
`50% (vmin + vmax)` from the observed swing. A regression test on a synthetic
15+
0 V / 3.3 V 25 MHz square wave validates the recovery.
16+
- Completing the PVT envelope **process-corner monotonicity** lemma and Rust test
17+
(ff ≤ tt ≤ ss) closes the last independent shape axis: temperature, voltage,
18+
and process corner are now all formally guarded.
19+
20+
### What changed behavior
21+
- `cli/tri/src/fpga.rs`: added `vcd_line_ends_with_token` helper; applied exact
22+
`$end` token terminator to VCD `$date`/`$version`/`$comment` sections; added
23+
real-valued VCD auto-threshold; added
24+
`test_parse_vcd_comment_with_embedded_end_token` and
25+
`test_parse_vcd_real_auto_threshold`.
26+
- `proofs/lean4/Trinity/TernaryFPGABoot.lean`: added
27+
`pvt_half_ns_monotone_in_process_corner`.
28+
- `cli/tri/src/fpga.rs`: added `test_pvt_half_ns_monotone_in_process_corner`.
29+
- `fpga/HARDWARE_SSOT.md`: added §3.6.17 documenting W420 instrument-import and
30+
PVT monotonicity work.
31+
- Close-out artifacts: `docs/reports/WAVE_LOOP_420_REPORT.md`,
32+
`docs/reports/FPGA_LOOP_EVIDENCE_W420_2026-07-06.md`, and
33+
`docs/reports/FPGA_LOOP_COOPERATION_W421_2026-07-06.md`.
34+
35+
### Patterns to reuse
36+
- When a report claims a parser hardening landed, diff the relevant file and
37+
run the claimed regression test before trusting the claim. Intention and
38+
commit content can diverge, especially after rebases or clean-branch rebuilds.
39+
- For analog instrument imports, provide an **auto-threshold fallback** computed
40+
from the observed swing, but keep the explicit override for noisy captures.
41+
- For placeholder models, prove **shape on every independent axis** (monotone in
42+
temp, antitone in voltage, monotone in process corner). Each axis gets both a
43+
symbolic Lean lemma and a numeric Rust sweep.
44+
45+
### Anti-patterns to avoid
46+
- Do not assume a reported fix exists in the tree; verify with `git show` and
47+
targeted tests.
48+
- Do not reject real-valued instrument imports when the threshold can be inferred
49+
from the data itself.
50+
- Do not leave any PVT envelope axis without a shape lemma; even placeholder
51+
coefficients must be formally well-behaved.
52+
353
## 2026-07-05 — Wave Loop 419 (Variant C fallback: VCD/CSV hardening, PVT monotonicity, standalone lake workflow)
454

555
### What worked

0 commit comments

Comments
 (0)