Retrieved article excerpt
Open article · Retrieved 2026-10-13T18:28:35.124213+00:00
## Repository navigation
# fix(core): discover system configuration directory at lowest precedence - #54921
#54921
Merged
[rekram1-node](https://github.com/rekram1-node) merged 3 commits into
[dev](https://github.com/anomalyco/opencode/tree/dev)anomalyco/opencode:devfrom
[system-config](https://github.com/anomalyco/opencode/tree/system-config)anomalyco/opencode:system-configCopy head branch name to clipboard
Oct 13, 2026
Merged
## [fix(core): discover system configuration directory at lowest precedence](https://github.com/anomalyco/opencode/pull/54921#top)#54921 [rekram1-node](https://github.com/rekram1-node) merged 3 commits into [dev](https://github.com/anomalyco/opencode/tree/dev)anomalyco/opencode:devfrom [system-config](https://github.com/anomalyco/opencode/tree/system-config)anomalyco/opencode:system-configCopy head branch name to clipboard
## Conversation
[@rekram1-node](https://github.com/rekram1-node)
### @rekram1-node **[rekram1-node](https://github.com/rekram1-node)** commented [Oct 12, 2026](https://github.com/anomalyco/opencode/pull/54921#issue-5819800957) • edited Loading Uh oh! There was an error while loading. [Please reload this page](https://github.com/anomalyco/opencode/pull/54921).
Copy link
Copy Markdown
Collaborator
### Issue for this PR
Fixes [#51107](https://github.com/anomalyco/opencode/issues/51107)
Fixes [#53074](https://github.com/anomalyco/opencode/issues/53074)
### Type of change
- Bug fix
- New feature
- Refactor / code improvement
- Documentation
### What does this PR do?
Includes the platform system configuration directory (`/Library/Application Support/opencode` on macOS, `/etc/opencode` on Linux, `%ProgramData%\opencode` on Windows) in `ConfigDiscovery.discover`, `Config.load`, and `ConfigWatch.plan` at the lowest configuration priority (ahead of well-known, global, and project configuration).
- Ordinary settings and directory-backed definitions (`providers`, `mcp`, `agents`, `commands`, `skills`, `plugins`, `model`, etc.) act as machine-wide defaults that user-global and project configuration can build on or override.
- Because `ManagedPolicy.statements` evaluates authored documents in reverse order (`entries.toReversed()`), loading the system configuration directory first automatically gives its `experimental.policies` (and migrated V1 `enabled_providers` / `disabled_providers`) the highest file-based policy authority—outranking project and user-global policies without special-casing `ManagedPolicy`.
### How did you verify your code works?
- Added unit and live tests in `packages/core/test/config/config.test.ts` and `packages/core/test/config/watch.test.ts` covering platform path resolution, lowest-priority loading, `system: false` isolation, and watcher planning.
- Ran `bun run check` and the full `packages/core/test/config/` suite.
[opencode-agent[bot]](https://github.com/apps/opencode-agent)
**[opencode-agent](https://github.com/apps/opencode-agent)
Bot**
reviewed
[Oct 12, 2026](https://github.com/anomalyco/opencode/pull/54921#pullrequestreview-5495533190)
[View reviewed changes](https://github.com/anomalyco/opencode/pull/54921/files)
### @opencode-agent **[opencode-agent](https://github.com/apps/opencode-agent) Bot** left a comment
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment.
### Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. [Learn more](https://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment).
Works as described. With `/etc/opencode/opencode.json` present, the base ignores it. With this PR, its settings load at the lowest priority, and a system `provider.use` deny removes a provider that the project config defines (checked with `config.get` / `provider.list` via opencode-drive in both checkouts). `bun test test/config/` passes (231) and `packages/core` typechecks cleanly.
Public API (all backwards compatible): adds the platform system config directory as a new config source (`/etc/opencode`, `/Library/Application Support/opencode`, `%ProgramData%\opencode`), so existing configs only change behaviour if that directory exists. Also adds `ConfigDiscovery.Sources.system`, `ConfigDiscovery.systemDirectory()` and a `system?: boolean | string` option on `Config.Options`. `global: false` now also skips the system directory. No HTTP API, SDK, CLI or environment variable changes.
Main point: V1 loaded this directory at the highest priority for *all* settings. Here only policies outrank users and projects, so other admin settings become user-overridable (see the inline comment). The tests could also be smaller (inline). The macOS `ai.opencode.managed` profile is still not read.
Fixes [#51107](https://github.com/anomalyco/opencode/issues/51107)
Related: [#53074](https://github.com/anomalyco/opencode/issues/53074), [#47351](https://github.com/anomalyco/opencode/issues/47351)
Comment thread
[packages/core/src/config.ts](https://github.com/anomalyco/opencode/pull/54921/files#diff-4114b8f08217be27efd35a3891857cfabc6eb75aee8ab39ba304e4d1b1095323)
Show resolved
Hide resolved
### Uh oh!
There was an error while loading. [Please reload this page](https://github.com/anomalyco/opencode/pull/54921).
Comment thread
[packages/core/test/config/policy.test.ts](https://github.com/anomalyco/opencode/pull/54921/files#diff-0abe122f02d1e14fbf123c262df3eef8bed19a8313262d2c3d12cfc514548c61)
Outdated
Show resolved
Hide resolved
### Uh oh!
There was an error while loading. [Please reload this page](https://github.com/anomalyco/opencode/pull/54921).
Comment thread
[packages/core/test/config/config.test.ts](https://github.com/anomalyco/opencode/pull/54921/files#diff-9982e8302b9d4b8f0ab202b0e3a88673d57add0564659dcf186b28196545e911)
Outdated
Show resolved
Hide resolved
### Uh oh!
There was an error while loading. [Please reload this page](https://github.com/anomalyco/opencode/pull/54921).
[@rekram1-node](https://github.com/rekram1-node)
[rekram1-node](https://github.com/rekram1-node)
[force-pushed](https://github.com/anomalyco/opencode/compare/9abe8ede4af8c9949711b617031ba74a4e99b2e9..f36a16a181843f2d514e7d0da6cc92016b59286a)
the
system-config
branch
from
[`9abe8ed`](https://github.com/anomalyco/opencode/commit/9abe8ede4af8c9949711b617031ba74a4e99b2e9) to
[`f36a16a`](https://github.com/anomalyco/opencode/commit/f36a16a181843f2d514e7d0da6cc92016b59286a) [Compare](https://github.com/anomalyco/opencode/compare/9abe8ede4af8c9949711b617031ba74a4e99b2e9..f36a16a181843f2d514e7d0da6cc92016b59286a)
[October 13, 2026 01:28](https://github.com/anomalyco/opencode/pull/54921#event-33093258035)
[@rekram1-node](https://github.com/rekram1-node) [@rntdrts](https://github.com/rntdrts)
`fix(core): discover system configuration directory at lowest precedence`
…
`d4b059c`
```
Co-authored-by: Renato Duarte <[email protected]>
```
[@rekram1-node](https://github.com/rekram1-node)
[rekram1-node](https://github.com/rekram1-node)
[force-pushed](https://github.com/anomalyco/opencode/compare/f36a16a181843f2d514e7d0da6cc92016b59286a..d4b059cd66927c1ad523277fdfe9d1efb29691a7)
the
system-config
branch
from
[`f36a16a`](https://github.com/anomalyco/opencode/commit/f36a16a181843f2d514e7d0da6cc92016b59286a) to
[`d4b059c`](https://github.com/anomalyco/opencode/commit/d4b059cd66927c1ad523277fdfe9d1efb29691a7) [Compare](https://github.com/anomalyco/opencode/compare/f36a16a181843f2d514e7d0da6cc92016b59286a..d4b059cd66927c1ad523277fdfe9d1efb29691a7)
[October 13, 2026 01:28](https://github.com/anomalyco/opencode/pull/54921#event-33093267438)
[@rekram1-node](https://github.com/rekram1-node)
[rekram1-node](https://github.com/rekram1-node)
mentioned this pull request
[Oct 13, 2026](https://github.com/anomalyco/opencode/pull/54921#ref-pullrequest-5582950374)
[fix(core): load managed config directory and macOS managed preferences
#51337](https://github.com/anomalyco/opencode/pull/51337)
Closed
4 of 6 tasks
[rekram1-node](https://github.com/rekram1-node)
added 2 commits
[October 12, 2026 22:07](https://github.com/anomalyco/opencode/pull/54921#commits-pushed-8f8b54f)
[@rekram1-node](https://github.com/rekram1-node)
`feat(core): load macOS MDM managed preferences`
`8f8b54f`
[@rekram1-node](https://github.com/rekram1-node)
`refactor(core): simplify system directory resolution`
`a73a9ec`
Hide details
View details
[@rekram1-node](https://github.com/rekram1-node)
[rekram1-node](https://github.com/rekram1-node)
merged commit [`ba82b37`](https://github.com/anomalyco/opencode/commit/ba82b370c1c3853d2e06e8c5f3837d43e62bbcd2)
into
dev
[Oct 13, 2026](https://github.com/anomalyco/opencode/pull/54921#event-33100199937)
9 checks passed
### Uh oh!
There was an error while loading. [Please reload this page](https://github.com/anomalyco/opencode/pull/54921).
[@rekram1-node](https://github.com/rekram1-node)
[rekram1-node](https://github.com/rekram1-node)
deleted the
system-config
branch
[October 13, 2026 04:02](https://github.com/anomalyco/opencode/pull/54921#event-33100201383)
[@verdverm](https://github.com/verdverm)
### **[verdverm](https://github.com/verdverm)** commented [Oct 13, 2026](https://github.com/anomalyco/opencode/pull/54921#issuecomment-6151059619) • edited Loading Uh oh! There was an error while loading. [Please reload this page](https://github.com/anomalyco/opencode/pull/54921).
Copy link
Copy Markdown
Contributor
| |
| --- |
| This breaks the security controls having the system config as the highest priority, which is not editable by users. Our need is to prevent policies from being circumventable by user/project config. This is a **major** security regression For reference - <https://code.claude.com/docs/en/settings#check-what-your-organization-enforces> - <https://learn.chatgpt.com/docs/enterprise/managed-configuration#locations-and-precedence> |
[@verdverm](https://github.com/verdverm)
[verdverm](https://github.com/verdverm)
mentioned this pull request
[Oct 13, 2026](https://github.com/anomalyco/opencode/pull/54921#ref-issue-5835214796)
[Support system level configuration at the highest precedence to enhance security posturing
earendil-works/pi#10895](https://github.com/earendil-works/pi/issues/10895)
Closed
[Sign up for free](https://github.com/join?source=comment-repo)
**to join this conversation on GitHub**.
Already have an account?
[Sign in to comment](https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fanomalyco%2Fopencode%2Fpull%2F54921)
### Labels
None yet
### 2 participants
[@rekram1-node](https://github.com/rekram1-node) [@verdverm](https://github.com/verdverm)
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.