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
pin the walk aligner to the torso instead of the bounding box
[._.]/ Adam Eivy2dacc8216633
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 4514cb7596..301bd62a56 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -187,3 +187,4 @@- **[issue-2991] Support portless desktop managed processes and an app→sprite reverse lookup** — a managed app can now describe a GUI/desktop process (`type: 'desktop'`, e.g. a Godot game binary) with no HTTP port, and the port-dependent surfaces degrade gracefully instead of faking a port. Start now launches a desktop app from its own `startCommands` with PM2 `autorestart` OFF (a window closing is a normal exit, not a crash to loop on — `startWithCommand` gained an `{ autorestart }` option), skips the web-server ecosystem path, and refuses to spawn a second instance when the process is already online. Status reports from the supervisor alone (a clean quit renders as *stopped*, never "unreachable"), and the null-tolerant reserved-port collection already excludes absent ports. The "Open UI" launcher stays hidden for a portless app (`getLaunchUrls` returns all-null) rather than linking to `undefined`. New `GET /api/apps/:id/sprite-bindings` reverse-lookup lists the sprite records whose `publishBinding.appId` targets an app, surfaced on the app Overview tab as "Published Sprite Assets" with their destination paths — making "PortOS is the creative source for this app" legible from the app side. Publishing itself still resolves purely from `repoPath`, with no dependency on registered processes.- **[issue-2953] Finish the image-to-3D workspace: file-upload picker, a per-record detail route, and a records library** — the `/media/3d` page now doubles as a library, listing every `image_to_3d_models` record (newest-first) as a deep-link card into a new `/media/3d/:id` detail view. The detail page mounts the reusable `GlbViewer` (with **Download .glb**) once a render lands `ready`, polls while `generating`, surfaces the runner's actionable error on `failed`, and offers re-render + delete (inline-confirm) — the URL is the source of truth for what's open, per the ID-based deep-linking convention. `GalleryImagePicker` gains an optional `allowUpload` prop: an "Upload" control saves a file off disk into the gallery via the existing peer-syncable `POST /api/image-gen/upload`, then selects it exactly like a gallery image, so an uploaded photo feeds `createImageTo3dModel` the same way a render-history pick does. No new backend surface — everything runs against the endpoints that landed in #2973.- **[issue-3043] Let a frozen imported walk set be unlocked for regeneration** — a character imported from the source pipeline whose walk set was finalized without its per-run source clips (the phase-1 import shape) had *no reachable action at all*: unlock and reopen both 409'd `LEGACY_IMPORTED_WALK_SET` (nothing to re-derive from), the cycle-target PUT 409'd `WALK_SET_FINAL` (set is frozen), and the workflow header rendered a dead `imported · no clips to re-derive` label with no button behind it — while the drift banner told the user to re-derive. The guard's premise was too narrow: it reasoned only about *re-derivation*, but a walk render is conditioned on the direction's **locked anchor**, so such a set can always be rebuilt from scratch — it just costs a new render per direction instead of a free local repack. `POST /walk/unlock` now accepts `{ acknowledgeNoClips }`, honored only where the server has proven every stranded direction has a locked anchor to regenerate from (an acknowledgement can never be the thing that strands a set — a stranded direction with an unlocked anchor still refuses, with the original error code). `getWalkState` stamps `walkSet.unlock = { blocked, stranded, acknowledgeable }` from the same resolver the gate itself uses, so the button a client offers and the 409 it might hit are computed from one reading of the set; the refusal that *can* be acknowledged past gets its own code (`LEGACY_IMPORTED_WALK_SET_REGENERABLE`) and names that path. The Walk Cycles header replaces the dead label with an **Unlock anyway** panel stating the cost as visible text rather than a tooltip (one new grok render per direction, every approval dropped, nothing deleted on disk), and the Loop Trimmer disables its `CycleTarget` while the set is frozen — it was enabled and 409'd on change — with the same two unlock offers below it. Two adjacent bugs surfaced while proving the escape is real and are fixed with it: `startWalkGenerationImpl` read `manifest.chromaKey` alone, but the importer stamps the key it used on the RECORD and copies a manifest carrying none — so every fully-locked source-pipeline import reported `MAIN_NOT_LOCKED` ("no frozen chroma key") and refused every Generate; the lookup now falls back manifest → record, the order reference.js already resolves it in at eight sites, The postprocess path carried the SAME missing rung (`run.chromaKey || manifest.chromaKey`) and died inside sharp with `Invalid hex color: undefined` on any reprocess of an imported run — a parser complaining about its argument, naming neither the field nor the record behind it. All three sites now share one `resolveChromaKey({ manifest, record, run })` (run → manifest → record), and a genuinely keyless record is refused by name before reaching the color parser. And the render path's anchor/chroma preconditions are now one shared `resolveWalkRenderability()`, so the gate that promises "every direction can be regenerated" and the render path that has to deliver it cannot drift — a predicate checking less than the render requires is exactly how an acknowledgement walks a user into the dead end it promises cannot happen.+- **[issue-3049] Pin the walk aligner to the character's torso, not its bounding box** — a re-derived walk cycle slid visibly left and right as the legs scissored instead of walking in place; measured on a real packed 12-frame strip the torso travelled **29px** in a 384px cell. `alignFrames` crops each frame to its own alpha bbox and composites the crop at `dx`, and since #3021 `dx` was a single shared value — but `sourceRootXs[i]` is measured *relative to that frame's own crop*, so a constant `dx` pins `bbox.left` (the leading arm/leg extremity) and lets the body swing by the full spread of those offsets. The emitted manifest showed it exactly: `hipOffsets` spanning 26.2px against `translations` whose x was `122` for all twelve frames, and the strip itself had `bbox.left` at exactly 122 in every cell while the hip swung 179→205. #3021's premise was right (the old 42%–76% hip/leg band did migrate as the legs scissored) but freezing `dx` swapped it for a *worse* landmark: measured in absolute source coordinates over one 6s clip, the candidates rank torso 14px · hip 17px · head 24px · **bbox.left 44px** · legs 52px. So `rootX` now measures the **torso** band (30%–58%, above the knees — the visual mass a viewer tracks and the part genuinely stationary in a walk-in-place) and `dx` is per-frame again, computed from each frame's own crop offset so the shared landmark lands on the pivot every time; that cancels the crop variation *and* the residual drift grok leaves in a "walk in place" clip (~14px). `rootX` is shared with `atlas.js` for idle-frame registration, so both moved together. The #3021 guard had asserted the mechanism (`new Set(translations.map(([dx]) => dx)).size === 1`) rather than the behaviour, and its own fixed-torso/swinging-arm fixture passed while the body slid 30px — it now measures where the torso *lands* in the output frames and requires ≤1px spread, which pinning the crop cannot satisfy. Re-deriving a real direction: torso spread **29px → 1.0px**, with the hip band still swinging 8px and `bbox.left` varying 9px (limbs moving, body still).diff --git a/server/services/sprites/walkPostprocess.js b/server/services/sprites/walkPostprocess.jsindex c9a7997352..d6f4736944 100644--- a/server/services/sprites/walkPostprocess.js+++ b/server/services/sprites/walkPostprocess.js@@ -423,14 +423,23 @@ export function alphaBbox(frame, threshold = BBOX_ALPHA_THRESHOLD) {}/**- * x-center of the character at the hip/leg band (42%–76% of bbox height) —- * the per-frame pivot the alignment pins to x=192.+ * x-center of the character at the TORSO band (30%–58% of bbox height) — the+ * per-frame pivot the alignment pins to x=192.+ *+ * The band is the chest/waist, deliberately ABOVE the knees. Measured in+ * absolute source coordinates across a real 6s clip, the candidate landmarks+ * rank (spread over the cycle, one direction): torso 14px · hip 17px · head 24px+ * · bbox.left 44px · legs 52px. The old 42%–76% band reached into the scissoring+ * legs, which is what made a per-frame anchor migrate — the symptom #3021+ * described. The torso is the visual mass a viewer tracks and the part that is+ * genuinely stationary in a walk-in-place, so pinning it is both the stablest+ * measurement and the right physical model; arms and legs then swing around it.*/export function rootX(frame, bbox) {const { data, width } = frame;const H = bbox.bottom - bbox.top;- const bandTop = bbox.top + pyRound(H * 0.42);- const bandBottom = bbox.top + pyRound(H * 0.76);+ const bandTop = bbox.top + pyRound(H * 0.30);+ const bandBottom = bbox.top + pyRound(H * 0.58);const xs = [];for (let y = bandTop; y < bandBottom; y++) {for (let x = bbox.left; x < bbox.right; x++) {@@ -501,17 +510,24 @@ export async function alignFrames(frames) {const maxHeight = Math.max(...bboxes.map((b) => b.bottom - b.top));const scale = Math.min(1, (WALK_CELL_SIZE * 0.78) / maxWidth, (WALK_CELL_SIZE * 0.82) / maxHeight);- // ONE hip anchor for the whole direction (#3021). Anchoring x per frame made- // the body slide: `rootX` is the median of the hip/leg band, so it migrates as- // the legs scissor, and being a float median of an even-sized set it lands on- // .5 often enough that banker's rounding alternates the result by 1px on- // consecutive frames — a toggle locked to frame parity. A walk cycle rendered- // in place has a constant hip x by definition, so the median ACROSS frames is- // both the physically correct model and immune to per-frame silhouette noise.- // Per-frame values stay in the manifest (`hipOffsets`) for diagnostics.+ // Anchor the TORSO of each frame on the pivot (#3049).+ //+ // #3021 replaced a per-frame x anchor with ONE shared offset, because the old+ // hip/leg-band `rootX` migrated as the legs scissored. That treated the+ // symptom: a shared dx positions the CROP, and each frame is cropped to its+ // own alpha bbox, so freezing dx silently pins `bbox.left` — the leading+ // arm/leg extremity, and empirically the second-WORST landmark on the body+ // (44px of travel over a cycle, against 14px for the torso). The result was a+ // 26px left-right lurch, measured on a packed 12-frame strip: bbox.left sat at+ // exactly 122 in all twelve cells while the hip swung 179→205.+ //+ // With `rootX` now measuring the torso (see above), the per-frame anchor is+ // both stable and correct: `dx` is computed from THIS frame's own crop offset+ // so the shared landmark lands on the pivot every time, which cancels the crop+ // variation AND any real drift left in the source clip (grok's "walk in place"+ // still wanders ~14px). Residual is bounded by the torso measurement, not by+ // the silhouette's widest limb.const sourceRootXs = frames.map((f, i) => (rootX(f, bboxes[i]) - bboxes[i].left) * scale);- const sharedRootX = median(sourceRootXs);- const dx = pyRound(WALK_PIVOT[0] - sharedRootX);const aligned = [];const translations = [];@@ -520,6 +536,7 @@ export async function alignFrames(frames) {const cropped = cropFrame(frames[i], bbox);const size = [Math.max(1, pyRound(cropped.width * scale)), Math.max(1, pyRound(cropped.height * scale))];const resized = await premultipliedResize(cropped, size[0], size[1]);+ const dx = pyRound(WALK_PIVOT[0] - sourceRootXs[i]);// Feet land on the baseline by the frame's ROBUST bottom, not its bbox// bottom. `alphaBbox` extends to a single surviving despill speck or a// dropped shadow, and pinning that to y=352 lifted the whole body by@@ -536,13 +553,14 @@ export async function alignFrames(frames) {cellSize: WALK_CELL_SIZE,fixedScale: pyRoundTo(scale, 8),targetPivot: WALK_PIVOT,- // Renamed from 'one-fixed-scale-plus-per-frame-translation': x is now- // shared across the direction, so only y varies per frame. The shared x- // itself is not stored separately — it IS every entry of `translations`.- operation: 'one-fixed-scale-shared-hip-x-plus-per-frame-baseline-y',- // The per-frame hip measurements the shared anchor was taken from. Kept- // for diagnostics: their spread is the drift this alignment cancels, so a- // regression shows up as translations moving with them again.+ // Both axes vary per frame again (#3049): x pins this frame's torso to the+ // pivot, y its robust baseline. The distinguishing fact vs the pre-#3021+ // shape is WHICH landmark x uses — the torso band, not the hip/leg band.+ operation: 'one-fixed-scale-per-frame-torso-x-and-baseline-y',+ // The per-frame torso measurements the anchor is taken from. Kept for+ // diagnostics: their spread is the drift this alignment cancels, so a+ // regression shows up as `translations[i][0]` going constant while these+ // still move (that is exactly the #3021 shape this replaced).hipOffsets: sourceRootXs.map((v) => pyRoundTo(v, 4)),translations,},diff --git a/server/services/sprites/walkPostprocess.test.js b/server/services/sprites/walkPostprocess.test.jsindex 71f3dae832..570d22d712 100644--- a/server/services/sprites/walkPostprocess.test.js+++ b/server/services/sprites/walkPostprocess.test.js@@ -216,7 +216,7 @@ describe('alignFrames / packStrip', () => {const { frames, alignment } = await alignFrames([frame]);expect(frames[0].width).toBe(WALK_CELL_SIZE);expect(alignment.fixedScale).toBe(1); // fits inside 299×314 unscaled- expect(alignment.operation).toBe('one-fixed-scale-shared-hip-x-plus-per-frame-baseline-y');+ expect(alignment.operation).toBe('one-fixed-scale-per-frame-torso-x-and-baseline-y');const [dx, dy] = alignment.translations[0];expect(dy).toBe(352 - 200); // feet on the baselineexpect(dx).toBe(192 - 50); // hip median (col 99.5 abs → 49.5 rel) → pyRound(192-49.5)=142@@ -239,23 +239,47 @@ describe('alignFrames / packStrip', () => {// observe it — which is why the per-frame drift in #3021 went untested for so// long. These build a synthetic direction whose frames differ only in ways a// real gait differs, and assert the character doesn't move because of it.- describe('inter-frame registration (#3021)', () => {- // Torso/hips identical in every frame; only an arm swings. A viewer should- // see the arm move and the body stay put.+ describe('inter-frame registration (#3021, #3049)', () => {+ // Torso/legs identical in every frame; only an arm swings. A viewer should+ // see the arm move and the body stay put. The arm sits ABOVE the torso+ // measuring band so the fixture isolates what it claims to: a silhouette+ // change that must not move the body.const swingingArm = (armX) => {const frame = makeFrame(200, 300);- fillRect(frame, 80, 40, 120, 240, [80, 60, 40, 255]); // torso+legs, fixed- fillRect(frame, armX, 90, armX + 20, 130, [80, 60, 40, 255]); // arm, moves+ fillRect(frame, 80, 40, 200, 280, [80, 60, 40, 255]); // torso+legs, fixed+ fillRect(frame, armX, 60, armX + 20, 100, [80, 60, 40, 255]); // arm, movesreturn frame;};- it('gives every frame the same x, so a swinging arm cannot slide the body', async () => {- const { alignment } = await alignFrames([swingingArm(50), swingingArm(80), swingingArm(120)]);- const xs = alignment.translations.map(([dx]) => dx);- expect(new Set(xs).size).toBe(1);- // The per-frame measurements are kept for diagnostics and DO still vary —- // pin that, so this test can't pass by the anchor becoming constant.+ // Asserted on the OUTPUT, not on `dx`. The original form of this test pinned+ // `new Set(translations.map(([dx]) => dx)).size === 1` — the mechanism #3021+ // introduced rather than the behavior it wanted, and the two are not the same+ // claim. A shared dx positions the CROP, and each frame is cropped to its own+ // bbox, so a frame whose arm extends the bbox 30px further left had its whole+ // body composited 30px further right. This fixture passed that assertion+ // while the body slid by exactly that much. Measuring where the torso LANDS+ // cannot be satisfied that way.+ it('keeps the body still while an arm swings', async () => {+ const { frames, alignment } = await alignFrames(+ [swingingArm(50), swingingArm(80), swingingArm(120)],+ );+ const torsoXs = frames.map((f) => rootX(f, alphaBbox(f)));+ expect(Math.max(...torsoXs) - Math.min(...torsoXs)).toBeLessThanOrEqual(1);+ // …and it is not passing because the anchor went constant: the per-frame+ // measurements vary, and x compensates for them.expect(new Set(alignment.hipOffsets).size).toBeGreaterThan(1);+ expect(new Set(alignment.translations.map(([dx]) => dx)).size).toBeGreaterThan(1);+ });++ // The regression that motivated #3049, in miniature: the leading limb defines+ // bbox.left, so an anchor that positions the crop rather than the character+ // moves the body by the limb's travel.+ it('does not let the leading limb become the anchor', async () => {+ const { frames } = await alignFrames([swingingArm(50), swingingArm(120)]);+ const lefts = frames.map((f) => alphaBbox(f).left);+ // bbox.left MUST differ between the two (the arm is out on one of them).+ // A constant here is the #3021 shape: crop pinned, body free to slide.+ expect(new Set(lefts).size).toBeGreaterThan(1);});it('keeps the baseline stable across frames of equal height', async () => {