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: attribute foundation verification to judge models

[._.]/ Adam Eivy9c7911827f15
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 7425d75f58..32a0ce97c0 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -2,7 +2,7 @@
## Changed
-- **Series Autopilot can learn which models actually work at each step.** AI run history now distinguishes technical completion from a later editorial keep/revert decision and aggregates evidence by orchestration step, creative-versus-judge role, provider, model, and reasoning effort. The new opt-in selector requires multiple quality-reviewed samples plus a positive reliability threshold, ignores disabled providers and removed models, and remains a soft default beneath explicit run choices and exact prompt-stage pins. The Options panel reports how much attributed and quality-reviewed evidence exists, while local APIs expose the full metrics and allow an operator to correct or backfill a historical outcome, including its effort when the older run predates effort telemetry. Concurrent metadata updates for one run are serialized so provider telemetry cannot overwrite its Autopilot step/role attribution. Foundation judges record contract-valid responses separately from true editorial approval, and foundation repairs automatically record accepted versus rolled-back outcomes, so a model that finishes a long run but makes the story worse is not learned as a success.
+- **Series Autopilot can learn which models actually work at each step.** AI run history now distinguishes technical completion from a later editorial keep/revert decision and aggregates evidence by orchestration step, creative-versus-judge role, provider, model, and reasoning effort. The new opt-in selector requires multiple quality-reviewed samples plus a positive reliability threshold, ignores disabled providers and removed models, and remains a soft default beneath explicit run choices and exact prompt-stage pins. The Options panel reports how much attributed and quality-reviewed evidence exists, while local APIs expose the full metrics and allow an operator to correct or backfill a historical outcome, including its effort when the older run predates effort telemetry. Concurrent metadata updates for one run are serialized so provider telemetry cannot overwrite its Autopilot step/role attribution, and internal structure-verification calls retain the judge role instead of inheriting their repairer's creative role. Foundation judges record contract-valid responses separately from true editorial approval, and foundation repairs automatically record accepted versus rolled-back outcomes, so a model that finishes a long run but makes the story worse is not learned as a success.
- **Completed CoS agents no longer strand a worktree because of their own completion marker.** The `.agent-done` sentinel is consumed before worktree cleanup, but Git still reported the untracked file as ordinary authored work and the safety gate preserved the otherwise-clean checkout with a high-priority warning. Cleanup now ignores only that runtime marker: sentinel-only trees are removed normally, while any real source change still preserves the worktree and is named in the warning.
diff --git a/server/services/pipeline/foundationJudge.js b/server/services/pipeline/foundationJudge.js
index 8d98b6f8b5..f188e6fd08 100644
--- a/server/services/pipeline/foundationJudge.js
+++ b/server/services/pipeline/foundationJudge.js
@@ -1608,6 +1608,8 @@ export async function applyFoundationFix(seriesId, dimension, {
judgeProviderDefault,
judgeModelDefault,
judgeEffortDefault,
+ judgeOnRunCreated,
+ judgeOnRunSettled,
preserveDroppedSeasons = false,
onRunCreated,
onRunSettled,
@@ -1676,8 +1678,8 @@ export async function applyFoundationFix(seriesId, dimension, {
providerDefault: judgeProviderDefault,
modelDefault: judgeModelDefault,
effortDefault: judgeEffortDefault,
- onRunCreated,
- onRunSettled,
+ onRunCreated: judgeOnRunCreated,
+ onRunSettled: judgeOnRunSettled,
};
const runGuardedStructureRepair = async () => {
const first = await resolveVerifyIssues(seriesId, { findings, ...resolveOptions });
diff --git a/server/services/pipeline/foundationJudge.test.js b/server/services/pipeline/foundationJudge.test.js
index bae7a99adc..2e1c877f2b 100644
--- a/server/services/pipeline/foundationJudge.test.js
+++ b/server/services/pipeline/foundationJudge.test.js
@@ -1023,22 +1023,28 @@ describe('applyFoundationFix — dimension → owning-service routing table', ()
.mockResolvedValueOnce({ issues: [blocker] })
.mockResolvedValueOnce({ issues: [] });
+ const writerOnRunCreated = vi.fn();
+ const judgeOnRunCreated = vi.fn();
const r = await applyFoundationFix('ser-1', 'structure', {
finding: { gap: 'The midpoint lacks a costly reversal.', fix: 'Add a costly reversal.' },
providerOverride: 'writer-provider',
modelOverride: 'writer-model',
effortOverride: 'max',
+ onRunCreated: writerOnRunCreated,
judgeProviderDefault: 'judge-provider',
judgeModelDefault: 'judge-model',
judgeEffortDefault: 'xhigh',
+ judgeOnRunCreated,
});
expect(arcPlanner.resolveVerifyIssues).toHaveBeenCalledTimes(2);
expect(arcPlanner.resolveVerifyIssues).toHaveBeenNthCalledWith(2, 'ser-1', expect.objectContaining({
findings: [blocker], providerDefault: 'writer-provider', modelDefault: 'writer-model', effortDefault: 'max',
+ onRunCreated: writerOnRunCreated,
}));
expect(arcPlanner.verifyArc).toHaveBeenNthCalledWith(1, 'ser-1', expect.objectContaining({
providerDefault: 'judge-provider', modelDefault: 'judge-model', effortDefault: 'xhigh',
+ onRunCreated: judgeOnRunCreated,
}));
expect(arcPlanner.restoreArcState).not.toHaveBeenCalled();
expect(r).toMatchObject({ dimension: 'structure', applied: true, actions: 4 });
diff --git a/server/services/pipeline/seriesAutopilot/childRuns.js b/server/services/pipeline/seriesAutopilot/childRuns.js
index ab9c352bd5..300a865895 100644
--- a/server/services/pipeline/seriesAutopilot/childRuns.js
+++ b/server/services/pipeline/seriesAutopilot/childRuns.js
@@ -734,6 +734,7 @@ export async function runFoundationGate(seriesId, record) {
let fix;
const repairRunIds = [];
const creativeHooks = providerOverrideOpts(record);
+ const repairJudgeHooks = providerOverrideOpts(record, 'judge');
try {
fix = await applyFoundationFix(seriesId, weak.dimension, {
finding: snap.dimensions?.[weak.dimension] || {},
@@ -742,6 +743,8 @@ export async function runFoundationGate(seriesId, record) {
judgeProviderDefault: judgeLlm.providerOverride,
judgeModelDefault: judgeLlm.modelOverride,
judgeEffortDefault: judgeLlm.effortOverride,
+ judgeOnRunCreated: repairJudgeHooks.onRunCreated,
+ judgeOnRunSettled: repairJudgeHooks.onRunSettled,
...seasonPreserveOpts(record),
effortOverride: creativeLlm.effortOverride,
onRunCreated: (runId) => {