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
[Improvement: PortOS] Implement Next Planned Feature (#208)
[._.]/ Adam Eivyc68f38d09b5a
diff --git a/PLAN.md b/PLAN.mdindex ef3048dab9..a585ba8adb 100644--- a/PLAN.md+++ b/PLAN.md@@ -16,7 +16,7 @@ For project goals, see [GOALS.md](./GOALS.md). For completed work, see [DONE.md]The pipeline now has multi-frame evaluation, auto-accept watchdog, and a cheap smoke fixture (see DONE.md 2026-05-06). The first real E2E run surfaced these remaining targets:-- [ ] **i2v continuity fidelity.** `useContinuationFromPrior: true` feeds the prior scene's last frame as `sourceImagePath` but doesn't pin `imageStrength`. Renders sometimes drift hard from the seed (a "blue ball" continuation generates a totally new scene that loosely starts from the seed). `imageStrength` is already threaded through `videoGen/local.js`; surface it as a per-scene knob in the treatment schema (default ~0.85 for continuation scenes, lower if the prompt deliberately changes the subject) and pipe it through `sceneRunner.params`.+- [x] **i2v continuity fidelity.** `useContinuationFromPrior: true` feeds the prior scene's last frame as `sourceImagePath` but doesn't pin `imageStrength`. Renders sometimes drift hard from the seed (a "blue ball" continuation generates a totally new scene that loosely starts from the seed). `imageStrength` is already threaded through `videoGen/local.js`; surface it as a per-scene knob in the treatment schema (default ~0.85 for continuation scenes, lower if the prompt deliberately changes the subject) and pipe it through `sceneRunner.params`.- [ ] **Audio continuity across scenes.** mlx-video-with-audio generates audio per-clip; concatenated scenes have audible cuts at scene boundaries. Either render scenes silently and add a single backing audio pass at stitch time, or apply a short crossfade in `videoTimeline/local.js#buildFfmpegArgs` (already does video crossfades — extend to audio with `acrossfade`).- [ ] **Duplicate evaluator spawn dedup.** During the long E2E run, server logs showed `Task already being spawned, skipping duplicate` followed seconds later by a *second* agent spawning for the exact same task id. The CoS task lane logic ends up double-acquiring. Reproduce in a unit test against `taskSchedule` / `agentLifecycle` and fix the de-dup window.- [ ] **Render slowness on long sessions.** Per-scene render time degraded from ~3.5 min (early) to 10–30 min (late) within one project — likely accumulated listeners + queue races. Profile after sustained use; the round-22 dedup work probably already helps; verify.diff --git a/client/src/components/creative-director/TreatmentTab.jsx b/client/src/components/creative-director/TreatmentTab.jsxindex 87d2f0b396..777c381b55 100644--- a/client/src/components/creative-director/TreatmentTab.jsx+++ b/client/src/components/creative-director/TreatmentTab.jsx@@ -37,6 +37,7 @@ export default function TreatmentTab({ project }) {</div><span className="text-xs text-port-text-muted">{s.durationSeconds}s {s.useContinuationFromPrior ? '· continues' : s.sourceImageFile ? '· from image' : '· text-to-video'}+ {typeof s.imageStrength === 'number' && ` · str ${s.imageStrength}`}</span></div><pre className="whitespace-pre-wrap text-xs text-port-text-muted font-mono mt-2">{s.prompt}</pre>diff --git a/data.sample/prompts/stages/cd-evaluate.md b/data.sample/prompts/stages/cd-evaluate.mdindex 65f633e1c6..fce2dea628 100644--- a/data.sample/prompts/stages/cd-evaluate.md+++ b/data.sample/prompts/stages/cd-evaluate.md@@ -23,6 +23,8 @@ Your ONLY job is to evaluate a freshly-rendered scene and decide whether it work- Render prompt: {{scene.promptJson}}- Render: `{{render.width}}×{{render.height}}`, {{render.numFrames}} frames @ {{render.fps}}fps- Strategy: {{scene.strategy}}+{{#scene.hasImageStrength}}- Image strength: {{scene.imageStrength}} (0–1; higher = stick closer to source image){{/scene.hasImageStrength}}+{{^scene.hasImageStrength}}- Image strength: default (continuation: 0.85; otherwise renderer default){{/scene.hasImageStrength}}- Retry count: {{scene.retryCount}} (max 3)- Rendered video: `/data/videos/{{scene.renderedJobId}}.mp4`{{#multiFrame}}@@ -83,7 +85,7 @@ Content-Type: application/json```Do NOT issue this POST for the retry or failed branches below — rejected renders should not enter the collection.-**If the render misses the mark and retries are still available** (`retryCount < 3`): tweak the prompt and request a re-render. The server will run the new render and then send you back here for another evaluation.+**If the render misses the mark and retries are still available** (`retryCount < 3`): tweak the prompt and request a re-render. The server will run the new render and then send you back here for another evaluation. You may also adjust `imageStrength` (0.0–1.0) on i2v scenes — drop it (e.g. 0.85 → 0.6) when the seed image is dominating and the prompt isn't expressed; raise it (e.g. → 0.95) when continuation drifted too far from the prior scene. Omit `imageStrength` from the PATCH to leave it unchanged.```json{"status": "pending",diff --git a/data.sample/prompts/stages/cd-treatment.md b/data.sample/prompts/stages/cd-treatment.mdindex 59548c3346..9455ef3778 100644--- a/data.sample/prompts/stages/cd-treatment.md+++ b/data.sample/prompts/stages/cd-treatment.md@@ -34,7 +34,8 @@ The user did not supply a story. Invent one that suits the style spec and target1. Design a story arc that fits ~{{project.targetDurationSeconds}}s of total runtime. Think in scenes that are 1–10 seconds each (most should be 4–6s; reserve short ones for cuts and long ones for held shots).2. Each scene should have a clear visual intent and a render prompt that incorporates the style spec.3. Decide for each scene whether it continues from the previous scene's last frame (`useContinuationFromPrior: true`) or starts from a new image (`useContinuationFromPrior: false`, optionally with a `sourceImageFile` basename if you want to seed from a specific gallery image). Scene 1 either uses the project starting image (if provided — copy its filename into `sourceImageFile`) or starts as text-to-video.-4. Don't pad with filler; if the natural arc is shorter than the target, that's fine — produce fewer scenes.+4. Optionally set `imageStrength` (0.0–1.0) on i2v scenes (continuation OR seeded) to control how strongly the source image conditions the render. Higher values stick closer to the source (good for tight continuation); lower values give the model more freedom (good when the prompt deliberately diverges from the seed). Omit (or set null) to accept the default — continuation scenes default to 0.85, other scenes use the renderer's built-in default.+5. Don't pad with filler; if the natural arc is shorter than the target, that's fine — produce fewer scenes.## Output contract@@ -56,9 +57,10 @@ Content-Type: application/json"negativePrompt": "<optional>","durationSeconds": 5,"useContinuationFromPrior": false,- "sourceImageFile": {{startingImageFileLiteral}}+ "sourceImageFile": {{startingImageFileLiteral}},+ "imageStrength": null},- { "sceneId": "scene-2", "order": 1, ..., "useContinuationFromPrior": true }+ { "sceneId": "scene-2", "order": 1, ..., "useContinuationFromPrior": true, "imageStrength": 0.85 }]}```diff --git a/server/lib/creativeDirectorPrompts.js b/server/lib/creativeDirectorPrompts.jsindex d5fac75de3..4628d70292 100644--- a/server/lib/creativeDirectorPrompts.js+++ b/server/lib/creativeDirectorPrompts.js@@ -105,6 +105,11 @@ function buildEvaluateView(project, scene) {: (scene.sourceImageFile? `seeded from image \`${scene.sourceImageFile}\``: 'text-to-video');+ // Surface the per-scene imageStrength so the evaluator can see what the+ // current setting was (and whether to nudge it on retry). Continuation+ // scenes default to 0.85 in sceneRunner; for the prompt we show the+ // explicit value (if any) so the agent can reason about the actual knob.+ const hasImageStrength = typeof scene.imageStrength === 'number';return {project: buildProjectView(project),aspect,@@ -119,6 +124,8 @@ function buildEvaluateView(project, scene) {nextRetryCount,positionLabel,strategy,+ hasImageStrength,+ imageStrength: hasImageStrength ? scene.imageStrength : null,},render: renderParams,multiFrame: frames.length >= 2,diff --git a/server/lib/creativeDirectorPrompts.test.js b/server/lib/creativeDirectorPrompts.test.jsindex f8e9ca0d1f..0b1926fdc7 100644--- a/server/lib/creativeDirectorPrompts.test.js+++ b/server/lib/creativeDirectorPrompts.test.js@@ -181,3 +181,32 @@ describe('buildEvaluatePrompt — scene metadata', () => {expect(out).toContain('Strategy: seeded from image `hero.png`');});});++describe('buildEvaluatePrompt — imageStrength surfacing', () => {+ it('shows the explicit imageStrength when the scene has one set', async () => {+ const out = await buildEvaluatePrompt(baseProject, {+ ...baseScene,+ evaluationFrames: [],+ imageStrength: 0.6,+ });+ expect(out).toContain('Image strength: 0.6');+ expect(out).not.toContain('Image strength: default');+ });++ it('falls back to "default" wording when imageStrength is unset', async () => {+ const out = await buildEvaluatePrompt(baseProject, {+ ...baseScene,+ evaluationFrames: [],+ });+ expect(out).toContain('Image strength: default');+ });++ it('treats null imageStrength like unset (use defaults)', async () => {+ const out = await buildEvaluatePrompt(baseProject, {+ ...baseScene,+ evaluationFrames: [],+ imageStrength: null,+ });+ expect(out).toContain('Image strength: default');+ });+});diff --git a/server/lib/validation.js b/server/lib/validation.jsindex 4e75a7efca..8afaafea1d 100644--- a/server/lib/validation.js+++ b/server/lib/validation.js@@ -872,6 +872,13 @@ export const creativeDirectorSceneSchema = z.object({durationSeconds: z.number().min(1).max(10),useContinuationFromPrior: z.boolean().default(false),sourceImageFile: safeBasename.nullable().optional(),+ // How strongly the source image conditions the i2v render. 1.0 = preserve+ // source closely; lower values give the model more freedom to drift.+ // Null lets the runtime pick — `sceneRunner.js` applies 0.85 as the+ // default for continuation scenes (anchors the next clip to the prior+ // last-frame so renders don't drift hard), and leaves it null otherwise+ // (mlx_video / dgrauet uses its own default).+ imageStrength: z.number().min(0).max(1).nullable().optional(),status: z.enum(SCENE_STATUSES).default('pending'),retryCount: z.number().int().min(0).max(10).default(0),renderedJobId: z.string().max(64).nullable().optional(),@@ -899,6 +906,10 @@ export const creativeDirectorSceneUpdateSchema = z.object({retryCount: z.number().int().min(0).max(10).optional(),renderedJobId: z.string().max(64).nullable().optional(),prompt: z.string().min(1).max(8000).optional(),+ // Evaluator may adjust per-scene strength on retry — e.g. drop from+ // 0.85 → 0.6 when the seed image is too dominant or raise toward 1.0+ // when continuation drifted.+ imageStrength: z.number().min(0).max(1).nullable().optional(),evaluation: z.object({score: z.number().min(0).max(1).optional(),notes: z.string().max(2000).optional(),diff --git a/server/services/creativeDirector/sceneRunner.js b/server/services/creativeDirector/sceneRunner.jsindex bffcc4945a..99e8da97c9 100644--- a/server/services/creativeDirector/sceneRunner.js+++ b/server/services/creativeDirector/sceneRunner.js@@ -41,6 +41,19 @@ import { enqueueEvaluateTask } from './agentBridge.js';const MAX_SCENE_RETRIES = 3;+// Default image strength when an i2v continuation scene has no explicit+// per-scene `imageStrength`. Anchors the next clip to the prior last-frame+// hard enough to preserve scene geometry (subject, camera, palette) while+// still allowing motion. Lower values let the model drift; higher values+// can cause near-still frames. 0.85 lands near the sweet spot in practice.+export const DEFAULT_CONTINUATION_IMAGE_STRENGTH = 0.85;++export function resolveImageStrength({ explicit, isContinuation }) {+ if (explicit != null) return explicit;+ if (isContinuation) return DEFAULT_CONTINUATION_IMAGE_STRENGTH;+ return null;+}+/*** Kick off a render for a single scene. Returns the jobId; the caller does* not need to await completion — the listener installed here will spawn@@ -163,6 +176,17 @@ export async function runSceneRender(project, scene) {durationSeconds: scene.durationSeconds,});+ // Resolve effective image strength. Continuation renders that don't pin a+ // strength tend to drift hard from the seed (a "blue ball" continuation+ // generates a totally new scene that loosely starts from the seed) — so+ // anchor i2v continuation scenes at 0.85 by default. Explicit per-scene+ // values from the treatment / evaluator override the default; null+ // outside continuation lets the renderer apply its own default.+ const effectiveImageStrength = resolveImageStrength({+ explicit: scene.imageStrength,+ isContinuation: continuationSourceFromExtract && !!sourceImagePath,+ });+const params = {pythonPath,prompt: scene.prompt,@@ -177,6 +201,7 @@ export async function runSceneRender(project, scene) {tiling: 'auto',sourceImagePath,mode: sourceImagePath ? 'image' : 'text',+ imageStrength: effectiveImageStrength,// Smoke-test / dev knob: skips the mlx_video audio-gen pass to cut// wall-clock per scene roughly in half. Project-level so every scene// in the project inherits the same setting.diff --git a/server/services/creativeDirector/sceneRunner.test.js b/server/services/creativeDirector/sceneRunner.test.jsnew file mode 100644index 0000000000..25d9095e70--- /dev/null+++ b/server/services/creativeDirector/sceneRunner.test.js@@ -0,0 +1,101 @@+import { describe, it, expect } from 'vitest';+import {+ resolveImageStrength,+ DEFAULT_CONTINUATION_IMAGE_STRENGTH,+} from './sceneRunner.js';+import {+ creativeDirectorSceneSchema,+ creativeDirectorSceneUpdateSchema,+} from '../../lib/validation.js';++const baseScene = {+ sceneId: 'scene-1',+ order: 0,+ intent: 'cat enters frame',+ prompt: 'a cat walks into view',+ durationSeconds: 4,+};++describe('resolveImageStrength', () => {+ it('returns explicit value when set', () => {+ expect(resolveImageStrength({ explicit: 0.6, isContinuation: true })).toBe(0.6);+ expect(resolveImageStrength({ explicit: 0.6, isContinuation: false })).toBe(0.6);+ });++ it('returns 0 when explicitly set to 0 (does not treat as falsy)', () => {+ // Bug guard: a naive `explicit || 0.85` would clobber an explicit 0.+ expect(resolveImageStrength({ explicit: 0, isContinuation: true })).toBe(0);+ });++ it('defaults continuation scenes to 0.85 when no explicit value', () => {+ expect(resolveImageStrength({ explicit: null, isContinuation: true }))+ .toBe(DEFAULT_CONTINUATION_IMAGE_STRENGTH);+ expect(resolveImageStrength({ explicit: undefined, isContinuation: true }))+ .toBe(DEFAULT_CONTINUATION_IMAGE_STRENGTH);+ });++ it('returns null for non-continuation scenes with no explicit value', () => {+ expect(resolveImageStrength({ explicit: null, isContinuation: false })).toBe(null);+ });++ it('exports 0.85 as the documented continuation default', () => {+ expect(DEFAULT_CONTINUATION_IMAGE_STRENGTH).toBe(0.85);+ });+});++describe('creativeDirectorSceneSchema — imageStrength', () => {+ it('accepts an in-range imageStrength', () => {+ const result = creativeDirectorSceneSchema.safeParse({ ...baseScene, imageStrength: 0.7 });+ expect(result.success).toBe(true);+ expect(result.data.imageStrength).toBe(0.7);+ });++ it('accepts boundary values 0 and 1', () => {+ expect(creativeDirectorSceneSchema.safeParse({ ...baseScene, imageStrength: 0 }).success).toBe(true);+ expect(creativeDirectorSceneSchema.safeParse({ ...baseScene, imageStrength: 1 }).success).toBe(true);+ });++ it('accepts null imageStrength (use default behavior)', () => {+ const result = creativeDirectorSceneSchema.safeParse({ ...baseScene, imageStrength: null });+ expect(result.success).toBe(true);+ expect(result.data.imageStrength).toBe(null);+ });++ it('accepts an omitted imageStrength', () => {+ const result = creativeDirectorSceneSchema.safeParse({ ...baseScene });+ expect(result.success).toBe(true);+ });++ it('rejects values above 1', () => {+ expect(creativeDirectorSceneSchema.safeParse({ ...baseScene, imageStrength: 1.5 }).success).toBe(false);+ });++ it('rejects values below 0', () => {+ expect(creativeDirectorSceneSchema.safeParse({ ...baseScene, imageStrength: -0.1 }).success).toBe(false);+ });+});++describe('creativeDirectorSceneUpdateSchema — imageStrength', () => {+ it('lets the evaluator adjust imageStrength on retry', () => {+ const result = creativeDirectorSceneUpdateSchema.safeParse({+ status: 'pending',+ retryCount: 1,+ imageStrength: 0.6,+ });+ expect(result.success).toBe(true);+ expect(result.data.imageStrength).toBe(0.6);+ });++ it('lets the evaluator clear imageStrength back to default behavior', () => {+ const result = creativeDirectorSceneUpdateSchema.safeParse({+ status: 'pending',+ imageStrength: null,+ });+ expect(result.success).toBe(true);+ expect(result.data.imageStrength).toBe(null);+ });++ it('rejects out-of-range adjustments', () => {+ expect(creativeDirectorSceneUpdateSchema.safeParse({ imageStrength: 2 }).success).toBe(false);+ });+});