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: close four review-gate findings in the reviewer-effort pin
[._.]/ Adam Eivya9e224873a17
diff --git a/server/lib/cosValidation.js b/server/lib/cosValidation.jsindex 04934df6a1..7e43eec174 100644--- a/server/lib/cosValidation.js+++ b/server/lib/cosValidation.js@@ -570,14 +570,27 @@ export function reviewerEffortsFromDefaults(defaults) {* for codex, `[]` for everything else. Delegates to `buildEffortArgs` so the flag* shape has exactly one home (the spawn builders use the same one).*+ * **Normalizes first, deliberately.** `buildEffortArgs` CLAMPS an out-of-ladder+ * value (`agy` + `max` → `--effort high`), which is right for a provider pin the+ * user set against a different provider, but wrong here: a reviewer effort is+ * chosen from that reviewer's own list, so an out-of-ladder value means stale or+ * hand-edited state — and emitting a clamped flag would run the review at an+ * effort the picker displays as `unsupported`. Dropping to the reviewer's own+ * default is the honest failure, matching `normalizeReviewerEffort`'s contract.+ * The normalize is here rather than left to callers because this function is+ * reached with raw task metadata (`reviewLoopReviewerEfforts`), which no+ * normalizer has necessarily touched.+ ** @param {string} reviewer - reviewer slug* @param {string|null|undefined} effort* @returns {string[]}*/export function reviewerEffortArgs(reviewer, effort) {const binary = reviewerCliBinary(reviewer);- if (!binary || !effort) return [];- return buildEffortArgs(effort, { id: reviewer, command: binary });+ if (!binary) return [];+ const level = normalizeReviewerEffort(effort, reviewer);+ if (!level) return [];+ return buildEffortArgs(level, { id: reviewer, command: binary });}/**diff --git a/server/lib/cosValidation.test.js b/server/lib/cosValidation.test.jsindex a6f3a95872..adc4f58b01 100644--- a/server/lib/cosValidation.test.js+++ b/server/lib/cosValidation.test.js@@ -228,6 +228,19 @@ describe('per-reviewer reasoning effort (reviewerEfforts)', () => {expect(reviewerEffortArgs('claude', null)).toEqual([]);});+ it('DROPS an out-of-ladder effort instead of clamping it, even from unnormalized input', () => {+ // The underlying `buildEffortArgs` clamps (agy `max` → `--effort high`), which+ // is right for a provider pin carried across providers but wrong for a reviewer+ // effort picked from that reviewer's own list: emitting a clamped flag would run+ // the review at a tier the picker labels `unsupported`. This function is reached+ // with RAW task metadata (`reviewLoopReviewerEfforts`), so it must normalize+ // itself rather than trust the caller.+ expect(reviewerEffortArgs('antigravity', 'max')).toEqual([]);+ expect(reviewerEffortArgs('antigravity', 'ultra')).toEqual([]);+ // Case/whitespace still normalize through rather than being rejected.+ expect(reviewerEffortArgs('codex', ' HIGH ')).toEqual(['-c', 'model_reasoning_effort=high']);+ });+it('builds the slashdo-invocation note only for CLI reviewers carrying an effort', () => {const note = buildReviewerEffortNote(['codex', 'claude', 'copilot'], { codex: 'high', claude: 'low', copilot: 'high' });expect(note).toContain('`codex -c model_reasoning_effort=high`');diff --git a/server/services/agentPromptBuilder.js b/server/services/agentPromptBuilder.jsindex b6e65d3bc6..1fc5c4a0ee 100644--- a/server/services/agentPromptBuilder.js+++ b/server/services/agentPromptBuilder.js@@ -641,15 +641,23 @@ export function buildReviewLoopFollowUpSection(metadata = {}, { verbose = false,// The pinned reasoning effort rides the same body as `effort` — the endpoint// forwards it as the backend's OpenAI-compatible `reasoning_effort`. Same// absent-vs-empty contract as the model: no pin ⇒ the key is omitted, not blank.+ // Which body keys this run actually pins, accumulated across the local-LLM+ // reviewers in the list. The jq example below is built from THIS set rather than+ // naming both keys unconditionally: an effort-only run that was shown a+ // `model: "…"` placeholder would have the agent send the literal ellipsis, and+ // the route's `body.model || configured` prefers that truthy junk over the+ // install default — turning a pinned-effort review into a model-not-found error.+ const localLlmPinKeys = new Set();const localLlmPinNote = LOCAL_LLM_REVIEWERS.filter(r => reviewers.includes(r)).map((r) => {const keys = [];- if (typeof reviewerModelMap[r] === 'string' && reviewerModelMap[r]) keys.push(`"model": "${reviewerModelMap[r]}"`);- if (typeof reviewerEffortMap[r] === 'string' && reviewerEffortMap[r]) keys.push(`"effort": "${reviewerEffortMap[r]}"`);+ if (typeof reviewerModelMap[r] === 'string' && reviewerModelMap[r]) { keys.push(`"model": "${reviewerModelMap[r]}"`); localLlmPinKeys.add('model'); }+ if (typeof reviewerEffortMap[r] === 'string' && reviewerEffortMap[r]) { keys.push(`"effort": "${reviewerEffortMap[r]}"`); localLlmPinKeys.add('effort'); }return keys.length ? `\`${r}\` → \`${keys.join(', ')}\`` : null;}).filter(Boolean);+ const localLlmPinJq = ['backend: "…"', ...[...localLlmPinKeys].map(k => `${k}: "…"`), 'diff: .'].join(', ');const localLlmInvocation = `POST the diff to PortOS's local reviewer endpoint and extract its review text before evaluating it. Substitute the active reviewer name for \`<lmstudio|ollama>\`:\`\`\`bashREVIEW_RESPONSE=$(mktemp)@@ -663,7 +671,7 @@ elsefi\`\`\`Only a successfully extracted \`.findings\` value is the review text; treat it like any other reviewer's findings.${localLlmPinNote.length- ? ` This run pins settings for ${localLlmPinNote.join(', ')} — add those keys to the JSON body (\`jq -Rs '{ backend: "…", model: "…", effort: "…", diff: . }'\`) so the review runs with them instead of the install defaults.`+ ? ` This run pins settings for ${localLlmPinNote.join(', ')} — add those keys to the JSON body (\`jq -Rs '{ ${localLlmPinJq} }'\`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk.`: ''}`;// Instruct the agent to request each username reviewer as a PR reviewer and// gate the merge on their approval. `gh pr edit --add-reviewer` takes the barediff --git a/server/services/cleanupAgentWorktree.test.js b/server/services/cleanupAgentWorktree.test.jsindex 7e6685e71c..0ebc9d9373 100644--- a/server/services/cleanupAgentWorktree.test.js+++ b/server/services/cleanupAgentWorktree.test.js@@ -832,6 +832,47 @@ describe('cleanupAgentWorktree - openPR path', () => {expect(followUp.metadata.reviewLoopCodexModel).toBeNull();});+ // The effort map narrows against EFFORT_SELECTABLE_REVIEWERS, a DIFFERENT roster+ // than the model map's — `antigravity` takes an effort but no PortOS-pinnable+ // model. Passing the model roster here would silently drop every agy pin at this+ // hop with the rest of the suite still green, so pin the distinction explicitly.+ it('narrows the effort map against the effort roster, keeping an antigravity pin the model roster excludes', async () => {+ git.push.mockResolvedValue(undefined);+ git.createPR.mockResolvedValue({ success: true, url: 'https://github.com/test/repo/pull/61' });+ git.requestCopilotReview.mockResolvedValue({ success: true });+ addTask.mockResolvedValue({ id: 'sys-rl-eff' });++ await cleanupAgentWorktree('agent-1', true, {+ openPR: true, requestCopilotReview: true, reviewers: ['copilot', 'antigravity', 'claude'],+ reviewerModels: { claude: 'qwen2.5:7b' },+ // `codex` isn't in the reviewer list; `copilot` has no effort control at all.+ reviewerEfforts: { antigravity: 'high', claude: 'xhigh', codex: 'low', copilot: 'high' },+ description: 'Build',+ originalTask: { id: 'task-orig', priority: 'MEDIUM', metadata: { app: 'sparsetree' }, description: 'Build' }+ });++ const [followUp] = addTask.mock.calls[0];+ expect(followUp.metadata.reviewLoopReviewerEfforts).toEqual({ antigravity: 'high', claude: 'xhigh' });+ // The model map narrows on its own roster and is unaffected by the effort pins.+ expect(followUp.metadata.reviewLoopReviewerModels).toEqual({ claude: 'qwen2.5:7b' });+ });++ it('drops the effort map entirely when no effort-capable reviewer is in the list', async () => {+ git.push.mockResolvedValue(undefined);+ git.createPR.mockResolvedValue({ success: true, url: 'https://github.com/test/repo/pull/62' });+ git.requestCopilotReview.mockResolvedValue({ success: true });+ addTask.mockResolvedValue({ id: 'sys-rl-noeff' });++ await cleanupAgentWorktree('agent-1', true, {+ openPR: true, requestCopilotReview: true, reviewers: ['copilot'],+ reviewerEfforts: { claude: 'high' }, description: 'Build',+ originalTask: { id: 'task-orig', priority: 'MEDIUM', metadata: { app: 'sparsetree' }, description: 'Build' }+ });++ // Empty → null, so the prompt builder's "nothing configured" path is unambiguous.+ const [followUp] = addTask.mock.calls[0];+ expect(followUp.metadata.reviewLoopReviewerEfforts).toBeNull();+ });it('drops the model map entirely when no model-capable reviewer is in the list', async () => {git.push.mockResolvedValue(undefined);git.createPR.mockResolvedValue({ success: true, url: 'https://github.com/test/repo/pull/59' });diff --git a/server/services/cosTaskStore.js b/server/services/cosTaskStore.jsindex 0142376774..4a899d59de 100644--- a/server/services/cosTaskStore.js+++ b/server/services/cosTaskStore.js@@ -16,7 +16,7 @@ import { readFile, writeFile, stat } from 'fs/promises';import { existsSync } from 'fs';import { join } from 'path';import { parseTasksMarkdown, groupTasksByStatus, getAutoApprovedTasks, getAwaitingApprovalTasks, generateTasksMarkdown, hasKnownPrefix } from '../lib/taskParser.js';-import { REVIEW_STOP_MODES, normalizeReviewers, normalizeReviewUsernames, normalizeOptionalReviewers, normalizeReviewerMaxRounds, normalizeReviewerModels, normalizeReviewerEfforts } from '../lib/validation.js';+import { REVIEW_STOP_MODES, normalizeReviewers, normalizeReviewUsernames, normalizeOptionalReviewers, normalizeReviewerMaxRounds, normalizeReviewerModels, normalizeReviewerEfforts, reviewerEffortsFromDefaults } from '../lib/validation.js';import { PR_COMPLETIONS, PR_COMPLETION_VALUES } from '../lib/prDisposition.js';import { RETRY_HOLD_KEY, RETRY_HOLD_SINCE_KEY } from '../lib/taskRetryHold.js';import { REQUEUED_AT_KEY } from '../lib/taskRequeue.js';@@ -1135,10 +1135,17 @@ export async function resolveTaskChallengeWithRecheck(taskId, { recheck, resolve}const backend = recheck?.backend;// Model: explicit override wins, else the Code Review Defaults for this backend.+ // Effort has no per-request override (a re-check re-runs the SAME reviewer+ // configuration, it doesn't reconfigure it), so it always comes from the+ // defaults — but it must come from somewhere: this verdict decides whether a+ // disputed rejection is upheld or escalated to the user, and deriving it from a+ // pass run at a weaker effort than the user configured is the same silent+ // downgrade the pin exists to prevent.+ const recheckDefaults = await getCodeReviewDefaults().catch(() => null);+ const effort = reviewerEffortsFromDefaults(recheckDefaults)[backend] || null;let model = recheck?.model;if (!model) {- const defaults = await getCodeReviewDefaults().catch(() => null);- model = backend === 'ollama' ? defaults?.ollamaModel : defaults?.lmstudioModel;+ model = backend === 'ollama' ? recheckDefaults?.ollamaModel : recheckDefaults?.lmstudioModel;}// 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@@ -1146,8 +1153,8 @@ export async function resolveTaskChallengeWithRecheck(taskId, { recheck, resolveif (!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 });+ console.log(`⚖️ Re-checking challenge on ${taskId} via ${backend} (${model}${effort ? `, ${effort} effort` : ''})`);+ const review = await runLocalCodeReview({ backend, model, effort, diff: recheck?.diff });if (!review?.ok) {return { error: `Re-check failed: ${review?.error || 'unknown reviewer error'}`, code: 'RECHECK_FAILED' };}