@@ -19,8 +19,8 @@ import * as path from 'path';
1919jest . mock ( '../../../src/utils/fs-extra-safe.js' , ( ) => ( {
2020 pathExists : jest . fn ( ) ,
2121 ensureDir : jest . fn ( ) ,
22- readJson : jest . fn ( ) ,
23- writeJson : jest . fn ( ) ,
22+ readFile : jest . fn ( ) ,
23+ writeFile : jest . fn ( ) ,
2424 remove : jest . fn ( ) ,
2525 readdir : jest . fn ( )
2626} ) ) ;
@@ -47,8 +47,8 @@ describe('ComplianceTracker', () => {
4747 // Default mock implementations
4848 mockFs . pathExists . mockResolvedValue ( false ) ;
4949 mockFs . ensureDir . mockResolvedValue ( undefined ) ;
50- mockFs . readJson . mockResolvedValue ( { } ) ;
51- mockFs . writeJson . mockResolvedValue ( undefined ) ;
50+ mockFs . readFile . mockResolvedValue ( '{}' ) ;
51+ mockFs . writeFile . mockResolvedValue ( undefined ) ;
5252
5353 // Create ComplianceTracker instance
5454 complianceTracker = new ComplianceTracker ( mockConfig ) ;
@@ -145,12 +145,9 @@ describe('ComplianceTracker', () => {
145145 await complianceTracker . recordActivity ( 'test-agent' , activity ) ;
146146
147147 // Assert
148- expect ( mockFs . writeJson ) . toHaveBeenCalledWith (
148+ expect ( mockFs . writeFile ) . toHaveBeenCalledWith (
149149 path . join ( mockConfig . commDir , '.compliance' , 'test-agent.json' ) ,
150- expect . objectContaining ( {
151- agent : 'test-agent' ,
152- tasksCreated : 1
153- } )
150+ expect . stringContaining ( '"agent": "test-agent"' )
154151 ) ;
155152 } ) ;
156153 } ) ;
@@ -171,7 +168,7 @@ describe('ComplianceTracker', () => {
171168 escalationLevel : 1
172169 } ;
173170
174- mockFs . readJson . mockResolvedValue ( perfectRecord ) ;
171+ mockFs . readFile . mockResolvedValue ( JSON . stringify ( perfectRecord ) ) ;
175172
176173 // Act
177174 const level = await complianceTracker . getComplianceLevel ( 'perfect-agent' ) ;
@@ -196,7 +193,7 @@ describe('ComplianceTracker', () => {
196193 } ;
197194
198195 mockFs . pathExists . mockResolvedValue ( true ) ;
199- mockFs . readJson . mockResolvedValue ( record ) ;
196+ mockFs . readFile . mockResolvedValue ( JSON . stringify ( record ) ) ;
200197
201198 // Act
202199 const level = await complianceTracker . getComplianceLevel ( 'poor-delegator' ) ;
@@ -222,7 +219,7 @@ describe('ComplianceTracker', () => {
222219 } ;
223220
224221 mockFs . pathExists . mockResolvedValue ( true ) ;
225- mockFs . readJson . mockResolvedValue ( record ) ;
222+ mockFs . readFile . mockResolvedValue ( JSON . stringify ( record ) ) ;
226223
227224 // Act
228225 const level = await complianceTracker . getComplianceLevel ( 'no-todo-agent' ) ;
@@ -248,7 +245,7 @@ describe('ComplianceTracker', () => {
248245 } ;
249246
250247 mockFs . pathExists . mockResolvedValue ( true ) ;
251- mockFs . readJson . mockResolvedValue ( record ) ;
248+ mockFs . readFile . mockResolvedValue ( JSON . stringify ( record ) ) ;
252249
253250 // Act
254251 const level = await complianceTracker . getComplianceLevel ( 'no-plan-agent' ) ;
@@ -284,7 +281,7 @@ describe('ComplianceTracker', () => {
284281 escalationLevel : 4
285282 } ;
286283
287- mockFs . readJson . mockResolvedValue ( record ) ;
284+ mockFs . readFile . mockResolvedValue ( JSON . stringify ( record ) ) ;
288285
289286 // Act
290287 const level = await complianceTracker . getComplianceLevel ( 'terrible-agent' ) ;
@@ -458,18 +455,15 @@ describe('ComplianceTracker', () => {
458455 escalationLevel : 1
459456 } ;
460457
461- mockFs . readJson . mockResolvedValue ( record ) ;
458+ mockFs . readFile . mockResolvedValue ( JSON . stringify ( record ) ) ;
462459
463460 // Act
464461 await complianceTracker . updateComplianceScore ( 'test-agent' ) ;
465462
466463 // Assert
467- expect ( mockFs . writeJson ) . toHaveBeenCalledWith (
464+ expect ( mockFs . writeFile ) . toHaveBeenCalledWith (
468465 expect . any ( String ) ,
469- expect . objectContaining ( {
470- complianceScore : expect . any ( Number ) ,
471- escalationLevel : expect . any ( Number )
472- } )
466+ expect . stringContaining ( '"complianceScore": ' )
473467 ) ;
474468 } ) ;
475469 } ) ;
@@ -494,7 +488,7 @@ describe('ComplianceTracker', () => {
494488 } ;
495489
496490 mockFs . readdir . mockResolvedValue ( [ 'stale-agent.json' ] as unknown as string [ ] ) ;
497- mockFs . readJson . mockResolvedValue ( staleRecord ) ;
491+ mockFs . readFile . mockResolvedValue ( JSON . stringify ( staleRecord ) ) ;
498492 mockFs . pathExists . mockResolvedValue ( true ) ;
499493 mockFs . remove . mockResolvedValue ( undefined ) ;
500494
@@ -522,7 +516,7 @@ describe('ComplianceTracker', () => {
522516 escalationLevel : 1
523517 } ;
524518
525- mockFs . readJson . mockResolvedValue ( recentRecord ) ;
519+ mockFs . readFile . mockResolvedValue ( JSON . stringify ( recentRecord ) ) ;
526520 mockFs . pathExists . mockResolvedValue ( true ) ;
527521
528522 // Act
@@ -536,7 +530,7 @@ describe('ComplianceTracker', () => {
536530 describe ( 'error handling' , ( ) => {
537531 it ( 'should handle file read errors gracefully' , async ( ) => {
538532 // Arrange
539- mockFs . readJson . mockRejectedValue ( new Error ( 'File read error' ) ) ;
533+ mockFs . readFile . mockRejectedValue ( new Error ( 'File read error' ) ) ;
540534
541535 // Act
542536 const level = await complianceTracker . getComplianceLevel ( 'error-agent' ) ;
@@ -547,7 +541,7 @@ describe('ComplianceTracker', () => {
547541
548542 it ( 'should handle file write errors gracefully' , async ( ) => {
549543 // Arrange
550- mockFs . writeJson . mockRejectedValue ( new Error ( 'File write error' ) ) ;
544+ mockFs . writeFile . mockRejectedValue ( new Error ( 'File write error' ) ) ;
551545
552546 const activity : ComplianceActivity = {
553547 type : 'task_created' ,
0 commit comments