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: require enforced CLI isolation for claim reviews (#8286)

[._.]/ Adam Eivydf18beb669b2
diff --git a/server/scripts/run-local-code-review.test.js b/server/scripts/run-local-code-review.test.js
index 8d0d9054fc..e890663569 100644
--- a/server/scripts/run-local-code-review.test.js
+++ b/server/scripts/run-local-code-review.test.js
@@ -76,15 +76,15 @@ it('runs a saved provider reviewer from the standalone claim bridge without boot
await rm(root, { recursive: true, force: true });
});
expect(results).toHaveLength(5);
- // A generic harness has no enforced reviewer mode: it still reviews code,
- // ordinary or claim, confined to a scratch cwd (the harness fails if it can
- // see the caller's checkout), but public-comment screening refuses it.
- for (const result of [results[2], results[3]]) {
- expect(result.code, result.stderr).toBe(0);
- expect(JSON.parse(result.stdout)).toMatchObject({ ok: true, backend: 'provider:example-cli', findings: 'NO FINDINGS' });
+ // A generic harness can review ordinary code from scratch, but claim
+ // review and public-comment screening require an enforced reviewer mode.
+ expect(results[2].code, results[2].stderr).toBe(0);
+ expect(JSON.parse(results[2].stdout)).toMatchObject({ ok: true, backend: 'provider:example-cli', findings: 'NO FINDINGS' });
+ for (const result of [results[3], results[4]]) {
+ expect(result.code).not.toBe(0);
+ expect(result.stderr).toMatch(/REVIEWER_UNSUPPORTED/);
+ expect(JSON.parse(result.stdout)).toMatchObject({ ok: false, code: 'REVIEWER_UNSUPPORTED' });
}
- expect(results[4].code).not.toBe(0);
- expect(results[4].stderr).toMatch(/REVIEWER_UNSUPPORTED/);
for (const [index, model] of ['review-model', 'default-model'].entries()) {
const result = results[index];
expect(result.code, result.stderr).toBe(0);
diff --git a/server/services/codeReview.js b/server/services/codeReview.js
index 56a0805605..fa11cf4f32 100644
--- a/server/services/codeReview.js
+++ b/server/services/codeReview.js
@@ -668,11 +668,10 @@ async function resolveServedModel(backend, baseUrl) {
* no-tool environment allowlist (no forge or cloud
* credentials), so nothing it writes reaches a checkout.
*
- * `allowUnconfined` admits that last tier. A code review sets it: the diff is
- * the operator's own branch, or a claim branch the operator's own agent just
- * wrote with full permissions from the same issue text, so a confined reviewer
- * widens nothing. Claim-comment screening leaves it off — raw public comments
- * reach no agent that could act on them.
+ * `allowUnconfined` admits that last tier for ordinary code reviews. Claim
+ * reviews and public-comment screening leave it off: their supplied diff or
+ * comments may contain untrusted contributor instructions, so the reviewer
+ * must have a vendor-enforced no-tool or read-only mode.
*/
export async function resolveProviderReviewTransport(provider, { allowUnconfined = false } = {}) {
if (!provider || provider.enabled === false) {
@@ -687,7 +686,7 @@ export async function resolveProviderReviewTransport(provider, { allowUnconfined
return {
transport: null,
code: 'REVIEWER_UNSUPPORTED',
- error: 'This provider has no enforced no-tool or read-only mode, so it cannot screen public comments. Use its API mode or a local model for that gate.',
+ error: 'This provider has no enforced no-tool or read-only mode for this review. Use its API mode or a local model.',
}
}
@@ -883,10 +882,12 @@ async function runReviewerCompletion({ backend, model: pinnedModel, messages, ef
* reviewer's working directory when its vendor enforces a no-tool or
* read-only review mode (#6338), neither of which can write to it. A CLI with
* no such mode never receives it: it runs in a scratch directory instead.
- * @param {boolean} [opts.toolFree] - Claim review: every CLI reviewer runs in a
- * scratch cwd instead of `opts.cwd`, whatever its mode.
+ * @param {boolean} [opts.toolFree] - Run a CLI reviewer in a scratch cwd instead
+ * of `opts.cwd`, whatever its mode.
+ * @param {string} [opts.kind] - `claim-review` additionally requires a
+ * vendor-enforced no-tool or read-only transport before launching any CLI.
*/
-export async function runLocalCodeReview({ backend, model, diff, effort = null, timeoutMs = undefined, baseUrl = null, cwd = null, toolFree = false } = {}) {
+export async function runLocalCodeReview({ backend, model, diff, effort = null, timeoutMs = undefined, baseUrl = null, cwd = null, toolFree = false, kind = null } = {}) {
if (!isToolFreeReviewer(backend)) {
return { ok: false, error: `Unsupported reviewer backend: ${backend}` }
}
@@ -916,8 +917,8 @@ export async function runLocalCodeReview({ backend, model, diff, effort = null,
diffSizeBytes,
baseUrl,
cwd,
- toolFree,
- allowUnconfined: true,
+ toolFree: kind === 'claim-review' || toolFree,
+ allowUnconfined: kind !== 'claim-review',
messages: [
{ role: 'system', content: CODE_REVIEW_SYSTEM_PROMPT },
{ role: 'user', content: `Review this PR diff:\n\n${fence}diff\n${trimmedDiff}\n${fence}` },
diff --git a/server/services/codeReview.providers.test.js b/server/services/codeReview.providers.test.js
index a2b3d6ef80..3d3c2dd944 100644
--- a/server/services/codeReview.providers.test.js
+++ b/server/services/codeReview.providers.test.js
@@ -174,22 +174,21 @@ describe('configured provider reviewers', () => {
expect(runCliProviderPrompt).not.toHaveBeenCalled();
});
- // Antigravity (like any harness with no enforced reviewer mode) reviews code,
- // ordinary or claim, but never from the caller's checkout: its ordinary argv
- // may carry a blanket-permission flag, so it runs in a scratch directory with
- // the diff inlined and the no-tool environment allowlist.
- it('runs a harness with no enforced reviewer mode confined to a scratch directory', async () => {
+ // Ordinary code review preserves the scratch-only fallback for a harness
+ // without an enforced mode. Claim review must refuse it before process launch.
+ it('runs an ordinary review in scratch but refuses an unconfined claim review', async () => {
for (const command of ['agy', 'custom-agent']) {
getProviderById.mockResolvedValue({ ...provider, type: 'cli', command });
runCliProviderPrompt.mockResolvedValue({ text: 'NO FINDINGS', partial: false });
const claimRequest = localReviewBridgeRequest({ kind: 'claim-review', backend, diff: 'example diff' }, process.cwd());
- for (const request of [{ backend, model: 'pinned-coder', diff: 'example diff', cwd: process.cwd() }, claimRequest]) {
- expect(await runLocalCodeReview(request)).toMatchObject({ ok: true });
- const args = runCliProviderPrompt.mock.lastCall[0];
- expect(args).toMatchObject({ safetyProfile: 'public-review-gate', codeReview: true });
- expect(args.cwd).not.toBe(process.cwd());
- await expect(access(args.cwd)).rejects.toThrow();
- }
+ expect(await runLocalCodeReview({ backend, model: 'pinned-coder', diff: 'example diff', cwd: process.cwd() })).toMatchObject({ ok: true });
+ const args = runCliProviderPrompt.mock.lastCall[0];
+ expect(args).toMatchObject({ safetyProfile: 'public-review-gate', codeReview: true });
+ expect(args.cwd).not.toBe(process.cwd());
+ await expect(access(args.cwd)).rejects.toThrow();
+ runCliProviderPrompt.mockClear();
+ expect(await runLocalCodeReview(claimRequest)).toMatchObject({ ok: false, code: 'REVIEWER_UNSUPPORTED' });
+ expect(runCliProviderPrompt).not.toHaveBeenCalled();
}
});
diff --git a/server/services/cosTaskGenerator.test.js b/server/services/cosTaskGenerator.test.js
index e7ca32613b..4cceae4a94 100644
--- a/server/services/cosTaskGenerator.test.js
+++ b/server/services/cosTaskGenerator.test.js
@@ -2028,7 +2028,8 @@ describe('buildClaimWorkTask reviewer pin', () => {
const { prompt } = await buildClaimWorkTask(app, { reviewers: ['provider:example-reviewer'] });
expect(prompt).toContain('kind: "claim-review"');
expect(prompt).toContain('toolFree: true');
- expect(prompt).toContain('Provider CLIs run in an isolated scratch directory with the diff inlined');
+ expect(prompt).toContain('Provider CLIs run in an isolated scratch directory with the diff inlined, under an enforced no-tool or read-only vendor profile');
+ expect(prompt).toContain('a CLI without one is unavailable before launch');
expect(prompt).toContain('For a required local reviewer, record `REVIEW_STATUS=review-blocked`');
expect(prompt).toContain('an optional inconclusive result remains non-blocking');
});
diff --git a/server/services/cosTaskPrompts.js b/server/services/cosTaskPrompts.js
index 08329f6084..c42af5557b 100644
--- a/server/services/cosTaskPrompts.js
+++ b/server/services/cosTaskPrompts.js
@@ -183,7 +183,7 @@ fi
}).join('\n\n');
const accessPolicy = enforceIsolation
- ? 'Claim reviews send only the supplied diff. Provider CLIs run in an isolated scratch directory with the diff inlined, under an enforced no-tool or read-only vendor profile when one exists and without forge or cloud credentials. API and local-model providers receive the diff without tools.'
+ ? 'Claim reviews send only the supplied diff. Provider CLIs run in an isolated scratch directory with the diff inlined, under an enforced no-tool or read-only vendor profile and without forge or cloud credentials; a CLI without one is unavailable before launch. API and local-model providers receive the diff without tools.'
: 'CLI providers can inspect the checkout; API providers review the supplied diff.';
return `${claimCommentGateBlock}\n\n## Local Reviewer Procedure\n\nConfigured provider and local-model reviews run before standalone CLI reviewers. ${accessPolicy} Run each configured local reviewer in its listed order using the command below. Only a successfully extracted non-empty \`.findings\` string is a review result. Timeout, transport failure, malformed JSON, an error response, or missing/empty findings is INCONCLUSIVE: do not substitute a self-review. For a required local reviewer, record \`REVIEW_STATUS=review-blocked\`, continue to publish the MR/PR, then leave it open and do not merge until the required review completes; an optional inconclusive result remains non-blocking. If every configured reviewer returns a configuration fault and none produces a verdict, report this distinct run-summary state: ${ZERO_REVIEWER_COVERAGE_NOTE} This remains non-blocking when every reviewer is marked \`~opt\`; do not use that wording when any reviewer produces a verdict. Substantive findings, failed tests/build, unpushed fixes, or publication failures still block.\n\n${commands}${cliOutcomeInstructions}`;
}