Make plan approval gate only active in plan mode

- Add in_plan_mode flag to Agent struct
- Add set_plan_mode() and is_plan_mode() methods
- Gate check now only runs when in_plan_mode is true
- CLI calls set_plan_mode(true) on /plan command and EnterPlanMode
- CLI calls set_plan_mode(false) on approval and CTRL-D exit
- Update integration test to enable plan mode
- Fix test YAML to use Vec<Check> for negative/boundary checks
This commit is contained in:
Dhanji R. Prasanna
2026-02-05 11:41:52 +11:00
parent 3d284b8b60
commit 0f919237ea
5 changed files with 35 additions and 14 deletions

View File

@@ -906,6 +906,9 @@ async fn test_plan_approval_gate_blocks_unapproved_changes() {
// Set the working directory to the temp git repo
agent.set_working_dir(temp_path.to_string_lossy().to_string());
// Enable plan mode (required for the gate check to run)
agent.set_plan_mode(true);
// Create an unapproved plan for this session
let mut plan = Plan::new("test-plan");
plan.items.push(PlanItem {
@@ -915,8 +918,8 @@ async fn test_plan_approval_gate_blocks_unapproved_changes() {
touches: vec!["src/test.rs".to_string()],
checks: Checks {
happy: Check::new("happy", "target"),
negative: Check::new("negative", "target"),
boundary: Check::new("boundary", "target"),
negative: vec![Check::new("negative", "target")],
boundary: vec![Check::new("boundary", "target")],
},
evidence: vec![],
notes: None,

View File

@@ -616,11 +616,11 @@ items:
desc: Works correctly
target: test::module
negative:
desc: Handles errors
target: test::module
- desc: Handles errors
target: test::module
boundary:
desc: Edge cases
target: test::module"#
- desc: Edge cases
target: test::module"#
}),
};
let write_result = agent.execute_tool(&write_call).await.unwrap();

View File

@@ -420,11 +420,11 @@ items:
desc: Works
target: test
negative:
desc: Errors
target: test
- desc: Errors
target: test
boundary:
desc: Edge
target: test"#
- desc: Edge
target: test"#
}),
);
@@ -477,8 +477,8 @@ items:
touches: ["src/test.rs"]
checks:
happy: {desc: Works, target: test}
negative: {desc: Errors, target: test}
boundary: {desc: Edge, target: test}"#
negative: [{desc: Errors, target: test}]
boundary: [{desc: Edge, target: test}]"#
}),
);
agent.execute_tool(&write_call).await.unwrap();