Skip to content

fix(agent-guard): discover contributed skill guards under plugins/*/skills/*/guards - #1757

Open
Kaap10 wants to merge 2 commits into
apache:mainfrom
Kaap10:fix/agent-guard-plugin-guards-discovery
Open

Kaap10 wants to merge 2 commits into
apache:mainfrom
Kaap10:fix/agent-guard-plugin-guards-discovery

Conversation

@Kaap10

@Kaap10 Kaap10 commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

While exploring the agent-guard dispatcher and auditing how pre-execution hooks discover skill guards across different harnesses, I noticed that agent_guard.discover_guards() was returning only 1 guard (no_verify_commit.py from guards.d/), completely omitting the domain-specific safety guards documented in the README (mention, mark_ready, and security_language).

Tracking down the discovery logic, guard_dirs() was still scanning (root / "skills").glob("*/guards"). Following the modular plugin migration (#1087 / #1672), canonical guards live under plugins/*/skills/*/guards. On checkouts where skills/* entries are symlinks (or in adopter repositories deploying plugins directly without top-level symlink mirrors), the glob returned empty and the guards silently dropped.

Summary

  • Extend agent_guard.guard_dirs() to discover contributed skill guards under plugins/*/skills/*/guards in addition to skills/*/guards (retaining backwards compatibility).
  • Update framework_root() to recognize either skills/ or plugins/ sitting beside tools/agent-guard.
  • Deduplicate discovered guard directories using d.resolve() so environments exposing both canonical plugin paths and skills/ symlinks do not register duplicate guard instances.
  • Align tools/agent-guard/tests/test_skill_guards.py and test_discovery.py with canonical plugin directories, cross-platform path handling, and new regression unit tests.

Type of change

  • Python package (tools/*/ with pyproject.toml)
  • CI / dev loop (prek, workflows, validators)

Test plan

  • ruff check and ruff format --check pass with zero warnings across all touched files.
  • mypy --platform linux tools/agent-guard/src/agent_guard passes (Success: no issues found in 3 source files).
  • pytest tools/agent-guard/tests/test_skill_guards.py tools/agent-guard/tests/test_discovery.py passes cleanly (87 passed, 2 skipped on Windows non-admin symlink privileges).
  • Regression tests added:
    • test_plugin_skill_guards_are_discovered()
    • test_guard_dirs_deduplicates_symlinks()
  • Verified in Python: agent_guard.discover_guards() discovers all 4 active guards (no_verify_commit, mention, mark_ready, security_language).

RFC-AI-0004 compliance

  • Sandbox — ensures pre-execution action guards are reliably active across all harnesses and plugin environments.

Linked issues

Fixes #1756

@github-actions github-actions Bot added family:tools tools/* substrate:action-guard Tool substrate: deterministic pre-tool-use command guards labels Oct 21, 2026
@Kaap10
Kaap10 force-pushed the fix/agent-guard-plugin-guards-discovery branch from cad5280 to 88d986e Compare October 21, 2026 14:42
@github-actions github-actions Bot added family:setup setup-* skills capability:platform Framework / agent substrate skills (install, verify, doctor, override, status, setup bootstrap) labels Oct 21, 2026
@Kaap10

Kaap10 commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

Hi @potiuk - while auditing agent-guard hook discovery across runtimes, I noticed discover_guards() only returned the single builtin guard (no_verify_commit.py) and missed the canonical domain guards (mention, mark_ready, security_language).

Post-modularization (#1087 / #1672), guards live under plugins/*/skills/*/guards, but guard_dirs() was still scanning skills/*/guards. On checkouts where skills/* are symlinks (or in adopter setups without top-level symlink mirrors), the glob silently returned empty.

This PR adds plugin guard discovery, hardens directory deduplication with d.resolve(), aligns test paths, and adds regression tests.

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) family:setup setup-* skills family:tools tools/* substrate:action-guard Tool substrate: deterministic pre-tool-use command guards

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(agent-guard): guard_dirs() fails to discover contributed skill guards under plugins/*/skills/*/guards

1 participant