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
fix: repair render-blocking canon from prose
[._.]/ Adam Eivyd948e5daf1ec
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 35062a4089..06e53e0f5f 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -12,6 +12,7 @@- **A late structure-repair regression no longer erases an independently verified improvement.** The bounded correction sequence could shrink nine arc blockers to one, then let its final attempt trade that residual for five and restore the entire pre-repair plan—discarding the proven one-blocker checkpoint. It now restores the best verified intermediate state, sends that partial improvement through the harsh foundation re-judge, and leaves the full arc gate dirty so the residual must still clear before beats. Model evidence follows the same transaction boundary: the retained repair runs remain provisional, while the regressive run is immediately scored as rejected; a fully reverted repair is also a rejection rather than a schema-invalid response.- **Character-first planning now includes the cast's visual foundation.** The pre-arc character architect used to complete psychology and relationships while its response contract omitted physical description, silhouette, visual identity, and palette, so a graphic-novel series could settle its plot around characters the image pipeline still had to invent. Those identity-bearing fields now participate in completeness, prompt hashing, harsh foundation scoring, and repair; optional sheets such as props, expressions, gestures, and wardrobes are authored when the character's form supports them.- **Series Autopilot can pause without killing productive work.** The live control used to offer only Stop, which terminates the active provider run even when a long foundation judgment is doing useful work. **Pause safely** now records a graceful request, lets the active step and any provisional repair-verification transaction settle, then persists a resumable manual pause; **Stop now** remains available as the immediate emergency control.+- **Canon readiness now repairs manuscript-supported blanks before blocking art.** Autopilot's pre-render gate could identify a drawn character, place, or object with no description, but it immediately paused even though the Nouns workflow already had a safe fill-blanks-only service. The gate now runs that strict prose-grounded backfill for each affected issue, rechecks shared canon, and pauses only for locked nouns or visual facts the manuscript genuinely never established—never inventing unsupported design to force a pass.- **Arc verification can now repair the per-character milestones it judges.** The verifier already read canonical per-character arcs, but its resolver could only edit the series arc, volumes, and issue synopses, so a contradiction in a character transition was impossible to close and repeated retries rewrote unrelated records instead. Finding-keyed character-arc patches now preserve character and transition IDs, merge only named fields, participate in regression rollback, and migrate existing prompt installations to the sparse contract.diff --git a/client/src/components/pipeline/AutopilotPanel.jsx b/client/src/components/pipeline/AutopilotPanel.jsxindex 3006063009..eef26a0542 100644--- a/client/src/components/pipeline/AutopilotPanel.jsx+++ b/client/src/components/pipeline/AutopilotPanel.jsx@@ -341,6 +341,7 @@ function frameLabel(f) {return `Unlocked ${parts.join(', ')}${kept.length ? ` · kept ${kept.join(' + ')} locked` : ''}`;}case 'render:queued': return `Queued draft render: ${f.target}`;+ case 'canon:repair': return `Canon repair: ${f.filled || 0} described from prose${f.unsupported ? ` · ${f.unsupported} unsupported` : ''}`;case 'gap:filed': return `Filed CoS task (${f.gapKind})`;// Pipeline self-improvement post-mortem. Only the START frame is live — the// verdict rides the terminal frame (a client tears its stream down there).diff --git a/server/services/pipeline/seriesAutopilot.js b/server/services/pipeline/seriesAutopilot.jsindex 682011e621..a6805146b5 100644--- a/server/services/pipeline/seriesAutopilot.js+++ b/server/services/pipeline/seriesAutopilot.js@@ -49,7 +49,9 @@* CANON GATE: before any visual production, a series-level canonVerify step* (canonReadiness.js) checks that every canon noun appearing where it'd be* DRAWN (comic-script panels / teleplay) has a description. Undescribed drawn- * nouns pause the run for human review — an artist can't render a name. (An+* nouns are first backfilled strictly from the issue prose; anything the+* manuscript still cannot support pauses the run for human review — an artist+* can't render a name. (An* off-page noun named only in prose narration is never drawn, so it doesn't* block here; it's a Nouns-stage quality note.)*diff --git a/server/services/pipeline/seriesAutopilot.test.js b/server/services/pipeline/seriesAutopilot.test.jsindex aff2ef8220..8df0b6d525 100644--- a/server/services/pipeline/seriesAutopilot.test.js+++ b/server/services/pipeline/seriesAutopilot.test.js@@ -145,11 +145,20 @@ vi.mock('./scriptVerify.js', () => ({ verifyComicScript }));let canonReady = true;let canonUndescribed = [];+let canonBlockingIssues = [];const checkSeriesCanonReadiness = vi.fn(async (seriesId) => ({- seriesId, ready: canonReady, issues: [], blockingIssues: [], undescribed: canonUndescribed,+ seriesId, ready: canonReady, issues: [], blockingIssues: canonBlockingIssues, undescribed: canonUndescribed,}));vi.mock('./canonReadiness.js', () => ({ checkSeriesCanonReadiness }));+const describeCanonFromProse = vi.fn(async () => {+ canonReady = true;+ canonUndescribed = [];+ canonBlockingIssues = [];+ return { report: { filled: 1, none: [], skippedLocked: [] }, runId: 'run-canon-repair' };+});+vi.mock('../universeCanon.js', () => ({ describeCanonFromProse }));+// Foundation-quality gate (#2176). Drive the judged weighted score + the fix// router per test. Default: a clean foundation (10) so the gate passes on the// first round and existing downstream-step tests are unaffected.@@ -240,6 +249,7 @@ beforeEach(() => {scriptVerifyFindings = [];canonReady = true;canonUndescribed = [];+ canonBlockingIssues = [];foundationScore = 10;foundationDimensionScores = null;foundationFixApplied = true;@@ -3200,6 +3210,26 @@ describe('autopilot conductor', () => {expect(series.autopilot?.status).toBe('paused');});+ it('backfills drawn canon from prose before pausing visual production', async () => {+ const { seriesId, issueId } = await seedComplete();+ await seriesSvc.updateSeries(seriesId, { universeId: 'uni-1' });+ await issuesSvc.updateStage(issueId, 'prose', ready('Kai wears a patched saffron pressure coat with a cracked brass respirator.'));+ const noun = { id: 'c1', name: 'Kai', kind: 'character', locked: false };+ canonReady = false;+ canonUndescribed = [noun];+ canonBlockingIssues = [{ issueId, number: 1, title: 'I1', none: [noun] }];++ await autopilot.startSeriesAutopilot(seriesId, { includeVisual: true });+ await waitFor(runFinished(seriesId));++ expect(describeCanonFromProse).toHaveBeenCalledWith('uni-1', expect.objectContaining({+ corpus: expect.stringContaining('saffron pressure coat'),+ targets: [{ id: 'c1', kind: 'character' }],+ }));+ expect(autopilot.__testing.runs.get(seriesId)?.lastPayload?.type).toBe('complete');+ expect(visualSpies.enqueueComicCover).toHaveBeenCalled();+ });+it('files only the specific gap (not also the generic stalled) when canon pauses', async () => {canonReady = false;canonUndescribed = [{ id: 'c1', name: 'Kai', kind: 'character' }];diff --git a/server/services/pipeline/seriesAutopilot/dryRun.js b/server/services/pipeline/seriesAutopilot/dryRun.jsindex 9f66e4f074..4b94acd349 100644--- a/server/services/pipeline/seriesAutopilot/dryRun.js+++ b/server/services/pipeline/seriesAutopilot/dryRun.js@@ -205,8 +205,11 @@ export function buildDryRunPlan(series, issues, options, costContext = {}) {});}if (VISUAL_DRAFT_ENABLED && wantsVisual(options) && wantsComic(series, options)) {- // canonVerify runs an LLM pass but bills no cos action (token-only) — 0 budget.- plan.push({ kind: 'canonVerify', count: 1, note: 'descriptive integrity of drawn nouns (no budget cost)', estActions: 0 });+ // The deterministic check is free. When it finds a blank drawn noun it may+ // conditionally call the strict prose-grounded backfill before pausing; the+ // snapshot cannot know that future script reference set, so keep the base+ // estimate at zero and name the conditional spend explicitly.+ plan.push({ kind: 'canonVerify', count: 1, note: 'descriptive integrity of drawn nouns (may spend one LLM call per affected issue to backfill strictly from prose)', estActions: 0 });const visualNeeded = ordered.filter((i) => !visualReady(i)).length;// Each draft render bills one cos action: cover + back per issue, plus one per// interior page. The interior-page count isn't known until the script parses,diff --git a/server/services/pipeline/seriesAutopilot/state.js b/server/services/pipeline/seriesAutopilot/state.jsindex 7ca93a1768..36fd2ddedc 100644--- a/server/services/pipeline/seriesAutopilot/state.js+++ b/server/services/pipeline/seriesAutopilot/state.js@@ -54,7 +54,7 @@ export const AUTOPILOT_TERMINAL_TYPES = new Set(['complete', 'paused', 'canceled// `reason` arguments instead.export const SIGNAL_FRAME_TYPES = Object.freeze(new Set(['note', 'step:skip', 'verify:round', 'resolve:round', 'resolve:rollback', 'resolve:isolate', 'check:complete',- 'foundation:round', 'foundation:fix', 'child:retry', 'child:escalate',+ 'foundation:round', 'foundation:fix', 'canon:repair', 'child:retry', 'child:escalate','revision:cycle', 'revision:converged', 'gap:filed',]));diff --git a/server/services/pipeline/seriesAutopilot/visualSteps.js b/server/services/pipeline/seriesAutopilot/visualSteps.jsindex 7f92179db0..ed1b8cd27a 100644--- a/server/services/pipeline/seriesAutopilot/visualSteps.js+++ b/server/services/pipeline/seriesAutopilot/visualSteps.js@@ -9,12 +9,19 @@ import { parseComicScript } from '../../../lib/comicScriptParser.js';import { isRunCanceledError } from '../../../lib/aiToolkit/errorDetection.js';import { getDomainBudgetStatus, recordDomainUsage } from '../../domainUsage.js';import { getIssue, updateStageWithLatest } from '../issues.js';+import { getSeries } from '../series.js';+import { describeCanonFromProse } from '../../universeCanon.js';import { slotKeyForVariant } from '../owners.js';import { enqueueComicCover, enqueueComicBackCover, enqueueVisualComicPage } from '../visualStages.js';import { checkSeriesCanonReadiness } from '../canonReadiness.js';import { broadcast, fileGap, providerOverrideOpts } from './session.js';import { slotEnqueued, pageEnqueued, visualReady } from './stepResolver.js';+// Mirror the manual describe-canon route's corpus ceiling. A generated prose+// stage may be larger, but the repair prompt should not silently become the+// pipeline's biggest request just because Autopilot invoked the same service.+const CANON_REPAIR_CORPUS_MAX = 200_000;+// Turn a render-enqueue result into the { slotKey, slot } pair the render// routes persist (proof → proofImage, final → finalImage).const slotFromRenderResult = (result) => {@@ -168,7 +175,65 @@ export async function runVisualDraft(sId, issueId, record) {// has no description (it can't be drawn). Marks canonVerified when clean so the// run proceeds to visual drafting.export async function runCanonVerify(sId, record) {- const report = await checkSeriesCanonReadiness(sId);+ let report = await checkSeriesCanonReadiness(sId);+ if (!report.ready) {+ const series = await getSeries(sId);+ const providerOpts = providerOverrideOpts(record);+ for (const blocking of (series?.universeId ? report.blockingIssues : [])) {+ if (record.cancelRequested) return { canceled: true };+ const issue = await getIssue(blocking.issueId);+ const corpus = (issue.stages?.prose?.output || '').trim().slice(0, CANON_REPAIR_CORPUS_MAX);+ const targets = (blocking.none || [])+ .filter((noun) => noun.locked !== true)+ .map((noun) => ({ id: noun.id, kind: noun.kind }));+ // Strictly manuscript-grounded by contract: no prose evidence means this+ // issue remains a visible blocker rather than Autopilot inventing canon.+ if (!corpus || targets.length === 0) continue;+ const budget = await getDomainBudgetStatus('cos');+ if (!budget.withinBudget) {+ return {+ pause: true,+ pauseKind: 'budget',+ reason: `daily cos ${budget.exceeded || 'actions'} budget reached while describing canon`,+ residual: report.undescribed.map((noun) => ({+ severity: 'high', location: `${noun.kind} "${noun.name}"`,+ problem: 'Appears where it would be drawn but has no description.',+ })),+ };+ }+ let repaired;+ try {+ repaired = await describeCanonFromProse(series.universeId, {+ corpus,+ targets,+ ...providerOpts,+ });+ } catch (err) {+ if (isRunCanceledError(err)) return { canceled: true };+ const detail = (err?.message || String(err)).slice(0, 300);+ return {+ pause: true,+ pauseKind: 'providerFailed',+ reason: `Canon description repair could not complete: ${detail}`,+ residual: report.undescribed.map((noun) => ({+ severity: 'high', location: `${noun.kind} "${noun.name}"`,+ problem: 'Appears where it would be drawn but has no description.',+ })),+ };+ }+ if (repaired?.runId) await recordDomainUsage('cos', { actions: 1 });+ broadcast(sId, {+ type: 'canon:repair',+ issueId: blocking.issueId,+ filled: repaired?.report?.filled || 0,+ unsupported: repaired?.report?.none?.length || 0,+ skippedLocked: repaired?.report?.skippedLocked?.length || 0,+ });+ }+ // Re-read after every issue-local repair. Shared canon means one fill can+ // clear the same noun across many later issues without another LLM call.+ report = await checkSeriesCanonReadiness(sId);+ }broadcast(sId, {type: 'verify:round', scope: 'canon', round: 1,findings: report.undescribed.length, blocking: report.undescribed.length,diff --git a/server/services/universeCanon.js b/server/services/universeCanon.jsindex 2ce5d608af..e996b7826b 100644--- a/server/services/universeCanon.js+++ b/server/services/universeCanon.js@@ -257,7 +257,12 @@ const hasDescription = (kind, entry) => {* written, and only into entries that are STILL empty + unlocked at write time.*/export async function describeCanonFromProse(universeId, opts = {}) {- const { corpus, targets, providerOverride, modelOverride } = opts;+ const {+ corpus, targets,+ providerOverride, modelOverride,+ providerDefault, modelDefault, effortDefault,+ onRunCreated, onRunSettled,+ } = opts;if (typeof corpus !== 'string' || !corpus.trim()) {throw new ServerError('describeCanonFromProse: corpus is required', {status: 400, code: 'UNIVERSE_CANON_NO_CORPUS',@@ -301,6 +306,11 @@ export async function describeCanonFromProse(universeId, opts = {}) {}, {providerOverride,modelOverride,+ providerDefault,+ modelDefault,+ effortDefault,+ onRunCreated,+ onRunSettled,returnsJson: true,source: 'universe-canon-describe-from-prose',});@@ -359,10 +369,10 @@ export async function describeCanonFromProse(universeId, opts = {}) {return Object.keys(patch).length ? patch : null;});console.log(`📝 Universe canon describe-from-prose — universe=${shortId(universeId)} filled=${report.filled} none=${report.none.length} thin=${report.thin.length} runId=${shortId(result.runId)}`);- return { universe: updated || universe, report };+ return { universe: updated || universe, report, runId: result.runId };}console.log(`📝 Universe canon describe-from-prose — universe=${shortId(universeId)} filled=0 none=${report.none.length} thin=${report.thin.length} runId=${shortId(result.runId)}`);- return { universe, report };+ return { universe, report, runId: result.runId };}/**