Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (claude): pin which manifest file the approval hash covers

[._.]/ Adam Eivy2be471b30fb7
diff --git a/server/services/sprites/walk.test.js b/server/services/sprites/walk.test.js
index bb59ff998f..c74089b638 100644
--- a/server/services/sprites/walk.test.js
+++ b/server/services/sprites/walk.test.js
@@ -401,7 +401,9 @@ describe('approveWalkDirection', () => {
expect(state.selection.directions.east).toMatchObject({
status: 'approved', runId, runPath: `runs/${runId}`, runManifest: manifestRel,
});
- expect(state.selection.directions.east.runManifestSha256).toMatch(/^[0-9a-f]{64}$/);
+ expect(state.selection.directions.east.runManifestSha256).toBe(
+ sha256(await readFile(join(TEST_ROOT, 'sprites', id, manifestRel))),
+ );
expect(state.walkSet).toBeNull();
});
@@ -418,7 +420,12 @@ describe('approveWalkDirection', () => {
// unlike the hash-pinned imported manifest it points at.
status: 'approved', runId, runManifest: manifestRel,
});
- expect(state.selection.directions.east.runManifestSha256).toMatch(/^[0-9a-f]{64}$/);
+ // Pin WHICH file was hashed, not merely that something was: the whole bug is
+ // that the anchored path resolved to a file that isn't there, so a shape-only
+ // assertion would pass over a hash of the wrong (or a missing) manifest.
+ expect(state.selection.directions.east.runManifestSha256).toBe(
+ sha256(await readFile(join(TEST_ROOT, 'sprites', id, manifestRel))),
+ );
});
it('finalizes the walk set on the 8th approval and freezes the record', async () => {
diff --git a/server/services/sprites/walkTrims.test.js b/server/services/sprites/walkTrims.test.js
index cd5be06e02..9d035e0c74 100644
--- a/server/services/sprites/walkTrims.test.js
+++ b/server/services/sprites/walkTrims.test.js
@@ -116,7 +116,11 @@ async function characterWithRedrawRun(id, { frameCount = 6 } = {}) {
// re-anchor at read time; left raw they resolve to
// `data/sprites/<id>/art-source/sprites/<id>/…`, which is inside the record dir
// (so the traversal gate passes) but does not exist.
-async function characterWithImportedRun(id, { manifest = 'valid' } = {}) {
+// `anchorPaths: false` writes the same fixture with RECORD-relative paths, so a
+// test can exercise manifest handling (absent / malformed) in isolation from the
+// re-anchoring — otherwise a malformed-manifest assertion passes for the wrong
+// reason on a reverted fix (the anchored path 404s and throws the same code).
+async function characterWithImportedRun(id, { manifest = 'valid', anchorPaths = true } = {}) {
await records.createRecord({ kind: 'character', name: 'Imported' }, id);
const width = CELL * CELL_COLORS.length;
const buf = Buffer.alloc(width * CELL * 4);
@@ -129,7 +133,7 @@ async function characterWithImportedRun(id, { manifest = 'valid' } = {}) {
await mkdir(join(runDir, 'generated'), { recursive: true });
await sharp(buf, { raw: { width, height: CELL, channels: 4 } }).png()
.toFile(join(runDir, 'generated', 'strip.png'));
- const anchored = (rel) => `art-source/sprites/${id}/${rel}`;
+ const anchored = (rel) => (anchorPaths ? `art-source/sprites/${id}/${rel}` : rel);
const stripRel = `runs/${RUN_ID}/generated/strip.png`;
const manifestRel = `runs/${RUN_ID}/generated/manifest.json`;
if (manifest !== 'absent') {
@@ -291,10 +295,17 @@ describe('saveLoopTrim', () => {
expect(manifest.selectedFrames.map((f) => f.sourceFrameLabel)).toEqual(['0', '1']);
});
+ // Record-relative on purpose: the manifest is genuinely READ here (the path
+ // resolves), so the throw can only come from the malformed-content guard — not
+ // from a 404 the way an anchored path would on an unfixed reader. That isolates
+ // this assertion to the absent-vs-malformed split it names.
it('still rejects a manifest that exists but is inconsistent', async () => {
- const id = await characterWithImportedRun(newId(), { manifest: 'malformed' });
+ const id = await characterWithImportedRun(newId(), { manifest: 'malformed', anchorPaths: false });
await expect(saveLoopTrim(id, { runId: RUN_ID, enabledColumns: [0, 1] }))
.rejects.toMatchObject({ code: 'RUN_MANIFEST_INVALID' });
+ // The throw must be terminal — no half-written trim artifacts left behind.
+ await expect(readFile(join(TEST_ROOT, 'sprites', id, 'walk/trims/east-loop-v001.json'), 'utf8'))
+ .rejects.toMatchObject({ code: 'ENOENT' });
});
it('rejects unknown runs, unpackaged runs, and out-of-strip columns', async () => {