Skip to content

Commit b558b9b

Browse files
Dmitrii Vasilevclaude
andcommitted
feat(igla): Wave Loop 419 — Variant C VCD/CSV hardening, PVT monotonicity, standalone lake workflow
- Harden VCD $comment parser with exact $end token terminator. - Add CSV --csv-channel selection and multi-channel header auto-detection. - Add Rust tests for PVT half-ns monotonicity in temp / antitonicity in VCCINT. - Add matching Lean 4 lemmas in Trinity.TernaryFPGABoot. - Fix --standalone generated import to use only Trinity.TernaryFPGABoot. - Document standalone lake-package workflow in fpga/HARDWARE_SSOT.md. - Close-out reports and W420 cooperation variants. Closes #1357 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 27c3868 commit b558b9b

10 files changed

Lines changed: 943 additions & 75 deletions

File tree

.trinity/current-issue.md

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,55 @@
1-
# Wave Loop 418FPGA physical capture, real relay gate, or further formal tooling
1+
# Wave Loop 419 — physical CCLK capture, real relay gate, or instrument-import parity
22

3-
**Issue:** #1353
4-
**Branch:** `wave-loop-418`
5-
**Milestone:** Continue the FPGA boot-evidence line from W417.
3+
**Issue:** #1357
4+
**Branch:** `wave-loop-419`
5+
**Milestone:** Continue the FPGA boot-evidence line from W418.
66

77
---
88

99
## Goal
1010

11-
Wave 417 closed the W415/W416 hygiene loop. Wave 418 re-evaluates the bench
12-
state and executes the first available variant.
11+
Wave 418 closed the Variant C fallback (formal tooling and instrument import).
12+
Wave 419 re-evaluates the bench state and executes the first available variant.
1313

1414
1. **Variant A (preferred when bench becomes available):**
1515
- Wire P12 to a logic-analyzer channel and capture real CCLK for
1616
`OSCFSEL=6` and `OSCFSEL=7`.
17+
- Program each variant to SPI flash and perform a true cold-POR boot.
1718
- Import the captures with `tri fpga measured-to-lean --csv/--vcd --raw-ns
1819
--standalone --validate --pvt-context <ctx.json>` and commit the generated
1920
Lean theorems.
2021
- Document the measured frequencies/duty cycles and PVT context in
2122
`fpga/HARDWARE_SSOT.md`.
2223

23-
2. **Variant B (if relay hardware is available):**
24+
2. **Variant B (if relay hardware is available, no CCLK probe):**
2425
- Implement a real `--relay-port` backend for `tri fpga cold-por`
2526
(e.g. serial or TCP relay controlling board power).
2627
- Perform an automated cold-POR power-cycle and capture STAT without
2728
operator intervention.
28-
- Document relay wiring in `fpga/HARDWARE_SSOT.md`.
29+
- Document relay wiring and port syntax in `fpga/HARDWARE_SSOT.md`.
2930

3031
3. **Variant C (fallback if bench still blocked):**
31-
- Add a regression test that the PVT envelope stays ≥ the nominal bound
32-
across the full operating rectangle.
33-
- Extend instrument import for VCD `$date`/`$version`/`$comment` headers and
34-
analog CSV voltage columns.
35-
- Build a standalone Lean proof integration test from a synthetic CSV.
36-
- Document the first-real-capture checklist in `fpga/HARDWARE_SSOT.md`.
32+
- Extend instrument-import parity: additional VCD/CSV formats and hardened
33+
`$comment` sections.
34+
- Add PVT envelope monotonicity/antitonicity tests in Rust and Lean.
35+
- Document the standalone `lake`-package workflow end-to-end in
36+
`fpga/HARDWARE_SSOT.md`.
3737

3838
---
3939

4040
## Decomposed plan
4141

42-
See `docs/reports/FPGA_LOOP_COOPERATION_W418_2026-07-04.md`.
42+
See `docs/reports/FPGA_LOOP_COOPERATION_W419_2026-07-04.md` and
43+
`.claude/plans/wave-loop-419.md`.
4344

4445
| Step | File(s) | Deliverable |
4546
|------|---------|-------------|
46-
| 1 | `cli/tri/src/fpga.rs` | Variant A import, B relay backend, or C regression/integration tests |
47-
| 2 | `proofs/lean4/Trinity/TernaryFPGABoot.lean` | PVT envelope regression lemma or new measured theorems |
47+
| 1 | `cli/tri/src/fpga.rs` | Variant A import, B relay backend, or C parity/monotonicity tests |
48+
| 2 | `proofs/lean4/Trinity/TernaryFPGABoot.lean` | PVT monotonicity lemmas or new measured theorems |
4849
| 3 | `fpga/HARDWARE_SSOT.md` | Updated capture / relay / integration protocol |
49-
| 4 | `docs/reports/*` | W418 report, evidence, W419 cooperation |
50-
| 5 | `.trinity/experience.md` | W418 learnings |
51-
| 6 | git/PR | squash-merge to `master`, close #1353, open #? for W419 |
50+
| 4 | `docs/reports/*` | W419 report, evidence, W420 cooperation |
51+
| 5 | `.trinity/experience.md` | W419 learnings |
52+
| 6 | git/PR | squash-merge to `master`, close #1357, open #? for W420 |
5253

5354
---
5455

@@ -57,29 +58,40 @@ See `docs/reports/FPGA_LOOP_COOPERATION_W418_2026-07-04.md`.
5758
### Bundle A
5859
- [ ] AC-A1: P12 is wired to a logic-analyzer channel and real CCLK capture files exist for `OSCFSEL=6` and `OSCFSEL=7`.
5960
- [ ] AC-A2: `tri fpga measured-to-lean --csv/--vcd --raw-ns --standalone` generated Lean files build with `lake build`.
60-
- [ ] AC-A3: Measured CCLK is within the N25Q128_3V spec, or any exceedance is explicitly explained.
61+
- [ ] AC-A3: Measured CCLK satisfies the PVT-aware flash spec, or any exceedance is explicitly explained.
6162

6263
### Bundle B
6364
- [ ] AC-B1: `tri fpga cold-por <bit> --relay-port <real>` performs an automated power-cycle and captures STAT.
6465
- [ ] AC-B2: The resulting log has `relay_mock: false` and a real STAT raw value.
65-
- [ ] AC-B3: `fpga/HARDWARE_SSOT.md` documents relay wiring and port mapping.
66+
- [ ] AC-B3: `fpga/HARDWARE_SSOT.md` documents relay wiring and port syntax.
6667

6768
### Bundle C
68-
- [ ] AC-C1: A regression test verifies the PVT envelope lower bound across the operating rectangle.
69-
- [ ] AC-C2: Instrument import handles VCD `$date`/`$version`/`$comment` headers or analog CSV voltage columns.
70-
- [ ] AC-C3: A standalone `.lean` file generated from the CLI type-checks in a temporary `lake` package.
69+
- [x] AC-C1: At least one additional instrument-import unit test lands (VCD `$comment` hardening + CSV `--csv-channel` explicit select).
70+
- [x] AC-C2: Rust and Lean tests verify PVT envelope monotonicity/antitonicity.
71+
- [x] AC-C3: The standalone lake-package workflow is documented end-to-end.
7172

7273
### Invariant checks
73-
- [ ] `./scripts/tri test` parse/typecheck/gen/seal-verify phases pass.
74-
- [ ] `lake build Trinity.TernaryFPGABoot` passes.
75-
- [ ] `cargo test -p tri fpga::tests` passes.
74+
- [x] `./scripts/tri test` parse/typecheck/gen/seal-verify phases pass.
75+
- [x] `lake build Trinity.TernaryFPGABoot` passes.
76+
- [x] `cargo test -p tri fpga::tests` passes.
77+
78+
---
79+
80+
## PR
81+
- Target: `master`
82+
- PR: #1360
83+
- Body: `Closes #1357`
84+
- Report: `docs/reports/WAVE_LOOP_419_REPORT.md`
85+
- Evidence: `docs/reports/FPGA_LOOP_EVIDENCE_W419_2026-07-05.md`
86+
- Cooperation W420: `docs/reports/FPGA_LOOP_COOPERATION_W420_2026-07-05.md`
7687

7788
---
7889

7990
## Default variant
8091

81-
Execute **Variant A** if the analyzer is wired. Otherwise try **Variant B** if a
82-
relay is available. Otherwise fall back to **Variant C**.
92+
Execute **Variant A** if the analyzer and DLC10 cable are available. Otherwise
93+
try **Variant B** if a relay and DLC10 cable are available. Otherwise fall back
94+
to **Variant C**.
8395

8496
---
8597

.trinity/current_task/activity.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,3 +1460,7 @@
14601460
- **Commit:** docs(NOW): W418 setup, mark W417 PR #1354 merged
14611461
- **Files:** .claude/plans/wave-loop-418.md,.trinity/experience.md,cli/tri/src/fpga.rs,docs/NOW.md,docs/reports/FPGA_LOOP_COOPERATION_W419_2026-07-04.md,docs/reports/FPGA_LOOP_EVIDENCE_W418_2026-07-04.md,docs/reports/WAVE_LOOP_418_REPORT.md,fpga/HARDWARE_SSOT.md,proofs/lean4/Trinity/TernaryFPGABoot.lean
14621462

1463+
## 2026-07-04T18:22:51Z — wave-loop-419-clean
1464+
- **Commit:** docs(w420): set W420 issue number to #1361 and record W419 PR #1360 (Closes #1357, Refs #1361)
1465+
- **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
1466+

.trinity/experience.md

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

3+
## 2026-07-05 — Wave Loop 419 (Variant C fallback: VCD/CSV hardening, PVT monotonicity, standalone lake workflow)
4+
5+
### What worked
6+
- Hardening the VCD `$comment` parser with an **exact-token terminator** closed a
7+
real regression vector: vendor comments that contain the substring `$end` no
8+
longer confuse the signal dictionary. A single regression test with an embedded
9+
`$end`-like token prevents future heuristic drift.
10+
- Adding `--csv-channel <name>` and extending header-name auto-detection to
11+
`cclk`, `vccint`, `vccaux`, `ain`, `a0`, `channel0` makes multi-channel
12+
instrument exports first-class. The explicit selector is simpler than trying to
13+
guess every vendor dialect.
14+
- Proving PVT envelope **monotonicity in temperature** and **antitonicity in
15+
VCCINT** in both Lean 4 and Rust guards the shape of the placeholder envelope
16+
independently of the exact coefficients. The symbolic Lean proofs and the
17+
numeric Rust tests reinforce each other.
18+
- Documenting the full `measured-to-lean --standalone` lake-package workflow in
19+
`fpga/HARDWARE_SSOT.md` turned a "works in tests" feature into a reproducible
20+
user protocol.
21+
- Catching the invalid `import Trinity.BitstreamConfig` in the `--standalone`
22+
output showed that **string assertions are not enough** for generated-code
23+
tests: the integration test that runs `lake build` on the generated file is
24+
what found the bug.
25+
26+
### What changed behavior
27+
- `cli/tri/src/fpga.rs`: VCD `$comment` exact-terminator parsing;
28+
`--csv-channel` option and multi-channel header detection;
29+
`test_pvt_half_ns_monotone_in_temp` / `test_pvt_half_ns_antitone_in_vccint`;
30+
`test_parse_cclk_csv_explicit_channel_select`;
31+
`--standalone` template now imports only `Trinity.TernaryFPGABoot`.
32+
- `proofs/lean4/Trinity/TernaryFPGABoot.lean`: added
33+
`pvt_half_ns_monotone_in_temp` and `pvt_half_ns_antitone_in_vccint`.
34+
- `fpga/HARDWARE_SSOT.md`: added §3.6.16 standalone lake-package workflow.
35+
- `docs/NOW.md`: W419 close-out and W420 setup.
36+
- Close-out artifacts: `docs/reports/WAVE_LOOP_419_REPORT.md`,
37+
`docs/reports/FPGA_LOOP_EVIDENCE_W419_2026-07-05.md`, and
38+
`docs/reports/FPGA_LOOP_COOPERATION_W420_2026-07-05.md`.
39+
40+
### Patterns to reuse
41+
- For section-skipping parsers, match the **exact delimiter token** and clear
42+
state immediately when the delimiter appears on the same line; do not use
43+
substring heuristics.
44+
- When adding user-facing selectors to instrument parsers, also add a
45+
regression test that would fail if the selector is ignored or the fallback
46+
overrides it.
47+
- For placeholder model coefficients, prove the **shape** (monotonicity,
48+
bounds) symbolically and add a numeric operating-rectangle regression. This
49+
combination survives coefficient updates as long as the shape constraints
50+
remain.
51+
- For generated-code deliverables, the canonical integration test is to
52+
**type-check the generated artifact in a fresh package** that depends on the
53+
real library via a local path. String snapshots catch regressions; package
54+
builds catch invalid imports and namespaces.
55+
56+
### Anti-patterns to avoid
57+
- Do not assert only string contents for generated source files; always exercise
58+
the downstream compiler/package build.
59+
- Do not import a Lean 4 **namespace** as if it were a module. Names inside a
60+
file are reached through the file's module name, then opened with `open` if
61+
needed.
62+
- Do not let a parser heuristic silently override an explicit user option;
63+
resolve precedence clearly (explicit option > named header > numeric fallback).
64+
365
## 2026-07-04 — Wave Loop 418 (Variant C fallback: PVT regression, instrument import, standalone Lean integration)
466

567
### What worked

0 commit comments

Comments
 (0)