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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (claude): probe for the clip AFTER manifest expansion, not before
[._.]/ Adam Eivyf1edea6111f4
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex b97c32acec..5aeb359dc5 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -25,7 +25,7 @@## Sprite Manager-- **[issue-2984] Imported walk cycles now bring their source clip along, so they can be re-derived at a new frame count** — importing a character used to copy the finished walk strips but leave behind the video clip each one was extracted from. Since the packer can only ever resample *down*, that permanently froze every imported direction at the frame count it arrived with: a character imported at 8 frames could never be brought up to 12 to match a direction generated here, and PortOS couldn't compile its atlas at all while the two disagreed. The importer now copies each run's source clip (resolving it whichever folder layout the source tree uses), so imported directions become re-derivable — while the bulky extracted frame folders are still skipped, since they're re-extracted from the clip on demand. A clip whose contents don't match the checksum its manifest declares is refused with a message naming the run rather than silently imported. Characters imported before this upgrade are checked on startup and healed where the clip is already somewhere in their folder; where it isn't, PortOS logs plainly that re-running the import against the original source tree is what brings it across.+- **[issue-2984] Imported walk cycles now bring their source clip along, so they can be re-derived at a new frame count** — importing a character used to copy the finished walk strips but leave behind the video clip each one was extracted from. Since the packer can only ever resample *down*, that permanently froze every imported direction at the frame count it arrived with: a character imported at 8 frames could never be brought up to 12 to match a direction generated here, and PortOS couldn't compile its atlas at all while the two disagreed. The importer now copies each run's source clip (resolving it whichever folder layout the source tree uses), so the material re-derivation needs is finally on disk — while the bulky extracted frame folders are still skipped, since they're re-extracted from the clip on demand. A clip whose contents don't match the checksum its manifest declares is refused with a message naming the run rather than silently imported. Characters imported before this upgrade are checked on startup and healed where the clip is already somewhere in their folder; where it isn't, PortOS logs plainly that re-running the import against the original source tree is what brings it across. (Actually re-deriving an imported direction at a new frame count also needs the imported-walk-set lock lifted — that lands next.)- **[issue-2978] Saving a loop trim now works on imported characters** — for a character whose walk cycles came in through the source-pipeline import, the Loop Trimmer would load, scrub, and play the animation perfectly, then fail on **Save trim** with "Packaged run manifest is missing or inconsistent" — after you'd already picked your frames, and with nothing saved. The imported artwork was never damaged; PortOS was simply looking for the packaged manifest under the wrong folder and giving up. Trims now save on imported characters, keep the real gait-phase labels (left-contact, left-passing, …) for each kept frame, and record the correct source strip. A run whose manifest went missing entirely now falls back to the strip's own geometry and still trims, while a manifest that's genuinely corrupt still refuses loudly instead of quietly guessing. The same lookup fixed approving an imported walk direction, which would have failed the same way.- **Steer a directional-anchor re-roll with a correction note** — when a directional anchor comes out wrong (say the north-east pose grew a pocket on the arm that has none in every other view), re-rolling it with the same inputs tended to just reproduce the same mistake. Each unlocked anchor tile now has a small **Correction (optional)** box: type what to fix ("no pocket on the right sleeve") and hit **Regenerate**, and the note is appended to that pose's prompt as an explicit override so the new render actually diverges. The button reads **Generate** on the first render and **Regenerate** once candidates exist, the correction is per-direction (so eight different fixes don't collide), and it rides into the candidate's saved prompt so the image preview shows exactly what was asked for. Main-reference iteration is unchanged — it already has its own design-prompt box.- **[issue-2964] The same correction note now steers a re-roll from the asset card too** — the correction box used to live only on the Reference Set's anchor grid, so re-rolling a directional-anchor candidate from its card in the Assets library ignored any fix you'd typed. Each anchor candidate card now carries the same correction affordance: click its note icon to type ("no pocket on the right sleeve") and hit **Regenerate**, and that guidance is appended to the pose's prompt exactly as it is from the grid. The two surfaces share one correction per direction, so a note you type in either place shows up in the other, and both re-rolls send the identical instruction.diff --git a/scripts/migrations/205-backfill-imported-walk-source-clips.js b/scripts/migrations/205-backfill-imported-walk-source-clips.jsindex 30f06003e3..82cbd1e26b 100644--- a/scripts/migrations/205-backfill-imported-walk-source-clips.js+++ b/scripts/migrations/205-backfill-imported-walk-source-clips.js@@ -62,11 +62,21 @@ const altRunLayoutRel = (rel) => {return match ? `${match[1] === 'grok' ? 'runs' : 'grok'}${match[2]}` : null;};+// An IMPORTED run record, as distinct from one PortOS generated itself: the+// importer copies source-pipeline records verbatim, and those carry no `id`+// (that field is stamped by approveWalkDirection) and repo-anchored paths.+// Only imported runs belong in the "re-import to get the clip" tally — a native+// run still rendering, or one whose render errored before writing a clip, has+// no clip for reasons a re-import would not fix.+const looksImported = (record) => !record.id+ || (typeof record.sourceVideoPath === 'string' && record.sourceVideoPath.includes('art-source/sprites/'));+/*** Backfill one run. Returns 'copied' when the clip was placed, 'missing' when- * it is not reachable inside the record, or null when there is nothing to do- * (the clip is already in place, or the directory holds no run record at all —- * neither should inflate the "needs a re-import" count).+ * an imported run's clip is not reachable inside the record, or null when there+ * is nothing to do (the clip is already in place, the directory holds no run+ * record at all, or the run is a native one that simply has no clip yet) —+ * none of which should inflate the "needs a re-import" count.*/async function backfillRun(recDir, recordId, runDirRel) {const record = await readJson(join(recDir, runDirRel, RUN_RECORD_NAME));@@ -90,7 +100,7 @@ async function backfillRun(recDir, recordId, runDirRel) {await copyFile(join(recDir, rel), join(recDir, destRel));return 'copied';}- return 'missing';+ return looksImported(record) ? 'missing' : null;}async function migrateRecord(recDir, recordId) {diff --git a/server/services/sprites/importer.js b/server/services/sprites/importer.jsindex fe7ef47f33..27cc16299c 100644--- a/server/services/sprites/importer.js+++ b/server/services/sprites/importer.js@@ -105,19 +105,24 @@ async function verifyHashes(destDir, expectations, errors, copiedThisRun) {// a clean re-import.if (SOURCE_CLIP_REF.test(relPath)) {await rm(join(destDir, relPath), { force: true });- return { dropped: true, error: `run ${relPath.split('/')[1]}: source clip failed sha256 verification — not imported` };+ return { dropped: relPath };}return { error: `sha256 mismatch: ${relPath}` };}),);for (const o of outcomes) if (o.error) errors.push(o.error);- // `dropped` feeds back into the caller's file count: a clip removed here was+ // Collapse drops by PATH, not by outcome: one clip pinned by two manifests+ // that disagree on its hash yields two mismatching expectations for the same+ // file, and counting both would decrement the caller's file total twice for a+ // single deleted clip (and report the same run twice).+ const dropped = [...new Set(outcomes.filter((o) => o.dropped).map((o) => o.dropped))];+ for (const relPath of dropped) {+ errors.push(`run ${relPath.split('/')[1]}: source clip failed sha256 verification — not imported`);+ }+ // The caller subtracts `dropped` from its file count: a clip removed here was// counted when it was copied, and an import summary must not claim a file it// deliberately deleted.- return {- verified: outcomes.filter((o) => o.verified).length,- dropped: outcomes.filter((o) => o.dropped).length,- };+ return { verified: outcomes.filter((o) => o.verified).length, dropped: dropped.length };}// Manifest paths reference files repo-relative (art-source/sprites/<id>/…) or@@ -267,23 +272,25 @@ async function importApprovedDirection({ srcCharDir, destDir, characterId, direcif (runRel && (await resolveSourceRel(srcCharDir, `${runRel}/generated/review-preview.json`))) {refs.add(`${runRel}/generated/review-preview.json`);}- // The source clip (#2984). Most packaged manifests name it (so the generic- // collector already has it, hash pin included), but an older imported- // manifest may not — and a direction with no clip can never be re-derived at- // a different frame count. The RUN_DIR_MATCH gate keeps this to real run- // entries (an imagegen redraw entry has no run dir and no clip), and the- // twin check keeps a manifest that named the clip under the OTHER layout- // from copying the same bytes to two destinations.- const clipRel = runRel && `${runRel}/generated/${SOURCE_CLIP_NAME}`;- if (clipRel && RUN_DIR_MATCH.test(runRel) && !refs.has(clipRel) && !refs.has(altRunLayoutPath(clipRel))- && (await resolveSourceRel(srcCharDir, clipRel))) {- refs.add(clipRel);- }// One extra expansion level: packaged manifests / previews the run record// names in turn declare the strip files (and their hash pins).for (const rel of [...refs]) {if (rel.endsWith('.json')) collectManifestRefs(await readCharJson(srcCharDir, rel), characterId, refs, hashExpectations);}+ // The source clip (#2984) — a fallback for a run whose manifests never name+ // it, since a direction with no clip can never be re-derived at a different+ // frame count. Deliberately AFTER the expansion above: the usual carrier of+ // `sourceVideoPath` is the packaged manifest, one level down, so probing+ // earlier would miss a clip already collected and copy the same bytes to two+ // destinations (once per run layout). The RUN_DIR_MATCH gate keeps this to+ // real run entries (an imagegen redraw entry has no run dir and no clip), and+ // the twin check ignores a manifest that named the clip under the OTHER+ // layout — that path is already in `refs` and denotes the same file.+ const clipRel = runRel && `${runRel}/generated/${SOURCE_CLIP_NAME}`;+ if (clipRel && RUN_DIR_MATCH.test(runRel) && !refs.has(clipRel) && !refs.has(altRunLayoutPath(clipRel))+ && (await resolveSourceRel(srcCharDir, clipRel))) {+ refs.add(clipRel);+ }refs.delete(manifestRel);for (const rel of [...refs].sort()) {if (await copyCharFile(srcCharDir, destDir, rel)) {diff --git a/server/services/sprites/importer.test.js b/server/services/sprites/importer.test.jsindex 321a125115..2f04a573b8 100644--- a/server/services/sprites/importer.test.js+++ b/server/services/sprites/importer.test.js@@ -309,6 +309,10 @@ describe('walk-run source clips', () => {kind: 'grok-walk-animation-run', status: 'candidate', characterId: 'drifter', direction: 'east',postprocessManifest: 'art-source/sprites/drifter/runs/run-b/generated/east-manifest.json',}, null, 2);+ const drifterWestRun = JSON.stringify({+ kind: 'grok-walk-animation-run', status: 'candidate', characterId: 'drifter', direction: 'west',+ postprocessManifest: 'art-source/sprites/drifter/runs/run-c/generated/west-manifest.json',+ }, null, 2);let drifter;beforeAll(async () => {@@ -333,6 +337,15 @@ describe('walk-run source clips', () => {runManifest: 'art-source/sprites/drifter/runs/run-b/animation-run.json',runManifestSha256: sha256(drifterEastRun),},+ // run-c's PACKAGED manifest names the clip under the grok/ layout+ // while the entry says runs/ — the probe must recognize that as the+ // same file, not import a second copy under the entry's layout.+ west: {+ status: 'approved',+ runPath: 'art-source/sprites/drifter/runs/run-c',+ runManifest: 'art-source/sprites/drifter/runs/run-c/animation-run.json',+ runManifestSha256: sha256(drifterWestRun),+ },},},'art-source/sprites/drifter/grok/run-a/animation-run.json': drifterSouthRun,@@ -353,6 +366,12 @@ describe('walk-run source clips', () => {sourceVideoSha256: sha256('THE-CLIP-THE-MANIFEST-EXPECTS'),},'art-source/sprites/drifter/runs/run-b/generated/source-video.mp4': 'TAMPERED-CLIP',+ 'art-source/sprites/drifter/runs/run-c/animation-run.json': drifterWestRun,+ 'art-source/sprites/drifter/runs/run-c/generated/west-manifest.json': {+ kind: 'deterministically-packaged-grok-walk-video', direction: 'west',+ sourceVideoPath: 'art-source/sprites/drifter/grok/run-c/generated/source-video.mp4',+ },+ 'art-source/sprites/drifter/grok/run-c/generated/source-video.mp4': CLIP_BYTES,// Never named by the walk set — must contribute nothing, silently.'art-source/sprites/drifter/runs/run-stale/animation-run.json': '{"status":"orphan"}','art-source/sprites/drifter/runs/run-stale/generated/source-video.mp4': 'ORPHAN-CLIP',@@ -368,21 +387,32 @@ describe('walk-run source clips', () => {// the manifest value that names it resolves after import.expect(readFileSync(join(drifterDir(), 'runs/run-a/generated/source-video.mp4'), 'utf8')).toBe(CLIP_BYTES);expect(existsSync(join(drifterDir(), 'runs/run-a/animation-run.json'))).toBe(true);+ expect(existsSync(join(drifterDir(), 'runs/run-a/animation-run.json'))).toBe(true);expect(existsSync(join(drifterDir(), 'runs/run-a/generated/south-strip.png'))).toBe(true);- expect(existsSync(join(drifterDir(), 'grok'))).toBe(false);+ expect(existsSync(join(drifterDir(), 'grok/run-a'))).toBe(false);// ~5× the clip's bytes and re-extractable on demand — still excluded.expect(existsSync(join(drifterDir(), 'runs/run-a/generated/raw/frame-000.png'))).toBe(false);- // south run record + south clip + east run record verify; the east clip doesn't.- expect(drifter.verified).toBe(3);+ // south + west run records, the south clip, and the west clip verify; the+ // east clip doesn't (its bytes disagree with the hash its manifest pins).+ expect(drifter.verified).toBe(4);+ });++ it('imports a manifest-declared clip exactly once when the manifest and the walk-set entry disagree on layout', () => {+ // run-c's manifest declares the clip under grok/ while its entry says+ // runs/. The bytes land at the DECLARED (manifest) path — the value the+ // read layer re-anchors — and the run-dir probe must not add a second copy+ // under the entry's layout.+ expect(readFileSync(join(drifterDir(), 'grok/run-c/generated/source-video.mp4'), 'utf8')).toBe(CLIP_BYTES);+ expect(existsSync(join(drifterDir(), 'runs/run-c/generated/source-video.mp4'))).toBe(false);});it('refuses a clip whose bytes disagree with the manifest\'s sourceVideoSha256, naming the run', () => {expect(drifter.errors).toContain('run run-b: source clip failed sha256 verification — not imported');expect(existsSync(join(drifterDir(), 'runs/run-b/generated/source-video.mp4'))).toBe(false);// …and the summary doesn't claim a file the import deliberately deleted:- // spec + walk set + 2 run records + 2 packaged manifests + strip + south- // clip = 8, with the dropped east clip subtracted back out.- expect(drifter.files).toBe(8);+ // spec + walk set + 3 run records + 3 packaged manifests + strip + the+ // south and west clips = 11, with the dropped east clip subtracted back out.+ expect(drifter.files).toBe(11);// The rest of that run still imported — one bad clip isn't a run-wide abort.expect(existsSync(join(drifterDir(), 'runs/run-b/animation-run.json'))).toBe(true);});