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

address review (codex): gate universe-tag friendlification on the from-universe marker so a user's universe:* tag is never misclassified as legacy

[._.]/ Adam Eivy303a1519cfbd
diff --git a/server/lib/catalogUniverseTags.js b/server/lib/catalogUniverseTags.js
index 56ebab475c..96dcf3bf34 100644
--- a/server/lib/catalogUniverseTags.js
+++ b/server/lib/catalogUniverseTags.js
@@ -75,6 +75,17 @@ export function universeIdFromLegacyTag(tag) {
*/
export function friendlifyUniverseTags(tags, nameForId, canonicalKey) {
const input = Array.isArray(tags) ? tags : [];
+
+ // GATE on the `from-universe` marker: the backfill ALWAYS stamped the marker
+ // alongside `universe:<id>`, so its presence is what identifies a machine-
+ // tagged row. Without it, a `universe:<anything>` tag is a legitimate USER
+ // tag (e.g. a thematic `universe:marvel`) — leave the row completely untouched
+ // rather than rewriting/dropping a real tag or withholding the marker forever
+ // on an unresolvable user suffix.
+ const hasMarker = input.some((t) => typeof t === 'string'
+ && t.trim().toLowerCase() === LEGACY_UNIVERSE_MARKER_TAG);
+ if (!hasMarker) return { tags: input, changed: false, unresolved: false };
+
const kept = [];
let sawMarker = false;
const idTags = []; // { id, original } in encounter order, first-seen-per-id
diff --git a/server/lib/catalogUniverseTags.test.js b/server/lib/catalogUniverseTags.test.js
index b04590b7d4..965c9ca9b0 100644
--- a/server/lib/catalogUniverseTags.test.js
+++ b/server/lib/catalogUniverseTags.test.js
@@ -58,6 +58,17 @@ describe('catalogUniverseTags — friendlifyUniverseTags', () => {
expect(tags).toEqual(['hero', 'noir']);
});
+ it('leaves a `universe:`-prefixed USER tag untouched when the from-universe marker is absent', () => {
+ // The backfill always stamps `from-universe` alongside `universe:<id>`, so
+ // without the marker this is a legit user tag — must not be rewritten,
+ // dropped, or treated as an unresolved legacy tag.
+ const r1 = friendlifyUniverseTags(['universe:marvel', 'hero'], nameFor, canonicalKey);
+ expect(r1).toEqual({ tags: ['universe:marvel', 'hero'], changed: false, unresolved: false });
+ // Even if the suffix happens to match a real universe id, no marker → no-op.
+ const r2 = friendlifyUniverseTags(['universe:u-1'], nameFor, canonicalKey);
+ expect(r2).toEqual({ tags: ['universe:u-1'], changed: false, unresolved: false });
+ });
+
it('PRESERVES an unresolved universe id tag (+ marker) for a later retry and reports NOT changed', () => {
// The universe name can't resolve yet (it arrived after this ingredient, or
// the local lookup misses). Dropping the id tag would lose it forever, so we