@@ -28,20 +28,52 @@ func TestApplyToolExecutionCompletionTracksWriteAndVerification(t *testing.T) {
2828 t .Parallel ()
2929
3030 written := applyToolExecutionCompletion (controlplane.CompletionState {}, toolExecutionSummary {
31- HasSuccessfulWorkspaceWrite : true ,
31+ Results : []tools.ToolResult {
32+ {Facts : tools.ToolExecutionFacts {WorkspaceWrite : true }},
33+ },
3234 })
3335 if ! written .HasUnverifiedWrites {
3436 t .Fatalf ("expected successful write to require verification, got %+v" , written )
3537 }
3638
3739 verified := applyToolExecutionCompletion (written , toolExecutionSummary {
38- HasSuccessfulVerification : true ,
40+ Results : []tools.ToolResult {
41+ {Facts : tools.ToolExecutionFacts {VerificationPerformed : true , VerificationPassed : true }},
42+ },
3943 })
4044 if verified .HasUnverifiedWrites {
4145 t .Fatalf ("expected explicit verification to clear pending write, got %+v" , verified )
4246 }
4347}
4448
49+ func TestApplyToolExecutionCompletionKeepsUnverifiedWhenVerifyBeforeWrite (t * testing.T ) {
50+ t .Parallel ()
51+
52+ got := applyToolExecutionCompletion (controlplane.CompletionState {}, toolExecutionSummary {
53+ Results : []tools.ToolResult {
54+ {Facts : tools.ToolExecutionFacts {VerificationPerformed : true , VerificationPassed : true }},
55+ {Facts : tools.ToolExecutionFacts {WorkspaceWrite : true }},
56+ },
57+ })
58+ if ! got .HasUnverifiedWrites {
59+ t .Fatalf ("expected write after verify to remain unverified, got %+v" , got )
60+ }
61+ }
62+
63+ func TestApplyToolExecutionCompletionClearsWhenVerifyAfterWrite (t * testing.T ) {
64+ t .Parallel ()
65+
66+ got := applyToolExecutionCompletion (controlplane.CompletionState {}, toolExecutionSummary {
67+ Results : []tools.ToolResult {
68+ {Facts : tools.ToolExecutionFacts {WorkspaceWrite : true }},
69+ {Facts : tools.ToolExecutionFacts {VerificationPerformed : true , VerificationPassed : true }},
70+ },
71+ })
72+ if got .HasUnverifiedWrites {
73+ t .Fatalf ("expected verify after write to clear unverified flag, got %+v" , got )
74+ }
75+ }
76+
4577func TestHasPendingAgentTodosBlocksOnAnyNonTerminalTodo (t * testing.T ) {
4678 t .Parallel ()
4779
0 commit comments