apache / apache/maka

bug(runtime): linked worktree boundaries omit the Git commondir

Open
#4,336 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
5.4k
Forks
502
Avg merge
1d 2h
Merged PRs (30d)
715

Description

## What happened

In a linked Git worktree opened with macOS sandbox mode set to Auto, approving the requested `.git/worktrees/` subtree leaves the repository's shared Git metadata inaccessible. After individual shared files such as `config` and `packed-refs` are approved, `git status --short --branch` can exit `0`, warn that `.git/info/exclude` is inaccessible, and list tracked files as additions. `git log` can report that the current branch is broken.

## How to reproduce

1. Create a linked worktree from a repository with tracked files:

```sh
MAIN="$HOME/path/to/main-checkout"
WORKSPACE="$HOME/path/to/linked-worktree"
git -C "$MAIN" worktree add -b boundary-repro "$WORKSPACE"
```

2. Open `$WORKSPACE` in Maka on macOS.
3. Keep sandbox mode set to Auto with the workspace-write profile.
4. Run `git status --short --branch` through the managed Bash tool.
5. Approve the boundary request for `$MAIN/.git/worktrees/` and the individual shared Git metadata files requested afterward.

The command can return `0` with an inaccessible `.git/info/exclude` warning and a false list of added files.

## Expected

A read-scoped subtree request for a standard linked-worktree admin directory should be normalized to the repository's shared `.git` directory before approval. One read approval should let `git status` and `git log` read the real refs, objects, configuration, and excludes. Write operations such as `git commit` should keep their exact requested path and require separate approval.

## Root cause

`packages/runtime/src/sandbox-boundary-path.ts:80-108` canonicalizes paths and scopes while omitting the linked-worktree `commondir` relationship. `packages/runtime/src/builtin-tools.ts:743-749` supplies only the current working directory as the workspace root, so the main checkout's shared `.git` directory remains outside the managed boundary.

## Environment

- Maka commit: `4cbe224`
- OS: macOS 26.6.1
- Surface: Runtime managed Bash / Auto sandbox
- Node.js: 24.19.0

Contributor guide

Open the contributing guide

Research direction

Start with packages/runtime/src/sandbox-boundary-path.ts:80-108 and packages/runtime/src/builtin-tools.ts:743-749, then reproduce the linked-worktree case with git status --short --branch and git log through the managed Bash tool. Trace how the commondir relationship and workspace root are handled. Done means read-scoped approvals reach the shared .git directory while writes retain their exact requested paths and require separate approval.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, typescript
Domain
devtools, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.