feat: enforce OpenCode subagent permission constraints - #1921
Merged
limityan merged 2 commits intoJul 31, 2026
Conversation
Translate supported OpenCode agent permission rules into independent constraint layers and carry them through the existing tool pipeline. Preserve current source ordering, V1 migration, path semantics, and fail-closed behavior without adding a new runtime owner.
Restore upstream direct and directory source ordering. Keep V1 disable as a deep-merged field while preserving V2 tombstone and mixed-schema re-add behavior.
limityan
force-pushed
the
yanzhn/opencode-subagent-permissions
branch
from
July 31, 2026 06:49
5997f69 to
11a0b4e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
结果
为 OpenCode 外部 Subagent 接入可执行的 Agent-local 权限约束,同时保持 BitFun 现有权限管线为唯一最终裁决者。外部规则作为独立 constraint layer 参与裁决,只能收紧宿主策略,不能借
allow扩大工具能力或绕过父级限制。本 PR 约 2.4k 行变更,不新增运行时 owner,也不涉及 Plugin Host Runtime。
范围
agent/prompt/disable/permission,并解析 Core V2agents/system/disabled/permissions的已验证安全子集。write/edit/patch/apply_patch归一为 BitFunedit,不猜测 action pattern 或嵌套 resource map。OPENCODE_CONFIG、project direct config(root-to-nearest),再到用户 Agent Markdown、project.opencodeconfig/Markdown(opened-to-root)、兼容用户目录和显式目录。Task,避免当前子任务父级 ceiling 尚未携带外部约束时形成委派逃逸。CI 修正
旧 head 的 Linux、macOS、Windows Rust job 均失败于相同两项 Core 来源顺序回归,不是平台差异:project
.opencode被错误按 root-to-nearest 应用,导致 nearest/inner 定义覆盖 outer 定义。本次修正恢复生产 OpenCode 的两阶段顺序,并补齐生命周期语义:
.opencode目录阶段:opened-to-root;disable:普通 deep-merge 字段,后续省略时保持禁用,显式false才重新启用;disabled:true:逐文档 tombstone;后续任意同名非 disabled contribution 从空定义重建;deny丢失。设计取舍
disable误当删除竞品对照锁定到 OpenCode
da59457ca4ff55aca0147d4ddb33c495dc72be31的生产 V1 config owner、Core V2 config/location 实现,以及 oh-my-openagent Oracle 配置。明确不做
Task委派;后续只有在子任务 ceiling 能完整携带约束时才可单独评估。allow自动授予工具;工具资格与权限裁决保持分离。验证
cargo test --locked -p bitfun-opencode-adapter --test opencode_subagent_adapter:20/20cargo test --locked -p bitfun-core --lib:1680 passed、0 failed、1 ignoredcargo check -p bitfun-core --no-default-features --features product-full:通过node scripts/check-core-boundaries.mjs:通过pnpm run check:repo-hygiene:通过git diff gcwing/main --check:通过完整
cargo check --workspace在本地仍受仓库未提供src/mobile-web/dist的 desktop embed 输入限制;未生成或提交无关前端产物。GitHub Actions run30610811432已在 exact head11a0b4e505f03b622d6b2d5108f4814ff1b2a3d7完成:Shell、Frontend、Ubuntu/macOS CLI 与 Ubuntu/Windows/macOS Rust 共 7/7 jobs 通过。复审
独立对抗性复审覆盖生产来源顺序、alias/watch、V1/V2 disable/tombstone、mixed-schema 重建、资源坐标、Windows 匹配和委派逃逸。复审新增的 mixed-schema P1 已按失败回归修复;最终未发现遗留 P0/P1。