feat: Add typed approvalstore client for the approval-store schema #3
No reviewers
Labels
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
brooktrails/directory-pacifier!3
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/approvalstore-client"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Provides one INSERT-per-action surface over schema/001-003: ProposePlan,
ExpandOperation, Decide, RecordExecution, GrantTrust, plus view-backed
ListPendingPlans / ListApprovedReadyToExecute / LookupEffectiveTrust.
Content hashes are computed by the client (via internal/contenthash) so
callers cannot diverge from the canonical form.
Integration tests exercise each method under the appropriate Postgres
role via SET LOCAL ROLE inside a transaction, confirming that role grants
are enforced end-to-end through the typed surface. Client-side input
validation (decision/expires_at, empty JSON, expected_target_count) is
covered without touching a DB.
Extend the schema-test CI job to run the new integration tests alongside
the existing dbtest suite.
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com
Automated review by pr-reviewer v0.15.0 | Safety Check | anthropic | tracking id
r-dc70f9-9ea3e1This is an AI-generated review and may contain mistakes.
Status: ✅ Completed
✅ Verdict: LGTM — Nothing alarming found - this is a well-structured database client with comprehensive tests and proper role-based access controls.
Complexity: moderate
This PR adds a typed Go client for an approval-store database schema with proper role-based access control validation.
Key observations:
SET LOCAL ROLESecurity considerations reviewed:
Data integrity:
The code quality is high with proper error handling, comprehensive tests, and clear separation of concerns. The integration test approach using role switching is particularly well done.
Automated review by pr-reviewer v0.15.0 | Safety Check | anthropic | tracking id
r-dc7170-81d022This is an AI-generated review and may contain mistakes.
Status: ✅ Completed
✅ Verdict: LGTM — This is a well-structured database client implementation with comprehensive integration tests and proper role-based security enforcement.
Complexity: moderate
Safety Check Review
This PR adds a typed Go client for the approval-store schema with comprehensive integration tests. The code is well-structured and follows good practices:
Positive Observations
SET LOCAL ROLENo Alarming Issues Found
The 1000+ lines of new code are legitimate implementation and comprehensive tests, not vendored dependencies. The CI integration properly extends existing schema tests.
Automated review by pr-reviewer v0.15.0 | Full Review | anthropic | tracking id
r-dc718b-2a1cb8This is an AI-generated review and may contain mistakes.
Status: ✅ Completed
✅ Verdict: Approve — This is a well-architected, comprehensive typed client library with excellent test coverage and security considerations.
Complexity: moderate
Code Review: Typed approvalstore client
This PR introduces a comprehensive typed Go client for the approval-store schema. The implementation is well-designed with strong security practices and thorough test coverage.
Strengths
Architecture & Design
DBTXinterface allows flexible usage with pools, connections, or transactionsInput Validation & Error Handling
Test Coverage
TestFullLifecycleexercises the complete propose→expand→decide→execute flow using actual Postgres rolesTestRoleEnforcementconfirms database-level access controls work through the typed interfaceCode Quality
DecisionandTrustLevelvaluesrows.Close()Technical Implementation Notes
PostgreSQL Integration
durationToInterval/intervalToDurationconversion properly handles the impedance mismatch between Go and Postgres time representationsJSON Handling
validateJSONfunction prevents empty JSON while allowing flexible contentrawOrNilhelper properly handles optional JSON fieldsjson.RawMessagefor deferred parsingMinor Observations
Line 300: The comment about "lossy but harmless approximation" for interval conversion is well-documented and appropriate for the use case
Lines 79, 142: Client-side validation provides good user experience by catching common errors early
Test structure: The role-switching pattern with
SET LOCAL ROLEin transactions is elegant and provides strong end-to-end validationCI Integration
The workflow changes properly extend the schema-test job to include the new integration tests, maintaining the existing database setup while expanding coverage.
Verdict
This is high-quality code that follows Go best practices and implements a secure, well-tested database client. The role-based security model is properly implemented, the test coverage is comprehensive, and the code is maintainable and well-documented. Ready to merge.