feat: Phase 1 robot mode + forgiving parser test suite #8
Notifications
Due Date
No due date set.
Depends on
#4 feat: Wire ForgivingParser into REPL command dispatch
terraphim/agent-tasks
Reference: terraphim/agent-tasks#8
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem Statement
Phase 1 of the session-search spec (Robot Mode + Forgiving Parser) has shipping code in
crates/terraphim_agent/src/robot/andcrates/terraphim_agent/src/forgiving/, but no dedicated test suite covers the new surfaces. Task 1.6 is unchecked. Without tests, typo correction, alias expansion, exit-code mapping, and JSON output shape can regress silently as later tasks land.Current State
ForgivingParserinforgiving/parser.rshas inline unit tests for the bare parser but no integration tests that exercise the REPL dispatcher.robot/output.rs,robot/exit_codes.rs, androbot/budget.rshave minimal or no assertions on JSON shape or exit-code mapping.--robot --format jsonoutput.repl_integration_testsharness incrates/terraphim_agent/tests/does not cover robot mode.Acceptance Criteria
ForgivingParser::parse: exact match, alias expansion, typo correction (edit distance 1 and 2), unknown command, suggestion list.RobotFormatter: JSON schema, compact variant, description/body field presence, error payload shape.ExitCodemapping: success (0), usage error (64), soft limit (2), internal error (70).tests/repl_robot_tests.rsthat runs the REPL with--robot --format jsonagainst a fixture haystack and asserts the full envelope.instaor plaininclude_str!) for representative JSON payloads: search hit, search miss, alias-expanded command, auto-corrected command.cargo test -p terraphim_agent --features repl-full.cargo clippy -p terraphim_agent --features repl-full --tests -- -D warningspasses.cargo llvm-cov -p terraphim_agent --features repl-full -- robot forgiving) shows ≥ 80 % line coverage forrobot/andforgiving/modules.Proposed Approach
crates/terraphim_agent/src/forgiving/parser.rstest module additions covering the fourParseResultvariants explicitly.crates/terraphim_agent/tests/repl_robot_tests.rsusing a seeded in-memory haystack fixture; exerciseReplHandlerend-to-end in robot mode.crates/terraphim_agent/tests/fixtures/robot/— one file per scenario.#[cfg(test)]helpers inrobot/mod.rsfor building minimalRobotResponseobjects.Dependencies
Depends on #4 (ForgivingParser wiring) — integration tests need the dispatcher to actually route through the parser before they can verify auto-correction.
Verification
Scope
~300 LOC of test code + ~6 snapshot fixtures. No production code touched. Single PR.
Upstream: Implements Task 1.6 of
docs/specifications/terraphim-agent-session-search-tasks.mdfor terraphim/terraphim-ai.