From 3c6b5951dd2f7ef2f042d63ae4cc31ebdc695286 Mon Sep 17 00:00:00 2001 From: Trinity Bee Date: Sat, 10 Oct 2026 00:53:54 +0000 Subject: [PATCH 1/3] Port scripts/gen_w672.py to specs/port/scripts/gen_w672.t27 Mirror of the twice-reviewed gen_w631..gen_w662 family pattern (definitive template gen_w662.t27): the original writes a 163x2^6 Pt grid literal whose points are numbered (2e + offset) % 32768, so the port carries the decisions as pure helpers -- indent (4 spaces per level), coordinate ((2e + offset + step) % 32768), build_tree (base + n * inner_points) -- and leaves the text assembly and file write to a generate() stub, per "port the decision, not the plumbing". Six tests pin the original's behaviour: indent width, first point (0, 1), last point and the dst[81][1][0][0][0][0][0] mid point (the original's comment says "# 73" but the code computes 163 // 2 = 81 -- a comment is not a value, so the port carries the code's values 5216/10432/10433), the 32768-offset wrap, base threading, and the whole-grid 10432 point count. t27c parse, typecheck and test-report (6/6 passing, 0 vacuous) all clean; t27c gen emits 68 lines with zero "not yet implemented". Closes #8265 --- specs/port/scripts/gen_w672.t27 | 80 +++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 specs/port/scripts/gen_w672.t27 diff --git a/specs/port/scripts/gen_w672.t27 b/specs/port/scripts/gen_w672.t27 new file mode 100644 index 0000000000..5712583c20 --- /dev/null +++ b/specs/port/scripts/gen_w672.t27 @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: Apache-2.0 +// Port of scripts/gen_w672.py (issue #8265). +// The original writes the spec w672_bench_module_163x2p6_aos_var_call_write.t27: a +// [163][2][2][2][2][2][2]Pt grid literal whose points are numbered in row-major order. +// The decisions in it are the indent width, the coordinate of each point (2e + offset, +// wrapped at 32768) and how many points a subtree consumes. Building the text and +// writing the file are plumbing. One note on the original's comments: the comment +// on MID_IDX says "# 73" but the code computes 163 // 2 = 81; a comment is not a +// value, and this port carries the code's value. +module gen_w672 { + const WRAP: u32 = 32768; + const INDENT_UNIT: u32 = 4; + + // indent(level): the number of spaces for one indent level (" " * level). + fn indent(level: u32) -> u32 { + return INDENT_UNIT * level; + } + + // coordinate(e, offset, step): x is step 0, y is step 1 -> (2e + offset + step) % 32768. + fn coordinate(e: u32, offset: u32, step: u32) -> u32 { + return (2 * e + offset + step) % WRAP; + } + + // build_tree(n, inner_points, base): the next base after n subtrees of inner_points + // points each, starting at base. A leaf row is n subtrees of one point. + fn build_tree(n: u32, inner_points: u32, base: u32) -> u32 { + var b: u32 = base; + var i: u32 = 0; + while (i < n) { + b = b + inner_points; + i = i + 1; + } + return b; + } + + // Plumbing: assembles the text and writes the .t27 file; no test calls it. + fn generate() -> u32 { + undefined; + } + + test indent_is_four_spaces_per_level { + assert(indent(0) == 0); + assert(indent(1) == 4); + assert(indent(2) == 8); + } + + test first_point_is_zero_one { + assert(coordinate(0, 0, 0) == 0); + assert(coordinate(0, 0, 1) == 1); + } + + test last_point_matches_the_generated_expectations { + // 163 * 64 = 10432 points, the last has e = 10431: x = 20862, y = 20863. + assert(coordinate(10431, 0, 0) == 20862); + assert(coordinate(10431, 0, 1) == 20863); + // The point at dst[81][1][0][0][0][0][0] has e = 81 * 64 + 32 = 5216. + assert(coordinate(5216, 0, 0) == 10432); + assert(coordinate(5216, 0, 1) == 10433); + } + + test offset_32768_wraps_back { + assert(coordinate(0, 32768, 0) == 0); + assert(coordinate(0, 32768, 1) == 1); + assert(coordinate(10431, 32768, 0) == 20862); + assert(coordinate(10431, 32768, 1) == 20863); + } + + test build_tree_advances_the_base { + // leaf row of 163 single points starting at 0 + assert(build_tree(163, 1, 0) == 163); + // 2 subtrees of 32 points from base 10 + assert(build_tree(2, 32, 10) == 74); + assert(build_tree(0, 5, 7) == 7); + } + + test whole_grid_has_10432_points { + // 163 * 2^6 points: 163 outer entries of 64 points each + assert(build_tree(163, 64, 0) == 10432); + } +} From 8c0f722cda08a1aaaf8c0e6429c00ac9fe4e74fd Mon Sep 17 00:00:00 2001 From: "queen-publisher[bot]" Date: Sat, 10 Oct 2026 04:55:14 +0000 Subject: [PATCH 2/3] docs: the coordination entry this branch needs to land A pull request must add exactly one docs/now entry and a bee has no way to know that: its brief names a boundary file and acceptance criteria, and docs/now/ is neither. The publisher adds it rather than failing the gate. Closes #8265 Co-Authored-By: Claude Opus 5 --- ...gen-w672-py-python-3-functions-to-specs-port-sc.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 docs/now/2026-10-10-published-port-scripts-gen-w672-py-python-3-functions-to-specs-port-sc.md diff --git a/docs/now/2026-10-10-published-port-scripts-gen-w672-py-python-3-functions-to-specs-port-sc.md b/docs/now/2026-10-10-published-port-scripts-gen-w672-py-python-3-functions-to-specs-port-sc.md new file mode 100644 index 0000000000..d22319e635 --- /dev/null +++ b/docs/now/2026-10-10-published-port-scripts-gen-w672-py-python-3-functions-to-specs-port-sc.md @@ -0,0 +1,11 @@ +# NOW -- Port scripts/gen_w672.py (Python, 3 functions) to specs/port/scripts/gen_w672.t27 (published 2026-10-10) + +## A bee's work on #8265, published from `queen-8265` (Closes #8265) + +- The branch changes 1 file(s): `specs/port/scripts/gen_w672.t27`. +- `git diff --stat origin/master...queen-8265` reads: 1 file changed, 80 insertions(+) +- This entry is written by the publisher, not by the bee. A pull request must + add exactly one `docs/now/` entry and a bee has no way to know that: its brief + names a boundary file and acceptance criteria, and `docs/now/` is neither. +- What this entry does NOT establish: that the work is correct. The gates on the + pull request judge that, and they are the same gates every other change meets. From f79d4c4e36bba6df50943c1e2db62431052e7c21 Mon Sep 17 00:00:00 2001 From: Dmitrii Vasilev Date: Mon, 12 Oct 2026 17:44:59 +0700 Subject: [PATCH 3/3] fix(port): port build_tree as the original's recursion, not a flat sum The flat 'n subtrees of inner_points points each' loop missed the algorithm: the original recurses over shape[1:], one dimension per level, a leaf row laying out n single points and every inner level running n subtrees one after another, each starting from the base the previous sibling ended on. Ported with SHAPE: [7]u32 and a recursive build_tree(shape, depth, base), the way gen_w692 did (#8718), and the expected-value constants (TOTAL, MID_E, LAST_X..) the original substitutes into the emitted test now live here as consts instead of inline literals. The body also leaves the 28-member flat build_tree duplicate group: t27c dupes --bodies no longer lists gen_w672 under build_tree. t27c test-report on the branch: 7 tests, 7 pass, 0 FAIL, 100%, 0 vacuous. Refs #8265 Co-Authored-By: Claude Opus 5.5 --- specs/port/scripts/gen_w672.t27 | 100 +++++++++++++++++++++++--------- 1 file changed, 72 insertions(+), 28 deletions(-) diff --git a/specs/port/scripts/gen_w672.t27 b/specs/port/scripts/gen_w672.t27 index 5712583c20..1c27cfd797 100644 --- a/specs/port/scripts/gen_w672.t27 +++ b/specs/port/scripts/gen_w672.t27 @@ -2,15 +2,35 @@ // Port of scripts/gen_w672.py (issue #8265). // The original writes the spec w672_bench_module_163x2p6_aos_var_call_write.t27: a // [163][2][2][2][2][2][2]Pt grid literal whose points are numbered in row-major order. -// The decisions in it are the indent width, the coordinate of each point (2e + offset, -// wrapped at 32768) and how many points a subtree consumes. Building the text and -// writing the file are plumbing. One note on the original's comments: the comment -// on MID_IDX says "# 73" but the code computes 163 // 2 = 81; a comment is not a -// value, and this port carries the code's value. +// The decisions in it are the expected point values the generated test asserts, the +// indent width, the coordinate of each point (2e + offset, wrapped at 32768) and the +// row-major point numbering build_tree's recursion threads through the shape. +// Building the text and writing the file are plumbing. module gen_w672 { const WRAP: u32 = 32768; const INDENT_UNIT: u32 = 4; + // Expected values the original substitutes into the emitted test (lines 9-21): + // 163 * 2^6 = 10432 points, the last at e = 10431, the mid one at + // dst[MID_IDX][1][0][0][0][0][0]. The original's "# 73" comment on MID_IDX is + // stale: 163 // 2 is 81, and 81 is what the original actually substitutes. + const OUTER: u32 = 163; + const TOTAL: u32 = OUTER * 64; + const LAST_IDX: u32 = OUTER - 1; + const MID_IDX: u32 = OUTER / 2; + const MID_E: u32 = MID_IDX * 64 + 32; + const LAST_X: u32 = (2 * (TOTAL - 1)) % WRAP; + const LAST_Y: u32 = (2 * (TOTAL - 1) + 1) % WRAP; + const MID_X: u32 = (2 * MID_E) % WRAP; + const MID_Y: u32 = (2 * MID_E + 1) % WRAP; + const WRAP_LAST_X: u32 = (2 * (TOTAL - 1) + WRAP) % WRAP; + const WRAP_LAST_Y: u32 = (2 * (TOTAL - 1) + 1 + WRAP) % WRAP; + + // SHAPE: the grid's dims, one outer [163] and six [2]s. build_tree walks + // exactly this, one level per dimension, the way the original slices + // shape[1:] on every recursive call. + const SHAPE: [7]u32 = [163, 2, 2, 2, 2, 2, 2]; + // indent(level): the number of spaces for one indent level (" " * level). fn indent(level: u32) -> u32 { return INDENT_UNIT * level; @@ -21,19 +41,31 @@ module gen_w672 { return (2 * e + offset + step) % WRAP; } - // build_tree(n, inner_points, base): the next base after n subtrees of inner_points - // points each, starting at base. A leaf row is n subtrees of one point. - fn build_tree(n: u32, inner_points: u32, base: u32) -> u32 { + // build_tree(shape, depth, base): the original's recursion, one dimension + // per level. A leaf row (the last dimension) lays out n single points and + // returns base + n; above it, n subtrees of the remaining shape run one + // after another, each starting from the base the previous sibling ended on. + // The original's third argument, offset, feeds only the leaf coordinates -- + // coordinate()'s decision here -- so it is not threaded; the literal text + // it joins from these calls is plumbing. The point numbering the base + // threading computes (e at index path [i0]..[ik] is base + i0*d1*..*dk + + // ... + ik) is the decision, and the next base is what this returns, the + // second slot of the original's tuple. + fn build_tree(shape: [7]u32, depth: u32, base: u32) -> u32 { + if (depth == 6) { + return base + shape[depth]; + } var b: u32 = base; var i: u32 = 0; - while (i < n) { - b = b + inner_points; + while (i < shape[depth]) { + b = build_tree(shape, depth + 1, b); i = i + 1; } return b; } - // Plumbing: assembles the text and writes the .t27 file; no test calls it. + // Plumbing: assembles the literal with build_tree, gates the text on ASCII, + // writes the .t27 file and prints the byte count; no test calls it. fn generate() -> u32 { undefined; } @@ -51,30 +83,42 @@ module gen_w672 { test last_point_matches_the_generated_expectations { // 163 * 64 = 10432 points, the last has e = 10431: x = 20862, y = 20863. - assert(coordinate(10431, 0, 0) == 20862); - assert(coordinate(10431, 0, 1) == 20863); - // The point at dst[81][1][0][0][0][0][0] has e = 81 * 64 + 32 = 5216. - assert(coordinate(5216, 0, 0) == 10432); - assert(coordinate(5216, 0, 1) == 10433); + assert(coordinate(TOTAL - 1, 0, 0) == LAST_X); + assert(coordinate(TOTAL - 1, 0, 1) == LAST_Y); + // The point at dst[MID_IDX][1][0][0][0][0][0] has e = MID_IDX * 64 + 32. + assert(coordinate(MID_E, 0, 0) == MID_X); + assert(coordinate(MID_E, 0, 1) == MID_Y); } test offset_32768_wraps_back { - assert(coordinate(0, 32768, 0) == 0); - assert(coordinate(0, 32768, 1) == 1); - assert(coordinate(10431, 32768, 0) == 20862); - assert(coordinate(10431, 32768, 1) == 20863); + assert(coordinate(0, WRAP, 0) == 0); + assert(coordinate(0, WRAP, 1) == 1); + assert(coordinate(TOTAL - 1, WRAP, 0) == WRAP_LAST_X); + assert(coordinate(TOTAL - 1, WRAP, 1) == WRAP_LAST_Y); + } + + test build_tree_walks_one_dimension_per_level { + // a leaf row (the last [2]) lays out two single points from base 7 + assert(build_tree(SHAPE, 6, 7) == 9); + // one inner subtree: the six [2]s under a single outer entry hold 64 + // points, so from base 10 the subtree ends at 74 + assert(build_tree(SHAPE, 1, 10) == 74); } - test build_tree_advances_the_base { - // leaf row of 163 single points starting at 0 - assert(build_tree(163, 1, 0) == 163); - // 2 subtrees of 32 points from base 10 - assert(build_tree(2, 32, 10) == 74); - assert(build_tree(0, 5, 7) == 7); + test base_threading_numbers_points_row_major { + // dst[MID_IDX][1][0][0][0][0][0] is element MID_IDX*64 + 32: the first + // MID_IDX outer entries consume MID_IDX*64 points -- the base handed + // to the next outer subtree -- then one [2]-subtree consumes 32 more + // before the point's own leaf row + var head: [7]u32 = [81, 2, 2, 2, 2, 2, 2]; + assert(build_tree(head, 0, 0) == MID_IDX * 64); + assert(build_tree(head, 0, 0) + 32 == MID_E); } test whole_grid_has_10432_points { - // 163 * 2^6 points: 163 outer entries of 64 points each - assert(build_tree(163, 64, 0) == 10432); + // the full recursion over all seven dimensions: 163 outer entries of + // 64 points each, the base threaded through every subtree -- the count + // the original's generated literal embodies + assert(build_tree(SHAPE, 0, 0) == TOTAL); } }