Pinned pi SDK 0.85.1 bridge, Python supervisor, artifact exporter, scripted backend peer, image checks and boundary checks under agent/**. Review findings F1-F3 are recorded in docs/implementation/PI_AGENT_REVIEW.md.
24 lines
1.3 KiB
TypeScript
24 lines
1.3 KiB
TypeScript
import test from 'node:test';
|
||
import assert from 'node:assert/strict';
|
||
import { WarningCollector } from '../warnings.js';
|
||
import { warning } from '../validation.js';
|
||
|
||
test('repeats preserve bounded Unicode messages and snapshots do not alias', () => {
|
||
const collector = new WarningCollector(); const value = { code: 'repeat', message: '雪'.repeat(341), name: 'file' };
|
||
collector.add(value); const before = collector.snapshot();
|
||
for (let i = 0; i < 150; i++) collector.add(value);
|
||
const entries = collector.snapshot(); assert.equal(entries.length, 1); warning(entries[0]);
|
||
assert(Buffer.byteLength(entries[0].message) <= 1024); assert(!entries[0].message.includes('<27>')); assert.match(entries[0].message, /Repeated 151 times/);
|
||
assert.equal(before[0].message, value.message);
|
||
});
|
||
test('overflow includes repetitions of the replaced last warning', () => {
|
||
const collector = new WarningCollector();
|
||
for (let i = 0; i < 100; i++) collector.add({ code: `warning_${i}`, message: 'Warning.' });
|
||
collector.add({ code: 'warning_99', message: 'Warning.' });
|
||
collector.add({ code: 'overflow', message: 'Warning.' });
|
||
collector.add({ code: 'warning_99', message: 'Warning.' });
|
||
const entries = collector.snapshot(); assert.equal(entries.length, 100);
|
||
assert.match(entries.at(-1)!.message, /^4 additional/);
|
||
entries.forEach(warning);
|
||
});
|