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); +}