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
address review: gate reference plans across peers + constrain stepId (#2773)
[._.]/ Adam Eivy369d3db0fdc2
diff --git a/server/lib/creativeDirectorValidation.js b/server/lib/creativeDirectorValidation.jsindex 5364442dee..ac284e1e1e 100644--- a/server/lib/creativeDirectorValidation.js+++ b/server/lib/creativeDirectorValidation.js@@ -261,7 +261,13 @@ export const creativeDirectorSceneUpdateSchema = z.object({// ---------------------------------------------------------------------------export const creativeDirectorPlanStepSchema = z.object({- stepId: z.string().min(1).max(64),+ // Word chars + hyphen only — this MUST stay in lockstep with the cross-step+ // result-reference grammar in planAdvance.js (`{{steps.<stepId>.result.<key>}}`,+ // stepId group `[\w-]+`, #2773). A looser stepId here would let the planner mint+ // an id that a downstream step can't reference, with no safe re-plan recovery+ // (the producer already ran, and renaming the step re-runs it). Rejecting at+ // plan-author time surfaces a 4xx the planner fixes per the cd-plan prompt.+ stepId: z.string().min(1).max(64).regex(/^[\w-]+$/, 'stepId must contain only word characters or hyphens'),toolName: z.string().min(1).max(64),// Free-form tool args — each tool re-validates against its own Zod schema at// dispatch, so the plan gate stays permissive (an over-strict gate here woulddiff --git a/server/lib/schemaVersions.js b/server/lib/schemaVersions.jsindex fd6a459eef..e5e6408dc0 100644--- a/server/lib/schemaVersions.js+++ b/server/lib/schemaVersions.js@@ -344,15 +344,19 @@ export const PORTOS_SCHEMA_VERSIONS = Object.freeze({// rewrite is needed — existing legacy projects simply lack both keys and the// advance loop treats an absent key identically to null (falsy → legacy video// flow); migration 175 only seeds the new `cd-plan` prompt stage.- // NOT bumped to 3 for cross-step result references (`{{steps.<id>.result.<key>}}`- // in `plan.steps[].args`, #2773): the trigger for a bump is a project-SHAPE- // change a plan-unaware sanitizer would strip on round-trip. References add no- // field — they are string VALUES inside `args`, already `z.record(z.any())`,- // which a v2 sanitizer preserves verbatim (no strip, no LWW loss). A v2 peer- // merely can't RESOLVE the syntax at execution time, and schema-versioning- // gates payload integrity, not execution parity across rolling upgrades (a v2- // peer can't run any v3-added behavior — that's inherent, not a corruption).- creativeDirectorProjects: 2,+ // v3 = cross-step result references (`{{steps.<stepId>.result.<key>}}` inside+ // `plan.steps[].args`, #2773). Unlike v2 this is NOT about a sanitizer+ // round-trip strip (the refs are free-form `args` strings a v2 sanitizer+ // preserves verbatim) — it's an EXECUTION-semantics break: only the v3 advance+ // loop resolves the syntax. A v2 peer that receives a running reference-plan and+ // then boot-recovers it (`recoverInFlightProjects` resets the step to pending)+ // would dispatch the literal `{{…}}` as e.g. a seriesId, fail/re-plan, and+ // LWW-push the damaged plan back onto the v3 peer — corrupting the newer peer's+ // healthy project. Bumping makes the v2 receiver reject the ahead-version+ // transfer (per-category 412) until it upgrades, so it never mis-executes a+ // syntax it can't resolve. No record rewrite needed — reference-free projects+ // are unchanged; the bump only gates cross-version CD-project sync.+ creativeDirectorProjects: 3,// v1 = Mood boards (PostgreSQL `mood_boards`) federated via the per-record// peer-sync push pipeline (record kind `moodBoard`, sync category `moodBoards`,// #1564). Same posture as `creativeDirectorProjects` above: a brand-NEW synceddiff --git a/server/routes/creativeDirector.test.js b/server/routes/creativeDirector.test.jsindex a8eae0aa5a..506666af2b 100644--- a/server/routes/creativeDirector.test.js+++ b/server/routes/creativeDirector.test.js@@ -601,6 +601,29 @@ describe('creativeDirector routes', () => {});});+ describe('PATCH /:id/plan — stepId grammar (#2773)', () => {+ const validStep = { stepId: 'create-series', toolName: 'pipeline_createSeries', args: { name: 'Nova' }, dependsOn: [] };++ it('accepts a word/hyphen stepId', async () => {+ cdService.setPlan.mockResolvedValue({ id: 'cd-1', plan: { steps: [validStep] } });+ const r = await request(app).patch('/api/creative-director/cd-1/plan').send({ steps: [validStep] });+ expect(r.status).toBe(200);+ expect(cdService.setPlan).toHaveBeenCalled();+ });++ it('400s on a stepId with a dot (unreferenceable by the result-reference grammar)', async () => {+ const r = await request(app).patch('/api/creative-director/cd-1/plan')+ .send({ steps: [{ ...validStep, stepId: 'create.series' }] });+ expect(r.status).toBe(400);+ });++ it('400s on a stepId with a space', async () => {+ const r = await request(app).patch('/api/creative-director/cd-1/plan')+ .send({ steps: [{ ...validStep, stepId: 'create series' }] });+ expect(r.status).toBe(400);+ });+ });+describe('POST /:id/plan/step/:stepId', () => {const projectWithStep = (status = 'rendering') => ({id: 'cd-1', status, directive: { goal: 'x' },