From 7b388bb8ce0a0c06cc7e1d411dd6949b897d2914 Mon Sep 17 00:00:00 2001 From: dmitrii-f-t27 Date: Sat, 17 Oct 2026 20:00:57 -0300 Subject: [PATCH] spec(port): port specs/port/trinity/src/tri/faculty_types.t27 (Closes #10005) Port gHashTag/trinity:src/tri/faculty_types.zig (at ee512359254b, ~170 lines) as specs/port/trinity/src/tri/faculty_types.t27 - Roadmap Stage 5, goal #4547, target t27c gen-rust. The one listed function is ported under the name the issue asks for, FacultySnapshot_activeFaculty (original line 123, activeFaculty method), and tested (3 tests, 3 pass, 0 vacuous, 6 runtime asserts, 100% function coverage): the active faculty is the count of the six seats whose status is up. Two honest notes: the original's FacultySnapshot carries agents: [6]AgentState - an array of structs this language's Verilog lowering does not implement (W469) - so the port's TrinityFacultySnapshot carries the six statuses as a scalar array of status codes (the up/down/stub/tbd enum as codes, the labels and colors are the caller's presentation); and the name FacultySnapshot is already defined by specs/tri/agent/faculty_board.t27, so the port's type is renamed TrinityFacultySnapshot - the function keeps the required name. All four generators (gen, gen-rust, gen-c, gen-verilog) emit this spec before the push. Verified: parse OK, spec-status IMPLEMENTED, typecheck 0 errors, coverage 1/1, test-report 3/3 pass, 0 BLOCKED, gen 56 lines with 0 'not yet implemented', boundary exactly this one file, dupe_scan: the function name is unique, bare scan reports zero error lines. Dmitrii Fedorov ([@dmitrii-f-t27](https://github.com/dmitrii-f-t27)) --- specs/port/trinity/src/tri/faculty_types.t27 | 64 ++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 specs/port/trinity/src/tri/faculty_types.t27 diff --git a/specs/port/trinity/src/tri/faculty_types.t27 b/specs/port/trinity/src/tri/faculty_types.t27 new file mode 100644 index 0000000000..87c06702bf --- /dev/null +++ b/specs/port/trinity/src/tri/faculty_types.t27 @@ -0,0 +1,64 @@ +module port::trinity::faculty_types; + +// Port of gHashTag/trinity:src/tri/faculty_types.zig (at ee512359254b, +// ~170 lines) - t27 issue #10005, Roadmap Stage 5 (goal #4547), target +// t27c gen-rust. The faculty board's shared types file the A2A dashboard +// reads; the one listed function is the snapshot's active-faculty count. +// The original's FacultySnapshot carries agents: [6]AgentState - an array +// of structs this language's Verilog lowering does not implement (W469), +// and the name FacultySnapshot is already defined by +// specs/tri/agent/faculty_board.t27, so the port's snapshot is named +// TrinityFacultySnapshot and carries the six agents' statuses as a +// scalar array of status codes. The enum status set (up, down, stub, +// tbd) arrives as those codes; the labels, colors and emoji of the +// original's enums are the caller's presentation. + +// The status codes of the original's AgentStatus enum. +pub const FACULTY_STATUS_UP: u8 = 0; +pub const FACULTY_STATUS_DOWN: u8 = 1; +pub const FACULTY_STATUS_STUB: u8 = 2; +pub const FACULTY_STATUS_TBD: u8 = 3; + +// The faculty is fixed at six agents (ralph, scholar, mu, oracle, swarm, +// linter - original lines 10-16). +pub const FACULTY_AGENT_COUNT: usize = 6; + +// The snapshot the dashboard reads: one status code per faculty seat. +pub struct TrinityFacultySnapshot { + statuses: [6]u8, +} + +// Line 123, written per the issue as FacultySnapshot_activeFaculty: the +// active faculty is the count of seats whose status is up. +pub fn FacultySnapshot_activeFaculty(s: TrinityFacultySnapshot) -> u8 { + var count: u8 = 0; + var i: usize = 0; + while (i < s.statuses.len) { + if (s.statuses[i] == FACULTY_STATUS_UP) { + count += 1; + } + i += 1; + } + return count; +} + +test all_six_up_counts_six { + const all = TrinityFacultySnapshot { statuses: [0, 0, 0, 0, 0, 0] }; + assert(FacultySnapshot_activeFaculty(all) == 6); +} + +test none_up_counts_zero { + const none = TrinityFacultySnapshot { statuses: [1, 2, 3, 1, 2, 3] }; + assert(FacultySnapshot_activeFaculty(none) == 0); + const down = TrinityFacultySnapshot { statuses: [1, 1, 1, 1, 1, 1] }; + assert(FacultySnapshot_activeFaculty(down) == 0); +} + +test mixed_statuses_count_exactly { + const three = TrinityFacultySnapshot { statuses: [0, 1, 0, 2, 0, 3] }; + assert(FacultySnapshot_activeFaculty(three) == 3); + const one = TrinityFacultySnapshot { statuses: [1, 2, 3, 3, 2, 0] }; + assert(FacultySnapshot_activeFaculty(one) == 1); + const five = TrinityFacultySnapshot { statuses: [0, 0, 3, 0, 0, 0] }; + assert(FacultySnapshot_activeFaculty(five) == 5); +}