mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-12 06:06:37 +03:00
Fix critique routing signals
Read the documented critique snapshot keys while preserving legacy aliases, and surface missing metrics as null instead of zero. Prepared with AI assistance under maintainer pbakaus's standing automation authorization.
This commit is contained in:
@@ -42,14 +42,15 @@ function latestCritique(cwd) {
|
||||
if (!latest) return null;
|
||||
const get = (key) => latest.meta[key] ?? null;
|
||||
const num = (v) => {
|
||||
if (v == null) return null;
|
||||
const n = Number(v);
|
||||
return Number.isFinite(n) ? n : null;
|
||||
};
|
||||
return {
|
||||
slug: get('slug'),
|
||||
score: num(get('score')),
|
||||
p0: num(get('p0')),
|
||||
p1: num(get('p1')),
|
||||
score: num(get('total_score') ?? get('score')),
|
||||
p0: num(get('p0_count') ?? get('p0')),
|
||||
p1: num(get('p1_count') ?? get('p1')),
|
||||
timestamp: get('timestamp'),
|
||||
file: path.relative(cwd, latest.path),
|
||||
};
|
||||
|
||||
@@ -76,6 +76,24 @@ describe('gatherSignals', () => {
|
||||
assert.equal(s.critique.latest.slug, 'home');
|
||||
});
|
||||
|
||||
it('reads the documented critique snapshot metadata keys', async () => {
|
||||
write('.impeccable/critique/2026-05-02T10-00-00Z__pricing.md',
|
||||
'---\nslug: pricing\ntotal_score: 24\np0_count: 2\np1_count: 5\ntimestamp: 2026-05-02T10-00-00Z\n---\nbody\n');
|
||||
const s = await gatherSignals(scratch);
|
||||
assert.equal(s.critique.latest.score, 24);
|
||||
assert.equal(s.critique.latest.p0, 2);
|
||||
assert.equal(s.critique.latest.p1, 5);
|
||||
});
|
||||
|
||||
it('reports missing critique metrics as null', async () => {
|
||||
write('.impeccable/critique/2026-05-02T10-00-00Z__pricing.md',
|
||||
'---\nslug: pricing\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