feat(governance): Add GovernancePlugin for runtime agent governance#102
feat(governance): Add GovernancePlugin for runtime agent governance#102sunilp wants to merge 2 commits intogoogle:mainfrom
Conversation
Adds policy-based tool filtering, delegation scope enforcement, and structured audit trails for ADK agents. Moved from google/adk-python#4897 per maintainer guidance.
Maps sunilp's PolicyEvaluator protocol (google/adk-python-community#102) to APS 3-signature policy chain (intent → decision → receipt). - APSPolicyEvaluator: evaluate_tool_call + evaluate_agent_delegation - APSPolicyDecision: duck-typed compatible with ADK's PolicyDecision - Wildcard scope expansion (tool:* → specific tool) - Monotonic narrowing enforcement for delegation - Full cryptographic proof chain in metadata - 16 tests, 3 suites, 102 total passing 102 tests, 0 failures.
|
Friendly bump — anything needed from my side to move this forward? Happy to address feedback or adjust the scope. |
|
@gemini-cli /review |
|
🤖 Hi @DeanChensj, I've received your request, and I'm working on it now! You can track my progress in the logs for more details. |
There was a problem hiding this comment.
Great start on the GovernancePlugin! It provides a solid foundation for runtime governance in ADK.
I've identified a few issues that should be addressed before merging:
- Missing Regex Argument Validation: The
allowed_arg_patternsinToolPolicyis defined but not enforced inbefore_tool_callback. This was mentioned as a key feature in the PR description. - Memory Growth in
_audit_log: The internal audit log list grows indefinitely, which could lead to memory leaks in long-running applications. - Interleaved Audit Events: Since
_audit_logis shared across invocations, events from different sessions will be mixed.
Please address these implementation details. Otherwise, the architecture looks sound and well-integrated with the ADK plugin system.
| Attributes: | ||
| action: The type of action being audited. | ||
| agent_name: The agent that triggered the action. | ||
| tool_name: The tool involved, if applicable. |
There was a problem hiding this comment.
The allowed_arg_patterns attribute is defined here but doesn't seem to be used in before_tool_callback. Was the implementation missed?
| agent_name=agent_name, | ||
| context=tool_context, | ||
| ) | ||
| if decision.decision == Decision.DENY: |
There was a problem hiding this comment.
Since _audit_log is shared across all invocations using this plugin instance, events from different sessions will be interleaved. If this is intended for a global audit trail, it's fine, but be aware of memory growth.
| ], | ||
| ) | ||
|
|
||
| await self._emit_audit( |
There was a problem hiding this comment.
Missing implementation for ToolPolicy.allowed_arg_patterns regex validation. The PR description and docstrings mention this feature, but the code doesn't enforce it here. It should probably be checked before or after the custom policy evaluator.
| governance decision point, queryable via standard logging or | ||
| custom audit handlers. | ||
|
|
||
| Example: |
There was a problem hiding this comment.
The _audit_log list grows indefinitely as it's never cleared. This could lead to a memory leak in long-running processes. Consider adding a way to clear it or using a bounded buffer if internal logging is desired.
Summary
Adds a
GovernancePluginthat provides runtime governance for ADK agents — policy-based tool filtering, delegation scope enforcement, and structured audit trails — without modifying agent logic.Moved here from google/adk-python#4897 per maintainer guidance (community plugins belong in this repo).
What it does
SELECT)PolicyEvaluatorprotocol for organization-specific rules; customAuditHandlerfor integration with logging/SIEM systemsUsage
Files
src/google/adk_community/governance/governance_plugin.py— plugin implementation (692 lines)src/google/adk_community/governance/__init__.py— public API exportstests/unittests/governance/test_governance_plugin.py— unit tests (577 lines)Testing plan
Related