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): preserve forward-unknown featureAreas ids instead of stripping them
[._.]/ Adam Eivyecaa5e14cd60
diff --git a/client/src/components/goals/GoalDetailPanel.test.jsx b/client/src/components/goals/GoalDetailPanel.test.jsxindex eb82bdecf2..ee87bfdf18 100644--- a/client/src/components/goals/GoalDetailPanel.test.jsx+++ b/client/src/components/goals/GoalDetailPanel.test.jsx@@ -190,11 +190,11 @@ describe('GoalDetailPanel Daily Driver feature-area override (issue #2679)', ());});- it('omits featureAreas from the payload when the override was not touched (forward-compat)', async () => {- // Editing an unrelated field must NOT round-trip featureAreas — otherwise a- // goal synced from a newer federated peer carrying a forward-unknown area id- // would 400 against the strict updateGoalInputSchema enum. Omitting the key- // lets the service preserve the stored value (unknown ids included).+ it('preserves forward-unknown ids when editing an unrelated field (no data loss on federated installs)', async () => {+ // A goal synced from a newer peer carries a feature-area id this install+ // doesn't know. Editing an unrelated field must round-trip that id intact —+ // dropping it would LWW-propagate a truncated array back and erase the newer+ // peer's config. The (non-strict) server schema accepts the unknown id.await renderPanel({ ...baseGoal, featureAreas: ['someFutureAreaFromANewerPeer'] });fireEvent.click(screen.getByText('Edit'));// Change only the title; never touch the feature-area buttons.@@ -205,15 +205,14 @@ describe('GoalDetailPanel Daily Driver feature-area override (issue #2679)', ()await Promise.resolve();});const [, payload] = api.updateGoal.mock.calls[0];- expect(payload).not.toHaveProperty('featureAreas');+ expect(payload.featureAreas).toEqual(['someFutureAreaFromANewerPeer']);expect(payload.title).toBe('Master the craft, revised');});- it('strips locally-unknown ids when the override IS changed', async () => {- // A goal carries a forward-unknown id plus a known one; the user toggles a- // known area, so the override is "changed" and gets sent — but the unknown- // id (invisible in this install's UI) must be stripped so the update still- // validates.+ it('preserves forward-unknown ids when the override IS changed', async () => {+ // A goal carries a forward-unknown id plus a known one; the user toggles+ // another known area. The unknown id (invisible in this install's UI) must+ // ride along untouched so it is never erased across federation.await renderPanel({ ...baseGoal, featureAreas: ['someFutureAreaFromANewerPeer', 'universes'] });fireEvent.click(screen.getByText('Edit'));// Toggle a different known area on → override changed.@@ -223,7 +222,16 @@ describe('GoalDetailPanel Daily Driver feature-area override (issue #2679)', ()await Promise.resolve();});const [, payload] = api.updateGoal.mock.calls[0];- expect(payload.featureAreas).toEqual(['universes', 'tribe']);- expect(payload.featureAreas).not.toContain('someFutureAreaFromANewerPeer');+ expect(payload.featureAreas).toEqual(['someFutureAreaFromANewerPeer', 'universes', 'tribe']);+ });++ it('shows the category-default hint for an override of only forward-unknown ids', async () => {+ // Only forward-unknown ids selected → no visible button is active and the+ // Daily Driver falls back to the category default at read time, so the hint+ // must be shown (gating on known-selection, not raw array length).+ await renderPanel({ ...baseGoal, featureAreas: ['someFutureAreaFromANewerPeer'] });+ fireEvent.click(screen.getByText('Edit'));+ expect(screen.getByText(/Default \(Mastery\):/)).toBeTruthy();+ expect(screen.getByText(/Daily POST, Memory/)).toBeTruthy();});});diff --git a/client/src/components/goals/GoalEditForm.jsx b/client/src/components/goals/GoalEditForm.jsxindex 86b753e91f..9662c3c387 100644--- a/client/src/components/goals/GoalEditForm.jsx+++ b/client/src/components/goals/GoalEditForm.jsx@@ -21,8 +21,15 @@ export default function GoalEditForm({toggleFeatureArea, parentOptions, saveEdit, onCancel}) {const selectedAreas = form.featureAreas || [];- // Category default shown (greyed) when no per-goal override is set, so the- // user sees which areas the Daily Driver will deep-link to by default.+ // Gate the greyed category-default hint on whether any LOCALLY-KNOWN area is+ // selected — not on raw array length. A version-skewed goal can carry only+ // forward-unknown ids (from a newer peer); those render no visible button and+ // getGoalFeatureAreas filters them, so the Daily Driver still falls back to the+ // category default. Keying on length would hide the hint in that case and lie+ // about the actual behavior (issue #2679).+ const hasKnownSelection = selectedAreas.some(id => FEATURE_AREAS[id]);+ // Category default shown (greyed) when no known override is set, so the user+ // sees which areas the Daily Driver will deep-link to by default.const categoryDefaultLabels = (GOAL_CATEGORY_FEATURE_MAP[form.category] || []).map(id => FEATURE_AREAS[id]?.label).filter(Boolean);@@ -205,7 +212,7 @@ export default function GoalEditForm({);})}</div>- {selectedAreas.length === 0 && (+ {!hasKnownSelection && (<p className="text-[10px] text-gray-600 mt-1">Default ({CATEGORY_CONFIG[form.category]?.label || form.category}):{' '}{categoryDefaultLabels.length > 0 ? categoryDefaultLabels.join(', ') : 'none for this category'}diff --git a/client/src/hooks/useGoalDetail.js b/client/src/hooks/useGoalDetail.jsindex d0d285ae31..067a6769cc 100644--- a/client/src/hooks/useGoalDetail.js+++ b/client/src/hooks/useGoalDetail.js@@ -1,7 +1,6 @@import { useState, useEffect } from 'react';import * as api from '../services/api';import { MAX_TAGS, MAX_TAG_LENGTH } from '../components/goals/goalConstants';-import { FEATURE_AREA_IDS } from '../lib/goalFeatureMap';// State + handlers backing GoalDetailPanel. Extracted so the panel can stay a// thin composition shell; behavior is identical to the prior inline logic.@@ -69,29 +68,17 @@ export function useGoalDetail({ goal, allGoals, onClose, onRefresh }) {};const saveEdit = async () => {- // Forward-compat across federated installs (issue #2679): a goal synced- // from a newer peer can carry a `featureAreas` id this install doesn't know- // yet, and `updateGoalInputSchema`'s strict enum would 400 if we sent it.- // So only include `featureAreas` in the payload when the user actually- // changed the override — when unchanged, omit it and let the service- // preserve the stored value (unknown ids included). On the changed path,- // strip to locally-known ids so the update always validates.- const { featureAreas, ...rest } = form;- const original = goal.featureAreas || [];- const current = featureAreas || [];- const featureAreasChanged =- current.length !== original.length ||- current.some((id, i) => id !== original[i]);- const payload = {- ...rest,+ // `form.featureAreas` carries the full override, INCLUDING any forward-unknown+ // ids preserved from `startEdit` (issue #2679). The multi-select only toggles+ // ids this install knows; unknown ids ride along untouched. We send the whole+ // array so those unknown ids are never dropped — the (now non-strict) server+ // schema accepts them and `getGoalFeatureAreas` filters them at read time.+ await api.updateGoal(goal.id, {+ ...form,parentId: form.parentId || null,targetDate: form.targetDate || null,timeBlockConfig: form.timeBlockConfig || null- };- if (featureAreasChanged) {- payload.featureAreas = current.filter(id => FEATURE_AREA_IDS.includes(id));- }- await api.updateGoal(goal.id, payload);+ });setEditing(false);onRefresh();};diff --git a/server/lib/identityValidation.js b/server/lib/identityValidation.jsindex 24e12f8584..86bfcd155d 100644--- a/server/lib/identityValidation.js+++ b/server/lib/identityValidation.js@@ -1,10 +1,21 @@import { z } from 'zod';-import { FEATURE_AREA_IDS } from './goalFeatureMap.js';// Per-goal feature-area override (issue #2666): an ordered list of feature-area// ids the Daily Driver deep-links to for this goal, overriding the category// default. Absent/empty → the goal falls back to its category's default map.-const featureAreasSchema = z.array(z.enum(FEATURE_AREA_IDS)).max(FEATURE_AREA_IDS.length);+//+// Forward-compat (issue #2679): this is deliberately NOT `z.enum(FEATURE_AREA_IDS)`.+// Goals sync between federated peers as whole records (no schema-version gate),+// so an older install can receive — and store, via dataSync's direct file write+// which bypasses this route validation — a goal carrying a feature-area id a+// newer peer introduced. If the edit path rejected those ids, saving that goal+// would 400; if the client stripped them, the truncated array would LWW-propagate+// back and erase the newer peer's config. So we accept any non-empty string id+// here and let `getGoalFeatureAreas` filter ids this install doesn't know at read+// time — unknown ids are preserved in storage, ignored when resolving areas. The+// cap stays generous (not tied to this install's FEATURE_AREA_IDS.length) so a+// goal pinning more areas than this version knows still validates.+const featureAreasSchema = z.array(z.string().min(1)).max(64);export const sectionStatusEnum = z.enum(['active', 'pending', 'unavailable']);