Skip to content

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

fix: preserve lyrics build denial messaging (#4850)

[._.]/ Adam Eivyb5ed3050cdde
diff --git a/server/lib/federatedMediaWire.js b/server/lib/federatedMediaWire.js
index 146a2c4ab5..971bbe7410 100644
--- a/server/lib/federatedMediaWire.js
+++ b/server/lib/federatedMediaWire.js
@@ -393,9 +393,9 @@ const federatedMediaFeaturesSchema = z.array(z.unknown()).max(256)
// previous build advertises that genuinely per-model fact in the capability
// block. A published list WINS over it outright rather than being OR'd with it
// — a peer that told us its whole vocabulary and left this feature out has
-// positively denied it. `decisive` records whether a FAILING legacy tell proves
-// the peer's build is old; the input-assets block is not decisive because a
-// healthy peer may simply have a text-only model configured.
+// positively denied it. The input-assets block cannot prove that the peer's
+// build is old because a healthy peer may simply have a text-only model
+// configured.
//
// Both gate identically; only a message that blames the BUILD may distinguish
// them. See federatedMediaDeniesFeature.
@@ -411,7 +411,7 @@ const FEDERATED_MEDIA_LEGACY_FEATURE_TELL = Object.freeze(Object.assign(Object.c
// its own array-excluding record guard, and a malformed `inputAssets: []`
// reading true here and false there is exactly the provider/consumer
// disagreement this helper exists to prevent.
- inputAssets: { tell: (capability) => isPlainObject(capability?.inputAssets), decisive: false },
+ inputAssets: { tell: (capability) => isPlainObject(capability?.inputAssets) },
}));
/**
@@ -445,9 +445,8 @@ export function federatedMediaDeclaresFeatures(status) {
* `federatedMediaSupports` flattens two different "no"s, because both must gate
* the same way: a peer that published a list and left the feature out has
* POSITIVELY denied it, while a peer that published no list may simply predate
- * the list — or, for an ambiguous feature, speak it and have nothing configured
- * that uses it. Only a MESSAGE may distinguish them, and telling a healthy peer
- * to update itself is worse than giving the generic remedy.
+ * the list. A present status with no list proves that a peer predates the
+ * status-root feature vocabulary for `lyrics`; an absent status does not.
*
* @param {object|null} status - a validated provider status payload
* @param {string} feature - a FEDERATED_MEDIA_FEATURES member
@@ -458,7 +457,7 @@ export function federatedMediaDeclaresFeatures(status) {
export function federatedMediaDeniesFeature(status, feature, capability = null) {
if (federatedMediaSupports(status, feature, capability)) return false;
return federatedMediaDeclaresFeatures(status)
- || FEDERATED_MEDIA_LEGACY_FEATURE_TELL[feature]?.decisive === true;
+ || (feature === 'lyrics' && isPlainObject(status));
}
// Strip unknown fields from peer responses before persisting or exposing them
diff --git a/server/lib/federatedMediaWire.test.js b/server/lib/federatedMediaWire.test.js
index da83f113c0..ef2bac11f5 100644
--- a/server/lib/federatedMediaWire.test.js
+++ b/server/lib/federatedMediaWire.test.js
@@ -393,15 +393,18 @@ describe('federatedMediaSupports', () => {
expect(federatedMediaDeclaresFeatures({ features: 'lyrics' })).toBe(false);
});
- // Gating is identical for both "no"s; only a MESSAGE may distinguish them,
- // and which missing signal indicts the peer's build differs per feature.
+ // Gating is identical for both "no"s; only a MESSAGE may distinguish them.
+ // A present status without a list proves a lyrics peer predates the status-root
+ // vocabulary, but not input-assets support because that signal is per-model.
it('attributes a denial to the build only where the missing signal proves it', () => {
const withBlock = capability({ inputAssets: { roles: ['initImage'] } });
// A published list that omits the feature is a positive denial either way.
expect(federatedMediaDeniesFeature({ features: [] }, 'lyrics', capability())).toBe(true);
expect(federatedMediaDeniesFeature({ features: ['lyrics'] }, 'inputAssets', withBlock)).toBe(true);
- // No list and no capability-level tell leaves the build version unknown.
- expect(federatedMediaDeniesFeature({}, 'lyrics', capability())).toBe(false);
+ // A present status without a list is an old-build denial for lyrics now that
+ // every supported lyrics peer publishes the status-root vocabulary.
+ expect(federatedMediaDeniesFeature({}, 'lyrics', capability())).toBe(true);
+ expect(federatedMediaDeniesFeature(null, 'lyrics', capability())).toBe(false);
// ...while an absent inputAssets block is ambiguous — a healthy peer may
// speak conditioning and simply have a text-only model configured, so it
// must not be told to update itself.
diff --git a/server/routes/music.js b/server/routes/music.js
index f36fc27683..f7b5afaf29 100644
--- a/server/routes/music.js
+++ b/server/routes/music.js
@@ -471,8 +471,8 @@ router.post('/generate', asyncHandler(async (req, res) => {
}
if (!federatedMediaSupports(resolved.status, 'lyrics', capability)) {
// `federatedMediaDeniesFeature` keeps message selection separate from
- // the shared fail-closed gate, so only a positively published feature
- // vocabulary is described as a build-level denial here.
+ // the shared fail-closed gate: a present pre-vocabulary status is also
+ // a build-level denial for lyrics, while a missing status is unknown.
throw new ServerError(
federatedMediaDeniesFeature(resolved.status, 'lyrics', capability)
? 'The selected peer runs a PortOS build that cannot carry lyrics to its provider. Update the peer, or render this track locally.'
diff --git a/server/routes/music.test.js b/server/routes/music.test.js
index 70ae4f90b8..7efd2a1c68 100644
--- a/server/routes/music.test.js
+++ b/server/routes/music.test.js
@@ -695,6 +695,23 @@ describe('music routes', () => {
expect(mediaQueue.enqueue).not.toHaveBeenCalled();
});
+ it('POST /generate identifies a peer build that omits the lyrics feature', async () => {
+ const peer = { id: '00000000-0000-4000-8000-000000000001', enabled: true };
+ remoteProvider.peers = [peer];
+ remoteProvider.resolve.mockResolvedValueOnce({
+ peer,
+ capability: remoteLyricCapability({ lyrics: true }),
+ status: { features: ['inputAssets'] },
+ });
+
+ const r = await request(app).post('/api/music/generate').send(remoteLyricRequest(peer));
+
+ expect(r.status).toBe(400);
+ expect(r.body.code).toBe('MEDIA_PROVIDER_LYRICS_UNSUPPORTED');
+ expect(r.body.error).toContain('Update the peer');
+ expect(mediaQueue.enqueue).not.toHaveBeenCalled();
+ });
+
it('POST /generate accepts lyrics from a peer that advertises only the status-root feature', async () => {
const peer = { id: '00000000-0000-4000-8000-000000000001', enabled: true };
remoteProvider.peers = [peer];