mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-14 23:26:39 +03:00
Centralize critique snapshot reading (#511)
Make critique storage the single owner of snapshot discovery and frontmatter parsing, and keep context signals focused on summarizing the canonical result. AI-assisted: Prepared by Codex under pbakaus's scheduled architecture-refactor authorization.
This commit is contained in:
@@ -76,6 +76,22 @@ describe('gatherSignals', () => {
|
||||
assert.equal(s.critique.latest.slug, 'home');
|
||||
});
|
||||
|
||||
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');
|
||||
write('.impeccable/critique/2026-05-02T10-00-00Z__pricing.md',
|
||||
'---\nslug: pricing\nscore: 9\np0: 0\np1: 1\ntimestamp: 2026-05-02T10-00-00Z\n---\nbody\n');
|
||||
write('.impeccable/critique/ignore.md', '# Critique ignores\n');
|
||||
write('.impeccable/critique/9999-not-a-snapshot.md', '# Draft\n');
|
||||
const s = await gatherSignals(scratch);
|
||||
assert.equal(s.critique.latest.slug, 'pricing');
|
||||
assert.equal(s.critique.latest.score, 9);
|
||||
assert.equal(
|
||||
s.critique.latest.file,
|
||||
'.impeccable/critique/2026-05-02T10-00-00Z__pricing.md',
|
||||
);
|
||||
});
|
||||
|
||||
it('handles a non-git dir without throwing', async () => {
|
||||
const s = await gatherSignals(scratch);
|
||||
assert.equal(s.git.isRepo, false);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import { describe, it, beforeEach, afterEach } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { mkdtempSync, rmSync, symlinkSync } from 'node:fs';
|
||||
import { mkdtempSync, rmSync, symlinkSync, writeFileSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { spawnSync } from 'node:child_process';
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
slugFromTarget,
|
||||
writeSnapshot,
|
||||
readLatestSnapshot,
|
||||
readLatestSnapshotAcrossTargets,
|
||||
readTrend,
|
||||
nowFilenameStamp,
|
||||
} from '../skill/scripts/critique-storage.mjs';
|
||||
@@ -114,6 +115,16 @@ describe('writeSnapshot + readLatestSnapshot', () => {
|
||||
assert.match(latest.body, /new/);
|
||||
});
|
||||
|
||||
it('picks the newest snapshot across target slugs', () => {
|
||||
writeSnapshot({ slug: 'home', meta: {}, body: 'old', cwd, now: new Date('2026-05-01T00:00:00Z') });
|
||||
writeSnapshot({ slug: 'pricing', meta: {}, body: 'new', cwd, now: new Date('2026-05-12T00:00:00Z') });
|
||||
writeFileSync(join(cwd, '.impeccable', 'critique', 'ignore.md'), '# Critique ignores\n');
|
||||
writeFileSync(join(cwd, '.impeccable', 'critique', '9999-not-a-snapshot.md'), '# Draft\n');
|
||||
const latest = readLatestSnapshotAcrossTargets({ cwd });
|
||||
assert.equal(latest.meta.slug, 'pricing');
|
||||
assert.match(latest.body, /new/);
|
||||
});
|
||||
|
||||
it('does not see snapshots for a different slug', () => {
|
||||
writeSnapshot({ slug: 'pricing-astro', meta: { total_score: 10 }, body: 'b', cwd });
|
||||
assert.equal(readLatestSnapshot('index-astro', { cwd }), null);
|
||||
|
||||
Reference in New Issue
Block a user