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

fix: keep a tied character repair that measurably filled the cast's blank fields

[._.]/ Adam Eivy33ab0a4dfe9c
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index f6704d44fc..07542f9668 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -86,3 +86,4 @@
- **OpenClaw is a chat screen again instead of the Settings tab strip with a chat under it.** `/openclaw` is a top-level route, but it rendered a "Settings" title and the full 22-item settings tab bar above its own header — so the first screen was navigation for somewhere else, and at phone width the composer and its **Send** button both started below the fold. The settings chrome is gone, the runtime-status readout collapsed into a disclosure that shows the runtime label at a glance, and the session list now hides behind a **Sessions** button below `lg` (picking a session closes it) so the conversation owns the width. In the composer, the three context fields (app, directory, extra instructions) fold behind a **Context** toggle that badges how many are set, and the drag/paste/files hint row came out because the placeholder already says it — leaving the message box and Send pinned to the bottom of the pane at any scroll position.
- **Arc verification no longer reports a phantom "no pilot or finale" on a volume that has both.** The check that flags arc-role imbalance reads each episode's `arcRole`, but the plan snapshot handed to the verifier never included that field — so it saw twelve episodes with no roles at all and reported the imbalance on every single pass, on every series, no matter how the volume was actually laid out. On its own that was a stray low-severity finding. What made it expensive is that the foundation gate's structure repair reverts its whole rewrite whenever verification comes back with *any* blocker left: the phantom finding could never be closed, so a run whose real contradictions had all been fixed still rolled the repair back and paused for human review, reporting the correct fixes as a failed attempt. (Observed on a series that paused with "structure repair left 5 arc-verification blocker(s)", one of which was this.) The snapshot now carries `arcRole` — as an explicit `null` when unset, so "no role" stays distinguishable from a dropped field — which also means the auto-resolver can finally see the roles it is being asked to fix instead of assigning them blind.
- **A URL that doesn't match a page now says so instead of quietly depositing you on the Dashboard.** Every unmatched route — a stale bookmark, a typo, or a half-remembered path like `/annotate` (the annotator actually lives at `/media/annotate`) — hit a blanket redirect to `/`, so the user saw the page-loading spinner, then the Dashboard's skeleton widgets, then the Dashboard: indistinguishable from the app losing their navigation, with no account of what happened. Unknown routes now render a 404 page that names the path that didn't match and offers Go back, Dashboard, and a reminder that ⌘K searches every page by name. `/annotate` and `/annotate/:mediaKey` are redirected to their real `/media/annotate` home rather than being swallowed, and the annotator's own keyless state stopped reading like a loading screen: it now distinguishes "nothing selected" from "that media is no longer available" and offers **Choose media** and **Blank canvas** — the latter being the first way to start a free-standing sketch from the UI at all.
+- **A character repair that objectively filled the blank cast fields is no longer thrown away because the judge scored it a tie.** The foundation gate holds each repair provisional until an independent re-judge proves it helped the dimension it was asked to fix, and reverts it otherwise — the right rule for editorial work that can only be assessed by reading it. But the character dimension's core complaint is frequently a countable one ("every core character has blank physicalDescription, visualNotes, silhouetteNotes, visualIdentity and colorPalette"), and answering it is a countable act. On the observed run the repair authored all five visual fields for all five leads — roughly five minutes of a max-effort ensemble pass — the judge came back holding character at the same 5 while unrelated worldbuilding drifted 8 → 7, and the gate reverted every sheet and paused the run for review with the cast blank again. The gate now takes a second, LLM-free opinion before it reverts a *tied* character repair: it counts the blank framework and visual fields across the exact cast the repair is allowed to write (the series roster, minus locked members) before and after, and keeps the work when that count went down. A repair whose target regressed is still reverted, every other dimension is unaffected, and a repair that changed nothing measurable is still rejected — what changed is that a fact on disk now outranks a tied score.
diff --git a/server/services/pipeline/foundationJudge.js b/server/services/pipeline/foundationJudge.js
index e1f54b18b2..06130578f3 100644
--- a/server/services/pipeline/foundationJudge.js
+++ b/server/services/pipeline/foundationJudge.js
@@ -494,6 +494,39 @@ function repairableSeriesFoundationCharacters(characters, series, issues = []) {
.filter((character) => character?.locked !== true);
}
+/**
+ * Blank foundation fields across the cast a `character` repair is allowed to
+ * write — the series roster minus locked members, over the SAME framework +
+ * visual field sets the character dimension is scored on.
+ *
+ * This is the gate's objective, LLM-free second opinion on a repair the judge
+ * scored as a tie. A judge can misread the cast — a presence-marker render once
+ * showed every authored design as the bare word `ready`, so a complete five-sheet
+ * character foundation was scored as absent and thrown away — but "25 named
+ * fields went from empty to authored" is a fact on disk, not an opinion.
+ */
+export function countFoundationCharacterBlanks(characters, series, issues = []) {
+ const targets = repairableSeriesFoundationCharacters(characters, series, issues);
+ return rankFoundationCharacters(targets, series, issues)
+ .reduce((total, { blanks }) => total + blanks, 0);
+}
+
+/**
+ * `countFoundationCharacterBlanks` against live records. Pass `charactersOverride`
+ * to measure a checkpoint's cast (the pre-repair snapshot) against the same
+ * series/issue roster the live count uses, so only the cast content differs.
+ */
+export async function readFoundationCharacterBlanks(seriesId, charactersOverride = null) {
+ assertValidSeriesId(seriesId);
+ const series = await getSeries(seriesId);
+ const [universe, issues] = await Promise.all([
+ series?.universeId ? getUniverse(series.universeId).catch(() => null) : null,
+ listIssues({ seriesId }),
+ ]);
+ const characters = Array.isArray(charactersOverride) ? charactersOverride : universe?.characters;
+ return countFoundationCharacterBlanks(characters, series, issues);
+}
+
const joinedLength = (lines) => lines.reduce((total, line) => total + line.length + 1, 0);
const pluralLines = (count) => (count === 1 ? 'line' : 'lines');
diff --git a/server/services/pipeline/foundationJudge.test.js b/server/services/pipeline/foundationJudge.test.js
index 981e4fcae1..1b303a2a73 100644
--- a/server/services/pipeline/foundationJudge.test.js
+++ b/server/services/pipeline/foundationJudge.test.js
@@ -81,6 +81,7 @@ const {
thinnestCharacter,
rankFoundationCharacters,
seriesFoundationCharacters,
+ countFoundationCharacterBlanks,
foundationInputsHash,
FOUNDATION_DIMENSIONS,
FOUNDATION_WEIGHTS,
@@ -402,6 +403,43 @@ describe('rankFoundationCharacters — core-cast repair targets', () => {
});
});
+describe('countFoundationCharacterBlanks — objective repair evidence', () => {
+ const series = { characterArcs: [{ characterId: 'chr-lead', characterName: 'Lead' }] };
+ const blankLead = { id: 'chr-lead', name: 'Lead', role: 'protagonist' };
+ const authoredLead = {
+ ...blankLead,
+ ghost: 'g', wound: 'w', lie: 'l', want: 'wa', need: 'n', coreTheme: 'c', motivations: 'm', speechPattern: 's',
+ secrets: ['one'],
+ physicalDescription: 'p', visualNotes: 'v', silhouetteNotes: 'si', visualIdentity: 'vi',
+ colorPalette: [{ name: 'Rope Tan', hex: '#B89A6A' }],
+ };
+
+ it('drops to zero once every framework and visual field is authored', () => {
+ expect(countFoundationCharacterBlanks([blankLead], series)).toBe(14);
+ expect(countFoundationCharacterBlanks([authoredLead], series)).toBe(0);
+ });
+
+ it('counts only the repairable roster — locked and unreferenced cast are excluded', () => {
+ const cast = [
+ blankLead,
+ { id: 'chr-locked', name: 'Locked', locked: true },
+ { id: 'chr-extra', name: 'Extra' },
+ ];
+ const lockedSeries = {
+ characterArcs: [
+ { characterId: 'chr-lead', characterName: 'Lead' },
+ { characterId: 'chr-locked', characterName: 'Locked' },
+ ],
+ };
+ // Only the unlocked, story-referenced lead contributes its 14 blanks.
+ expect(countFoundationCharacterBlanks(cast, lockedSeries)).toBe(14);
+ });
+
+ it('treats a missing cast as nothing to measure rather than throwing', () => {
+ expect(countFoundationCharacterBlanks(null, series)).toBe(0);
+ });
+});
+
describe('renderArc — episode-list budget', () => {
const bigSeries = {
arc: { logline: 'AL', summary: 'AS', themes: ['t1'], protagonistArc: 'PA', shape: 'rise' },
diff --git a/server/services/pipeline/seriesAutopilot.test.js b/server/services/pipeline/seriesAutopilot.test.js
index e637966d4c..3f956ad6cf 100644
--- a/server/services/pipeline/seriesAutopilot.test.js
+++ b/server/services/pipeline/seriesAutopilot.test.js
@@ -179,6 +179,10 @@ const judgeFoundation = vi.fn(async () => ({
const applyFoundationFix = vi.fn(async (_sId, dimension) => ({ dimension, applied: foundationFixApplied }));
const snapshotFoundationState = vi.fn(async (seriesId) => ({ seriesId, marker: 'foundation-checkpoint' }));
const restoreFoundationState = vi.fn(async () => ({ restored: true, episodesRestored: 0 }));
+// Objective blank-field count behind the character arm's tie-breaker. Default:
+// an unchanged cast (the checkpoint read and the post-repair read agree), so a
+// tie stays a tie unless a test says the repair actually filled fields.
+const readFoundationCharacterBlanks = vi.fn(async () => 0);
vi.mock('./foundationJudge.js', async (importOriginal) => {
const actual = await importOriginal();
return {
@@ -188,6 +192,7 @@ vi.mock('./foundationJudge.js', async (importOriginal) => {
establishCharacterFoundation: (...args) => establishCharacterFoundation(...args),
snapshotFoundationState: (...args) => snapshotFoundationState(...args),
restoreFoundationState: (...args) => restoreFoundationState(...args),
+ readFoundationCharacterBlanks: (...args) => readFoundationCharacterBlanks(...args),
};
});
@@ -1988,6 +1993,45 @@ describe('autopilot conductor', () => {
]));
});
+ it('foundation gate: keeps a tied character repair that objectively filled blank cast fields', async () => {
+ // The 2026-08-11 stall: the character repair authored every blank visual
+ // field on the core cast, the judge held character at 5 (its prompt showed
+ // each authored field as a presence marker, not the design), and unrelated
+ // worldbuilding noise dropped the aggregate — so a complete character pass
+ // was reverted. Filled fields on disk now outrank the tied score.
+ const snapshot = (weightedScore, worldbuilding) => ({
+ seriesId: 'ser-example', status: 'complete', weightedScore,
+ dimensions: {
+ worldbuilding: { score: worldbuilding, gap: 'External societies read as negotiation venues.', fix: 'Add daily practices.' },
+ character: { score: 5, gap: 'Every core character has blank visual fields.', fix: 'Author the visual foundation.' },
+ structure: { score: 5, gap: 'The climax occurs in two places.', fix: 'Reconcile issue 11 and 12.' },
+ craft: { score: 8, gap: 'The exemplars are all one culture.', fix: 'Add an external-culture exemplar.' },
+ },
+ });
+ judgeFoundation
+ .mockImplementationOnce(async () => snapshot(6.5, 8))
+ .mockImplementationOnce(async () => snapshot(6.1, 7))
+ .mockImplementationOnce(async () => ({
+ seriesId: 'ser-example', status: 'complete', weightedScore: 8,
+ dimensions: {
+ worldbuilding: { score: 8, gap: 'g', fix: 'f' },
+ character: { score: 8, gap: 'g', fix: 'f' },
+ structure: { score: 8, gap: 'g', fix: 'f' },
+ craft: { score: 8, gap: 'g', fix: 'f' },
+ },
+ }));
+ // 25 blank fields across the repairable cast before the repair, none after.
+ readFoundationCharacterBlanks.mockResolvedValueOnce(25).mockResolvedValueOnce(0);
+
+ const { seriesId } = await seedComplete();
+ await autopilot.startSeriesAutopilot(seriesId, { maxFoundationRounds: 3 });
+ await waitFor(runFinished(seriesId));
+
+ expect(restoreFoundationState).not.toHaveBeenCalled();
+ expect(autopilot.__testing.runs.get(seriesId)?.lastPayload?.type).toBe('complete');
+ expect(applyFoundationFix.mock.calls.map(([, dimension]) => dimension)).toEqual(['character', 'character']);
+ });
+
it('foundation gate: rejects the first repair when the same target fails to improve', async () => {
const stalled = {
seriesId: 'ser-example', status: 'complete', weightedScore: 7,
diff --git a/server/services/pipeline/seriesAutopilot/childRuns.js b/server/services/pipeline/seriesAutopilot/childRuns.js
index 2785608a4f..1f44edb2f9 100644
--- a/server/services/pipeline/seriesAutopilot/childRuns.js
+++ b/server/services/pipeline/seriesAutopilot/childRuns.js
@@ -15,7 +15,8 @@ import {
} from '../arcPlanner.js';
import {
judgeFoundation, applyFoundationFix, establishCharacterFoundation, foundationGateStatus, foundationFixTarget,
- residualFindings, snapshotFoundationState, restoreFoundationState, DEFAULT_FOUNDATION_THRESHOLD,
+ residualFindings, snapshotFoundationState, restoreFoundationState, readFoundationCharacterBlanks,
+ DEFAULT_FOUNDATION_THRESHOLD,
} from '../foundationJudge.js';
import * as volumeBeatsRunner from '../volumeBeatsRunner.js';
import * as autoRunner from '../autoRunner.js';
@@ -669,10 +670,23 @@ export async function runFoundationGate(seriesId, record) {
{ location: dimension, problem: beforeDimension.gap || '' },
{ location: dimension, problem: afterDimension.gap || '' },
);
+ // A character repair's work is objectively measurable without asking an
+ // LLM: count the blank framework/visual fields across the repairable cast
+ // before and after. A judge that renders or reads the cast wrongly can
+ // report a tied score over a foundation it can no longer see — that cost
+ // a complete five-sheet character design pass on 2026-08-11, discarded
+ // because the judge prompt showed each authored field as the bare word
+ // `ready`. Filled fields are a fact on disk, so they outrank a tie.
+ const blanksAfter = pendingRepair.characterBlanksBefore === null
+ ? null
+ : await readFoundationCharacterBlanks(seriesId).catch(() => null);
+ const objectivelyFilled = blanksAfter !== null && blanksAfter < pendingRepair.characterBlanksBefore;
// A tie can represent a deeper newly exposed layer, but only when the
// aggregate did not regress. A strictly improved target is accepted even
// if it makes another latent dimension judgeable.
- const earned = targetImproved || (targetTied && gapChanged && score >= beforeWeighted);
+ const earned = targetImproved
+ || (targetTied && objectivelyFilled)
+ || (targetTied && gapChanged && score >= beforeWeighted);
if (!earned) {
await Promise.all((pendingRepair.runIds || []).map((runId) => recordModelOutcome(runId, {
role: 'creative', stage: 'foundationGate', outcome: 'rejected', target: dimension,
@@ -789,6 +803,12 @@ export async function runFoundationGate(seriesId, record) {
// promptRunner has already walked its full fallback cascade by the time
// this throws, so there is no retry left to attempt here.
const repairSnapshot = await snapshotFoundationState(seriesId);
+ // Measured off the checkpoint's own cast so the before/after pair differs
+ // only in character content — null for every other dimension, which is what
+ // switches the objective check off.
+ const characterBlanksBefore = weak.dimension === 'character'
+ ? await readFoundationCharacterBlanks(seriesId, repairSnapshot?.universe?.characters).catch(() => null)
+ : null;
let fix;
const repairRunIds = [];
const creativeHooks = providerOverrideOpts(record);
@@ -864,6 +884,7 @@ export async function runFoundationGate(seriesId, record) {
judge: snap,
snapshot: repairSnapshot,
runIds: retainedRepairRunIds,
+ characterBlanksBefore,
};
changed = true;
}