Skip to content

Add repository OpenCode permission defaults - #25326

Merged
nwparker merged 5 commits into
mainfrom
orca/repository-opencode-permissions-14433
Oct 5, 2026
Merged

nwparker merged 5 commits into
mainfrom
orca/repository-opencode-permissions-14433

Conversation

@nwparker

@nwparker nwparker commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​11 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​11
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​19 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​16

ELI5

OpenCode can discover Orca’s repository permission defaults while still asking before reading environment secrets, accessing external directories, or continuing a repeated tool loop.

What Changed

Adapts @Jinwoo-H’s repository-config contribution from #14433. The default allows actions, followed by explicit confirmation rules for .env, .env.*, external directories and repeated tool loops. .env.example stays allowed. OpenCode uses the last matching rule, so these exceptions follow the default.

Extends the existing root-directory guard to allow opencode.json alongside the reviewed cloud entry. Other new root entries remain blocked.

Why

OpenCode’s project config discovery applies the same rules to the main checkout and git worktrees without adding launch-time overrides. The explicit exceptions preserve confirmation for sensitive actions that a blanket default would override.

Linked Issue

Replaces #14433. Original contribution by @Jinwoo-H: #14433. This adaptation narrows its original allow-everything policy.

Visual Proof

N/A — repository configuration and a CI guard; no rendered UI change.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Installed OpenCode 2.0.16 on macOS discovered the exact adapted config and registered all six ordered project rules in the Build agent in a fresh isolated project. The first snapshot contained only default rules; the second registered the project suffix. Both CLI children and the controller exited normally, and the private endpoint refused connections afterward. This verifies configuration and registered-agent discovery, not an executed tool permission decision.

The earlier three isolated controls verified project-config discovery without a root config, with the original config, and in a linked git worktree. The guard regression failed before the change (11 passed, 1 failed), then all 12 passed. Existing cloud, unrelated-root refusal, raw Git pathname and annotation-fencing cases passed. Owned lint, formatting, official anti-slop rules, changed-code quality, syntax, root guard and diff checks passed. The JSON-only adaptation passed formatting and diff checks; no TypeScript behavior changed, so desktop typechecks/builds were not repeated.

Review

Three files. The config follows the installed OpenCode schema and last-match precedence. External-directory confirmation also takes precedence over built-in internal-directory allow rules. The doom_loop rule also retains legacy compatibility; the installed 2.0.16 check verifies its discovery. Session-specific or saved permission rules are outside this discovery check. The existing cloud exception remains unchanged; there are no platform-specific runtime or remote wire changes.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 93b83e69-0458-4375-8e1d-b04577c23d7b
📥 Commits

Reviewing files that changed from the base of the PR and between 43fa8fa and 45f01f9.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 99e13f83-66d8-4c80-9d6f-7a32a8758d09
📥 Commits

Reviewing files that changed from the base of the PR and between 955dce5 and 43fa8fa.

📒 Files selected for processing (3)
  • .github/scripts/check-root-directory-entries.mjs
  • config/scripts/check-root-directory-entries.test.mjs
  • opencode.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The change adds an opencode.json permission configuration. The root-entry guard now exempts this file, and a test verifies that the guard accepts it.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 43fa8

The configuration preserves the intended approval prompts and is admitted by the root-entry guard. No actionable merge-blocking risk is established.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 43fa8

The policy allows unmatched actions while requesting approval for specified environment-file reads, external-directory access, and repeated calls. No newly exploitable path is established, but the effective permissions depend on the installed runtime and existing user and agent settings.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The relevant exposure is tool activity in OpenCode sessions consuming this project policy. Accessible files, services, and credentials depend on the launching process and enabled tools; the supplied evidence does not establish tenant-wide, production, or cloud-administrator access.

Trust Boundaries and Controls

  • observed — Permission choices become repository-distributed configuration. The named approval rules are visible controls, but neither the file nor the admission test establishes whether they govern file access performed inside shell commands or override existing user and agent restrictions.
  • observed — The reported no-config Build wildcard is counterevidence against attributing Build's broad authority to this PR. It does not resolve effective permissions for other agents, user configurations, or runtime versions.

Hardening Proposals

  • proposed — Validate effective approval decisions on supported OpenCode versions, including interaction with restrictive user and agent settings and shell-mediated sensitive-file access. Treat the named read prompts as tool-specific controls unless broader enforcement is demonstrated.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: adding repository OpenCode permission defaults.
Description check ✅ Passed The description covers the change, rationale, testing, visual-proof status, and review notes. The linked item is a related pull request, not clearly an issue, and the full lint, typecheck, test, and b…
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The committed config is equivalent to "permission": "allow". Because OpenCode merges the project ruleset after its built-in defaults and evaluates last-match-wins, it also lifts the default ask on reading *.env files, on external_directory access, and on doom_loop — silently, for anyone whose OpenCode working directory is an Orca checkout. Please confirm that is intended; if the goal is only to drop routine prompts, a narrower key preserves those guards.

Reviewed changes

  • Repository OpenCode config — new root opencode.json sets permission to {"*":{"*":"allow"}} ($schema present, schema-valid).
  • Root-entry guard — REVIEWED_ROOT_ENTRIES now accepts opencode.json alongside cloud, so the CI landing-page bloat guard tolerates the new root file.
  • Guard regression test — a case asserting the guard returns 0 for a root opencode.json (would fail against the old guard, so it is real coverage).

The guard and test changes are sound. The one substantive point is the effective scope of the wildcard, called out inline.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

Comment thread opencode.json Resolved

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Narrowed the OpenCode permission catch-all — the repository opencode.json now keeps the {"*":{"*":"allow"}} default but re-states explicit ask rules for reading *.env/*.env.*, for external_directory access, and for doom_loop, with *.env.example left allowed. This restores the confirmation prompts the wildcard had shadowed, which was the sole finding in the prior review.

The exceptions are ordered after the catch-all within the same project ruleset, and OpenCode concatenates the built-in defaults with the project ruleset last while evaluating findLast, so each guard wins. Verified against sst/opencode dev: Wildcard.match (* → .*, anchored), permission/index.ts evaluate/findLast, and agent/agent.ts (merge(defaults, …, user) plus built-in defaults that already contain these exact rules). The guard script and its regression test are unchanged from the prior review and remain sound.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker merged commit 822fc5b into main Oct 5, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant