Phase 4: Isolate subagent hooks by repo#9
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR implements phase 4 of the dispatched-subagent guard rollout by scoping subagent marker enforcement to the current git repository (via git_root) to eliminate cross-repo false positives while retaining backward compatibility with legacy marker formats.
Changes:
- Update the dispatched-subagent marker format to store per-entry objects (
{name, ts, git_root}) and include a top-levelgit_root, with legacy-format normalization on write/clear. - Update git-hook and
preToolUseenforcement to evaluate marker relevance by repo match (and conservatively block when repo identity can’t be determined). - Expand documentation and regression tests to cover cross-repo isolation, dual-format migration, and conservative fallback behavior.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
tentacle.py |
Writes/clears repo-scoped marker entries and exposes enriched marker state for JSON consumers. |
hooks/check_subagent_marker.py |
Adds repo-scope evaluation and dual-format parsing for the primary git-hook enforcement path. |
hooks/rules/subagent_guard.py |
Adds repo-scope evaluation and dual-format parsing for the defense-in-depth preToolUse guard. |
test_tentacle_runtime.py |
Updates existing assertions for the new marker entry shape and adds extensive new-format/compat/isolation tests. |
test_hooks.py |
Adds end-to-end hook regression tests for dual-format markers, repo-scope behavior, and conservative fallbacks. |
docs/HOOKS.md |
Documents new marker schema, repo-scope enforcement semantics, migration behavior, and limitations. |
docs/USAGE.md |
Updates user-facing guidance for cross-repo isolation and migration behavior. |
README.md |
Updates high-level documentation to reflect repo-scoped blocking and migration notes. |
skills/tentacle-orchestration/SKILL.md |
Updates skill guidance to explain repo-scoped enforcement and migration/limitations. |
auto-update-tools.py |
Adds warnings prompting users to reinstall per-repo hooks after hook changes. |
install.py |
Adds post-install messaging reminding users to rerun --install-git-hooks after auto-update. |
Comment on lines
+2107
to
+2110
| if __name__ == "__main__": | ||
| unittest.main(verbosity=2) | ||
|
|
||
|
|
Comment on lines
+595
to
+600
| names.append(entry) | ||
| entries.append({"name": entry, "ts": None, "git_root": None}) | ||
| elif isinstance(entry, dict): | ||
| name = entry.get("name", "") | ||
| names.append(name) | ||
| entries.append(entry) |
Comment on lines
+221
to
+224
| > **Note:** The docstring in `is_marker_fresh()` says "Fail-open on any exception" but the | ||
| > outer exception handlers around the zombie check and repo-scope check both use `pass` | ||
| > (continue to block). Only structural errors before active-entries processing are fail-open. | ||
| > `subagent_guard.py` uses `return False` on its outermost exception, so it is fully fail-open. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
5 tasks
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.
Overview
This PR ships phase 4 of the dispatched-subagent guard rollout by isolating hook enforcement at the repository level instead of sharing one global block across unrelated repos.
The runtime marker now stores per-entry objects with
name,ts, andgit_root, and both enforcement surfaces accept old and new marker formats during migration. This removes the cross-repo false positive from phase 3 while keeping the same-repo multi-orchestrator case explicitly serialized and documented.Changes Made
tentacle.pycheck_subagent_marker.pyandsubagent_guard.pyto evaluate per-entry relevance with repo matching and conservative fallback behaviorauto-update-tools.pyandinstall.pyso users re-install per-repo git hooks after updatesModified files
README.mdauto-update-tools.pydocs/HOOKS.mddocs/USAGE.mdhooks/check_subagent_marker.pyhooks/rules/subagent_guard.pyinstall.pyskills/tentacle-orchestration/SKILL.mdtentacle.pytest_hooks.pytest_tentacle_runtime.pyDiff Summary
Validation
python3 -m pytest test_tentacle_runtime.py -q→ 206 passedpython3 test_hooks.py→ 379 passedKnown limitation