feat(types): add Fiduciary Circuit Breaker risk extension#165
feat(types): add Fiduciary Circuit Breaker risk extension#165ravyg wants to merge 1 commit intogoogle-agentic-commerce:mainfrom
Conversation
Summary of ChangesHello @ravyg, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Agent Payments Protocol (AP2) by integrating a Fiduciary Circuit Breaker (FCB) extension. This new capability provides a crucial layer of runtime governance, allowing for real-time monitoring of autonomous agent behavior beyond static mandate checks. By defining clear risk signals, a state-based control mechanism, and human escalation protocols, the FCB aims to proactively mitigate anomalous or high-risk transactions, thereby increasing trust and security within the agentic commerce ecosystem. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a Fiduciary Circuit Breaker (FCB) risk extension, a significant feature for runtime governance of agent transactions. The changes are comprehensive, including new types for both Python and Go, extensive documentation, and thorough test suites for both languages. The implementation quality is very high across the board. The code is clean, well-structured, and idiomatic. The documentation is clear and detailed, and the tests cover a wide range of cases including unit, serialization, and complete end-to-end scenarios. My review includes a few minor suggestions for the Go implementation to add comments to exported struct fields, enhancing clarity and aligning them with the well-documented Python models. Overall, this is an excellent contribution.
This PR implements structured risk types for AP2 Section 7.4 (Risk Signals), which was "intentionally left open-ended" in the v0.1 specification. The Fiduciary Circuit Breaker (FCB) pattern provides runtime governance for autonomous agent transactions through: - Trip conditions that evaluate agent behavior against predefined thresholds (VALUE_THRESHOLD, CUMULATIVE_THRESHOLD, VELOCITY, ANOMALY, etc.) - A state machine for governance (CLOSED → OPEN → HALF_OPEN → TERMINATED) - Human escalation protocol for exceptional cases - Structured risk signals for network/issuer visibility Changes: - Add src/ap2/types/risk.py with Python type definitions - Add samples/go/pkg/ap2/types/risk.go with Go type definitions - Add docs/topics/fiduciary-circuit-breaker.md with documentation - Update src/ap2/types/__init__.py to export new types - Update mkdocs.yml to include FCB in navigation This addresses the gap identified in Section 7.4 where temporal gaps, user asynchronicity, and agent identity verification require runtime governance beyond what mandate-based authorization provides.> Add comprehensive unit tests for the Fiduciary Circuit Breaker (FCB) risk extension types: Go tests (samples/go/pkg/ap2/types/risk_test.go): - 11 tests covering type constants, helper methods, JSON serialization - Tests for NewHumanEscalation, NewFCBEvaluation, AddTripResult - Complete integration scenario test Python tests (tests/test_risk.py): - 22 tests covering all enum types and Pydantic models - JSON round-trip serialization tests - B2B quote negotiation integration scenario Also includes minor formatting fix to risk.go (whitespace alignment).
|
@holtskinner @joshlund-goog please review, thanks! |
Summary
Adds structured risk signal types for AP2 Section 7.4 (Risk Signals), introducing a Fiduciary Circuit Breaker (FCB) pattern for runtime governance of autonomous agent transactions.
FCB enables standardized trip conditions, state-based controls, and human escalation to mitigate risky or anomalous behavior beyond mandate-based authorization.
Changes
src/ap2/types/risk.pysamples/go/pkg/ap2/types/risk.godocs/topics/fiduciary-circuit-breaker.mdsrc/ap2/types/__init__.pymkdocs.ymlFeatures
CLOSED → OPEN → HALF_OPEN → TERMINATEDTests
risk.goCompatibility
Additive only — no breaking changes.
Fixes #163