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 r2): version-slot poisoning, wider legacy marker, keyed publish panel

[._.]/ Adam Eivy1c543672178f
diff --git a/client/src/components/sprites/PublishWorkflow.jsx b/client/src/components/sprites/PublishWorkflow.jsx
index ec973b5820..7c44d73b27 100644
--- a/client/src/components/sprites/PublishWorkflow.jsx
+++ b/client/src/components/sprites/PublishWorkflow.jsx
@@ -99,7 +99,7 @@ export default function PublishWorkflow({ record, walk, atlas, onChanged }) {
// Phase-1 imported walk sets carry source-pipeline paths and no packaged
// frames — the server refuses to recompile them (LEGACY_IMPORTED_WALK_SET).
// Show why instead of offering a button that always fails.
- if (walk.walkSet.selectionPath?.startsWith('art-source/')) {
+ if (walk.walkSet.selectionPath?.includes('art-source/sprites/')) {
return (
<div className="bg-port-card border border-port-border rounded-lg p-4 space-y-1">
<h3 className="text-sm font-medium text-gray-200 flex items-center gap-2">
diff --git a/client/src/pages/Sprites.jsx b/client/src/pages/Sprites.jsx
index 07f3da1b5a..5c1acb406a 100644
--- a/client/src/pages/Sprites.jsx
+++ b/client/src/pages/Sprites.jsx
@@ -387,7 +387,10 @@ export default function Sprites() {
walk={detail.walk}
onChanged={onWorkflowChanged}
/>
+ {/* Keyed by record so form state and an armed publish/overwrite
+ confirmation never survive switching characters. */}
<PublishWorkflow
+ key={detail.record.id}
record={detail.record}
walk={detail.walk}
atlas={detail.atlas}
diff --git a/server/services/sprites/atlas.js b/server/services/sprites/atlas.js
index a6e48b0859..7c6c3e28a4 100644
--- a/server/services/sprites/atlas.js
+++ b/server/services/sprites/atlas.js
@@ -188,9 +188,11 @@ export async function validateForCompile(recordId) {
// frames/ to minimize copies). Recompiling them here is structurally
// impossible; say so plainly instead of a misleading tamper error. Their
// already-published runtime atlases were imported and remain browsable.
- const legacyPrefix = 'art-source/';
+ // Match the importer's own legacy-path recognition (relToCharacterDir):
+ // the marker can sit at any index (absolute/repo-prefixed variants), not
+ // just the string start.
if (
- typeof walkSet.selectionPath === 'string' && walkSet.selectionPath.startsWith(legacyPrefix)
+ typeof walkSet.selectionPath === 'string' && walkSet.selectionPath.includes('art-source/sprites/')
) {
throw new ServerError(
'This walk set was imported from the source pipeline — its packaged frames were not imported, so PortOS cannot recompile it. Imported runtime atlases remain available in the asset library; to compile here, run the walk workflow on a new character.',
@@ -422,7 +424,17 @@ export async function compileAtlasInTail(recordId, { geometry: geometryOverride
const stem = atlasStem(recordId);
const runtimeAbs = join(dir, RUNTIME_DIR);
- const version = await nextAtlasVersion(runtimeAbs, stem);
+ let version = await nextAtlasVersion(runtimeAbs, stem);
+ // Never adopt a PNG-missing slot whose surviving manifest vouches for
+ // DIFFERENT bytes — writing there would land a PNG its own manifest
+ // contradicts and then 409 on the manifest write, poisoning the version
+ // dir. Advance until the slot is empty or its manifest matches these bytes
+ // (the re-materialize case).
+ for (;;) {
+ const survivor = await readJSONFile(join(runtimeAbs, `v${version}`, `${stem}-v${version}-manifest.json`), null);
+ if (!survivor || survivor.atlasSha256 === atlasSha256) break;
+ version += 1;
+ }
const versionRel = `${RUNTIME_DIR}/v${version}`;
const atlasRel = `${versionRel}/${stem}-v${version}.png`;
const manifestRel = `${versionRel}/${stem}-v${version}-manifest.json`;
diff --git a/server/services/sprites/atlas.test.js b/server/services/sprites/atlas.test.js
index b89b752184..fea6bc711f 100644
--- a/server/services/sprites/atlas.test.js
+++ b/server/services/sprites/atlas.test.js
@@ -268,6 +268,23 @@ describe('compileAtlas', () => {
expect(await readFile(join(TEST_ROOT, 'sprites', id, first.atlasPath))).toBeTruthy();
});
+ it('skips a PNG-missing slot whose surviving manifest vouches for different bytes', async () => {
+ const id = await finalizedCharacter();
+ const first = await compileAtlas(id);
+ // Delete the v1 PNG, then change the inputs (geometry) so the recompile
+ // produces DIFFERENT bytes — it must land in v2, not poison v1.
+ rmSync(join(TEST_ROOT, 'sprites', id, first.atlasPath));
+ const next = await compileAtlas(id, {
+ geometry: { cellSize: 64, pivot: [32, 56], targetMaxHeight: 44, targetMaxWidth: 52 },
+ });
+ expect(next.version).toBe(first.version + 1);
+ // v1's surviving manifest is untouched and still describes the original.
+ const v1Manifest = JSON.parse(
+ await readFile(join(TEST_ROOT, 'sprites', id, first.manifestPath), 'utf8'),
+ );
+ expect(v1Manifest.atlasSha256).toBe(first.atlasSha256);
+ });
+
it('rejects geometry whose content bounds cannot fit the cell', async () => {
const id = await finalizedCharacter();
await expect(compileAtlas(id, { geometry: { cellSize: 64, targetMaxWidth: 64 } }))
diff --git a/server/services/sprites/publish.test.js b/server/services/sprites/publish.test.js
index 7c57d51a7c..03f083a2fa 100644
--- a/server/services/sprites/publish.test.js
+++ b/server/services/sprites/publish.test.js
@@ -289,6 +289,24 @@ describe('publishAtlas', () => {
expect(second.published).toBe(true);
});
+ it('reuses the current pointer geometry when compiling for publish', async () => {
+ const { id } = await characterWithAtlas();
+ await setPublishBinding(id, BINDING);
+
+ // No pointer yet → default geometry (undefined override).
+ await publishAtlas(id);
+ expect(compileAtlasInTail).toHaveBeenLastCalledWith(id, { geometry: undefined });
+
+ // A pointer with custom geometry → publish compiles with exactly it.
+ const geometry = { cellSize: 64, pivot: [32, 56], targetMaxHeight: 44, targetMaxWidth: 52 };
+ await writeFile(
+ join(TEST_ROOT, 'sprites', id, 'runtime/current.json'),
+ JSON.stringify({ version: 1, atlasPath: `runtime/v1/${id}-animation-atlas-v1.png`, geometry }),
+ );
+ await publishAtlas(id);
+ expect(compileAtlasInTail).toHaveBeenLastCalledWith(id, { geometry });
+ });
+
it('refuses to ship a tampered or missing compiled atlas file', async () => {
const { id, atlasRel } = await characterWithAtlas();
await setPublishBinding(id, BINDING);