Skip to content

feat(agent-isolation): hook-manager contract, with prek as its first adapter - #1819

Merged
potiuk merged 2 commits into
apache:mainfrom
potiuk:hook-manager-contract
Oct 25, 2026
Merged

potiuk merged 2 commits into
apache:mainfrom
potiuk:hook-manager-contract

Conversation

@potiuk

@potiuk potiuk commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

Summary

  • The secure setup's prek integration (install shim, sandbox and host-only homes, sandbox-lint checks) becomes the first adapter of a new hook-manager contract (tools/hook-manager/, contract:hook-manager), so pre-commit, lefthook, husky and other managers can join by adding an adapter rather than another set of hand-written special cases.
  • registry.json is the single source of truth; tools/dev/sync-hook-managers.py (a new prek hook) validates it and writes it into the shim, the whole-user dispatcher and sandbox-lint, which run where the registry is not available.
  • Detection: a repository uses a manager when one of its config files is at the root (prek: prek.toml, .pre-commit-config.yaml, .pre-commit-config.yml), a tracked one sits below it (prek workspace mode), or an installed hook runs it (custom --config). Per-repository configuration (the env.PREK_HOME sandbox-lint requires, the shim, verify 19d) applies only then. The per-user protections, the Edit(~/.cache/prek/**) deny and the dispatcher's host-only home, stay on for every registered manager, since those homes are shared by every repository on the host.

Type of change

  • Skill change (.claude/skills/<name>/) — eval fixtures updated below
  • Tool / bridge contract (tools/<system>/*.md)
  • Python package (tools/*/ with pyproject.toml)
  • Cross-cutting (RFC, AGENTS.md, sandbox, privacy-LLM)
  • Documentation (docs/, README.md, CONTRIBUTING.md)
  • CI / dev loop (prek, workflows, validators)

Test plan

  • prek run --all-files --skip workspace-pytest passes
  • Tests for every changed member pass: agent-isolation (new test_hook_manager_shim.py; dispatcher detection / fail-closed cases), sandbox-lint (uses_hook_manager, deny always required, home only where used), dev (test_sync_hook_managers.py), vendor-neutrality-score, skill-and-tool-validator, setup-preflight
  • For skill changes: setup-isolated-setup-verify eval suite run on this branch and on main. main fails the same 4 cases (step-1 case-7, step-2 cases 3, 5, 6); this branch additionally failed case-3 (grader timeout) and case-6 (check 5, harness version floor), neither touching check 19, the only part of the skill changed
  • For skill behaviour changes: a new or updated eval fixture — not added; the verify 19d change only narrows when the env.PREK_HOME part applies

RFC-AI-0004 compliance

  • Sandbox — no new host access; the default-home deny and host-only homes are kept unconditional
  • Vendor neutrality — the contract is manager-agnostic; prek is one adapter

Linked issues

Follow-up adapters (good first issues), each building on this contract:

Notes for reviewers (optional)

  • prek-shim.sh is renamed to hook-manager-shim.sh; a host that installed the old script as ~/.claude/bin/prek keeps working.
  • prek 0.5.7 refuses a bare prek install while a global core.hooksPath is set, so the shim is required, not only convenient.
  • One unrelated file (plugins/magpie-setup/skills/isolated-setup-doctor/tests/test_probe_3_container_gateway.py) is reformatted: it was unformatted on main, and the commit hook formats the whole plugins member.
  • The second commit moved the deny and host home back to unconditional after a security review of the first: gating them on detection would have let a project without prek drop the deny on a per-user directory.

Generative AI disclosure: prepared with Claude Code (Claude Opus 5); reviewed by the submitter.

🤖 Generated with Claude Code

…adapter

The secure setup's prek integration (the install shim, the sandbox and
host-only homes, the sandbox-lint checks) becomes one instance of a
contract for git-hook managers: tools/hook-manager/README.md states the
install-target, home and detection rules, and registry.json records how
each manager satisfies them.

- hook-manager-shim.sh replaces prek-shim.sh; it takes the tool from the
  name it is installed under (~/.claude/bin/<tool>) and applies the
  adapter's install strategy (git-dir-flag for prek).
- The whole-user dispatcher gives each manager the repository uses its
  host-only home, and none to a repository that uses none.
- sandbox-lint requires env.<HOME> and the default-home deny only for a
  project that uses the manager: a root config file, a tracked nested
  config (prek workspaces), or an installed hook that runs it.
- tools/dev/sync-hook-managers.py validates the registry and writes it
  into the shim, the dispatcher and sandbox-lint (prek hook).
- contract:hook-manager joins the label taxonomy, the validator and the
  vendor-neutrality policy.

The contract lists the strategies the other managers need (pre-commit,
lefthook, husky, overcommit, CaptainHook, and those that need none),
from a source-level check of each, for follow-up adapters.

Generated-by: Claude Opus 5
…ional

Detection now decides only what is configured for a repository: the
sandbox home a project's settings must carry, the shim, verify 19d.
The default-home deny and the dispatcher's host home stay on for every
registered manager. Both homes are per-user: a project without prek
dropping the deny lets its sandboxed commands write the environments
another project's terminal commits run, and a hook that reaches prek
through a script would otherwise inherit the sandbox home in a
bypassed command.

Generated-by: Claude Opus 5
@potiuk
potiuk enabled auto-merge (squash) October 25, 2026 16:35
@github-actions github-actions Bot added family:setup setup-* skills family:tools tools/* family:docs Docs, MISSION.md, READMEs family:ci .github workflows, prek, validators capability:platform Framework / agent substrate skills (install, verify, doctor, override, status, setup bootstrap) substrate:analytics Tool substrate: read-only metrics / dashboards / renderers substrate:sandbox Tool substrate: agent isolation, egress control, settings audit substrate:framework-dev Tool substrate: build / validate / eval the framework itself labels Oct 25, 2026
@potiuk
potiuk merged commit d774c41 into apache:main Oct 25, 2026
22 checks passed
@github-actions github-actions Bot added the contract:hook-manager Tool capability: git-hook managers under the secure setup (install target, sandbox / host homes) label Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

capability:platform Framework / agent substrate skills (install, verify, doctor, override, status, setup bootstrap) contract:hook-manager Tool capability: git-hook managers under the secure setup (install target, sandbox / host homes) family:ci .github workflows, prek, validators family:docs Docs, MISSION.md, READMEs family:setup setup-* skills family:tools tools/* substrate:analytics Tool substrate: read-only metrics / dashboards / renderers substrate:framework-dev Tool substrate: build / validate / eval the framework itself substrate:sandbox Tool substrate: agent isolation, egress control, settings audit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant