Skip to content
Closed
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
64 changes: 64 additions & 0 deletions specs/port/trinity/src/tri/faculty_types.t27
Original file line number Diff line number Diff line change
@@ -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);
}
Loading