8a0c84be88
Closes brain-retro 2026-05-20 #3 SIMPLIFIED — sanitizeWithCount in pii-filter (counts matches per pattern) + persistent monthly counter docs/observer/.pii-counters.json (bumped by Stop-hook on each episode write) + status-md-generator reads real count (no more piiMatches: 0 hardcode). PII patterns themselves NOT changed (F7 of parallel session already extended to 13 patterns). Counter is informational — write failure never blocks Stop-event. 5+1+1=7 new vitest tests, 256/256 GREEN. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
52 lines
2.1 KiB
JavaScript
52 lines
2.1 KiB
JavaScript
import { describe, it, expect } from 'vitest';
|
|
import { renderStatus } from './status-md-generator.mjs';
|
|
|
|
const baseInputs = (overrides = {}) => ({
|
|
now: '2026-05-19T10:00:00+03:00',
|
|
c1: { status: 'ok', detail: 'no drift' },
|
|
c2: { status: 'ok', detail: '0 version drift' },
|
|
c3: { status: 'ok', detail: 'last read today' },
|
|
c5: { status: 'ok', detail: 'coverage OK · registration OK' },
|
|
observer: { episodeCount: 12, observerErrors: 0, piiMatches: 0 },
|
|
...overrides,
|
|
});
|
|
|
|
describe('renderStatus', () => {
|
|
it('renders all 5 controllers + metrics', () => {
|
|
const md = renderStatus(baseInputs());
|
|
expect(md).toContain('# Brain Status');
|
|
expect(md).toContain('| C1 L1-watcher | ✅');
|
|
expect(md).toContain('| C2 Cross-ref consistency | ✅');
|
|
expect(md).toContain('| C3 Observer-of-observer | ✅');
|
|
expect(md).toContain('| C4 Сигнальный статус | ✅');
|
|
expect(md).toContain('| C5 Observer-coverage | ✅');
|
|
expect(md).toContain('12 episodes');
|
|
});
|
|
|
|
it('shows a warn status for the coverage controller', () => {
|
|
const md = renderStatus(baseInputs({ c5: { status: 'warn', detail: '3 commits, 0 episodes' } }));
|
|
expect(md).toContain('| C5 Observer-coverage | ⚠️');
|
|
});
|
|
|
|
it('shows the observer_error count in the metrics block', () => {
|
|
const md = renderStatus(baseInputs({ observer: { episodeCount: 4, observerErrors: 2, piiMatches: 0 } }));
|
|
expect(md).toContain('2 observer_error markers');
|
|
});
|
|
|
|
it('shows a red status for failing controllers', () => {
|
|
const md = renderStatus(baseInputs({ c1: { status: 'fail', detail: '2 plugins not formalized' } }));
|
|
expect(md).toContain('| C1 L1-watcher | 🔴');
|
|
});
|
|
|
|
it('mentions the capability-readiness behavioral rule', () => {
|
|
const md = renderStatus(baseInputs());
|
|
expect(md).toContain('capability-readiness');
|
|
expect(md).toContain('feedback_brain_unused_tools_not_problem');
|
|
});
|
|
|
|
it('shows piiMatches > 0 when counter file has data (Task 3)', () => {
|
|
const md = renderStatus(baseInputs({ observer: { episodeCount: 24, observerErrors: 0, piiMatches: 7 } }));
|
|
expect(md).toMatch(/7 PII matches before filter/);
|
|
});
|
|
});
|