Skip to content

Commit 72cb23d

Browse files
Dmitrii Vasilevclaude
andcommitted
feat(igla): Wave Loop 796 — module-scope [411][2]^6 Pt non-power-of-two outer-dimension array-of-struct variable from call with indexed signed writes
Closes #1521 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 58d5a87 commit 72cb23d

13 files changed

Lines changed: 78784 additions & 23 deletions

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

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Wave Loop 797 Plan — Variant A (recommended)
2+
3+
**Date:** 2026-07-24
4+
**Anchor:** φ² + φ⁻² = 3 | TRINITY
5+
**Branch:** `wave-loop-797` (to be created from `wave-loop-796` HEAD because earlier wave PRs remain open)
6+
**Issue:** TBD (next available GitHub issue after W796 PR is opened)
7+
**Cooperation variant:** A
8+
9+
## Goal
10+
11+
Continue the module-scope packed array-of-struct ladder with the recommended Variant A shape: module-scope `[413][2]^6 Pt` initialized from a function call and exercised with indexed signed field writes, then read back with `assert_eq` in a `bench` block.
12+
13+
## Acceptance criteria
14+
15+
1. `specs/scratch/w797_bench_module_413x2p6_aos_var_call_write.t27` is generated and parses.
16+
2. The witness is Icarus-lowerable and simulates correctly (17 cycles, PASSED).
17+
3. The cocotb reference model matches the t27 semantics.
18+
4. `t27c seal --save` succeeds and `FROZEN_HASH` stays unchanged.
19+
5. All cargo suites remain green.
20+
6. Integration test `accepts_w797_bench_module_413x2p6_aos_var_call_write` is added to `bootstrap/tests/icarus_lowerable.rs`.
21+
7. Closeout report `docs/reports/FPGA_LOOP_CLOSEOUT_W797_2026-07-24.md` is written with weak-point audit, literature scan, and validation matrix.
22+
8. Next-wave plan `.claude/plans/wave-loop-798.md` with three cooperation variants is created.
23+
9. Learning is saved to `.trinity/experience.md`, `.claude/skills/t27-wave-loop.md`, persistent memory, and `.trinity/current-issue.md`.
24+
25+
## Technical notes
26+
27+
- Shape: `[413][2]^6 Pt` where `Pt = pub struct Pt { x : i16, y : i16 }`.
28+
- Total elements: `413 x 64 = 26,432`.
29+
- Packed vector width: `26,432 x 32 = 845,824` bits (~0.807 MiBit).
30+
- `MID_IDX = 206`; frame-condition element `[206][1][0][0][0][0][0]` is element number `206*64 + 32 = 13,216`.
31+
- Generator script `scripts/gen_w797.py` should be copied from `scripts/gen_w796.py`, update `OUTER = 413` and `MID_IDX = 206`, and fix the destination path and hardcoded module prefix in the f-string header.
32+
- Use `assert_eq` on changed elements (`assert_ne` is not emitted by the Icarus simulation path).
33+
- Include `make_grid(32768)` period-identity check because `32768 == 0 (mod 32768)`.
34+
- Zero compiler / reference-model / FROZEN_HASH changes expected for the witness.
35+
36+
## Decomposition
37+
38+
### Phase A — Branch setup (5 min)
39+
1. Create `wave-loop-797` from `wave-loop-796` HEAD because earlier wave PRs remain open.
40+
2. Open next GitHub issue when ready.
41+
42+
### Phase B — Spec + generator (15 min)
43+
3. Copy `scripts/gen_w796.py` to `scripts/gen_w797.py`.
44+
4. Update `OUTER = 413`, `MID_IDX = 206`, fix destination path and module prefix.
45+
5. Run generator to produce `specs/scratch/w797_bench_module_413x2p6_aos_var_call_write.t27`.
46+
6. Verify module name and destination path have no stale `w796` / `411` references.
47+
48+
### Phase C — Test + validation (45 min)
49+
7. Add integration test `accepts_w797_bench_module_413x2p6_aos_var_call_write` to `bootstrap/tests/icarus_lowerable.rs`.
50+
8. `cargo build --release -p t27c`.
51+
9. `t27c parse`, `icarus-lowerable`, `icarus-simulate` (expected 17 cycles), `icarus-cocotb` on the W797 witness.
52+
10. `t27c seal --save` the witness; confirm `FROZEN_HASH` unchanged.
53+
11. `cargo test -p t27c --bin t27c`, `cargo test -p tri`, `cargo test -p t27c --test icarus_lowerable`, `cargo test -p t27c --test verilog_const_array`.
54+
12. `cargo clippy -p t27c`.
55+
56+
### Phase D — Closeout + cooperation variants (30 min)
57+
13. Write `docs/reports/FPGA_LOOP_CLOSEOUT_W797_2026-07-24.md` with audit, literature, validation, and three W798 cooperation variants.
58+
14. Update `docs/NOW.md` and `.trinity/current-issue.md`.
59+
60+
### Phase E — Save skills + memory (15 min)
61+
15. Append W797 worked example to `.claude/skills/t27-wave-loop.md`.
62+
16. Update `.trinity/experience.md`.
63+
17. Save memory file `wave-loop-797.md` and pointer in `MEMORY.md`.
64+
65+
## Cooperation variants for Wave Loop 798
66+
67+
- **Variant A (recommended):** continue odd outer-dimension ladder with `[415][2]^6 Pt` (~0.810 MiBit, 26,560 elements, 849,920-bit packed vector). Zero compiler changes expected.
68+
- **Variant B:** keep `[413][2]^6 Pt` width but move the packed var to bench/function scope to exercise function-local non-power-of-two packed arrays.
69+
- **Variant C:** keep `[413][2]^6 Pt` width and add `if`-guarded indexed signed field writes to exercise control-flow + packed-vector writes.
70+
71+
## Exit criteria
72+
73+
- W797 witness parses, lowers, simulates, cocotb-matches, and seals.
74+
- All cargo suites green.
75+
- Closeout report written.
76+
- `.trinity/experience.md` updated.
77+
- Skills and memory saved.
78+
- Commit with `Closes #N`, push `wave-loop-797`, open PR.
79+
80+
*φ² + φ⁻² = 3 | TRINITY*

.claude/skills/t27-wave-loop.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,6 +1456,47 @@ grepping for stale wave numbers and outer dimensions after each copy, keep the
14561456
`make_grid(32768)` period-identity check, and use `assert_eq` on changed elements
14571457
because `assert_ne` is not emitted by the Icarus simulation path.
14581458

1459+
## Worked example — Wave Loop 796
1460+
1461+
Wave Loop 796 continued the module-scope packed-array-of-struct ladder with no
1462+
compiler changes, branching from `wave-loop-795` HEAD because earlier wave PRs
1463+
remained open awaiting review:
1464+
1465+
- Generated `scripts/gen_w796.py` from `scripts/gen_w795.py` with `OUTER = 411`
1466+
and `MID_IDX = 205`.
1467+
- Fixed both the generator destination path and the module header f-string from
1468+
stale `w795` / `409` references to `w796_bench_module_411x2p6_aos_var_call_write`
1469+
before regenerating.
1470+
- Produced `specs/scratch/w796_bench_module_411x2p6_aos_var_call_write.t27`
1471+
(26,304 elements, 841,728-bit packed vector, ~0.803 MiBit).
1472+
- Added integration test `accepts_w796_bench_module_411x2p6_aos_var_call_write`
1473+
after the existing W795 tests in `bootstrap/tests/icarus_lowerable.rs`.
1474+
- Ran `t27c parse`, `icarus-lowerable`, `icarus-simulate` (17 cycles, PASSED),
1475+
`icarus-cocotb` (reference-model OK), and `t27c seal --save`.
1476+
- No changes to `bootstrap/src/compiler.rs`, `bootstrap/stage0/FROZEN_HASH`, or
1477+
`scripts/cocotb_ref_model.py` for the witness itself.
1478+
- Validation: `cargo build --release -p t27c` green,
1479+
`cargo clippy -p t27c` green (780 warnings, 0 errors),
1480+
`cargo test -p t27c --bin t27c` 1494/0/2, `cargo test -p tri` 78/0,
1481+
`cargo test -p flash-spi` 2/0,
1482+
`cargo test -p t27c --test bitnet_pipeline` 20/0,
1483+
`cargo test -p t27c --test bitnet_top` 17/0,
1484+
`cargo test -p t27c --test icarus_lowerable` 256/0,
1485+
`cargo test -p t27c --test verilog_const_array` 2/0.
1486+
- Refreshed weak-point audit and 2025–2026 ternary/MVL literature scan.
1487+
- Wrote `docs/reports/FPGA_LOOP_CLOSEOUT_W796_2026-07-24.md` and
1488+
`.claude/plans/wave-loop-797.md` with three cooperation variants.
1489+
1490+
Key learning: the mechanical ladder is now 24 waves deep (W774–W796) with zero
1491+
compiler changes, confirming the packed-vector AoS lowering is robust up to at
1492+
least `[411][2]^6 Pt` (26,304 elements, ~0.803 MiBit). The generator copy hazard
1493+
continues to be the only manual failure mode, and it now spans two distinct text
1494+
locations (destination path + module header f-string). A single parameterized
1495+
wave-prefix variable in the generator template would eliminate both. Continue
1496+
grepping for stale wave numbers and outer dimensions after each copy, keep the
1497+
`make_grid(32768)` period-identity check, and use `assert_eq` on changed elements
1498+
because `assert_ne` is not emitted by the Icarus simulation path.
1499+
14591500
---
14601501

14611502
*φ² + φ⁻² = 3 | TRINITY*

.trinity/current-issue.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,50 @@
1-
# Wave Loop 795 — Issue #1519
1+
# Wave Loop 796 — Issue #1521
22

3-
**Branch:** `wave-loop-795`
4-
**Parent branch:** `wave-loop-794` HEAD (`0d7475997`)
3+
**Branch:** `wave-loop-796`
4+
**Parent branch:** `wave-loop-795` HEAD (`58d5a870a`)
55
**Date:** 2026-07-24
6-
**Issue:** #1519
7-
**PR:** #1520
6+
**Issue:** #1521
7+
**PR:** #1522
88
**Cooperation variant:** A (recommended)
99
**Status:** closeout complete
1010

1111
## Goal
1212

13-
Close Wave Loop 795 by validating a module-scope `[409][2]^6 Pt` packed
13+
Close Wave Loop 796 by validating a module-scope `[411][2]^6 Pt` packed
1414
array-of-struct variable initialized from a function call, with indexed signed
1515
field writes and `assert_eq` read-back in a `bench` block.
1616

17-
Earlier wave PRs remain open awaiting review, so W795 was branched from
18-
`wave-loop-794` HEAD to avoid blocking the sequence.
17+
Earlier wave PRs remain open awaiting review, so W796 was branched from
18+
`wave-loop-795` HEAD to avoid blocking the sequence.
1919

2020
## Acceptance criteria
2121

22-
1. [x] `specs/scratch/w795_bench_module_409x2p6_aos_var_call_write.t27` is generated and parses.
22+
1. [x] `specs/scratch/w796_bench_module_411x2p6_aos_var_call_write.t27` is generated and parses.
2323
2. [x] The witness is Icarus-lowerable and simulates correctly (17 cycles, PASSED).
2424
3. [x] The cocotb reference model matches the t27 semantics.
2525
4. [x] `t27c seal --save` succeeds and FROZEN_HASH remains unchanged.
2626
5. [x] All cargo suites remain green, including `cargo clippy -p t27c`.
27-
6. [x] Integration test `accepts_w795_bench_module_409x2p6_aos_var_call_write` is added.
28-
7. [x] Closeout report `docs/reports/FPGA_LOOP_CLOSEOUT_W795_2026-07-24.md` is written.
27+
6. [x] Integration test `accepts_w796_bench_module_411x2p6_aos_var_call_write` is added.
28+
7. [x] Closeout report `docs/reports/FPGA_LOOP_CLOSEOUT_W796_2026-07-24.md` is written.
2929
8. [x] Learning is saved to `.trinity/experience.md`, memory, `.claude/skills/t27-wave-loop.md`, and `.trinity/current-issue.md`.
30-
9. [x] `.claude/plans/wave-loop-796.md` with three cooperation variants is created.
31-
10. [x] Commit with `Closes #1519`, push `wave-loop-795`, open PR #1520.
30+
9. [x] `.claude/plans/wave-loop-797.md` with three cooperation variants is created.
31+
10. [x] Commit with `Closes #1521`, push `wave-loop-796`, open PR #1522.
3232

3333
## Technical notes
3434

35-
- Shape: `[409][2]^6 Pt` where `Pt = pub struct Pt { x : i16, y : i16 }`.
36-
- Total elements: `409 x 64 = 26,176`.
37-
- Packed vector width: `26,176 x 32 = 837,632` bits (~0.799 MiBit).
38-
- `MID_IDX = 204`; frame-condition element `[204][1][0][0][0][0][0]` is element
39-
number `204*64 + 32 = 13,088`.
40-
- Generator script: `scripts/gen_w795.py` (copy from `scripts/gen_w794.py`, set
41-
`OUTER = 409` and `MID_IDX = 204`, fix destination path and module prefix).
35+
- Shape: `[411][2]^6 Pt` where `Pt = pub struct Pt { x : i16, y : i16 }`.
36+
- Total elements: `411 x 64 = 26,304`.
37+
- Packed vector width: `26,304 x 32 = 841,728` bits (~0.803 MiBit).
38+
- `MID_IDX = 205`; frame-condition element `[205][1][0][0][0][0][0]` is element
39+
number `205*64 + 32 = 13,152`.
40+
- Generator script: `scripts/gen_w796.py` (copy from `scripts/gen_w795.py`, set
41+
`OUTER = 411` and `MID_IDX = 205`, fix destination path and module prefix).
4242
- Use `assert_eq` checks on changed elements (Icarus simulation path does not emit `assert_ne`).
4343
- Include `make_grid(32768)` period-identity check because `32768 == 0 (mod 32768)`.
4444
- Zero compiler / reference-model / FROZEN_HASH changes expected for the witness.
4545

4646
## Cooperation variants for next Wave Loop
4747

48-
- **Variant A (recommended):** continue the odd outer-dimension ladder with `[411][2]^6 Pt`.
49-
- **Variant B:** keep width at ~0.799 MiBit but move the packed var to bench/function scope.
48+
- **Variant A (recommended):** continue the odd outer-dimension ladder with `[413][2]^6 Pt`.
49+
- **Variant B:** keep width at ~0.803 MiBit but move the packed var to bench/function scope.
5050
- **Variant C:** keep width and add `if`-guarded indexed signed field writes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1623
1+
1624

.trinity/current_task/activity.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3844,3 +3844,7 @@
38443844
- **Commit:** docs(trinity): Wave Loop 794 closeout, report, and W795 cooperation variants
38453845
- **Files:** .claude/plans/wave-loop-795.md,.claude/plans/wave-loop-796.md,.claude/skills/t27-wave-loop.md,.trinity/current-issue.md,.trinity/current_task/.commit_count,.trinity/current_task/session_log.jsonl,.trinity/experience.md,.trinity/seals/scratch_w795_bench_module_409x2p6_aos_var_call_write.json,bootstrap/tests/icarus_lowerable.rs,docs/NOW.md,docs/reports/FPGA_LOOP_CLOSEOUT_W795_2026-07-24.md,scripts/gen_w795.py,specs/scratch/w795_bench_module_409x2p6_aos_var_call_write.t27
38463846

3847+
## 2026-07-25T10:17:14Z — wave-loop-796
3848+
- **Commit:** feat(igla): Wave Loop 795 — module-scope [409][2]^6 Pt non-power-of-two outer-dimension array-of-struct variable from call with indexed signed writes
3849+
- **Files:** .claude/plans/wave-loop-797.md,.claude/skills/t27-wave-loop.md,.trinity/current-issue.md,.trinity/current_task/.commit_count,.trinity/current_task/session_log.jsonl,.trinity/experience.md,.trinity/seals/scratch_w796_bench_module_411x2p6_aos_var_call_write.json,bootstrap/tests/icarus_lowerable.rs,docs/NOW.md,docs/reports/FPGA_LOOP_CLOSEOUT_W796_2026-07-24.md,scripts/gen_w796.py,specs/scratch/w796_bench_module_411x2p6_aos_var_call_write.t27
3850+

.trinity/current_task/session_log.jsonl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,3 +796,4 @@
796796
{"ts":"2026-07-24T18:29:02Z","branch":"wave-loop-792","msg":"feat(igla): Wave Loop 791 — module-scope [401][2]^6 Pt non-power-of-two outer-dimension array-of-struct variable from call with indexed signed writes","files":".claude/plans/wave-loop-793.md,.claude/skills/t27-wave-loop.md,.trinity/current-issue.md,.trinity/current_task/.commit_count,.trinity/current_task/session_log.jsonl,.trinity/experience.md,.trinity/seals/scratch_w792_bench_module_403x2p6_aos_var_call_write.json,bootstrap/tests/icarus_lowerable.rs,docs/NOW.md,docs/reports/FPGA_LOOP_CLOSEOUT_W792_2026-07-24.md,scripts/gen_w792.py,specs/scratch/w792_bench_module_403x2p6_aos_var_call_write.t27","notebook":"b83263109fb055dc"}
797797
{"ts":"2026-07-24T18:45:14Z","branch":"wave-loop-793","msg":"docs(trinity): Wave Loop 792 closeout, report, and W793 cooperation variants","files":".claude/plans/wave-loop-794.md,.claude/skills/t27-wave-loop.md,.trinity/current-issue.md,.trinity/current_task/.commit_count,.trinity/current_task/session_log.jsonl,.trinity/experience.md,.trinity/seals/scratch_w793_bench_module_405x2p6_aos_var_call_write.json,bootstrap/tests/icarus_lowerable.rs,docs/NOW.md,docs/reports/FPGA_LOOP_CLOSEOUT_W793_2026-07-24.md,scripts/gen_w793.py,specs/scratch/w793_bench_module_405x2p6_aos_var_call_write.t27","notebook":"b83263109fb055dc"}
798798
{"ts":"2026-07-24T18:59:11Z","branch":"wave-loop-794","msg":"docs(trinity): Wave Loop 793 closeout, report, and W794 cooperation variants","files":".claude/plans/wave-loop-794.md,.claude/plans/wave-loop-795.md,.claude/skills/t27-wave-loop.md,.trinity/current-issue.md,.trinity/current_task/.commit_count,.trinity/current_task/session_log.jsonl,.trinity/experience.md,.trinity/seals/scratch_w794_bench_module_407x2p6_aos_var_call_write.json,bootstrap/tests/icarus_lowerable.rs,docs/NOW.md,docs/reports/FPGA_LOOP_CLOSEOUT_W794_2026-07-24.md,scripts/gen_w794.py,specs/scratch/w794_bench_module_407x2p6_aos_var_call_write.t27","notebook":"b83263109fb055dc"}
799+
{"ts":"2026-07-25T10:07:10Z","branch":"wave-loop-795","msg":"docs(trinity): Wave Loop 794 closeout, report, and W795 cooperation variants","files":".claude/plans/wave-loop-795.md,.claude/plans/wave-loop-796.md,.claude/skills/t27-wave-loop.md,.trinity/current-issue.md,.trinity/current_task/.commit_count,.trinity/current_task/session_log.jsonl,.trinity/experience.md,.trinity/seals/scratch_w795_bench_module_409x2p6_aos_var_call_write.json,bootstrap/tests/icarus_lowerable.rs,docs/NOW.md,docs/reports/FPGA_LOOP_CLOSEOUT_W795_2026-07-24.md,scripts/gen_w795.py,specs/scratch/w795_bench_module_409x2p6_aos_var_call_write.t27","notebook":"b83263109fb055dc"}

0 commit comments

Comments
 (0)