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: let pr-reviewer stages run on enabled TUI providers, spawned headless

[._.]/ Adam Eivy9229c78691a6
diff --git a/client/src/components/ProviderModelSelector.jsx b/client/src/components/ProviderModelSelector.jsx
index 125f9ae5f3..d62c1cc714 100644
--- a/client/src/components/ProviderModelSelector.jsx
+++ b/client/src/components/ProviderModelSelector.jsx
@@ -65,6 +65,7 @@ import {
filterHardwareCompatibleProviderModels,
isProviderHardwareCompatible,
isProviderModelHardwareCompatible,
+ selectableProviders,
localToolUseHint,
withToolUseOptionLabel,
} from '../utils/providers.js';
@@ -139,16 +140,11 @@ export default function ProviderModelSelector({
const annotateToolUse = highlightToolUse && toolUseLoaded;
const toolHint = annotateToolUse ? localToolUseHint(effectiveModel, selectedProvider, toolUseIdsByProvider) : null;
const toolIncapable = toolHint?.toolCapable === false;
- // Only offer enabled providers (treat a missing `enabled` as enabled). The
- // currently-selected provider stays visible even if disabled, so a record
+ // Only offer enabled, hardware-compatible, policy-allowed providers; the
+ // currently-selected provider stays visible whatever its state, so a record
// pinned to a now-disabled provider still renders its value instead of
- // silently blanking the select. This is the single DRY gate for every
- // provider→model picker; callers may also pre-filter, which is idempotent.
- const visibleProviders = providerList.filter(
- (p) => (p.enabled !== false || p.id === selectedProviderId)
- && (isProviderHardwareCompatible(p) || p.id === selectedProviderId)
- && (!providerAllowed || providerAllowed(p) || p.id === selectedProviderId)
- );
+ // silently blanking the select (`selectableProviders` is the one rule).
+ const visibleProviders = selectableProviders(providerList, { selectedId: selectedProviderId, allowed: providerAllowed });
const compatibleModels = filterHardwareCompatibleProviderModels(availableModels, selectedProvider)
.filter((model) => !modelAllowed || modelAllowed(model, selectedProvider));
const selectedModelIsUnavailable = Boolean(
diff --git a/client/src/components/cos/tabs/schedule/PipelineStageConfig.jsx b/client/src/components/cos/tabs/schedule/PipelineStageConfig.jsx
index 07b3912e5e..073177cce5 100644
--- a/client/src/components/cos/tabs/schedule/PipelineStageConfig.jsx
+++ b/client/src/components/cos/tabs/schedule/PipelineStageConfig.jsx
@@ -5,7 +5,7 @@ import {
effortSurvivingModel,
localBackendForProvider,
publicReviewSelectionPolicy,
- supportsPublicReviewPosture,
+ selectableProviders,
PUBLIC_REVIEW_ACTIONS_POSTURE,
PUBLIC_REVIEW_NO_TOOL_POSTURE,
} from '../../../../utils/providers';
@@ -19,12 +19,14 @@ import {
togglePrReviewerActions,
} from './scheduleConstants';
-// Which providers on THIS install can enforce a posture. The server publishes
-// `publicReviewPostures` per provider, derived from the vendor rows, so the
-// picker never carries its own list of vendor names — an install with only
-// grok, only codex, or only a local Claude wrapper each get a correct list.
-const eligibleProvidersFor = (providers, posture) =>
- (providers || []).filter((provider) => supportsPublicReviewPosture(provider, posture));
+// Which providers on THIS install the stage's picker actually offers. The
+// posture half is server-published (`publicReviewPostures`, derived from the
+// vendor rows — no vendor names on the client); the rest is the picker's own
+// visibility rule, reused so the "eligible" note can never list a provider
+// the dropdown hides (switched off, hardware-incompatible), which is what left
+// Stage 3 looking unconfigurable.
+const eligibleProvidersFor = (providers, policy) =>
+ selectableProviders(providers, { allowed: policy.provider });
export default function PipelineStageConfig({ taskType, config, providers, onUpdate, updating, setUpdating }) {
const stages = pipelineStages(config);
@@ -128,7 +130,7 @@ export default function PipelineStageConfig({ taskType, config, providers, onUpd
const posture = isSecurityStage ? null : stagePublicReviewPosture(stage);
const isNoToolStage = posture === PUBLIC_REVIEW_NO_TOOL_POSTURE;
const isActionsStage = Boolean(posture) && !isNoToolStage;
- const eligibleProviders = posture ? eligibleProvidersFor(providers, posture) : null;
+ const eligibleProviders = posture ? eligibleProvidersFor(providers, selectionPolicies[posture]) : null;
const localBackend = localBackendForProvider(stageProvider);
const localModelIds = localBackend === 'ollama' ? ollama : localBackend === 'lmstudio' ? lmstudio : [];
// A LOCAL provider's installed-model list is the source of truth (its
@@ -168,10 +170,10 @@ export default function PipelineStageConfig({ taskType, config, providers, onUpd
</div>
{isSecurityStage && (
<div className="rounded-lg border border-port-accent/30 bg-port-bg/60 px-3 py-2 text-xs text-gray-300">
- <p className="font-medium text-port-accent">Managed Llama Prompt Guard 2 86M</p>
- <p className="mt-1">Fixed, pinned, offline classifier. It scans complete external content before Stage 2 and never appears as a chat model or receives tools, MCP servers, repository files, or GitHub credentials.</p>
+ <p className="font-medium text-port-accent">Deterministic hidden-content screen</p>
+ <p className="mt-1">Server-side checks on each external PR&apos;s complete title, description, and diff for content a human reviewer would miss — invisible or direction-control Unicode, comments GitHub never renders that address a model — and for obvious model-directed harm: instruction overrides, decode-and-follow or download-and-run instructions, credential exfiltration, and attempts to steer the review verdict. No model, tools, repository checkout, or GitHub credentials are involved.</p>
<p className="mt-1 text-gray-500">
- Install or check readiness from{' '}
+ The pinned Llama Prompt Guard 2 classifier runs as an optional second layer only when it is installed on{' '}
<Link to="/models/llms/abuse" className="underline hover:text-port-accent">Models → LLMs → Abuse Guard</Link>.
</p>
</div>
diff --git a/client/src/components/cos/tabs/schedule/PipelineStageConfig.test.jsx b/client/src/components/cos/tabs/schedule/PipelineStageConfig.test.jsx
index 0fda45e235..c95c5e25cf 100644
--- a/client/src/components/cos/tabs/schedule/PipelineStageConfig.test.jsx
+++ b/client/src/components/cos/tabs/schedule/PipelineStageConfig.test.jsx
@@ -177,6 +177,23 @@ describe('PipelineStageConfig — posture-driven eligibility', () => {
expect(screen.getAllByText(/Eligible on this install: Grok/).length).toBe(2);
});
+ // The bug behind #5906's blocked run: the CLI records were disabled and the
+ // TUI records enabled, so the note listed three "eligible" providers while
+ // the dropdown offered only the placeholder. Eligibility now follows what the
+ // server publishes for the ENABLED records — TUI siblings included.
+ it('lists only enabled providers as eligible, matching what the dropdown offers', () => {
+ renderWith([
+ { id: 'codex', name: 'Codex CLI', type: 'cli', command: 'codex', enabled: false, models: ['gpt-5.6'], publicReviewPostures: ['no-tool', 'sandboxed-actions'] },
+ { id: 'codex-tui', name: 'Codex TUI', type: 'tui', command: 'codex', enabled: true, models: ['gpt-5.6'], publicReviewPostures: ['no-tool', 'sandboxed-actions'] },
+ { id: 'grok-cli', name: 'Grok Build CLI', type: 'cli', command: 'grok', enabled: false, models: ['grok-4'], publicReviewPostures: ['no-tool', 'sandboxed-actions'] },
+ ]);
+ const providerSelects = screen.getAllByLabelText('Provider');
+ expect([...providerSelects[1].options].map((o) => o.value)).toEqual(['', 'codex-tui']);
+ const note = screen.getByText(/Sandboxed stage\. Eligible on this install:/);
+ expect(note.textContent).toContain('Eligible on this install: Codex TUI.');
+ expect(note.textContent).not.toContain('Grok Build CLI');
+ });
+
it('warns instead of silently offering nothing when a stage has no eligible provider', () => {
renderWith([
{ id: 'claude-ollama', name: 'Local Claude', type: 'cli', command: 'claude', endpoint: 'http://127.0.0.1:11434', models: ['safe-model'], publicReviewPostures: ['no-tool'] },
diff --git a/client/src/utils/providers.js b/client/src/utils/providers.js
index 16f64e2bc6..3e3e97e042 100644
--- a/client/src/utils/providers.js
+++ b/client/src/utils/providers.js
@@ -343,6 +343,20 @@ export const filterSelectableModels = (models) =>
export const isProviderHardwareCompatible = (provider) =>
isHardwareCompatible(provider?.hardwareCompatibility);
+/**
+ * The providers a picker may offer: enabled, runnable on this hardware, and
+ * allowed by the caller's policy — plus the currently-selected id whatever its
+ * state, so a saved pin still renders instead of silently blanking. This is
+ * the single rule `ProviderModelSelector` renders from; a caller that lists
+ * "eligible" providers beside such a picker must derive the list from here so
+ * the note and the dropdown cannot disagree.
+ */
+export const selectableProviders = (providers, { selectedId = '', allowed = null } = {}) =>
+ (Array.isArray(providers) ? providers : []).filter((provider) => (
+ provider?.id === selectedId
+ || (provider?.enabled !== false && isProviderHardwareCompatible(provider) && (!allowed || allowed(provider)))
+ ));
+
export const isProviderModelHardwareCompatible = (provider, model) =>
isProviderHardwareCompatible(provider)
&& isHardwareCompatible(provider?.modelHardwareCompatibility?.[model]);
diff --git a/server/lib/providerVendors.js b/server/lib/providerVendors.js
index 708d81edc0..02ab4b4a92 100644
--- a/server/lib/providerVendors.js
+++ b/server/lib/providerVendors.js
@@ -98,8 +98,8 @@ import {
ensureCursorTuiArgs,
ensureCursorHeadlessArgs,
} from './cursor.js';
+import { PROVIDER_TYPES } from './aiToolkit/constants.js';
import {
- isPublicReviewNoToolProfile,
publicReviewPostureForProfile,
PUBLIC_REVIEW_EXECUTION_PROFILE,
PUBLIC_REVIEW_GATE_EXECUTION_PROFILE,
@@ -136,6 +136,15 @@ function defaultSpawnArgs(cliArgsFn, fallbackCommand) {
});
}
+/**
+ * A provider record that names a local binary PortOS can spawn headless. A
+ * public-review stage never runs interactively: a TUI record of the same
+ * vendor (`codex-tui`, `grok-tui`, …) is spawned through the vendor's headless
+ * recipe exactly like its CLI sibling, so the user's enabled TUI providers are
+ * legal stage choices. API/custom providers have no binary and no recipe.
+ */
+const isDirectBinaryProvider = (provider) => provider?.type === PROVIDER_TYPES.CLI || provider?.type === PROVIDER_TYPES.TUI;
+
// ─── codex ──────────────────────────────────────────────────────────────────
function codexCliArgs(baseArgs, { model, effort, provider }) {
@@ -274,11 +283,11 @@ const CODEX = {
// enforced recipe when a stage selects them.
[PUBLIC_REVIEW_NO_TOOL_POSTURE]: {
spawnArgs: codexPublicReviewSpawnArgs,
- matchProvider: (provider) => isCodexCommand(provider?.command) || provider?.id === CODEX_CLI_ID || provider?.id === 'codex-tui',
+ matchProvider: (provider) => isDirectBinaryProvider(provider) && (isCodexCommand(provider?.command) || provider?.id === CODEX_CLI_ID || provider?.id === 'codex-tui'),
},
[PUBLIC_REVIEW_ACTIONS_POSTURE]: {
spawnArgs: codexPublicReviewActionsSpawnArgs,
- matchProvider: (provider) => provider?.type === 'cli' && isCodexCommand(provider?.command),
+ matchProvider: (provider) => isDirectBinaryProvider(provider) && isCodexCommand(provider?.command),
},
},
};
@@ -304,11 +313,11 @@ const ANTIGRAVITY = {
publicReview: {
[PUBLIC_REVIEW_NO_TOOL_POSTURE]: {
spawnArgs: antigravityPublicReviewSpawnArgs,
- matchProvider: (provider) => provider?.type === 'cli' && isAntigravityCommand(provider?.command),
+ matchProvider: (provider) => isDirectBinaryProvider(provider) && isAntigravityCommand(provider?.command),
},
[PUBLIC_REVIEW_ACTIONS_POSTURE]: {
spawnArgs: antigravityPublicReviewActionsSpawnArgs,
- matchProvider: (provider) => provider?.type === 'cli' && isAntigravityCommand(provider?.command),
+ matchProvider: (provider) => isDirectBinaryProvider(provider) && isAntigravityCommand(provider?.command),
},
},
};
@@ -354,11 +363,11 @@ const GROK = {
publicReview: {
[PUBLIC_REVIEW_NO_TOOL_POSTURE]: {
spawnArgs: grokPublicReviewSpawnArgs,
- matchProvider: (provider) => provider?.type === 'cli' && isGrokCommand(provider?.command),
+ matchProvider: (provider) => isDirectBinaryProvider(provider) && isGrokCommand(provider?.command),
},
[PUBLIC_REVIEW_ACTIONS_POSTURE]: {
spawnArgs: grokPublicReviewActionsSpawnArgs,
- matchProvider: (provider) => provider?.type === 'cli' && isGrokCommand(provider?.command),
+ matchProvider: (provider) => isDirectBinaryProvider(provider) && isGrokCommand(provider?.command),
},
},
};
@@ -526,7 +535,7 @@ const CLAUDE = {
// permission modes, so it fails closed for the actions stage.
[PUBLIC_REVIEW_NO_TOOL_POSTURE]: {
spawnArgs: claudePublicReviewArgs,
- matchProvider: (provider) => provider?.type === 'cli' && isClaudeCommand(provider?.command),
+ matchProvider: (provider) => isDirectBinaryProvider(provider) && isClaudeCommand(provider?.command),
},
},
};
@@ -592,21 +601,13 @@ export function inferTuiCommand(id) {
return CLAUDE.inferredCommand;
}
-/** `applyCommandDefaults` (tuiHandshake.js): TUI posture-flag dispatch. */
-export function applyCommandDefaults(command, args, { safetyProfile = null } = {}) {
- if (publicReviewPostureForProfile(safetyProfile) === PUBLIC_REVIEW_ACTIONS_POSTURE) {
- throw new Error('The public-review-actions profile requires a supported direct CLI sandbox');
- }
- const vendor = PROVIDER_VENDORS.find((v) => (
- (isPublicReviewNoToolProfile(safetyProfile) ? v.publicReviewTuiArgs : v.tuiArgs)
- && v.matchCommand(command)
- ));
- if (isPublicReviewNoToolProfile(safetyProfile)) {
- if (!vendor || typeof vendor.publicReviewTuiArgs !== 'function') {
- throw new Error(`Provider command '${command}' has no enforced public-review posture`);
- }
- return vendor.publicReviewTuiArgs(args, { safetyProfile });
- }
+/**
+ * `applyCommandDefaults` (tuiHandshake.js): interactive-session flag dispatch.
+ * Public-review stages never reach this — they always spawn headless through
+ * `buildVendorSpawnConfig`, which is where a posture is enforced.
+ */
+export function applyCommandDefaults(command, args) {
+ const vendor = PROVIDER_VENDORS.find((v) => v.tuiArgs && v.matchCommand(command));
if (!vendor) return args;
return vendor.tuiArgs(args);
}
@@ -660,11 +661,13 @@ export function buildVendorSpawnConfig(provider, ctx) {
* offer a stage's eligible providers, so it must stay derived from the vendor
* rows rather than from a hardcoded list of vendor names.
*
- * Interactive (TUI) sessions and API/custom providers have no maintained
- * recipe: a generic read-only prompt is not enforcement, so they fail closed.
+ * API/custom providers have no maintained recipe: a generic read-only prompt
+ * is not enforcement, so they fail closed. A TUI record IS eligible — the
+ * stage spawns its binary headless through the vendor's enforced recipe, never
+ * as an interactive session (see `isDirectBinaryProvider`).
*/
-export function publicReviewPosturesForProvider(provider, { tui = false } = {}) {
- if (tui || provider?.type !== 'cli') return [];
+export function publicReviewPosturesForProvider(provider) {
+ if (!isDirectBinaryProvider(provider)) return [];
return PUBLIC_REVIEW_POSTURES.filter((posture) => Boolean(publicReviewRecipe(provider, posture)));
}
@@ -678,8 +681,8 @@ export function publicReviewCapableVendorIds(posture) {
}
/** Whether `provider` has a maintained, enforced recipe for one posture. */
-export function supportsPublicReviewPosture(provider, posture, { tui = false } = {}) {
- if (tui || provider?.type !== 'cli') return false;
+export function supportsPublicReviewPosture(provider, posture) {
+ if (!isDirectBinaryProvider(provider)) return false;
return Boolean(publicReviewRecipe(provider, posture));
}
@@ -696,9 +699,9 @@ export function supportsPublicReviewPosture(provider, posture, { tui = false } =
*
* @returns {{ reason: string, category: string }|null}
*/
-export function publicReviewProviderBlock(provider, posture, { tui = false } = {}) {
+export function publicReviewProviderBlock(provider, posture) {
if (!posture) return null;
- if (supportsPublicReviewPosture(provider, posture, { tui })) return null;
+ if (supportsPublicReviewPosture(provider, posture)) return null;
return {
reason: `Provider '${providerLabel(provider)}' has no enforced ${posture} public-content review mode`,
category: posture === PUBLIC_REVIEW_ACTIONS_POSTURE
@@ -708,13 +711,13 @@ export function publicReviewProviderBlock(provider, posture, { tui = false } = {
}
/** Whether a provider can run a tool-free public-content stage. */
-export function supportsPublicReviewProvider(provider, options) {
- return supportsPublicReviewPosture(provider, PUBLIC_REVIEW_NO_TOOL_POSTURE, options);
+export function supportsPublicReviewProvider(provider) {
+ return supportsPublicReviewPosture(provider, PUBLIC_REVIEW_NO_TOOL_POSTURE);
}
/** Whether a provider can run the sandboxed final public-review stage. */
-export function supportsPublicReviewActionsProvider(provider, options) {
- return supportsPublicReviewPosture(provider, PUBLIC_REVIEW_ACTIONS_POSTURE, options);
+export function supportsPublicReviewActionsProvider(provider) {
+ return supportsPublicReviewPosture(provider, PUBLIC_REVIEW_ACTIONS_POSTURE);
}
/**
diff --git a/server/lib/providerVendors.publicReview.test.js b/server/lib/providerVendors.publicReview.test.js
index 3375c2d18e..3aeca9ee92 100644
--- a/server/lib/providerVendors.publicReview.test.js
+++ b/server/lib/providerVendors.publicReview.test.js
@@ -50,7 +50,7 @@ describe('public-review provider postures', () => {
expect(publicReviewProviderBlock(codex, undefined)).toBeNull();
// The transport is irrelevant when nothing is being enforced: a TUI session
// and an api provider run ordinary tasks all day.
- expect(publicReviewProviderBlock({ ...codex, type: 'tui' }, null, { tui: true })).toBeNull();
+ expect(publicReviewProviderBlock({ ...codex, type: 'tui' }, null)).toBeNull();
expect(publicReviewProviderBlock({ ...codex, type: 'api' }, null)).toBeNull();
});
@@ -65,17 +65,37 @@ describe('public-review provider postures', () => {
category: 'public-review-actions-provider-unsupported',
});
- // A TUI session has no enforced argv, whatever its vendor row declares.
- expect(publicReviewProviderBlock({ ...codex, type: 'tui' }, PUBLIC_REVIEW_NO_TOOL_POSTURE, { tui: true })).toEqual({
- reason: "Provider 'codex-cli' has no enforced no-tool public-content review mode",
- category: 'public-review-provider-unsupported',
+ // A TUI record of a recipe-bearing vendor is spawned headless through
+ // that recipe, so it is as eligible as its CLI sibling. An api provider
+ // has no binary to spawn and no recipe.
+ expect(publicReviewProviderBlock({ ...codex, id: 'codex-tui', type: 'tui' }, PUBLIC_REVIEW_NO_TOOL_POSTURE)).toBeNull();
+ expect(publicReviewProviderBlock({ ...codex, id: 'codex-tui', type: 'tui' }, PUBLIC_REVIEW_ACTIONS_POSTURE)).toBeNull();
+ expect(publicReviewProviderBlock({ id: 'grok', type: 'api', command: undefined }, PUBLIC_REVIEW_ACTIONS_POSTURE)).toEqual({
+ reason: "Provider 'grok' has no enforced sandboxed-actions public-content review mode",
+ category: 'public-review-actions-provider-unsupported',
+ });
+ });
+
+ // The user's enabled providers are commonly the TUI records (the CLI
+ // siblings switched off), and a stage runs the same binary headless either
+ // way — so a TUI record carries its vendor's postures.
+ it('derives the same postures for a TUI record of a recipe-bearing vendor', () => {
+ expect(publicReviewPosturesForProvider({ ...codex, id: 'codex-tui', type: 'tui' })).toEqual([PUBLIC_REVIEW_NO_TOOL_POSTURE, PUBLIC_REVIEW_ACTIONS_POSTURE]);
+ expect(publicReviewPosturesForProvider({ ...grok, id: 'grok-tui', type: 'tui' })).toEqual([PUBLIC_REVIEW_NO_TOOL_POSTURE, PUBLIC_REVIEW_ACTIONS_POSTURE]);
+ expect(publicReviewPosturesForProvider({ ...localClaude, id: 'claude-ollama-tui', type: 'tui' })).toEqual([PUBLIC_REVIEW_NO_TOOL_POSTURE]);
+ // The headless recipe, not the TUI argv, is what the stage spawns.
+ const config = buildVendorSpawnConfig({ ...codex, id: 'codex-tui', type: 'tui', args: ['--full-auto'] }, {
+ effectiveModel: 'gpt-5.6',
+ safetyProfile: PUBLIC_REVIEW_ACTIONS_EXECUTION_PROFILE,
});
+ expect(config.args).toEqual(expect.arrayContaining(['exec', '--sandbox', 'workspace-write']));
+ expect(config.args).not.toContain('--full-auto');
});
it('fails closed for transports and vendors with no maintained recipe', () => {
- // A TUI session and an HTTP api provider have no enforced argv at all.
- expect(publicReviewPosturesForProvider({ ...codex, type: 'tui' }, { tui: true })).toEqual([]);
+ // An HTTP api provider has no binary to spawn and no enforced argv.
expect(publicReviewPosturesForProvider({ ...codex, type: 'api' })).toEqual([]);
+ expect(publicReviewPosturesForProvider({ id: 'opencode-tui', type: 'tui', command: 'opencode' })).toEqual([]);
// An unknown command must never inherit claude's always-true fallback row.
expect(publicReviewPosturesForProvider({ id: 'custom', type: 'cli', command: 'custom-agent' })).toEqual([]);
// opencode/kimi/cursor have no maintained no-tool or sandbox recipe yet.
diff --git a/server/routes/providers.js b/server/routes/providers.js
index 408d454b35..b91b97d01c 100644
--- a/server/routes/providers.js
+++ b/server/routes/providers.js
@@ -149,7 +149,7 @@ const presentProvider = (provider, capabilities = captureSystemCapabilities()) =
// `publicReviewPostures` is the value the schedule UI filters on, so a stage
// offers exactly the providers this install can actually enforce. The two
// booleans are derived from it and kept for existing consumers.
- const publicReviewPostures = publicReviewPosturesForProvider(provider, { tui: provider?.type === 'tui' });
+ const publicReviewPostures = publicReviewPosturesForProvider(provider);
return sanitizeProvider({
...decorated,
publicReviewPostures,
diff --git a/server/services/agentLifecycle.js b/server/services/agentLifecycle.js
index c0a33fd070..9820efbd8c 100644
--- a/server/services/agentLifecycle.js
+++ b/server/services/agentLifecycle.js
@@ -417,12 +417,18 @@ async function runAgentSpawn(task) {
return null;
}
const { provider, selectedModel, modelSelection } = resolution;
- const isTui = isTuiProvider(provider);
const executionProfile = task.metadata?.executionProfile;
const publicReviewPosture = publicReviewPostureForProfile(executionProfile);
const publicReviewNoTools = publicReviewPosture === PUBLIC_REVIEW_NO_TOOL_POSTURE;
const publicReviewActions = executionProfile === PUBLIC_REVIEW_ACTIONS_EXECUTION_PROFILE;
const publicReview = Boolean(publicReviewPosture);
+ const isTui = isTuiProvider(provider);
+ // A public-content stage never runs as an interactive session: a TUI
+ // provider record is spawned headless through its vendor's enforced
+ // recipe (the same binary as its CLI sibling) — the recipe that makes it
+ // eligible in `providerVendors.js` — so the user's enabled TUI providers
+ // are legal stage choices without opening a PTY.
+ const spawnHeadless = publicReview || !isTui;
if (publicReview) {
const scanBlock = publicReviewScanBlock(task);
if (scanBlock) {
@@ -465,7 +471,7 @@ async function runAgentSpawn(task) {
// payload can be edited without the browser: the picker is a convenience,
// never the enforcement. The helper owns the "no posture requested" case,
// so an ordinary task (posture `null`) passes straight through (#5830).
- const postureBlock = publicReviewProviderBlock(provider, publicReviewPosture, { tui: isTui });
+ const postureBlock = publicReviewProviderBlock(provider, publicReviewPosture);
if (postureBlock) {
const { reason, category } = postureBlock;
await updateTask(task.id, {
@@ -649,7 +655,7 @@ async function runAgentSpawn(task) {
workspacePath,
appName: resolvedAppName
});
- const executionMode = isTui ? (dispatchUseRunner ? 'runner-tui' : 'tui') : dispatchUseRunner ? 'runner' : 'direct';
+ const executionMode = !spawnHeadless ? (dispatchUseRunner ? 'runner-tui' : 'tui') : dispatchUseRunner ? 'runner' : 'direct';
// Register the agent with model info.
//
@@ -896,8 +902,8 @@ async function runAgentSpawn(task) {
// their deliberately bounded GPU concurrency posture.
const maxConcurrentThreads = cloudSwarmThreadCapacity(runProvider, task.metadata?.swarmCount);
const safetyProfile = publicReview ? executionProfile : null;
- const cliConfig = isTui
- ? buildTuiSpawnConfig(runProvider, selectedModel, { systemPromptFile, effort: taskEffort, maxConcurrentThreads, safetyProfile })
+ const cliConfig = !spawnHeadless
+ ? buildTuiSpawnConfig(runProvider, selectedModel, { systemPromptFile, effort: taskEffort, maxConcurrentThreads })
: buildCliSpawnConfig(runProvider, selectedModel, cliSettingsEnv, { systemPromptFile, effort: taskEffort, maxConcurrentThreads, safetyProfile });
emitLog('success', `Spawning agent for task ${task.id}`, {
@@ -920,7 +926,7 @@ async function runAgentSpawn(task) {
// must NOT run here on the success path; the lane is released by the
// agent-completion handler when the work finishes.
handedOff = true;
- if (isTui) {
+ if (!spawnHeadless) {
return await spawnTuiAgent({
agentId,
task,
diff --git a/server/services/agentLifecycle.postureGate.test.js b/server/services/agentLifecycle.postureGate.test.js
index 8d6eb04cd5..cc0b641ffb 100644
--- a/server/services/agentLifecycle.postureGate.test.js
+++ b/server/services/agentLifecycle.postureGate.test.js
@@ -113,9 +113,10 @@ import { updateTask } from './cos.js';
import { spawningTasks, runnerAgents } from './agentState.js';
// The provider every install actually runs its CoS agents on, and the one named
-// in the #5866 outage: a TUI session has no maintained public-review recipe, so
-// it is exactly the provider the broken gate rejected for ordinary work.
+// in the #5866 outage: the broken gate rejected it for ordinary work.
const CLAUDE_TUI = { id: 'claude-code-tui', type: 'tui', command: 'claude', envVars: {} };
+// A TUI record whose vendor declares no public-review recipe at all.
+const OPENCODE_TUI = { id: 'opencode-tui', type: 'tui', command: 'opencode', envVars: {} };
/** Every `updateTask` call that wrote a public-review posture block. */
const postureBlockWrites = () => vi.mocked(updateTask).mock.calls.filter(
@@ -152,6 +153,9 @@ describe('public-review posture gate — spawn behavior (#5866)', () => {
// fails closed on a provider with no maintained recipe. A fix for the above
// that simply deleted the gate would pass every test but this one.
it('still blocks a public-review stage whose provider has no enforced posture', async () => {
+ vi.mocked(resolveAgentProviderAndModel).mockResolvedValue({
+ ok: true, provider: OPENCODE_TUI, selectedModel: 'qwen', modelSelection: {},
+ });
await spawnAgentForTask({
id: 'task-public-review',
metadata: {
@@ -166,8 +170,27 @@ describe('public-review posture gate — spawn behavior (#5866)', () => {
expect(call).toBeDefined();
const [, update] = call;
expect(update.status).toBe('blocked');
- expect(update.metadata.blockedReason).toContain("Provider 'claude-code-tui'");
+ expect(update.metadata.blockedReason).toContain("Provider 'opencode-tui'");
expect(update.metadata.blockedReason).toContain('no-tool');
expect(update.metadata.blockedCategory).toBe('public-review-provider-unsupported');
});
+
+ // The user's enabled providers are typically the TUI records. A public-content
+ // stage runs the same binary headless through the vendor's enforced recipe,
+ // so a TUI record of a recipe-bearing vendor passes the gate and must never
+ // be handed to the interactive PTY spawner.
+ it('spawns a public-review stage on a TUI provider headless, never as a PTY session', async () => {
+ const { buildTuiSpawnConfig, spawnTuiAgent } = await import('./agentTuiSpawning.js');
+ await spawnAgentForTask({
+ id: 'task-public-review-tui',
+ metadata: {
+ executionProfile: 'public-review-gate',
+ pipeline: { securityScan: { completed: true, status: 'passed', safePrCount: 1 } },
+ },
+ });
+
+ expect(postureBlockWrites()).toEqual([]);
+ expect(buildTuiSpawnConfig).not.toHaveBeenCalled();
+ expect(spawnTuiAgent).not.toHaveBeenCalled();
+ });
});
diff --git a/server/services/agentLifecycle.test.js b/server/services/agentLifecycle.test.js
index 3cfd802331..e0899cbe61 100644
--- a/server/services/agentLifecycle.test.js
+++ b/server/services/agentLifecycle.test.js
@@ -328,7 +328,7 @@ describe('agentLifecycle — guard wiring', () => {
// requested no posture. Pin the call so the caller cannot re-derive it from a
// boolean support check and reintroduce the same collapse.
it('asks the posture helper for the provider gate rather than re-deriving it', () => {
- expect(AGENT_LIFECYCLE_SRC).toContain('const postureBlock = publicReviewProviderBlock(provider, publicReviewPosture, { tui: isTui })');
+ expect(AGENT_LIFECYCLE_SRC).toContain('const postureBlock = publicReviewProviderBlock(provider, publicReviewPosture)');
expect(AGENT_LIFECYCLE_SRC).toMatch(/if \(postureBlock\) \{[\s\S]*?status: 'blocked'/);
// The helper owns the blocked category too, so the gate cannot pick its own.
expect(AGENT_LIFECYCLE_SRC).toContain('const { reason, category } = postureBlock;');
@@ -566,7 +566,7 @@ describe('runAgentSpawn source — handedOff pre-spawn vs post-handoff split', (
describe('runAgentSpawn source — durable TUI ownership (#3202)', () => {
it('routes TUI providers through the runner when it is available', () => {
expect(RUN_SPAWN_BODY).toMatch(
- /const executionMode = isTui \? \(dispatchUseRunner \? 'runner-tui' : 'tui'\)/
+ /const executionMode = !spawnHeadless \? \(dispatchUseRunner \? 'runner-tui' : 'tui'\)/
);
expect(RUN_SPAWN_BODY).toMatch(/spawnTuiAgent\(\{[\s\S]{0,1000}?useDurableRunner:\s*dispatchUseRunner/);
expect(RUN_SPAWN_BODY).not.toMatch(/useRunner:\s*isTui\s*\?\s*false\s*:\s*useRunner/);
diff --git a/server/services/agentTuiSpawning.js b/server/services/agentTuiSpawning.js
index 90d6d955fa..69736c19e5 100644
--- a/server/services/agentTuiSpawning.js
+++ b/server/services/agentTuiSpawning.js
@@ -66,7 +66,6 @@ import {
SUBMIT_KEY,
} from '../lib/tuiHandshake.js';
import { injectTuiModelAndEffort } from '../lib/providerVendors.js';
-import { isPublicReviewNoToolProfile } from '../lib/agentExecutionProfiles.js';
import { agentGuardEnv } from '../lib/agentGuard/index.js';
import { composeProviderEnv } from '../lib/cliChildEnv.js';
import { cliProviderAuthDescriptor } from '../lib/processEnv.js';
@@ -195,15 +194,10 @@ export function buildTuiSpawnConfig(provider, model, {
systemPromptFile = null,
effort = null,
maxConcurrentThreads = null,
- safetyProfile = null,
shell = resolveInteractiveShell(),
} = {}) {
const command = provider?.command || inferTuiCommand(provider?.id);
- const baseArgs = applyCommandDefaults(
- command,
- isPublicReviewNoToolProfile(safetyProfile) ? [] : [...(provider?.args || [])],
- { safetyProfile },
- );
+ const baseArgs = applyCommandDefaults(command, [...(provider?.args || [])]);
// Model+effort injection (including the antigravity-validates-the-pair special
// case) is shared with tuiHandshake.js#buildTuiInvocation via
// providerVendors.js#injectTuiModelAndEffort, so the two spawn paths can't
diff --git a/server/services/publicReviewProviderSelection.js b/server/services/publicReviewProviderSelection.js
index 5b58d618fd..446454506c 100644
--- a/server/services/publicReviewProviderSelection.js
+++ b/server/services/publicReviewProviderSelection.js
@@ -48,7 +48,7 @@ export async function eligiblePublicReviewProviders(posture, { providers = null
const list = providers || (await getAllProviders()).providers || [];
return list.filter((provider) => (
isEnabled(provider)
- && supportsPublicReviewPosture(provider, posture, { tui: provider?.type === 'tui' })
+ && supportsPublicReviewPosture(provider, posture)
));
}