repo.commit creates the commit with go-git, so .git/hooks and core.hooksPath are ignored and the message is whatever the workflow YAML says.
A repository whose rules live only in a hook — formatter, secret scanner,
commitlint, DCO trailer — gets a commit that breaks them: the run reports
success and the pull request fails the check afterwards. Documented in WORKFLOWS.md under repo.commit (no code change there).
Wanted: hooks: true on repo.commit, off by default.
CommitAll already runs inside the task container (hybridTrees.CommitAll), so
the hooks would execute where the repository's own code already runs. The
daemon-side Push stays hook-free, as it must: a pre-push hook would run
repo-supplied code next to the daemon's credentials. When the setting is on,
replace the go-git stage-and-commit with git -C <dir> commit -a -F <msgfile>;
git is already in both images.
Decisions this needs:
a failing hook parks the run and reports the hook's output, instead of
committing anyway;
the captured diff is taken after the hook, so hook-side edits reach review.
Done when: a repo whose pre-commit rewrites a file shows the rewritten file in
the captured change, and a repo whose commit-msg hook fails parks the run with
the hook's output.
`repo.commit` creates the commit with go-git, so `.git/hooks` and
`core.hooksPath` are ignored and the message is whatever the workflow YAML says.
A repository whose rules live only in a hook — formatter, secret scanner,
commitlint, DCO trailer — gets a commit that breaks them: the run reports
success and the pull request fails the check afterwards. Documented in
`WORKFLOWS.md` under `repo.commit` (no code change there).
Wanted: `hooks: true` on `repo.commit`, off by default.
`CommitAll` already runs inside the task container (`hybridTrees.CommitAll`), so
the hooks would execute where the repository's own code already runs. The
daemon-side `Push` stays hook-free, as it must: a `pre-push` hook would run
repo-supplied code next to the daemon's credentials. When the setting is on,
replace the go-git stage-and-commit with `git -C <dir> commit -a -F <msgfile>`;
git is already in both images.
Decisions this needs:
- a failing hook parks the run and reports the hook's output, instead of
committing anyway;
- the captured diff is taken after the hook, so hook-side edits reach review.
Done when: a repo whose pre-commit rewrites a file shows the rewritten file in
the captured change, and a repo whose commit-msg hook fails parks the run with
the hook's output.
Implemented twice, reviewed twice on the full six-angle pass, and not mergeable as scoped. Recording the constraints here so the next attempt starts from them instead of rediscovering them. The branch run/commit-hooks was reset; the commits stay reachable in the reflog for 90 days.
P0 — the isolation does not hold on the default deployment
Root-owned worktree means hooks run as the credential-bearing worker.WORKTREE_UID is the daemon's own uid (internal/daemon/daemon.go:2439), and Dockerfile.archied runs the daemon as root. With uid 0 there is nothing to drop to, so hooks run as root. Filtering the child environment does not isolate it: a same-uid subprocess reads /proc/$PPID/environ and gets STATE_STORE_TOKEN / NATS_TOKEN. The harness refuses exactly this (internal/agentexec/harness_proc_unix.go:25-32), and this path reintroduces it. A real fix needs a distinct unprivileged identity for hook execution, and to refuse rather than degrade when none exists.
A fixup commit publishes the pre-hook content. Folding a hook's unstaged rewrite in as a second commit puts the original in HEAD~1 and pushes it with the branch: a redacting hook leaves the secret in history while the final diff looks clean. Anything that runs hooks must produce one commit or none.
P1 — the container path cannot satisfy the current design
Ownership ordering.hybridTrees.CommitAll runs before reconcileOwnership (internal/app/agentworker/task_execution.go:56-58), while the harness chowns the worktree to the harness user (harness_runner.go:74, default uid 1000, skipping .git). Git then rejects the checkout as dubious ownership, or the hook user cannot rewrite harness-owned files, before a hook runs at all.
Identity. For non-root identities the daemon clears BotUser/BotEmail (daemon.go:2458-2459), and git -c user.name= -c user.email= fails with "empty ident name". The go-git path supplied a signature instead; a git-binary path must supply an attribution the run is authorised to use.
Alternates. Task clones borrow objects from the shared mirror; git in a Kit container cannot see them unless the alternate store is mounted read-only.
What a correct design needs
A separate unprivileged uid for hook execution (not the daemon's), ownership reconciled before the commit rather than after, an explicit commit attribution for every identity, the mirror mounted for the git process, and a single-commit guarantee. That is not a change to one step; it is a change to how the task container hands a worktree to git. Worth its own issue once the container-boundary work lands.
Documentation kept from the attempt: WORKFLOWS.md now says hooks never run, which stays true.
Implemented twice, reviewed twice on the full six-angle pass, and **not mergeable as scoped**. Recording the constraints here so the next attempt starts from them instead of rediscovering them. The branch `run/commit-hooks` was reset; the commits stay reachable in the reflog for 90 days.
### P0 — the isolation does not hold on the default deployment
1. **Root-owned worktree means hooks run as the credential-bearing worker.** `WORKTREE_UID` is the daemon's own uid (`internal/daemon/daemon.go:2439`), and `Dockerfile.archied` runs the daemon as root. With uid 0 there is nothing to drop to, so hooks run as root. Filtering the child environment does not isolate it: a same-uid subprocess reads `/proc/$PPID/environ` and gets `STATE_STORE_TOKEN` / `NATS_TOKEN`. The harness refuses exactly this (`internal/agentexec/harness_proc_unix.go:25-32`), and this path reintroduces it. A real fix needs a distinct unprivileged identity for hook execution, and to refuse rather than degrade when none exists.
2. **A fixup commit publishes the pre-hook content.** Folding a hook's unstaged rewrite in as a second commit puts the original in `HEAD~1` and pushes it with the branch: a redacting hook leaves the secret in history while the final diff looks clean. Anything that runs hooks must produce one commit or none.
### P1 — the container path cannot satisfy the current design
- **Ownership ordering.** `hybridTrees.CommitAll` runs before `reconcileOwnership` (`internal/app/agentworker/task_execution.go:56-58`), while the harness chowns the worktree to the harness user (`harness_runner.go:74`, default uid 1000, skipping `.git`). Git then rejects the checkout as dubious ownership, or the hook user cannot rewrite harness-owned files, before a hook runs at all.
- **Identity.** For non-root identities the daemon clears `BotUser`/`BotEmail` (`daemon.go:2458-2459`), and `git -c user.name= -c user.email=` fails with "empty ident name". The go-git path supplied a signature instead; a git-binary path must supply an attribution the run is authorised to use.
- **Alternates.** Task clones borrow objects from the shared mirror; git in a Kit container cannot see them unless the alternate store is mounted read-only.
### What a correct design needs
A separate unprivileged uid for hook execution (not the daemon's), ownership reconciled before the commit rather than after, an explicit commit attribution for every identity, the mirror mounted for the git process, and a single-commit guarantee. That is not a change to one step; it is a change to how the task container hands a worktree to git. Worth its own issue once the container-boundary work lands.
Documentation kept from the attempt: `WORKFLOWS.md` now says hooks never run, which stays true.
sam
added the deferred label 2026-11-07 16:45:04 +00:00
Closed: goes against the product plan in epic #1977. Core gains no more built-in repository steps; forge and repository actions come from connectors (#1979, #1657).
Closed: goes against the product plan in epic #1977. Core gains no more built-in repository steps; forge and repository actions come from connectors (#1979, #1657).
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
repo.commitcreates the commit with go-git, so.git/hooksandcore.hooksPathare ignored and the message is whatever the workflow YAML says.A repository whose rules live only in a hook — formatter, secret scanner,
commitlint, DCO trailer — gets a commit that breaks them: the run reports
success and the pull request fails the check afterwards. Documented in
WORKFLOWS.mdunderrepo.commit(no code change there).Wanted:
hooks: trueonrepo.commit, off by default.CommitAllalready runs inside the task container (hybridTrees.CommitAll), sothe hooks would execute where the repository's own code already runs. The
daemon-side
Pushstays hook-free, as it must: apre-pushhook would runrepo-supplied code next to the daemon's credentials. When the setting is on,
replace the go-git stage-and-commit with
git -C <dir> commit -a -F <msgfile>;git is already in both images.
Decisions this needs:
committing anyway;
Done when: a repo whose pre-commit rewrites a file shows the rewritten file in
the captured change, and a repo whose commit-msg hook fails parks the run with
the hook's output.
Implemented twice, reviewed twice on the full six-angle pass, and not mergeable as scoped. Recording the constraints here so the next attempt starts from them instead of rediscovering them. The branch
run/commit-hookswas reset; the commits stay reachable in the reflog for 90 days.P0 — the isolation does not hold on the default deployment
WORKTREE_UIDis the daemon's own uid (internal/daemon/daemon.go:2439), andDockerfile.archiedruns the daemon as root. With uid 0 there is nothing to drop to, so hooks run as root. Filtering the child environment does not isolate it: a same-uid subprocess reads/proc/$PPID/environand getsSTATE_STORE_TOKEN/NATS_TOKEN. The harness refuses exactly this (internal/agentexec/harness_proc_unix.go:25-32), and this path reintroduces it. A real fix needs a distinct unprivileged identity for hook execution, and to refuse rather than degrade when none exists.HEAD~1and pushes it with the branch: a redacting hook leaves the secret in history while the final diff looks clean. Anything that runs hooks must produce one commit or none.P1 — the container path cannot satisfy the current design
hybridTrees.CommitAllruns beforereconcileOwnership(internal/app/agentworker/task_execution.go:56-58), while the harness chowns the worktree to the harness user (harness_runner.go:74, default uid 1000, skipping.git). Git then rejects the checkout as dubious ownership, or the hook user cannot rewrite harness-owned files, before a hook runs at all.BotUser/BotEmail(daemon.go:2458-2459), andgit -c user.name= -c user.email=fails with "empty ident name". The go-git path supplied a signature instead; a git-binary path must supply an attribution the run is authorised to use.What a correct design needs
A separate unprivileged uid for hook execution (not the daemon's), ownership reconciled before the commit rather than after, an explicit commit attribution for every identity, the mirror mounted for the git process, and a single-commit guarantee. That is not a change to one step; it is a change to how the task container hands a worktree to git. Worth its own issue once the container-boundary work lands.
Documentation kept from the attempt:
WORKFLOWS.mdnow says hooks never run, which stays true.Closed: goes against the product plan in epic #1977. Core gains no more built-in repository steps; forge and repository actions come from connectors (#1979, #1657).