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
refactor([issue-2986]): drop the dead scanner column from the compiled walk atlas
[._.]/ Adam Eivyb0a1947c9095
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 5fb26ce59e..e95df2a776 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -25,7 +25,8 @@## Sprite Manager-- **[issue-2982] Publishing an atlas your game can't read now stops instead of silently breaking it** — the atlas PNG used to be the *entire* export: nothing described how many walk frames were in it, so a game with an 8-frame walk baked in as a constant would happily accept a 12-frame publish and then draw the wrong frames from the wrong columns forever, with no crash and no log. Two things fix that. A publish target can now declare the grid it was built against (`runtimeContract`: walk frame count, cell size, column count), and a publish whose compiled atlas disagrees is refused with a message naming both numbers — "Atlas has 14 columns (12 walk frames) but Example App expects 10 (8 walk frames)" — plus the two ways to resolve it. And every publish now writes a small `….layout.json` file beside the atlas describing the grid PortOS actually produced: cell size, ordered column names, per-track column spans (so a future multi-frame scanner or ambient action is additive, not a rewrite), row order, and the atlas checksum — so the game can resolve columns by name and verify what it loaded instead of trusting a constant. Targets with no declared contract publish exactly as before. Also documented: playback **fps in PortOS is preview-only**. It ships in the sidecar labeled as authoring metadata, because the consuming game drives its walk from movement distance and has no frame-rate concept at all — a 6 fps preview and a 24 fps preview export byte-identical atlases. See `docs/features/sprite-export-contract.md`.+- **[issue-2986] Compiled atlases no longer waste a column on a duplicate of the idle pose** — every atlas used to end with an extra "scanner" column that was a pixel-for-pixel copy of the idle cell, left over from an early render and never drawn by anything. It's gone: an 8-frame walk now compiles to 9 columns instead of 10, and a 12-frame walk to 13 instead of 14 — a smaller sprite sheet with nothing lost. The `layout.json` file published beside the atlas drops the matching entry, so it keeps describing exactly what's in the image. Atlases you already published are untouched until you republish, and imported or previously compiled sheets that still carry the column keep loading and displaying normally. Recompiling a character produces a new atlas version, as any change does. (A real scanner *action*, when there is one, will be its own animation track with its own frame count rather than a column bolted onto the walk cycle.)+- **[issue-2982] Publishing an atlas your game can't read now stops instead of silently breaking it** — the atlas PNG used to be the *entire* export: nothing described how many walk frames were in it, so a game with an 8-frame walk baked in as a constant would happily accept a 12-frame publish and then draw the wrong frames from the wrong columns forever, with no crash and no log. Two things fix that. A publish target can now declare the grid it was built against (`runtimeContract`: walk frame count, cell size, column count), and a publish whose compiled atlas disagrees is refused with a message naming both numbers — "Atlas has 13 columns (12 walk frames) but Example App expects 9 (8 walk frames)" — plus the two ways to resolve it. And every publish now writes a small `….layout.json` file beside the atlas describing the grid PortOS actually produced: cell size, ordered column names, per-track column spans (so a future multi-frame scanner or ambient action is additive, not a rewrite), row order, and the atlas checksum — so the game can resolve columns by name and verify what it loaded instead of trusting a constant. Targets with no declared contract publish exactly as before. Also documented: playback **fps in PortOS is preview-only**. It ships in the sidecar labeled as authoring metadata, because the consuming game drives its walk from movement distance and has no frame-rate concept at all — a 6 fps preview and a 24 fps preview export byte-identical atlases. See `docs/features/sprite-export-contract.md`.- **[issue-2984] Imported walk cycles now bring their source clip along** — 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 — the frames needed to run a cycle at a *higher* count only exist in the clip, and the clip stayed in the source tree. 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-2979] Characters now start from a turnaround sheet, so accessories stop jumping sides** — directional anchors used to be drawn from a single front-facing reference, which meant the AI had to invent every side it hadn't seen: a hip bag on the character's front would migrate to their back in the north view, and pockets or straps would swap sides between the east and west profiles. The reference workflow is now three ordered steps. **1 · Turnaround sheet**: describe the character (or attach a design image) and generate one image showing them from four angles — front, right, back, left — with every accessory pinned to the same side of the body in each panel. Lock it, and it becomes the character's identity root. **2 · Main reference**: redrawn from the sheet's front panel with one click, no separate design input. **3 · Directional anchors**: each pose is now redrawn from the sheet's panel for *that* side, so the model can see the hip bag instead of guessing at it. Picking the chroma-key background also moved to the sheet lock, where it can see the character from every angle — so a green backpack that's only visible from behind is accounted for up front instead of surprising you later. Forking a character now seeds the new one's sheet from the original's, inheriting every side.- **[issue-2979] Existing characters can backfill a turnaround sheet from their locked main** — a character you built before this shows the same three steps, with step 1 offering **Generate from locked main**: it expands the front view you already froze into the full four-view sheet, keeps your existing chroma key exactly as-is, and unblocks the directional anchors you haven't locked yet — which are then drawn from the sheet like a new character's. Already-locked references and anchors are untouched (they're immutable by design), so the benefit applies to whatever poses you still have left to derive.diff --git a/docs/features/sprite-export-contract.md b/docs/features/sprite-export-contract.mdindex 21b0cf8471..25e0618620 100644--- a/docs/features/sprite-export-contract.md+++ b/docs/features/sprite-export-contract.md@@ -6,18 +6,20 @@ Publishing is the only sprite path that writes outside `data/`. Everything else## The atlas grid-The compiler (`server/services/sprites/atlas.js`) produces one PNG: a fixed-cell grid of `idle + N walk phases + scanner` columns × 8 direction rows.+The compiler (`server/services/sprites/atlas.js`) produces one PNG: a fixed-cell grid of `idle + N walk phases` columns × 8 direction rows.| Property | Value ||---|---|| Cell size | 96 × 96 px (overridable per compile; the published geometry is whatever was compiled) || Pivot | `(48, 88)` — silhouette centered on x, feet on the y ground line || Rows | 8, in `directionOrder`: `south`, `south-east`, `east`, `north-east`, `north`, `north-west`, `west`, `south-west` |-| Columns | `idle` at 0, the N walk phases from 1, `scanner` last |+| Columns | `idle` at 0, the N walk phases from 1 || N (walk frame count) | authorable, 6–16 (`walkBounds.js`); historically always 8 |`N` is read from the approved run manifests — every direction in one atlas must share it — so the atlas width tracks the authored count. **That makes the column layout a moving target for anything that hardcodes it.**+> **Atlases compiled before #2986 carry one extra trailing `scanner` column** — a verbatim copy of the idle cell, from an early render, that no consumer ever sampled. The compiler no longer emits it (an action animation is its own named track, not a column appended to the walk cycle), so an 8-frame grid is 9 columns wide rather than 10. Reading side is unchanged: an imported or previously published atlas that still has the column keeps loading, and its sidecar still describes the `scanner` span it really has. Recompiling a set drops the column and produces a new atlas version; existing published atlases are untouched until republished.+## What crosses the publish boundaryExactly two files land in the app repo:@@ -42,12 +44,11 @@ Nothing else crosses. The compile manifest, the run provenance, the trims, and t"cellSize": 96,"rows": 8,"rowOrder": ["south", "south-east", "east", "north-east", "north", "north-west", "west", "south-west"],- "columns": ["idle", "left-contact", "…", "right-up", "scanner"],- "columnCount": 10,+ "columns": ["idle", "left-contact", "…", "right-up"],+ "columnCount": 9,"tracks": {"idle": { "start": 0, "count": 1 },- "walk": { "start": 1, "count": 8 },- "scanner": { "start": 9, "count": 1 }+ "walk": { "start": 1, "count": 8 }},"walkFrameCount": 8,"previewFps": 12,@@ -57,7 +58,7 @@ Nothing else crosses. The compile manifest, the run provenance, the trims, and tConsumer guidance:-- **Resolve columns by name, not by constant.** `tracks` gives each animation track a column span, so a walk of any length — and any future track (a four-frame scanner action, a three-frame ambient loop) — is additive rather than a breaking re-read. `columns` is the flat list for anything that wants raw names.+- **Resolve columns by name, not by constant.** `tracks` gives each animation track a column span, so a walk of any length — and any future track (a four-frame scanner action, a three-frame ambient loop) — is additive rather than a breaking re-read. A track that isn't in the grid simply isn't in `tracks`; don't assume one is present. `columns` is the flat list for anything that wants raw names.- **Verify before you trust.** `sourceAtlasSha256` identifies the atlas the layout describes. The sidecar is written *before* the PNG on each publish, so a partially-completed publish is detectable (hash mismatch) rather than silent.- **The sidecar carries no timestamp** — identical geometry produces byte-identical content, so an unchanged republish rewrites nothing.- The sidecar shares the PNG's per-repo write serialization and its occupied-destination guard: an atlas whose sidecar was deleted gets it back on the next publish, and a file at that path PortOS didn't write (no `kind: portos-sprite-atlas-layout`, or not valid JSON at all) is never replaced without an explicit overwrite acknowledgment. It has no *divergence* guard — unlike the PNG, a PortOS-written sidecar someone hand-edited is simply regenerated, since it is derived data.@@ -72,7 +73,7 @@ If your app *is* time-driven, pick its own frame rate. Do not read `previewFps`## Frame count is a coordinated cross-repo change-Column layout is the one thing an app genuinely has to agree with PortOS about. Changing `N` shifts every column after `idle` — a game that reads walk columns 1–8 out of a 14-column atlas renders the wrong phases *and* draws a walk frame where the scanner belongs. No crash, no log.+Column layout is the one thing an app genuinely has to agree with PortOS about. Changing `N` shifts every column after `idle` — a game that reads walk columns 1–8 out of a 13-column atlas renders the wrong phases and samples past the end of the walk it thinks it has. No crash, no log.Two mechanisms guard that:diff --git a/server/services/sprites/atlas.js b/server/services/sprites/atlas.jsindex 0d760a1b4c..42904d8dc5 100644--- a/server/services/sprites/atlas.js+++ b/server/services/sprites/atlas.js@@ -2,7 +2,7 @@* Sprites — runtime atlas compiler (issue #2898, phase 4).** Compiles the immutable runtime sprite-sheet from a finalized eight-direction- * walk set: an (idle + N walk phases + scanner)-column × 8-row grid (× S/SE/E/+ * walk set: an (idle + N walk phases)-column × 8-row grid (× S/SE/E/* NE/N/NW/W/SW) of fixed-size cells, each frame scaled once per direction and* translated so its silhouette centers on the pivot x and its feet land exactly* on the pivot ground line. N (the walk frame count) is read from the approved@@ -45,20 +45,27 @@ import {sampleBorderKey, validateMeasuredKey, recoverAlphaFrame, despillKeyFrame,alphaBbox, compositeOnto, sha256Buffer,} from './walkPostprocess.js';-import { ATLAS_IDLE_COLUMN, ATLAS_SCANNER_COLUMN } from './walkBounds.js';+import { ATLAS_IDLE_COLUMN } from './walkBounds.js';import { withWalkWriteTail, walkSetRelPath, isImportedWalkSet } from './walk.js';// Player atlas contract (source pipeline runtime_publish.py): 96px cells,// pivot (48,88) — silhouette centered on x=48, feet on the y=88 ground line —// content bounded to 86×74 so nothing touches a cell edge.//-// The runtime grid is `idle` + the N walk-phase columns + `scanner`. N is the-// walk set's frame count (variable-frame walks: #sprite-walk-variable-frames);-// it is read from the approved run manifests, not hardcoded, so the atlas width+// The runtime grid is `idle` + the N walk-phase columns. N is the walk set's+// frame count (variable-frame walks: #sprite-walk-variable-frames); it is read+// from the approved run manifests, not hardcoded, so the atlas width// 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) => [ATLAS_IDLE_COLUMN, ...walkLabels, ATLAS_SCANNER_COLUMN];+//+// A trailing `scanner` column used to follow the walk phases — a verbatim copy+// of the idle cell that no consumer ever sampled (#2986). It is no longer+// compiled: an action animation is its own named track (per-track spans in the+// layout sidecar, atlasLayout.js), not a column bolted onto the walk cycle.+// Imported/legacy atlases and manifests that still carry the column keep+// loading and displaying unchanged — this is a write-side change only.+export const atlasColumns = (walkLabels) => [ATLAS_IDLE_COLUMN, ...walkLabels];export const ATLAS_COLUMNS = atlasColumns(WALK_PHASES);export const DEFAULT_ATLAS_GEOMETRY = {cellSize: 96,@@ -343,17 +350,6 @@ async function compileDirectionRow(recordId, direction, validated, geometry) {cells.push({ column: frame.phase, ...normalized, sourcePath: frame.path, sourceSha256: frame.sha256 });}- // Cell frames are read-only after normalization, so the scanner placeholder- // can share the idle cell's buffer outright.- cells.push({- column: ATLAS_SCANNER_COLUMN,- cell: idle.cell,- meta: idle.meta,- sourcePath: anchor.path,- sourceSha256: anchor.sha256,- policy: 'locked-idle-placeholder',- });-return {direction,runId,@@ -361,7 +357,6 @@ async function compileDirectionRow(recordId, direction, validated, geometry) {walkDirectionScale: pyRoundTo(directionScale, 8),idleScale: pyRoundTo(idleScale, 8),idlePolicy: 'locked-directional-reference-anchor',- scannerPolicy: 'locked-idle-placeholder',cells,};}@@ -423,11 +418,20 @@ export async function compileAtlasInTail(recordId, { geometry: geometryOverrideconst validated = await validateForCompile(recordId);const dir = spriteDir(recordId);+ // Columns/width follow the set's actual frame count, not the historical 8.+ const columns = atlasColumns(validated.walkLabels);+// Pre-pixel idempotency: the compile is deterministic, so an unchanged// walk set + identical geometry means identical bytes by construction —// skip the whole pixel pipeline. The evidence chain was still revalidated// above; the post-encode sha comparison below stays as the fallback for a// pointer whose geometry fields predate a shape change.+ // The COLUMN LIST is part of that geometry comparison, not just the cell+ // metrics: a grid-shape change (#2986 dropping the trailing scanner column)+ // leaves every cell metric identical, so without it a pre-#2986 pointer would+ // be returned as up-to-date and the stale wider atlas would never recompile.+ // A pointer predating the columns field at all (undefined) also falls through,+ // which is correct — the post-encode sha compare then decides.// Both idempotent early-returns require the pointed-at atlas file to still// exist — otherwise a deleted runtime/vN PNG would loop forever ("recompile"// → pointer returned untouched → still missing); falling through re-writes@@ -442,6 +446,7 @@ export async function compileAtlasInTail(recordId, { geometry: geometryOverride&& JSON.stringify(current.geometry?.pivot) === JSON.stringify(geometry.pivot)&& current.geometry?.targetMaxHeight === geometry.targetMaxHeight&& current.geometry?.targetMaxWidth === geometry.targetMaxWidth+ && JSON.stringify(current.geometry?.columns) === JSON.stringify(columns)) {return { ...current, created: false };}@@ -452,8 +457,6 @@ export async function compileAtlasInTail(recordId, { geometry: geometryOverride}const { cellSize } = geometry;- // Columns/width follow the set's actual frame count, not the historical 8.- const columns = atlasColumns(validated.walkLabels);const atlasWidth = cellSize * columns.length;const atlasHeight = cellSize * SPRITE_DIRECTIONS.length;const atlas = { data: Buffer.alloc(atlasWidth * atlasHeight * 4), width: atlasWidth, height: atlasHeight };@@ -548,7 +551,6 @@ export async function compileAtlasInTail(recordId, { geometry: geometryOverridewalkDirectionScale: row.walkDirectionScale,idleScale: row.idleScale,idlePolicy: row.idlePolicy,- scannerPolicy: row.scannerPolicy,cells: row.cells.map((cell, c) => ({column: cell.column,columnIndex: c,diff --git a/server/services/sprites/atlas.test.js b/server/services/sprites/atlas.test.jsindex 07d9e0685a..3b911178da 100644--- a/server/services/sprites/atlas.test.js+++ b/server/services/sprites/atlas.test.js@@ -1,7 +1,7 @@/*** Runtime atlas compiler (#2898): evidence-chain validation (walk set,* selection, run manifests, frame + anchor sha256s), the geometry contract- * (10×8 grid, per-direction single scale, pivot ground line), immutable+ * (9×8 grid, per-direction single scale, pivot ground line), immutable* versioning, and compile idempotency. Fixtures lock a real reference set* (real normalize + chroma-key selection) and hand-write the walk artifacts* with a correct hash chain.@@ -148,7 +148,7 @@ beforeEach(() => {afterAll(() => rmSync(TEST_ROOT, { recursive: true, force: true }));describe('compileAtlas', () => {- it('compiles the 10×8 player atlas with full provenance and a current pointer', async () => {+ it('compiles the 9×8 player atlas with full provenance and a current pointer', async () => {const id = await finalizedCharacter();const result = await compileAtlas(id);@@ -164,15 +164,16 @@ describe('compileAtlas', () => {const manifest = JSON.parse(await readFile(join(TEST_ROOT, 'sprites', id, result.manifestPath), 'utf8'));expect(manifest.kind).toBe('reviewed-walk-set-runtime-atlas');- expect(manifest.geometry.columns).toEqual(['idle', ...WALK_PHASES, 'scanner']);+ // idle + 8 walk phases — no trailing scanner placeholder (#2986).+ expect(manifest.geometry.columns).toEqual(['idle', ...WALK_PHASES]);expect(manifest.geometry.directionOrder).toEqual(SPRITE_DIRECTIONS);expect(manifest.directions).toHaveLength(8);for (const row of manifest.directions) {- expect(row.cells).toHaveLength(10);+ expect(row.cells).toHaveLength(9);expect(row.cells[0].policy).toBe('locked-directional-reference-anchor');- expect(row.cells[9].policy).toBe('locked-idle-placeholder');- // Scanner mirrors the idle cell's placement exactly.- expect(row.cells[9].occupiedBounds).toEqual(row.cells[0].occupiedBounds);+ expect(row.cells.map((c) => c.column)).not.toContain('scanner');+ expect(row.cells.some((c) => c.policy === 'locked-idle-placeholder')).toBe(false);+ expect(row).not.toHaveProperty('scannerPolicy');for (const cell of row.cells) {// Feet on the pivot ground line: bounds bottom (top + height - 1) = pivot y.expect(cell.occupiedBounds.top + cell.occupiedBounds.height - 1).toBe(DEFAULT_ATLAS_GEOMETRY.pivot[1]);@@ -196,16 +197,42 @@ describe('compileAtlas', () => {const result = await compileAtlas(id);const meta = await sharp(join(TEST_ROOT, 'sprites', id, result.atlasPath)).metadata();- // idle + 12 walk phases + scanner = 14 columns.- expect(meta.width).toBe(DEFAULT_ATLAS_GEOMETRY.cellSize * 14);+ // idle + 12 walk phases = 13 columns.+ expect(meta.width).toBe(DEFAULT_ATLAS_GEOMETRY.cellSize * 13);expect(meta.height).toBe(DEFAULT_ATLAS_GEOMETRY.cellSize * SPRITE_DIRECTIONS.length);const manifest = JSON.parse(await readFile(join(TEST_ROOT, 'sprites', id, result.manifestPath), 'utf8'));- expect(manifest.geometry.columns).toEqual(['idle', ...walkPhaseLabels(12), 'scanner']);+ expect(manifest.geometry.columns).toEqual(['idle', ...walkPhaseLabels(12)]);expect(manifest.geometry.walkFrameCount).toBe(12);expect(manifest.geometry.walkFps).toBe(8);- expect(manifest.geometry.widthPx).toBe(DEFAULT_ATLAS_GEOMETRY.cellSize * 14);- for (const row of manifest.directions) expect(row.cells).toHaveLength(14);+ expect(manifest.geometry.widthPx).toBe(DEFAULT_ATLAS_GEOMETRY.cellSize * 13);+ for (const row of manifest.directions) expect(row.cells).toHaveLength(13);+ });++ it('recompiles a set whose pointer still describes the pre-#2986 scanner grid', async () => {+ const id = await finalizedCharacter();+ const first = await compileAtlas(id);++ // Simulate a pointer written by the old compiler: same walk set, same cell+ // metrics, but the wider `idle + N + scanner` column list (and therefore+ // different atlas bytes). Every field the cheap pre-pixel idempotency check+ // looks at is identical EXCEPT the column list — so without that comparison+ // the stale wider grid would be reported as up-to-date and never recompile.+ const pointerAbs = join(TEST_ROOT, 'sprites', id, 'runtime/current.json');+ const pointer = JSON.parse(await readFile(pointerAbs, 'utf8'));+ pointer.atlasSha256 = 'f'.repeat(64);+ pointer.geometry = {+ ...pointer.geometry,+ columns: [...pointer.geometry.columns, 'scanner'],+ widthPx: pointer.geometry.widthPx + pointer.geometry.cellSize,+ };+ await writeFile(pointerAbs, JSON.stringify(pointer));++ const again = await compileAtlas(id);+ expect(again.created).toBe(true);+ expect(again.version).toBe(first.version + 1);+ expect(again.geometry.columns).toEqual(['idle', ...WALK_PHASES]);+ expect(again.geometry.widthPx).toBe(DEFAULT_ATLAS_GEOMETRY.cellSize * 9);});it('refuses to compile a set whose directions disagree on frame count', async () => {@@ -279,7 +306,7 @@ describe('compileAtlas', () => {geometry: { cellSize: 64, pivot: [32, 56], targetMaxHeight: 44, targetMaxWidth: 52 },});const meta = await sharp(join(TEST_ROOT, 'sprites', id, result.atlasPath)).metadata();- expect(meta.width).toBe(64 * 10);+ expect(meta.width).toBe(64 * 9);expect(meta.height).toBe(64 * 8);});diff --git a/server/services/sprites/atlasLayout.js b/server/services/sprites/atlasLayout.jsindex 199c55ff4c..dc247c67db 100644--- a/server/services/sprites/atlasLayout.js+++ b/server/services/sprites/atlasLayout.js@@ -60,10 +60,12 @@ export function layoutSidecarPath(atlasDestPath) {/*** The walk-phase columns of a compiled grid: everything that is neither the- * idle anchor nor the scanner placeholder. Derived from the ACTUAL column+ * idle anchor nor a legacy 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.+ * 8-frame gait phases. The compiler no longer emits a scanner column (#2986),+ * but imported/pre-#2986 grids still carry one, so it stays filtered here —+ * otherwise their walk-frame count would come back one too high.*/const walkColumnsOf = (columns) =>columns.filter((c) => c !== ATLAS_IDLE_COLUMN && c !== ATLAS_SCANNER_COLUMN);@@ -80,13 +82,14 @@ export function resolveWalkFrameCount(geometry) {/*** Group the flat column list into named tracks of contiguous column spans:- * `{ idle: { start: 0, count: 1 }, walk: { start: 1, count: 8 }, … }`. The walk+ * `{ 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.+ * of the boundary — and so a legacy grid's one-column `scanner` placeholder is+ * still described honestly rather than folded into the walk span.*/export function deriveTracks(columns, walkFrameCount) {const walkStart = columns[0] === ATLAS_IDLE_COLUMN ? 1 : 0;diff --git a/server/services/sprites/atlasLayout.test.js b/server/services/sprites/atlasLayout.test.jsindex 7b11a29eda..c5739ae134 100644--- a/server/services/sprites/atlasLayout.test.js+++ b/server/services/sprites/atlasLayout.test.js@@ -11,8 +11,10 @@ import {import { walkPhaseLabels } from './walkBounds.js';const DIRECTIONS = ['S', 'SE', 'E', 'NE', 'N', 'NW', 'W', 'SW'];+// The grid the compiler emits today: idle + N walk phases (#2986 dropped the+// trailing scanner placeholder).const geometryFor = (walkFrameCount, overrides = {}) => ({- columns: ['idle', ...walkPhaseLabels(walkFrameCount), 'scanner'],+ columns: ['idle', ...walkPhaseLabels(walkFrameCount)],directionOrder: DIRECTIONS,rows: DIRECTIONS.length,cellSize: 96,@@ -20,6 +22,13 @@ const geometryFor = (walkFrameCount, overrides = {}) => ({walkFps: 10,...overrides,});+// A pre-#2986 / imported grid, which still carries the scanner column. The+// sidecar is the READ side of the contract, so it must keep describing these.+const legacyGeometryFor = (walkFrameCount, overrides = {}) =>+ geometryFor(walkFrameCount, {+ columns: ['idle', ...walkPhaseLabels(walkFrameCount), 'scanner'],+ ...overrides,+ });describe('layoutSidecarPath', () => {it('swaps the .png extension for .layout.json', () => {@@ -32,18 +41,25 @@ describe('layoutSidecarPath', () => {describe('resolveWalkFrameCount', () => {it('prefers the declared count and falls back to counting non-anchor columns', () => {expect(resolveWalkFrameCount(geometryFor(12))).toBe(12);+ expect(resolveWalkFrameCount(legacyGeometryFor(12))).toBe(12);// Pre-#2970 pointers carry no walkFrameCount.- expect(resolveWalkFrameCount({ columns: ['idle', 'a', 'b', 'c', 'scanner'] })).toBe(3);- // A scanner-less grid (#2986) still resolves.expect(resolveWalkFrameCount({ columns: ['idle', 'a', 'b'] })).toBe(2);+ // …and a pre-#2986 one is counted without its scanner placeholder.+ expect(resolveWalkFrameCount({ columns: ['idle', 'a', 'b', 'c', 'scanner'] })).toBe(3);expect(resolveWalkFrameCount({})).toBeNull();});});describe('deriveTracks', () => {it('collapses the walk columns into one span and gives every other column its own', () => {- const columns = ['idle', ...walkPhaseLabels(6), 'scanner'];- expect(deriveTracks(columns, 6)).toEqual({+ // The compiled grid is idle + walk only (#2986) — no third track.+ expect(deriveTracks(['idle', ...walkPhaseLabels(6)], 6)).toEqual({+ idle: { start: 0, count: 1 },+ walk: { start: 1, count: 6 },+ });+ // A pre-#2986 grid still describes its scanner placeholder honestly rather+ // than folding it into the walk span.+ expect(deriveTracks(['idle', ...walkPhaseLabels(6), 'scanner'], 6)).toEqual({idle: { start: 0, count: 1 },walk: { start: 1, count: 6 },scanner: { start: 7, count: 1 },@@ -52,8 +68,8 @@ describe('deriveTracks', () => {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'];+ // must still describe ONE walk track, not ten singletons.+ const columns = ['idle', ...walkPhaseLabels(10)];expect(deriveTracks(columns, 10).walk).toEqual({ start: 1, count: 10 });});@@ -90,17 +106,33 @@ describe('buildAtlasLayout', () => {cellSize: 96,rows: 8,rowOrder: DIRECTIONS,- columnCount: 10,+ columnCount: 9,walkFrameCount: 8,previewFps: 10,});- expect(layout.tracks.walk).toEqual({ start: 1, count: 8 });+ expect(layout.columns).toEqual(['idle', ...walkPhaseLabels(8)]);+ // The compiled grid has exactly two tracks — the scanner span is gone with+ // the column it described (#2986).+ expect(layout.tracks).toEqual({ idle: { start: 0, count: 1 }, walk: { start: 1, count: 8 } });expect(layout.previewFpsNote).toMatch(/do not use this as a runtime frame rate/);// No timestamp: identical geometry must produce byte-identical content so// an unchanged republish stays a no-op.expect(JSON.stringify(layout)).not.toMatch(/publishedAt/);});+ it('still describes a pre-#2986 grid that carries a scanner column', () => {+ const layout = buildAtlasLayout({+ characterId: 'example-character',+ geometry: legacyGeometryFor(8),+ atlasSha256: 'abc123',+ version: 2,+ atlasDestPath: 'assets/sprites/hero/hero-atlas.png',+ });+ expect(layout.columnCount).toBe(10);+ expect(layout.walkFrameCount).toBe(8);+ expect(layout.tracks.scanner).toEqual({ start: 9, count: 1 });+ });+it('refuses geometry with no column list', () => {expect(() => buildAtlasLayout({ characterId: 'x', geometry: {}, atlasDestPath: 'a.png' })).toThrow(/no column list/);@@ -108,7 +140,7 @@ describe('buildAtlasLayout', () => {});describe('runtimeContractMismatch', () => {- const contract = { walkFrameCount: 8, cellSize: 96, columnCount: 10 };+ const contract = { walkFrameCount: 8, cellSize: 96, columnCount: 9 };it('passes an absent contract and a matching one', () => {expect(runtimeContractMismatch(geometryFor(12), null)).toBeNull();@@ -118,17 +150,17 @@ describe('runtimeContractMismatch', () => {it('names both counts and both resolutions on a frame-count mismatch', () => {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).toContain('Atlas has 13 columns (12 walk frames)');+ expect(message).toContain('Example App expects 9 (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 message = runtimeContractMismatch(geometry, contract, 'Example App');- expect(message).toContain('Atlas has 9 columns (8 walk frames)');+ // A pre-#2986 atlas (still carrying the scanner column) against a contract+ // re-bound to the current 9-column grid: same walk frames, wrong shape.+ const message = runtimeContractMismatch(legacyGeometryFor(8), contract, 'Example App');+ expect(message).toContain('Atlas has 10 columns (8 walk frames)');expect(message).toMatch(/grid shape changed/);});diff --git a/server/services/sprites/publish.test.js b/server/services/sprites/publish.test.jsindex 473d209760..e3cbef6741 100644--- a/server/services/sprites/publish.test.js+++ b/server/services/sprites/publish.test.js@@ -57,7 +57,7 @@ const { SPRITE_DIRECTIONS: DIRECTIONS } = await import('./prompts.js');// The geometry block a real compile writes into the runtime pointer — the// publish path reads it for the contract guard and the layout sidecar.const atlasGeometry = (walkFrameCount = 8, overrides = {}) => ({- columns: ['idle', ...walkPhaseLabels(walkFrameCount), 'scanner'],+ columns: ['idle', ...walkPhaseLabels(walkFrameCount)],directionOrder: DIRECTIONS,rows: DIRECTIONS.length,cellSize: 96,@@ -65,6 +65,13 @@ const atlasGeometry = (walkFrameCount = 8, overrides = {}) => ({walkFps: 12,...overrides,});+// A pre-#2986 / imported grid, which still carries the trailing scanner+// placeholder. Publishing one must still work and must describe it honestly.+const legacyAtlasGeometry = (walkFrameCount = 8, overrides = {}) =>+ atlasGeometry(walkFrameCount, {+ columns: ['idle', ...walkPhaseLabels(walkFrameCount), 'scanner'],+ ...overrides,+ });const sidecarPath = (destPath) => destPath.replace(/\.png$/, '.layout.json');const readSidecar = async (destPath) =>@@ -142,10 +149,10 @@ describe('validatePublishBinding / setPublishBinding', () => {const { id } = await characterWithAtlas();const saved = await setPublishBinding(id, {...BINDING,- runtimeContract: { walkFrameCount: 8, cellSize: 96, columnCount: 10 },+ runtimeContract: { walkFrameCount: 8, cellSize: 96, columnCount: 9 },});expect(saved.publishBinding.runtimeContract).toEqual({- walkFrameCount: 8, cellSize: 96, columnCount: 10,+ walkFrameCount: 8, cellSize: 96, columnCount: 9,});for (const bad of [@@ -401,7 +408,7 @@ describe('runtime contract guard (#2982)', () => {const { id } = await characterWithAtlas();await setPublishBinding(id, {...BINDING,- runtimeContract: { walkFrameCount: 8, cellSize: 96, columnCount: 10 },+ runtimeContract: { walkFrameCount: 8, cellSize: 96, columnCount: 9 },});const result = await publishAtlas(id);expect(result.published).toBe(true);@@ -411,10 +418,10 @@ describe('runtime contract guard (#2982)', () => {const { id } = await characterWithAtlas('atlas-png-bytes-12f', atlasGeometry(12));await setPublishBinding(id, {...BINDING,- runtimeContract: { walkFrameCount: 8, cellSize: 96, columnCount: 10 },+ runtimeContract: { walkFrameCount: 8, cellSize: 96, columnCount: 9 },});await expect(publishAtlas(id)).rejects.toMatchObject({ status: 409, code: 'PUBLISH_CONTRACT_MISMATCH' });- await expect(publishAtlas(id)).rejects.toThrow(/14 columns \(12 walk frames\).*expects 10 \(8 walk frames\)/s);+ await expect(publishAtlas(id)).rejects.toThrow(/13 columns \(12 walk frames\).*expects 9 \(8 walk frames\)/s);await expect(publishAtlas(id)).rejects.toThrow(/reprocess this walk set to 8 frames/);// Nothing landed in the game repo — not the atlas, not the sidecar.expect(await readFile(join(APP_REPO, BINDING.atlasDestPath)).catch(() => null)).toBeNull();@@ -451,24 +458,40 @@ describe('layout sidecar (#2982)', () => {cellSize: 96,rows: 8,walkFrameCount: 12,- columnCount: 14,+ columnCount: 13,previewFps: 12,sourceAtlasSha256: sha256(Buffer.from(atlasBytes)),});expect(layout.columns[0]).toBe('idle');- expect(layout.columns.at(-1)).toBe('scanner');- expect(layout.columns).toHaveLength(14);+ // idle + 12 walk phases — the sidecar advertises no scanner span, because+ // the atlas beside it no longer has that column (#2986).+ expect(layout.columns).not.toContain('scanner');+ expect(layout.columns).toHaveLength(13);// Per-track spans so a future multi-frame track is additive, not a rewrite.expect(layout.tracks).toEqual({idle: { start: 0, count: 1 },walk: { start: 1, count: 12 },- scanner: { start: 13, count: 1 },});// previewFps travels labeled as authoring-only — the app must not animate from it.expect(layout.previewFpsNote).toMatch(/Authoring metadata only/);expect(result.publication).toMatchObject({ layoutDestPath: 'assets/sprites/hero/hero-atlas.layout.json' });});+ it('still describes a pre-#2986 atlas that carries a scanner column', async () => {+ // Imported/legacy atlases keep publishing unchanged — the sidecar reports+ // the grid the PNG actually is, scanner span and all, rather than the shape+ // the current compiler would emit.+ const { id } = await characterWithAtlas('atlas-png-bytes-legacy', legacyAtlasGeometry(8));+ await setPublishBinding(id, BINDING);+ const result = await publishAtlas(id);++ expect(result.published).toBe(true);+ const layout = await readSidecar(BINDING.atlasDestPath);+ expect(layout.columnCount).toBe(10);+ expect(layout.walkFrameCount).toBe(8);+ expect(layout.tracks.scanner).toEqual({ start: 9, count: 1 });+ });+it('is a no-op on an unchanged republish but self-heals a deleted sidecar', async () => {const { id } = await characterWithAtlas();await setPublishBinding(id, BINDING);@@ -513,7 +536,7 @@ describe('layout sidecar (#2982)', () => {expect(result.layoutWritten).toBe(true);const layout = await readSidecar(BINDING.atlasDestPath);expect(layout).toMatchObject({- walkFrameCount: 10, columnCount: 12, atlasVersion: 2, sourceAtlasSha256: sha256(Buffer.from(nextBytes)),+ walkFrameCount: 10, columnCount: 11, atlasVersion: 2, sourceAtlasSha256: sha256(Buffer.from(nextBytes)),});});diff --git a/server/services/sprites/walkBounds.js b/server/services/sprites/walkBounds.jsindex ac00912c07..ad8379cb31 100644--- a/server/services/sprites/walkBounds.js+++ b/server/services/sprites/walkBounds.js@@ -21,10 +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.+// The 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. `scanner` is READ-ONLY now: the+// compiler stopped emitting that duplicate-of-idle column (#2986), but+// imported/pre-#2986 grids still carry it, so the sidecar must keep+// recognizing it by name.export const ATLAS_IDLE_COLUMN = 'idle';export const ATLAS_SCANNER_COLUMN = 'scanner';