feat: add pluggable policy & taxonomy#5898
Conversation
|
Response from ADK Triaging Agent Hello @ViktorVeselov, thank you for creating this PR! We really appreciate your contribution implementing the pluggable Taxonomy & Policy Security Engine. To help us review and merge your changes more efficiently, could you please provide the following details from our contribution guidelines:
This context is very helpful for the reviewers to understand the fix and ensure high code quality. Thank you for your support! |
|
Hi @ViktorVeselov , Thank you for your contribution! We appreciate you taking the time to submit this pull request. |
Below is the requested testing context, including the complete summary of the passed unit tests under
|
Gotcha, I will see what we can do there then. I'd assume that I got positive feedback from you tho? |





Have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
Problem:
Developers and system administrators need a robust, standardized way to enforce security policies and access controls on skills based on organizational hierarchies and taxonomies (e.g., flat department structures or rich SKOS JSON-LD classifications). Currently, the SDK lacks an extensible, out-of-the-box plugin architecture that intercepts skill listings and execution checks to apply context-aware taxonomy validation. Additionally, taxonomy can be used and/or executed as a more deterministic task handler without taking away LLM's decision-making. This taxonomy can be used to empower existing systems, and, for example, can be applied to AntigravityCLI if needed.
Solution:
The initial design referred to embedding the design/taxonomy directly into the core SDK; instead of that, it pivoted to plugins. As a result, the following is true: Implemented a fully pluggable, opt-in Taxonomy & Policy Security Engine (as a
TaxonomyPlugin(BasePlugin)). Key design points include:Frontmattermodel to parsetaxonomy-bindsnatively, reusing the SDK's existing path segment guards under the hood._TAXONOMY_BIND_PATTERNas a pre-compiled module-level immutable constant for maximum speed and security.TaxonomyRegistrycleanly parses both standard Flat Key-Value JSON (id/parentId/name/definition) and rich JSON-LD with SKOS (Concept,prefLabel,altLabel,definition,broader) standards to resolve organizational hierarchies.TaxonomyPipelineandTaxonomyResolverinterfaces to dynamically chain multiple contextual policy resolvers (e.g., checking user roles, entitlements, and classification rules) during runtime execution.list_skillsandis_skill_allowedhooks, keeping lists in the expected dictionary-wrapped XML response structure.Testing Plan
Unit Tests:
Comprehensive Test Suite Executed:
Added and verified 53 passing test cases under the native
pytestframework, including:test_taxonomy_plugin.py(6 cases): Validates full parsing of Flat and SKOS JSON-LD structures, asyncTaxonomyPipelinechaining,DefaultSkillPolicyset-intersection filtering, and interceptivebefore_tool_callbacklisting logic.test_models.py(4 cases): Validatestaxonomy-bindsaliases, list item validation, rejection of invalid tags (e.g. strings containing spaces), and serialization format.test__utils.py(1 case): End-to-end load tests validating YAML frontmatter mapping withinSKILL.mdparser loops.Note
Environmental Package Mock Details:
Due to a pre-existing dependency issue where the installed
google-genailibrary lacks the expectedAvatarConfigattribute in certain environments, I pre-emptively mockedgoogle.genai.types.AvatarConfig(inheriting frompydantic.BaseModel) directly insidetests/unittests/conftest.py.This ensures that the test runner bypasses system-level schema compilation issues and allows the entire unit test suite to compile cleanly in any CI/CD or local environment, while remaining focused on validating our functionalities.
Manual Tests:
To manually verify the taxonomy filter pipeline:
DefaultSkillPolicy:taxonomy-bindsto your skill's frontmatter configuration:list_skillswith a dynamic context (e.g. passing a user identity or role insidetool_context) and observe that skills bound to unauthorized taxonomies are securely filtered out of the response.Important
Request for Thorough Verification and Security Auditing:
As this engine controls dynamic skill execution visibility, it acts as a primary security container boundary. It rprefered that reviewers thoroughly review and test:
Checklist
Additional context
dictexpected by__build_response_event.