Repository navigation
Description
Port part 1 of 2 of tools/ternary_model.py to specs/port/tools/ternary_model.t27 (8 functions)
Context
tools/ternary_model.py is 94 lines of hand-written Python. Re-author its logic as specs/port/tools/ternary_model.t27 so that t27c generates the equivalent. The Python file stays where it is - this issue adds the .t27 source it should have been written in.
.t27 is the hand-authored source language. t27c compiles it out to C, Rust, Verilog and Zig. You are writing source, not compiler output, and not prose about an implementation. The goal of this project is that every hand-written file in the repository is authored in .t27 and the other languages are generated from it - this issue is one file of that migration.
All 2 parts name the same file, so they share one boundary and cannot run at the same time. The swarm holds specs/port/tools/ternary_model.t27 for whoever has it.
Read the original first
$ cd /Users/playom/t27
$ wc -l tools/ternary_model.py
$ sed -n '1,120p' tools/ternary_model.py
What to write
Create specs/port/tools/ternary_model.t27 with one .t27 function per Python function below. Keep the names exactly as they are - the name is how the port is checked. Quoted verbatim from the original:
- line 19 -
def _i16(v): - line 23 -
def _i8(v): - line 27 -
def tmul(ta, tb): - line 38 -
def dot27(a, b): - line 48 -
def sign0(v): - line 53 -
def negate(t): - line 61 -
def pack2(t0, t1): - line 68 -
def pack3(t0, t1, t2):
Add a test block for each of the 8 functions, asserting on the behaviour you read in the original. A ported body with nothing asserting on it is a claim, not a result - and the review compiles the generated Zig and runs exactly those tests.
Acceptance criteria
-
test -f specs/port/tools/ternary_model.t27 && echo presentprintspresent(today the file does not exist)
-
grep -cE '^\s*(pub )?fn (_i16|_i8|tmul|dot27|sign0|negate|pack2|pack3)\(' specs/port/tools/ternary_model.t27prints8- every function above is ported under its own name
-
t27c gen specs/port/tools/ternary_model.t27 > /tmp/t27-gen.zig && grep -c 'not yet implemented' /tmp/t27-gen.zigprints0, andt27c gen specs/port/tools/ternary_model.t27 | wc -lprints more than24- an absent or empty file makes the grep print0on its own, so both halves are required
-
t27c spec-status specs/port/tools/ternary_model.t27does not printNOPARSE- the file still parses. (This replaces a parse-metrics criterion. The compiler in the container prints no such metrics, so the command printed nothing and no work could ever satisfy it.)
-
grep -cE '^[[:space:]]*test[[:space:]]+("|[A-Za-z_])' specs/port/tools/ternary_model.t27prints at least8
Use t27c, not the t27c on PATH: the PATH build prints no parse metrics at all, so criterion 4 greps nothing and an empty result reads as a pass.
Boundary
specs/port/tools/ternary_model.t27
Activity
gHashTag commentedon Sep 20, 2026
Re-filed as #4377.
An attempt claimed this issue on 2026-09-17 and left an empty branch. A dispatch row that has spent its retry ceiling is released once and then keeps its issue for good, which is the right rule for a third identical failure and the wrong outcome for an issue nobody ever attempted twice. The new issue carries the same work, the same boundary, and today's brief.
Closing this one so the swarm can take the work again.
Port ternary_model.py functions to T27