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: enforce read-only reviewer posture on every code-review path (#6338)

[._.]/ Adam Eivy493aff17148b
diff --git a/server/services/codeReview.js b/server/services/codeReview.js
index b6d72fca30..7e37d4f6d4 100644
--- a/server/services/codeReview.js
+++ b/server/services/codeReview.js
@@ -610,10 +610,18 @@ async function resolveServedModel(backend, baseUrl) {
return { model: probe.models[0], reason: null }
}
-/** Resolve the selected provider without conflating code review with public-content screening.
- * Explicit tool-free stages still require a maintained enforcement recipe.
+/**
+ * Resolve the selected provider's review transport. A reviewer is always a
+ * feedback agent, never a writer (#6338): a CLI transport is only granted when
+ * the vendor has a maintained no-tool (read-only) public-review recipe —
+ * `supportsPublicReviewProvider()` — regardless of whether this request came
+ * from the tool-free public-content path or an ordinary trusted-repo review.
+ * A harness with no such recipe (e.g. Antigravity, whose only maintained
+ * posture may apply edits) is refused here rather than falling back to that
+ * vendor's normal unrestricted argv, which for several CLIs is a blanket
+ * `--dangerously-skip-permissions`-class flag.
*/
-export async function resolveProviderReviewTransport(provider, { toolFree = false } = {}) {
+export async function resolveProviderReviewTransport(provider) {
if (!provider || provider.enabled === false) {
return { transport: null, code: 'REVIEWER_UNAVAILABLE', error: 'Reviewer provider is missing or disabled.' }
}
@@ -621,11 +629,11 @@ export async function resolveProviderReviewTransport(provider, { toolFree = fals
if (provider.type === 'api' || isCodexTextTransportEnabled(provider)) return { transport: 'api' }
if (!provider.command) return { transport: null, code: 'REVIEWER_UNSUPPORTED', error: 'Reviewer provider has no command configured.' }
const { supportsPublicReviewProvider } = await import('../lib/providerVendors.js')
- if (toolFree && !supportsPublicReviewProvider(provider)) {
+ if (!supportsPublicReviewProvider(provider)) {
return {
transport: null,
code: 'REVIEWER_UNSUPPORTED',
- error: 'This provider has no enforced tool-free review transport. Select its API mode or a supported reviewer harness.',
+ error: 'This provider has no enforced read-only review transport. Select its API mode or a supported reviewer harness.',
}
}
return { transport: 'cli' }
@@ -645,7 +653,7 @@ async function runConfiguredProviderCompletion({ backend, model: pinnedModel, me
const { PATHS } = await import('../lib/paths.js')
return createProviderService({ dataDir: PATHS.data }).getProviderById(providerId)
})
- const transport = await resolveProviderReviewTransport(provider, { toolFree })
+ const transport = await resolveProviderReviewTransport(provider)
// A missing/disabled record is refused here, but an unsupported HARNESS is
// refused at the branch below instead — a pinned effort the provider's model
// cannot do is the more specific complaint, and it was already the answer this
@@ -670,9 +678,16 @@ async function runConfiguredProviderCompletion({ backend, model: pinnedModel, me
const { mkdtemp, rm } = await import('node:fs/promises')
const { tmpdir } = await import('node:os')
const { join } = await import('node:path')
- // Public comment screening stays isolated. Code review may inspect the
- // caller's checkout using the selected harness's normal capabilities.
- const safetyProfile = toolFree ? PUBLIC_REVIEW_GATE_EXECUTION_PROFILE : null
+ // A reviewer is a feedback agent, never a writer (#6338): every CLI review
+ // run — tool-free public-content screening AND an ordinary trusted-repo
+ // review — enforces the maintained no-tool posture, so it can never carry a
+ // vendor's normal unrestricted argv (for several CLIs, a blanket
+ // `--dangerously-skip-permissions`-class flag). `resolveProviderReviewTransport`
+ // already refused a harness with no such recipe before this point.
+ // `toolFree` still controls cwd isolation: public content stays off the
+ // caller's real checkout, while an ordinary review may still inspect it —
+ // read-only, since the posture forbids writes regardless.
+ const safetyProfile = PUBLIC_REVIEW_GATE_EXECUTION_PROFILE
const isolatedCwd = toolFree || !reviewCwd ? await mkdtemp(join(tmpdir(), 'portos-review-')) : null
const cwd = isolatedCwd || reviewCwd
result = await Promise.resolve().then(async () => {
@@ -815,6 +830,16 @@ async function runReviewerCompletion({ backend, model: pinnedModel, messages, ef
* the documented 5 min ceiling.
* @param {string} [opts.baseUrl] - Validated local OpenAI-compatible base URL;
* defaults to the backend manager's current URL.
+ * @param {string} [opts.cwd] - Caller's checkout, passed through to a CLI
+ * reviewer's working directory. A CLI-backed review always runs under the
+ * maintained no-tool posture (#6338) regardless of `toolFree` — it can never
+ * write to this checkout, since the CLI advertises no tools at all — so
+ * passing it is safe even for an untrusted diff.
+ * @param {boolean} [opts.toolFree] - Isolates the CLI reviewer into a scratch
+ * cwd instead of `opts.cwd`, for untrusted public-content screening where the
+ * real checkout should not even be the process's working directory. Does NOT
+ * relax the no-tool posture in the other direction: `false` still runs
+ * tool-free, just with `opts.cwd` as the working directory.
*/
export async function runLocalCodeReview({ backend, model, diff, effort = null, timeoutMs = undefined, baseUrl = null, cwd = null, toolFree = false } = {}) {
if (!isToolFreeReviewer(backend)) {
diff --git a/server/services/codeReview.providers.test.js b/server/services/codeReview.providers.test.js
index 77ae20aa26..a54bb99db3 100644
--- a/server/services/codeReview.providers.test.js
+++ b/server/services/codeReview.providers.test.js
@@ -110,7 +110,7 @@ describe('configured provider reviewers', () => {
const result = await runLocalCodeReview({ backend, model: task.reviewerModels[backend], effort: task.reviewerEfforts[backend], diff: 'example diff' });
expect(result).toMatchObject({ ok: true, findings: 'NO FINDINGS', effort: 'high' });
const args = runCliProviderPrompt.mock.calls[0][0];
- expect(args).toMatchObject({ provider: { ...cli, effort: 'high' }, model: 'pinned-coder', safetyProfile: null });
+ expect(args).toMatchObject({ provider: { ...cli, effort: 'high' }, model: 'pinned-coder', safetyProfile: 'public-review-gate' });
await expect(access(args.cwd)).rejects.toThrow();
expect(callProviderAISimple).not.toHaveBeenCalled();
@@ -146,7 +146,7 @@ describe('configured provider reviewers', () => {
expect(runCliProviderPrompt).toHaveBeenCalledWith(expect.objectContaining({
provider: expect.objectContaining({ credentialBootstrap: cli.credentialBootstrap }),
bootstrapEnv: {},
- safetyProfile: null,
+ safetyProfile: 'public-review-gate',
}));
cli.credentialBootstrap.envCommand = [process.execPath, '-e', 'console.log("ANTHROPIC_AUTH_TOKEN=example-minted-token")'];
@@ -154,7 +154,7 @@ describe('configured provider reviewers', () => {
expect(await runLocalCodeReview({ backend, diff: 'example diff' })).toMatchObject({ ok: true, findings: 'NO FINDINGS' });
expect(runCliProviderPrompt).toHaveBeenCalledWith(expect.objectContaining({
bootstrapEnv: { ANTHROPIC_AUTH_TOKEN: 'example-minted-token' },
- safetyProfile: null,
+ safetyProfile: 'public-review-gate',
}));
// A credential command that FAILS is still a failed review, not a silent
@@ -174,14 +174,18 @@ describe('configured provider reviewers', () => {
expect(runCliProviderPrompt).not.toHaveBeenCalled();
});
- it('runs Antigravity and custom harnesses in the requested checkout without demanding tool-free support', async () => {
+ // #6338: a reviewer is a feedback agent, never a writer. Antigravity's only
+ // maintained public-review posture may apply edits (`accept-edits`), so it
+ // has no enforced no-tool recipe — every CLI review, tool-free or ordinary,
+ // must refuse it (and any other unrecognized harness) rather than fall back
+ // to that vendor's normal unrestricted argv, which for several CLIs is a
+ // blanket `--dangerously-skip-permissions`-class flag.
+ it('refuses Antigravity and custom harnesses that have no enforced no-tool review posture, in an ordinary review too', async () => {
for (const command of ['agy', 'custom-agent']) {
getProviderById.mockResolvedValue({ ...provider, type: 'cli', command });
runCliProviderPrompt.mockResolvedValue({ text: 'NO FINDINGS', partial: false });
- expect(await runLocalCodeReview({ backend, model: 'pinned-coder', diff: 'example diff', cwd: process.cwd() })).toMatchObject({ ok: true, findings: 'NO FINDINGS' });
- expect(runCliProviderPrompt.mock.lastCall[0]).toMatchObject({ cwd: process.cwd(), model: 'pinned-coder', safetyProfile: null });
- expect(runCliProviderPrompt.mock.lastCall[0].prompt).toContain('inspect surrounding source');
- await expect(access(process.cwd())).resolves.toBeUndefined();
+ expect(await runLocalCodeReview({ backend, model: 'pinned-coder', diff: 'example diff', cwd: process.cwd() })).toMatchObject({ ok: false, code: 'REVIEWER_UNSUPPORTED' });
+ expect(runCliProviderPrompt).not.toHaveBeenCalled();
}
});
@@ -218,7 +222,11 @@ describe('configured provider reviewers', () => {
});
describe('getProviderReviewUnsupported', () => {
- it('names missing CLI commands without rejecting unfamiliar harnesses', async () => {
+ // #6338: every CLI reviewer now needs a maintained no-tool posture, so a
+ // harness this install doesn't recognize (no `supportsPublicReviewProvider`
+ // recipe) is reported unsupported too — it would otherwise fall back to
+ // that vendor's unrestricted argv.
+ it('names missing CLI commands and unfamiliar harnesses with no enforced no-tool posture', async () => {
listProviders.mockResolvedValue([
provider,
{ ...provider, id: 'hosted-harness', type: 'cli', command: 'custom-agent' },
@@ -228,7 +236,10 @@ describe('configured provider reviewers', () => {
const unsupported = await getProviderReviewUnsupported();
// The capable provider is ABSENT rather than false, so "nobody fetched
// this map" and "nothing is wrong here" read the same to a picker.
- expect(unsupported).toEqual({ 'provider:no-command': 'REVIEWER_UNSUPPORTED' });
+ expect(unsupported).toEqual({
+ 'provider:no-command': 'REVIEWER_UNSUPPORTED',
+ 'provider:hosted-harness': 'REVIEWER_UNSUPPORTED',
+ });
expect(unsupported['provider:example-gpu']).toBeUndefined();
// A disabled provider is already badged `disabled` by the picker's own
// provider-record check; reporting it here would badge one fact twice.