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(pipeline): repair dimensions below the requested foundation score first (#7154)
[._.]/2036e60992bd
diff --git a/server/services/pipeline/foundationJudge.js b/server/services/pipeline/foundationJudge.jsindex 24db41d9ed..765ed05e06 100644--- a/server/services/pipeline/foundationJudge.js+++ b/server/services/pipeline/foundationJudge.js@@ -200,9 +200,9 @@ export function computeWeightedScore(dimensions) {}/**- * The dimension the improve loop should target next: the LARGEST weighted- * deficit `weight × (10 − score)` — i.e. the single fix that moves the weighted- * composite the most. Ties break toward the lower raw score, then rubric order.+ * Largest weighted distance from a perfect rubric score, retained for snapshot+ * diagnostics: `weight × (10 − score)`. Gate repair selection instead uses+ * foundationFixTarget with the requested threshold. Ties break toward the lower raw score, then rubric order.* (Fixing a high-weight low-score dimension first is what converges the gate;* "weakest" by bare score would waste rounds polishing a 10%-weight craft nit* while a thin 40%-weight world drags the composite down.) Pure + unit-tested.@@ -242,7 +242,22 @@ export function foundationGateStatus(dimensions, weightedScore, threshold = DEFAexport function foundationFixTarget(dimensions, threshold = DEFAULT_FOUNDATION_THRESHOLD) {const { dimensionFloor, failingDimensions } = foundationGateStatus(dimensions, 0, threshold);- if (failingDimensions.length === 0) return weakestDimension(dimensions);+ if (failingDimensions.length === 0) {+ const target = Number.isFinite(threshold) ? threshold : DEFAULT_FOUNDATION_THRESHOLD;+ // Repair the shortfall that keeps this run below its requested bar. Using+ // distance from 10 sent a 7.8/8 foundation back to worldbuilding (already 8)+ // while its only deficient dimension, structure (7), remained untouched.+ const belowTarget = FOUNDATION_DIMENSIONS+ .filter((dimension) => dimensions?.[dimension] && clampScore(dimensions[dimension].score) < target)+ .map((dimension) => ({+ dimension,+ score: clampScore(dimensions[dimension].score),+ deficit: Math.round(FOUNDATION_WEIGHTS[dimension] * (target - clampScore(dimensions[dimension].score)) * 100) / 100,+ }))+ .sort((a, b) => b.deficit - a.deficit || a.score - b.score+ || FOUNDATION_DIMENSIONS.indexOf(a.dimension) - FOUNDATION_DIMENSIONS.indexOf(b.dimension));+ return belowTarget[0] || weakestDimension(dimensions);+ }return failingDimensions.map((dimension) => ({dimension,diff --git a/server/services/pipeline/seriesAutopilot.test.js b/server/services/pipeline/seriesAutopilot.test.jsindex a90b599a24..66f7517b57 100644--- a/server/services/pipeline/seriesAutopilot.test.js+++ b/server/services/pipeline/seriesAutopilot.test.js@@ -2255,6 +2255,23 @@ describe('autopilot conductor', () => {expect(applyFoundationFix).toHaveBeenCalledWith(seriesId, 'character', expect.any(Object));});+ it('foundation gate: repairs the dimension below the requested bar before polishing an already-ready world', async () => {+ foundationScore = 7.8;+ foundationDimensionScores = { worldbuilding: 8, character: 8, structure: 7, craft: 8 };+ applyFoundationFix.mockImplementationOnce(async (_seriesId, dimension) => {+ foundationScore = 8;+ foundationDimensionScores = { worldbuilding: 8, character: 8, structure: 8, craft: 8 };+ return { dimension, applied: true };+ });+ const { seriesId } = await seedComplete();+ await autopilot.startSeriesAutopilot(seriesId, { foundationThreshold: 8, maxFoundationRounds: 2 });+ await waitFor(runFinished(seriesId));++ expect(applyFoundationFix).toHaveBeenCalledTimes(1);+ expect(applyFoundationFix).toHaveBeenCalledWith(seriesId, 'structure', expect.any(Object));+ expect(autopilot.__testing.runs.get(seriesId)?.lastPayload?.type).toBe('complete');+ });+it('foundation gate: lets a newly surfaced target run before applying divergence patience', async () => {const snap = (weightedScore, scores) => ({seriesId: 'ser-example', status: 'complete', weightedScore,@@ -2289,18 +2306,18 @@ describe('autopilot conductor', () => {});it('foundation gate: reverts a repair that leaves its target unchanged, then retries it from the checkpoint', async () => {- const snapshot = (weightedScore) => ({+ const snapshot = (weightedScore, worldbuilding = 8) => ({seriesId: 'ser-example', status: 'complete', weightedScore,dimensions: {- worldbuilding: { score: 8, gap: 'The active-node evidence rule is undefined.', fix: 'Define it.' },- character: { score: 7, gap: 'Aruun privacy is mislabeled as a relapse.', fix: 'Separate privacy from safety disclosure.' },- structure: { score: 6, gap: 'The charter handoff is thin.', fix: 'Stage the handoff.' },- craft: { score: 7, gap: 'The panel grammar is thin.', fix: 'Add panel rules.' },+ worldbuilding: { score: worldbuilding, gap: 'The active-node evidence rule is undefined.', fix: 'Define it.' },+ character: { score: 6, gap: 'Aruun privacy is mislabeled as a relapse.', fix: 'Separate privacy from safety disclosure.' },+ structure: { score: 7, gap: 'The charter handoff is thin.', fix: 'Stage the handoff.' },+ craft: { score: 8, gap: 'The panel grammar is thin.', fix: 'Add panel rules.' },},});judgeFoundation.mockImplementationOnce(async () => snapshot(7.2))- .mockImplementationOnce(async () => snapshot(7.1));+ .mockImplementationOnce(async () => snapshot(7.1, 7.75));const checkpoint = { seriesId: 'ser-example', marker: 'before-character-repair' };snapshotFoundationState.mockResolvedValueOnce(checkpoint);