feat(core): bounded O(1) risk aggregator with normalized context + extended tests#21
Open
Ananya44444 wants to merge 2 commits intoc2siorg:mainfrom
Open
feat(core): bounded O(1) risk aggregator with normalized context + extended tests#21Ananya44444 wants to merge 2 commits intoc2siorg:mainfrom
Ananya44444 wants to merge 2 commits intoc2siorg:mainfrom
Conversation
…and extensibility guards
There was a problem hiding this comment.
Pull request overview
Adds a new Python-side “risk context” contract and deterministic O(1) risk aggregation helper intended to produce an OPA-compatible input object, along with a dedicated test suite validating shape, normalization, determinism, and score bounds.
Changes:
- Introduces
acf.sdk_integration.risk_contextwith fixed-signal normalization, weighted scoring, and hook/provenance adjustments. - Adds
acf.sdk_integrationpackage exports for the new aggregator surface. - Adds pytest coverage for structure, normalization, determinism, and defaulting behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| sdk/python/acf/sdk_integration/risk_context.py | Implements RiskContext + aggregate_risk with fixed-size normalization and scoring. |
| sdk/python/acf/sdk_integration/init.py | Exposes RiskContext and aggregate_risk as package-level API. |
| sdk/python/tests/test_risk_context.py | Adds tests for shape/normalization/determinism/score bounds for the new aggregator. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
Implemented a deterministic, O(1) Risk Aggregator that produces a normalized RiskContext aligned with the Phase-1 architecture.
Added explicit weighted scoring model with bounded signal set
Enforced signal normalization and schema constraints to preserve fast-path guarantees
Introduced provenance-aware scoring hooks (non-breaking for v1, extensible for v2)
Added guardrails for fixed signal vector to prevent unbounded growth
Included hook-aware placeholders for future policy tuning without affecting current latency
Tests:
Covered structure, normalization, determinism, and score bounds
Added edge cases for missing/invalid signals
Ensured OPA-compatible input format ({"input": RiskContext})
This keeps the aggregator strictly within the fast-path constraints (<10ms) while aligning with the taxonomy-driven policy layer.