Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# NOW -- DECISION NEEDED: ternary packing layout is arithmetically impossible (blocks 343 of 906 corpus files) (published 2026-09-23)

## A bee's work on #3873, published from `queen-3873` (Closes #3873)

- The branch changes 1 file(s): `specs/base/types.t27`.
- `git diff --stat origin/master...queen-3873` reads: 1 file changed, 10 insertions(+), 6 deletions(-)
- 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.
16 changes: 10 additions & 6 deletions specs/base/types.t27
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ pub const Trit = enum(i8) {
// Constants - PackedTrit
// ============================================================================

// PackedTrit: 8 trits packed into u8
// Layout: [t7 t6 t5 t4 t3 t2 t1 t0] where each t ∈ {-1, 0, +1}
// PackedTrit: 4 trits packed into u8
// Layout: [t3 t2 t1 t0] where each t ∈ {-1, 0, +1}
// Encoding: -1 → 10, 0 → 00, +1 → 01 (2 bits per trit)
// So packed byte: [t7_1 t7_0][t6_1 t6_0]...[t0_1 t0_0]
// So packed byte: [t3_1 t3_0][t2_1 t2_0][t1_1 t1_0][t0_1 t0_0]
pub const PACKED_BITS_PER_TRIT : u8 = 2;
pub const TRITS_PER_BYTE : u8 = 8;
pub const TRITS_PER_BYTE : u8 = 4;

// Trit value mapping (2-bit to trit)
// -1 → 10b = 2, 0 → 00b = 0, +1 → 01b = 1
Expand All @@ -48,7 +48,7 @@ pub const PackedTrit = u8; // Type alias
// Can represent any value in 3^27 ≈ 7.6×10^12 states
// Practical use: vector operations, VSA bindings, weight storage
pub const TRITS_PER_WORD : u8 = 27;
pub const WORD_BYTES : u8 = 5; // ceil(27/8) = 5 bytes for 27 trits
pub const WORD_BYTES : u8 = 7; // ceil(27/4) = 7 bytes for 27 trits

pub const TernaryWord = [WORD_BYTES]u8; // Type alias

Expand Down Expand Up @@ -199,7 +199,11 @@ pub fn ternary_word_pack(src: []Trit, count: u8) TernaryWord {
var result = [_]u8{0} ** WORD_BYTES;

for (0..@min(count, TRITS_PER_WORD)) |i| {
result = pack_trit(src[i], @intCast(i), result);
const byte_index = i / TRITS_PER_BYTE;
const trit_in_byte = i % TRITS_PER_BYTE;
const old = result[byte_index];
const packed = pack_trit(src[i], trit_in_byte, old);
result[byte_index] = packed;
}

return result;
Expand Down
Loading