22// used to decide whether repeated tool actions can recover prior failures.
33import { describe , expect , it } from "vitest" ;
44import {
5- buildToolActionFingerprint ,
65 buildToolMutationState ,
76 isLikelyMutatingToolName ,
87 isMutatingToolCall ,
@@ -22,21 +21,23 @@ describe("tool mutation helpers", () => {
2221 } ) ;
2322
2423 it ( "builds stable fingerprints for mutating calls and omits read-only calls" , ( ) => {
25- const writeFingerprint = buildToolActionFingerprint (
24+ const writeFingerprint = buildToolMutationState (
2625 "write" ,
2726 { path : "/tmp/demo.txt" , id : 42 } ,
2827 "write /tmp/demo.txt" ,
29- ) ;
28+ ) . actionFingerprint ;
3029 expect ( writeFingerprint ) . toBe ( "tool=write|path=/tmp/demo.txt|id=42" ) ;
3130
32- const metaOnlyFingerprint = buildToolActionFingerprint (
31+ const metaOnlyFingerprint = buildToolMutationState (
3332 "exec" ,
3433 { command : "npm start" } ,
3534 "npm start" ,
36- ) ;
35+ ) . actionFingerprint ;
3736 expect ( metaOnlyFingerprint ) . toBe ( "tool=exec|meta=npm start" ) ;
3837
39- const readFingerprint = buildToolActionFingerprint ( "read" , { path : "/tmp/demo.txt" } ) ;
38+ const readFingerprint = buildToolMutationState ( "read" , {
39+ path : "/tmp/demo.txt" ,
40+ } ) . actionFingerprint ;
4041 expect ( readFingerprint ) . toBeUndefined ( ) ;
4142 } ) ;
4243
@@ -49,7 +50,7 @@ describe("tool mutation helpers", () => {
4950 ] ) ( "treats read-only shell command as non-mutating: %s %s" , ( toolName , command ) => {
5051 expect ( isMutatingToolCall ( toolName , { command } ) ) . toBe ( false ) ;
5152 expect ( buildToolMutationState ( toolName , { command } ) . mutatingAction ) . toBe ( false ) ;
52- expect ( buildToolActionFingerprint ( toolName , { command } , command ) ) . toBeUndefined ( ) ;
53+ expect ( buildToolMutationState ( toolName , { command } , command ) . actionFingerprint ) . toBeUndefined ( ) ;
5354 } ) ;
5455
5556 it . each ( [
@@ -101,22 +102,22 @@ describe("tool mutation helpers", () => {
101102 ] ) ( "keeps ambiguous or mutating shell command mutating: %s %s" , ( toolName , command ) => {
102103 expect ( isMutatingToolCall ( toolName , { command } ) ) . toBe ( true ) ;
103104 expect ( buildToolMutationState ( toolName , { command } , command ) . mutatingAction ) . toBe ( true ) ;
104- expect ( buildToolActionFingerprint ( toolName , { command } , command ) ) . toBe (
105+ expect ( buildToolMutationState ( toolName , { command } , command ) . actionFingerprint ) . toBe (
105106 `tool=${ toolName } |meta=${ command . toLowerCase ( ) . replace ( / \s + / g, " " ) } ` ,
106107 ) ;
107108 } ) ;
108109
109110 it ( "treats coding-tool path aliases as the same stable target" , ( ) => {
110- const filePathFingerprint = buildToolActionFingerprint ( "edit" , {
111+ const filePathFingerprint = buildToolMutationState ( "edit" , {
111112 file_path : "/tmp/demo.txt" ,
112113 old_string : "before" ,
113114 new_string : "after" ,
114- } ) ;
115- const fileAliasFingerprint = buildToolActionFingerprint ( "edit" , {
115+ } ) . actionFingerprint ;
116+ const fileAliasFingerprint = buildToolMutationState ( "edit" , {
116117 file : "/tmp/demo.txt" ,
117118 oldText : "before" ,
118119 newText : "after again" ,
119- } ) ;
120+ } ) . actionFingerprint ;
120121
121122 expect ( filePathFingerprint ) . toBe ( "tool=edit|path=/tmp/demo.txt" ) ;
122123 expect ( fileAliasFingerprint ) . toBe ( "tool=edit|path=/tmp/demo.txt" ) ;
0 commit comments