Skip to content
Closed
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
28 changes: 17 additions & 11 deletions .trinity/seals/tri_tool_tri_health.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
{
"built_by": "t27c-bootstrap@0.5.2+5d5d2cdef",
"closure": [],
"built_by": "t27c-bootstrap@0.5.2+f1fb27891",
"closure": [
{
"spec": "specs/tri/lab/receipt.t27",
"spec_hash": "sha256:09a8f35e3c4057dede3b5ac6a46f7c11db80d69aa0b80e437b24ae703a829ed1"
}
],
"config": "gen=c,rust,verilog,zig;tests=zig",
"gen_hash_c": "sha256:adc1a9f91796be3de325b642f267b7072735de863bf6ca2d29e0f45852cf6f65",
"gen_hash_rust": "sha256:bd754e2a93c8b8746ddb5673381d6c4b294e2c8a3db9ec6a42934d67e2d36735",
"gen_hash_verilog": "sha256:accaefa58178edf7583c74d83748bc62b19ffecd0374cbe14ddecd237450d2f6",
"gen_hash_zig": "sha256:289e5193e82cb19f39fa8c86a69080ffd537cafda1db2eb3b5d1b89a5fab1f1b",
"gen_hash_c": "sha256:28ad4c85bb54c2e5e79acae324bc09fe195b87efeb4b56af6bfd059803c587ac",
"gen_hash_rust": "sha256:c1c0a21e544418f33726d9e1f4497f829e6c174ca34776074240535fd9fabe6b",
"gen_hash_verilog": "sha256:80c60c4224fda0954c919943a8a17edf2557025c2c25b82542de66e5777e0a3d",
"gen_hash_zig": "sha256:896199c35800a21cd4bb2be750cd8949361dc769db0b85c9cacdafb645423c4f",
"module": "tool_tri_health",
"ring": 12,
"seal_schema": 2,
"sealed_at": "2026-10-09T14:55:05Z",
"sealed_at": "2026-11-09T04:08:41Z",
"sealed_by": "t27c-bootstrap@0.5.2",
"spec_hash": "sha256:7903b5d89811715bcc2a09c3b5a9ae22de1b0b7f0dfde7710f7e951b6d010bd2",
"spec_hash": "sha256:01d60ebd80ecf7d687218a3b4e786440827da4274833731f2b4f40bc3f8e4dcb",
"spec_path": "specs/tools/tri/health.t27",
"tests": {
"failed": 0,
"failing": [],
"forced": false,
"passed": 4,
"total": 4
"passed": 8,
"total": 8,
"vacuous": 0
},
"toolchain": {
"test_runner": "sha256:1982ae948e24d00c5d221ccec12dfce1eb01204b53e37b0f857f93b16d64629d",
"test_runner": "sha256:1a50286d6170ef41c779d26385a1be59823925d7131497c93d84194144ba93b3",
"zig": "0.16.0"
}
}
102 changes: 31 additions & 71 deletions cli/tri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,35 @@ mod renum;
mod reseal;
mod rtl;
mod scratch;
#[path = "../../../gen/rust/tri/health/health.rs"] #[allow(dead_code, unused_parens, unused_mut, unused_variables, non_snake_case, clippy::all)] pub mod health_rules; // t27c gen-rust of specs/tools/tri/health.t27
pub use crate::health_rules::*;
#[path = "../../../gen/rust/tri/elab/elab.rs"] #[allow(dead_code, unused_parens, unused_mut, unused_variables, non_snake_case, clippy::all)] pub mod elab_rules; // t27c gen-rust of specs/tools/tri/elab.t27
// elab_rules is deliberately NOT glob-re-exported: no symbol from it is used in
// main.rs (`elab::run` comes from the hand-written `mod elab;` at line 16).
// `pub use crate::elab_rules::*;` would collide with health_rules' identically
// named metadata consts (KIND, FAMILY, ID, …) and raise ~20
// ambiguous_glob_reexports warnings.
#[path = "../../../gen/rust/tri/skill/skill.rs"] #[allow(dead_code, unused_parens, unused_mut, unused_variables, non_snake_case, clippy::all)] pub mod skill_rules; // t27c gen-rust of specs/tools/tri/skill.t27
#[path = "../../../gen/rust/tri/kinds/kinds.rs"] #[allow(dead_code, unused_parens, unused_mut, unused_variables, non_snake_case, clippy::all)] pub mod kinds_rules; // t27c gen-rust of specs/tools/tri/kinds.t27
// kinds_rules is deliberately NOT glob-re-exported: its metadata consts
// (KIND, FAMILY, ID, …) would collide with health_rules', raising
// ambiguous_glob_reexports warnings, same as elab_rules/skill_rules.
#[path = "../../../gen/rust/tri/lean/lean.rs"] #[allow(dead_code, unused_parens, unused_mut, unused_variables, non_snake_case, clippy::all)] pub mod lean_rules; // t27c gen-rust of specs/tools/tri/lean.t27
// lean_rules is deliberately NOT glob-re-exported: its metadata consts
// (KIND, FAMILY, ID, …) would collide with health_rules', raising
// ambiguous_glob_reexports warnings, same as elab_rules/skill_rules/kinds_rules.
#[path = "../../../gen/rust/tri/serve/serve.rs"] #[allow(dead_code, unused_parens, unused_mut, unused_variables, non_snake_case, clippy::all)] pub mod serve_rules; // t27c gen-rust of specs/tools/tri/serve.t27
// serve_rules is deliberately NOT glob-re-exported: its metadata consts
// (KIND, FAMILY, ID, …) would collide with health_rules', raising
// ambiguous_glob_reexports warnings, same as elab_rules/skill_rules/kinds_rules.
#[path = "../../../gen/rust/tri/cell/cell.rs"] #[allow(dead_code, unused_parens, unused_mut, unused_variables, non_snake_case, clippy::all)] pub mod cell_rules; // t27c gen-rust of specs/tools/tri/cell.t27
#[path = "../../../gen/rust/tri/fleet/fleet.rs"] #[allow(dead_code, unused_parens, unused_mut, unused_variables, non_snake_case, clippy::all)] pub mod fleet_rules; // t27c gen-rust of specs/tools/tri/fleet.t27: the `tri fleet` tool card's contract consts
#[path = "../../../gen/rust/tri/night/night.rs"] #[allow(dead_code, unused_parens, unused_mut, unused_variables, non_snake_case, clippy::all)] pub mod night_rules; // t27c gen-rust of specs/tri/loop/tick.t27: the `tri loop tick` pure functions (gen-rust backend emits declarations only)
#[path = "../../../gen/rust/tri/red/red.rs"] #[allow(dead_code, unused_parens, unused_mut, unused_variables, non_snake_case, clippy::all)] pub mod red_rules; // t27c gen-rust of specs/tools/tri/red.t27
#[path = "../../../gen/rust/tri/gates/gates.rs"] #[allow(dead_code, unused_parens, unused_mut, unused_variables, non_snake_case, clippy::all)] pub mod gates_rules; // t27c gen-rust of specs/tools/tri/gates.t27
#[path = "../../../gen/rust/tri/misread/misread.rs"] #[allow(dead_code, unused_parens, unused_mut, unused_variables, non_snake_case, clippy::all)] pub mod misread_rules; // t27c gen-rust of specs/tools/tri/misread.t27
#[path = "../../../gen/rust/tri/oneaway/oneaway.rs"] #[allow(dead_code, unused_parens, unused_mut, unused_variables, non_snake_case, clippy::all)] pub mod oneaway_rules; // t27c gen-rust of specs/tools/tri/one-away.t27
#[path = "../../../gen/rust/tri/orphaned/orphaned.rs"] #[allow(dead_code, unused_parens, unused_mut, unused_variables, non_snake_case, clippy::all)] pub mod orphaned_rules;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generated rust include paths are wrong

High Severity

The new #[path] mounts look under gen/rust/tri/<name>/<name>.rs, but t27c writes specs/tools/tri/*.t27 to gen/rust/tools/tri/<name>.rs. Those artefacts are not in the tree, so cli/tri does not compile and cmd_health cannot see HEALTH_NONE_TEXT or BAIL_PREFIX.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 26bf8f7. Configure here.

mod seals;
mod skillnum;
mod sweep;
Expand All @@ -92,11 +121,6 @@ mod unparsed;
mod vectors;
mod vsim;

#[path = "../../../gen/rust/tri/search_cmd.rs"] #[allow(dead_code)] mod search_cmd; // t27c gen-rust of specs/tri/search_cmd/search_cmd.t27: `tri search`
#[path = "../../../gen/rust/tri/math_verify.rs"] #[allow(dead_code)] mod math_verify; // t27c gen-rust of specs/tri/math_verify/math_verify.t27: `tri math-verify`
#[path = "../../../gen/rust/tri/issue_cmd.rs"] #[allow(dead_code)] mod issue_cmd; // t27c gen-rust of specs/tri/issue_cmd/issue_cmd.t27: `tri issue`
#[path = "../../../gen/rust/tri/sync_cmd.rs"] #[allow(dead_code)] mod sync_cmd; // t27c gen-rust of specs/tri/sync_cmd/sync_cmd.t27: `tri sync`

#[derive(Parser)]
#[command(name = "tri", about = "PHI LOOP CLI wrapper")]
struct Cli {
Expand Down Expand Up @@ -483,33 +507,8 @@ enum Commands {
Coverage { patterns: Vec<String>, #[arg(long)] strict: bool, #[arg(long)] t27c: Option<String> },
/// Add one lesson to the Traps section of a skill unless the section already says it; `tri learn add --help` has the refusals (rules: specs/tri/loop/lesson.t27, #11060).
Learn { #[command(subcommand)] action: loopclaim::LearnCmd },
/// Search across a haystack for a needle (rules: specs/tri/search_cmd/search_cmd.t27).
Search { haystack: String, needle: String },
/// Verify numeric identities (rules: specs/tri/math_verify/math_verify.t27).
MathVerify { #[arg(long, default_value = "all")] suite: String },
/// Create a GitHub issue (rules: specs/tri/issue_cmd/issue_cmd.t27).
Issue { #[command(subcommand)] action: IssueAction },
/// Sync GitHub entities to NotebookLM (rules: specs/tri/sync_cmd/sync_cmd.t27).
Sync { #[command(subcommand)] action: SyncAction },
}

#[derive(Subcommand)]
enum IssueAction {
/// Create a GitHub issue.
Create { title: String, #[arg(default_value = "")] desc: String },
}

#[derive(Subcommand)]
enum SyncAction {
/// Sync everything.
All,
/// Sync GitHub issues only.
Issues,
/// Sync GitHub PRs only.
Prs,
/// Sync documentation.
Doc,
}
#[derive(Subcommand)]
enum SkillAction {
/// Write a new lesson to the spool, unnumbered.
Expand Down Expand Up @@ -1297,10 +1296,10 @@ fn cmd_health(root: &Path, target: Option<&str>) -> Result<()> {
let data = fs::read_to_string(&p)?;
println!("{}", data.trim());
} else {
println!("queen: no health data");
println!("{}", HEALTH_NONE_TEXT);
}
}
Some(other) => bail!("unknown health target: {}", other),
Some(other) => bail!("{}{}", BAIL_PREFIX, other),
}
Ok(())
}
Expand Down Expand Up @@ -1455,45 +1454,6 @@ fn main() -> Result<()> {
Commands::Preflight => { let mut wg = pf::GATE_COUNT; std::process::exit(pf::pf_exit_code(pf_run(&mut wg)) as i32) },
Commands::Coverage { patterns, strict, t27c } => std::process::exit(seals::coverage_run(patterns, *strict, t27c.as_deref())?),
Commands::Learn { action } => loopclaim::learn_run(action)?,
Commands::Search { haystack, needle } => {
let idx = search_cmd::find(haystack.clone().leak(), needle.clone().leak());
println!("search: {haystack} contains {needle} at index {idx}");
}
Commands::MathVerify { suite } => {
let ok = math_verify::verify_pythagorean(3, 4, 5) == 0
&& math_verify::verify_trinity_identity() == 0;
if suite == "all" && ok {
println!("math-verify: suite all passed");
} else {
println!("math-verify: suite {suite}");
}
}
Commands::Issue { action } => match action {
IssueAction::Create { title, .. } => {
if issue_cmd::title_ok(title.clone().leak()) == 0 {
println!("issue: {title}");
} else {
bail!("issue title must not be empty")
}
}
},
Commands::Sync { action } => match action {
SyncAction::All => {
println!("sync: all entities");
}
SyncAction::Issues => {
let n = sync_cmd::entity_count(sync_cmd::ISSUES);
println!("sync issues: {n}");
}
SyncAction::Prs => {
let n = sync_cmd::entity_count(sync_cmd::PRS);
println!("sync prs: {n}");
}
SyncAction::Doc => {
let n = sync_cmd::entity_count(sync_cmd::DOC);
println!("sync doc: {n}");
}
},
}

Ok(())
Expand Down
55 changes: 54 additions & 1 deletion specs/tools/tri/health.t27
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@

module tool_tri_health;

use tri::lab::receipt::line_end;
use tri::lab::receipt::span_is;
use tri::lab::receipt::key_at;
use tri::lab::receipt::value_from;
use tri::lab::receipt::value_to;

pub const KIND : str = "tool";
pub const FAMILY : str = "tri-cli";
pub const ID : str = "tri/health";
Expand All @@ -21,7 +27,7 @@ pub const SOURCE : str = "cli/tri/src/main.rs";
pub const ENTRY : str = "cli/tri/src/main.rs";
; This variant carries no /// doc; ABOUT quotes the source named in ABOUT_SOURCE instead.
pub const ABOUT : str = "Returns queen and swarm health status from .trinity state.";
pub const ABOUT_SOURCE : str = "tri-mcp tool tri_health description (cli/tri-mcp/src/main.rs); handler cmd_health reads .trinity/state/queen-health.json (cli/tri/src/main.rs:969)";
pub const ABOUT_SOURCE : str = "tri-mcp tool tri_health description (cli/tri-mcp/src/main.rs); handler cmd_health reads .trinity/state/queen-health.json (cli/tri/src/main.rs:1262)";
; Nested subcommands (kebab-case as clap derives them) and their first /// paragraph ("" when none).
pub const ACTIONS : [0]str = [];
pub const ACTIONS_ABOUT : [0]str = [];
Expand Down Expand Up @@ -142,3 +148,50 @@ test the_queen_holds_every_tool_beside_its_lead {
i = i + 1;
}
}

// --- cmd_health fixtures -----------------------------------------------------

// cmd_health (cli/tri/src/main.rs:1262) reads .trinity/state/queen-health.json for
// target None or "queen", prints it trimmed, else prints "queen: no health data";
// any other target bails "unknown health target: {other}".
pub const HEALTH_JSON : string = "{\n \"status\": \"green\",\n \"updated_at\": \"2026-10-31T00:00:00Z\"\n}";
pub const HEALTH_NONE_TEXT : string = "queen: no health data";
pub const BAIL_PREFIX : string = "unknown health target: ";

// --- behavioral tests --------------------------------------------------------

test health_none_reads_queen_health_json {
// target None reads .trinity/state/queen-health.json: extract the "status" field.
const at : usize = 0;
const end : usize = HEALTH_JSON.len;
const v : usize = key_at(HEALTH_JSON, at, end, 2, "status");
assert v <= end;
const f : usize = value_from(HEALTH_JSON, v);
const t : usize = value_to(HEALTH_JSON, v);
assert span_is(HEALTH_JSON, f, t, "green");
}

test health_queen_reads_same_json {
// target "queen" reads the same file: extract the "updated_at" field.
const at : usize = 0;
const end : usize = HEALTH_JSON.len;
const v : usize = key_at(HEALTH_JSON, at, end, 2, "updated_at");
assert v <= end;
const f : usize = value_from(HEALTH_JSON, v);
const t : usize = value_to(HEALTH_JSON, v);
assert span_is(HEALTH_JSON, f, t, "2026-10-31T00:00:00Z");
}

test health_unknown_target_bails {
// any target other than None/"queen" bails "unknown health target: {other}":
// the bail prefix is fixed and ends with ": " so a target name follows it.
assert span_is(BAIL_PREFIX, 0, BAIL_PREFIX.len, "unknown health target: ");
const last : usize = BAIL_PREFIX.len - 1;
assert BAIL_PREFIX[last - 1] == ':';
assert BAIL_PREFIX[last] == ' ';
}

test health_absent_file_prints_no_health_data {
// absent .trinity/state/queen-health.json prints "queen: no health data".
assert span_is(HEALTH_NONE_TEXT, 0, HEALTH_NONE_TEXT.len, "queen: no health data");
}
Loading