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 (codex r3): pin walk-selection + publication artifacts, surface per-file import errors in UI, preserve cleared chroma key

[._.]/ Adam Eivyae25ec6544a5
diff --git a/client/src/pages/Sprites.jsx b/client/src/pages/Sprites.jsx
index 8021b2360d..931330a8d3 100644
--- a/client/src/pages/Sprites.jsx
+++ b/client/src/pages/Sprites.jsx
@@ -23,13 +23,22 @@ function ImportPanel({ onImported }) {
const [sourceRoot, setSourceRoot] = useState('');
const [includeProps, setIncludeProps] = useState(true);
const [importing, setImporting] = useState(false);
+ const [importErrors, setImportErrors] = useState([]);
const runImport = async () => {
setImporting(true);
+ setImportErrors([]);
try {
- const { totals } = await importSprites({ sourceRoot: sourceRoot.trim(), includeProps });
- toast.success(`Imported ${totals.subjects} subjects (${totals.files} files, ${totals.verified} hash-verified${totals.errors ? `, ${totals.errors} errors` : ''})`);
- setOpen(false);
+ const { results, totals } = await importSprites({ sourceRoot: sourceRoot.trim(), includeProps });
+ if (totals.errors > 0) {
+ // Keep the panel open and show WHICH files failed — a count alone
+ // gives the user nothing to repair.
+ setImportErrors(results.flatMap((r) => r.errors.map((e) => `${r.id}: ${e}`)));
+ toast.error(`Import finished with ${totals.errors} error${totals.errors === 1 ? '' : 's'} — details below`);
+ } else {
+ toast.success(`Imported ${totals.subjects} subjects (${totals.files} files, ${totals.verified} hash-verified)`);
+ setOpen(false);
+ }
onImported();
} catch {
// request() already toasted the failure — keep the panel open for a retry.
@@ -89,6 +98,11 @@ function ImportPanel({ onImported }) {
{importing ? <RefreshCw className="w-4 h-4 animate-spin" /> : <Download className="w-4 h-4" />}
{importing ? 'Importing…' : 'Run Import'}
</button>
+ {importErrors.length > 0 && (
+ <ul className="max-h-40 overflow-y-auto space-y-1 text-xs text-port-error border border-port-border rounded p-2">
+ {importErrors.map((e) => <li key={e}>{e}</li>)}
+ </ul>
+ )}
</div>
);
}
diff --git a/server/services/sprites/importer.js b/server/services/sprites/importer.js
index c2b3601aaf..e418d22954 100644
--- a/server/services/sprites/importer.js
+++ b/server/services/sprites/importer.js
@@ -112,7 +112,10 @@ async function verifyHashes(destDir, expectations, errors, copiedThisRun) {
// manifest must not be able to copy outside data/sprites/.
function relToCharacterDir(manifestPath, characterId) {
if (typeof manifestPath !== 'string' || !manifestPath) return null;
- const marker = `sprites/${characterId}/`;
+ // Anchor to the SOURCE tree — a published game-tree path
+ // (game/assets/sprites/<id>/…) or engine resource URI also contains
+ // "sprites/<id>/" but is not a character-dir asset.
+ const marker = `art-source/sprites/${characterId}/`;
const idx = manifestPath.indexOf(marker);
const rel = idx >= 0 ? manifestPath.slice(idx + marker.length) : manifestPath.replace(/^\/+/, '');
// A repo-anchored path OUTSIDE the character dir (contract docs, pipeline
@@ -272,7 +275,21 @@ async function importCharacter({ sourceRoot, characterId, spec, specPath, select
if (!rel.endsWith('.json')) continue;
const walkSet = await readJson(join(destDir, 'walk', rel));
if (walkSet?.kind !== 'finalized-eight-direction-walk-set' || walkSet?.status !== 'final') continue;
- for (const [direction, dir] of Object.entries(walkSet.directions || {})) {
+ // The set's own top-level references (selectionPath/selectionSha256 …)
+ // are hash-pinned provenance too. Harvest them from the metadata ONLY —
+ // never from `directions`, or non-approved directions' run files would
+ // ride in through the generic collector.
+ const { directions, ...walkSetMeta } = walkSet;
+ const metaRefs = new Set();
+ collectManifestRefs(walkSetMeta, characterId, metaRefs, hashExpectations);
+ for (const metaRel of [...metaRefs].sort()) {
+ if (copiedThisRun.has(metaRel)) continue;
+ if (await copyCharFile(srcCharDir, destDir, metaRel)) {
+ result.files += 1;
+ copiedThisRun.add(metaRel);
+ } else result.errors.push(`walk set: referenced file missing: ${metaRel}`);
+ }
+ for (const [direction, dir] of Object.entries(directions || {})) {
if (dir?.status !== 'approved') {
result.errors.push(`walk set ${direction}: not approved (${dir?.status ?? 'missing'}) — skipped`);
continue;
@@ -291,19 +308,20 @@ async function importCharacter({ sourceRoot, characterId, spec, specPath, select
for (const rel of copied) copiedThisRun.add(`runtime/${rel}`);
}
- // Published-selection provenance: verify the immutable runtime atlas the
- // catalog hash-pins, and bring the published keyed source along.
- if (selection?.characterId === characterId) {
- const imm = selection.selected?.immutableRuntimeArtifact;
- const immRel = relToCharacterDir(imm?.path, characterId);
- if (immRel && imm?.sha256) hashExpectations.push({ relPath: immRel, sha256: imm.sha256 });
- const keyedRel = relToCharacterDir(selection.selected?.keyedSourcePath, characterId);
- if (keyedRel && (await copyCharFile(srcCharDir, destDir, keyedRel))) {
- result.files += 1;
- copiedThisRun.add(keyedRel);
- if (selection.selected?.keyedSourceSha256) {
- hashExpectations.push({ relPath: keyedRel, sha256: selection.selected.keyedSourceSha256 });
- }
+ // Published-selection provenance: copy and hash-verify every character-dir
+ // artifact the catalog's selection declares (immutable atlas archive, keyed
+ // source, publication manifest, …) via the generic collector — pins ride in
+ // through the {path,sha256} / <base>Path+<base>Sha256 conventions, and
+ // repo-anchored references outside the character dir are ignored.
+ if (selection?.characterId === characterId && selection.selected) {
+ const selRefs = new Set();
+ collectManifestRefs(selection.selected, characterId, selRefs, hashExpectations);
+ for (const rel of [...selRefs].sort()) {
+ if (copiedThisRun.has(rel)) continue;
+ if (await copyCharFile(srcCharDir, destDir, rel)) {
+ result.files += 1;
+ copiedThisRun.add(rel);
+ } else result.errors.push(`published selection: referenced asset missing: ${rel}`);
}
}
diff --git a/server/services/sprites/importer.test.js b/server/services/sprites/importer.test.js
index 93ea628273..836300d447 100644
--- a/server/services/sprites/importer.test.js
+++ b/server/services/sprites/importer.test.js
@@ -60,6 +60,18 @@ const southReviewPreview = JSON.stringify({
}, null, 2);
// Imagegen-style run (the v19-east shape): manifest + strips at the version
// root, surrounded by unselected candidates that must stay behind.
+// Non-final manifest in walk/: copies as provenance, contributes no assets —
+// and the finalized set hash-pins it via selectionPath/selectionSha256.
+const heroWalkSelection = JSON.stringify({
+ schemaVersion: 1, kind: 'reviewed-directional-walk-selection', characterId: 'hero', status: 'complete',
+ directions: {
+ south: {
+ status: 'approved',
+ runPath: 'art-source/sprites/hero/grok/run-decoy',
+ runManifest: 'art-source/sprites/hero/grok/run-decoy/animation-run.json',
+ },
+ },
+}, null, 2);
const eastManifest = JSON.stringify({
kind: 'imagegen-redraw-manifest', direction: 'east',
stripPath: 'art-source/sprites/hero/imagegen/v2/east-strip.png',
@@ -95,6 +107,8 @@ beforeAll(() => {
'art-source/sprites/hero/reference/candidates/reject-1.png': 'UNAPPROVED',
'art-source/sprites/hero/walk/hero-walk-set-v1.json': {
schemaVersion: 1, kind: 'finalized-eight-direction-walk-set', characterId: 'hero', status: 'final',
+ selectionPath: 'art-source/sprites/hero/walk/hero-walk-selection-v1.json',
+ selectionSha256: sha256(heroWalkSelection),
directions: {
south: {
status: 'approved',
@@ -123,18 +137,7 @@ beforeAll(() => {
},
},
},
- // Non-final manifest kinds in walk/: the files copy as provenance, but
- // their directions must contribute NO assets.
- 'art-source/sprites/hero/walk/hero-walk-selection-v1.json': {
- schemaVersion: 1, kind: 'reviewed-directional-walk-selection', characterId: 'hero', status: 'complete',
- directions: {
- south: {
- status: 'approved',
- runPath: 'art-source/sprites/hero/grok/run-decoy',
- runManifest: 'art-source/sprites/hero/grok/run-decoy/animation-run.json',
- },
- },
- },
+ 'art-source/sprites/hero/walk/hero-walk-selection-v1.json': heroWalkSelection,
'art-source/sprites/hero/grok/run-1/animation-run.json': southRunRecord,
'art-source/sprites/hero/grok/run-1/generated/south-manifest.json': southPackagedManifest,
'art-source/sprites/hero/grok/run-1/generated/south-strip.png': 'FAKE-STRIP',
@@ -154,6 +157,10 @@ beforeAll(() => {
selectionId: 's1', characterId: 'hero', status: 'selected',
selected: {
keyedSourcePath: 'art-source/sprites/hero/hero-atlas-keyed.png',
+ // Game-tree publish target: also contains "sprites/hero/" but is NOT
+ // a character-dir asset — must be ignored, not reported missing.
+ runtimePath: 'game/assets/sprites/hero/hero-animation-atlas.png',
+ runtimeSha256: sha256('PUBLISHED-COPY'),
immutableRuntimeArtifact: {
path: 'art-source/sprites/hero/runtime/v1/hero-animation-atlas-v1.png',
sha256: sha256('FAKE-ATLAS'),
@@ -178,9 +185,9 @@ describe('importFromSource', () => {
const hero = results.find((r) => r.id === 'hero');
expect(hero.kind).toBe('character');
- // south anchor + south run record + pinned south strip + east manifest
- // + hash-pinned runtime atlas
- expect(hero.verified).toBe(5);
+ // south anchor + pinned walk selection + south run record + pinned south
+ // strip + east manifest + hash-pinned runtime atlas
+ expect(hero.verified).toBe(6);
expect(hero.errors).toEqual([
'walk set east: referenced asset missing: imagegen/v2/gone.png',
'walk set west: not approved (pending) — skipped',
diff --git a/server/services/sprites/recordsLogic.js b/server/services/sprites/recordsLogic.js
index 2b8bb263a5..75347f8d41 100644
--- a/server/services/sprites/recordsLogic.js
+++ b/server/services/sprites/recordsLogic.js
@@ -87,7 +87,9 @@ export function mergeImportedRecord(existing, imported, now) {
name: imported.name,
status: imported.status,
spec: imported.spec,
- chromaKey: existing.chromaKey || imported.chromaKey,
+ // Preserve the existing value verbatim — including an intentional null
+ // clear; `||` would resurrect the legacy import default over a clear.
+ chromaKey: existing.chromaKey !== undefined ? existing.chromaKey : imported.chromaKey,
importedFrom: imported.importedFrom,
updatedAt: now,
};
diff --git a/server/services/sprites/recordsLogic.test.js b/server/services/sprites/recordsLogic.test.js
index 9df71a4155..b358c6938f 100644
--- a/server/services/sprites/recordsLogic.test.js
+++ b/server/services/sprites/recordsLogic.test.js
@@ -86,4 +86,10 @@ describe('mergeImportedRecord', () => {
expect(next.chromaKey).toBe('#FF00FF');
expect(next.notes).toBeNull();
});
+
+ it('an explicitly cleared chromaKey stays cleared on re-import', () => {
+ const cleared = { ...existing, chromaKey: null };
+ const next = mergeImportedRecord(cleared, imported, '2026-07-23T00:00:00.000Z');
+ expect(next.chromaKey).toBeNull(); // || would resurrect the import default
+ });
});