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:
Paul Bakaus
2026-08-11 13:00:31 -04:00
parent d4aacaccfd
commit 357f358050
2 changed files with 10 additions and 1 deletions
+1 -1
View File
@@ -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;
};
+9
View File
@@ -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');