feat: add universe and policy packages #5
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!5
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/universe-and-policy"
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?
also rename the go module
internal/universe — Driver interface plus a Registry for dispatching by universes.kind. Subjects, scopes, and a per-driver Vocabulary describe what a universe can do. The first concrete driver is ad_domain: it parses driver_config from the universes table, builds a WinRM Executor against the configured DC via an injected ExecutorFactory, and offers computer-subject enumeration in single and fleet scopes plus subject validation. Identifiers are character- whitelisted and single-quote-escaped before being interpolated into PowerShell. Fleet enumeration uses newline-separated stdout instead of JSON so PS 5.1's single-element-array unwrapping is irrelevant. internal/policy — two-lane policy: * advisory: a YAML loader producing a flat list of guidance strings for the LLM system prompt * mandatory: a small engine the rpcserver consults before executing an approved op. MVP rule — registered ops are required, read-only is always allowed, write ops require effective trust >= notify_all. Trust source is an interface so tests can fake it without spinning up Postgres. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>Automated review by pr-reviewer v0.15.0 | Full Review | anthropic | tracking id
r-dc79b0-eb751eThis is an AI-generated review and may contain mistakes.
Status: ✅ Completed
✅ Verdict: Approve — Well-architected implementation with comprehensive tests and good separation of concerns.
Complexity: complex
Review of PR #5: feat: add universe and policy packages
This PR adds significant new functionality with two major packages:
universe(for abstracting operation targets) andpolicy(for two-tier rule system), along with expanding the approval store. The implementation is well-architected with excellent test coverage.✅ Strengths
Architecture & Design
universeprovides a pluggable system for different target sourcesTrustSourceandOperationLookupSecurity & Safety
trustAtLeast()Test Coverage
dbtestpackage tests against actual Postgres📝 Minor Observations
Error Handling
The error handling is generally excellent, but there are a few areas worth noting:
Line 104 in
ad_domain.go: Error message could be more specific:Consider truncating very long stderr output to prevent log pollution.
Performance Considerations
Line 92-96 in
ad_domain.go: The fleet enumeration usesGet-ADComputer -Filter *which could be slow in large domains. Consider documenting this limitation or adding pagination for future enhancement.Documentation
The package documentation is excellent, particularly the clear explanation of the two-tier policy system and the Driver interface contract.
🔍 Technical Details
Module Rename
The module rename from
github.com/rcsheets/directory-pacifiertogit.brooktrails.org/brooktrails/directory-pacifieris properly handled with consistent import updates.Database Integration
TrustLevel,Decision)PowerShell Integration
🚀 No Issues Found
I found no bugs, security vulnerabilities, or architectural concerns. The code follows Go best practices, has excellent error handling, and comprehensive test coverage. The abstractions are well-designed and the implementation is production-ready.
The complexity rating reflects the significant architectural additions (new packages, interfaces, database integration) rather than any implementation concerns - this is high-quality code that adds substantial value to the project.
Automated review by pr-reviewer v0.15.0 | Full Review | anthropic | tracking id
r-dc79b5-08b840This is an AI-generated review and may contain mistakes.
Status: ✅ Completed
✅ Verdict: Approve — Well-structured additions with comprehensive policy and universe packages, solid test coverage, and proper separation of concerns.
Complexity: moderate
Code Review: Add universe and policy packages
This PR adds two substantial packages (
policyanduniverse) plus renames the Go module. The implementation demonstrates good architectural design with clear separation of concerns.✅ Positive Aspects
Strong Architecture & Design:
Driver,TrustSource,OperationLookup)Comprehensive Test Coverage:
Security-First Approach:
Code Quality:
🔍 Areas Reviewed
Universe Package (
internal/universe/):Policy Package (
internal/policy/):Approval Store Updates:
🎯 Minor Observations
The Go version
1.26.2in go.mod appears to be from the future, but this likely reflects development against a newer version and is not problematic.Some files lack corresponding tests (
internal/approvalstore/store.go,internal/policy/advisory.go, etc.), but the core functionality is well-covered through integration and unit tests.📋 Summary
This is a well-crafted addition that demonstrates solid software engineering practices. The code is secure, testable, and follows good architectural patterns. The policy system provides appropriate flexibility while maintaining necessary constraints, and the universe abstraction will support future extensibility.
The rename from
github.com/rcsheets/directory-pacifiertogit.brooktrails.org/brooktrails/directory-pacifieris handled cleanly throughout the codebase.