mirror of
https://github.com/davidkaya/aryx.git
synced 2026-08-03 18:38:35 +02:00
fix: require tool approval by default
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { describe, expect, test } from 'bun:test';
|
||||
|
||||
import {
|
||||
applyDefaultToolApprovalPolicy,
|
||||
approvalPolicyRequiresToolCallApproval,
|
||||
approvalPolicyRequiresCheckpoint,
|
||||
normalizeApprovalPolicy,
|
||||
@@ -14,6 +15,20 @@ import {
|
||||
} from '@shared/domain/approval';
|
||||
|
||||
describe('approval helpers', () => {
|
||||
test('applies tool-call approval by default while preserving an explicit empty policy', () => {
|
||||
expect(applyDefaultToolApprovalPolicy()).toEqual({
|
||||
rules: [{ kind: 'tool-call' }],
|
||||
});
|
||||
|
||||
expect(normalizeApprovalPolicy({})).toEqual({
|
||||
rules: [],
|
||||
});
|
||||
|
||||
expect(applyDefaultToolApprovalPolicy({})).toEqual({
|
||||
rules: [],
|
||||
});
|
||||
});
|
||||
|
||||
test('normalizes duplicate checkpoint rules and auto-approved tools into stable policy entries', () => {
|
||||
expect(normalizeApprovalPolicy({
|
||||
rules: [
|
||||
|
||||
@@ -20,6 +20,14 @@ describe('pattern validation', () => {
|
||||
}
|
||||
});
|
||||
|
||||
test('builtin patterns require tool-call approval by default', () => {
|
||||
const patterns = createBuiltinPatterns(BUILTIN_TIMESTAMP);
|
||||
|
||||
for (const pattern of patterns) {
|
||||
expect(pattern.approvalPolicy?.rules).toContainEqual({ kind: 'tool-call' });
|
||||
}
|
||||
});
|
||||
|
||||
test('magentic pattern is marked unavailable', () => {
|
||||
const magentic = createBuiltinPatterns(BUILTIN_TIMESTAMP).find(
|
||||
(pattern) => pattern.mode === 'magentic',
|
||||
|
||||
@@ -31,6 +31,7 @@ describe('workspace seed', () => {
|
||||
for (const pattern of workspace.patterns) {
|
||||
expect(pattern.createdAt).toBe(workspace.lastUpdatedAt);
|
||||
expect(pattern.updatedAt).toBe(workspace.lastUpdatedAt);
|
||||
expect(pattern.approvalPolicy?.rules).toContainEqual({ kind: 'tool-call' });
|
||||
}
|
||||
|
||||
const magentic = workspace.patterns.find((pattern) => pattern.mode === 'magentic');
|
||||
|
||||
Reference in New Issue
Block a user