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

refactor([issue-2982]): reuse the Zod contract schema and derive walk tracks positionally

[._.]/ Adam Eivy62526ff32aa4
diff --git a/server/services/sprites/atlas.js b/server/services/sprites/atlas.js
index 963c9fdc6a..0d760a1b4c 100644
--- a/server/services/sprites/atlas.js
+++ b/server/services/sprites/atlas.js
@@ -45,6 +45,7 @@ import {
sampleBorderKey, validateMeasuredKey, recoverAlphaFrame, despillKeyFrame,
alphaBbox, compositeOnto, sha256Buffer,
} from './walkPostprocess.js';
+import { ATLAS_IDLE_COLUMN, ATLAS_SCANNER_COLUMN } from './walkBounds.js';
import { withWalkWriteTail, walkSetRelPath, isImportedWalkSet } from './walk.js';
// Player atlas contract (source pipeline runtime_publish.py): 96px cells,
@@ -57,7 +58,7 @@ import { withWalkWriteTail, walkSetRelPath, isImportedWalkSet } from './walk.js'
// grows/shrinks with the chosen count. ATLAS_COLUMNS is the historical 8-frame
// layout, kept as the default/fallback; atlasColumns(labels) builds the actual
// column list a given compile uses.
-export const atlasColumns = (walkLabels) => ['idle', ...walkLabels, 'scanner'];
+export const atlasColumns = (walkLabels) => [ATLAS_IDLE_COLUMN, ...walkLabels, ATLAS_SCANNER_COLUMN];
export const ATLAS_COLUMNS = atlasColumns(WALK_PHASES);
export const DEFAULT_ATLAS_GEOMETRY = {
cellSize: 96,
@@ -329,7 +330,7 @@ async function compileDirectionRow(recordId, direction, validated, geometry) {
throw compileError(`${direction} idle height ${idle.meta.occupiedBounds.height} misses the walk median ${pyRoundTo(desiredIdleHeight, 2)}`);
}
cells.push({
- column: 'idle',
+ column: ATLAS_IDLE_COLUMN,
...idle,
sourcePath: anchor.path,
sourceSha256: anchor.sha256,
@@ -345,7 +346,7 @@ async function compileDirectionRow(recordId, direction, validated, geometry) {
// Cell frames are read-only after normalization, so the scanner placeholder
// can share the idle cell's buffer outright.
cells.push({
- column: 'scanner',
+ column: ATLAS_SCANNER_COLUMN,
cell: idle.cell,
meta: idle.meta,
sourcePath: anchor.path,
diff --git a/server/services/sprites/atlasLayout.js b/server/services/sprites/atlasLayout.js
index 372d100ae0..4e5200567c 100644
--- a/server/services/sprites/atlasLayout.js
+++ b/server/services/sprites/atlasLayout.js
@@ -27,10 +27,14 @@
* it rides along as `previewFps`, explicitly labeled as authoring metadata the
* consumer must ignore.
*
- * Pure and dependency-free (no fs, no sharp): publish.js builds the payload
- * before taking any write lock, and the shape is unit-testable on its own.
+ * Pure and dependency-free (no image graph, no state): publish.js builds the
+ * payload before taking any write lock, and the shape is unit-testable on its
+ * own.
*/
+import { basename } from 'path';
+import { ATLAS_IDLE_COLUMN, ATLAS_SCANNER_COLUMN } from './walkBounds.js';
+
// Bump only on a breaking shape change. Adding a field (or a new track) is
// additive — consumers read `tracks`/`columns` by name, not by position.
export const ATLAS_LAYOUT_SCHEMA_VERSION = 1;
@@ -41,8 +45,6 @@ export const ATLAS_LAYOUT_KIND = 'portos-sprite-atlas-layout';
export const PREVIEW_FPS_NOTE = 'Authoring metadata only — the speed PortOS previews this walk at. '
+ 'The consuming app determines real playback (e.g. from movement distance); do not use this as a runtime frame rate.';
-const IDLE_COLUMN = 'idle';
-const SCANNER_COLUMN = 'scanner';
const WALK_TRACK = 'walk';
/**
@@ -56,31 +58,42 @@ export function layoutSidecarPath(atlasDestPath) {
return `${stem}.layout.json`;
}
+/**
+ * The walk-phase columns of a compiled grid: everything that is neither the
+ * idle anchor nor the scanner placeholder. Derived from the ACTUAL column
+ * names rather than from `walkPhaseLabels(count)`, so a grid whose columns are
+ * positional (`frame-00…`) groups into one walk span just like the named
+ * 8-frame gait phases — and so a scanner-less grid (#2986) still resolves.
+ */
+const walkColumnsOf = (columns) =>
+ columns.filter((c) => c !== ATLAS_IDLE_COLUMN && c !== ATLAS_SCANNER_COLUMN);
+
/**
* Walk frame count for a compiled atlas. Pointers written before #2970 have no
- * `walkFrameCount`, so fall back to counting the columns that are neither the
- * idle anchor nor the scanner placeholder — which also survives #2986 dropping
- * the scanner column from the grid.
+ * `walkFrameCount`, so fall back to counting the walk columns themselves.
*/
export function resolveWalkFrameCount(geometry) {
if (Number.isInteger(geometry?.walkFrameCount)) return geometry.walkFrameCount;
if (!Array.isArray(geometry?.columns)) return null;
- return geometry.columns.filter((c) => c !== IDLE_COLUMN && c !== SCANNER_COLUMN).length;
+ return walkColumnsOf(geometry.columns).length;
}
/**
* Group the flat column list into named tracks of contiguous column spans:
- * `{ idle: { start: 0, count: 1 }, walk: { start: 1, count: 8 }, … }`. Every
- * walk-phase column collapses into the single `walk` track; any other column
- * becomes a track of its own named for the column. A future four-frame scanner
- * action therefore lands as `scanner: { start, count: 4 }` with no shape change
- * on either side of the boundary.
+ * `{ idle: { start: 0, count: 1 }, walk: { start: 1, count: 8 }, … }`. The walk
+ * track is the `walkFrameCount` columns following the idle anchor — positional,
+ * per the grid contract, so it doesn't care whether those columns carry named
+ * gait phases or positional `frame-NN` labels. Every other column becomes a
+ * track of its own named for the column, so a future four-frame scanner action
+ * lands as `scanner: { start, count: 4 }` with no shape change on either side
+ * of the boundary.
*/
-export function deriveTracks(columns, walkLabels = []) {
- const walkColumns = new Set(walkLabels);
+export function deriveTracks(columns, walkFrameCount) {
+ const walkStart = columns[0] === ATLAS_IDLE_COLUMN ? 1 : 0;
+ const walkEnd = walkStart + (Number.isInteger(walkFrameCount) ? walkFrameCount : 0);
const tracks = {};
columns.forEach((column, index) => {
- const name = walkColumns.has(column) ? WALK_TRACK : column;
+ const name = index >= walkStart && index < walkEnd ? WALK_TRACK : column;
const existing = tracks[name];
if (!existing) {
tracks[name] = { start: index, count: 1 };
@@ -105,7 +118,7 @@ export function deriveTracks(columns, walkLabels = []) {
* path compares hashes to decide whether anything actually changed).
*/
export function buildAtlasLayout({
- characterId, geometry, atlasSha256, version, atlasDestPath, walkLabels,
+ characterId, geometry, atlasSha256, version, atlasDestPath,
}) {
const columns = geometry?.columns;
if (!Array.isArray(columns) || !columns.length) {
@@ -118,7 +131,7 @@ export function buildAtlasLayout({
characterId,
// Basename only: the sidecar sits beside the atlas, so a repo-relative
// path would just be a second copy of where the reader already is.
- atlasFile: atlasDestPath.split('/').pop(),
+ atlasFile: basename(atlasDestPath),
atlasVersion: version ?? null,
sourceAtlasSha256: atlasSha256,
cellSize: geometry.cellSize ?? null,
@@ -126,7 +139,7 @@ export function buildAtlasLayout({
rowOrder: Array.isArray(geometry.directionOrder) ? [...geometry.directionOrder] : null,
columns: [...columns],
columnCount: columns.length,
- tracks: deriveTracks(columns, walkLabels ?? []),
+ tracks: deriveTracks(columns, walkFrameCount),
walkFrameCount,
previewFps: Number.isFinite(geometry.walkFps) ? geometry.walkFps : null,
previewFpsNote: PREVIEW_FPS_NOTE,
@@ -136,48 +149,38 @@ export function buildAtlasLayout({
/**
* Compare compiled atlas geometry against an app's declared runtime contract.
* Returns `null` when they agree (or when no contract was declared — an absent
- * contract publishes unchecked, exactly as before this existed), otherwise
- * `{ code, message }` naming BOTH the actual and expected numbers and the two
- * ways to resolve the disagreement.
+ * contract publishes unchecked, exactly as before this existed), otherwise a
+ * message naming BOTH the actual and expected numbers and the two ways to
+ * resolve the disagreement.
+ *
+ * Callers pass describable geometry (a column list); publish.js asserts that
+ * once, up front, for both this and `buildAtlasLayout`.
*/
export function runtimeContractMismatch(geometry, contract, appLabel = 'the bound app') {
if (!contract) return null;
- const actualColumns = Array.isArray(geometry?.columns) ? geometry.columns.length : null;
+ const actualColumns = geometry.columns.length;
const actualFrames = resolveWalkFrameCount(geometry);
- if (actualColumns === null || actualFrames === null) {
- return {
- code: 'ATLAS_GEOMETRY_UNKNOWN',
- message: `The compiled atlas reports no column layout, so the runtime contract declared by ${appLabel} cannot be verified — recompile the atlas before publishing.`,
- };
- }
-
const { walkFrameCount: expectedFrames, columnCount: expectedColumns, cellSize: expectedCellSize } = contract;
const actualDesc = `Atlas has ${actualColumns} columns (${actualFrames} walk frames)`;
const expectedDesc = Number.isInteger(expectedColumns)
? `${expectedColumns} (${expectedFrames} walk frames)`
: `${expectedFrames} walk frames`;
+ const countMismatch = (resolution) => `${actualDesc} but ${appLabel} expects ${expectedDesc}. ${resolution}`;
if (Number.isInteger(expectedFrames) && expectedFrames !== actualFrames) {
- return {
- code: 'PUBLISH_CONTRACT_MISMATCH',
- message: `${actualDesc} but ${appLabel} expects ${expectedDesc}. `
- + `Update the game's walk-frame constant and its cycle distance, or reprocess this walk set to ${expectedFrames} frames before publishing.`,
- };
+ return countMismatch(
+ `Update the game's walk-frame constant and its cycle distance, or reprocess this walk set to ${expectedFrames} frames before publishing.`,
+ );
}
if (Number.isInteger(expectedColumns) && expectedColumns !== actualColumns) {
- return {
- code: 'PUBLISH_CONTRACT_MISMATCH',
- message: `${actualDesc} but ${appLabel} expects ${expectedDesc}. `
- + `The grid shape changed — update the app's expected column layout, or re-bind its runtime contract to ${actualColumns} columns before publishing.`,
- };
+ return countMismatch(
+ `The grid shape changed — update the app's expected column layout, or re-bind its runtime contract to ${actualColumns} columns before publishing.`,
+ );
}
if (Number.isInteger(expectedCellSize) && expectedCellSize !== geometry.cellSize) {
- return {
- code: 'PUBLISH_CONTRACT_MISMATCH',
- message: `Atlas cells are ${geometry.cellSize}px but ${appLabel} expects ${expectedCellSize}px. `
- + `Recompile this atlas at ${expectedCellSize}px cells, or update the app's cell-size constant before publishing.`,
- };
+ return `Atlas cells are ${geometry.cellSize}px but ${appLabel} expects ${expectedCellSize}px. `
+ + `Recompile this atlas at ${expectedCellSize}px cells, or update the app's cell-size constant before publishing.`;
}
return null;
}
diff --git a/server/services/sprites/atlasLayout.test.js b/server/services/sprites/atlasLayout.test.js
index 4c7d0cfcbd..7b11a29eda 100644
--- a/server/services/sprites/atlasLayout.test.js
+++ b/server/services/sprites/atlasLayout.test.js
@@ -41,18 +41,25 @@ describe('resolveWalkFrameCount', () => {
});
describe('deriveTracks', () => {
- it('collapses walk-phase columns into one span and gives every other column its own', () => {
+ it('collapses the walk columns into one span and gives every other column its own', () => {
const columns = ['idle', ...walkPhaseLabels(6), 'scanner'];
- expect(deriveTracks(columns, walkPhaseLabels(6))).toEqual({
+ expect(deriveTracks(columns, 6)).toEqual({
idle: { start: 0, count: 1 },
walk: { start: 1, count: 6 },
scanner: { start: 7, count: 1 },
});
});
+ it('spans the walk by position, so positional frame-NN labels group too', () => {
+ // A grid whose columns are `frame-00…` rather than the named gait phases
+ // must still describe ONE walk track, not eight singletons.
+ const columns = ['idle', ...walkPhaseLabels(10), 'scanner'];
+ expect(deriveTracks(columns, 10).walk).toEqual({ start: 1, count: 10 });
+ });
+
it('describes a future multi-frame track as a span', () => {
const columns = ['idle', 'w0', 'w1', 'scan-a', 'scan-a', 'scan-a'];
- expect(deriveTracks(columns, ['w0', 'w1'])).toEqual({
+ expect(deriveTracks(columns, 2)).toEqual({
idle: { start: 0, count: 1 },
walk: { start: 1, count: 2 },
'scan-a': { start: 3, count: 3 },
@@ -60,7 +67,7 @@ describe('deriveTracks', () => {
});
it('refuses a grid whose track columns are not contiguous', () => {
- expect(() => deriveTracks(['idle', 'scanner', 'idle'], [])).toThrow(/non-contiguously/);
+ expect(() => deriveTracks(['idle', 'scanner', 'idle'], 0)).toThrow(/non-contiguously/);
});
});
@@ -72,7 +79,6 @@ describe('buildAtlasLayout', () => {
atlasSha256: 'abc123',
version: 4,
atlasDestPath: 'assets/sprites/hero/hero-atlas.png',
- walkLabels: walkPhaseLabels(8),
});
expect(layout).toMatchObject({
schemaVersion: ATLAS_LAYOUT_SCHEMA_VERSION,
@@ -111,31 +117,25 @@ describe('runtimeContractMismatch', () => {
});
it('names both counts and both resolutions on a frame-count mismatch', () => {
- const result = runtimeContractMismatch(geometryFor(12), contract, 'Example App');
- expect(result.code).toBe('PUBLISH_CONTRACT_MISMATCH');
- expect(result.message).toContain('Atlas has 14 columns (12 walk frames)');
- expect(result.message).toContain('Example App expects 10 (8 walk frames)');
- expect(result.message).toMatch(/walk-frame constant/);
- expect(result.message).toMatch(/reprocess this walk set to 8 frames/);
+ const message = runtimeContractMismatch(geometryFor(12), contract, 'Example App');
+ expect(message).toContain('Atlas has 14 columns (12 walk frames)');
+ expect(message).toContain('Example App expects 10 (8 walk frames)');
+ expect(message).toMatch(/walk-frame constant/);
+ expect(message).toMatch(/reprocess this walk set to 8 frames/);
});
it('flags a column-count-only mismatch as a grid-shape change', () => {
// The scanner column removed (#2986) against a contract that still expects it.
const geometry = { columns: ['idle', ...walkPhaseLabels(8)], cellSize: 96, walkFrameCount: 8 };
- const result = runtimeContractMismatch(geometry, contract, 'Example App');
- expect(result.message).toContain('Atlas has 9 columns (8 walk frames)');
- expect(result.message).toMatch(/grid shape changed/);
+ const message = runtimeContractMismatch(geometry, contract, 'Example App');
+ expect(message).toContain('Atlas has 9 columns (8 walk frames)');
+ expect(message).toMatch(/grid shape changed/);
});
it('flags a cell-size mismatch', () => {
- const result = runtimeContractMismatch(geometryFor(8, { cellSize: 64 }), contract, 'Example App');
- expect(result.message).toBe(
+ expect(runtimeContractMismatch(geometryFor(8, { cellSize: 64 }), contract, 'Example App')).toBe(
'Atlas cells are 64px but Example App expects 96px. '
+ "Recompile this atlas at 96px cells, or update the app's cell-size constant before publishing.",
);
});
-
- it('refuses to vouch for geometry it cannot read', () => {
- expect(runtimeContractMismatch({}, contract).code).toBe('ATLAS_GEOMETRY_UNKNOWN');
- });
});
diff --git a/server/services/sprites/publish.js b/server/services/sprites/publish.js
index a86c8bbcc6..420fd68036 100644
--- a/server/services/sprites/publish.js
+++ b/server/services/sprites/publish.js
@@ -45,10 +45,8 @@ import { updateRecord } from './records.js';
import { withWalkWriteTail } from './walk.js';
import { compileAtlasInTail } from './atlas.js';
import { sha256Buffer } from './walkPostprocess.js';
-import { walkPhaseLabels, WALK_MIN_FRAME_COUNT, WALK_MAX_FRAME_COUNT } from './walkBounds.js';
-import {
- buildAtlasLayout, layoutSidecarPath, runtimeContractMismatch, resolveWalkFrameCount,
-} from './atlasLayout.js';
+import { spriteRuntimeContractSchema } from '../../lib/validation.js';
+import { buildAtlasLayout, layoutSidecarPath, runtimeContractMismatch } from './atlasLayout.js';
// Per-repo serialization: keyed by the resolved repoPath (matching
// appDeployer's `deployingApps` key), so two app records pointing at the
@@ -88,42 +86,29 @@ async function requireAppRepo(appId, status) {
return { app, repoRoot: app.repoPath };
}
-const isPositiveInt = (v) => Number.isInteger(v) && v > 0;
-
/**
* Validate the optional runtimeContract — the grid the consuming app was built
- * against (#2982). `walkFrameCount` is required when a contract is present (it
- * is the whole point of declaring one); `cellSize` and `columnCount` are
- * optional extra assertions. The fields are NOT cross-checked against each
- * other here: what counts as a consistent column layout is the compiler's
- * business and changes with the grid (#2986 drops the scanner column), so a
- * stale count surfaces at publish with both numbers named rather than as an
- * unexplained 400 at save.
+ * against (#2982). Shape and bounds come from the SAME Zod schema the route
+ * parses, so a non-route caller (importer, peer sync, a test) can't persist a
+ * contract the route would have rejected.
+ *
+ * `walkFrameCount` is required once a contract is present (it is the whole
+ * point of declaring one); `cellSize` and `columnCount` are optional extra
+ * assertions. The fields are NOT cross-checked against each other: what counts
+ * as a consistent column layout is the compiler's business and changes with the
+ * grid (#2986 drops the scanner column), so a stale count surfaces at publish
+ * with both numbers named rather than as an unexplained 400 at save.
*/
function validateRuntimeContract(runtimeContract) {
if (runtimeContract === undefined || runtimeContract === null) return null;
- if (typeof runtimeContract !== 'object' || Array.isArray(runtimeContract)) {
- throw bindingError('runtimeContract must be an object', 'INVALID_RUNTIME_CONTRACT');
- }
- const { walkFrameCount, cellSize, columnCount } = runtimeContract;
- if (!Number.isInteger(walkFrameCount)
- || walkFrameCount < WALK_MIN_FRAME_COUNT || walkFrameCount > WALK_MAX_FRAME_COUNT) {
- throw bindingError(
- `runtimeContract.walkFrameCount must be an integer between ${WALK_MIN_FRAME_COUNT} and ${WALK_MAX_FRAME_COUNT}`,
- 'INVALID_RUNTIME_CONTRACT',
- );
+ const parsed = spriteRuntimeContractSchema.safeParse(runtimeContract);
+ if (!parsed.success) {
+ const issue = parsed.error.issues?.[0];
+ const field = issue?.path?.length ? `runtimeContract.${issue.path.join('.')}` : 'runtimeContract';
+ throw bindingError(`${field}: ${issue?.message || 'invalid'}`, 'INVALID_RUNTIME_CONTRACT');
}
- if (cellSize !== undefined && cellSize !== null && !isPositiveInt(cellSize)) {
- throw bindingError('runtimeContract.cellSize must be a positive integer', 'INVALID_RUNTIME_CONTRACT');
- }
- if (columnCount !== undefined && columnCount !== null && !isPositiveInt(columnCount)) {
- throw bindingError('runtimeContract.columnCount must be a positive integer', 'INVALID_RUNTIME_CONTRACT');
- }
- return {
- walkFrameCount,
- cellSize: isPositiveInt(cellSize) ? cellSize : null,
- columnCount: isPositiveInt(columnCount) ? columnCount : null,
- };
+ const { walkFrameCount, cellSize, columnCount } = parsed.data;
+ return { walkFrameCount, cellSize: cellSize ?? null, columnCount: columnCount ?? null };
}
/** Validate a publishBinding shape (null clears it). */
@@ -241,34 +226,30 @@ async function publishAtlasImpl(recordId, { acknowledgeOverwrite = false } = {})
: undefined;
const compiled = await compileAtlasInTail(recordId, { geometry: geometryOverride });
- // Export contract (#2982): refuse a publish the bound app cannot consume,
- // BEFORE taking the repo write lock — the game tree stays untouched and the
- // message names both the actual and expected counts. No declared contract ⇒
- // unchanged, unchecked behavior.
+ // Export contract (#2982). Everything below runs BEFORE the repo write lock,
+ // so a publish the bound app cannot consume leaves the game tree untouched.
+ // One geometry assertion serves both the contract compare and the sidecar.
const appLabel = app.name || binding.appId;
- const mismatch = runtimeContractMismatch(compiled.geometry, binding.runtimeContract, appLabel);
- if (mismatch) {
- throw new ServerError(mismatch.message, { status: 409, code: mismatch.code });
- }
-
- // The sidecar describing the grid PortOS actually produced. Built here (pure,
- // lock-free) so a geometry the compiler can't describe fails before any
- // write, and so the same bytes are used by both the write and the up-to-date
- // comparison below. It carries no timestamp: identical geometry ⇒ identical
- // bytes ⇒ a republish is a genuine no-op.
if (!Array.isArray(compiled.geometry?.columns)) {
throw new ServerError(
- 'The compiled atlas reports no column layout, so its layout sidecar cannot be written — recompile the atlas before publishing.',
+ 'The compiled atlas reports no column layout, so neither its export contract nor its layout sidecar can be resolved — recompile the atlas before publishing.',
{ status: 422, code: 'ATLAS_GEOMETRY_UNKNOWN' },
);
}
+ // No declared contract ⇒ unchanged, unchecked behavior.
+ const mismatch = runtimeContractMismatch(compiled.geometry, binding.runtimeContract, appLabel);
+ if (mismatch) throw new ServerError(mismatch, { status: 409, code: 'PUBLISH_CONTRACT_MISMATCH' });
+
+ // The sidecar describing the grid PortOS actually produced. Built here (pure,
+ // lock-free) so the same bytes serve both the write and the up-to-date
+ // comparison below. It carries no timestamp: identical geometry ⇒ identical
+ // bytes ⇒ a republish is a genuine no-op.
const layout = buildAtlasLayout({
characterId: recordId,
geometry: compiled.geometry,
atlasSha256: compiled.atlasSha256,
version: compiled.version,
atlasDestPath: binding.atlasDestPath,
- walkLabels: walkPhaseLabels(resolveWalkFrameCount(compiled.geometry)),
});
const layoutBuffer = Buffer.from(`${JSON.stringify(layout, null, 2)}\n`);
const layoutSha256 = sha256Buffer(layoutBuffer);
@@ -279,7 +260,7 @@ async function publishAtlasImpl(recordId, { acknowledgeOverwrite = false } = {})
// keys its lock by repoPath, so honor it here (the reverse direction —
// deploy checking publishes — isn't needed; publishes are sub-second).
if (isDeploying(repoRoot)) {
- throw new ServerError(`App ${app.name || binding.appId} is deploying — retry when the deploy finishes`, { status: 409, code: 'APP_DEPLOY_IN_PROGRESS' });
+ throw new ServerError(`App ${appLabel} is deploying — retry when the deploy finishes`, { status: 409, code: 'APP_DEPLOY_IN_PROGRESS' });
}
const destAbs = anchorRepoPath(repoRoot, binding.atlasDestPath, 'atlasDestPath');
// The sidecar is repo-anchored and written inside this same per-repo tail
@@ -291,8 +272,8 @@ async function publishAtlasImpl(recordId, { acknowledgeOverwrite = false } = {})
// mutated — an atlas already at the destination but MISSING its sidecar
// still gets one, so the two can never be permanently out of step.
const writeLayoutSidecar = async () => {
- const existingLayoutSha = (await pathExists(layoutAbs)) ? await sha256File(layoutAbs) : null;
- if (existingLayoutSha === layoutSha256) return false;
+ const existing = await readFile(layoutAbs).catch(() => null);
+ if (existing?.equals(layoutBuffer)) return false;
await atomicWrite(layoutAbs, layoutBuffer);
return true;
};
@@ -396,7 +377,7 @@ async function publishAtlasImpl(recordId, { acknowledgeOverwrite = false } = {})
const publication = await recordPublication({
destPreviousSha256: destSha256, codeBinding, layoutDestPath, layoutSha256,
});
- console.log(`🚚 sprite atlas v${compiled.version} published for ${recordId} → ${app.name || binding.appId}:${binding.atlasDestPath}`);
+ console.log(`🚚 sprite atlas v${compiled.version} published for ${recordId} → ${appLabel}:${binding.atlasDestPath}`);
return { published: true, publication, compiled, layoutWritten, layoutDestPath };
});
}
diff --git a/server/services/sprites/walkBounds.js b/server/services/sprites/walkBounds.js
index efd2594bfb..ac00912c07 100644
--- a/server/services/sprites/walkBounds.js
+++ b/server/services/sprites/walkBounds.js
@@ -21,6 +21,13 @@ export const WALK_PHASES = [
// Legacy default / fallback frame count for manifests (or clients) that omit it.
export const WALK_FRAME_COUNT = 8;
+// The two non-walk columns of the runtime atlas grid, named once so the
+// compiler that WRITES them (atlas.js `atlasColumns`) and the layout sidecar
+// that DESCRIBES them (atlasLayout.js) can never disagree on a column's
+// identity — the same reason walkPhaseLabels lives here.
+export const ATLAS_IDLE_COLUMN = 'idle';
+export const ATLAS_SCANNER_COLUMN = 'scanner';
+
// Configurable authoring range (#sprite-walk-variable-frames). The packer
// resamples the detected gait window DOWN to `frameCount` distinct source frames
// (never upsamples), and playback fps is metadata — so a slower/smoother walk