mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-11 21:57:14 +03:00
Reject empty critique metrics
Treat empty and whitespace-only snapshot values as missing so malformed frontmatter cannot reintroduce plausible zeroes. Prepared with AI assistance under maintainer pbakaus's standing automation authorization.
This commit is contained in:
@@ -42,7 +42,7 @@ function latestCritique(cwd) {
|
||||
if (!latest) return null;
|
||||
const get = (key) => latest.meta[key] ?? null;
|
||||
const num = (v) => {
|
||||
if (v == null) return null;
|
||||
if (v == null || (typeof v === 'string' && v.trim() === '')) return null;
|
||||
const n = Number(v);
|
||||
return Number.isFinite(n) ? n : null;
|
||||
};
|
||||
|
||||
@@ -94,6 +94,15 @@ describe('gatherSignals', () => {
|
||||
assert.equal(s.critique.latest.p1, null);
|
||||
});
|
||||
|
||||
it('reports empty and invalid critique metrics as null', async () => {
|
||||
write('.impeccable/critique/2026-05-02T10-00-00Z__pricing.md',
|
||||
'---\nslug: pricing\ntotal_score: \np0_count: \np1_count: nope\ntimestamp: 2026-05-02T10-00-00Z\n---\nbody\n');
|
||||
const s = await gatherSignals(scratch);
|
||||
assert.equal(s.critique.latest.score, null);
|
||||
assert.equal(s.critique.latest.p0, null);
|
||||
assert.equal(s.critique.latest.p1, null);
|
||||
});
|
||||
|
||||
it('reads the newest critique snapshot across target slugs', async () => {
|
||||
write('.impeccable/critique/2026-05-01T10-00-00Z__home.md',
|
||||
'---\nslug: home\nscore: 6\np0: 1\np1: 3\ntimestamp: 2026-05-01T10-00-00Z\n---\nbody\n');
|
||||
|
||||
Reference in New Issue
Block a user