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: explain headless reviewer command permission refusals (#10666)
Adam Eivyef65c1385db8
diff --git a/client/src/components/settings/CodeReviewersTab.jsx b/client/src/components/settings/CodeReviewersTab.jsxindex 9ebe30d935..0f24c2368a 100644--- a/client/src/components/settings/CodeReviewersTab.jsx+++ b/client/src/components/settings/CodeReviewersTab.jsx@@ -34,6 +34,7 @@ const FOLLOW_UP_PATH = '/models/code-reviewers/follow-up';const CONFIG_FAULT_REMEDIES = {NO_MODEL: 'Select a model on Review chain.',+ REVIEWER_COMMAND_PERMISSION_DENIED: 'Use a compatible non-interactive review transport or supported tool-free vendor configuration; keep command, network and write permissions disabled.',REVIEWER_ACCESS_DENIED: 'Select an accessible service or model, or correct provider access.',REVIEWER_UNSUPPORTED: 'Set its command or switch it to API mode in AI Providers.',};diff --git a/client/src/components/settings/CodeReviewersTab.test.jsx b/client/src/components/settings/CodeReviewersTab.test.jsxindex cc8bb28108..650ea4e585 100644--- a/client/src/components/settings/CodeReviewersTab.test.jsx+++ b/client/src/components/settings/CodeReviewersTab.test.jsx@@ -216,6 +216,16 @@ describe('CodeReviewersTab', () => {expect(screen.getByText(/The next successful review clears this warning/)).toBeInTheDocument();});+ it('names a headless command refusal and recommends a compatible reviewer without granting permissions', async () => {+ api.getCodeReviewDefaults.mockResolvedValue({+ reviewers: ['provider:example-cli'], optionalReviewers: ['provider:example-cli'],+ reviewerConfigFaults: { 'provider:example-cli': { code: 'REVIEWER_COMMAND_PERMISSION_DENIED', lastFailureAt: 123 } },+ });+ renderTab(<CodeReviewersTab />);+ expect(await screen.findByText(/provider:example-cli: the last review attempt failed/)).toHaveTextContent('Use a compatible non-interactive review transport or supported tool-free vendor configuration; keep command, network and write permissions disabled.');+ expect(screen.getByText(/The next successful review clears this warning/)).toBeInTheDocument();+ });+it('renders error banner with Retry button and disables Save button when fetch rejects', async () => {api.getCodeReviewDefaults.mockRejectedValue(new Error('Network error'));diff --git a/server/lib/README.md b/server/lib/README.mdindex 7b13857437..9cc0981664 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -221,7 +221,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub| `llmText.js` | Pure LLM-output text helpers — `stripCodeFences` (unfence a model reply) and `parseLLMJSON` (unfence then JSON.parse with a descriptive throw). Below the provider layer, so lib can clean model output without importing provider orchestration. || `providerCooldown.js` | Provider bench policy — `resolveProviderBench(analysis)` → `null` (don't bench) / a `usage-limit` marker / an `unavailable` marker with the per-category cooldown from `COOLDOWN_MS_BY_CATEGORY`. Declines to bench request/response-specific categories (`isRequestSpecificCategory` / `isSchemaTypeCategory`) so one bad model id or off-shape response can't take a healthy provider offline. Shared by `services/promptRunner.js` (prompt cascade) and `services/agentFinalization.js` (finished CoS agent run) so both bench a category for the same window. Pure. || `reviewerConfig.js` | Review-Loop reviewer vocabulary (split out of `cosValidation.js`, #5702; Zod-free): the reviewer roster + aliases (`REVIEWER_VALUES` / `REVIEWER_ALIASES` / `DEFAULT_REVIEWER`), the local-LLM / PortOS-only / model-capable / effort-selectable subsets, the slug→CLI-binary map (`REVIEWER_CLI_BINARIES`, `isCliReviewer`, `reviewerCliBinary`), the keyed model/effort/max-rounds pin normalizers + resolvers (`normalizeReviewers`, `normalizeReviewerModels`, `normalizeReviewerEfforts`, `resolveReviewerGroup` — task reviewer overrides fall back through system tiers when paused, `resolveReviewerConfig`, `resolveReviewPolicy` — the whole reviewer config plus stop-mode and the public-forge `reviewerApplies` clamp as ONE frozen `reviewPolicy` the prompt builders take, `resolveClaimReviewerConfig`, `KEYED_REVIEWER_PINS`), the override-key rosters that say when a task has pinned its own reviewers (`REVIEWER_OVERRIDE_KEYS` — everything the picker writes and its reset clears; `REVIEWER_LIST_OVERRIDE_KEYS` / `hasReviewerOverride` — only the keys that can change the resolved LIST), and the emitters that render a reviewer set into slashdo argv (`buildReviewWithArgs` — which emits `--reviewer-applies` only alongside an `APPLY_CAPABLE_REVIEWERS` slug, the reviewers slashdo lets edit the tree, `buildReviewersCsv`) and into agent-prompt notes (`buildReviewerPinNote`, `buildReviewerEffortNote`). Re-exported flat by `cosValidation.js`, so existing `validation.js` imports keep resolving. Provider-backed identities use `provider:<id>` (`isProviderReviewer`, `isReviewer`, `isToolFreeReviewer`) and additive `providerModels` defaults; legacy scalar pins stay compatible. `REVIEWER_CONFIG_FAULT_CODES` / `isReviewerConfigFault` name the refusals a caller fixes by changing configuration (no model, missing/disabled provider, missing CLI command or unsupported explicitly restricted transport) rather than by retrying, so a reviewer that can never answer is not mistaken for a transient outage. |-| `reviewerHealth.js` | Dependency-free `activeReviewerGroupIndex` (shared runtime/editor pause selection), bounded malformed-review diagnostics and finish metadata, reviewer configuration-fault vocabulary and `reviewerAccessFailureCode`, which recognizes explicit structured OpenCode access refusals without treating generic HTTP or transport failures as permanent faults. |+| `reviewerHealth.js` | Dependency-free `activeReviewerGroupIndex` (shared runtime/editor pause selection), bounded malformed-review diagnostics and finish metadata, reviewer configuration-fault vocabulary, `reviewerCommandPermissionFailureCode` for explicit headless command-permission refusals, and `reviewerAccessFailureCode`, which recognizes explicit structured OpenCode access refusals without treating generic HTTP or transport failures as permanent faults. || `providerPrerequisites.js` | Can a provider run on this host AT ALL — `providerPrerequisites(provider, { runtime, gatewayKeySet })` → `{ met, missing: [{ code, label }] }` (CLI binary on PATH, API key stored for a public endpoint, the sibling key a gateway-backed wrapper inherits from the API record of its own gateway id unless it carries its own), plus `providerRuntimeKey` (`null` for an API provider, for a command carrying an explicit path, and for a provider with its own `PATH` in `envVars` — the runtime table only answers "does the BARE binary resolve on PortOS's PATH?", which is not those providers' question), `isPrivateNetworkEndpoint` (mirror of the client copy: loopback/RFC1918/tailnet CGNAT + ULA/`.ts.net`/single-label hosts need no key) and `describeMissingPrerequisites`. `runtime: null` = NOT PROBED and never counts as missing. Feeds BOTH `GET /api/providers` and the fallback chain in `aiToolkit/providerStatus.js` (via `services/providerPrerequisites.js`), so a `NEEDS SETUP` card and the router read one computation (#4611). `ROUTING_BLOCKING_CODES`/`blocksRouting(missing)` narrow what ROUTING may act on to the missing binary. Stored, inherited, and environment-backed credential findings stay presentation-only here because the server cannot assume the eventual process environment; the client card classifies sanitized env metadata through tri-state lookups (#4612). Pure. || `tuiShellLaunch.js` | `buildTuiShellLaunch(provider)` → `{ commandLine, env }` for launching a TUI provider by hand in a Shell session (the AI Providers card's "Launch in Shell" button). Resolves the command via `tuiHandshake.js#buildTuiInvocation` (so the vendor posture flags and `--model`/`--effort` injection match a real TUI spawn) and the env via `cliChildEnv.js#composeProviderEnv`. **The env is why this is server-side and the deep link carries only a provider ID**: a TUI provider's backend lives in `envVars` (`ANTHROPIC_BASE_URL` for an Ollama-backed or Bedrock `claude`, `OPENCODE_CONFIG_CONTENT` for an OpenCode wrapper), so a shell handed only the command line would run the right binary against the vendor cloud instead of the local daemon the user configured — and those values are secret, so they can't ride a URL. Returns null for a non-TUI provider. Must be given a RAW provider, never a client-sanitized one (redacted `'***'` env reads truthy). || `tuiHandshake.js` | Shared TUI invocation + paste-handshake constants. Also owns `SUBMIT_KEY` — the single Enter byte every PTY writer sends, whether it's submitting a pasted TUI prompt or a command PortOS injected into a shell session. It is CR, never LF: a POSIX pty's ICRNL hides the difference, but cmd.exe under Windows ConPTY accepts only CR and leaves an LF-terminated line typed-but-unexecuted at the prompt. |diff --git a/server/lib/reviewerHealth.js b/server/lib/reviewerHealth.jsindex 329d2d0439..55fe4ba530 100644--- a/server/lib/reviewerHealth.js+++ b/server/lib/reviewerHealth.js@@ -3,7 +3,7 @@* configuration: health readers must not load a runner or probe a provider.*/export const REVIEWER_CONFIG_FAULT_CODES = Object.freeze([- 'NO_MODEL', 'REVIEWER_UNAVAILABLE', 'REVIEWER_UNSUPPORTED', 'REVIEWER_ACCESS_DENIED',+ 'NO_MODEL', 'REVIEWER_UNAVAILABLE', 'REVIEWER_UNSUPPORTED', 'REVIEWER_ACCESS_DENIED', 'REVIEWER_COMMAND_PERMISSION_DENIED',]);export const isReviewerConfigFault = code => REVIEWER_CONFIG_FAULT_CODES.includes(code);@@ -24,6 +24,13 @@ export function reviewerAccessFailureCode(reviewer, failure) {return freeTierError || accessDenied ? 'REVIEWER_ACCESS_DENIED' : null;}+/** Match the vendor's explicit headless refusal, never generic permission prose. */+export function reviewerCommandPermissionFailureCode(message) {+ if (typeof message !== 'string') return null;+ return /^(?:jetski:\s*)?no output produced [—–-] a tool required the ["']command["'] permission that headless mode cannot prompt for, so it was auto-denied\.?$/im.test(message)+ ? 'REVIEWER_COMMAND_PERMISSION_DENIED' : null;+}+/** First nonempty tier with ALL members unpaused, or the first configured tier.* Empty drafts never participate. Shared by runtime and the settings preview;* configuration faults are warnings, not quota pauses or a new fallback rule.diff --git a/server/scripts/run-local-code-review.test.js b/server/scripts/run-local-code-review.test.jsindex d8ee6042f7..25172059c0 100644--- a/server/scripts/run-local-code-review.test.js+++ b/server/scripts/run-local-code-review.test.js@@ -33,6 +33,10 @@ it('runs a saved provider reviewer from the standalone claim bridge without bootconst args = process.argv.slice(2);// No reviewer mode means ordinary argv, so it must run outside the caller's checkout.if (existsSync('context.txt') || args.includes('baked-model') || args[args.indexOf('--model') + 1] !== 'review-model') process.exit(1);+ if (args.includes('--refuse')) {+ process.stderr.write('jetski: no output produced — a tool required the "command" permission that headless mode cannot prompt for, so it was auto-denied.\\nsynthetic-private-path-or-credential');+ process.exit(1);+ }process.stdout.write('NO FINDINGS');});`);@@ -41,6 +45,7 @@ it('runs a saved provider reviewer from the standalone claim bridge without bootawait writeFile(join(data, 'providers.json'), JSON.stringify({ activeProvider: 'example-gpu', providers: {'example-gpu': { id: 'example-gpu', name: 'Example GPU', type: 'api', enabled: true,endpoint: `http://127.0.0.1:${api.address().port}/v1`, models: ['default-model', 'review-model'], defaultModel: 'default-model' },+ 'example-refusal': { id: 'example-refusal', name: 'Example Refusal', type: 'cli', enabled: true, command: process.execPath, args: [harness, '--refuse'], defaultModel: 'review-model' },'example-cli': { id: 'example-cli', name: 'Example CLI', type: 'cli', enabled: true, command: process.execPath, args: [harness, '--model', 'baked-model'], defaultModel: 'default-model' },} }));await writeFile(join(data, 'settings.json'), JSON.stringify({ codeReview: {@@ -70,12 +75,17 @@ it('runs a saved provider reviewer from the standalone claim bridge without bootconst cliRequest = { backend: 'provider:example-cli', model: 'review-model', diff: request.diff };return [await runReview(request), await runReview({ ...request, inheritDefaults: false }), await runReview(cliRequest),await runReview({ ...cliRequest, kind: 'claim-review' }),- await runReview({ kind: 'claim-comments', backend: 'provider:example-cli', model: 'review-model', comments: [{ login: 'example-user', type: 'User', body: 'I will work on this' }] })];+ await runReview({ kind: 'claim-comments', backend: 'provider:example-cli', model: 'review-model', comments: [{ login: 'example-user', type: 'User', body: 'I will work on this' }] }),+ await runReview({ ...cliRequest, backend: 'provider:example-refusal', kind: 'claim-review', inheritDefaults: false })];})().finally(async () => {await new Promise(resolve => api.close(resolve));await rm(root, { recursive: true, force: true });});- expect(results).toHaveLength(5);+ expect(results).toHaveLength(6);+ expect(results[5].code).not.toBe(0);+ expect(JSON.parse(results[5].stdout)).toMatchObject({ ok: false, code: 'REVIEWER_COMMAND_PERMISSION_DENIED' });+ expect(results[5].stderr).toContain('Reviewer configuration fault (REVIEWER_COMMAND_PERMISSION_DENIED) for provider:example-refusal');+ expect(results[5].stdout + results[5].stderr).not.toContain('synthetic-private');// Ordinary and claim code reviews both use the scratch review procedure.// Public-comment screening still requires an enforced reviewer mode.for (const result of [results[2], results[3]]) {diff --git a/server/services/codeReview.js b/server/services/codeReview.jsindex 9d0161f040..3c42db7e6c 100644--- a/server/services/codeReview.js+++ b/server/services/codeReview.js@@ -55,7 +55,7 @@ import {} from '../lib/goalFidelity.js'import { MAX_SCREENSHOT_BYTES } from '../lib/uploadLimits.js'import { normalizeGoalFidelityFollowUpTrigger } from '../lib/goalFidelityFollowUp.js'-import { activeReviewerGroupIndex, isReviewerConfigFault, normalizeReviewFinishReason, reviewFailureDiagnostics } from '../lib/reviewerHealth.js'+import { activeReviewerGroupIndex, isReviewerConfigFault, reviewerCommandPermissionFailureCode, normalizeReviewFinishReason, reviewFailureDiagnostics } from '../lib/reviewerHealth.js'import { getSettings, updateSettingsWith, settingsEvents } from './settings.js'export const REVIEWER_PAUSE_MS = 24 * 60 * 60 * 1000@@ -925,6 +925,16 @@ async function runConfiguredProviderCompletion({ backend, model: pinnedModel, mesafetyProfile, codeReview: true })}).catch(() => ({ error: 'Reviewer credential setup or execution failed.' })).finally(() => isolatedCwd && rm(isolatedCwd, { recursive: true, force: true }))+ // A failed headless command request is a configuration fault, not a verdict.+ // Replace vendor prose with a bounded remedy before health or bridge output.+ if (result.error || result.partial || !result.text?.trim()) {+ const code = reviewerCommandPermissionFailureCode(result.error || result.stderr)+ if (code) return {+ ok: false,+ code,+ error: 'The headless reviewer required command permission. Use a compatible non-interactive review transport or supported tool-free vendor configuration.',+ }+ }if (result.partial) {const errorMsg = result.stderr?.trim() || result.text?.trim() || 'Reviewer exited before completing its response.'return {diff --git a/server/services/codeReview.providers.test.js b/server/services/codeReview.providers.test.jsindex 5ae37e4205..e97673fecb 100644--- a/server/services/codeReview.providers.test.js+++ b/server/services/codeReview.providers.test.js@@ -150,6 +150,30 @@ describe('configured provider reviewers', () => {expect(result).not.toHaveProperty('findings');});+ it('returns a bounded configuration fault for an explicit headless command refusal without a verdict', async () => {+ getProviderById.mockResolvedValue({ ...provider, type: 'cli', command: 'agy' });+ const diagnostic = 'jetski: no output produced — a tool required the "command" permission that headless mode cannot prompt for, so it was auto-denied.';+ for (const failure of [{ error: diagnostic }, { stderr: diagnostic, text: '', partial: false }, { stderr: diagnostic, text: 'incomplete', partial: true }]) {+ runCliProviderPrompt.mockResolvedValue({ ...failure, stderr: `${diagnostic}\nsynthetic-private-path-or-credential` });+ const result = await runLocalCodeReview({ backend, diff: 'example diff' });+ expect(result).toEqual({ ok: false, code: 'REVIEWER_COMMAND_PERMISSION_DENIED', error: expect.stringContaining('supported tool-free vendor configuration') });+ expect(isReviewerConfigFault(result.code)).toBe(true);+ expect(JSON.stringify(result)).not.toContain('synthetic-private');+ }+ expect(runCliProviderPrompt).toHaveBeenCalledTimes(3);+ expect(callProviderAISimple).not.toHaveBeenCalled();+ });++ it.each(['permission denied', 'headless mode cannot prompt for permission', 'Reviewer returned no content.', 'Provider call timed out after 1000ms', 'connection reset'])('keeps generic CLI failure transient: %s', async error => {+ getProviderById.mockResolvedValue({ ...provider, type: 'cli', command: 'agy' });+ runCliProviderPrompt.mockResolvedValue({ error });+ const result = await runLocalCodeReview({ backend, diff: 'example diff', timeoutMs: 1000 });+ expect(result.ok).toBe(false);+ expect(result.error).toContain(error.includes('timed out') ? 'timed out after 1000ms' : error);+ expect(isReviewerConfigFault(result.code)).toBe(false);+ expect(result).not.toHaveProperty('findings');+ });+// #7720: a bootstrap-credentialed harness has a maintained no-tool recipe and// must be usable as a reviewer, not refused at selection time. The record// reaches the CLI spawn with its `credentialBootstrap` intact — that is whatdiff --git a/server/services/codeReview.test.js b/server/services/codeReview.test.jsindex e6418ae605..029c4d2b74 100644--- a/server/services/codeReview.test.js+++ b/server/services/codeReview.test.js@@ -373,6 +373,20 @@ describe('codeReview helpers', () => {expect(await getReviewerConfigHealth()).toEqual({ status: 'ok', configFaults: {} })})+ it('records a headless command refusal as a warning without pausing or changing optional policy, then clears it', async () => {+ const reviewer = 'provider:example-cli'+ const config = { reviewers: [reviewer], optionalReviewers: [reviewer] }+ mockedSettings.current = { codeReview: config }+ await reportReviewerFailure(reviewer, { code: 'REVIEWER_COMMAND_PERMISSION_DENIED', error: 'synthetic-private-diagnostic' }, 100)+ expect(mockedSettings.current.codeReview).toEqual({ ...config, reviewerHealth: {+ [reviewer]: { code: 'REVIEWER_COMMAND_PERMISSION_DENIED', reason: 'configuration', failureCount: 1, lastFailureAt: 100 },+ } })+ expect(codeReviewSettingsSchema.parse(mockedSettings.current.codeReview)).toEqual(mockedSettings.current.codeReview)+ expect(await getReviewerConfigHealth()).toMatchObject({ status: 'warning', configFaults: { [reviewer]: { code: 'REVIEWER_COMMAND_PERMISSION_DENIED' } } })+ await reportReviewerSuccess(reviewer, 200)+ expect(mockedSettings.current.codeReview).toEqual(config)+ })+it('persists and reports only safe malformed diagnostics without pausing or changing reviewer policy', async () => {mockedSettings.current = { codeReview: { reviewers: ['ollama'], optionalReviewers: ['ollama'] } }const config = structuredClone(mockedSettings.current.codeReview)