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
fix: filter unrecognized federated-media features instead of rejecting the payload (#4826)
[._.]/ Adam Eivy10c4af66cf65
diff --git a/docs/FEDERATED_MEDIA_PROVIDERS.md b/docs/FEDERATED_MEDIA_PROVIDERS.mdindex b440f2ce6e..69ba13ba5d 100644--- a/docs/FEDERATED_MEDIA_PROVIDERS.md+++ b/docs/FEDERATED_MEDIA_PROVIDERS.md@@ -425,8 +425,15 @@ which a per-capability boolean could not: both looked like an absent field.conditioning — for the same fail-closed reason `concurrency` and `byKind` readabsent as unknown: a provider that never shipped the handling rejects the fieldat submission, so inferring consent from silence turns every such render into a-400 the user cannot act on. A feature this build does not recognize is ignored-rather than invalidating the payload, so a newer provider stays readable.+400 the user cannot act on.++A consumer **filters** this list rather than validating it. A feature name it+does not recognize is carried through and simply never matched; one that is not+a short identifier token is dropped; a `features` value too malformed to filter+at all degrades to absent. None of those invalidate the status. That matters+more than it looks: a strict element schema would take a peer's ENTIRE status+offline over one string, turning "ignores a feature we have not heard of" into+"cannot read this peer" — the failure this list was introduced to prevent.Consumers ask `federatedMediaSupports(status, feature, capability)` rather thantesting the list inline, which is also where the overlap fallback to the legacydiff --git a/server/lib/federatedMediaWire.js b/server/lib/federatedMediaWire.jsindex d59b63c897..9aeb759a7f 100644--- a/server/lib/federatedMediaWire.js+++ b/server/lib/federatedMediaWire.js@@ -356,13 +356,31 @@ const federatedMediaQueueStatusSchema = z.object({// absent list reads as the wire-v1 baseline (see federatedMediaSupports).export const FEDERATED_MEDIA_FEATURES = Object.freeze(['lyrics', 'inputAssets']);-// Deliberately NOT a z.enum over FEDERATED_MEDIA_FEATURES: a Zod enum rejects-// the whole payload on an unknown member, so the day a provider adds a fourth-// feature every older consumer would fail to parse its entire status rather-// than ignoring one string it does not recognize — the same trap `byKind`-// avoids with partialRecord. The pattern still bounds the shape so the field-// cannot smuggle free-form text (and therefore PII) across the boundary.-const federatedMediaFeatureSchema = z.string().regex(/^[a-zA-Z][a-zA-Z0-9]{0,39}$/);+// A feature name is a short identifier token. Underscores and hyphens are in+// the alphabet even though this build's own vocabulary is camelCase: the point+// is to bound the shape so the field cannot smuggle free-form text (and+// therefore PII) across the boundary, not to force a naming style on a peer+// that may be several versions ahead of us.+const FEDERATED_MEDIA_FEATURE_RE = /^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/;++// FILTERS rather than validates, and deliberately NOT a z.enum over+// FEDERATED_MEDIA_FEATURES. Either a strict enum or a strict element schema+// would reject the WHOLE status payload over one string the consumer merely+// does not recognize, so the day a provider ships a feature named outside our+// expectations every older consumer would go from "ignores one feature" to+// "cannot read this peer at all" — the same trap `byKind` avoids with+// partialRecord, and the exact failure this list was introduced to prevent.+//+// Dropping an out-of-shape member is also what keeps the PII bound meaningful:+// prose never reaches storage, instead of a prose-carrying payload being+// rejected wholesale after we have already read it.+const federatedMediaFeaturesSchema = z.array(z.string()).max(256)+ .transform((features) => features.filter((feature) => FEDERATED_MEDIA_FEATURE_RE.test(feature)))+ // A `features` value that is not even a bounded array of strings degrades to+ // ABSENT — the undecidable wire-v1 baseline — rather than invalidating the+ // status. Not `[]`: an empty list is a peer positively denying every feature,+ // which is a stronger claim than a malformed field has earned.+ .catch(() => undefined);// The ONE place the "absent reads as false" reasoning lives (#4826). Every// consumer gate — server route, consumer service, client panel — asks through@@ -462,7 +480,7 @@ export const federatedMediaProviderStatusSchema = z.object({// Optional and additive; **absent reads as the wire-v1 baseline** (no lyrics,// no conditioning). Bounded well above this build's own vocabulary so a// provider that speaks more than we do still validates.- features: z.array(federatedMediaFeatureSchema).max(32).optional(),+ features: federatedMediaFeaturesSchema.optional(),kinds: z.array(mediaKindSchema).max(KNOWN_MEDIA_KINDS.length),queue: federatedMediaQueueStatusSchema,capabilities: z.array(federatedMediaCapabilitySchema).max(300),diff --git a/server/lib/federatedMediaWire.test.js b/server/lib/federatedMediaWire.test.jsindex 89a86c1d9a..9f571a1b7b 100644--- a/server/lib/federatedMediaWire.test.js+++ b/server/lib/federatedMediaWire.test.js@@ -238,12 +238,37 @@ describe('federated media status kind projection', () => {expect(federatedMediaSupports(parsed.data, 'holoProjection')).toBe(true);});- it('rejects a features entry shaped like free-form text', () => {- const bad = (features) => federatedMediaProviderStatusSchema- .safeParse(status({ features })).success;- expect(bad(['a private note about the user'])).toBe(false);- expect(bad([''])).toBe(false);- expect(bad(['x'.repeat(41)])).toBe(false);+ // A future feature this build has never heard of must survive the trip,+ // whatever its naming style — rejecting it would take the peer's WHOLE status+ // with it, which is the failure the list exists to prevent.+ it('carries a future feature name in any identifier style', () => {+ const parsed = federatedMediaProviderStatusSchema+ .parse(status({ features: ['lyrics', 'conditioning-images', 'input_assets'] }));+ expect(parsed.features).toEqual(['lyrics', 'conditioning-images', 'input_assets']);+ });++ // Dropping the member, not the payload: prose never reaches storage, and the+ // features the peer legitimately published still arrive.+ it('drops a features entry shaped like free-form text and keeps the rest', () => {+ const featuresOf = (features) => federatedMediaProviderStatusSchema+ .parse(status({ features })).features;+ expect(featuresOf(['lyrics', 'a private note about the user'])).toEqual(['lyrics']);+ expect(featuresOf(['lyrics', ''])).toEqual(['lyrics']);+ expect(featuresOf(['lyrics', 'x'.repeat(65)])).toEqual(['lyrics']);+ });++ // A field too malformed to filter reads as ABSENT — the undecidable wire-v1+ // baseline — never as `[]`, which would be the peer positively denying every+ // feature, a stronger claim than a broken field has earned. And never as a+ // failed parse, which would take the whole peer offline over one bad field.+ it('degrades an unusable features field to absent without failing the payload', () => {+ const parsed = (features) => federatedMediaProviderStatusSchema+ .safeParse(status({ features }));+ for (const bad of ['lyrics', ['lyrics', 123], Array.from({ length: 300 }, (_, i) => `f${i}`)]) {+ const result = parsed(bad);+ expect(result.success).toBe(true);+ expect(result.data.features).toBeUndefined();+ }});it('rejects a concurrency that claims no capacity at all', () => {