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): bound eyeline payload by total chars + per-description length (#1466)
Adam Eivyd70a71e1469f
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 9286aa07fb..4656764477 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 with a non-silent omission marker so a very large storyboard 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 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-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 51ebefc569..53235ae674 100644--- a/server/lib/editorial/shotContinuity.js+++ b/server/lib/editorial/shotContinuity.js@@ -102,14 +102,20 @@ const DIRECTION_PROMPT_LABEL = {neutral: 'screen direction: neutral (head-on)',};-// Cap on how many qualifying scenes a single eyeline pass renders, so a series-// with a very large storyboard can't overflow the provider context in one-// unchunked LLM call. An eyeline match is a WITHIN-scene judgment (no cross-scene-// context is lost by splitting the corpus), so the cap simply bounds one pass;-// the omission is surfaced in the block (NOT silent — see the trailing marker) so-// the model and any reader know coverage stopped. Generous enough that a normal-// series renders whole. (A future iteration could page across the overflow.)+// Bounds on a single eyeline pass so a very large storyboard can't overflow the+// provider context in one unchunked LLM call. Three independent limits — the pass+// stops at whichever it hits first, and every omission is surfaced in the block+// (NOT silent) so the model and any reader know coverage stopped. An eyeline match+// is a WITHIN-scene judgment, so omitting a scene loses no cross-scene context;+// a future iteration could page across the overflow.+// - 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).+// - EYELINE_MAX_DESC_CHARS — per-shot description truncation, so one giant shot+// description can't blow the budget on its own.export const EYELINE_MAX_SCENES = 60;+export const EYELINE_MAX_CHARS = 24_000;+export const EYELINE_MAX_DESC_CHARS = 600;/*** Render the collected storyboard scenes into a compact, ordered text block for@@ -126,25 +132,34 @@ export const EYELINE_MAX_SCENES = 60;* `continuityFromShotId` reference still resolves to a visible line; an* undescribed shot renders its description as `(no description)`.*- * At most `maxScenes` qualifying scenes are rendered (bounds one unchunked LLM- * call); when more qualify, a trailing marker names how many were omitted so the- * truncation is never silent (eyeline is a within-scene judgment, so omitting a- * scene loses no cross-scene context).+ * 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.** 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 }} [opts]+ * @param {{ maxScenes?: number, maxChars?: number, maxDescChars?: number }} [opts]* @returns {string}*/export function summarizeStoryboardShots(storyboardScenes, opts = {}) {const maxScenes = Number.isInteger(opts.maxScenes) && opts.maxScenes > 0? opts.maxScenes: EYELINE_MAX_SCENES;+ const maxChars = Number.isInteger(opts.maxChars) && opts.maxChars > 0+ ? opts.maxChars+ : EYELINE_MAX_CHARS;+ const maxDescChars = Number.isInteger(opts.maxDescChars) && opts.maxDescChars > 0+ ? opts.maxDescChars+ : EYELINE_MAX_DESC_CHARS;const entries = Array.isArray(storyboardScenes) ? storyboardScenes : [];const blocks = [];let qualifying = 0;+ let usedChars = 0;+ let truncatedDesc = false;for (const entry of entries) {const scene = entry?.scene;if (!scene || typeof scene !== 'object') continue;@@ -155,7 +170,9 @@ export function summarizeStoryboardShots(storyboardScenes, opts = {}) {// Need at least two described shots to compare an eyeline / appearance across.if (describedCount < 2) continue;qualifying += 1;- if (blocks.length >= maxScenes) continue; // keep counting (for the marker) but stop rendering+ // Keep counting (for the omission marker) but stop rendering once EITHER the+ // scene cap or the character budget is reached.+ if (blocks.length >= maxScenes || usedChars >= maxChars) continue;const issueNumber = Number.isInteger(entry.issueNumber) ? entry.issueNumber : null;const sceneName = typeof scene.heading === 'string' && scene.heading.trim()? scene.heading.trim()@@ -172,18 +189,27 @@ export function summarizeStoryboardShots(storyboardScenes, opts = {}) {const from = typeof s.continuityFromShotId === 'string' && s.continuityFromShotId? ` (continues from ${s.continuityFromShotId})`: '';- const desc = typeof s.description === 'string' && s.description.trim()+ let desc = typeof s.description === 'string' && s.description.trim()? s.description.trim(): '(no description)';+ if (desc.length > maxDescChars) {+ desc = `${desc.slice(0, maxDescChars)}…[truncated]`;+ truncatedDesc = true;+ }lines.push(` - ${id} [${type}, ${dir}]${from}: ${desc}`);}- blocks.push(`${header}\n${lines.join('\n')}`);+ const block = `${header}\n${lines.join('\n')}`;+ blocks.push(block);+ usedChars += block.length + 2; // +2 for the '\n\n' join that will follow}if (!blocks.length) return '';const omitted = qualifying - blocks.length;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.)');+ }return blocks.join('\n\n');}diff --git a/server/lib/editorial/shotContinuity.test.js b/server/lib/editorial/shotContinuity.test.jsindex 4e6a444735..c7c6068c60 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 } from './shotContinuity.js';+import { findAxisReversals, findShotTypeMonotony, summarizeStoryboardShots, EYELINE_MAX_SCENES, EYELINE_MAX_CHARS, EYELINE_MAX_DESC_CHARS } from './shotContinuity.js';describe('findAxisReversals', () => {it('flags an axis reversal across a continuity-linked left↔right pair', () => {@@ -204,7 +204,29 @@ describe('summarizeStoryboardShots (#1466)', () => {expect(block).toContain('3 additional scenes omitted');});- it('exposes a sane default cap', () => {+ 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 });+ expect(block).toContain('Scene 1 (Issue 1): S1');+ expect(block).not.toContain('S2');+ expect(block).toContain('9 additional scenes omitted');+ });++ it('truncates an oversized shot description and reports the truncation', () => {+ const huge = 'x'.repeat(2000);+ const block = summarizeStoryboardShots([+ sceneEntry(1, { heading: 'BIG', shots: [{ id: 'a', description: huge }, { id: 'b', description: 'short' }] }),+ ], { maxDescChars: 50 });+ expect(block).toContain('…[truncated]');+ expect(block).not.toContain(huge);+ expect(block).toContain('shot descriptions were 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);});});