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 (codex): federation version bump + per-type PATCH validation
[._.]/ Adam Eivy7a8125bc2e37
diff --git a/server/lib/creativeCommissionValidation.js b/server/lib/creativeCommissionValidation.jsindex 01231ce2ac..2bdb5fb8c6 100644--- a/server/lib/creativeCommissionValidation.js+++ b/server/lib/creativeCommissionValidation.js@@ -181,11 +181,9 @@ export const creativeCommissionGenerationUpdateSchema = creativeCommissionGenera// `episodeCount` on a `video` one) is a 400 at the boundary rather than silently// dropped by the sanitizer. Runs only where the ability is known (the create// schema, whose `targetAbility` defaults to `video`).-function refineGenerationForAbility(data, ctx) {- if (!data || typeof data.generation !== 'object' || data.generation === null) return;- const ability = data.targetAbility || 'video';+function pushOffTypeKeyIssues(generation, ability, ctx) {const allowed = new Set(generationKeysForAbility(ability));- for (const key of Object.keys(data.generation)) {+ for (const key of Object.keys(generation)) {if (!allowed.has(key)) {ctx.addIssue({code: z.ZodIssueCode.custom,@@ -196,6 +194,25 @@ function refineGenerationForAbility(data, ctx) {}}+// Create path: `targetAbility` always resolves (defaults to `video`), so the+// generation keys are always checkable.+function refineGenerationForAbility(data, ctx) {+ if (!data || typeof data.generation !== 'object' || data.generation === null) return;+ pushOffTypeKeyIssues(data.generation, data.targetAbility || 'video', ctx);+}++// Update path: only check when the PATCH ALSO sets `targetAbility` — then the+// pairing is unambiguous (e.g. `{ targetAbility: 'image', generation: {+// targetDurationSeconds } }` is a mistake we can reject). When the PATCH omits+// `targetAbility`, the effective type is the stored record's, which the schema+// can't see; the adapter's `sanitizeGeneration` drops any off-type key as the+// backstop (a harmless no-op, not a corruption).+function refineGenerationForAbilityIfTargetPresent(data, ctx) {+ if (!data || typeof data.generation !== 'object' || data.generation === null) return;+ if (!data.targetAbility) return;+ pushOffTypeKeyIssues(data.generation, data.targetAbility, ctx);+}+// The LLM provider/model that PROCESSES the commission — i.e. the Creative// Director cognitive stages (treatment + production plan) the scheduled fire// runs as CoS agent tasks. `providerId`/`model` are the same shape the CD@@ -279,4 +296,5 @@ export const creativeCommissionUpdateSchema = z.object({// model: null }`), so no separate no-defaults update variant is needed.assignment: creativeCommissionAssignmentSchema.optional(),feedbackWindow: z.number().int().min(0).max(50).optional(),-}).refine((p) => Object.keys(p).length > 0, { message: 'patch must include at least one field' });+}).refine((p) => Object.keys(p).length > 0, { message: 'patch must include at least one field' })+ .superRefine(refineGenerationForAbilityIfTargetPresent);diff --git a/server/lib/schemaVersions.js b/server/lib/schemaVersions.jsindex 70b44b4058..aca0c6d956 100644--- a/server/lib/schemaVersions.js+++ b/server/lib/schemaVersions.js@@ -418,7 +418,14 @@ export const PORTOS_SCHEMA_VERSIONS = Object.freeze({// see syncWire's `creativeCommission` case) so only the owning machine fires the// cron (no double-run). Soft-delete tombstones; the FIRST incompatible// brief-shape change MUST bump this to 2.- creativeCommissions: 1,+ // v2 = per-output-type commissions (#2769): `targetAbility` widened past `video`+ // and `generation` became per-type (image `imageCount`, music `lengthSeconds`,+ // series `episodeCount`). A pre-#2769 (v1) peer's sanitizer only understands the+ // video generation shape, so it would silently drop those type-specific keys on+ // receive — and could push the video-shaped downgrade back via LWW. The bump+ // gates mixed-version transfers of this category so a v1 peer never mangles a v2+ // brief (compareSchemaVersions marks a v2 sender "ahead" of a v1 receiver).+ creativeCommissions: 2,// v1 = standalone media-library federation (#1566). NOT a record kind — it's// the wire contract for the library-level asset manifest a full-sync peer// advertises at GET /api/peer-sync/library-manifest. The receiver-pull sweepdiff --git a/server/routes/creativeCommissions.test.js b/server/routes/creativeCommissions.test.jsindex 30c1e93685..20d0c71c7f 100644--- a/server/routes/creativeCommissions.test.js+++ b/server/routes/creativeCommissions.test.js@@ -137,6 +137,31 @@ describe('PATCH /api/creative-commission/:id', () => {expect(res.status).toBe(400);expect(svc.updateCommission).not.toHaveBeenCalled();});++ it('rejects a PATCH whose generation param conflicts with an explicit targetAbility (#2769)', async () => {+ // targetAbility is in the patch, so the off-type key is checkable → 400.+ const res = await request(buildApp()).patch('/api/creative-commission/commission-1')+ .send({ targetAbility: 'image', generation: { targetDurationSeconds: 10 } });+ expect(res.status).toBe(400);+ expect(svc.updateCommission).not.toHaveBeenCalled();+ });++ it('accepts a PATCH that switches type and sets that type\'s params (#2769)', async () => {+ svc.updateCommission.mockResolvedValue({ id: 'commission-1', targetAbility: 'image' });+ const res = await request(buildApp()).patch('/api/creative-commission/commission-1')+ .send({ targetAbility: 'image', generation: { imageCount: 3 } });+ expect(res.status).toBe(200);+ expect(svc.updateCommission).toHaveBeenCalledWith('commission-1', { targetAbility: 'image', generation: { imageCount: 3 } });+ });++ it('accepts a generation-only PATCH without targetAbility (sanitizer backstops off-type keys) (#2769)', async () => {+ // No targetAbility in the patch → the effective type is the stored record's,+ // which the schema can't see; the adapter drops any off-type key on sanitize.+ svc.updateCommission.mockResolvedValue({ id: 'commission-1' });+ const res = await request(buildApp()).patch('/api/creative-commission/commission-1')+ .send({ generation: { imageCount: 3 } });+ expect(res.status).toBe(200);+ });});describe('POST /api/creative-commission/:id/run', () => {