refactor(guardrails): own the rule descriptor and hash, drop responsecache import#473
Conversation
…cache import GuardrailRuleDescriptor and ComputeGuardrailsHash were defined in responsecache although they are guardrail-domain concepts, forcing the guardrails package to depend on the cache layer. Move them into guardrails (descriptor renamed to RuleDescriptor to avoid package stutter); the cache keeps consuming the hash as an opaque context value, which was already the only way it received it. No behavior change; hash tests move with the code. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (8)
💤 Files with no reviewable changes (2)
📝 WalkthroughWalkthroughGuardrail rule descriptor hashing is relocated from internal/responsecache to a new internal/guardrails/hash.go module, introducing RuleDescriptor and ComputeGuardrailsHash. All producers (definitions.go, registry.go) and consumers (admin and workflows tests) are updated to reference the guardrails package instead of responsecache, with the old type/function and their tests removed. ChangesGuardrails Hash Relocation
Estimated code review effort: 2 (Simple) | ~12 minutes Sequence Diagram(s)sequenceDiagram
participant Caller as Registry Consumer
participant Registry as guardrails.Registry
participant Hash as guardrails.ComputeGuardrailsHash
Caller->>Registry: Register(guardrail, RuleDescriptor)
Registry->>Registry: store descriptor
Caller->>Registry: BuildPipeline(references)
Registry->>Registry: collect []RuleDescriptor
Registry->>Hash: ComputeGuardrailsHash(descriptors)
Hash-->>Registry: pipeline hash
Registry-->>Caller: pipeline + hash
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Summary
Fixes a dependency inversion found in the architecture review (see
docs/dev/2026-07-04_architecture-review.mdon #472):GuardrailRuleDescriptorandComputeGuardrailsHashwere defined inresponsecachealthough they are guardrail-domain concepts, which forcedguardrails(a domain package) to import the cache layer.internal/guardrails(hash.go); the descriptor is renamedRuleDescriptorto avoidguardrails.GuardrailRuleDescriptorstutter.responsecachenever used them in production code — the hash reaches the cache as an opaque context value (core.WithGuardrailsHash), which is unchanged. The cache's context helpers stay put.workflows/admintest references updated.guardrailsno longer importsresponsecacheat all (verified viago list).User-visible impact
None. Identical hash algorithm and wiring; pure ownership move.
Testing
Full
go build ./...andgo test ./...pass; pre-commitmake test-raceran on the commit.🤖 Generated with Claude Code
Summary by CodeRabbit