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

feat([issue-1288]): object↔character emotional attachment model + editorial checks

[._.]/ Adam Eivy7cea9e3ae0c0
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 616b043b69..2504784a58 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -2,6 +2,8 @@
## Added
+- **[issue-1288] Object↔character attachments — model who cares about each object, and why.** An object's significance used to be a single free-text field with no link to the cast. Each universe object now also carries **structured attachments**: pick a character, then capture the **emotion** they feel toward the object (grief, pride, guilt, longing…), **why it matters** to that specific character, **how they came to have it** (the backstory link), and a **role** archetype (talisman / macguffin / memento / tool / symbol / custom). The object card in the universe canon editor gets a collapsible **Attachments** section to add, edit, and remove these. Three new editorial checks read the web: **Unattached significant object** (an object with written significance that nobody is on record caring about), **Unmotivated object interaction** (an LLM scan for moments where a character treats an object as significant with no established reason), and **Attachment backstory consistency** (an LLM check that flags an attachment whose origin story contradicts the character's established background). The legacy prose `significance` field is untouched; attachments are purely additive and version-gated for cross-machine sync so an older peer can't silently strip them. (#1288)
+
- **Structured character relationships + opposing-force tagging.** A character's relationships used to be a single free-text field — readable, but invisible to tooling. Each universe character now also carries **structured relationship links**: pick a target character from the cast, tag the dynamic (ally / antagonist / rival / mentor / love-interest / family / custom), and add a short description. A link can optionally carry an **opposing force** — a binary tension the reader watches to see reverse (hunter/prey, winner/loser, predator/prey, smart/dumb, or a custom axis), with each side's role and a note ("reader is waiting to see if these flip"). The Cast editor surfaces opposition pairs prominently (they're a story spine, not every story has them). Three new editorial checks validate the web: **Relationship reciprocity** (A links B but B doesn't link back), **Relationship dangling target** (a link points at a deleted character), and an advisory **Opposition role-reversal payoff** (surfaces every tagged opposing-force pair so you can confirm the roles ever reverse — or deliberately don't). The legacy prose `relationships` field is untouched; `relationshipLinks` is purely additive and version-gated for cross-machine sync so an older peer can't silently strip it. (`server/lib/storyBible.js`, `server/lib/validation.js`, `server/lib/editorial/checkRegistry.js`, `server/lib/schemaVersions.js`, `client/src/components/universe/CharacterDetailEditor.jsx`) (#1287)
- **Reverse Outline — a color-coded scene map of your drafted manuscript.** A new **Reverse Outline** view (linked from the series page) reads the finished/drafted manuscript and lays out what's *actually on the page*: it identifies the recurring plotlines (A-plot, subplots, POV threads) and segments the prose into scenes, each tagged to the plotline it advances — then shows them as a grid (rows = plotlines, columns = scenes in reading order) so you can see thread cadence, gaps, and tangles at a glance. Click any scene marker to read its summary, POV, setting, character list, and narrative/action/dialogue mix, and jump straight into the manuscript editor at that scene's issue. Generation streams live progress; the outline flags itself **stale** once the manuscript changes so you know to regenerate. This scene segmentation is the shared substrate upcoming editorial checks (scene balance, POV justification, cliffhangers, arc transitions) will read rather than re-deriving. (#1286)
diff --git a/client/src/components/pipeline/CanonCard.jsx b/client/src/components/pipeline/CanonCard.jsx
index 9037ab33b5..7ec3e49a77 100644
--- a/client/src/components/pipeline/CanonCard.jsx
+++ b/client/src/components/pipeline/CanonCard.jsx
@@ -20,6 +20,7 @@ import MediaJobThumb from './MediaJobThumb';
import EntryCard from '../universe/EntryCard';
import EntryThumbSlot from '../universe/EntryThumbSlot';
import CharacterDetailEditor from '../universe/CharacterDetailEditor';
+import ObjectAttachmentsEditor from '../universe/ObjectAttachmentsEditor';
import CharacterReferenceSheetPanel from '../universe/CharacterReferenceSheetPanel';
import CharacterLoraChip from '../loraTraining/CharacterLoraChip';
import { BIBLE_LIMITS } from '../../lib/bibleLimits';
@@ -280,6 +281,12 @@ export default function CanonCard({
// `castList` (the universe-wide character list) feeds the relationship-link
// target picker in CharacterDetailEditor (#1287).
characterExtensions = null,
+ // Universe-only object extensions. When provided + kind is 'objects',
+ // CanonCard reveals an Attachments editor (object↔character emotional
+ // attachment links, #1288). NounsStage (series view) omits this.
+ // Shape: { castList } — the universe-wide character list feeds the
+ // attachment target picker in ObjectAttachmentsEditor.
+ objectExtensions = null,
}) {
const description = kind.descFor(entry);
const refs = Array.isArray(entry.imageRefs) ? entry.imageRefs : [];
@@ -422,6 +429,17 @@ export default function CanonCard({
</div>
</CharacterDetailsToggle>
) : null}
+ {/* Universe-only: object↔character attachment editor (#1288). Hidden when
+ the caller didn't pass `objectExtensions` (pipeline series view).
+ Locked objects render read-only inputs. */}
+ {kind.key === 'objects' && objectExtensions && onPatchEntry ? (
+ <ObjectAttachmentsEditor
+ entry={entry}
+ characters={objectExtensions.castList || []}
+ onPatch={(patch) => onPatchEntry(entry.id, patch)}
+ disabled={locked}
+ />
+ ) : null}
</>
);
diff --git a/client/src/components/universe/ObjectAttachmentsEditor.jsx b/client/src/components/universe/ObjectAttachmentsEditor.jsx
new file mode 100644
index 0000000000..1fc7333ea3
--- /dev/null
+++ b/client/src/components/universe/ObjectAttachmentsEditor.jsx
@@ -0,0 +1,159 @@
+/**
+ * Object↔character attachment editor (#1288) — the object-side analog of the
+ * Relationships section in CharacterDetailEditor.jsx. Each attachment ties this
+ * object to ONE character and captures the emotion / significance / origin of
+ * that bond plus a `role` archetype.
+ *
+ * Self-contained collapsible section (mirrors CanonCard's WardrobeSection
+ * toggle) so it can mount inside the object's CanonCard body. Needs the cast
+ * (`characters`) to populate the target picker; the whole `attachments` array
+ * is patched on every mutation (mirrors the relationship-link onPatch contract),
+ * and text fields buffer via useFieldDraft and commit on blur.
+ */
+
+import { useState } from 'react';
+import { ChevronDown, ChevronRight, Plus, Trash2, Heart } from 'lucide-react';
+import { BIBLE_LIMITS as L } from '../../lib/bibleLimits';
+import useFieldDraft from '../../hooks/useFieldDraft';
+
+// Mirrors `ATTACHMENT_ROLES` in server/lib/storyBible.js (#1288). The server
+// sanitizer coerces an unrecognized value to 'custom', so adding a token here
+// without the server side just means the UI offers a value the server folds
+// back to custom.
+const ATTACHMENT_ROLES = Object.freeze([
+ 'talisman', 'macguffin', 'memento', 'tool', 'symbol', 'custom',
+]);
+
+const SELECT_CLASS = 'flex-1 min-w-0 px-1.5 py-0.5 text-xs bg-port-bg border border-port-border rounded text-white disabled:opacity-50';
+const INPUT_CLASS = 'w-full px-1.5 py-0.5 text-xs bg-port-bg border border-port-border rounded text-white disabled:opacity-50';
+
+// One attachment row — character + role selects, an emotion input, and
+// significance + origin prose. The character whose id this points at may have
+// been deleted; show an explicit "(missing)" option so the dangling state is
+// visible and repointable rather than silently snapping to the first character.
+function AttachmentRow({ attachment, idx, characters, onUpdate, onRemove, disabled }) {
+ const emotion = useFieldDraft(attachment.emotion || '', (v) => onUpdate({ emotion: v }));
+ const significance = useFieldDraft(attachment.significance || '', (v) => onUpdate({ significance: v }));
+ const origin = useFieldDraft(attachment.origin || '', (v) => onUpdate({ origin: v }));
+ const targetMissing = !!attachment.characterId
+ && !characters.some((c) => c.id === attachment.characterId);
+ return (
+ <div className="rounded border border-port-border bg-port-bg/40 p-2 space-y-1.5">
+ <div className="flex items-center gap-1.5">
+ <select
+ value={attachment.characterId || ''}
+ onChange={(e) => onUpdate({ characterId: e.target.value })}
+ disabled={disabled}
+ aria-label={`attachment ${idx + 1} character`}
+ className={SELECT_CLASS}
+ >
+ {targetMissing ? (
+ <option value={attachment.characterId}>(missing: {attachment.characterId})</option>
+ ) : null}
+ {characters.map((c) => <option key={c.id} value={c.id}>{c.name || c.id}</option>)}
+ </select>
+ <select
+ value={ATTACHMENT_ROLES.includes(attachment.role) ? attachment.role : 'custom'}
+ onChange={(e) => onUpdate({ role: e.target.value })}
+ disabled={disabled}
+ aria-label={`attachment ${idx + 1} role`}
+ className="w-28 shrink-0 px-1.5 py-0.5 text-xs bg-port-bg border border-port-border rounded text-white disabled:opacity-50"
+ >
+ {ATTACHMENT_ROLES.map((r) => <option key={r} value={r}>{r}</option>)}
+ </select>
+ <button
+ type="button" onClick={onRemove} disabled={disabled}
+ title="Remove attachment" aria-label={`remove attachment ${idx + 1}`}
+ className="shrink-0 text-gray-500 hover:text-port-error disabled:opacity-30"
+ >
+ <Trash2 size={12} />
+ </button>
+ </div>
+ <input
+ type="text" value={emotion.value} onChange={emotion.onChange} onBlur={emotion.onBlur}
+ placeholder="emotion (e.g. grief, pride, guilt, longing)"
+ maxLength={L.ATTACHMENT_EMOTION_MAX} disabled={disabled}
+ aria-label={`attachment ${idx + 1} emotion`}
+ className={INPUT_CLASS}
+ />
+ <textarea
+ value={significance.value} onChange={significance.onChange} onBlur={significance.onBlur}
+ placeholder="why it matters to THIS character"
+ rows={2} maxLength={L.ATTACHMENT_SIGNIFICANCE_MAX} disabled={disabled}
+ aria-label={`attachment ${idx + 1} significance`}
+ className={INPUT_CLASS}
+ />
+ <textarea
+ value={origin.value} onChange={origin.onChange} onBlur={origin.onBlur}
+ placeholder="how they came to have it (backstory link)"
+ rows={2} maxLength={L.ATTACHMENT_ORIGIN_MAX} disabled={disabled}
+ aria-label={`attachment ${idx + 1} origin`}
+ className={INPUT_CLASS}
+ />
+ </div>
+ );
+}
+
+export default function ObjectAttachmentsEditor({ entry, characters = [], onPatch, disabled = false }) {
+ const [open, setOpen] = useState(false);
+ const attachments = Array.isArray(entry.attachments) ? entry.attachments : [];
+ const cast = (Array.isArray(characters) ? characters : []).filter((c) => c?.id);
+ const commit = (next) => onPatch?.({ attachments: next });
+ const addAttachment = () => {
+ if (!cast.length) return;
+ setOpen(true);
+ commit([...attachments, { characterId: cast[0].id, emotion: '', significance: '', origin: '', role: 'custom' }]);
+ };
+ const updateAttachment = (idx, patch) =>
+ commit(attachments.map((a, i) => (i === idx ? { ...a, ...patch } : a)));
+ const removeAttachment = (idx) => commit(attachments.filter((_, i) => i !== idx));
+
+ // Hide entirely when there's nothing to show and no way to add (read-only +
+ // empty). Otherwise the toggle is always available.
+ if (disabled && attachments.length === 0) return null;
+
+ return (
+ <div className="mt-2">
+ <button
+ type="button"
+ onClick={() => setOpen((v) => !v)}
+ className="inline-flex items-center gap-1 text-[10px] uppercase tracking-wider text-gray-500 hover:text-white"
+ >
+ {open ? <ChevronDown size={10} /> : <ChevronRight size={10} />}
+ <Heart size={10} />
+ Attachments ({attachments.length})
+ </button>
+ {open ? (
+ <div className="mt-1.5 pl-3 border-l border-port-border space-y-2">
+ {attachments.length > 0 ? (
+ attachments.map((attachment, idx) => (
+ <AttachmentRow
+ key={attachment.id || `att-${idx}`}
+ attachment={attachment}
+ idx={idx}
+ characters={cast}
+ onUpdate={(patch) => updateAttachment(idx, patch)}
+ onRemove={() => removeAttachment(idx)}
+ disabled={disabled}
+ />
+ ))
+ ) : (
+ <p className="text-[11px] text-gray-500 italic">No attachments yet.</p>
+ )}
+ {!disabled && (cast.length === 0 ? (
+ <p className="text-[11px] text-gray-500 italic">
+ Add a character to this universe to {attachments.length ? 're-point these attachments' : 'attach a character'}.
+ </p>
+ ) : (
+ <button
+ type="button" onClick={addAttachment}
+ className="inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded border border-port-border text-gray-400 hover:text-white hover:border-gray-500"
+ >
+ <Plus size={10} /> Add attachment
+ </button>
+ ))}
+ </div>
+ ) : null}
+ </div>
+ );
+}
diff --git a/client/src/components/universe/ObjectAttachmentsEditor.test.jsx b/client/src/components/universe/ObjectAttachmentsEditor.test.jsx
new file mode 100644
index 0000000000..e06972c49c
--- /dev/null
+++ b/client/src/components/universe/ObjectAttachmentsEditor.test.jsx
@@ -0,0 +1,86 @@
+import { describe, it, expect, vi } from 'vitest';
+import { render, screen, fireEvent } from '@testing-library/react';
+import ObjectAttachmentsEditor from './ObjectAttachmentsEditor';
+
+const WATCH = { id: 'obj-watch', name: 'Pocket Watch' };
+const MARA = { id: 'chr-mara', name: 'Mara' };
+const BRAM = { id: 'chr-bram', name: 'Bram' };
+
+// The section starts collapsed — open it by clicking its header button.
+const openAttachments = () => {
+ fireEvent.click(screen.getByRole('button', { name: /Attachments/i }));
+};
+
+describe('ObjectAttachmentsEditor (#1288)', () => {
+ it('prompts to add a character when the universe has none', () => {
+ render(<ObjectAttachmentsEditor entry={WATCH} characters={[]} onPatch={() => {}} />);
+ openAttachments();
+ expect(screen.getByText(/Add a character to this universe/i)).toBeInTheDocument();
+ });
+
+ it('adds an attachment defaulting to the first character + custom role', () => {
+ const onPatch = vi.fn();
+ render(<ObjectAttachmentsEditor entry={WATCH} characters={[MARA, BRAM]} onPatch={onPatch} />);
+ openAttachments();
+ fireEvent.click(screen.getByRole('button', { name: /Add attachment/i }));
+ expect(onPatch).toHaveBeenCalledWith({
+ attachments: [{ characterId: 'chr-mara', emotion: '', significance: '', origin: '', role: 'custom' }],
+ });
+ });
+
+ it('renders an existing attachment with character + role selects', () => {
+ const entry = {
+ ...WATCH,
+ attachments: [{ id: 'att-1', characterId: 'chr-mara', role: 'memento' }],
+ };
+ render(<ObjectAttachmentsEditor entry={entry} characters={[MARA, BRAM]} onPatch={() => {}} />);
+ openAttachments();
+ expect(screen.getByRole('combobox', { name: /attachment 1 character/i })).toHaveValue('chr-mara');
+ expect(screen.getByRole('combobox', { name: /attachment 1 role/i })).toHaveValue('memento');
+ });
+
+ it('patches the role when the role select changes', () => {
+ const onPatch = vi.fn();
+ const entry = {
+ ...WATCH,
+ attachments: [{ id: 'att-1', characterId: 'chr-mara', role: 'memento' }],
+ };
+ render(<ObjectAttachmentsEditor entry={entry} characters={[MARA]} onPatch={onPatch} />);
+ openAttachments();
+ fireEvent.change(screen.getByRole('combobox', { name: /attachment 1 role/i }), {
+ target: { value: 'talisman' },
+ });
+ expect(onPatch).toHaveBeenCalledWith({
+ attachments: [{ id: 'att-1', characterId: 'chr-mara', role: 'talisman' }],
+ });
+ });
+
+ it('keeps an attachment removable + surfaces a deleted character as "(missing)"', () => {
+ const onPatch = vi.fn();
+ const entry = {
+ ...WATCH,
+ attachments: [{ id: 'att-1', characterId: 'chr-deleted', role: 'memento' }],
+ };
+ render(<ObjectAttachmentsEditor entry={entry} characters={[MARA]} onPatch={onPatch} />);
+ openAttachments();
+ expect(screen.getByText(/missing: chr-deleted/i)).toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: /remove attachment 1/i }));
+ expect(onPatch).toHaveBeenCalledWith({ attachments: [] });
+ });
+
+ it('shows the attachment count in the header', () => {
+ const entry = {
+ ...WATCH,
+ attachments: [{ id: 'att-1', characterId: 'chr-mara' }, { id: 'att-2', characterId: 'chr-bram' }],
+ };
+ render(<ObjectAttachmentsEditor entry={entry} characters={[MARA, BRAM]} onPatch={() => {}} />);
+ expect(screen.getByText(/Attachments \(2\)/i)).toBeInTheDocument();
+ });
+
+ it('renders nothing when read-only with no attachments', () => {
+ const { container } = render(
+ <ObjectAttachmentsEditor entry={WATCH} characters={[MARA]} onPatch={() => {}} disabled />,
+ );
+ expect(container).toBeEmptyDOMElement();
+ });
+});
diff --git a/client/src/components/universe/UniverseCanonSection.jsx b/client/src/components/universe/UniverseCanonSection.jsx
index 4aa23e6b62..2b51f18397 100644
--- a/client/src/components/universe/UniverseCanonSection.jsx
+++ b/client/src/components/universe/UniverseCanonSection.jsx
@@ -813,6 +813,9 @@ export default function UniverseCanonSection({
onBulkLock={(nextLocked) => handleBulkLockKind(kind, nextLocked)}
bulkLocking={bulkLockingKindKey === kind.key}
fullList={Array.isArray(universe[kind.key]) ? universe[kind.key] : []}
+ // The universe-wide character list — feeds the attachment target
+ // picker in ObjectAttachmentsEditor for the objects kind (#1288).
+ castList={Array.isArray(universe.characters) ? universe.characters : []}
externalPendingByEntryId={externalPendingByEntryId}
// Single-kind view (`?kind=places`, sidebar deep-links) — the
// outer canon section already supplies the h2 + description + card
@@ -864,7 +867,7 @@ export default function UniverseCanonSection({
);
}
-function KindSection({ kind, universeId, all, totalCount, filtered, usage, renderingJobs, onRender, onJobCompleted, onJobFailed, onPreview, onRefine, refiningId, onExpandCharacter, expandingId, onSheetCompleted, onSheetDeleted, onToggleLock, togglingLockId, onPatchEntry, onRenderCleanPlate, onDescribeImages = null, seriesNameMap, onBulkLock, bulkLocking, fullList, externalPendingByEntryId = null, compact = false, onRenderAll = null, renderingAll = false, onPickFromCatalog = null, catalogLinking = false, onAddEntry = null, creating = false }) {
+function KindSection({ kind, universeId, all, totalCount, filtered, usage, renderingJobs, onRender, onJobCompleted, onJobFailed, onPreview, onRefine, refiningId, onExpandCharacter, expandingId, onSheetCompleted, onSheetDeleted, onToggleLock, togglingLockId, onPatchEntry, onRenderCleanPlate, onDescribeImages = null, seriesNameMap, onBulkLock, bulkLocking, fullList, castList = [], externalPendingByEntryId = null, compact = false, onRenderAll = null, renderingAll = false, onPickFromCatalog = null, catalogLinking = false, onAddEntry = null, creating = false }) {
// Universe-only character wiring — `null` for non-character kinds so
// CanonCard's gate stays `kind === 'characters' && characterExtensions`.
// Memoized so the BASE object is stable across re-renders that aren't
@@ -881,6 +884,15 @@ function KindSection({ kind, universeId, all, totalCount, filtered, usage, rende
: null),
[kind.key, universeId, onExpandCharacter, onSheetCompleted, onSheetDeleted, fullList],
);
+ // Universe-only object wiring (#1288) — `null` for non-object kinds so
+ // CanonCard's gate stays `kind === 'objects' && objectExtensions`. `castList`
+ // is the universe-wide character list (passed in directly, since `fullList`
+ // for the objects kind is the objects, not the cast) feeding the attachment
+ // target picker in ObjectAttachmentsEditor.
+ const objectExtensions = useMemo(
+ () => (kind.key === 'objects' ? { castList } : null),
+ [kind.key, castList],
+ );
const Icon = kind.icon;
// Manual-add form state — local to the section (mirrors CategoryEditor's
@@ -1071,6 +1083,7 @@ function KindSection({ kind, universeId, all, totalCount, filtered, usage, rende
characterExtensions={characterExtensions
? { ...characterExtensions, expanding: expandingId === entry.id }
: null}
+ objectExtensions={objectExtensions}
/>
))}
</ul>
diff --git a/client/src/lib/bibleLimits.js b/client/src/lib/bibleLimits.js
index bcb4bd8a0e..1084ae3dd9 100644
--- a/client/src/lib/bibleLimits.js
+++ b/client/src/lib/bibleLimits.js
@@ -66,6 +66,11 @@ export const BIBLE_LIMITS = Object.freeze({
PLACE_DESCRIPTION_MAX: 2000,
OBJECT_DESCRIPTION_MAX: 2000,
SIGNIFICANCE_MAX: 1000,
+ ATTACHMENT_CHARACTER_ID_MAX: 64,
+ ATTACHMENT_EMOTION_MAX: 120,
+ ATTACHMENT_SIGNIFICANCE_MAX: 1000,
+ ATTACHMENT_ORIGIN_MAX: 1000,
+ ATTACHMENTS_PER_OBJECT_MAX: 40,
ENTRIES_PER_BIBLE_MAX: 200,
PROMPT_MAX: 2000,
TAG_MAX: 60,
diff --git a/data.reference/prompts/stage-config.json b/data.reference/prompts/stage-config.json
index a1c1733930..7243e2e4eb 100644
--- a/data.reference/prompts/stage-config.json
+++ b/data.reference/prompts/stage-config.json
@@ -477,6 +477,20 @@
"model": "default",
"returnsJson": true,
"variables": []
+ },
+ "pipeline-editorial-object-motivation": {
+ "name": "Pipeline — Editorial Check: Unmotivated object interaction",
+ "description": "Editorial check (#1288): flags moments where a character treats an object as significant without earned motivation — no recorded attachment and no on-page setup. Reads the stitched manuscript plus the canon object↔character attachments. Returns issue-anchored findings.",
+ "model": "default",
+ "returnsJson": true,
+ "variables": []
+ },
+ "pipeline-editorial-object-backstory": {
+ "name": "Pipeline — Editorial Check: Attachment backstory consistency",
+ "description": "Editorial check (#1288): flags object↔character attachments whose origin story contradicts the attached character's established background — conflicting people, places, eras, or timelines. Canon-only (no manuscript). Returns canon-anchored findings.",
+ "model": "default",
+ "returnsJson": true,
+ "variables": []
}
}
}
diff --git a/data.reference/prompts/stages/pipeline-editorial-object-backstory.md b/data.reference/prompts/stages/pipeline-editorial-object-backstory.md
new file mode 100644
index 0000000000..531198e0dd
--- /dev/null
+++ b/data.reference/prompts/stages/pipeline-editorial-object-backstory.md
@@ -0,0 +1,59 @@
+# Pipeline — Editorial Check: Attachment backstory consistency
+
+You are a continuity editor doing a single focused pass for ONE problem:
+**attachment backstory contradictions** — an object↔character attachment whose
+*origin* (how the character came to have or care about the object) contradicts
+that character's established *background*.
+
+A contradiction is a hard conflict of fact or timeline, not merely an absence:
+
+- The origin says the character received the object from someone the background
+ says they never met (or who died before the character was born).
+- The origin is set in a place, era, or life-stage the background rules out.
+- The origin implies a relationship, skill, or circumstance the background
+ directly contradicts.
+
+## Attachments to check
+
+Each entry pairs an attachment's origin with the attached character's
+established background. Judge ONLY whether the origin and the background can
+both be true.
+
+```
+{{attachments}}
+```
+
+## Task
+
+For each attachment whose origin contradicts the character's background, name
+the contradiction precisely — quote the conflicting detail from each side —
+explain why they can't both hold, and suggest the smallest change that
+reconciles them (adjust the origin, or note what the background would need to
+allow it).
+
+Do NOT flag: an origin the background merely doesn't mention (absence is not a
+contradiction), a deliberately mysterious origin, or a minor detail that doesn't
+actually conflict.
+
+Use the object/character names from the entries as the `location` (e.g.
+`Object "Pocket Watch" — Mara's attachment`). If no attachment contradicts its
+character's background, return an empty `findings` array — do not invent issues.
+
+## Output contract
+
+Return ONLY valid JSON matching this shape — no prose, no markdown fence, no
+commentary:
+
+```json
+{
+ "findings": [
+ {
+ "severity": "high|medium|low",
+ "location": "Object \"<name>\" — <character>'s attachment",
+ "problem": "1–3 sentences naming the contradiction, quoting both conflicting details",
+ "suggestion": "1–3 sentences on the smallest change that reconciles origin and background",
+ "anchorQuote": "short verbatim quote from the contradicting origin or background"
+ }
+ ]
+}
+```
diff --git a/data.reference/prompts/stages/pipeline-editorial-object-motivation.md b/data.reference/prompts/stages/pipeline-editorial-object-motivation.md
new file mode 100644
index 0000000000..6d9c649819
--- /dev/null
+++ b/data.reference/prompts/stages/pipeline-editorial-object-motivation.md
@@ -0,0 +1,67 @@
+# Pipeline — Editorial Check: Unmotivated object interaction
+
+You are a developmental editor doing a single focused pass for ONE problem:
+**unmotivated object interaction** — a character interacts meaningfully with an
+object (clutches it, hides it, risks something for it, reacts emotionally to it)
+when the prose has given them no reason to care about that object.
+
+A well-motivated interaction is grounded: the reader already knows why the
+object matters to this character — a memory, a stake, a need, a fear. An
+*unmotivated* one asks the reader to accept significance that was never earned.
+
+## Established attachments (canon)
+
+These are the object↔character bonds the canon already records. An interaction
+is well-motivated when it lines up with an attachment here (or with stakes the
+prose itself has established). Treat an interaction as suspect when the character
+acts as though an object matters to them but no attachment and no on-page setup
+support it.
+
+```
+{{objects}}
+```
+
+## Manuscript
+
+The manuscript is stitched from the drafted issues. Each section begins with a
+header like `# Issue 3 — Title (prose)`; use the issue number in that header to
+attribute each finding to its `issueNumber`.
+
+```
+{{manuscript}}
+```
+
+## Task
+
+Identify the interactions where a character treats an object as significant
+without earned motivation. For each, quote a short verbatim anchor from the text
+(≤ 200 characters), name the issue number it appears in, explain why the
+interaction reads as unmotivated, and suggest how to ground it (an attachment to
+record, a beat of setup to add, or a reason to dramatize).
+
+Do NOT flag: interactions grounded in a recorded attachment, stakes the prose
+already established, or an object whose meaning is deliberately a mystery the
+story is actively building toward.
+
+Be specific and cite the text. If every object interaction is well-motivated,
+return an empty `findings` array — do not invent issues.
+
+## Output contract
+
+Return ONLY valid JSON matching this shape — no prose, no markdown fence, no
+commentary:
+
+```json
+{
+ "findings": [
+ {
+ "severity": "high|medium|low",
+ "issueNumber": 3,
+ "location": "string — where in the issue (scene/paragraph)",
+ "problem": "1–3 sentences naming the unmotivated interaction and why it rings hollow",
+ "suggestion": "1–3 sentences on how to ground the object's meaning for this character",
+ "anchorQuote": "short verbatim quote from the manuscript (≤ 200 chars)"
+ }
+ ]
+}
+```
diff --git a/scripts/migrations/094-object-attachment-check-stages.js b/scripts/migrations/094-object-attachment-check-stages.js
new file mode 100644
index 0000000000..6377ad47e1
--- /dev/null
+++ b/scripts/migrations/094-object-attachment-check-stages.js
@@ -0,0 +1,94 @@
+/**
+ * Seed the two object-attachment editorial-check stages into existing installs
+ * (#1288).
+ *
+ * Mirrors `092-editorial-info-dumping-stage.js`, but seeds BOTH new stages in
+ * one pass: copies each `.md` template from `data.reference/prompts/stages/`
+ * and merges its stage-config entry into `data/prompts/stage-config.json`. Boot
+ * runs migrations (server/index.js) but NOT `setup-data.js`, so an upgrade that
+ * pulls + `pm2 restart`s (rather than running `update.sh`) would otherwise leave
+ * these stages unseeded and the `objects.unmotivated-interaction` /
+ * `objects.backstory-consistency` editorial checks would throw "Stage not found"
+ * the first time they run.
+ */
+
+import { access, copyFile, mkdir, readFile, writeFile, constants } from 'fs/promises';
+import { dirname, join } from 'path';
+
+const STAGES = [
+ 'pipeline-editorial-object-motivation',
+ 'pipeline-editorial-object-backstory',
+];
+
+export default {
+ async up({ rootDir }) {
+ const stagesDir = join(rootDir, 'data', 'prompts', 'stages');
+ await mkdir(stagesDir, { recursive: true });
+
+ // 1) Copy each prompt template if it isn't already present.
+ for (const stageKey of STAGES) {
+ const filename = `${stageKey}.md`;
+ const dataPath = join(stagesDir, filename);
+ const samplePath = join(rootDir, 'data.reference', 'prompts', 'stages', filename);
+
+ const exists = await access(dataPath, constants.F_OK).then(() => true, () => false);
+ if (exists) {
+ console.log(`📝 ${stageKey} prompt: already present`);
+ continue;
+ }
+ const sampleExists = await access(samplePath, constants.F_OK).then(() => true, () => false);
+ if (!sampleExists) {
+ console.warn(`⚠️ ${stageKey}: sample missing for ${filename} — skipping copy`);
+ continue;
+ }
+ try {
+ await copyFile(samplePath, dataPath);
+ console.log(`✅ seeded ${filename}`);
+ } catch (err) {
+ console.warn(`⚠️ ${stageKey}: copy failed for ${filename}: ${err.message}`);
+ }
+ }
+
+ // 2) Merge each stage-config entry (skip any already present).
+ const installedConfigPath = join(rootDir, 'data', 'prompts', 'stage-config.json');
+ const sampleConfigPath = join(rootDir, 'data.reference', 'prompts', 'stage-config.json');
+ const sampleConfigExists = await access(sampleConfigPath, constants.F_OK).then(() => true, () => false);
+ if (!sampleConfigExists) {
+ console.warn('⚠️ 094-object-attachment-check-stages: data.reference stage-config.json missing — cannot resolve entries; skipping config write');
+ return;
+ }
+ try {
+ const sample = JSON.parse(await readFile(sampleConfigPath, 'utf8'));
+ const installedExists = await access(installedConfigPath, constants.F_OK).then(() => true, () => false);
+ const installed = installedExists
+ ? JSON.parse(await readFile(installedConfigPath, 'utf8'))
+ : { stages: {} };
+ installed.stages = installed.stages || {};
+
+ let added = 0;
+ for (const stageKey of STAGES) {
+ if (installed.stages[stageKey]) {
+ console.log(`📝 ${stageKey} stage-config: already present`);
+ continue;
+ }
+ if (!sample?.stages?.[stageKey]) {
+ console.warn(`⚠️ 094-object-attachment-check-stages: sample stage-config missing ${stageKey} — skipping`);
+ continue;
+ }
+ installed.stages[stageKey] = sample.stages[stageKey];
+ added += 1;
+ }
+
+ if (added === 0) {
+ console.log('📝 094-object-attachment-check-stages: no stage-config entries to add');
+ return;
+ }
+ await mkdir(dirname(installedConfigPath), { recursive: true });
+ await writeFile(installedConfigPath, JSON.stringify(installed, null, 2) + '\n', 'utf8');
+ const action = installedExists ? 'merged' : 'created';
+ console.log(`📝 094-object-attachment-check-stages stage-config (${action}): ${added} added`);
+ } catch (err) {
+ console.warn(`⚠️ 094-object-attachment-check-stages: stage-config merge failed: ${err.message}`);
+ }
+ },
+};
diff --git a/server/lib/editorial/checkRegistry.js b/server/lib/editorial/checkRegistry.js
index c02e2baff0..8c1b62f514 100644
--- a/server/lib/editorial/checkRegistry.js
+++ b/server/lib/editorial/checkRegistry.js
@@ -42,6 +42,15 @@ export const CHECK_FIELD_TYPES = Object.freeze(['number', 'boolean', 'text']);
// JSON_MERGE_TARGETS stage merge), so no migration is needed for a NEW stage.
export const INFO_DUMPING_STAGE = 'pipeline-editorial-info-dumping';
+// Stage names for the two object-attachment LLM checks (#1288). Like the
+// info-dumping stage, each prompt ships in data.reference/prompts/stages/ and
+// its config in stage-config.json; both propagate to fresh installs via
+// setup-data.js and to existing installs via migration 094 (boot runs
+// migrations but NOT setup-data, so the migration is required — see
+// scripts/migrations/094-object-attachment-check-stages.js).
+export const OBJECT_MOTIVATION_STAGE = 'pipeline-editorial-object-motivation';
+export const OBJECT_BACKSTORY_STAGE = 'pipeline-editorial-object-backstory';
+
// ---------------------------------------------------------------------------
// Deterministic helpers for the character-name dissimilarity check.
// ---------------------------------------------------------------------------
@@ -87,6 +96,116 @@ function* eachRelationshipLink(chars) {
}
}
+// ---------------------------------------------------------------------------
+// Shared scaffolding for the object-attachment checks (#1288). All three walk
+// `canon.objects × attachments`, resolving each attachment's `characterId`
+// against the cast, so the id-bearing object/character lists, the id→character
+// lookup, and the attachment iteration live here once.
+// ---------------------------------------------------------------------------
+
+function attachmentCanon(ctx) {
+ const objects = (ctx.canon?.objects || []).filter((o) => o && o.id);
+ const chars = (ctx.canon?.characters || []).filter((c) => c && c.id);
+ return {
+ objects,
+ chars,
+ nameById: new Map(chars.map((c) => [c.id, c.name || c.id])),
+ charById: new Map(chars.map((c) => [c.id, c])),
+ };
+}
+
+// Yields every attachment that points at a character, as { o, att }.
+function* eachAttachment(objects) {
+ for (const o of objects) {
+ for (const att of (Array.isArray(o.attachments) ? o.attachments : [])) {
+ if (att?.characterId) yield { o, att };
+ }
+ }
+}
+
+// A human-readable summary of every object + who's attached to it, fed to the
+// unmotivated-interaction LLM so it knows which objects already carry an
+// established stake (and which don't) before judging a prose interaction.
+function describeObjectAttachments(ctx) {
+ const { objects, nameById } = attachmentCanon(ctx);
+ const lines = [];
+ for (const o of objects) {
+ const atts = Array.isArray(o.attachments) ? o.attachments : [];
+ const sig = (o.significance || '').trim();
+ const attText = atts.length
+ ? atts.map((a) => {
+ const who = nameById.get(a.characterId) || a.characterId;
+ const emotion = a.emotion ? ` (${a.emotion})` : '';
+ const why = a.significance ? ` — ${a.significance}` : '';
+ return `${who}${emotion}${why}`;
+ }).join('; ')
+ : 'nobody';
+ lines.push(`- ${o.name || o.id}${sig ? ` — significance: ${sig}` : ''}\n attached to: ${attText}`);
+ }
+ return lines.join('\n') || '(no objects in canon)';
+}
+
+// The attachment rows whose `origin` can be checked against the attached
+// character's `background` — both must be present, and the character must
+// still exist (a dangling characterId is the UI/sanitizer's concern, not this
+// check's). Shared by the backstory-consistency check's `gate` (cheap presence
+// test) and its `run` (the actual prompt rows) so they never disagree.
+function attachmentBackstoryRows(ctx) {
+ const { objects, charById } = attachmentCanon(ctx);
+ const rows = [];
+ for (const { o, att } of eachAttachment(objects)) {
+ const origin = (att.origin || '').trim();
+ if (!origin) continue;
+ const char = charById.get(att.characterId);
+ if (!char) continue;
+ const background = (char.background || '').trim();
+ if (!background) continue;
+ rows.push({
+ object: o.name || o.id,
+ character: char.name || char.id,
+ emotion: (att.emotion || '').trim(),
+ origin,
+ background,
+ });
+ }
+ return rows;
+}
+
+// ---------------------------------------------------------------------------
+// Shared LLM-check helpers. Every `kind: 'llm'` check truncates an over-long
+// manuscript before the call and normalizes the model's raw findings into the
+// manuscriptReview comment shape afterward — these collapse those two repeated
+// blocks so the cap message + field validation live once.
+// ---------------------------------------------------------------------------
+
+// Truncate `full` to `cap` chars with a note so a long corpus can't overflow a
+// small/local provider's context window. A single-call safeguard; full
+// per-provider context chunking is tracked separately.
+function capManuscript(full, cap) {
+ const text = full || '';
+ return text.length > cap
+ ? `${text.slice(0, cap)}\n\n[manuscript truncated to the first ${cap} characters for this check]`
+ : text;
+}
+
+// Normalize raw LLM findings into partial manuscriptReview comments: validate
+// severity against the allow-list (fall back to the check default), force the
+// check's `category`, coerce each string field, cap the count, and drop any
+// finding with no `problem`. `withIssueNumber` keeps a model-supplied issue
+// number (manuscript-scoped checks) vs. forcing null (canon-scoped checks).
+function mapLlmFindings(raw, { severityDefault, category, max, withIssueNumber }) {
+ const list = Array.isArray(raw) ? raw : [];
+ return list.slice(0, max).map((f) => ({
+ severity: SEVERITIES.includes(f?.severity) ? f.severity : severityDefault,
+ category,
+ location: typeof f?.location === 'string' ? f.location : '',
+ problem: typeof f?.problem === 'string' ? f.problem : '',
+ suggestion: typeof f?.suggestion === 'string' ? f.suggestion : '',
+ anchorQuote: typeof f?.anchorQuote === 'string' ? f.anchorQuote : '',
+ issueNumber: withIssueNumber && Number.isInteger(f?.issueNumber) ? f.issueNumber : null,
+ })).filter((f) => f.problem);
+}
+
// ---------------------------------------------------------------------------
// Registry entries.
// ---------------------------------------------------------------------------
@@ -251,6 +370,142 @@ export const EDITORIAL_CHECKS = [
return findings;
},
},
+ {
+ id: 'objects.unattached-significant',
+ label: 'Unattached significant object',
+ description:
+ 'Flags objects with written significance but no character attachment — the object clearly matters to the story, yet nobody in the cast is on record caring about it.',
+ scope: 'series',
+ kind: 'deterministic',
+ category: 'continuity',
+ severityDefault: 'low',
+ defaultEnabled: true,
+ configSchema: z.object({}),
+ run: (ctx) => {
+ const { objects } = attachmentCanon(ctx);
+ const findings = [];
+ for (const o of objects) {
+ const hasAttachment = Array.isArray(o.attachments) && o.attachments.length > 0;
+ const significance = (o.significance || '').trim();
+ if (hasAttachment || !significance) continue;
+ const name = o.name || o.id;
+ findings.push({
+ severity: ctx.severityDefault,
+ category: 'continuity',
+ location: `Object: ${name}`,
+ problem: `"${name}" has written significance but no character is attached to it — what does this object mean to anyone in the cast?`,
+ suggestion: 'Add an attachment linking this object to the character whose backstory or emotional stake it carries (or clear its significance if it is purely set dressing).',
+ anchorQuote: name,
+ issueNumber: null,
+ });
+ }
+ return findings;
+ },
+ },
+ {
+ id: 'objects.unmotivated-interaction',
+ label: 'Unmotivated object interaction',
+ description:
+ 'LLM scan — flags moments where a character interacts meaningfully with an object the prose (and the canon attachments) have given them no reason to care about.',
+ scope: 'issue',
+ kind: 'llm',
+ category: 'continuity',
+ severityDefault: 'low',
+ defaultEnabled: true,
+ needsManuscript: true,
+ configSchema: z.object({
+ // Cap findings per run so a long manuscript can't flood the review.
+ maxFindings: z.number().int().min(1).max(50).default(12),
+ // Bound the prompt so a long series can't overflow a small/local provider's
+ // context window. Single-call safeguard — mirrors the info-dumping check.
+ maxManuscriptChars: z.number().int().min(2000).max(200_000).default(48_000),
+ }),
+ configFields: [
+ {
+ key: 'maxFindings',
+ label: 'Max findings per run',
+ type: 'number',
+ min: 1,
+ max: 50,
+ step: 1,
+ help: 'Cap findings so a long manuscript can not flood the review.',
+ },
+ {
+ key: 'maxManuscriptChars',
+ label: 'Max manuscript characters analyzed',
+ type: 'number',
+ min: 2000,
+ max: 200_000,
+ step: 1000,
+ help: 'Bounds the prompt so a long series can not overflow a small provider context window.',
+ },
+ ],
+ gate: (ctx) => (ctx.manuscript || '').trim().length > 0,
+ run: async (ctx) => {
+ const manuscript = capManuscript(ctx.manuscript, ctx.config?.maxManuscriptChars ?? 48_000);
+ const { content } = await ctx.callStagedLLM(
+ OBJECT_MOTIVATION_STAGE,
+ { manuscript, objects: describeObjectAttachments(ctx) },
+ { returnsJson: true, source: OBJECT_MOTIVATION_STAGE },
+ );
+ return mapLlmFindings(content?.findings, {
+ severityDefault: ctx.severityDefault,
+ category: 'continuity',
+ max: ctx.config?.maxFindings ?? 12,
+ withIssueNumber: true,
+ });
+ },
+ },
+ {
+ id: 'objects.backstory-consistency',
+ label: 'Attachment backstory consistency',
+ description:
+ "LLM check — flags object attachments whose origin story contradicts the attached character's established background.",
+ scope: 'noun',
+ kind: 'llm',
+ category: 'continuity',
+ severityDefault: 'medium',
+ defaultEnabled: true,
+ // Canon-only (no manuscript): compares each attachment's `origin` against the
+ // attached character's `background`, both of which live on the canon.
+ configSchema: z.object({
+ maxFindings: z.number().int().min(1).max(50).default(12),
+ }),
+ configFields: [
+ {
+ key: 'maxFindings',
+ label: 'Max findings per run',
+ type: 'number',
+ min: 1,
+ max: 50,
+ step: 1,
+ help: 'Cap findings so a large cast can not flood the review.',
+ },
+ ],
+ // Skip the LLM call entirely when no attachment has both an origin AND an
+ // attached character with a background to contradict.
+ gate: (ctx) => attachmentBackstoryRows(ctx).length > 0,
+ run: async (ctx) => {
+ const rows = attachmentBackstoryRows(ctx);
+ if (!rows.length) return [];
+ const attachments = rows.map((r, i) =>
+ `${i + 1}. Object "${r.object}" — ${r.character}'s attachment${r.emotion ? ` (${r.emotion})` : ''}\n`
+ + ` Origin (how ${r.character} came to have it): ${r.origin}\n`
+ + ` ${r.character}'s established background: ${r.background}`,
+ ).join('\n\n');
+ const { content } = await ctx.callStagedLLM(
+ OBJECT_BACKSTORY_STAGE,
+ { attachments },
+ { returnsJson: true, source: OBJECT_BACKSTORY_STAGE },
+ );
+ return mapLlmFindings(content?.findings, {
+ severityDefault: ctx.severityDefault,
+ category: 'continuity',
+ max: ctx.config?.maxFindings ?? 12,
+ withIssueNumber: false,
+ });
+ },
+ },
{
id: 'prose.info-dumping',
label: 'Info-dumping / "as you know, Bob" exposition',
@@ -295,27 +550,18 @@ export const EDITORIAL_CHECKS = [
],
gate: (ctx) => (ctx.manuscript || '').trim().length > 0,
run: async (ctx) => {
- const cap = ctx.config?.maxManuscriptChars ?? 48_000;
- const full = ctx.manuscript || '';
- const manuscript = full.length > cap
- ? `${full.slice(0, cap)}\n\n[manuscript truncated to the first ${cap} characters for this check]`
- : full;
+ const manuscript = capManuscript(ctx.manuscript, ctx.config?.maxManuscriptChars ?? 48_000);
const { content } = await ctx.callStagedLLM(
INFO_DUMPING_STAGE,
{ manuscript },
{ returnsJson: true, source: INFO_DUMPING_STAGE },
);
- const raw = Array.isArray(content?.findings) ? content.findings : [];
- const max = ctx.config?.maxFindings ?? 12;
- return raw.slice(0, max).map((f) => ({
- severity: SEVERITIES.includes(f?.severity) ? f.severity : ctx.severityDefault,
+ return mapLlmFindings(content?.findings, {
+ severityDefault: ctx.severityDefault,
category: 'exposition',
- location: typeof f?.location === 'string' ? f.location : '',
- problem: typeof f?.problem === 'string' ? f.problem : '',
- suggestion: typeof f?.suggestion === 'string' ? f.suggestion : '',
- anchorQuote: typeof f?.anchorQuote === 'string' ? f.anchorQuote : '',
- issueNumber: Number.isInteger(f?.issueNumber) ? f.issueNumber : null,
- })).filter((f) => f.problem);
+ max: ctx.config?.maxFindings ?? 12,
+ withIssueNumber: true,
+ });
},
},
];
diff --git a/server/lib/editorial/checkRegistry.test.js b/server/lib/editorial/checkRegistry.test.js
index bd1a10c240..5a0ae13189 100644
--- a/server/lib/editorial/checkRegistry.test.js
+++ b/server/lib/editorial/checkRegistry.test.js
@@ -320,3 +320,143 @@ describe('relationships.opposition-reversal — deterministic advisory', () => {
expect(getCheck('relationships.opposition-reversal').defaultEnabled).toBe(false);
});
});
+
+describe('objects.unattached-significant — deterministic check (#1288)', () => {
+ const run = (objects) =>
+ getCheck('objects.unattached-significant').run({ canon: { objects }, config: {}, severityDefault: 'low' });
+
+ it('flags an object with significance but no attachments', () => {
+ const findings = run([
+ { id: 'o1', name: 'Pocket Watch', significance: 'her father gave it to her' },
+ ]);
+ expect(findings).toHaveLength(1);
+ expect(findings[0].category).toBe('continuity');
+ expect(findings[0].location).toContain('Pocket Watch');
+ expect(findings[0].problem).toMatch(/mean to anyone/i);
+ });
+
+ it('does not flag an object that has at least one attachment', () => {
+ const findings = run([
+ { id: 'o1', name: 'Pocket Watch', significance: 'matters', attachments: [{ characterId: 'c1' }] },
+ ]);
+ expect(findings).toEqual([]);
+ });
+
+ it('does not flag an object with no significance (pure set dressing)', () => {
+ const findings = run([{ id: 'o1', name: 'A Chair' }]);
+ expect(findings).toEqual([]);
+ });
+
+ it('tolerates empty / id-less canon', () => {
+ expect(run([])).toEqual([]);
+ expect(run([{ significance: 'orphan, no id' }])).toEqual([]);
+ });
+});
+
+describe('objects.unmotivated-interaction — LLM check (#1288)', () => {
+ const baseCtx = (overrides = {}) => ({
+ manuscript: 'She clutched the watch as if it meant everything.',
+ canon: {
+ objects: [{ id: 'o1', name: 'Watch', significance: 'heirloom', attachments: [{ characterId: 'c1', emotion: 'grief' }] }],
+ characters: [{ id: 'c1', name: 'Mara' }],
+ },
+ config: { maxManuscriptChars: 48_000, maxFindings: 12 },
+ severityDefault: 'low',
+ callStagedLLM: async () => ({ content: { findings: [] } }),
+ ...overrides,
+ });
+
+ it('passes the manuscript AND an objects-attachment summary to the model', async () => {
+ let vars = null;
+ await getCheck('objects.unmotivated-interaction').run(baseCtx({
+ callStagedLLM: async (_stage, v) => { vars = v; return { content: { findings: [] } }; },
+ }));
+ expect(vars.manuscript).toContain('clutched the watch');
+ expect(vars.objects).toContain('Watch');
+ expect(vars.objects).toContain('Mara'); // resolved character name, not the id
+ });
+
+ it('caps the manuscript so a long corpus cannot overflow context', async () => {
+ let sent = null;
+ await getCheck('objects.unmotivated-interaction').run(baseCtx({
+ manuscript: 'x'.repeat(100_000),
+ config: { maxManuscriptChars: 10_000, maxFindings: 12 },
+ callStagedLLM: async (_stage, v) => { sent = v.manuscript; return { content: { findings: [] } }; },
+ }));
+ expect(sent.length).toBeLessThan(11_000);
+ expect(sent).toContain('truncated');
+ });
+
+ it('shapes findings into the continuity category and respects maxFindings', async () => {
+ const many = Array.from({ length: 30 }, (_, i) => ({ severity: 'low', problem: `p${i}`, anchorQuote: `a${i}` }));
+ const findings = await getCheck('objects.unmotivated-interaction').run(baseCtx({
+ config: { maxManuscriptChars: 48_000, maxFindings: 4 },
+ callStagedLLM: async () => ({ content: { findings: many } }),
+ }));
+ expect(findings).toHaveLength(4);
+ expect(findings.every((f) => f.category === 'continuity')).toBe(true);
+ });
+
+ it('gates off when the manuscript is empty', () => {
+ expect(getCheck('objects.unmotivated-interaction').gate(baseCtx({ manuscript: ' ' }))).toBe(false);
+ });
+});
+
+describe('objects.backstory-consistency — LLM check (#1288)', () => {
+ const canonWithRow = () => ({
+ objects: [{ id: 'o1', name: 'Watch', attachments: [{ characterId: 'c1', emotion: 'grief', origin: 'gift from her father in 1990' }] }],
+ characters: [{ id: 'c1', name: 'Mara', background: 'orphaned at birth, never knew her parents' }],
+ });
+
+ it('gates on whether any attachment has both an origin and a character with a background', () => {
+ const check = getCheck('objects.backstory-consistency');
+ expect(check.gate({ canon: canonWithRow() })).toBe(true);
+ // origin present but no background → nothing to contradict
+ expect(check.gate({ canon: {
+ objects: [{ id: 'o1', name: 'Watch', attachments: [{ characterId: 'c1', origin: 'x' }] }],
+ characters: [{ id: 'c1', name: 'Mara' }],
+ } })).toBe(false);
+ // origin missing → skip
+ expect(check.gate({ canon: {
+ objects: [{ id: 'o1', name: 'Watch', attachments: [{ characterId: 'c1' }] }],
+ characters: [{ id: 'c1', name: 'Mara', background: 'x' }],
+ } })).toBe(false);
+ // dangling characterId → not this check's job
+ expect(check.gate({ canon: {
+ objects: [{ id: 'o1', name: 'Watch', attachments: [{ characterId: 'ghost', origin: 'x' }] }],
+ characters: [{ id: 'c1', name: 'Mara', background: 'x' }],
+ } })).toBe(false);
+ });
+
+ it('feeds origin + background rows to the model and shapes findings', async () => {
+ let vars = null;
+ const findings = await getCheck('objects.backstory-consistency').run({
+ canon: canonWithRow(),
+ config: { maxFindings: 12 },
+ severityDefault: 'medium',
+ callStagedLLM: async (_stage, v) => {
+ vars = v;
+ return { content: { findings: [{ severity: 'high', problem: 'orphan cannot receive a gift from her father', suggestion: 'fix', location: 'Object "Watch" — Mara\'s attachment' }] } };
+ },
+ });
+ expect(vars.attachments).toContain('Watch');
+ expect(vars.attachments).toContain('Mara');
+ expect(vars.attachments).toContain('orphaned at birth'); // the background side
+ expect(vars.attachments).toContain('gift from her father'); // the origin side
+ expect(findings).toHaveLength(1);
+ expect(findings[0].category).toBe('continuity');
+ expect(findings[0].issueNumber).toBeNull();
+ });
+
+ it('returns no findings (and never calls the model) when no row qualifies', async () => {
+ let called = false;
+ const findings = await getCheck('objects.backstory-consistency').run({
+ canon: { objects: [{ id: 'o1', name: 'Watch' }], characters: [] },
+ config: {},
+ severityDefault: 'medium',
+ callStagedLLM: async () => { called = true; return { content: { findings: [] } }; },
+ });
+ expect(findings).toEqual([]);
+ expect(called).toBe(false);
+ });
+});
diff --git a/server/lib/schemaVersions.js b/server/lib/schemaVersions.js
index 8fe94676bd..d3559c0412 100644
--- a/server/lib/schemaVersions.js
+++ b/server/lib/schemaVersions.js
@@ -44,7 +44,13 @@ export const PORTOS_SCHEMA_VERSIONS = Object.freeze({
// loss back onto the newer peer. Bumping makes the older peer reject the
// ahead-version universe transfer instead. Per-category gate → only universe
// sync pauses with old peers; pipeline/catalog/etc keep flowing.
- universes: 6,
+ // v7 = canon objects gained `attachments[]` (structured object↔character
+ // emotional-attachment links — emotion/significance/origin/role, #1288).
+ // Same rationale as v6: additive + gracefully degrading, but version-gated so
+ // a not-yet-upgraded peer that re-sanitizes a universe through its
+ // attachments-unaware `sanitizeObject` can't silently strip the field and
+ // LWW the loss back onto the newer peer.
+ universes: 7,
// v1 = post-split. Migrations 035/036 introduced the pipeline collection
// layout for issues and series.
// v2 = `stages.audio.audioMode` + `stages.audio.cues[]` added (whole-episode
diff --git a/server/lib/schemaVersions.test.js b/server/lib/schemaVersions.test.js
index d777d09c26..33a5d0a618 100644
--- a/server/lib/schemaVersions.test.js
+++ b/server/lib/schemaVersions.test.js
@@ -18,9 +18,10 @@ describe('PORTOS_SCHEMA_VERSIONS', () => {
// If this changes, the corresponding migration in scripts/migrations/
// must ship alongside it. The test exists to make a layout bump a
// deliberate two-file edit.
- // v6 = canon characters gained relationshipLinks[] (#1287); additive +
- // version-gated so an older peer can't strip-then-LWW the field back.
- expect(PORTOS_SCHEMA_VERSIONS.universes).toBe(6);
+ // v6 = canon characters gained relationshipLinks[] (#1287); v7 = canon
+ // objects gained attachments[] (#1288). Both additive + version-gated so an
+ // older peer can't strip-then-LWW the field back.
+ expect(PORTOS_SCHEMA_VERSIONS.universes).toBe(7);
});
it('declares pipeline collection layout versions', () => {
@@ -39,14 +40,14 @@ describe('buildPortosMeta', () => {
it('returns { portosVersion, schemaVersions } with the live registry', async () => {
const meta = await buildPortosMeta();
expect(meta.portosVersion).toMatch(/^\d+\.\d+\.\d+/);
- expect(meta.schemaVersions.universes).toBe(6);
+ expect(meta.schemaVersions.universes).toBe(7);
expect(meta.schemaVersions.pipelineIssues).toBe(2);
expect(meta.schemaVersions.pipelineSeries).toBe(2);
});
it('overrides merge into schemaVersions', async () => {
const meta = await buildPortosMeta({ schemaVersions: { future: 1 } });
- expect(meta.schemaVersions.universes).toBe(6);
+ expect(meta.schemaVersions.universes).toBe(7);
expect(meta.schemaVersions.future).toBe(1);
});
});
@@ -194,7 +195,7 @@ describe('scopeVersionDiff', () => {
// Sender is ahead on mediaCollections only; a universe transfer scopes to
// ['universes'] and stays compatible even though the union diff is not.
const union = compareSchemaVersions(
- { universes: 6, pipelineSeries: 2, pipelineIssues: 2, mediaCollections: 2 },
+ { universes: 7, pipelineSeries: 2, pipelineIssues: 2, mediaCollections: 2 },
PORTOS_SCHEMA_VERSIONS,
);
expect(union.compatible).toBe(false); // mediaCollections 2 > 1
diff --git a/server/lib/storyBible.js b/server/lib/storyBible.js
index c72be19404..3c04364606 100644
--- a/server/lib/storyBible.js
+++ b/server/lib/storyBible.js
@@ -101,6 +101,17 @@ export const BIBLE_LIMITS = Object.freeze({
// Objects
OBJECT_DESCRIPTION_MAX: 2000,
SIGNIFICANCE_MAX: 1000,
+ // Structured object↔character attachment links (#1288). The legacy prose
+ // `significance` field above stays; `attachments[]` is additive. Each link
+ // ties an object to ONE character and captures the emotion/significance/origin
+ // of that bond plus a `role` archetype. `characterId` caps match the canon id
+ // format; the prose fields are roomy because writers describe backstory at
+ // length, but tighter than NOTES so a runaway extraction stays bounded.
+ ATTACHMENT_CHARACTER_ID_MAX: 64,
+ ATTACHMENT_EMOTION_MAX: 120,
+ ATTACHMENT_SIGNIFICANCE_MAX: 1000,
+ ATTACHMENT_ORIGIN_MAX: 1000,
+ ATTACHMENTS_PER_OBJECT_MAX: 40,
// Per-bible cap (universal — protects against runaway extraction)
ENTRIES_PER_BIBLE_MAX: 200,
PROMPT_MAX: 2000,
@@ -155,6 +166,16 @@ export const RELATIONSHIP_OPPOSITION_AXES = Object.freeze([
const RELATIONSHIP_LINK_TYPE_SET = new Set(RELATIONSHIP_LINK_TYPES);
const RELATIONSHIP_OPPOSITION_AXIS_SET = new Set(RELATIONSHIP_OPPOSITION_AXES);
+// Object↔character attachment archetypes (#1288). `role` tags WHAT the object
+// is to the character narratively; `custom` lets the writer name one the list
+// misses (the prose `significance`/`origin` carry the specifics). An
+// unrecognized value coerces to `custom` rather than dropping the link, so a
+// legacy/peer payload carrying a future role still round-trips with its prose.
+export const ATTACHMENT_ROLES = Object.freeze([
+ 'talisman', 'macguffin', 'memento', 'tool', 'symbol', 'custom',
+]);
+const ATTACHMENT_ROLE_SET = new Set(ATTACHMENT_ROLES);
+
// Enums for the location-classification fields on Place canon entries.
// Mirrors AnyFilm's INT/EXT + time-of-day taxonomy so generated panels and
// scene starts inherit lighting/composition cues for free.
@@ -672,6 +693,31 @@ function sanitizeRelationshipLink(raw) {
return out;
}
+// Structured object↔character attachment (#1288). Requires a `characterId` — an
+// attachment with nothing to bind to is meaningless, so a blank target drops the
+// row (matches the targetCharacterId-required pattern in sanitizeRelationshipLink).
+// `role` normalizes an unrecognized value to `custom` rather than dropping it, so
+// a peer/legacy payload carrying a future role still round-trips with its prose
+// (emotion/significance/origin) intact. `locked` persists explicit true/false only.
+function sanitizeAttachment(raw) {
+ if (!raw || typeof raw !== 'object') return null;
+ const characterId = trimTo(raw.characterId, BIBLE_LIMITS.ATTACHMENT_CHARACTER_ID_MAX);
+ if (!characterId) return null;
+ const roleRaw = trimTo(raw.role, 60);
+ const role = ATTACHMENT_ROLE_SET.has(roleRaw) ? roleRaw : 'custom';
+ const out = {
+ id: ensureId(raw.id, 'att-'),
+ characterId,
+ emotion: trimTo(raw.emotion, BIBLE_LIMITS.ATTACHMENT_EMOTION_MAX),
+ significance: trimTo(raw.significance, BIBLE_LIMITS.ATTACHMENT_SIGNIFICANCE_MAX),
+ origin: trimTo(raw.origin, BIBLE_LIMITS.ATTACHMENT_ORIGIN_MAX),
+ role,
+ };
+ if (raw.locked === true) out.locked = true;
+ else if (raw.locked === false) out.locked = false;
+ return out;
+}
+
// Shared canon extras applied to every kind. Persists explicit `locked: true`
// AND `locked: false` so a Universe-Builder caller can flip the bit and have
// the change survive round-trips. Missing `locked` still collapses to absent
@@ -843,6 +889,14 @@ export function sanitizeObject(raw, { idPrefix = DEFAULT_ID_PREFIX.object, prese
aliases: cleanStringArray(raw.aliases, BIBLE_LIMITS.ALIAS_MAX, BIBLE_LIMITS.ALIASES_PER_ENTRY_MAX),
description: trimTo(raw.description, BIBLE_LIMITS.OBJECT_DESCRIPTION_MAX),
significance: trimTo(raw.significance, BIBLE_LIMITS.SIGNIFICANCE_MAX),
+ // Structured object↔character attachment links (#1288). Additive to the
+ // legacy prose `significance` field above. Empty array stays the legacy
+ // shape — every existing object keeps round-tripping unchanged.
+ attachments: sanitizeListWith(
+ raw.attachments,
+ sanitizeAttachment,
+ BIBLE_LIMITS.ATTACHMENTS_PER_OBJECT_MAX,
+ ),
notes: trimTo(raw.notes, BIBLE_LIMITS.NOTES_MAX),
imageRefs,
// A5: canonical prop / hero-object reference render.
diff --git a/server/lib/storyBible.test.js b/server/lib/storyBible.test.js
index dc13f8e444..258f994b80 100644
--- a/server/lib/storyBible.test.js
+++ b/server/lib/storyBible.test.js
@@ -413,6 +413,96 @@ describe('storyBible — sanitizeCharacter', () => {
});
});
+ describe('attachments (#1288)', () => {
+ it('defaults a missing attachments field to an empty array (legacy shape)', () => {
+ expect(sanitizeObject({ name: 'Watch' }).attachments).toEqual([]);
+ });
+
+ it('coerces a non-array attachments field to an empty array', () => {
+ expect(sanitizeObject({ name: 'Watch', attachments: 'nope' }).attachments).toEqual([]);
+ });
+
+ it('sanitizes a complete attachment and mints an att- id', () => {
+ const out = sanitizeObject({
+ name: 'Watch',
+ attachments: [{ characterId: 'chr-mara', emotion: 'grief', significance: 'her father\'s', origin: 'inherited', role: 'memento' }],
+ });
+ expect(out.attachments).toHaveLength(1);
+ expect(out.attachments[0].id).toMatch(/^att-/);
+ expect(out.attachments[0].characterId).toBe('chr-mara');
+ expect(out.attachments[0].emotion).toBe('grief');
+ expect(out.attachments[0].significance).toBe('her father\'s');
+ expect(out.attachments[0].origin).toBe('inherited');
+ expect(out.attachments[0].role).toBe('memento');
+ });
+
+ it('preserves a provided id verbatim', () => {
+ const out = sanitizeObject({ name: 'Watch', attachments: [{ id: 'att-fixed-1', characterId: 'chr-mara' }] });
+ expect(out.attachments[0].id).toBe('att-fixed-1');
+ });
+
+ it('drops an attachment with no characterId (meaningless link)', () => {
+ const out = sanitizeObject({
+ name: 'Watch',
+ attachments: [{ emotion: 'grief' }, { characterId: 'chr-mara' }],
+ });
+ expect(out.attachments).toHaveLength(1);
+ expect(out.attachments[0].characterId).toBe('chr-mara');
+ });
+
+ it('coerces an unrecognized role to custom (keeps prose intact)', () => {
+ const out = sanitizeObject({
+ name: 'Watch',
+ attachments: [{ characterId: 'chr-mara', role: 'heirloom', significance: 'matters' }],
+ });
+ expect(out.attachments[0].role).toBe('custom');
+ expect(out.attachments[0].significance).toBe('matters');
+ });
+
+ it('defaults a missing role to custom', () => {
+ const out = sanitizeObject({ name: 'Watch', attachments: [{ characterId: 'chr-mara' }] });
+ expect(out.attachments[0].role).toBe('custom');
+ });
+
+ it('persists explicit locked true/false but drops a non-boolean', () => {
+ const out = sanitizeObject({
+ name: 'Watch',
+ attachments: [
+ { characterId: 'a', locked: true },
+ { characterId: 'b', locked: false },
+ { characterId: 'c', locked: 'yes' },
+ ],
+ });
+ expect(out.attachments[0].locked).toBe(true);
+ expect(out.attachments[1].locked).toBe(false);
+ expect(out.attachments[2].locked).toBeUndefined();
+ });
+
+ it('caps the list at ATTACHMENTS_PER_OBJECT_MAX', () => {
+ const tooMany = Array.from(
+ { length: BIBLE_LIMITS.ATTACHMENTS_PER_OBJECT_MAX + 5 },
+ (_, i) => ({ characterId: `chr-${i}` }),
+ );
+ const out = sanitizeObject({ name: 'Watch', attachments: tooMany });
+ expect(out.attachments).toHaveLength(BIBLE_LIMITS.ATTACHMENTS_PER_OBJECT_MAX);
+ });
+
+ it('clamps over-long prose fields', () => {
+ const out = sanitizeObject({
+ name: 'Watch',
+ attachments: [{
+ characterId: 'chr-mara',
+ significance: 'x'.repeat(BIBLE_LIMITS.ATTACHMENT_SIGNIFICANCE_MAX + 50),
+ origin: 'y'.repeat(BIBLE_LIMITS.ATTACHMENT_ORIGIN_MAX + 50),
+ emotion: 'z'.repeat(BIBLE_LIMITS.ATTACHMENT_EMOTION_MAX + 50),
+ }],
+ });
+ expect(out.attachments[0].significance.length).toBe(BIBLE_LIMITS.ATTACHMENT_SIGNIFICANCE_MAX);
+ expect(out.attachments[0].origin.length).toBe(BIBLE_LIMITS.ATTACHMENT_ORIGIN_MAX);
+ expect(out.attachments[0].emotion.length).toBe(BIBLE_LIMITS.ATTACHMENT_EMOTION_MAX);
+ });
+ });
+
describe('extended character fields (novelist + graphic-novelist depth)', () => {
it('defaults every new string field to empty + every list field to []', () => {
const out = sanitizeCharacter({ name: 'Bare' });
diff --git a/server/lib/validation.js b/server/lib/validation.js
index dfd449a0c9..014f77daa2 100644
--- a/server/lib/validation.js
+++ b/server/lib/validation.js
@@ -3,7 +3,7 @@ import { ServerError } from './errorHandler.js';
import { partialWithoutDefaults, emptyToUndefined, emptyToNull } from './zodCompat.js';
import { WORK_KINDS, WORK_STATUSES, ANALYSIS_KINDS } from './writersRoomPresets.js';
import { ALL_STYLE_IDS, STYLE_ID } from './writersRoomStylePresets.js';
-import { BIBLE_LIMITS, RELATIONSHIP_LINK_TYPES, RELATIONSHIP_OPPOSITION_AXES } from './storyBible.js';
+import { BIBLE_LIMITS, RELATIONSHIP_LINK_TYPES, RELATIONSHIP_OPPOSITION_AXES, ATTACHMENT_ROLES } from './storyBible.js';
import { MIN_TIMEOUT as STAGE_TIMEOUT_MIN_MS, MAX_TIMEOUT as STAGE_TIMEOUT_MAX_MS } from './aiToolkit/constants.js';
// gpt-image-2 (codex backend) caps at 3840px per edge and 8,294,400 total
@@ -1180,11 +1180,26 @@ export const writersRoomPlaceUpdateSchema = z.object({
}).strict();
const wrObjectTextField = z.string().max(2000);
+// Structured object↔character attachment links (#1288). `id` is omitted on
+// POSTs — the sanitizer mints it. `role` accepts the known archetype tokens; an
+// unrecognized value (legacy/peer payload) is coerced to `custom` by the
+// sanitizer, not rejected here, so older clients never 400. Limits sourced from
+// BIBLE_LIMITS so bumping a constant updates Zod automatically.
+const wrAttachmentsField = z.array(z.object({
+ id: z.string().trim().max(64).optional(),
+ characterId: z.string().trim().min(1).max(BIBLE_LIMITS.ATTACHMENT_CHARACTER_ID_MAX),
+ emotion: z.string().max(BIBLE_LIMITS.ATTACHMENT_EMOTION_MAX).optional(),
+ significance: z.string().max(BIBLE_LIMITS.ATTACHMENT_SIGNIFICANCE_MAX).optional(),
+ origin: z.string().max(BIBLE_LIMITS.ATTACHMENT_ORIGIN_MAX).optional(),
+ role: z.enum(ATTACHMENT_ROLES).or(z.string().trim().max(60)).optional(),
+ locked: z.boolean().optional(),
+}).strict()).max(BIBLE_LIMITS.ATTACHMENTS_PER_OBJECT_MAX);
export const writersRoomObjectCreateSchema = z.object({
name: z.string().trim().min(1).max(200),
aliases: z.array(z.string().trim().min(1).max(200)).max(20).optional(),
description: wrObjectTextField.optional(),
significance: wrObjectTextField.optional(),
+ attachments: wrAttachmentsField.optional(),
notes: wrObjectTextField.optional(),
}).strict();
export const writersRoomObjectUpdateSchema = z.object({
@@ -1192,6 +1207,7 @@ export const writersRoomObjectUpdateSchema = z.object({
aliases: z.array(z.string().trim().min(1).max(200)).max(20).optional(),
description: wrObjectTextField.optional(),
significance: wrObjectTextField.optional(),
+ attachments: wrAttachmentsField.optional(),
notes: wrObjectTextField.optional(),
}).strict();
diff --git a/server/lib/validation.test.js b/server/lib/validation.test.js
index 03ed642c32..3c3658617f 100644
--- a/server/lib/validation.test.js
+++ b/server/lib/validation.test.js
@@ -16,7 +16,8 @@ import {
featureProviderConfigSchema,
codeReviewSettingsSchema,
locationSettingsSchema,
- writersRoomCharacterUpdateSchema
+ writersRoomCharacterUpdateSchema,
+ writersRoomObjectUpdateSchema
} from './validation.js';
describe('validation.js', () => {
@@ -827,4 +828,40 @@ describe('validation.js', () => {
expect(result.success).toBe(false);
});
});
+
+ describe('writersRoomObjectUpdateSchema — attachments (#1288)', () => {
+ it('accepts a well-formed attachment', () => {
+ const result = writersRoomObjectUpdateSchema.safeParse({
+ attachments: [{
+ characterId: 'chr-mara',
+ emotion: 'grief',
+ significance: 'her father gave it to her',
+ origin: 'inherited at his funeral',
+ role: 'memento',
+ }],
+ });
+ expect(result.success).toBe(true);
+ });
+
+ it('accepts an attachment with no id (server mints it) and a custom role', () => {
+ const result = writersRoomObjectUpdateSchema.safeParse({
+ attachments: [{ characterId: 'chr-mara', role: 'heirloom' }],
+ });
+ expect(result.success).toBe(true);
+ });
+
+ it('rejects an attachment missing characterId', () => {
+ const result = writersRoomObjectUpdateSchema.safeParse({
+ attachments: [{ emotion: 'grief' }],
+ });
+ expect(result.success).toBe(false);
+ });
+
+ it('rejects an unknown key inside an attachment (strict)', () => {
+ const result = writersRoomObjectUpdateSchema.safeParse({
+ attachments: [{ characterId: 'chr-mara', bogus: true }],
+ });
+ expect(result.success).toBe(false);
+ });
+ });
});
diff --git a/server/services/pipeline/editorial/checkRunner.test.js b/server/services/pipeline/editorial/checkRunner.test.js
index 5c84fb968b..9a53343698 100644
--- a/server/services/pipeline/editorial/checkRunner.test.js
+++ b/server/services/pipeline/editorial/checkRunner.test.js
@@ -46,6 +46,16 @@ vi.mock('../manuscriptReview.js', () => ({ seedReviewFromFindings: (...a) => see
const { runEditorialChecks, buildEditorialCheckPlan } = await import('./checkRunner.js');
const { runStagedLLM } = await import('../../../lib/stageRunner.js');
const { collectManuscriptSections } = await import('../arcPlanner.js');
+const { listChecks } = await import('../../../lib/editorial/index.js');
+
+// Build a `pipelineEditorialChecks.checks` map that disables every check
+// matching `predicate` — keeps these fixtures robust as the registry grows
+// (new checks shouldn't silently break a "no LLM" / "no checks" assertion).
+const disableWhere = (predicate) => ({
+ pipelineEditorialChecks: {
+ checks: Object.fromEntries(listChecks().filter(predicate).map((c) => [c.id, { enabled: false }])),
+ },
+});
beforeEach(() => {
seedStore.length = 0;
@@ -100,18 +110,16 @@ describe('runEditorialChecks', () => {
});
it('skips disabled checks', async () => {
- const settings = { pipelineEditorialChecks: { checks: { 'prose.info-dumping': { enabled: false } } } };
+ // Disable every LLM check → no provider call, only deterministic findings.
+ // The mock canon has no objects/links, so naming is the only producer.
+ const settings = disableWhere((c) => c.kind === 'llm');
const result = await runEditorialChecks('s1', { settings });
expect(runStagedLLM).not.toHaveBeenCalled();
expect(result.findings.every((f) => f.checkId === 'naming.dissimilar-names')).toBe(true);
});
it('returns an empty result when no checks are enabled', async () => {
- const settings = {
- pipelineEditorialChecks: {
- checks: { 'naming.dissimilar-names': { enabled: false }, 'prose.info-dumping': { enabled: false } },
- },
- };
+ const settings = disableWhere(() => true);
const result = await runEditorialChecks('s1', { settings });
expect(result.findings).toEqual([]);
expect(seedReviewFromFindings).not.toHaveBeenCalled();
@@ -128,8 +136,11 @@ describe('runEditorialChecks', () => {
});
it('one failing check does not abort the pass', async () => {
+ // Make info-dumping the only enabled LLM check so the single rejection lands
+ // on it (the object LLM checks would otherwise consume the mockRejectedOnce).
+ const settings = disableWhere((c) => c.kind === 'llm' && c.id !== 'prose.info-dumping');
runStagedLLM.mockRejectedValueOnce(new Error('provider down'));
- const result = await runEditorialChecks('s1');
+ const result = await runEditorialChecks('s1', { settings });
// Naming still produced findings; info-dump recorded an error in perCheck.
expect(result.findings.some((f) => f.checkId === 'naming.dissimilar-names')).toBe(true);
const infodump = result.perCheck.find((p) => p.checkId === 'prose.info-dumping');