diff --git a/conformance/BUILD.bazel b/conformance/BUILD.bazel index 86d37cc..b0aef45 100644 --- a/conformance/BUILD.bazel +++ b/conformance/BUILD.bazel @@ -21,6 +21,7 @@ exports_files( ) _TEST_DIRS = [ + "agent_tool_execution_governance", "aggregate", "aggregate_explicit_list_output", "aggregate_explicit_optional_none", diff --git a/conformance/testdata/agent_tool_execution_governance/config.yaml b/conformance/testdata/agent_tool_execution_governance/config.yaml new file mode 100644 index 0000000..d695615 --- /dev/null +++ b/conformance/testdata/agent_tool_execution_governance/config.yaml @@ -0,0 +1,42 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: agent_tool_execution_governance +variables: + - name: "request.is_emergency" + type_name: "bool" + - name: "request.env" + type_name: "string" + - name: "tool.is_mutation" + type_name: "bool" + - name: "tool.call.args" + type_name: "map" + params: + - type_name: "string" + - type_name: "dyn" +functions: + - name: "hasCreditCard" + overloads: + - id: "hasCreditCard" + args: + - type_name: "dyn" + return: + type_name: "bool" + - name: "hasEmailOrPhone" + overloads: + - id: "hasEmailOrPhone" + args: + - type_name: "dyn" + return: + type_name: "bool" diff --git a/conformance/testdata/agent_tool_execution_governance/policy.yaml b/conformance/testdata/agent_tool_execution_governance/policy.yaml new file mode 100644 index 0000000..a8c0c01 --- /dev/null +++ b/conformance/testdata/agent_tool_execution_governance/policy.yaml @@ -0,0 +1,44 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: agent_tool_execution_governance +rule: + aggregate: + # Dimension 1: Approval Requirements (First-Match Escalation) + - rule: + match: + - condition: "request.is_emergency" + output: "'REQUIRE_VP_APPROVAL'" + - condition: "tool.is_mutation && request.env == 'prod'" + output: "'REQUIRE_TECH_LEAD_2FA'" + - condition: "tool.is_mutation" + output: "'REQUIRE_PEER_CONFIRMATION'" + + # Dimension 2: Data Redaction (First-Match Specificity) + - rule: + match: + - condition: "hasCreditCard(tool.call.args)" + output: "'REDACT_PCI'" + - condition: "hasEmailOrPhone(tool.call.args)" + output: "'REDACT_PII'" + + # Dimension 3: Rate Limiting (First-Match Threshold Ladder) + - rule: + match: + - condition: "tool.call.args.batch_size > 10000" + output: "'THROTTLE_TIER_3'" + - condition: "tool.call.args.batch_size > 1000" + output: "'THROTTLE_TIER_2'" + - condition: "tool.call.args.batch_size > 100" + output: "'THROTTLE_TIER_1'" diff --git a/conformance/testdata/agent_tool_execution_governance/tests.yaml b/conformance/testdata/agent_tool_execution_governance/tests.yaml new file mode 100644 index 0000000..ef4aa11 --- /dev/null +++ b/conformance/testdata/agent_tool_execution_governance/tests.yaml @@ -0,0 +1,72 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +description: "Tests governance policy evaluation with multi-dimensional aggregate rules" +section: + - name: "emergency_approval" + tests: + - name: "emergency_trumps_all_approval_rules" + input: + request.is_emergency: + value: true + request.env: + value: "prod" + tool.is_mutation: + value: true + tool.call.args: + expr: "{'batch_size': 50}" + output: + expr: "['REQUIRE_VP_APPROVAL']" + - name: "prod_mutation_with_pci_and_throttling" + tests: + - name: "prod_mutation_pci_tier2" + input: + request.is_emergency: + value: false + request.env: + value: "prod" + tool.is_mutation: + value: true + tool.call.args: + expr: "{'batch_size': dyn(1500), 'cc': dyn('411111111111')}" + output: + expr: "['REQUIRE_TECH_LEAD_2FA', 'REDACT_PCI', 'THROTTLE_TIER_2']" + - name: "dev_mutation_with_pii_and_tier1" + tests: + - name: "dev_mutation_pii_tier1" + input: + request.is_emergency: + value: false + request.env: + value: "dev" + tool.is_mutation: + value: true + tool.call.args: + expr: "{'batch_size': dyn(500), 'email': dyn('user@example.com')}" + output: + expr: "['REQUIRE_PEER_CONFIRMATION', 'REDACT_PII', 'THROTTLE_TIER_1']" + - name: "read_only_tool" + tests: + - name: "no_rules_matched" + input: + request.is_emergency: + value: false + request.env: + value: "prod" + tool.is_mutation: + value: false + tool.call.args: + expr: "{'batch_size': 10}" + output: + expr: "[]"