Repository navigation
Done
Labels
capability:platformFramework / agent substrate skills (install, verify, doctor, override, status, setup bootstrap)contract:hook-managerTool capability: git-hook managers under the secure setup (install target, sandbox / host homes)family:ci.github workflows, prek, validatorsfamily:devRepo dev: .asf.yaml, spec-loop specs, Node manifests, .claude/settings.jsonfamily:docsDocs, MISSION.md, READMEsfamily:setupsetup-* skillsfamily:toolstools/*good first issueGood for newcomerssubstrate:framework-devTool substrate: build / validate / eval the framework itselfsubstrate:sandboxTool substrate: agent isolation, egress control, settings audit
Description
The hook-manager contract (#1819) defines how the secure agent setup integrates a git-hook manager: where its install puts the hook, how its home is split between sandboxed and host runs, and how the setup detects that a repository uses it.
prek is the only adapter so far.
This issue adds pre-commit (Python).
What the source says (pre-commit v4.7.0)
- Install target.
pre-commit installalways writes$(git rev-parse --git-common-dir)/hooks/<type>(commands/install_uninstall.py:47-53,git.py:86-93), but refuses whengit config core.hooksPathreturns anything (git.py:180-182):
Cowardly refusing to install hooks with core.hooksPath set.(install_uninstall.py:123-127).
Under the whole-user setup the globalcore.hooksPathis always set, so a plain install always fails.
There is no--git-dirflag (main.py:273-293). - Fix.
GIT_CONFIG_GLOBAL=/dev/null pre-commit installhides the global value from that check, and the install lands in the common dir.
Do not useGIT_CONFIG_COUNTto overridecore.hooksPath: any non-empty value is refused, and git treats an empty value as set (hooks then resolve against/).
Do not usepre-commit init-templatediras a workaround: it forcesoverwrite=True, which moves a foreign hook to.legacyand then deletes it. - Home.
PRE_COMMIT_HOME, else$XDG_CACHE_HOME/pre-commit, else~/.cache/pre-commit(store.py:32-36).
Hook runs execute the repositories cloned and the environments built there (repository.py:177,196), so it needs the same sandbox/host split as prek.
PRE_COMMIT_HOMEdoes not expand~(onlyos.path.realpath), so the committed settings cannot spell the sandbox home as~/.cache/pre-commit-sandbox; it would become<cwd>/~/.cache/.... - Generated hook. It hardcodes the install-time Python (
INSTALL_PYTHON=...) with a fallback topre-commitonPATH, and passes--hook-dir "$(dirname "$0")", which is used only to find<type>.legacy(hook_impl.py:36-46).
The dispatcher execs it by its real path, so that works. - Detection. Config
.pre-commit-config.yaml(or a custom--configpath written into the hook); no nested configs.
Hook marker: the generated hook namespre-commit.
What to do
- Add a
hide-global-configinstall strategy totools/agent-isolation/hook-manager-shim.sh(run the install withGIT_CONFIG_GLOBAL=/dev/null) and toSTRATEGIESintools/dev/sync-hook-managers.py, with a shim test. - Decide how a home that does not expand
~gets a per-user sandbox value.
The contract requiresexpands_tilde: truetoday.
One option:sandbox-add-project-root.shwrites the absolutePRE_COMMIT_HOMEinto the per-user.claude/settings.local.json, andsandbox-lintaccepts it there.
Write the choice into the contract's Home section. - Add the
pre-commitadapter totools/hook-manager/registry.json(detect.config_files: [".pre-commit-config.yaml", ".pre-commit-config.yml"],nested: false,hook_marker: "pre-commit") and runtools/dev/sync-hook-managers.py. - The two YAML names are shared with prek, so a repository with either uses both managers as far as detection goes; check that both homes are set for it and nothing breaks.
- Update the adapter table in the contract, and
docs/setup/sandbox-troubleshooting.mdfor the "Cowardly refusing" error.
Acceptance
pre-commit installthrough~/.claude/bin/pre-commitsucceeds under a globalcore.hooksPathand writes to the common dir, including in a linked worktree.- A hook run outside the sandbox gets a host-only
PRE_COMMIT_HOME; a sandboxed run gets the sandbox home; a repository without a pre-commit config gets neither. prek run --all-files --skip workspace-pytestand the agent-isolation, sandbox-lint and dev tests pass.
Metadata
Metadata
Assignees
Labels
capability:platformFramework / agent substrate skills (install, verify, doctor, override, status, setup bootstrap)contract:hook-managerTool capability: git-hook managers under the secure setup (install target, sandbox / host homes)family:ci.github workflows, prek, validatorsfamily:devRepo dev: .asf.yaml, spec-loop specs, Node manifests, .claude/settings.jsonfamily:docsDocs, MISSION.md, READMEsfamily:setupsetup-* skillsfamily:toolstools/*good first issueGood for newcomerssubstrate:framework-devTool substrate: build / validate / eval the framework itselfsubstrate:sandboxTool substrate: agent isolation, egress control, settings audit
Activity
ninglinLiu commentedon Oct 25, 2026
I'd like to work on this one: add the
hide-global-configinstall strategy tohook-manager-shim.shandSTRATEGIES, the pre-commit registry entry (with the non-expandingPRE_COMMIT_HOMEhandled explicitly), regenerate withtools/dev/sync-hook-managers.py, and add shim tests for the new strategy. Could a maintainer assign it to me? I'll wait for the assignment before opening a PR.wynneyin commentedon Nov 15, 2026
Checking in before I invest in a branch: #1895 (lefthook) landed
hide-global-config, so the shim half of step 1 exists. With the current registry, adding pre-commit validates everywhere except one line:So the open work is steps 2–5 plus the generator/lint plumbing for a home that does not expand
~. Two details from the layout that shape it:tools/dev/sync-hook-managers.pyrenders the shim cases, the dispatcher homes and the lint'sHOOK_MANAGER_HOMESfrom the registry, soexpands_tilde: falsehas to be carried into the generated lint tuple. The lint already reads the merged floor +settings.local.json(merge_layersatsandbox_lint/__init__.py), so an absolutePRE_COMMIT_HOMEwritten there is visible to it unchanged..pre-commit-config.yamlat this repository's root meanscheck_settingsandsandbox-lintclassify the framework repo itself as using pre-commit. The committed settings therefore cannot name that sandbox home with~(pre-commit keeps the literal viaos.path.realpath), so the per-user value has to come from the helper — which already writes absolute$HOMEpaths intosettings.local.json.Proposed shape (option 1 in the issue):
home.expands_tilde: falsefor pre-commit; sandbox home~/.cache/pre-commit-sandbox, host home under~/.local/share/,detect.nested: false,hook_marker: "pre-commit";sync-hook-managers.py: stop requiring the committedenventry for a non-expanding home, and render a fourth block — adapter → variable → sandbox home — intosandbox-add-project-root.sh;sandbox-add-project-root.sh: writeenv.PRE_COMMIT_HOMEas the absolute sandbox home when the repository uses pre-commit, and remove it when it does not ("a repository without a pre-commit config gets neither");sandbox-lint: forexpands_tilde: false, accept the absolute value from the merged settings and reject a literal~with a pointer to the helper;pre-commit; contract Home section and the "Cowardly refusing" entry indocs/setup/sandbox-troubleshooting.md.@ninglinLiu asked about this in October — if you are still working on it, say so and I will hand the analysis over instead of opening a competing PR.
feat(hook-manager): add a pre-commit adapter
bearomorphism commentedon Nov 24, 2026
I'm working on this at Taipei sprint
feat(hook-manager): add a pre-commit adapter
feat(hook-manager): add a pre-commit adapter
feat(hook-manager): add a pre-commit adapter
feat(hook-manager): add a pre-commit adapter
feat(hook-manager): add a pre-commit adapter
feat(hook-manager): add a pre-commit adapter (apache#2108)