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: 400 for missing re-check model + don't escalate on empty Blocking header (#2471)
Adam Eivy8ef02ff64367
diff --git a/server/services/cosChallenge.js b/server/services/cosChallenge.jsindex 8f1212290e..8a28c1f73e 100644--- a/server/services/cosChallenge.js+++ b/server/services/cosChallenge.js@@ -125,8 +125,16 @@ export function classifyRecheckOutcome(findings) {if (!trimmed) return null;// Exact clean sentinel — the diff is clean across all severities.if (/^no findings\.?$/i.test(trimmed)) return 'upheld';- // A surviving `## Blocking` section is the only thing that gates a merge.- if (/^\s*#{1,6}\s*blocking\b/im.test(trimmed)) return 'escalated';- // Findings present, but nothing under Blocking — nothing gates the merge.+ // A `## Blocking` section only sustains the rejection when it actually carries a+ // finding. A noisy reviewer (the very case this protocol guards against) that+ // emits a bare/empty Blocking header must NOT trigger the expensive user+ // escalation on the header alone — require non-empty body text under it.+ const blockingMatch = trimmed.match(/^\s*#{1,6}\s*blocking\b[^\n]*\n?([\s\S]*)$/im);+ if (blockingMatch) {+ // Body = text after the Blocking header up to the next heading (or EOF).+ const body = blockingMatch[1].split(/^\s*#{1,6}\s/m)[0];+ if (body.trim()) return 'escalated';+ }+ // Findings present, but nothing blocking — nothing gates the merge.return 'upheld';}diff --git a/server/services/cosChallenge.test.js b/server/services/cosChallenge.test.jsindex 7241397ae6..2abd3d11a4 100644--- a/server/services/cosChallenge.test.js+++ b/server/services/cosChallenge.test.js@@ -102,6 +102,11 @@ describe('cosChallenge', () => {expect(classifyRecheckOutcome('## Recommended\n- rename x\n\n## Nits\n- spacing')).toBe('upheld');});+ it('does NOT escalate on a bare/empty Blocking header (noisy-reviewer guard)', () => {+ expect(classifyRecheckOutcome('## Blocking\n\n## Recommended\n- x')).toBe('upheld');+ expect(classifyRecheckOutcome('## Blocking')).toBe('upheld');+ });+it('returns null for unusable input so the caller treats it as a failed re-check', () => {expect(classifyRecheckOutcome('')).toBeNull();expect(classifyRecheckOutcome(' ')).toBeNull();diff --git a/server/services/cosTaskStore.js b/server/services/cosTaskStore.jsindex 5321a59663..06efef5170 100644--- a/server/services/cosTaskStore.js+++ b/server/services/cosTaskStore.js@@ -725,7 +725,13 @@ export async function resolveTaskChallengeWithRecheck(taskId, { recheck, resolveconst defaults = await getCodeReviewDefaults().catch(() => null);model = backend === 'ollama' ? defaults?.ollamaModel : defaults?.lmstudioModel;}- console.log(`⚖️ Re-checking challenge on ${taskId} via ${backend}${model ? ` (${model})` : ''}`);+ // A missing model is a config problem (no Code Review Defaults set), not an+ // upstream-reviewer failure — surface it as a 4xx (RECHECK_NO_MODEL → 400), not+ // the 502 bucket reserved for a reviewer that's actually unreachable.+ if (!model) {+ return { error: `No model configured for the ${backend} reviewer — set one on the AI Providers → Code Review Defaults panel.`, code: 'RECHECK_NO_MODEL' };+ }+ console.log(`⚖️ Re-checking challenge on ${taskId} via ${backend} (${model})`);const review = await runLocalCodeReview({ backend, model, diff: recheck?.diff });if (!review?.ok) {return { error: `Re-check failed: ${review?.error || 'unknown reviewer error'}`, code: 'RECHECK_FAILED' };@@ -737,6 +743,8 @@ export async function resolveTaskChallengeWithRecheck(taskId, { recheck, resolveconst verdict = outcome === 'upheld'? `no blocking findings survived (${backend})`: `a blocking finding still stands (${backend})`;- const note = `Auto re-check by ${backend}${model ? ` (${model})` : ''}: ${verdict}.`;+ // The resolution note is auto-generated from the re-check verdict (any caller+ // `note` is intentionally not threaded here — the machine verdict is the record).+ const note = `Auto re-check by ${backend} (${model}): ${verdict}.`;return resolveTaskChallenge(taskId, { outcome, note, resolvedBy: resolvedBy || `recheck:${backend}` }, taskType, { now });}diff --git a/server/services/cosTaskStore.test.js b/server/services/cosTaskStore.test.jsindex 658f213c64..c60e27abe2 100644--- a/server/services/cosTaskStore.test.js+++ b/server/services/cosTaskStore.test.js@@ -692,6 +692,15 @@ describe('cosTaskStore.resolveTaskChallengeWithRecheck (#2471)', () => {expect(mock.reviewCalls[0].model).toBe('coder-7b');});+ it('returns RECHECK_NO_MODEL (config problem, not 502) when no model is configured', async () => {+ const id = await seedChallenged();+ mock.reviewDefaults = { lmstudioModel: null, ollamaModel: null };+ const result = await resolveTaskChallengeWithRecheck(id, { recheck: { backend: 'ollama', diff: 'diff' } });+ expect(result.code).toBe('RECHECK_NO_MODEL');+ // No reviewer call attempted without a model.+ expect(mock.reviewCalls.length).toBe(0);+ });+it('returns RECHECK_FAILED when the reviewer is unreachable', async () => {const id = await seedChallenged();mock.review = { ok: false, error: 'ollama request failed: ECONNREFUSED' };