























@@ -6,12 +6,14 @@ import {
66} from "./tool-policy-pipeline.js";
77import { resolveToolProfilePolicy } from "./tool-policy.js";
889-const { toolPolicyAuditInfo } = vi.hoisted(() => ({
9+const { toolPolicyAuditDebug, toolPolicyAuditInfo } = vi.hoisted(() => ({
10+toolPolicyAuditDebug: vi.fn(),
1011toolPolicyAuditInfo: vi.fn(),
1112}));
12131314vi.mock("../logging/subsystem.js", () => ({
1415createSubsystemLogger: () => ({
16+debug: toolPolicyAuditDebug,
1517info: toolPolicyAuditInfo,
1618}),
1719}));
@@ -49,6 +51,7 @@ function runAllowlistWarningStep(params: {
4951describe("tool-policy-pipeline", () => {
5052beforeEach(() => {
5153resetToolPolicyWarningCacheForTest();
54+toolPolicyAuditDebug.mockClear();
5255toolPolicyAuditInfo.mockClear();
5356});
5457@@ -318,6 +321,36 @@ describe("tool-policy-pipeline", () => {
318321removedToolsTruncated: 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});
322355323356test("audits deny removals with the deny config key", () => {
@@ -346,6 +379,7 @@ describe("tool-policy-pipeline", () => {
346379removedToolsTruncated: false,
347380},
348381);
382+expect(toolPolicyAuditDebug).not.toHaveBeenCalled();
349383});
350384351385test("splits mixed allow and deny policy audit entries by cause", () => {
@@ -388,6 +422,7 @@ describe("tool-policy-pipeline", () => {
388422removedToolsTruncated: false,
389423},
390424);
425+expect(toolPolicyAuditDebug).not.toHaveBeenCalled();
391426});
392427393428test("does not audit policy steps that leave the tool surface unchanged", () => {
@@ -405,6 +440,7 @@ describe("tool-policy-pipeline", () => {
405440],
406441});
407442443+expect(toolPolicyAuditDebug).not.toHaveBeenCalled();
408444expect(toolPolicyAuditInfo).not.toHaveBeenCalled();
409445});
410446@@ -433,5 +469,6 @@ describe("tool-policy-pipeline", () => {
433469removedToolsTruncated: false,
434470},
435471);
472+expect(toolPolicyAuditDebug).not.toHaveBeenCalled();
436473});
437474});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。