Files
brain/tools/enforce-floor-escape-consume.test.mjs
T

21 lines
1.1 KiB
JavaScript

import { describe, it, expect } from 'vitest';
import { decideMark } from './enforce-floor-escape-consume.mjs';
describe('enforce-floor-escape-consume decideMark', () => {
const now = 1000;
it('исполненный floor с непогашенным пропуском → отметка', () => {
const ev = { tool_name: 'Bash', tool_input: { command: 'git reset --hard' } };
const r = decideMark(ev, { grants: [{ action: 'bash:git reset --hard', ts: now - 5 }], consumed: [], now });
expect(r).toEqual({ action: 'bash:git reset --hard', ts: now - 5 });
});
it('нет совпавшего пропуска → null', () => {
const ev = { tool_name: 'Bash', tool_input: { command: 'git status' } };
expect(decideMark(ev, { grants: [], consumed: [], now })).toBe(null);
});
it('уже погашённый пропуск → null (one-shot)', () => {
const ev = { tool_name: 'Bash', tool_input: { command: 'git reset --hard' } };
const g = { action: 'bash:git reset --hard', ts: now - 5 };
expect(decideMark(ev, { grants: [g], consumed: [g], now })).toBe(null);
});
});