test(KB-037): verify LoopExit contract acceptance criteria and add gap coverage tests#3442
Conversation
… contract New tests covering acceptance criteria gaps: - NoReply with empty refs → MissingCompletionReference violation - DelegatedResult via result_refs → trusted Completed - Auth and Resource LoopBlockedKind → correct BlockedReason mapping - All 9 LoopFailureKind variants → stable sanitized category strings - RecoveryRequired not a LoopExit variant (extended serde coverage) - Cancelled with checkpoint + interrupted refs → Cancelled outcome - Terminal vs non-terminal TurnStatus lock semantics
There was a problem hiding this comment.
Code Review
This pull request introduces comprehensive gap coverage tests for loop exit contracts in crates/ironclaw_turns/tests/loop_exit_contract.rs. The new tests verify validation logic for completed, blocked, failed, and cancelled loop exits, ensure correct mapping of failure categories and blocked reasons, and validate terminal status behavior regarding lock retention. Additionally, the result_ref helper function is now utilized, and its dead_code allowance has been removed. I have no feedback to provide.
Code Review: PR #3442 — test(KB-037): verify LoopExit contract acceptance criteriaOverviewPure test-only PR (189 additions, 5 deletions, single file: The new tests are well-organized, each maps cleanly to one or more ACs, and the test file's existing helper functions ( Strengths
Issues / SuggestionsCorrectness / clarity
Style / conventions
Test coverage gaps still worth noting
Risk
|
|
@ilblackdragon addressed the latest review notes in
Verification is green: |
Summary
Verifies all 22 acceptance criteria from issue #3232 against the merged LoopExit contract (PR #3295, commit
02088937c) and adds 7 new tests covering identified gaps.Acceptance Criteria Verification (22/22 pass)
LoopExitandTurnRunnerOutcomeare distinct typesCompletedwith raw reply text impossible (deny_unknown_fields)Completed { AskUserReply }maps to terminal completedBlockedrequires gate ref + checkpoint id (non-optional fields)Blockedwith raw payloads rejected (deny_unknown_fields)Blocked(approval/auth/resource)maps to corresponding blocked statusCancelledaccepted only with host cancellation observedFailedcarries stable sanitized kindMaxIterationsmaps toFailed { IterationLimit }RecoveryRequirednot inLoopExitenum (only inLoopExitMapping)AC22 Note: This PR verifies the contract-layer behavior: duplicate
exit_idhandling is explicitly not enforced byLoopExitvalidation. Store-level idempotency remains intentionally deferred to KB-059/KB-060, where durable store tests should addduplicate_exit_id_idempotent_at_store_layer.New Tests Added (7)
Quality Gate
cargo test -p ironclaw_turns— 76 tests pass (19 in loop_exit_contract, 7 new)cargo clippy -p ironclaw_turns --tests -- -D warnings— zero warningscargo check -p ironclaw_turns— clean buildCloses #3232