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
feat: editorial eyeline-match continuity check on storyboard shots (#1466)
Adam Eivy4c058b7bcea6
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 79e8463719..e8e80f0fe8 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -7,6 +7,7 @@## Added- **[issue-1408] LoRA training quality-of-life: vision-assisted reference-sheet slicing, caption with Claude/Codex CLI providers, and a richer training queue.** Three improvements to building character LoRAs (Create → LoRA Training). **(1) Smarter sheet slicing** — "Slice reference sheet" now offers *Auto-detect figures with a vision model*, which asks a vision model to draw a tight box around each figure on the turnaround and crops those instead of a rigid grid; it falls back to the columns×rows grid automatically when no vision model is installed or detection finds nothing, so you still get crops to prune either way. **(2) Caption with a CLI model** — the caption-model picker now also lists vision-capable CLI providers (Codex / Claude Code), so you can auto-caption a dataset with `codex` or `claude` (vision) rather than only a local LM Studio / Ollama vision model. **(3) Training queue at a glance** — the new Training queue on the LoRA Training page shows each run's loss curve (a sparkline over its checkpoints) and sample thumbnails right in the row, so you can watch a run learn — and spot a divergence — without opening it. (Part of #1227, #1408)+- **[issue-1466] Editorial check flags storyboard eyeline-match breaks — the LLM-assisted sibling of the deterministic shot-continuity check.** A new **Storyboard eyeline match (gaze continuity)** LLM check (Create → Editorial Checks) reads a scene's per-issue storyboard shots and flags the eyeline mistakes a deterministic scan can't compute: two characters in conversation whose **gaze directions don't reciprocate** across the cut (both look the same way instead of toward each other), a **described eyeline that contradicts the shot's tagged screen direction** (the storyboard's own two signals disagree), and a **reverse-angle that doesn't flip the eyeline**. Where the deterministic **Storyboard shot continuity** check (#1315) reasons over the structured `shotType`/`screenDirection`/continuity-link fields for 180°-rule axis reversals and shot-type monotony, an eyeline match needs *semantic* reading of the free-text shot descriptions — so this one runs an LLM over a compact per-scene shot block (id, framing, direction, continuity link, description), built only from scenes that have two-or-more described shots to compare. Findings render as `Continuity` notes anchored to the offending shot pair + issue. The check skips the model call entirely when no scene qualifies. Ships a new stage prompt (`pipeline-editorial-eyeline-match`) that migrates for existing installs (117). (`server/lib/editorial/shotContinuity.js`, `server/lib/editorial/checkRegistry.js`, `data.reference/prompts/stages/pipeline-editorial-eyeline-match.md`, `scripts/migrations/117-editorial-eyeline-match-stage.js`, Part of #1283, #1466)- **[issue-1412] Editorial check classifies unmodeled proper nouns used as character names — the LLM-assisted half of roster economy.** A new **Unmodeled proper nouns used as character names** LLM check (Create → Editorial Checks) closes the gap the deterministic **roster economy** check (#1292) deliberately left open: that scan only sees canon names + aliases, so a proper noun used as an *apparent* character name that was never added to the story bible is invisible to it. This check surfaces those — and **classifies** each one, because a keyword scan can't tell a person from a place, organization, brand, or honorific. It reads the stitched manuscript plus your canon roster (names + aliases) as an exclusion list, flags capitalized proper nouns used as character names that are **absent from canon**, and calls out **throwaway one-appearance names** the reader is told to remember but who never recur — suggesting either adding them to canon or recasting them as an unnamed description. Unlike roster economy it runs even on an **empty bible** (then every named proper noun is a candidate). The LLM does only the judgment it alone can — surface a name and confirm it's a *person* — while a **deterministic pass counts each surfaced name's appearances across the whole manuscript and authors the verdict** (one-appearance throwaway vs recurring), so a long book reviewed in chunks never mislabels a name that appears in chapters 1 and 12 as a throwaway (and the same name surfaced from two chunks collapses to one finding). Findings render as `Casting` notes anchored to the issue + a verbatim quote. Ships a new stage prompt (`pipeline-editorial-unmodeled-names`) that migrates for existing installs (116). (`server/lib/editorial/checkRegistry.js`, `data.reference/prompts/stages/pipeline-editorial-unmodeled-names.md`, `scripts/migrations/116-editorial-unmodeled-names-stage.js`, Part of #1283, #1412)- **The Local LLM Playground now shows which Ollama models are warm in memory (and which one is processing).** The models sidebar reads Ollama's `/api/ps` (the same loaded-model probe the Memory Management panel uses) and flags each resident model with a green **In memory** badge carrying its VRAM footprint, plus a relative **"frees in Nm"** countdown until Ollama auto-evicts it. While a run is in flight, the model(s) it's driving show a **Processing** badge with a live spinner — derived from the playground's own in-flight run since `/api/ps` reports residency but not which model is mid-generation. A header chip summarizes **"N in memory"** at a glance. The loaded list polls every 6s (2s while busy) and refreshes on the manual refresh button. (`client/src/pages/LocalLlmPlayground.jsx`)diff --git a/data.reference/prompts/stage-config.json b/data.reference/prompts/stage-config.jsonindex edc88aff7f..f597ca9c28 100644--- a/data.reference/prompts/stage-config.json+++ b/data.reference/prompts/stage-config.json@@ -645,6 +645,13 @@"model": "default","returnsJson": true,"variables": []+ },+ "pipeline-editorial-eyeline-match": {+ "name": "Pipeline — Editorial Check: Storyboard eyeline match",+ "description": "Editorial check (#1466): LLM scan of a scene's storyboard shot list for eyeline-match breaks — two characters in conversation whose gaze directions don't reciprocate across the cut, or a described eyeline that contradicts the shot's tagged screen direction. The judgment sibling of the deterministic visual.shot-continuity check; reads the per-issue storyboard shots (storyboard.shots). Returns issue-anchored findings.",+ "model": "default",+ "returnsJson": true,+ "variables": []}}}diff --git a/data.reference/prompts/stages/pipeline-editorial-eyeline-match.md b/data.reference/prompts/stages/pipeline-editorial-eyeline-match.mdnew file mode 100644index 0000000000..db8548f6a5--- /dev/null+++ b/data.reference/prompts/stages/pipeline-editorial-eyeline-match.md@@ -0,0 +1,71 @@+# Pipeline — Editorial Check: Storyboard eyeline match++You are a continuity editor doing a single focused pass over a comic/film+storyboard for ONE problem: **eyeline-match breaks** within a scene.++An eyeline match is the rule that when the camera cuts between two characters in+the same exchange, their gaze directions must RECIPROCATE — if character A looks+screen-right at B, then B (filmed in the answering shot) should look screen-left+back at A. When both look the same way, or a character's described gaze+contradicts the shot's tagged screen direction, the audience loses the sense of+who is looking at whom across the cut.++Flag ONLY these eyeline problems:++- **Non-reciprocating gaze across a conversation cut.** Two characters talking to+ (or looking at) each other across consecutive/continuity-linked shots whose+ gaze directions are the SAME (both screen-left, or both screen-right) instead+ of opposite — so they appear to look past each other, not at each other.+- **Gaze contradicts the tagged screen direction.** A shot whose free-text+ description says a character looks one way while the shot's recorded screen+ direction is the opposite — the storyboard's own two signals disagree.+- **A reverse-angle that doesn't flip the eyeline.** A clear shot/reverse-shot+ pair (the answering angle on the second character) where the second character's+ gaze isn't mirrored, so the cut reads as both facing the same off-screen point.++## Shots to check++Each scene lists its shots in order. A shot line carries its id, its framing and+tagged screen direction in brackets, an optional "continues from" continuity+link, and the free-text description (where the gaze/eyeline lives):++```+{{shots}}+```++## Task++For each eyeline-match break, name the offending shot pair by id, quote the gaze+detail from each side, explain why the eyelines don't reciprocate, and suggest+the smallest fix (flip one shot's screen direction, or re-describe the gaze).++Use the scene/issue label and the two shot ids as the `location` (e.g.+`Issue 4 — INT. KITCHEN: shots shot-02 ↔ shot-03`). Set `issueNumber` to the+issue number shown in that scene's header when present (omit it otherwise).++Do NOT flag: a single character alone in frame (no one to match eyelines with),+a deliberate look-away or off-screen glance the description makes clear, a shot+with no gaze described, or framing/shot-type variety (a different check covers+that). Absence of a stated eyeline is NOT a break — only a genuine contradiction+or non-reciprocating pair is. If nothing breaks eyeline continuity, 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": 4,+ "location": "Issue <n> — <scene>: shots <idA> ↔ <idB>",+ "problem": "1–3 sentences naming the eyeline break, quoting the gaze detail from each shot",+ "suggestion": "1–3 sentences on the smallest fix (flip a screen direction or re-describe the gaze)",+ "anchorQuote": "short verbatim quote from one of the conflicting shot descriptions"+ }+ ]+}+```diff --git a/scripts/migrations/117-editorial-eyeline-match-stage.js b/scripts/migrations/117-editorial-eyeline-match-stage.jsnew file mode 100644index 0000000000..a5347164d2--- /dev/null+++ b/scripts/migrations/117-editorial-eyeline-match-stage.js@@ -0,0 +1,75 @@+/**+ * Seed the `pipeline-editorial-eyeline-match` stage into existing installs (#1466).+ *+ * Mirrors `116-editorial-unmodeled-names-stage.js`: copies the `.md` template+ * from `data.reference/prompts/stages/` and merges the 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 the new eyeline-match stage unseeded+ * and the `visual.eyeline-match` editorial check would throw "Stage not found"+ * the first time it runs.+ */++import { access, copyFile, mkdir, readFile, writeFile, constants } from 'fs/promises';+import { dirname, join } from 'path';++const FILENAME = 'pipeline-editorial-eyeline-match.md';+const STAGE_KEY = 'pipeline-editorial-eyeline-match';++export default {+ async up({ rootDir }) {+ const stagesDir = join(rootDir, 'data', 'prompts', 'stages');+ await mkdir(stagesDir, { recursive: true });++ 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(`📝 pipeline-editorial-eyeline-match prompt: already present`);+ } else {+ const sampleExists = await access(samplePath, constants.F_OK).then(() => true, () => false);+ if (!sampleExists) {+ console.warn(`⚠️ pipeline-editorial-eyeline-match: sample missing for ${FILENAME} — skipping copy`);+ } else {+ try {+ await copyFile(samplePath, dataPath);+ console.log(`✅ seeded ${FILENAME}`);+ } catch (err) {+ console.warn(`⚠️ pipeline-editorial-eyeline-match: copy failed for ${FILENAME}: ${err.message}`);+ }+ }+ }++ 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('⚠️ pipeline-editorial-eyeline-match: data.reference stage-config.json missing — cannot resolve entry; 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 || {};+ if (installed.stages[STAGE_KEY]) {+ console.log(`📝 pipeline-editorial-eyeline-match stage-config: already present`);+ return;+ }+ if (!sample?.stages?.[STAGE_KEY]) {+ console.warn(`⚠️ pipeline-editorial-eyeline-match: sample stage-config missing ${STAGE_KEY} — skipping`);+ return;+ }+ installed.stages[STAGE_KEY] = sample.stages[STAGE_KEY];+ await mkdir(dirname(installedConfigPath), { recursive: true });+ await writeFile(installedConfigPath, JSON.stringify(installed, null, 2) + '\n', 'utf8');+ const action = installedExists ? 'merged' : 'created';+ console.log(`📝 pipeline-editorial-eyeline-match stage-config (${action}): 1 added`);+ } catch (err) {+ console.warn(`⚠️ pipeline-editorial-eyeline-match: stage-config merge failed: ${err.message}`);+ }+ },+};diff --git a/scripts/migrations/117-editorial-eyeline-match-stage.test.js b/scripts/migrations/117-editorial-eyeline-match-stage.test.jsnew file mode 100644index 0000000000..4540dd905a--- /dev/null+++ b/scripts/migrations/117-editorial-eyeline-match-stage.test.js@@ -0,0 +1,86 @@+import { describe, it, expect, beforeEach, afterEach } from 'vitest';+import { mkdtempSync, rmSync, mkdirSync, writeFileSync, readFileSync, existsSync } from 'fs';+import { tmpdir } from 'os';+import { join, dirname } from 'path';+import { fileURLToPath } from 'url';++import migration from './117-editorial-eyeline-match-stage.js';++// scripts/migrations/<this> → ../.. is the repo root (matches _testHelpers.js).+const repoRoot = join(dirname(fileURLToPath(import.meta.url)), '..', '..');++// First-shipment seed migration (mirrors 116) — no MD5 bookkeeping, so the+// seed / no-clobber behavior is asserted directly.++const FILENAME = 'pipeline-editorial-eyeline-match.md';+const STAGE_KEY = 'pipeline-editorial-eyeline-match';+const BODY = '# Pipeline — Editorial Check: Storyboard eyeline match\n\nshipped body\n';++describe('migration 117 — seed editorial-eyeline-match stage', () => {+ let rootDir;+ let stagesDir;+ let refStagesDir;+ let installedConfigPath;++ const seedReference = ({ withConfig = true } = {}) => {+ writeFileSync(join(refStagesDir, FILENAME), BODY);+ if (withConfig) {+ const refConfigPath = join(rootDir, 'data.reference', 'prompts', 'stage-config.json');+ writeFileSync(+ refConfigPath,+ JSON.stringify({ stages: { [STAGE_KEY]: { name: STAGE_KEY, description: 'desc', model: 'default', returnsJson: true, variables: [] } } }, null, 2) + '\n',+ );+ }+ };++ beforeEach(() => {+ rootDir = mkdtempSync(join(tmpdir(), 'migration-117-'));+ stagesDir = join(rootDir, 'data', 'prompts', 'stages');+ refStagesDir = join(rootDir, 'data.reference', 'prompts', 'stages');+ installedConfigPath = join(rootDir, 'data', 'prompts', 'stage-config.json');+ mkdirSync(stagesDir, { recursive: true });+ mkdirSync(refStagesDir, { recursive: true });+ });++ afterEach(() => {+ rmSync(rootDir, { recursive: true, force: true });+ });++ it('seeds the .md template and merges the stage-config entry on a fresh install', async () => {+ seedReference();+ await expect(migration.up({ rootDir })).resolves.not.toThrow();+ expect(readFileSync(join(stagesDir, FILENAME), 'utf8')).toBe(BODY);+ const installed = JSON.parse(readFileSync(installedConfigPath, 'utf8'));+ expect(installed.stages[STAGE_KEY]).toMatchObject({ returnsJson: true });+ });++ it('is idempotent and never clobbers a customized .md or an existing stage-config entry', async () => {+ seedReference();+ const customBody = '# CUSTOMIZED — do not overwrite\n';+ writeFileSync(join(stagesDir, FILENAME), customBody);+ writeFileSync(+ installedConfigPath,+ JSON.stringify({ stages: { [STAGE_KEY]: { name: 'user-tuned', model: 'custom' } } }, null, 2) + '\n',+ );++ await migration.up({ rootDir });++ expect(readFileSync(join(stagesDir, FILENAME), 'utf8')).toBe(customBody);+ const installed = JSON.parse(readFileSync(installedConfigPath, 'utf8'));+ expect(installed.stages[STAGE_KEY]).toEqual({ name: 'user-tuned', model: 'custom' });+ });++ it('does not throw when the data.reference samples are missing', async () => {+ await expect(migration.up({ rootDir })).resolves.not.toThrow();+ expect(existsSync(join(stagesDir, FILENAME))).toBe(false);+ });++ it('matches the live shipped stage-config key + prompt file (drift catch)', () => {+ const refConfig = JSON.parse(+ readFileSync(join(repoRoot, 'data.reference', 'prompts', 'stage-config.json'), 'utf8'),+ );+ expect(refConfig.stages[STAGE_KEY], `stage-config missing ${STAGE_KEY}`).toBeTruthy();+ expect(refConfig.stages[STAGE_KEY].returnsJson).toBe(true);+ expect(existsSync(join(repoRoot, 'data.reference', 'prompts', 'stages', FILENAME))).toBe(true);+ });+});diff --git a/server/lib/editorial/README.md b/server/lib/editorial/README.mdindex 0f35bf0441..b0bf4ef612 100644--- a/server/lib/editorial/README.md+++ b/server/lib/editorial/README.md@@ -145,7 +145,7 @@ runner-injected `ctx.callInlineLLM` (an inline-prompt sibling of| `italicThoughts.js` | Pure, dependency-free italic-thought primitive for `prose.italic-thoughts` (#1300): `findItalicThoughts` (multi-word markdown `*…*` / `_…_` italic runs, dedup + word-count threshold so single-word emphasis, bold, and `snake_case` are skipped). The LLM siblings (`opening.wrong-start`, `prose.mirror-description`, `dialogue.pleasantries`, `prose.kill-your-darlings`) handle the judgment cases in the #1300 anti-pattern bundle. || `proseTics.js` | Pure, dependency-free copy-edit prose-tic primitives for the #1306 line-edit group: `tokenizeWords` / `splitSentences` (shared tokenization), `findFilterWords` (`prose.filter-words`), `findCrutchWords` (`prose.crutch-words`), `findAdverbs` (`prose.adverbs` — `-ly` adverbs + dialogue-tag adverbs), `findPassiveVoice` (`prose.passive-voice` — be-verb + past-participle heuristic), `findGestures` (`prose.repeated-gestures` — gesture tally + body-part autonomy), plus the seed `FILTER_WORDS` / `CRUTCH_WORDS` / `GESTURE_WORDS` lists. The LLM sibling `prose.telling-emotion` handles the named-emotion judgment case. || `repetition.js` | Pure, dependency-free word-echo & rhythm primitives for #1306: `findWordEchoes` (`prose.word-echoes` — distinctive word repeated within a window), `findRepeatedOpeners` (runs of sentences sharing an opener, "He… He… He…"), and `measureSentenceRhythm` (`prose.sentence-rhythm` — sentence-length variation). Reuses `tokenizeWords` / `splitSentences` from `proseTics.js`. |-| `shotContinuity.js` | Pure, dependency-free storyboard shot-continuity primitives for the deterministic `visual.shot-continuity` check (#1315): `findAxisReversals` (180°-rule axis flips across a continuity-linked shot pair using `screenDirection`) and `findShotTypeMonotony` (a scene whose classified shots all share one `shotType`). Reads the shot-grammar fields from `server/lib/shotGrammar.js`. The judgment cases (eyeline match, appearance/prop continuity) are LLM-sibling follow-ups. |+| `shotContinuity.js` | Pure, dependency-free storyboard shot-continuity primitives for the deterministic `visual.shot-continuity` check (#1315): `findAxisReversals` (180°-rule axis flips across a continuity-linked shot pair using `screenDirection`) and `findShotTypeMonotony` (a scene whose classified shots all share one `shotType`). Also `summarizeStoryboardShots` (#1466) — renders the collected `{ issueNumber, scene }` storyboard list into a compact per-scene shot block for the LLM `visual.eyeline-match` sibling (gaze reciprocity / eyeline-vs-screen-direction). Reads the shot-grammar fields from `server/lib/shotGrammar.js`. The remaining judgment case (appearance/prop continuity) is an LLM-sibling follow-up. || `dialogue.js` | Pure, dependency-free dialogue-tag primitives for the #1307 dialogue-craft group: `findSaidBookisms` (`dialogue.said-bookisms` — ornate speech tags like *expostulated*/*opined* and non-speech tags like "she smiled", matched only when adjacent to a double-quote span) and `findUnattributedDialogueRuns` (`dialogue.attribution-clarity` — runs of consecutive untagged/unbeated dialogue lines where the speaker can't be tracked), plus `attributeDialogueByOwner` (the coarse per-character dialogue-line tally behind `cast.representation-balance`'s dialogue-share signal, #1312 — credits each quoted paragraph to the first owner named in its beat) and the seed `SAID_BOOKISMS` / `NON_SPEECH_TAGS` lists. The LLM siblings `dialogue.on-the-nose` (subtext-free / "as you know, Bob" dialogue) and `dialogue.voice-distinctiveness` (per-character voice against canon `speechPattern`/`speechAccent`) handle the judgment cases. || `letteringDensity.js` | Pure, dependency-free comic lettering-density primitives for `comic.lettering-density` (#1313): `countWords`, `panelLetteringMetrics` (per-panel balloon/caption/SFX word + balloon tally over the `comicScriptParser` output), `analyzeComicLettering` (flags balloons/panels/pages over the configurable thresholds in `DEFAULT_LETTERING_THRESHOLDS`), `overflowSeverity` (severity scaled by how far over the limit), and `sanitizeLetteringThresholds`. Mirrored to `client/src/lib/letteringDensity.js` for the comic-script stage's inline warnings — keep the two in sync. || `index.js` | Barrel re-export of the above. |diff --git a/server/lib/editorial/checkRegistry.js b/server/lib/editorial/checkRegistry.jsindex aeb25e679d..cf1683e793 100644--- a/server/lib/editorial/checkRegistry.js+++ b/server/lib/editorial/checkRegistry.js@@ -48,7 +48,7 @@ import {findRepeatedOpeners,measureSentenceRhythm,} from './repetition.js';-import { findAxisReversals, findShotTypeMonotony } from './shotContinuity.js';+import { findAxisReversals, findShotTypeMonotony, summarizeStoryboardShots } from './shotContinuity.js';export const CHECK_SCOPES = Object.freeze(['series', 'issue', 'scene', 'noun']);export const CHECK_KINDS = Object.freeze(['deterministic', 'llm']);@@ -347,6 +347,18 @@ export function declaredThemesSummary(themes) {// place/org/brand/honorific).export const UNMODELED_NAMES_STAGE = 'pipeline-editorial-unmodeled-names';+// Stage name for the eyeline-match continuity LLM check (#1466). Ships in+// data.reference/prompts/stages/ + stage-config.json (fresh installs via+// setup-data.js) and migrates to existing installs via migration 117 (boot runs+// migrations but NOT setup-data, so the migration is required). Reads the per-issue+// storyboard shots (`ctx.storyboardScenes`, wired by #1315 — the same source the+// deterministic `visual.shot-continuity` check reads) and asks the model to flag+// eyeline-match breaks WITHIN a scene: two characters in conversation whose gaze+// directions don't reciprocate across the cut, or a described eyeline that+// contradicts the shot's screen direction. The judgment sibling the deterministic+// 180°/shot-type scan deliberately leaves to an LLM (see shotContinuity.js).+export const EYELINE_MATCH_STAGE = 'pipeline-editorial-eyeline-match';+// Render the canon roster's names + aliases (#1412) into a compact text block the// unmodeled-names check passes alongside the manuscript, so the model knows which// proper nouns are ALREADY modeled (and therefore must NOT be flagged) and only@@ -2354,6 +2366,55 @@ export const EDITORIAL_CHECKS = [return findings;},},+ {+ id: 'visual.eyeline-match',+ sources: ['storyboard.shots'],+ label: 'Storyboard eyeline match (gaze continuity)',+ description:+ 'LLM scan of a scene\'s storyboard shot list for eyeline-match breaks — two characters in conversation whose gaze directions don\'t reciprocate across the cut (both look the same way instead of toward each other), or a described eyeline that contradicts the shot\'s tagged screen direction. The judgment sibling of the deterministic visual.shot-continuity check (180° rule / shot-type variety): an eyeline match needs semantic reading of the free-text shot descriptions, not a vocabulary scan, so it runs an LLM over the per-issue storyboard shots. Anchors each finding to the offending shot pair.',+ scope: 'scene',+ kind: 'llm',+ category: 'continuity',+ severityDefault: 'medium',+ defaultEnabled: true,+ configSchema: z.object({+ // Cap findings per run so a long storyboard can't flood the review.+ 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 long storyboard can not flood the review.',+ },+ ],+ // Skip the LLM call entirely unless at least one scene has two-or-more+ // described shots to compare an eyeline across (mirrors the deterministic+ // sibling's storyboardScenes gate, but tightened to "comparable" scenes —+ // summarizeStoryboardShots returns '' when nothing qualifies).+ gate: (ctx) => !!summarizeStoryboardShots(ctx.storyboardScenes),+ run: async (ctx) => {+ const shots = summarizeStoryboardShots(ctx.storyboardScenes);+ if (!shots) return [];+ const { content } = await ctx.callStagedLLM(+ EYELINE_MATCH_STAGE,+ { shots },+ { returnsJson: true, source: EYELINE_MATCH_STAGE },+ );+ return mapLlmFindings(content?.findings, {+ severityDefault: ctx.severityDefault,+ category: 'continuity',+ max: ctx.config?.maxFindings ?? 12,+ // Storyboard scenes carry their source issue number (rendered into the+ // block header), so a finding keeps the model-supplied issue anchor.+ withIssueNumber: true,+ });+ },+ },{id: 'sensory.balance',sources: ['manuscript', 'reverseOutline'],diff --git a/server/lib/editorial/checkRegistry.test.js b/server/lib/editorial/checkRegistry.test.jsindex 724fcc5ecc..b8e5432910 100644--- a/server/lib/editorial/checkRegistry.test.js+++ b/server/lib/editorial/checkRegistry.test.js@@ -2590,6 +2590,67 @@ describe('objects.backstory-consistency — LLM check (#1288)', () => {});});+describe('visual.eyeline-match — LLM check (#1466)', () => {+ const sceneEntry = (issueNumber, scene) => ({ issueNumber, scene });+ // A comparable scene: two characters whose gaze does not reciprocate.+ const comparableScenes = () => [+ sceneEntry(4, {+ heading: 'INT. KITCHEN',+ shots: [+ { id: 'shot-01', shotType: 'medium', screenDirection: 'right', description: 'Anna faces Ben, looking screen-right' },+ { id: 'shot-02', shotType: 'medium', screenDirection: 'right', continuityFromShotId: 'shot-01', description: 'Ben answers Anna but also looks screen-right' },+ ],+ }),+ ];++ it('gates on whether any scene has two-or-more described shots to compare', () => {+ const check = getCheck('visual.eyeline-match');+ expect(check.gate({ storyboardScenes: comparableScenes() })).toBe(true);+ // A single described shot → nothing to match an eyeline across.+ expect(check.gate({ storyboardScenes: [sceneEntry(1, { heading: 'A', shots: [{ id: 's1', description: 'alone' }] })] })).toBe(false);+ expect(check.gate({ storyboardScenes: [] })).toBe(false);+ expect(check.gate({ storyboardScenes: null })).toBe(false);+ });++ it('feeds the rendered shot block to the model and shapes findings (issue-anchored)', async () => {+ let vars = null;+ const findings = await getCheck('visual.eyeline-match').run({+ storyboardScenes: comparableScenes(),+ config: { maxFindings: 12 },+ severityDefault: 'medium',+ callStagedLLM: async (_stage, v) => {+ vars = v;+ return { content: { findings: [{+ severity: 'high',+ issueNumber: 4,+ location: 'Issue 4 — INT. KITCHEN: shots shot-01 ↔ shot-02',+ problem: 'Both characters look screen-right, so their eyelines do not reciprocate across the cut.',+ suggestion: 'Flip shot-02 to screen-left so Ben looks back toward Anna.',+ anchorQuote: 'also looks screen-right',+ }] } };+ },+ });+ expect(vars.shots).toContain('Scene 1 (Issue 4): INT. KITCHEN');+ expect(vars.shots).toContain('shot-01');+ expect(findings).toHaveLength(1);+ expect(findings[0].category).toBe('continuity');+ expect(findings[0].issueNumber).toBe(4);+ expect(findings[0].severity).toBe('high');+ });++ it('returns no findings (and never calls the model) when no scene qualifies', async () => {+ let called = false;+ const findings = await getCheck('visual.eyeline-match').run({+ storyboardScenes: [sceneEntry(1, { heading: 'A', shots: [{ id: 's1', description: 'alone' }] })],+ config: {},+ severityDefault: 'medium',+ callStagedLLM: async () => { called = true; return { content: { findings: [] } }; },+ });+ expect(findings).toEqual([]);+ expect(called).toBe(false);+ });+});+describe('style.reading-level — deterministic check (#1303)', () => {const check = getCheck('style.reading-level');const run = (styleGuide, manuscript, config = {}) =>diff --git a/server/lib/editorial/shotContinuity.js b/server/lib/editorial/shotContinuity.jsindex 91ff1676c3..b11d77649b 100644--- a/server/lib/editorial/shotContinuity.js+++ b/server/lib/editorial/shotContinuity.js@@ -27,8 +27,9 @@* High-precision by design (favors under-flagging, like the other deterministic* scanners). Unclassified shots (null `shotType` / `screenDirection`) are treated* as ABSENT — skipped, never guessed — per the absent-vs-empty rule. The judgment- * cases this can't compute (eyeline match, appearance/prop continuity) are LLM- * siblings tracked as follow-ups.+ * cases this can't compute need an LLM: eyeline match ships as the `visual.eyeline-match`+ * check (#1466), fed by `summarizeStoryboardShots` below; appearance/prop continuity+ * is a tracked follow-up.*/// Two directions are an axis reversal only when both are decided AND opposite.@@ -87,6 +88,76 @@ export function findAxisReversals(scene) {return out;}+// Human-readable label for a shot's screen direction, used when rendering shots+// for the LLM eyeline/appearance continuity passes (#1466). `neutral` is head-on;+// an unset direction is named so the model knows the signal is absent, not "left".+const DIRECTION_PROMPT_LABEL = {+ left: 'faces screen-left',+ right: 'faces screen-right',+ neutral: 'faces head-on',+};++/**+ * Render the collected storyboard scenes into a compact, ordered text block for+ * an LLM continuity pass (eyeline match — #1466 — and, later, appearance/prop+ * continuity). Pure + deterministic so it's unit-testable and so its token cost+ * is countable. Each qualifying scene becomes a labeled block; each shot is one+ * line carrying the fields the model reasons over: id, shot type, screen+ * direction, continuity link, and the free-text description (the eyeline signal).+ *+ * A scene qualifies only when it has at least two shots with a non-empty+ * description — an eyeline/appearance match is a judgment ACROSS shots, so a+ * single-shot (or description-less) scene has nothing to compare. ALL shots of a+ * qualifying scene are rendered (not just the described ones) so a+ * `continuityFromShotId` reference still resolves to a visible line; an+ * undescribed shot renders its description as `(no description)`.+ *+ * Returns '' when no scene qualifies, so the caller can gate the LLM call on a+ * non-empty block (mirrors the object-backstory check's row gate).+ *+ * @param {Array<{ issueNumber: number|null, scene: object }>} storyboardScenes+ * @returns {string}+ */+export function summarizeStoryboardShots(storyboardScenes) {+ const entries = Array.isArray(storyboardScenes) ? storyboardScenes : [];+ const blocks = [];+ let sceneIndex = 0;+ for (const entry of entries) {+ const scene = entry?.scene;+ if (!scene || typeof scene !== 'object') continue;+ const shots = sceneShots(scene);+ const describedCount = shots.filter(+ (s) => s && typeof s === 'object' && typeof s.description === 'string' && s.description.trim(),+ ).length;+ // Need at least two described shots to compare an eyeline / appearance across.+ if (describedCount < 2) continue;+ sceneIndex += 1;+ const issueNumber = Number.isInteger(entry.issueNumber) ? entry.issueNumber : null;+ const sceneName = typeof scene.heading === 'string' && scene.heading.trim()+ ? scene.heading.trim()+ : (typeof scene.slugline === 'string' && scene.slugline.trim() ? scene.slugline.trim() : 'scene');+ const header = issueNumber != null+ ? `Scene ${sceneIndex} (Issue ${issueNumber}): ${sceneName}`+ : `Scene ${sceneIndex}: ${sceneName}`;+ const lines = [];+ for (const s of shots) {+ if (!s || typeof s !== 'object') continue;+ const id = typeof s.id === 'string' && s.id ? s.id : 'shot';+ const type = typeof s.shotType === 'string' && s.shotType ? s.shotType : 'unspecified framing';+ const dir = DIRECTION_PROMPT_LABEL[s.screenDirection] || 'screen direction unspecified';+ const from = typeof s.continuityFromShotId === 'string' && s.continuityFromShotId+ ? ` (continues from ${s.continuityFromShotId})`+ : '';+ const desc = typeof s.description === 'string' && s.description.trim()+ ? s.description.trim()+ : '(no description)';+ lines.push(` - ${id} [${type}, ${dir}]${from}: ${desc}`);+ }+ blocks.push(`${header}\n${lines.join('\n')}`);+ }+ return blocks.join('\n\n');+}+/*** Detect shot-type monotony in one scene: enough classified shots that they ALL* share a single `shotType`. Returns the monotony descriptor or null.diff --git a/server/lib/editorial/shotContinuity.test.js b/server/lib/editorial/shotContinuity.test.jsindex e44f173add..89e0700345 100644--- a/server/lib/editorial/shotContinuity.test.js+++ b/server/lib/editorial/shotContinuity.test.js@@ -1,5 +1,5 @@import { describe, it, expect } from 'vitest';-import { findAxisReversals, findShotTypeMonotony } from './shotContinuity.js';+import { findAxisReversals, findShotTypeMonotony, summarizeStoryboardShots } from './shotContinuity.js';describe('findAxisReversals', () => {it('flags an axis reversal across a continuity-linked left↔right pair', () => {@@ -126,3 +126,68 @@ describe('findShotTypeMonotony', () => {expect(findShotTypeMonotony({ shots: [] })).toBe(null);});});++describe('summarizeStoryboardShots (#1466)', () => {+ const sceneEntry = (issueNumber, scene) => ({ issueNumber, scene });++ it('renders a per-scene block with shot id, framing, direction, link and description', () => {+ const block = summarizeStoryboardShots([+ sceneEntry(4, {+ heading: 'INT. KITCHEN',+ shots: [+ { id: 'shot-01', shotType: 'medium', screenDirection: 'right', description: 'Anna looks toward the doorway' },+ { id: 'shot-02', shotType: 'medium', screenDirection: 'right', continuityFromShotId: 'shot-01', description: 'Ben answers, also looking right' },+ ],+ }),+ ]);+ expect(block).toContain('Scene 1 (Issue 4): INT. KITCHEN');+ expect(block).toContain('shot-01 [medium, faces screen-right]: Anna looks toward the doorway');+ expect(block).toContain('shot-02 [medium, faces screen-right] (continues from shot-01): Ben answers, also looking right');+ });++ it('skips a scene with fewer than two described shots (nothing to compare)', () => {+ // One described + one undescribed → not comparable.+ expect(summarizeStoryboardShots([+ sceneEntry(1, { heading: 'A', shots: [{ id: 's1', description: 'only one' }, { id: 's2' }] }),+ ])).toBe('');+ // Single described shot.+ expect(summarizeStoryboardShots([+ sceneEntry(1, { heading: 'A', shots: [{ id: 's1', description: 'alone' }] }),+ ])).toBe('');+ });++ it('still renders an undescribed shot (so a continuity ref resolves) once the scene qualifies', () => {+ const block = summarizeStoryboardShots([+ sceneEntry(null, {+ slugline: 'EXT. ROAD',+ shots: [+ { id: 's1', description: 'wide of the road' },+ { id: 's2', description: 'two riders approach' },+ { id: 's3' }, // undescribed, but the scene already qualifies on s1+s2+ ],+ }),+ ]);+ expect(block).toContain('Scene 1: EXT. ROAD'); // no issue number → no "(Issue n)"+ expect(block).toContain('s3 [unspecified framing, screen direction unspecified]: (no description)');+ });++ it('numbers only qualifying scenes sequentially and joins multiple with a blank line', () => {+ const block = summarizeStoryboardShots([+ sceneEntry(1, { heading: 'SKIP', shots: [{ id: 'x', description: 'lonely' }] }), // skipped+ sceneEntry(2, { heading: 'KEEP-A', shots: [{ id: 'a', description: 'one' }, { id: 'b', description: 'two' }] }),+ sceneEntry(3, { heading: 'KEEP-B', shots: [{ id: 'c', description: 'three' }, { id: 'd', description: 'four' }] }),+ ]);+ expect(block).toContain('Scene 1 (Issue 2): KEEP-A');+ expect(block).toContain('Scene 2 (Issue 3): KEEP-B');+ expect(block).not.toContain('SKIP');+ expect(block.split('\n\n')).toHaveLength(2);+ });++ it('returns empty string and never throws for empty / malformed input', () => {+ expect(summarizeStoryboardShots([])).toBe('');+ expect(summarizeStoryboardShots(null)).toBe('');+ expect(summarizeStoryboardShots(undefined)).toBe('');+ expect(() => summarizeStoryboardShots([{ scene: null }, { scene: { shots: 'x' } }, {}])).not.toThrow();+ expect(summarizeStoryboardShots([{ scene: { shots: [1, 2] } }])).toBe(''); // non-object shots → no descriptions+ });+});