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
address review (codex): make eyeline char-budget a hard ceiling + cap shots-per-scene (#1466)
Adam Eivy9c6c2386b3f2
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 4656764477..f8e506821f 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -7,7 +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. Gaze is read from the free-text shot description (the `screen direction` field records where a subject *faces or moves*, which isn't always where they look), and the pass is bounded three ways (scene count, total characters, per-shot description length) with non-silent omission/truncation markers so a very large storyboard — wide or deep — can't overflow the model context. 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-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. Gaze is read from the free-text shot description (the `screen direction` field records where a subject *faces or moves*, which isn't always where they look), and the pass is bounded four ways (scene count, shots-per-scene, a hard total-character ceiling, and per-shot description length) with non-silent omission/truncation markers so a very large storyboard — wide, deep, or with one pathological scene — can't overflow the model context. 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/server/lib/editorial/shotContinuity.js b/server/lib/editorial/shotContinuity.jsindex 53235ae674..754e97fec2 100644--- a/server/lib/editorial/shotContinuity.js+++ b/server/lib/editorial/shotContinuity.js@@ -111,11 +111,17 @@ const DIRECTION_PROMPT_LABEL = {// - EYELINE_MAX_SCENES — most scenes rendered in one pass.// - EYELINE_MAX_CHARS — total rendered-block character budget (the real// overflow guard: bounds 60 dense scenes, not just 60).+// Enforced as a HARD ceiling — a single block is+// truncated to the remaining budget if it would exceed it,+// so even one scene with thousands of shots can't blow past.// - EYELINE_MAX_DESC_CHARS — per-shot description truncation, so one giant shot// description can't blow the budget on its own.+// - EYELINE_MAX_SHOTS_PER_SCENE — most shot lines rendered per scene (the common+// "deep scene" guard, applied before the char ceiling).export const EYELINE_MAX_SCENES = 60;export const EYELINE_MAX_CHARS = 24_000;export const EYELINE_MAX_DESC_CHARS = 600;+export const EYELINE_MAX_SHOTS_PER_SCENE = 40;/*** Render the collected storyboard scenes into a compact, ordered text block for@@ -132,17 +138,20 @@ export const EYELINE_MAX_DESC_CHARS = 600;* `continuityFromShotId` reference still resolves to a visible line; an* undescribed shot renders its description as `(no description)`.*- * The rendered payload is bounded three ways (scene count, total chars, per-shot- * description length — see the EYELINE_MAX_* constants) so one unchunked LLM call- * can't overflow the provider context whether the storyboard is wide (many scenes)- * or deep (a few enormous descriptions). When anything is dropped or truncated a- * trailing marker says so — the truncation is never silent.+ * The rendered payload is bounded four ways (scene count, shots-per-scene, total+ * chars, per-shot description length — see the EYELINE_MAX_* constants) so one+ * unchunked LLM call can't overflow the provider context whether the storyboard+ * is wide (many scenes), deep (a few enormous descriptions), or has one pathological+ * scene with thousands of shots. The total-char budget is a HARD ceiling: a block+ * that would exceed the remaining budget is truncated to it, so the returned string+ * never exceeds `maxChars` (plus the two short trailing markers). When anything is+ * dropped or truncated a trailing marker says so — the truncation is never silent.** 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- * @param {{ maxScenes?: number, maxChars?: number, maxDescChars?: number }} [opts]+ * @param {{ maxScenes?: number, maxChars?: number, maxDescChars?: number, maxShotsPerScene?: number }} [opts]* @returns {string}*/export function summarizeStoryboardShots(storyboardScenes, opts = {}) {@@ -155,11 +164,16 @@ export function summarizeStoryboardShots(storyboardScenes, opts = {}) {const maxDescChars = Number.isInteger(opts.maxDescChars) && opts.maxDescChars > 0? opts.maxDescChars: EYELINE_MAX_DESC_CHARS;+ const maxShotsPerScene = Number.isInteger(opts.maxShotsPerScene) && opts.maxShotsPerScene > 0+ ? opts.maxShotsPerScene+ : EYELINE_MAX_SHOTS_PER_SCENE;const entries = Array.isArray(storyboardScenes) ? storyboardScenes : [];const blocks = [];let qualifying = 0;let usedChars = 0;let truncatedDesc = false;+ let truncatedShots = false;+ let truncatedBlock = false;for (const entry of entries) {const scene = entry?.scene;if (!scene || typeof scene !== 'object') continue;@@ -181,8 +195,12 @@ export function summarizeStoryboardShots(storyboardScenes, opts = {}) {? `Scene ${blocks.length + 1} (Issue ${issueNumber}): ${sceneName}`: `Scene ${blocks.length + 1}: ${sceneName}`;const lines = [];+ let renderedShots = 0;for (const s of shots) {if (!s || typeof s !== 'object') continue;+ // Bound shots-per-scene so one pathological scene with thousands of shots+ // can't dominate the pass; the dropped tail is reported in the line below.+ if (renderedShots >= maxShotsPerScene) { truncatedShots = true; break; }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';@@ -197,8 +215,20 @@ export function summarizeStoryboardShots(storyboardScenes, opts = {}) {truncatedDesc = true;}lines.push(` - ${id} [${type}, ${dir}]${from}: ${desc}`);+ renderedShots += 1;+ }+ if (truncatedShots && renderedShots === maxShotsPerScene) {+ lines.push(' - …[further shots in this scene omitted to fit the model context]');+ }+ let block = `${header}\n${lines.join('\n')}`;+ // HARD char ceiling: even after the per-shot and per-scene caps, truncate the+ // assembled block to whatever budget remains so the total can't be exceeded by+ // a single scene. Reserve the join's 2 chars.+ const remaining = maxChars - usedChars - 2;+ if (block.length > remaining) {+ block = `${block.slice(0, Math.max(0, remaining))}…[scene truncated]`;+ truncatedBlock = true;}- const block = `${header}\n${lines.join('\n')}`;blocks.push(block);usedChars += block.length + 2; // +2 for the '\n\n' join that will follow}@@ -207,8 +237,8 @@ export function summarizeStoryboardShots(storyboardScenes, opts = {}) {if (omitted > 0) {blocks.push(`(${omitted} additional scene${omitted === 1 ? '' : 's'} omitted from this eyeline pass to fit the model context — review them in a later pass.)`);}- if (truncatedDesc) {- blocks.push('(Some shot descriptions were truncated to fit the model context — open the storyboard for the full text.)');+ if (truncatedDesc || truncatedShots || truncatedBlock) {+ blocks.push('(Some shots or descriptions were truncated to fit the model context — open the storyboard for the full text.)');}return blocks.join('\n\n');}diff --git a/server/lib/editorial/shotContinuity.test.js b/server/lib/editorial/shotContinuity.test.jsindex c7c6068c60..7580738937 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, summarizeStoryboardShots, EYELINE_MAX_SCENES, EYELINE_MAX_CHARS, EYELINE_MAX_DESC_CHARS } from './shotContinuity.js';+import { findAxisReversals, findShotTypeMonotony, summarizeStoryboardShots, EYELINE_MAX_SCENES, EYELINE_MAX_CHARS, EYELINE_MAX_DESC_CHARS, EYELINE_MAX_SHOTS_PER_SCENE } from './shotContinuity.js';describe('findAxisReversals', () => {it('flags an axis reversal across a continuity-linked left↔right pair', () => {@@ -207,8 +207,11 @@ describe('summarizeStoryboardShots (#1466)', () => {it('stops rendering at the total character budget and reports the omission', () => {const comparable = (n) => sceneEntry(n, { heading: `S${n}`, shots: [{ id: `${n}a`, description: 'one' }, { id: `${n}b`, description: 'two' }] });const scenes = Array.from({ length: 10 }, (_, i) => comparable(i + 1));- // A tiny budget renders only the first scene, then reports the rest omitted.- const block = summarizeStoryboardShots(scenes, { maxChars: 1 });+ // Budget = exactly one rendered scene block + its join, so scene 1 renders+ // whole and scene 2 is omitted (usedChars then meets the budget). Derived from+ // a single-scene render so the test isn't brittle to formatting tweaks.+ const oneScene = summarizeStoryboardShots([comparable(1)], { maxChars: 1_000_000 });+ const block = summarizeStoryboardShots(scenes, { maxChars: oneScene.length + 2 });expect(block).toContain('Scene 1 (Issue 1): S1');expect(block).not.toContain('S2');expect(block).toContain('9 additional scenes omitted');@@ -221,12 +224,37 @@ describe('summarizeStoryboardShots (#1466)', () => {], { maxDescChars: 50 });expect(block).toContain('…[truncated]');expect(block).not.toContain(huge);- expect(block).toContain('shot descriptions were truncated');+ expect(block).toContain('truncated to fit the model context');+ });++ it('bounds shots-per-scene so one deep scene cannot dominate the pass', () => {+ const manyShots = Array.from({ length: 500 }, (_, i) => ({ id: `s${i}`, description: `shot ${i}` }));+ const block = summarizeStoryboardShots([+ sceneEntry(1, { heading: 'DEEP', shots: manyShots }),+ ], { maxShotsPerScene: 5 });+ // Only the first 5 shot lines render.+ expect(block).toContain('s0 ');+ expect(block).toContain('s4 ');+ expect(block).not.toContain('s5 ');+ expect(block).toContain('further shots in this scene omitted');+ expect(block).toContain('truncated to fit the model context');+ });++ it('enforces the total-char budget as a HARD ceiling even for a single huge scene', () => {+ const manyShots = Array.from({ length: 500 }, (_, i) => ({ id: `s${i}`, description: 'x'.repeat(40) }));+ const cap = 1200;+ const block = summarizeStoryboardShots([+ sceneEntry(1, { heading: 'HUGE', shots: manyShots }),+ ], { maxChars: cap, maxShotsPerScene: 1000, maxDescChars: 1000 });+ // The returned string never exceeds the budget (plus the short trailing marker).+ expect(block.length).toBeLessThanOrEqual(cap + 200);+ expect(block).toContain('[scene truncated]');});it('exposes sane default caps', () => {expect(EYELINE_MAX_SCENES).toBeGreaterThan(0);expect(EYELINE_MAX_CHARS).toBeGreaterThan(0);expect(EYELINE_MAX_DESC_CHARS).toBeGreaterThan(0);+ expect(EYELINE_MAX_SHOTS_PER_SCENE).toBeGreaterThan(0);});});