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
catalog: record referenced ingredient ids per Writers Room draft version
[._.]/ Adam Eivydaf3e6aa07c7
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex cb9ad5639a..65d9a6e1f5 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -13,6 +13,7 @@## Added+- **[catalog-writers-room-version-refs] Writers Room draft versions now record which catalog ingredients they reference.** Saving a draft scans the prose against the cast linked to that work in the Catalog (characters / places / objects / etc.) and stamps the matched ingredient ids onto the version snapshot. The Versions drawer renders those references as chips under each version, so you can see at a glance which cast a given draft actually mentions. The scan is best-effort — a catalog hiccup never blocks a save — and a client may pass an explicit `referencedIngredientIds[]` to skip the server scan.- **[catalog-pipeline-series-cast] "Cast (from Catalog)" panel on Series, Issue, and Writers Room pages.** A new reusable panel surfaces every catalog ingredient linked to the active series / issue / work bible — drawn from the existing `catalog_ingredient_refs` table — and lets you attach more via the existing Ingredient Picker or unlink with a click. Series records carry no embedded `characters[]` array, so the cast is purely additive and replicates through the existing catalog sync. The panel lives in the Series bible sidebar above "Canon", at the top of the active stage scroll on Issue (visible across every stage tab), and above the work editor in Writers Room when a work is selected.- **[catalog-bulk-import] Bulk-ingest endpoint for the Catalog.** A new "Bulk Import" panel on `/catalog/ingest` accepts JSON, CSV (`type,name,description,tags` header), or simple markdown (`## <Type>: <Name>` headings with paragraph body and optional `tags:` line) and creates ingredients directly — no per-row review screen. Each row is re-validated against the same Zod schema the single-create endpoint uses, so one bad row rolls back the entire batch; vector embeddings run in parallel before the transaction (same as the scrap-commit path), so bulk-imported rows are search-ready immediately rather than waiting for the embeddings backfill. `POST /api/catalog/bulk-import` is Zod-validated (2 MB payload cap), stamps optional `defaults.tags` plus an optional `universe`/`series`/`work`/`issue` ref onto every row in the same transaction, and surfaces parser warnings (e.g. `## Plce: …` typos in markdown that don't match a known type) in the response so users notice typos that would otherwise be silently skipped.- **[catalog-export-bundle] Export a catalog slice as a portable bundle.** `GET /api/catalog/export?refKind=universe|series|issue|work&refId=…&format=json|markdown|yaml` walks the ref table for the target, hydrates each ingredient + its scraps + ref-links, and returns an `attachment` bundle. Pairs with bulk import for round-trip portability (export → edit → re-import) — useful for sharing a universe's cast outside peer-sync or seeding a fresh install from a community pack. Relations and media-ref hydration ship with their own PLAN items.diff --git a/client/src/components/writers-room/WorkEditor.jsx b/client/src/components/writers-room/WorkEditor.jsxindex 50d9667615..acf680a715 100644--- a/client/src/components/writers-room/WorkEditor.jsx+++ b/client/src/components/writers-room/WorkEditor.jsx@@ -37,6 +37,7 @@ import {listWritersRoomObjects,promoteWritersRoomWorkToPipeline,} from '../../services/apiWritersRoom';+import { listCatalogIngredientsForRef } from '../../services/apiCatalog';import { STATUS_LABELS } from './labels';import { countWords } from '../../utils/formatters';import StoryboardPanel, { STORYBOARD_TAB, STORYBOARD_TAB_VALUES } from './StoryboardPanel';@@ -996,6 +997,31 @@ function MobileTab({ active, onClick, icon: Icon, label }) {function VersionsList({ work, dirty, onSwitch }) {const drafts = (work.drafts || []).slice().reverse();++ // Resolve referenced ingredient ids (stored per draft version) into display+ // names from the work's linked catalog cast. Only fetch when at least one+ // version actually carries refs — most works have none and we shouldn't hit+ // the catalog for them. The map is id → name; ids that no longer resolve+ // (unlinked since the version was saved) fall back to a short id chip.+ const hasRefs = drafts.some((d) => Array.isArray(d.referencedIngredientIds) && d.referencedIngredientIds.length > 0);+ const [nameById, setNameById] = useState({});+ useEffect(() => {+ if (!hasRefs || !work.id) return undefined;+ let cancelled = false;+ listCatalogIngredientsForRef('work', work.id, { silent: true })+ .then((rows) => {+ if (cancelled) return;+ const map = {};+ for (const row of rows || []) {+ const ing = row?.ingredient;+ if (ing?.id) map[ing.id] = ing.name || ing.id;+ }+ setNameById(map);+ })+ .catch(() => { if (!cancelled) setNameById({}); });+ return () => { cancelled = true; };+ }, [hasRefs, work.id]);+if (drafts.length === 0) {return <div className="text-xs text-gray-500 italic">No versions yet. Click Snapshot in the header to create one.</div>;}@@ -1009,6 +1035,7 @@ function VersionsList({ work, dirty, onSwitch }) {<ul className="space-y-1 text-xs">{drafts.map((draft) => {const isActive = draft.id === work.activeDraftVersionId;+ const refIds = Array.isArray(draft.referencedIngredientIds) ? draft.referencedIngredientIds : [];return (<li key={draft.id}><button@@ -1024,6 +1051,19 @@ function VersionsList({ work, dirty, onSwitch }) {</span><span className="text-[10px] text-gray-500">{draft.wordCount}w</span></button>+ {refIds.length > 0 && (+ <div className="flex flex-wrap gap-1 px-2 pt-1 pb-0.5">+ {refIds.map((id) => (+ <span+ key={id}+ className="px-1.5 py-0.5 rounded bg-port-bg border border-port-border text-[10px] text-gray-400 truncate max-w-[10rem]"+ title={nameById[id] || id}+ >+ {nameById[id] || `${id.slice(0, 12)}…`}+ </span>+ ))}+ </div>+ )}</li>);})}diff --git a/server/lib/validation.js b/server/lib/validation.jsindex 78218e0355..0038ca935b 100644--- a/server/lib/validation.js+++ b/server/lib/validation.js@@ -834,7 +834,13 @@ export const writersRoomWorkUpdateSchema = z.object({}).strict();export const writersRoomDraftSaveSchema = z.object({- body: z.string().max(5_000_000) // 5 MB ceiling — well over a long novel in plain text+ body: z.string().max(5_000_000), // 5 MB ceiling — well over a long novel in plain text+ // Catalog ingredient ids this draft version references. Optional: when+ // absent the server scans the prose against the work's linked cast and+ // derives the list itself; when present (e.g. a client that already knows+ // the set) it's trusted as the snapshot. Bounded so a malformed body can't+ // balloon the manifest.+ referencedIngredientIds: z.array(z.string().trim().min(1).max(128)).max(500).optional(),}).strict();export const writersRoomSnapshotSchema = z.object({diff --git a/server/routes/writersRoom.js b/server/routes/writersRoom.jsindex 80bf0f72c9..e609035305 100644--- a/server/routes/writersRoom.js+++ b/server/routes/writersRoom.js@@ -44,6 +44,7 @@ import {} from '../services/writersRoom/objects.js';import { promoteWorkToPipeline, ERR_NO_DRAFT_BODY } from '../services/writersRoom/promoteToPipeline.js';import { addItem as addCollectionItem, ERR_DUPLICATE } from '../services/mediaCollections.js';+import { scanProseForIngredientRefs } from '../services/catalogExtraction.js';const router = Router();@@ -105,8 +106,21 @@ router.post('/works/:id/promote-to-pipeline', asyncHandler(async (req, res) => {// ---------- draft body / versions ----------router.put('/works/:id/draft', asyncHandler(async (req, res) => {- const { body } = validateRequest(writersRoomDraftSaveSchema, req.body);- const { manifest, body: persisted } = await saveDraftBody(req.params.id, body);+ const { body, referencedIngredientIds } = validateRequest(writersRoomDraftSaveSchema, req.body);+ // Capture which catalog ingredients this version references. The client may+ // pass the set explicitly; otherwise derive it by scanning the prose against+ // the cast linked to this work. Best-effort — a catalog DB hiccup must not+ // block a writer from saving prose, so a scan failure falls through to "no+ // refs computed" (omitting the field preserves the prior version's snapshot).+ const refs = Array.isArray(referencedIngredientIds)+ ? referencedIngredientIds+ : await scanProseForIngredientRefs(body, { workId: req.params.id }).catch((err) => {+ console.error(`❌ wr: ingredient-ref scan failed: ${err.message}`);+ return undefined;+ });+ const { manifest, body: persisted } = await saveDraftBody(+ req.params.id, body, { referencedIngredientIds: refs },+ );res.json({ ...manifest, activeDraftBody: persisted });}));diff --git a/server/routes/writersRoom.test.js b/server/routes/writersRoom.test.jsindex 57a6305e0c..195f6f4b18 100644--- a/server/routes/writersRoom.test.js+++ b/server/routes/writersRoom.test.js@@ -54,7 +54,14 @@ vi.mock('../services/writersRoom/promoteToPipeline.js', () => ({promoteWorkToPipeline: vi.fn(),}));+// Mock the catalog scan so the draft-save route stays pure (no Postgres pool).+// Default: the work has no linked cast, so the scan finds nothing.+vi.mock('../services/catalogExtraction.js', () => ({+ scanProseForIngredientRefs: vi.fn(async () => []),+}));+import * as svc from '../services/writersRoom/local.js';+import * as catalogExtraction from '../services/catalogExtraction.js';import * as charSvc from '../services/writersRoom/characters.js';import * as placesSvc from '../services/writersRoom/places.js';import writersRoomRoutes from './writersRoom.js';@@ -144,13 +151,34 @@ describe('writersRoom routes', () => {expect(r.status).toBe(400);});- it('PUT /works/:id/draft persists and echoes the body', async () => {+ it('PUT /works/:id/draft persists, echoes the body, and stamps scanned ingredient refs', async () => {+ catalogExtraction.scanProseForIngredientRefs.mockResolvedValueOnce(['cat-chr-mira']);const r = await request(app).put('/api/writers-room/works/wr-work-1/draft').send({ body: 'new prose' });expect(r.status).toBe(200);- expect(svc.saveDraftBody).toHaveBeenCalledWith('wr-work-1', 'new prose');+ // The route scans the prose scoped to this work, then passes the derived+ // ids through to the save path.+ expect(catalogExtraction.scanProseForIngredientRefs).toHaveBeenCalledWith('new prose', { workId: 'wr-work-1' });+ expect(svc.saveDraftBody).toHaveBeenCalledWith('wr-work-1', 'new prose', { referencedIngredientIds: ['cat-chr-mira'] });expect(r.body.activeDraftBody).toBe('new prose');});+ it('PUT /works/:id/draft trusts a client-supplied referencedIngredientIds and skips the scan', async () => {+ const r = await request(app)+ .put('/api/writers-room/works/wr-work-1/draft')+ .send({ body: 'new prose', referencedIngredientIds: ['cat-plc-harbor'] });+ expect(r.status).toBe(200);+ expect(catalogExtraction.scanProseForIngredientRefs).not.toHaveBeenCalled();+ expect(svc.saveDraftBody).toHaveBeenCalledWith('wr-work-1', 'new prose', { referencedIngredientIds: ['cat-plc-harbor'] });+ });++ it('PUT /works/:id/draft survives a scan failure (best-effort, omits refs)', async () => {+ catalogExtraction.scanProseForIngredientRefs.mockRejectedValueOnce(new Error('db down'));+ const r = await request(app).put('/api/writers-room/works/wr-work-1/draft').send({ body: 'new prose' });+ expect(r.status).toBe(200);+ // Scan failure → undefined refs → save path preserves the prior snapshot.+ expect(svc.saveDraftBody).toHaveBeenCalledWith('wr-work-1', 'new prose', { referencedIngredientIds: undefined });+ });+it('POST /works/:id/versions accepts an optional label', async () => {const r = await request(app).post('/api/writers-room/works/wr-work-1/versions').send({ label: 'Pre-revision' });expect(r.status).toBe(201);diff --git a/server/services/catalogExtraction.js b/server/services/catalogExtraction.jsindex 3bce264c78..3e7c71694a 100644--- a/server/services/catalogExtraction.js+++ b/server/services/catalogExtraction.js@@ -22,6 +22,7 @@ import { extractBible } from '../lib/bibleExtractor.js';import { runStagedLLM } from '../lib/stageRunner.js';import { BIBLE_KINDS, BIBLE_FIELD, BIBLE_LIMITS } from '../lib/storyBible.js';import { catalogEvents } from './catalogEvents.js';+import { listIngredientsForRef } from './catalogDB.js';// Light-shape stage that bundles ideas/scenes/concepts into one LLM call.// Surfaced to the UI as a single stage row — the three result arrays land@@ -247,3 +248,59 @@ export async function extractIngredients({ rawText, scrapId = null, providerOverreturn { runId, ...draft, stages };}++// (refKind, refId) pairs the scan is allowed to consider. Only catalog+// ingredients linked to one of the provided targets are eligible — a draft+// shouldn't claim a reference to a character that lives in an unrelated+// universe just because the two names collide.+const SCAN_REF_KINDS = Object.freeze(['universe', 'series', 'work']);++/**+ * Detect which catalog ingredients a piece of prose references, scoped to the+ * ingredients linked to the given target(s).+ *+ * Substring-matches each candidate ingredient's `name` against the prose+ * (case-insensitive). The candidate set is the union of ingredients linked to+ * any provided ref — so a Writers Room draft only ever picks up the cast that+ * was deliberately attached to its work / series / universe, never an+ * arbitrary catalog row. Returns a de-duplicated list of matched ingredient+ * ids in stable (sorted) order so the stored array is comparable across saves.+ *+ * @param {string} text The prose to scan.+ * @param {object} scope+ * @param {string} [scope.universeId] Universe ref to scope candidates to.+ * @param {string} [scope.seriesId] Series ref to scope candidates to.+ * @param {string} [scope.workId] Work ref to scope candidates to.+ * @returns {Promise<string[]>} Matched ingredient ids (sorted, unique).+ */+export async function scanProseForIngredientRefs(text, scope = {}) {+ if (typeof text !== 'string' || !text.trim()) return [];+ const targets = [+ ['universe', scope.universeId],+ ['series', scope.seriesId],+ ['work', scope.workId],+ ].filter(([kind, id]) => SCAN_REF_KINDS.includes(kind) && typeof id === 'string' && id.trim());+ if (targets.length === 0) return [];++ // Union the candidate ingredients across every provided target. The same+ // ingredient can be linked to more than one target (a character attached to+ // both its universe and its work) — de-dupe by id so we scan its name once.+ const byId = new Map();+ for (const [kind, id] of targets) {+ const rows = await listIngredientsForRef(kind, id);+ for (const { ingredient } of rows) {+ if (ingredient?.id && ingredient?.name && !byId.has(ingredient.id)) {+ byId.set(ingredient.id, ingredient.name);+ }+ }+ }+ if (byId.size === 0) return [];++ const haystack = text.toLowerCase();+ const matched = [];+ for (const [id, name] of byId) {+ const needle = String(name).trim().toLowerCase();+ if (needle && haystack.includes(needle)) matched.push(id);+ }+ return matched.sort();+}diff --git a/server/services/catalogExtraction.test.js b/server/services/catalogExtraction.test.jsindex 55c51c13e2..24bcb25432 100644--- a/server/services/catalogExtraction.test.js+++ b/server/services/catalogExtraction.test.js@@ -19,11 +19,17 @@ vi.mock('../lib/bibleExtractor.js', () => ({vi.mock('../lib/stageRunner.js', () => ({runStagedLLM: vi.fn(),}));+// catalogDB pulls in the Postgres pool — mock just the one function the+// extractor consumes so scanProseForIngredientRefs stays a pure unit test.+vi.mock('./catalogDB.js', () => ({+ listIngredientsForRef: vi.fn(),+}));const bibleExtractor = await import('../lib/bibleExtractor.js');const stageRunner = await import('../lib/stageRunner.js');+const catalogDB = await import('./catalogDB.js');const { catalogEvents } = await import('./catalogEvents.js');-const { extractIngredients, EXTRACTION_STAGES } = await import('./catalogExtraction.js');+const { extractIngredients, EXTRACTION_STAGES, scanProseForIngredientRefs } = await import('./catalogExtraction.js');const emptyLightResponse = { content: { ideas: [], scenes: [], concepts: [] } };@@ -241,3 +247,88 @@ describe('catalogExtraction — bundled light stage', () => {expect(lightStage.error).toBe('provider down');});});++describe('catalogExtraction — scanProseForIngredientRefs', () => {+ // Build the { ingredient, role } row shape listIngredientsForRef returns.+ const row = (id, name) => ({ ingredient: { id, name }, role: 'cast' });++ it('returns [] for empty / non-string prose without querying the DB', async () => {+ expect(await scanProseForIngredientRefs('', { workId: 'wr-work-1' })).toEqual([]);+ expect(await scanProseForIngredientRefs(' ', { workId: 'wr-work-1' })).toEqual([]);+ expect(await scanProseForIngredientRefs(null, { workId: 'wr-work-1' })).toEqual([]);+ expect(catalogDB.listIngredientsForRef).not.toHaveBeenCalled();+ });++ it('returns [] when no scope target is provided (nothing to scope to)', async () => {+ expect(await scanProseForIngredientRefs('Mira walked in.', {})).toEqual([]);+ expect(catalogDB.listIngredientsForRef).not.toHaveBeenCalled();+ });++ it('ignores unknown / non-string scope ids', async () => {+ // Only the three known kinds (universe/series/work) are honored, and each+ // must be a non-empty string.+ expect(await scanProseForIngredientRefs('text', { workId: 42, foo: 'bar' })).toEqual([]);+ expect(await scanProseForIngredientRefs('text', { universeId: ' ' })).toEqual([]);+ expect(catalogDB.listIngredientsForRef).not.toHaveBeenCalled();+ });++ it('matches ingredient names as case-insensitive substrings of the prose', async () => {+ catalogDB.listIngredientsForRef.mockResolvedValue([+ row('cat-chr-mira', 'Mira'),+ row('cat-chr-tomas', 'Tomas'),+ row('cat-plc-harbor', 'The Drowned Harbor'),+ ]);+ const prose = 'mira crossed the drowned harbor at dawn, alone.';+ const ids = await scanProseForIngredientRefs(prose, { workId: 'wr-work-1' });+ // Mira (lowercased) + The Drowned Harbor match; Tomas does not. Sorted.+ expect(ids).toEqual(['cat-chr-mira', 'cat-plc-harbor'].sort());+ expect(catalogDB.listIngredientsForRef).toHaveBeenCalledWith('work', 'wr-work-1');+ });++ it('scopes candidates to the linked refs — never an arbitrary catalog row', async () => {+ // listIngredientsForRef is the only candidate source, so a name that isn't+ // in the linked cast simply never enters the match set.+ catalogDB.listIngredientsForRef.mockResolvedValue([row('cat-chr-mira', 'Mira')]);+ const ids = await scanProseForIngredientRefs('Mira and Galadriel spoke.', { workId: 'wr-work-1' });+ expect(ids).toEqual(['cat-chr-mira']); // Galadriel is not linked → not returned+ });++ it('unions candidates across multiple scope targets and de-dupes by id', async () => {+ catalogDB.listIngredientsForRef.mockImplementation(async (kind) => {+ if (kind === 'universe') return [row('cat-chr-mira', 'Mira'), row('cat-chr-shared', 'Shared')];+ if (kind === 'work') return [row('cat-chr-shared', 'Shared'), row('cat-chr-tomas', 'Tomas')];+ return [];+ });+ const ids = await scanProseForIngredientRefs('Mira, Shared, and Tomas all appear.', {+ universeId: 'u-1', workId: 'wr-work-1',+ });+ // Shared appears in both refs but is returned once. All three matched.+ expect(ids).toEqual(['cat-chr-mira', 'cat-chr-shared', 'cat-chr-tomas'].sort());+ expect(catalogDB.listIngredientsForRef).toHaveBeenCalledTimes(2);+ });++ it('returns [] when the linked cast is empty', async () => {+ catalogDB.listIngredientsForRef.mockResolvedValue([]);+ expect(await scanProseForIngredientRefs('Some prose.', { workId: 'wr-work-1' })).toEqual([]);+ });++ it('skips candidate rows missing an id or name', async () => {+ catalogDB.listIngredientsForRef.mockResolvedValue([+ { ingredient: { id: 'cat-chr-noname' }, role: 'cast' }, // no name → skipped+ { ingredient: { name: 'Nameless appears' }, role: 'cast' }, // no id → skipped+ row('cat-chr-real', 'Real'),+ ]);+ const ids = await scanProseForIngredientRefs('Real and Nameless appears here.', { workId: 'wr-work-1' });+ expect(ids).toEqual(['cat-chr-real']);+ });++ it('returns a sorted, de-duplicated id list', async () => {+ catalogDB.listIngredientsForRef.mockResolvedValue([+ row('cat-z', 'Zed'),+ row('cat-a', 'Ada'),+ row('cat-m', 'Mira'),+ ]);+ const ids = await scanProseForIngredientRefs('Zed, Ada, and Mira.', { workId: 'wr-work-1' });+ expect(ids).toEqual(['cat-a', 'cat-m', 'cat-z']);+ });+});diff --git a/server/services/writersRoom/local.js b/server/services/writersRoom/local.jsindex 6a87ed2638..d53b33deea 100644--- a/server/services/writersRoom/local.js+++ b/server/services/writersRoom/local.js@@ -384,7 +384,7 @@ function buildDraftMeta(text, base = {}) {};}-export async function saveDraftBody(workId, body) {+export async function saveDraftBody(workId, body, { referencedIngredientIds } = {}) {const manifest = await getWork(workId);const activeId = manifest.activeDraftVersionId;if (!activeId) throw badRequest('Work has no active draft');@@ -392,7 +392,15 @@ export async function saveDraftBody(workId, body) {await atomicWrite(draftPath(workId, activeId), text);const draftIdx = manifest.drafts.findIndex((d) => d.id === activeId);if (draftIdx < 0) throw notFound('Active draft');- manifest.drafts[draftIdx] = buildDraftMeta(text, manifest.drafts[draftIdx]);+ const meta = buildDraftMeta(text, manifest.drafts[draftIdx]);+ // Distinguish "caller omitted the field" (preserve the existing snapshot of+ // referenced ids) from "caller passed an empty array" (the prose no longer+ // mentions any linked ingredient — clear it). An absent field must NOT wipe+ // a previously-computed reference list.+ if (Array.isArray(referencedIngredientIds)) {+ meta.referencedIngredientIds = referencedIngredientIds;+ }+ manifest.drafts[draftIdx] = meta;manifest.updatedAt = nowIso();await saveManifest(workId, manifest);console.log(`📝 wr: saved draft ${activeId.slice(0, 14)}… (${manifest.drafts[draftIdx].wordCount} words)`);diff --git a/server/services/writersRoom/local.test.js b/server/services/writersRoom/local.test.jsindex 54f60ca57f..10fe87c08a 100644--- a/server/services/writersRoom/local.test.js+++ b/server/services/writersRoom/local.test.js@@ -191,6 +191,28 @@ describe('draft body and versioning', () => {expect(body).toBe('Body text v1.');});+ it('saveDraftBody stores referencedIngredientIds when provided; absence preserves the prior snapshot', async () => {+ const work = await createWork({ title: 'Refs' });+ // Present array → stored on the active draft meta.+ const { manifest: m1 } = await saveDraftBody(work.id, 'Mira appears.', {+ referencedIngredientIds: ['cat-chr-mira'],+ });+ const a1 = m1.drafts.find((d) => d.id === m1.activeDraftVersionId);+ expect(a1.referencedIngredientIds).toEqual(['cat-chr-mira']);++ // Field omitted → the prior reference snapshot must NOT be wiped.+ const { manifest: m2 } = await saveDraftBody(work.id, 'Mira appears again.');+ const a2 = m2.drafts.find((d) => d.id === m2.activeDraftVersionId);+ expect(a2.referencedIngredientIds).toEqual(['cat-chr-mira']);++ // Empty array → an intentional clear (prose no longer mentions anyone).+ const { manifest: m3 } = await saveDraftBody(work.id, 'Nobody here.', {+ referencedIngredientIds: [],+ });+ const a3 = m3.drafts.find((d) => d.id === m3.activeDraftVersionId);+ expect(a3.referencedIngredientIds).toEqual([]);+ });+it('snapshotDraft creates a new version that mirrors the current body', async () => {const work = await createWork({ title: 'Versioned' });await saveDraftBody(work.id, 'First pass.');