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: reject placeholder foundation verdicts

[._.]/ Adam Eivy6dd615f8616c
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 4c3f953b8d..305016b0c2 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -58,6 +58,7 @@
- **A note that iCloud wrongly reports as "not downloaded" can now be saved anyway.** The write guard screens for an offloaded note by looking for a real byte length with no local blocks — a shape an ordinary sparse or compressed file also has. When that misfired the lockout was permanent: asking iCloud to download an already-local file succeeds instantly and changes nothing, so every save was refused forever while the message told the user to try again shortly. The server now checks whether the download both succeeded and actually moved the file, so it can tell a download still in flight (or one that failed) from a refusal that will never clear — and only the second of those, twice in a row on the same note, offers the Brain Notes and Wiki editors a deliberate "Save anyway" row that writes it regardless. While a download really is in flight you still just wait, and the ordinary Save button, ⌘S, and background mirrors always refuse, so nothing bypasses the guard without an explicit click. The message no longer says to try again shortly when trying again cannot help.
- **Quiet Codex reasoning is no longer mistaken for a finished one-shot response.** The TUI runner's eight-second screen-idle fallback could kill an active long-form Luna or Sol stage between status repaints, then hand terminal chrome such as `[Pasted Content …]` to a JSON parser as if it were the model's answer. Codex one-shot calls now wait for their required response file, a natural exit, explicit cancellation, or the configured hard cap; inline idle completion remains available for other TUIs that do not honor file output.
+- **Quiet Codex reasoning is no longer mistaken for a finished one-shot response.** The TUI runner's eight-second screen-idle fallback could kill an active long-form Luna or Sol stage between status repaints, then hand terminal chrome such as `[Pasted Content …]` to a JSON parser as if it were the model's answer. Codex one-shot calls now wait for their required response file, a natural exit, explicit cancellation, or the configured hard cap; inline idle completion remains available for other TUIs that do not honor file output. The foundation judge also rejects the prompt's echoed `{ score: 6, gap: "string", fix: "string" }` schema example, so terminal chrome cannot masquerade as a real all-six editorial verdict even if a malformed transport reaches the retry gate.
- **Post-arc character repair no longer invents plot events that the episode plan never stages.** Character reconciliation could improve a supporting cast member by adding new early `atIssue` transitions, then the next foundation verdict correctly penalized structure because those characters were absent from the corresponding synopses. Existing transition beats are now read-only after the macro arc exists: character repair may deepen motivation, arc type, and start/end states, while the structure editor exclusively owns adding or moving dramatized events. Pre-arc character-first planning still authors provisional transitions normally.
diff --git a/server/services/pipeline/foundationJudge.js b/server/services/pipeline/foundationJudge.js
index 9e9974e290..3b33e801d2 100644
--- a/server/services/pipeline/foundationJudge.js
+++ b/server/services/pipeline/foundationJudge.js
@@ -278,12 +278,33 @@ function sanitizeDimension(raw) {
};
}
-// A judge response is "valid-shaped" when it carries the dimensions object we
-// scored against — the retry gate. A response that parses as JSON but omits the
-// rubric is treated as malformed and retried once.
+const PLACEHOLDER_FINDING = /^(?:string|placeholder|todo|tbd|n\/?a|none|null|undefined)$/i;
+const isMeaningfulFinding = (value) => (
+ typeof value === 'string'
+ && value.trim().length > 0
+ && !PLACEHOLDER_FINDING.test(value.trim())
+);
+
+// A judge response is "valid-shaped" only when every rubric dimension contains
+// a usable score plus concrete gap/fix prose. The prompt itself includes a JSON
+// shape example whose values are `{ score: 6, gap: "string", fix: "string" }`;
+// if a TUI screen scrape ever leaks through, a permissive dimensions-only check
+// would mistake that echoed contract for a real verdict and spend a repair round
+// on the literal instruction "string". Reject incomplete and placeholder
+// rubrics so the deliberate retry (and ultimately the caller) handles them as
+// malformed output instead of persisting fabricated editorial evidence.
export function isValidFoundationShape(content) {
- return !!(content && typeof content === 'object'
- && content.dimensions && typeof content.dimensions === 'object');
+ if (!(content && typeof content === 'object'
+ && content.dimensions && typeof content.dimensions === 'object')) return false;
+ if (!FOUNDATION_DIMENSIONS.every((dimension) => {
+ const finding = content.dimensions[dimension];
+ const score = Number(finding?.score);
+ return finding && typeof finding === 'object'
+ && Number.isFinite(score) && score >= 1 && score <= 10
+ && isMeaningfulFinding(finding.gap)
+ && isMeaningfulFinding(finding.fix);
+ })) return false;
+ return content.oneLineVerdict === undefined || isMeaningfulFinding(content.oneLineVerdict);
}
export function sanitizeFoundationJudge(parsed) {
@@ -567,7 +588,7 @@ async function runFoundationJudgeStage(ctx, runOptions) {
try {
const result = await runStagedLLM(STAGE, ctx, runOptions);
if (isValidFoundationShape(result.content)) return result;
- lastError = new Error('foundation judge response parsed but is missing the `dimensions` rubric');
+ lastError = new Error('foundation judge response parsed but its rubric is incomplete or contains placeholders');
} catch (err) {
lastError = err;
}
diff --git a/server/services/pipeline/foundationJudge.test.js b/server/services/pipeline/foundationJudge.test.js
index 9fd429dcb1..8a76563a8c 100644
--- a/server/services/pipeline/foundationJudge.test.js
+++ b/server/services/pipeline/foundationJudge.test.js
@@ -165,8 +165,19 @@ describe('sanitizeFoundationJudge — defensive LLM output shaping', () => {
expect(out.dimensions.worldbuilding.score).toBe(10);
expect(out.dimensions.character.score).toBe(0);
});
- it('isValidFoundationShape requires a dimensions object', () => {
- expect(isValidFoundationShape({ dimensions: {} })).toBe(true);
+ it('isValidFoundationShape requires every concrete rubric finding and rejects the echoed schema example', () => {
+ expect(isValidFoundationShape({ dimensions: dims(), oneLineVerdict: 'Specific weakest-link verdict' })).toBe(true);
+ expect(isValidFoundationShape({ dimensions: {} })).toBe(false);
+ expect(isValidFoundationShape({
+ dimensions: Object.fromEntries(FOUNDATION_DIMENSIONS.map((key) => [
+ key,
+ { score: 6, gap: 'string', fix: 'string' },
+ ])),
+ oneLineVerdict: 'string',
+ })).toBe(false);
+ expect(isValidFoundationShape({
+ dimensions: { ...dims(), craft: { score: 6, gap: '', fix: 'Add an actionable example.' } },
+ })).toBe(false);
expect(isValidFoundationShape({ oneLineVerdict: 'x' })).toBe(false);
expect(isValidFoundationShape(null)).toBe(false);
});
@@ -481,6 +492,30 @@ describe('judgeFoundation — cache / fast-pass', () => {
logSpy.mockRestore();
});
+ it('retries an echoed output-contract placeholder instead of persisting it as a score-six verdict', async () => {
+ seriesSvc.getSeries.mockResolvedValue({ id: 'ser-1', name: 'S', universeId: null });
+ const placeholderDimensions = Object.fromEntries(FOUNDATION_DIMENSIONS.map((key) => [
+ key,
+ { score: 6, gap: 'string', fix: 'string' },
+ ]));
+ stageRunner.runStagedLLM
+ .mockResolvedValueOnce({
+ content: { dimensions: placeholderDimensions, oneLineVerdict: 'string' },
+ providerId: 'judge-x', model: 'jm-heavy', runId: 'run-placeholder',
+ })
+ .mockResolvedValueOnce({
+ content: { dimensions: dims({ worldbuilding: 7 }), oneLineVerdict: 'The world rule is the weakest link.' },
+ providerId: 'judge-x', model: 'jm-heavy', runId: 'run-real',
+ });
+
+ const out = await judgeFoundation('ser-1', { force: true });
+
+ expect(stageRunner.runStagedLLM).toHaveBeenCalledTimes(2);
+ expect(out.runId).toBe('run-real');
+ expect(out.dimensions.worldbuilding.gap).toBe('gap worldbuilding');
+ expect(out.oneLineVerdict).toBe('The world rule is the weakest link.');
+ });
+
it('threads an autopilot critic route as soft defaults so a stage judge pin can win', async () => {
seriesSvc.getSeries.mockResolvedValue({ id: 'ser-1', name: 'S', universeId: null });
stageRunner.runStagedLLM.mockResolvedValue({