Repository navigation
fix(skills): allow verified managed subagent worktrees in workspace observation - #7134
Merged
Merged
Conversation
…tree test Address review feedback on #7134: - Extract open_workspace_observation_sync in maka-workspace-support and reuse it from maka-skills-native so managed worktree validation cannot drift while preserving skills' stricter private-root deny and read-only policy. - Isolate git config and index env vars in the worktree test fixture so host global excludes or commit signing cannot break test setup. - Write wt-skill only inside the child worktree after ensure() and assert prepare's metadataPrompt contains it, proving skills are scanned from the worktree rather than binding.source(). - Drop the redundant Unix symlink assertion already covered by skills core ReadRoot containment tests. Generated-by: Maka (Antigravity)
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.
English
Root Cause
When an agent (or user) creates a session with
workspace: { kind: "worktree" }, Maka allocates a managed Git worktree under<state_root>/subagent-worktrees/<hash>/worktreeand attachesworkspace.worktree = Some(binding).While
maka-workspace-support(and the files/git/process/computer/web plugins) explicitly validateworkspace.worktreeviaWorktrees::inspect(binding)and carve out a subpath rule underneath thestate_rootdeny policy,plugins/skills/native/src/sources.rs(Library::for_observation) had not been updated for managed worktrees:path.starts_with(&library.private)was alwaystruebecausesubagent-worktreeslives insidelibrary.private(state_root).library.projectsagainst the worktree path itself instead of validatingbindingviaWorktrees::inspectand checkingbinding.source().library.policydenied the entirelibrary.privatesubtree without carving out read-only access for the verified worktree directory.As a result, every
SessionSendto aworkspace: { kind: "worktree" }session failed duringskills.prepareand returnedSendResult::Rejected { reason: "skills_unavailable", skills: null }.Fix
plugins/skills/native/src/sources.rs(Library::for_observation) to validateworkspace.worktreeconsistently withmaka-workspace-support:binding.directory() == Path::new(&directory.path).Worktrees::open(&library.private.join("subagent-worktrees")).inspect(binding).binding.source()againstlibrary.projects.library.privatedenied while carving outAccess::Readstrictly for the verified worktree directory.managed_subagent_worktree_allows_project_skills_while_protecting_private_rootcovering:prepareandsearchdiscovering project skills inside a managed subagent worktree;privatestaying denied;private/subagent-worktreeswithout a verified binding staying rejected;projects/staying rejected.Verification
cargo test -p maka-skills-native(4/4 passed)cargo clippy -p maka-skills-native --all-targets -- -D warnings(passed)rustfmt --edition 2024 --check plugins/skills/native/src/sources.rs(passed)node scripts/ci.mjs check licenses(passed)简体中文
根因
使用
SessionCreate({ workspace: { kind: "worktree" } })创建隔离工作区会话时,Maka 会在<state_root>/subagent-worktrees/<hash>/worktree下分配托管 Git worktree,并在Workspace上附带worktree: Some(binding)。maka-workspace-support以及 files/git/process/computer/web 插件都已经通过Worktrees::inspect(binding)校验并放行托管 worktree,但plugins/skills/native/src/sources.rs的Library::for_observation遗漏了这一路径:subagent-worktrees位于library.private(即state_root)下,直接命中path.starts_with(&library.private);library.projects,而没有校验Worktrees::inspect(binding)与binding.source();library.policy对整个library.private设置了Access::Deny,没有为已校验的 worktree 目录开只读例外。导致只要启用了 skills 插件,向任意托管 worktree 会话发起
SessionSend都会在skills.prepare阶段报skills_workspace_unavailable,最终被plugins/agent/native/src/owner/skills.rs映射为SendResult::Rejected { reason: "skills_unavailable", skills: null }。修复内容
plugins/skills/native/src/sources.rs的Library::for_observation中补齐托管 worktree 校验(与maka-workspace-support保持同一安全边界):binding.directory() == Path::new(&directory.path);Worktrees::open(&library.private.join("subagent-worktrees")).inspect(binding)验证为合法托管 worktree;binding.source()属于已授权的library.projects;library.private为Deny,仅对已校验的该 worktree 目录放行Access::Read。managed_subagent_worktree_allows_project_skills_while_protecting_private_root,覆盖:prepare与search并发现 worktree 内的项目技能;private其它目录的符号链接仍被策略拒绝(Unix);worktree绑定的普通目录指向private/subagent-worktrees仍被拒绝;projects/下的托管 worktree 仍被拒绝。验证记录
cargo test -p maka-skills-native(4/4 通过)cargo clippy -p maka-skills-native --all-targets -- -D warnings(通过)rustfmt --edition 2024 --check plugins/skills/native/src/sources.rs(通过)node scripts/ci.mjs check licenses(通过)