@@ -6,12 +6,14 @@ import {
66} from "./tool-policy-pipeline.js" ;
77import { resolveToolProfilePolicy } from "./tool-policy.js" ;
88
9- const { toolPolicyAuditInfo } = vi . hoisted ( ( ) => ( {
9+ const { toolPolicyAuditDebug, toolPolicyAuditInfo } = vi . hoisted ( ( ) => ( {
10+ toolPolicyAuditDebug : vi . fn ( ) ,
1011 toolPolicyAuditInfo : vi . fn ( ) ,
1112} ) ) ;
1213
1314vi . mock ( "../logging/subsystem.js" , ( ) => ( {
1415 createSubsystemLogger : ( ) => ( {
16+ debug : toolPolicyAuditDebug ,
1517 info : toolPolicyAuditInfo ,
1618 } ) ,
1719} ) ) ;
@@ -49,6 +51,7 @@ function runAllowlistWarningStep(params: {
4951describe ( "tool-policy-pipeline" , ( ) => {
5052 beforeEach ( ( ) => {
5153 resetToolPolicyWarningCacheForTest ( ) ;
54+ toolPolicyAuditDebug . mockClear ( ) ;
5255 toolPolicyAuditInfo . mockClear ( ) ;
5356 } ) ;
5457
@@ -318,6 +321,36 @@ describe("tool-policy-pipeline", () => {
318321 removedToolsTruncated : false ,
319322 } ,
320323 ) ;
324+ expect ( toolPolicyAuditDebug ) . not . toHaveBeenCalled ( ) ;
325+ } ) ;
326+
327+ test ( "can lower removal audits for diagnostic-only policy probes" , ( ) => {
328+ const tools = [ { name : "exec" } , { name : "browser" } ] as unknown as DummyTool [ ] ;
329+
330+ applyToolPolicyPipeline ( {
331+ tools : tools as any ,
332+ toolMeta : ( ) => undefined ,
333+ warn : ( ) => { } ,
334+ auditLogLevel : "debug" ,
335+ steps : [
336+ {
337+ policy : { allow : [ "exec" ] } ,
338+ label : "doctor tools.profile (coding)" ,
339+ } ,
340+ ] ,
341+ } ) ;
342+
343+ expect ( toolPolicyAuditDebug ) . toHaveBeenCalledWith (
344+ "tool policy removed 1 tool(s) via doctor tools.profile (coding): browser" ,
345+ {
346+ rule : "doctor tools.profile (coding)" ,
347+ ruleKind : "allow" ,
348+ removedToolCount : 1 ,
349+ removedTools : [ "browser" ] ,
350+ removedToolsTruncated : false ,
351+ } ,
352+ ) ;
353+ expect ( toolPolicyAuditInfo ) . not . toHaveBeenCalled ( ) ;
321354 } ) ;
322355
323356 test ( "audits deny removals with the deny config key" , ( ) => {
@@ -346,6 +379,7 @@ describe("tool-policy-pipeline", () => {
346379 removedToolsTruncated : false ,
347380 } ,
348381 ) ;
382+ expect ( toolPolicyAuditDebug ) . not . toHaveBeenCalled ( ) ;
349383 } ) ;
350384
351385 test ( "splits mixed allow and deny policy audit entries by cause" , ( ) => {
@@ -388,6 +422,7 @@ describe("tool-policy-pipeline", () => {
388422 removedToolsTruncated : false ,
389423 } ,
390424 ) ;
425+ expect ( toolPolicyAuditDebug ) . not . toHaveBeenCalled ( ) ;
391426 } ) ;
392427
393428 test ( "does not audit policy steps that leave the tool surface unchanged" , ( ) => {
@@ -405,6 +440,7 @@ describe("tool-policy-pipeline", () => {
405440 ] ,
406441 } ) ;
407442
443+ expect ( toolPolicyAuditDebug ) . not . toHaveBeenCalled ( ) ;
408444 expect ( toolPolicyAuditInfo ) . not . toHaveBeenCalled ( ) ;
409445 } ) ;
410446
@@ -433,5 +469,6 @@ describe("tool-policy-pipeline", () => {
433469 removedToolsTruncated : false ,
434470 } ,
435471 ) ;
472+ expect ( toolPolicyAuditDebug ) . not . toHaveBeenCalled ( ) ;
436473 } ) ;
437474} ) ;
0 commit comments