From 1c3f56e4a2f52b34a4d5559c84e17c978427230d Mon Sep 17 00:00:00 2001 From: Trinity Bee Date: Fri, 9 Oct 2026 18:01:38 +0000 Subject: [PATCH 1/3] port: scripts/gen_w660.py as specs/port/scripts/gen_w660.t27 (Closes #8127) --- specs/port/scripts/gen_w660.t27 | 78 +++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 specs/port/scripts/gen_w660.t27 diff --git a/specs/port/scripts/gen_w660.t27 b/specs/port/scripts/gen_w660.t27 new file mode 100644 index 0000000000..116adb89d1 --- /dev/null +++ b/specs/port/scripts/gen_w660.t27 @@ -0,0 +1,78 @@ +// SPDX-License-Identifier: Apache-2.0 +// Port of scripts/gen_w660.py (issue #8127). +// The original writes the spec w660_bench_module_139x2p6_aos_var_call_write.t27: a +// [139][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. +module gen_w660 { + 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 { + // 139 * 64 = 8896 points, the last has e = 8895: x = 17790, y = 17791. + assert(coordinate(8895, 0, 0) == 17790); + assert(coordinate(8895, 0, 1) == 17791); + // The point at dst[69][1][0][0][0][0][0] has e = 69 * 64 + 32 = 4448. + assert(coordinate(4448, 0, 0) == 8896); + assert(coordinate(4448, 0, 1) == 8897); + } + + test offset_32768_wraps_back { + assert(coordinate(0, 32768, 0) == 0); + assert(coordinate(0, 32768, 1) == 1); + assert(coordinate(8895, 32768, 0) == 17790); + assert(coordinate(8895, 32768, 1) == 17791); + } + + test build_tree_advances_the_base { + // leaf row of 139 single points starting at 0 + assert(build_tree(139, 1, 0) == 139); + // 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_8896_points { + // 139 * 2^6 points: 139 outer entries of 64 points each + assert(build_tree(139, 64, 0) == 8896); + } +} From 88058ef433de50c49adf6810e4d8dd2bba67f062 Mon Sep 17 00:00:00 2001 From: "queen-publisher[bot]" Date: Sat, 10 Oct 2026 04:55:43 +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 #8127 Co-Authored-By: Claude Opus 5 --- ...gen-w660-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-w660-py-python-3-functions-to-specs-port-sc.md diff --git a/docs/now/2026-10-10-published-port-scripts-gen-w660-py-python-3-functions-to-specs-port-sc.md b/docs/now/2026-10-10-published-port-scripts-gen-w660-py-python-3-functions-to-specs-port-sc.md new file mode 100644 index 0000000000..2707cb4f19 --- /dev/null +++ b/docs/now/2026-10-10-published-port-scripts-gen-w660-py-python-3-functions-to-specs-port-sc.md @@ -0,0 +1,11 @@ +# NOW -- Port scripts/gen_w660.py (Python, 3 functions) to specs/port/scripts/gen_w660.t27 (published 2026-10-10) + +## A bee's work on #8127, published from `queen-8127` (Closes #8127) + +- The branch changes 1 file(s): `specs/port/scripts/gen_w660.t27`. +- `git diff --stat origin/master...queen-8127` reads: 1 file changed, 78 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 eba9e5e7b5e585de6374ec412829c0a95b8ba217 Mon Sep 17 00:00:00 2001 From: Dmitrii Vasilev Date: Mon, 12 Oct 2026 17:20:09 +0700 Subject: [PATCH 3/3] fix(port): make build_tree the original's recursion -- one dimension per level, the base threaded through the shape (Refs #8127) Co-Authored-By: Claude Opus 5.5 --- specs/port/scripts/gen_w660.t27 | 58 ++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 15 deletions(-) diff --git a/specs/port/scripts/gen_w660.t27 b/specs/port/scripts/gen_w660.t27 index 116adb89d1..d3208d7bb6 100644 --- a/specs/port/scripts/gen_w660.t27 +++ b/specs/port/scripts/gen_w660.t27 @@ -3,8 +3,8 @@ // The original writes the spec w660_bench_module_139x2p6_aos_var_call_write.t27: a // [139][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. +// 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_w660 { const WRAP: u32 = 32768; const INDENT_UNIT: u32 = 4; @@ -19,13 +19,29 @@ module gen_w660 { 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 { + // SHAPE: the grid's dims, one outer [139] 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 = [139, 2, 2, 2, 2, 2, 2]; + + // 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; @@ -63,16 +79,28 @@ module gen_w660 { assert(coordinate(8895, 32768, 1) == 17791); } - test build_tree_advances_the_base { - // leaf row of 139 single points starting at 0 - assert(build_tree(139, 1, 0) == 139); - // 2 subtrees of 32 points from base 10 - assert(build_tree(2, 32, 10) == 74); - assert(build_tree(0, 5, 7) == 7); + 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 base_threading_numbers_points_row_major { + // dst[69][1][0][0][0][0][0] is element 69*64 + 32 = 4448: the first + // 69 outer entries consume 69*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 = [69, 2, 2, 2, 2, 2, 2]; + assert(build_tree(head, 0, 0) == 69 * 64); + assert(build_tree(head, 0, 0) + 32 == 4448); } test whole_grid_has_8896_points { - // 139 * 2^6 points: 139 outer entries of 64 points each - assert(build_tree(139, 64, 0) == 8896); + // the full recursion over all seven dimensions: 139 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) == 8896); } }