Task: Avoid double IdP catalog fetch in policy-conflict check (#154)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 302
- Forks
- 107
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 41
Description
Context
Follow-up from a review nit on rossoctl/cortex#809 (pre-commit policy conflict diagnostic).
check_policy_conflicts (aiac/src/aiac/agent/uc/policy_check/check.py) calls
config.get_services() to derive service_type, and then resolve_focal_entities
(aiac/src/aiac/agent/shared/focal_entities.py) calls config.get_services() again
internally. That is two IdP catalog round-trips per check request where one would do.
Why it wasn't folded into rossoctl/cortex#809
resolve_focal_entities is shared with the live /apply builder path, and its docstring
deliberately forbids deriving service_type from focus.type (the caller routes on the
passed-in type to preserve the /apply contract). So the fix must not move the type lookup
into the resolver.
Proposed fix
Add an optional pre-fetched services parameter to resolve_focal_entities and thread the
already-fetched list through from check_policy_conflicts, keeping the /apply contract
byte-for-byte. (Caching the catalog on Configuration is an alternative, but the explicit
param keeps the seam obvious and testable.)
Acceptance
- Single
get_services()call perPOST /policy/checkrequest. - Live
/applypath and its 422 contract unchanged. - A test asserts the catalog call count (none currently does — noted in review).
Assisted-By: Claude (Anthropic AI) noreply@anthropic.com
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with aiac/src/aiac/agent/uc/policy_check/check.py and aiac/src/aiac/agent/shared/focal_entities.py, tracing the policy check and live /apply callers before running the relevant tests. Done means POST /policy/check makes one get_services() call, the catalog call count is covered by a test, and the live /apply path and its 422 contract remain unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend-api-design
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100