From 6b557f8cf2e5d910150fc82317ee56464f1582ce Mon Sep 17 00:00:00 2001 From: QQ Date: Tue, 10 Nov 2026 21:09:19 +0800 Subject: [PATCH] =?UTF-8?q?feat(policy):=20=E6=9C=AA=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E9=BB=98=E8=AE=A4=E6=8B=A6=E6=88=AA=EF=BC=8C?= =?UTF-8?q?=E9=97=AE=E6=B8=85=E5=8F=AA=E8=AF=BB=E8=BF=98=E6=98=AF=E6=94=B9?= =?UTF-8?q?=E5=8A=A8=E3=80=81=E7=99=BB=E8=AE=B0=E5=90=8E=E6=89=8D=E6=94=BE?= =?UTF-8?q?=E8=A1=8C=EF=BC=88POLICY=5FVERSION=200.5.0=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/policy.test.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/policy.test.js b/test/policy.test.js index 632410e..c15cdc8 100644 --- a/test/policy.test.js +++ b/test/policy.test.js @@ -137,6 +137,20 @@ test('keeps management tool audit and approval rules', () => { assert.match(evaluateToolPolicy('bingbu', 'automation_create', [approvedTask('bingbu')]), /门下省准奏记录/) }) +test('blocks unclassified tools by default instead of treating them as read-only', () => { + // 没在任何名单里的工具:执行部门、任务已准奏也先拦;丞相同样拦 + assert.match(evaluateToolPolicy('gongbu', 'some_future_tool', [approvedTask('gongbu')]), /尚未登记分类/) + assert.match(evaluateToolPolicy('lead', 'some_future_tool', []), /尚未登记分类/) + // 登记在册的只读工具照常放行 + for (const tool of ['read', 'grep', 'glob']) { + assert.equal(evaluateToolPolicy('zhongshu', tool, []), undefined) + assert.equal(evaluateToolPolicy('gongbu', tool, []), undefined) + } + // 签字类工具:没签字拦在签字关;签了字放行,不被未知工具规则误伤 + assert.match(evaluateToolPolicy('bingbu', 'remote_ssh_delete', [approvedTask('bingbu')]), /人工签字/) + assert.equal(evaluateToolPolicy('bingbu', 'remote_ssh_delete', [approvedTask('bingbu')], { humanSigned: true }), undefined) +}) + test('parses the department model command the panel sends', async () => { const { parseDeptModelCommand, describeDeptRoutes, readStoredRoutes, writeStoredRoutes } = await import('../index.js') assert.deepEqual(parseDeptModelCommand('gongbu deepseek deepseek-chat high'), {