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

fix([issue-2993]): keep the reopen gate alive after the walk set is un-frozen

[._.]/ Adam Eivyda69dc139c20
diff --git a/client/src/components/sprites/WalkWorkflow.jsx b/client/src/components/sprites/WalkWorkflow.jsx
index ce9d790c59..8cc954e639 100644
--- a/client/src/components/sprites/WalkWorkflow.jsx
+++ b/client/src/components/sprites/WalkWorkflow.jsx
@@ -273,7 +273,10 @@ function DirectionCard({
// The dead end: still packaged by the source pipeline AND no clip to re-derive
// from. Everything the server refuses for this direction refuses on exactly
// this, so every affordance below reads it rather than the import label alone.
- const importedNoClip = imported && !hasSourceClip;
+ // `run.importedPackaging` is the load-bearing half: the set-level `imported`
+ // prop comes off the frozen walk set, which is GONE after an unlock or the
+ // first reopen — exactly when the remaining directions still need gating.
+ const importedNoClip = (imported || Boolean(run?.importedPackaging)) && !hasSourceClip;
const statusLabel = approved ? 'approved'
: (pending || rendering) ? 'rendering…'
: run?.status === 'postprocessing' ? 'packaging…'
diff --git a/client/src/components/sprites/WalkWorkflow.test.jsx b/client/src/components/sprites/WalkWorkflow.test.jsx
index e7d314ebc9..8bde99e1eb 100644
--- a/client/src/components/sprites/WalkWorkflow.test.jsx
+++ b/client/src/components/sprites/WalkWorkflow.test.jsx
@@ -569,6 +569,41 @@ describe('WalkWorkflow reprocess + reopen', () => {
expect(screen.getByRole('button', { name: /^Reopen$/ })).toBeTruthy();
});
+ // Once a set is un-frozen (an unlock, or a reopen of some OTHER direction)
+ // there is no walkSet to carry the imported flag — but the still-approved
+ // directions behind it must stay gated, or a clipless one is strandable by
+ // clicking twice. The run's own `importedPackaging` is what survives.
+ it('keeps a clipless imported direction gated after the set is un-frozen', async () => {
+ render(
+ <MemoryRouter>
+ <WalkWorkflow
+ record={{ id: 'example-walker' }}
+ reference={{ manifest: { mainReference: { locked: true }, anchors: [{ direction: 'east', status: 'locked' }] } }}
+ walk={{
+ runs: [{
+ id: 'run-east',
+ direction: 'east',
+ status: 'approved',
+ importedPackaging: true,
+ stripPreview: { stripPath: 'grok/run-east/generated/strip.png', frameCount: 12, fps: 10, cellWidth: 384, cellHeight: 384 },
+ }],
+ selection: { directions: { east: { status: 'approved', runId: 'run-east' } } },
+ walkSet: null,
+ walkTarget: {
+ frameCount: 12, fps: 10, source: 'derived', sourceLabel: 'from the first approved direction', drift: [],
+ },
+ }}
+ renders={noRenders()}
+ duration={6}
+ onDurationChange={vi.fn()}
+ onGenerate={vi.fn()}
+ onChanged={vi.fn()}
+ />
+ </MemoryRouter>,
+ );
+ expect(screen.queryByRole('button', { name: /^Reopen$/ })).toBeNull();
+ });
+
// The set-level flag stays true while ANY direction is still source-packaged,
// so a card must read the per-direction list the server stamps — otherwise a
// direction already re-derived here keeps being treated as un-reopenable.
diff --git a/server/services/sprites/paths.js b/server/services/sprites/paths.js
index 6af1788d89..5c1096e22e 100644
--- a/server/services/sprites/paths.js
+++ b/server/services/sprites/paths.js
@@ -33,21 +33,6 @@ export function spriteDir(recordId) {
export const RUNTIME_POINTER_REL = 'runtime/current.json';
export const RUNTIME_PUBLICATIONS_REL = 'runtime/publications.json';
-/**
- * Normalize an asset-path field read out of an imported manifest to the
- * record-relative form `spriteAssetUrl`/`resolveSpriteAssetPath` expect. The
- * source pipeline embeds paths anchored at ITS repo root
- * (`art-source/sprites/<recordId>/...`) inside every manifest, and the
- * importer copies those manifests byte-for-byte — their hashes are pinned
- * and verified against the source, so importer.js never rewrites the copied
- * JSON content. Readers that treat an embedded path as record-relative (the
- * convention every PortOS-generated manifest already follows) must strip
- * that source-repo prefix at read time instead. Returns null for a path
- * that isn't inside this record (repo-anchored provenance, e.g. a pipeline
- * script path) or for missing/empty/traversal-shaped input. A path with no
- * repo-anchor segment is assumed already record-relative and passed through
- * unchanged — this is what makes the helper a no-op for PortOS's own runs.
- */
/**
* The path prefix the source art pipeline anchors every embedded reference at.
* A copied manifest names `art-source/sprites/<recordId>/…` for a file that, on
@@ -64,6 +49,21 @@ export const isSourcePipelinePath = (p) => typeof p === 'string' && p.includes(S
// postprocess reads it, and the walk service re-derives from it.
export const SOURCE_CLIP_NAME = 'source-video.mp4';
+/**
+ * Normalize an asset-path field read out of an imported manifest to the
+ * record-relative form `spriteAssetUrl`/`resolveSpriteAssetPath` expect. The
+ * source pipeline embeds paths anchored at ITS repo root
+ * (`art-source/sprites/<recordId>/...`) inside every manifest, and the
+ * importer copies those manifests byte-for-byte — their hashes are pinned
+ * and verified against the source, so importer.js never rewrites the copied
+ * JSON content. Readers that treat an embedded path as record-relative (the
+ * convention every PortOS-generated manifest already follows) must strip
+ * that source-repo prefix at read time instead. Returns null for a path
+ * that isn't inside this record (repo-anchored provenance, e.g. a pipeline
+ * script path) or for missing/empty/traversal-shaped input. A path with no
+ * repo-anchor segment is assumed already record-relative and passed through
+ * unchanged — this is what makes the helper a no-op for PortOS's own runs.
+ */
export function toRecordRelativeAssetPath(recordId, rawPath) {
if (typeof rawPath !== 'string' || !rawPath) return null;
const marker = `${SOURCE_PIPELINE_ANCHOR}${recordId}/`;
diff --git a/server/services/sprites/walk.js b/server/services/sprites/walk.js
index 0844ae24cb..61965c800a 100644
--- a/server/services/sprites/walk.js
+++ b/server/services/sprites/walk.js
@@ -30,7 +30,7 @@ import { GROK_TUI_ID } from '../../lib/grok.js';
import { getSettings } from '../settings.js';
import { getRecord, updateRecord } from './records.js';
import {
- spriteDir, resolveSpriteAssetPath, toRecordRelativeAssetPath, RUN_DIR_MATCH, altRunLayoutPath,
+ spriteDir, resolveSpriteAssetPath, toRecordRelativeAssetPath, altRunLayoutPath,
runDirOfPath, resolveDriftTolerantRel, isSourcePipelinePath, SOURCE_CLIP_NAME,
} from './paths.js';
import { requireCharacter, loadManifest } from './reference.js';
@@ -1160,12 +1160,25 @@ async function assertSetReDerivable(recordId, walkSet) {
);
}
-/** Reopen's per-direction twin of the gate above. */
-async function assertDirectionReDerivable(recordId, walkSet, direction) {
- if (!isImportedWalkSet(walkSet)) return;
- const stranded = await directionsWithoutClip(recordId, walkSet, [direction]);
- if (!stranded.length) return;
- throw notReDerivable(`This walk set was imported from the source pipeline and the ${direction} direction has no source clip on disk — reopening is not supported, because there would be nothing to re-derive from.`);
+/**
+ * Reopen's per-direction twin of the gate above.
+ *
+ * Keyed on the DIRECTION's own entry as well as the frozen set, because reopen
+ * un-freezes: after the first one `loadWalkSet` returns null, so a gate that
+ * consulted only the walk set would be dead for every reopen after it — and a
+ * clipless source-packaged direction could still be stranded, two clicks in,
+ * by following the advice the unlock refusal prints. The entry survives the
+ * un-freeze and carries the same provenance. The set-level marker stays in the
+ * OR so a copied `selectionPath` with entries that name no run at all is still
+ * refused, as it was before evidence entered the picture.
+ */
+async function assertDirectionReDerivable(recordId, walkSet, entry, direction) {
+ const imported = isSourcePipelinePath(entry?.runPath)
+ || isSourcePipelinePath(entry?.runManifest)
+ || isImportedWalkSet(walkSet);
+ if (!imported) return;
+ if (await directionClipRel(recordId, entry)) return;
+ throw notReDerivable(`The ${direction} direction is still packaged by the source pipeline and has no source clip on disk — reopening is not supported, because there would be nothing to re-derive from and its packaged frames were never imported.`);
}
// Un-finalize: drop the canonical "finalized" signal (the walk-set file) FIRST,
@@ -1223,9 +1236,11 @@ export function reopenWalkDirection(recordId, { direction }) {
async function reopenWalkDirectionImpl(recordId, direction) {
await requireCharacter(recordId);
- const walkSet = await loadWalkSet(recordId);
- await assertDirectionReDerivable(recordId, walkSet, direction);
- const selection = (await loadSelection(recordId)) || seedSelection(recordId);
+ const [walkSet, loaded] = await Promise.all([loadWalkSet(recordId), loadSelection(recordId)]);
+ const selection = loaded || seedSelection(recordId);
+ // The selection entry is the gate's evidence, so it is read BEFORE the
+ // re-derivability check (which needs it) and before the approval check.
+ await assertDirectionReDerivable(recordId, walkSet, selection.directions?.[direction], direction);
if (selection.directions?.[direction]?.status !== 'approved') {
throw new ServerError(`Direction ${direction} is not approved`, { status: 409, code: 'DIRECTION_NOT_APPROVED' });
}
diff --git a/server/services/sprites/walk.test.js b/server/services/sprites/walk.test.js
index 462717a7f1..e035151fca 100644
--- a/server/services/sprites/walk.test.js
+++ b/server/services/sprites/walk.test.js
@@ -938,6 +938,14 @@ describe('imported walk sets — evidence-based re-derive', () => {
expect(state.walkSet).toBeNull();
expect(state.selection.directions.east).toBeUndefined();
expect(state.selection.directions.north.status).toBe('approved');
+
+ // …and STILL refuses north now that the set is un-frozen. Reopen un-freezes,
+ // so a gate keyed only on the frozen walk set would be dead from here on and
+ // north could be stranded by simply clicking twice — which is what the unlock
+ // refusal's own "reopen them one at a time" advice would have walked into.
+ await expect(reopenWalkDirection(id, { direction: 'north' }))
+ .rejects.toMatchObject({ code: 'LEGACY_IMPORTED_WALK_SET' });
+ expect((await getWalkState(id)).selection.directions.north.status).toBe('approved');
});
// The acceptance case: an imported 8-frame direction brought up to 12 with no