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 (gemini): character editor uses physicalDescription, catalog list snippet falls back to it, cursor cope with repeated params

[._.]/ Adam Eivy38a600541f70
diff --git a/PLAN.md b/PLAN.md
index bde04381ab..bba7b2d823 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -14,6 +14,9 @@ The catalog backend, schema, federation routes, ingest extraction service, and C
- [ ] [catalog-ddl-drift-test] **Add a server test that diffs the catalog DDL between `server/scripts/init-db.sql` and the catalog block in `server/lib/db.js:ensureSchema()`.** Both files now duplicate the four table definitions + indexes + trigger functions; a future PR that updates one without the other will leave fresh installs and upgrading installs with different schemas. Lift the catalog DDL into a shared constant array consumed by both, or write a smoke test that parses both files and compares the relevant statements. Same risk exists for the `memories`/`memory_links` DDL but has been tolerated since the memory system landed; catalog inherits it. Surfaced when the user asked about Postgres schema upgrade management (2026-05-29).
- [ ] [catalog-bundled-universe-push] **Bundle catalog ingredients into universe peer-push payloads.** When peer A pushes a universe to peer B, the push should include the `catalog_ingredients` rows referenced by that universe's embedded canon plus the `catalog_ingredient_refs` rows linking universe→ingredient. Today the embedded canon payloads still replicate (so universes work end-to-end across peers), but the `tags`, `embedding`, `payload.summary`-style enrichments that live ONLY in the catalog row do not — they get re-derived from the embedded entry on the receiver's first backfill, which is a strictly-lossy view. Mirror the `bundleAdditionalKinds` pattern in `server/services/sharing/peerSync.js`. Schema-version gating already covers the new bundle: `RECORD_KIND_SCHEMA_CATEGORIES.universe` would need `['universes', 'catalog']` appended OR the bundling can rely on `cat-ingredient` arriving as its own already-gated kind in the same push. Pairs with `[catalog-federation-orchestrator]`.
- [ ] [catalog-extraction-idea-scene-concept] **Extend `server/services/catalogExtraction.js` to also extract idea / scene / concept ingredients from a scrap.** Current extractor reuses `extractBible` for character/place/object only (the three storyBible-shaped types). For the other three, ship a single LLM JSON-mode call with a custom prompt; surface the new stages on `catalog:extract:progress`. Until this lands, ideas/scenes/concepts are created manually via the Catalog list's "+ New" button.
+- [ ] [catalog-fts-character-fields] **`catalog_ingredients.search_tsv` (GENERATED ALWAYS) indexes `payload->>description|notes|background|summary` but NOT `physicalDescription` or `personality`** — so a search for "tall" or "introverted" misses bible-backfilled characters whose narrative text lives in those keys. Fix needs a schema migration: DROP COLUMN search_tsv + ADD COLUMN with the expanded expression (Postgres can't ALTER a STORED generated expression), update both `server/lib/db.js` and `server/scripts/init-db.sql`, and bump `PORTOS_SCHEMA_VERSIONS.catalog`. Surfaced by gemini review pass on the catalog PR (2026-05-29).
+- [ ] [catalog-commit-transactional] **`POST /api/catalog/scraps/:id/commit` does N `createIngredient` + N `linkIngredientToSource` writes in a sequential loop with no transaction.** A mid-loop failure (DB timeout, validation throw) leaves a partial commit — some ingredients persisted, some not, and some ingredients without source-link rows. Wrap the loop in `withTransaction` and pass the client down to `createIngredient` / `linkIngredientToSource`. Requires the catalogDB write helpers to accept an optional `client` (currently they call the pool-level `query()` directly). Surfaced by gemini review pass (2026-05-29).
+- [ ] [catalog-scrap-embedding-or-search] **Scraps embed on every create (`POST /api/catalog/scraps`), but the embedding column is never read** — no semantic-search route, no "find similar scraps" UI. Either remove the LLM round-trip on create (and keep the column for future use) OR ship the search endpoint that justifies the cost. Currently every scrap creation burns a 768-dim embedding call for zero search benefit. Surfaced by gemini review pass (2026-05-29).
- [ ] [catalog-ref-deletion-tombstones] **`catalog_ingredient_refs` uses hard DELETE on unlink — the row vanishes with no `sync_sequence` bump and no tombstone, so peers that already pulled the ref never learn it was removed and their "Appears in" panels stay stale.** Fix needs: add `deleted boolean DEFAULT false` + `deleted_at timestamptz` to `catalog_ingredient_refs` (DDL in both `server/lib/db.js` and `server/scripts/init-db.sql`), switch `unlinkIngredientFromRef` in `server/services/catalogDB.js:430` to soft-delete with `sync_sequence` bump, teach `applyRemoteChanges` in `server/services/catalogSync.js` to apply ref-delete envelopes, and bump `PORTOS_SCHEMA_VERSIONS.catalog`. Pairs with `[catalog-federation-orchestrator]` — also re-surfaced by the codex review pass on the catalog PR (2026-05-29).
- [ ] [catalog-tests] **Tests for the catalog stack.** `server/services/catalogDB.test.js` (CRUD round-trip — bootstrap follows `server/services/memoryDB.test.js`), `catalogExtraction.test.js` (mock aiToolkit, assert Zod conformance), `catalogSync.test.js` (envelope round-trip + LWW), `server/lib/catalogValidation.test.js` (Zod boundary tests), `server/scripts/migrateBibleToCatalog.test.js` (idempotency), `client/src/pages/Catalog.test.jsx`, `client/src/components/IngredientPicker.test.jsx`.
- [ ] [catalog-writers-room-version-refs] **Phase 9 (deferred at design time): capture catalog ingredient ids per Writers Room draft version.** Extend the draft save path in `server/services/writersRoom/local.js` to accept `referencedIngredientIds[]`. Add `scanProseForIngredientRefs(text, { universeId?, seriesId?, workId? })` to `catalogExtraction.js` (substring match scoped to refs linked to the target). UI: render referenced ingredients on each version-history chip in `client/src/pages/WritersRoom.jsx`.
diff --git a/client/src/pages/Catalog.jsx b/client/src/pages/Catalog.jsx
index 88dbdce89d..a2e758049e 100644
--- a/client/src/pages/Catalog.jsx
+++ b/client/src/pages/Catalog.jsx
@@ -30,11 +30,13 @@ const TYPES = [
const TYPE_BY_ID = Object.fromEntries(TYPES.map((t) => [t.id, t]));
-// Pull a short snippet from the type-specific payload — first hit wins
-// (description → summary → notes), trimmed and ellipsised to ~120 chars.
+// Pull a short snippet from the type-specific payload — first hit wins,
+// trimmed and ellipsised to ~120 chars. Characters use `physicalDescription`
+// (canon shape), so check it first to avoid rendering empty rows for
+// bible-backfilled characters whose only narrative text lives there.
function payloadSnippet(payload) {
if (!payload || typeof payload !== 'object') return '';
- const raw = payload.description || payload.summary || payload.notes || '';
+ const raw = payload.physicalDescription || payload.description || payload.summary || payload.notes || '';
const text = String(raw).trim().replace(/\s+/g, ' ');
if (text.length <= 120) return text;
return `${text.slice(0, 117)}…`;
diff --git a/client/src/pages/CatalogIngredient.jsx b/client/src/pages/CatalogIngredient.jsx
index 28998833cd..0e43281826 100644
--- a/client/src/pages/CatalogIngredient.jsx
+++ b/client/src/pages/CatalogIngredient.jsx
@@ -25,11 +25,16 @@ const LIGHT_FIELDS = [
];
const PAYLOAD_FIELDS = {
character: [
- ['role', 'Role', 'text'],
- ['description', 'Description', 'textarea'],
- ['personality', 'Personality', 'textarea'],
- ['motivations', 'Motivations', 'textarea'],
- ['notes', 'Notes', 'textarea'],
+ ['role', 'Role', 'text'],
+ // Canon character shape uses `physicalDescription` (matches
+ // sanitizeCharacter and the writers-room/bible extractor). A plain
+ // `description` here would render empty for backfill-promoted characters
+ // and edits would land in a sibling field the canon doesn't read.
+ ['physicalDescription', 'Physical Description', 'textarea'],
+ ['personality', 'Personality', 'textarea'],
+ ['background', 'Background', 'textarea'],
+ ['motivations', 'Motivations', 'textarea'],
+ ['notes', 'Notes', 'textarea'],
],
place: [
['slugline', 'Slugline', 'text'],
diff --git a/server/routes/catalog.js b/server/routes/catalog.js
index 415355915c..da63d6a7ff 100644
--- a/server/routes/catalog.js
+++ b/server/routes/catalog.js
@@ -212,7 +212,12 @@ router.get('/sync', asyncHandler(async (req, res) => {
const bracket = {};
for (const [k, v] of Object.entries(req.query)) {
const m = /^since\[([a-z]+)\]$/.exec(k);
- if (m && typeof v === 'string') bracket[m[1]] = v;
+ if (!m) continue;
+ // Node's `simple` parser collapses repeated keys into an array; take
+ // the last value (HTTP convention) instead of dropping the cursor on
+ // the floor and resetting to '0'.
+ const value = Array.isArray(v) ? v[v.length - 1] : v;
+ if (typeof value === 'string') bracket[m[1]] = value;
}
if (Object.keys(bracket).length > 0) {
since = bracket;