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

feat: expose runtimeContract in the sprite publish binding form (#2992)

[._.]/ Adam Eivy252830b90d09
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 4d949e84df..32d5400570 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -30,6 +30,7 @@
- **[issue-2993] Imported characters can finally be re-derived — smoother walks, and an atlas you can compile here** — a character brought over from a source art pipeline was frozen the moment it arrived: Unlock, Reopen and Compile all refused it outright, so an imported 8-frame walk could never be brought up to 12 and its atlas could only ever be re-published, never rebuilt. That refusal was written when the import genuinely left nothing behind to work from — but the importer now copies each direction's source clip, so it had become a lie. Those actions are now gated on whether the clip is actually there: a direction with its clip on disk reopens and reprocesses at any frame count and speed, with no new render and no new spend, and the buttons appear instead of being hidden. A direction with no clip is still refused, but now says so plainly and tells you to re-import the character. Compiling is likewise per-direction: the atlas names the directions still packaged by the source pipeline instead of refusing the whole set, so an imported character becomes compilable one direction at a time as you re-derive them — and approving a direction whose packaged frames were never imported is now caught up front, rather than surfacing much later as an unexplained compile error.
- **[issue-2996] A character you'd started but not locked now begins at the turnaround sheet too** — when turnaround sheets landed, characters already in progress kept the old flow: they'd still ask for a main reference first, and only pick up sheets afterward. Now a character that hasn't frozen anything yet simply starts at step 1 like a new one — nothing of yours is lost, because nothing was locked. Characters that *have* frozen a main reference are untouched: their locked artwork stays exactly as it is, and they still backfill a sheet from it. Uploading a design image is now accepted only on the turnaround step, since that's the render it actually seeds — the main reference and every anchor are drawn from the sheet, so attaching a separate image to them has nowhere to go and is rejected with a clear message.
- **[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-2992] Declare the grid your game expects right in the publish form** — the atlas-mismatch guard added in #2982 could only be armed by hand-writing an API call, because the publish binding form had no field for it. The form now has a compact **Runtime contract (optional)** group: set the walk frame count (and, optionally, cell size and column count) your game was built against, or click **Match current atlas** to fill it straight from the compiled atlas, so a mismatch is caught before you publish rather than silently breaking the game. The current atlas grid is shown right beside the fields, with a warning line the moment a saved contract disagrees with it. **Clear** removes a stored contract; saving the form without touching the contract leaves whatever the app already declared intact.
- **[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-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.
diff --git a/client/src/components/sprites/PublishWorkflow.jsx b/client/src/components/sprites/PublishWorkflow.jsx
index 551360d83c..b7cccc8b79 100644
--- a/client/src/components/sprites/PublishWorkflow.jsx
+++ b/client/src/components/sprites/PublishWorkflow.jsx
@@ -20,17 +20,49 @@ import { timeAgo } from '../../utils/formatters.js';
const inputClass = 'w-full px-2 py-1 text-xs bg-port-bg border border-port-border rounded text-gray-200 focus:border-port-accent focus:outline-none';
const fieldLabelClass = 'block text-xs text-gray-400 mb-1';
+// Mirrors of the server contract (server/services/sprites/walkBounds.js is the
+// single source of truth; kept as literals here rather than importing a server
+// module into the client bundle). WALK_MIN/MAX bound the walk-frame-count
+// input; IDLE/SCANNER name the non-walk columns so the "Match current atlas"
+// fallback can count walk columns the same way resolveWalkFrameCount does.
+const WALK_MIN_FRAME_COUNT = 6;
+const WALK_MAX_FRAME_COUNT = 16;
+const ATLAS_IDLE_COLUMN = 'idle';
+const ATLAS_SCANNER_COLUMN = 'scanner';
+
+// The compiled atlas stamps geometry.walkFrameCount, but imported/legacy
+// pointers may omit it — fall back to counting the walk columns, matching the
+// server's resolveWalkFrameCount so the compare and the fill button agree.
+function walkFrameCountOf(geometry) {
+ if (Number.isInteger(geometry?.walkFrameCount)) return geometry.walkFrameCount;
+ if (!Array.isArray(geometry?.columns)) return null;
+ return geometry.columns.filter(
+ (c) => c !== ATLAS_IDLE_COLUMN && c !== ATLAS_SCANNER_COLUMN,
+ ).length;
+}
+
export default function PublishWorkflow({ record, walk, atlas, onChanged }) {
const finalized = Boolean(walk?.walkSet);
const current = atlas?.current || null;
const publications = atlas?.publications || [];
const saved = record.publishBinding || null;
+ const savedContract = saved?.runtimeContract || null;
+ // Contract fields are strings so an empty input is distinguishable from a 0.
+ // The stored contract seeds them; walkFrameCount is the anchor field (an
+ // empty walk-frame-count means "no contract").
+ const seedFrames = savedContract?.walkFrameCount != null ? String(savedContract.walkFrameCount) : '';
+ const seedCell = savedContract?.cellSize != null ? String(savedContract.cellSize) : '';
+ const seedCols = savedContract?.columnCount != null ? String(savedContract.columnCount) : '';
+
const apps = useSidebarApps();
const [appId, setAppId] = useState(saved?.appId || '');
const [destPath, setDestPath] = useState(saved?.atlasDestPath || '');
const [codePath, setCodePath] = useState(saved?.codeBinding?.path || '');
const [resourcePath, setResourcePath] = useState(saved?.codeBinding?.resourcePath || '');
+ const [contractFrames, setContractFrames] = useState(seedFrames);
+ const [contractCell, setContractCell] = useState(seedCell);
+ const [contractCols, setContractCols] = useState(seedCols);
// null → idle; 'publish' → normal confirm; 'overwrite' → the server
// refused with PUBLISH_DEST_OCCUPIED / PUBLISH_LAYOUT_OCCUPIED and needs
// explicit consent. occupiedFile names which file the consent is about, so
@@ -46,8 +78,56 @@ export default function PublishWorkflow({ record, walk, atlas, onChanged }) {
setDestPath(saved?.atlasDestPath || '');
setCodePath(saved?.codeBinding?.path || '');
setResourcePath(saved?.codeBinding?.resourcePath || '');
+ setContractFrames(seedFrames);
+ setContractCell(seedCell);
+ setContractCols(seedCols);
setConfirmStage(null);
- }, [saved?.appId, saved?.atlasDestPath, saved?.codeBinding?.path, saved?.codeBinding?.resourcePath]);
+ }, [saved?.appId, saved?.atlasDestPath, saved?.codeBinding?.path, saved?.codeBinding?.resourcePath,
+ savedContract?.walkFrameCount, savedContract?.cellSize, savedContract?.columnCount,
+ seedFrames, seedCell, seedCols]);
+
+ // Parse the three contract inputs. walkFrameCount is the anchor: an empty
+ // field means "no contract". cellSize/columnCount are optional (empty → null).
+ const framesRaw = contractFrames.trim();
+ const cellRaw = contractCell.trim();
+ const colsRaw = contractCols.trim();
+ const framesNum = framesRaw === '' ? null : Number(framesRaw);
+ const cellNum = cellRaw === '' ? null : Number(cellRaw);
+ const colsNum = colsRaw === '' ? null : Number(colsRaw);
+ const hasContract = framesNum !== null;
+
+ const intInRange = (n, lo, hi) => Number.isInteger(n) && n >= lo && n <= hi;
+ // Validate only what's populated; walkFrameCount is required whenever any
+ // contract field is set (the server rejects a contract without it).
+ let contractError = null;
+ if (!hasContract && (cellRaw !== '' || colsRaw !== '')) {
+ contractError = 'Walk frame count is required for a runtime contract.';
+ } else if (hasContract && !intInRange(framesNum, WALK_MIN_FRAME_COUNT, WALK_MAX_FRAME_COUNT)) {
+ contractError = `Walk frame count must be a whole number ${WALK_MIN_FRAME_COUNT}–${WALK_MAX_FRAME_COUNT}.`;
+ } else if (cellNum !== null && !intInRange(cellNum, 16, 1024)) {
+ contractError = 'Cell size must be a whole number 16–1024.';
+ } else if (colsNum !== null && !intInRange(colsNum, 1, 256)) {
+ contractError = 'Column count must be a whole number 1–256.';
+ }
+
+ // Dirty relative to the SAVED contract, comparing the seeded string forms so
+ // "opened but untouched" never counts as a change.
+ const contractDirty = seedFrames !== framesRaw || seedCell !== cellRaw || seedCols !== colsRaw;
+
+ const fillFromAtlas = () => {
+ const geometry = current?.geometry;
+ if (!geometry) return;
+ const frames = walkFrameCountOf(geometry);
+ setContractFrames(frames != null ? String(frames) : '');
+ setContractCell(Number.isInteger(geometry.cellSize) ? String(geometry.cellSize) : '');
+ setContractCols(Array.isArray(geometry.columns) ? String(geometry.columns.length) : '');
+ };
+
+ const clearContract = () => {
+ setContractFrames('');
+ setContractCell('');
+ setContractCols('');
+ };
const [compile, compiling] = useAsyncAction(async () => {
const result = await compileSpriteAtlas(record.id, {}, { silent: true });
@@ -65,6 +145,15 @@ export default function PublishWorkflow({ record, walk, atlas, onChanged }) {
: null,
}
: null;
+ // Absent-vs-null: only touch runtimeContract when the contract group is
+ // dirty. An OMITTED key inherits the stored contract server-side (see
+ // setPublishBinding); an untouched save must not silently drop it. When
+ // dirty, a populated walkFrameCount sets it, an emptied one clears it (null).
+ if (binding && contractDirty) {
+ binding.runtimeContract = hasContract
+ ? { walkFrameCount: framesNum, cellSize: cellNum, columnCount: colsNum }
+ : null;
+ }
const result = await setSpritePublishBinding(record.id, binding, { silent: true });
onChanged?.();
return result;
@@ -128,7 +217,8 @@ export default function PublishWorkflow({ record, walk, atlas, onChanged }) {
const bindingDirty = (saved?.appId || '') !== appId
|| (saved?.atlasDestPath || '') !== destPath.trim()
|| (saved?.codeBinding?.path || '') !== codePath.trim()
- || (saved?.codeBinding?.resourcePath || '') !== resourcePath.trim();
+ || (saved?.codeBinding?.resourcePath || '') !== resourcePath.trim()
+ || contractDirty;
// Publish reads the SAVED binding server-side — gate on it, and hold while
// a binding save is in flight so a click can't race the PUT. The confirm
// row uses bindingSettled (not canPublish) so it stays mounted while the
@@ -139,6 +229,30 @@ export default function PublishWorkflow({ record, walk, atlas, onChanged }) {
const boundApp = apps.find((a) => a.id === saved?.appId);
const destLabel = `${boundApp?.name || saved?.appId}: ${saved?.atlasDestPath}`;
+ // Show the SAVED contract next to the compiled atlas geometry so a shape
+ // mismatch is visible here, not only in the publish-time 409. Mirrors the
+ // fields runtimeContractMismatch compares server-side.
+ const atlasGeom = current?.geometry || null;
+ const atlasFrames = walkFrameCountOf(atlasGeom);
+ const atlasCols = Array.isArray(atlasGeom?.columns) ? atlasGeom.columns.length : null;
+ const atlasCell = Number.isInteger(atlasGeom?.cellSize) ? atlasGeom.cellSize : null;
+ const atlasSummary = atlasGeom
+ ? `${atlasFrames ?? '?'} walk frames · ${atlasCols ?? '?'} cols${atlasCell != null ? ` · ${atlasCell}px` : ''}`
+ : null;
+ const savedContractMismatch = (() => {
+ if (!savedContract || !atlasGeom) return null;
+ if (Number.isInteger(savedContract.walkFrameCount) && savedContract.walkFrameCount !== atlasFrames) {
+ return `contract expects ${savedContract.walkFrameCount} walk frames, atlas has ${atlasFrames}`;
+ }
+ if (Number.isInteger(savedContract.columnCount) && savedContract.columnCount !== atlasCols) {
+ return `contract expects ${savedContract.columnCount} cols, atlas has ${atlasCols}`;
+ }
+ if (Number.isInteger(savedContract.cellSize) && savedContract.cellSize !== atlasCell) {
+ return `contract expects ${savedContract.cellSize}px cells, atlas has ${atlasCell ?? '?'}px`;
+ }
+ return null;
+ })();
+
return (
<div className="bg-port-card border border-port-border rounded-lg p-4 space-y-3">
<div className="flex items-center justify-between gap-2 flex-wrap">
@@ -192,10 +306,85 @@ export default function PublishWorkflow({ record, walk, atlas, onChanged }) {
<input value={resourcePath} onChange={(e) => setResourcePath(e.target.value)} placeholder="res://assets/sprites/hero/hero-atlas.png" className={inputClass} />
</FormField>
</div>
+
+ <div className="border border-port-border rounded p-2 space-y-2">
+ <div className="flex items-center justify-between gap-2 flex-wrap">
+ <span className="text-xs text-gray-300">Runtime contract (optional)</span>
+ <div className="flex items-center gap-2">
+ <button
+ type="button"
+ onClick={fillFromAtlas}
+ disabled={!current}
+ title={current ? undefined : 'Compile the atlas first'}
+ className="px-2 py-0.5 text-[11px] bg-port-bg border border-port-border rounded text-gray-300 hover:border-port-accent disabled:opacity-50"
+ >
+ Match current atlas
+ </button>
+ <button
+ type="button"
+ onClick={clearContract}
+ disabled={framesRaw === '' && cellRaw === '' && colsRaw === ''}
+ className="px-2 py-0.5 text-[11px] bg-port-bg border border-port-border rounded text-gray-300 hover:border-port-accent disabled:opacity-50"
+ >
+ Clear
+ </button>
+ </div>
+ </div>
+ <p className="text-[11px] text-gray-500">
+ The grid a consuming app was built against. A publish whose compiled atlas disagrees is
+ refused. Leave blank to publish unchecked; clearing removes a stored contract.
+ </p>
+ <div className="grid grid-cols-1 sm:grid-cols-3 gap-2">
+ <FormField label={`Walk frames (${WALK_MIN_FRAME_COUNT}–${WALK_MAX_FRAME_COUNT})`} labelClassName={fieldLabelClass}>
+ <input
+ type="number"
+ min={WALK_MIN_FRAME_COUNT}
+ max={WALK_MAX_FRAME_COUNT}
+ value={contractFrames}
+ onChange={(e) => setContractFrames(e.target.value)}
+ placeholder="12"
+ className={inputClass}
+ />
+ </FormField>
+ <FormField label="Cell size px (optional)" labelClassName={fieldLabelClass}>
+ <input
+ type="number"
+ min={16}
+ max={1024}
+ value={contractCell}
+ onChange={(e) => setContractCell(e.target.value)}
+ placeholder="96"
+ className={inputClass}
+ />
+ </FormField>
+ <FormField label="Column count (optional)" labelClassName={fieldLabelClass}>
+ <input
+ type="number"
+ min={1}
+ max={256}
+ value={contractCols}
+ onChange={(e) => setContractCols(e.target.value)}
+ placeholder="13"
+ className={inputClass}
+ />
+ </FormField>
+ </div>
+ {contractError && <p className="text-[11px] text-port-error">{contractError}</p>}
+ {atlasSummary && (
+ <p className="text-[11px] text-gray-500">
+ Current atlas grid: <span className="text-gray-300">{atlasSummary}</span>
+ </p>
+ )}
+ {savedContractMismatch && (
+ <p className="text-[11px] text-port-warning">Saved contract vs atlas: {savedContractMismatch}</p>
+ )}
+ </div>
+
<div className="flex items-center gap-2 flex-wrap">
<button
onClick={saveBinding}
- disabled={savingBinding || !bindingDirty}
+ disabled={savingBinding || !bindingDirty || Boolean(contractError)}
+ title={contractError || undefined}
className="px-2 py-1 text-xs bg-port-bg border border-port-border rounded text-gray-300 hover:border-port-accent disabled:opacity-50"
>
{savingBinding ? 'Saving…' : 'Save binding'}
diff --git a/client/src/components/sprites/PublishWorkflow.test.jsx b/client/src/components/sprites/PublishWorkflow.test.jsx
new file mode 100644
index 0000000000..0ad9421055
--- /dev/null
+++ b/client/src/components/sprites/PublishWorkflow.test.jsx
@@ -0,0 +1,114 @@
+import { describe, it, expect, vi, beforeEach } from 'vitest';
+import {
+ render, screen, act, fireEvent,
+} from '@testing-library/react';
+import { MemoryRouter } from 'react-router-dom';
+
+// Coverage for the runtime-contract field group (#2992). The load-bearing
+// behavior is the absent-vs-null merge: a populated contract SETS it, the
+// Clear affordance sends explicit `null`, and saving with the contract
+// untouched OMITS the key so the server inherits the stored contract.
+
+vi.mock('../../services/apiSprites.js', () => ({
+ compileSpriteAtlas: vi.fn(() => Promise.resolve({})),
+ setSpritePublishBinding: vi.fn(() => Promise.resolve({})),
+ publishSpriteAtlas: vi.fn(() => Promise.resolve({})),
+}));
+
+vi.mock('../../hooks/useSidebarApps.js', () => ({
+ useSidebarApps: () => [{ id: 'app-1', name: 'Example App' }],
+}));
+
+import PublishWorkflow from './PublishWorkflow';
+import { setSpritePublishBinding } from '../../services/apiSprites.js';
+
+const GEOMETRY = {
+ columns: ['idle', 'frame-00', 'frame-01', 'frame-02', 'frame-03', 'frame-04',
+ 'frame-05', 'frame-06', 'frame-07', 'frame-08', 'frame-09', 'frame-10', 'frame-11'],
+ cellSize: 96,
+ walkFrameCount: 12,
+};
+
+const atlasWith = (extra = {}) => ({
+ current: { version: 3, compiledAt: '2026-07-01T00:00:00.000Z', atlasPath: 'runtime/v3/a.png', geometry: GEOMETRY },
+ publications: [],
+ ...extra,
+});
+
+const renderWorkflow = (publishBinding, atlas = atlasWith()) => render(
+ <MemoryRouter>
+ <PublishWorkflow
+ record={{ id: 'example-walker', publishBinding }}
+ walk={{ walkSet: { imported: false } }}
+ atlas={atlas}
+ onChanged={vi.fn()}
+ />
+ </MemoryRouter>,
+);
+
+const savedContractBinding = {
+ appId: 'app-1',
+ atlasDestPath: 'assets/sprites/hero/hero-atlas.png',
+ codeBinding: null,
+ runtimeContract: { walkFrameCount: 12, cellSize: 96, columnCount: 13 },
+};
+
+const lastBindingArg = () => setSpritePublishBinding.mock.calls.at(-1)[1];
+
+describe('PublishWorkflow runtime contract', () => {
+ beforeEach(() => setSpritePublishBinding.mockClear());
+
+ it('SETS the contract from a populated field group', async () => {
+ renderWorkflow({ appId: 'app-1', atlasDestPath: 'assets/hero.png', codeBinding: null });
+
+ fireEvent.change(screen.getByLabelText(/Walk frames/), { target: { value: '12' } });
+ fireEvent.change(screen.getByLabelText(/Cell size/), { target: { value: '96' } });
+ fireEvent.change(screen.getByLabelText(/Column count/), { target: { value: '13' } });
+
+ await act(async () => { fireEvent.click(screen.getByText('Save binding')); });
+
+ expect(lastBindingArg().runtimeContract).toEqual({ walkFrameCount: 12, cellSize: 96, columnCount: 13 });
+ });
+
+ it('CLEARS the stored contract with an explicit null', async () => {
+ renderWorkflow(savedContractBinding);
+
+ await act(async () => { fireEvent.click(screen.getByText('Clear')); });
+ await act(async () => { fireEvent.click(screen.getByText('Save binding')); });
+
+ const binding = lastBindingArg();
+ expect('runtimeContract' in binding).toBe(true);
+ expect(binding.runtimeContract).toBeNull();
+ });
+
+ it('INHERITS the stored contract by OMITTING the key when untouched', async () => {
+ renderWorkflow(savedContractBinding);
+
+ // Make the binding dirty via an unrelated field so Save is enabled, but
+ // leave the contract untouched.
+ fireEvent.change(screen.getByLabelText(/Atlas destination/), { target: { value: 'assets/sprites/hero/renamed.png' } });
+ await act(async () => { fireEvent.click(screen.getByText('Save binding')); });
+
+ const binding = lastBindingArg();
+ expect('runtimeContract' in binding).toBe(false);
+ });
+
+ it('MATCHES the current atlas geometry into the fields', () => {
+ renderWorkflow({ appId: 'app-1', atlasDestPath: 'assets/hero.png', codeBinding: null });
+
+ fireEvent.click(screen.getByText('Match current atlas'));
+
+ expect(screen.getByLabelText(/Walk frames/).value).toBe('12');
+ expect(screen.getByLabelText(/Cell size/).value).toBe('96');
+ expect(screen.getByLabelText(/Column count/).value).toBe('13');
+ });
+
+ it('rejects an out-of-range walk frame count and blocks the save', () => {
+ renderWorkflow({ appId: 'app-1', atlasDestPath: 'assets/hero.png', codeBinding: null });
+
+ fireEvent.change(screen.getByLabelText(/Walk frames/), { target: { value: '99' } });
+
+ expect(screen.getByText(/Walk frame count must be/)).toBeInTheDocument();
+ expect(screen.getByText('Save binding')).toBeDisabled();
+ });
+});
diff --git a/docs/features/sprite-export-contract.md b/docs/features/sprite-export-contract.md
index 17e2a2c28c..cee32c8361 100644
--- a/docs/features/sprite-export-contract.md
+++ b/docs/features/sprite-export-contract.md
@@ -77,10 +77,10 @@ Column layout is the one thing an app genuinely has to agree with PortOS about.
Two mechanisms guard that:
-- **`publishBinding.runtimeContract`** (optional): `{ walkFrameCount, cellSize?, columnCount? }` — the grid the app was built against. Set it via `PUT /api/sprites/:id/publish-binding`. Publishing an atlas whose compiled geometry disagrees fails with a **409** naming both the actual and expected numbers and both resolutions (change the app's constant, or reprocess the walk set). A binding with no contract publishes unchecked, exactly as before the field existed.
+- **`publishBinding.runtimeContract`** (optional): `{ walkFrameCount, cellSize?, columnCount? }` — the grid the app was built against. Set it from the **Runtime contract** group in the publish binding form (the sprite's Publish workflow) — a "Match current atlas" button fills it from the compiled atlas geometry, and a "Clear" affordance removes it — or via `PUT /api/sprites/:id/publish-binding` directly. Publishing an atlas whose compiled geometry disagrees fails with a **409** naming both the actual and expected numbers and both resolutions (change the app's constant, or reprocess the walk set). A binding with no contract publishes unchecked, exactly as before the field existed.
- **The sidecar**, so an app that reads it can fail loudly on its own terms instead of relying on PortOS to have been asked.
-`runtimeContract` follows absent-vs-null semantics: a saved binding that omits the key inherits the stored contract (the publish form doesn't edit it), while an explicit `null` clears it. The inheritance is scoped to the same `appId` — re-pointing a character at a different app drops the old app's contract rather than holding the new one to it.
+`runtimeContract` follows absent-vs-null semantics: a saved binding that omits the key inherits the stored contract (saving the form with the contract group untouched omits it, so the stored contract survives an unrelated edit), while an explicit `null` — what the form's "Clear" sends — clears it. The inheritance is scoped to the same `appId` — re-pointing a character at a different app drops the old app's contract rather than holding the new one to it.
**A frame-count change is therefore a two-repo change.** Reprocess the walk set to the new count, update the app's frame-count constant *and* the distance/timing math derived from it, and update the contract — in whichever order, but neither half ships alone.