Skip to content

Phase 4: Isolate subagent hooks by repo#9

Merged
magicpro97 merged 2 commits into
mainfrom
dev/fpt/fix/repo-hook-isolation
Apr 22, 2026
Merged

Phase 4: Isolate subagent hooks by repo#9
magicpro97 merged 2 commits into
mainfrom
dev/fpt/fix/repo-hook-isolation

Conversation

@magicpro97
Copy link
Copy Markdown
Owner

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, and git_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

  • Added repo-scoped marker entries and legacy-upgrade handling in tentacle.py
  • Updated check_subagent_marker.py and subagent_guard.py to evaluate per-entry relevance with repo matching and conservative fallback behavior
  • Added rollout messaging in auto-update-tools.py and install.py so users re-install per-repo git hooks after updates
  • Updated README, HOOKS, USAGE, and the tentacle-orchestration skill to document migration behavior and known limitations
  • Expanded runtime and hook regression coverage for cross-repo isolation, legacy absorption, and fail-conservative repo matching
Modified files
  • README.md
  • auto-update-tools.py
  • docs/HOOKS.md
  • docs/USAGE.md
  • hooks/check_subagent_marker.py
  • hooks/rules/subagent_guard.py
  • install.py
  • skills/tentacle-orchestration/SKILL.md
  • tentacle.py
  • test_hooks.py
  • test_tentacle_runtime.py

Diff Summary

11 files changed, 1769 insertions(+), 109 deletions(-)

Validation

  • python3 -m pytest test_tentacle_runtime.py -q → 206 passed
  • python3 test_hooks.py → 379 passed
  • Final code review verdict: CLEAN

Known limitation

  • Same-repo multi-orchestrator is still not supported. This PR only fixes cross-repo false positives.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 22, 2026 04:37
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-level git_root, with legacy-format normalization on write/clear.
  • Update git-hook and preToolUse enforcement 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 thread test_tentacle_runtime.py Outdated
Comment on lines +2107 to +2110
if __name__ == "__main__":
unittest.main(verbosity=2)


Comment thread tentacle.py
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 thread docs/HOOKS.md Outdated
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>
@magicpro97 magicpro97 merged commit dedaf22 into main Apr 22, 2026
@magicpro97 magicpro97 deleted the dev/fpt/fix/repo-hook-isolation branch April 22, 2026 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants