TASK: tri_run — t27 CLI (.tri) as MCP tool
Context
The t27 repo has tri CLI — the PHI LOOP executor. Connecting it to trios-bridge means:
- Agent can run
.tri specs from BrowserOS chat
- PHI LOOP (edit spec → seal hash → gen → test → verdict → experience) becomes a single MCP tool call
experience/ SSOT auto-updates from chat
PHI LOOP: edit spec → seal hash → gen → test → verdict → experience → skill commit → git commit
Tool spec
// Tool: tri_run
interface TriRunInput {
command: string; // e.g. "math pslq", "trinity --watch-narwhal", "test all"
repoPath?: string; // default: process.env.T27_REPO_PATH or auto-detect
timeout?: number; // ms, default 30000
captureOutput?: boolean; // default true
}
interface TriRunResult {
ok: boolean;
stdout: string;
stderr: string;
exitCode: number;
durationMs: number;
experienceEntry?: string; // last line written to .trinity if detected
}
Tool: tri_spec_edit
Edit a .tri or .t27 spec file and trigger PHI LOOP:
// Tool: tri_spec_edit
interface TriSpecEditInput {
specPath: string; // relative to t27 repo root, e.g. "specs/phi.t27"
patch: string; // unified diff or full new content
sealAfter?: boolean; // run `tri seal` after edit (default: true)
testAfter?: boolean; // run `tri test` after seal (default: true)
}
interface TriSpecEditResult {
ok: boolean;
sealed: boolean;
testsPassed: boolean;
hash?: string; // FROZEN_HASH after seal
verdict: 'pass' | 'fail' | 'skip';
experiencePath?: string;
}
Tool: tri_experience_read
Read recent .trinity experience entries:
// Tool: tri_experience_read
interface TriExperienceInput {
filter?: string; // keyword filter, e.g. "phase2"
last?: number; // last N entries, default 10
}
interface TriExperienceResult {
entries: TrinityEntry[];
total: number;
}
interface TrinityEntry {
timestamp: string;
file: string;
content: string;
}
Config
// src/config.ts — add:
export const T27_REPO_PATH = process.env.T27_REPO_PATH
?? path.join(os.homedir(), 't27');
export const TRI_BIN = process.env.TRI_BIN
?? path.join(T27_REPO_PATH, 'target/release/tri');
Auto-detect: if tri not found at TRI_BIN → fallback to cargo run --bin tri --manifest-path {T27_REPO_PATH}/Cargo.toml.
Example usage from chat
User: "Run tri math pslq"
Agent: tri_run({command: "math pslq"})
Result: stdout with PSLQ computation + experience entry
User: "What's in recent t27 experience?"
Agent: tri_experience_read({last: 5})
Result: last 5 .trinity entries formatted as markdown
User: "Edit phi.t27 to add a new invariant"
Agent: tri_spec_edit({specPath: "specs/phi.t27", patch: "...", sealAfter: true, testAfter: true})
Result: {sealed: true, testsPassed: true, hash: "abc123", verdict: "pass"}
Architecture in bridge
crates/trios-bridge/src/tools/
└── tri/
├── mod.rs (or tri.ts)
├── tri_run.ts
├── tri_spec_edit.ts
└── tri_experience_read.ts
Add 3 new tools to bridge-server.ts → total: 14 MCP tools.
Tests required
// src/__tests__/tri-tools.test.ts
describe('tri_run', () => {
it('executes tri command and returns stdout', ...)
it('returns exitCode on failure', ...)
it('respects timeout', ...)
})
describe('tri_experience_read', () => {
it('returns last N entries from .trinity files', ...)
it('filters by keyword', ...)
})
describe('tri_spec_edit', () => {
it('applies patch to spec file', ...)
it('seals hash after edit', ...)
})
Laws
- L1:
Closes #7
- L4: 7+ tests
- L7: NO
.sh — spawn tri binary directly
Success criteria
φ² + 1/φ² = 3 | TRINITY | GO.
TASK: tri_run — t27 CLI (.tri) as MCP tool
Context
The t27 repo has
triCLI — the PHI LOOP executor. Connecting it to trios-bridge means:.trispecs from BrowserOS chatexperience/SSOT auto-updates from chatPHI LOOP: edit spec → seal hash → gen → test → verdict → experience → skill commit → git commit
Tool spec
Tool: tri_spec_edit
Edit a
.trior.t27spec file and trigger PHI LOOP:Tool: tri_experience_read
Read recent
.trinityexperience entries:Config
Auto-detect: if
trinot found atTRI_BIN→ fallback tocargo run --bin tri --manifest-path {T27_REPO_PATH}/Cargo.toml.Example usage from chat
Architecture in bridge
Add 3 new tools to
bridge-server.ts→ total: 14 MCP tools.Tests required
Laws
Closes #7.sh— spawntribinary directlySuccess criteria
tri_run({command: "math pslq"})returns stdout from t27 CLItri_experience_read({last: 5})returns .trinity entriestri_spec_editapplies patch + seals + returns verdictbun testgreenφ² + 1/φ² = 3 | TRINITY | GO.