Define explicit cache ownership contracts through Phase 6
Maintainers usually reply within 1 day
Nobody has claimed this yet.
- #599 by @anth-volk — closed without merging
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
Start by reading the cache and parameter implementations in PolicyEngine Core, then map each cache to the Type A–E ownership and lifecycle requirements in the issue. Break the work into the listed cache, tracing, parameter, and branch behaviors, with deterministic unit and integration tests for the specified cases. Done means the acceptance criteria are met, including downstream migrations without cache-internal changes; Phase 7 remains deferred.
Written by the indexing model from the issue text.
Description
Context
PolicyEngine Core currently uses several caches with different ownership,
isolation, invalidation, and lifetime requirements. Some callers have modified
private cache fields directly because Core did not expose operations for the
required behavior. Parameter tracing also allowed request-specific tracer state
to become associated with reusable parameter views.
Scope
Define and implement the cache architecture through Phase 6:
- Document Type A model-definition state, Type B policy-system caching, Type C
parameter-at-date caching, Type D simulation input and result caching, and
Type E YAML-case execution reuse. - Add generic cache contracts for lifecycle, construction, bounded retention,
revision validation, and branch behavior. - Bound YAML policy-system retention and isolate each YAML case's execution
state. - Keep tracer state local to the active calculation and out of cached parameter
views. - Give parameter trees monotonic revisions, retain eager materialization as the
default, and provide an explicit lazy strategy. - Centralize supplied-input provenance and calculated-result invalidation.
- Allow branches to share immutable array values while retaining independent
indexes. - Expose public parameter replacement, sharing, materialization, and cache
clearing operations for country packages.
Phase 7, which would separate imported model definitions from policy and
execution state, remains outside this issue.
Downstream migrations
- PolicyEngine/policyengine-us#9978
- PolicyEngine/policyengine-uk#2175
Acceptance criteria
- AI-facing documentation specifies each cache type's owner, key, value,
lifetime, mutation rules, invalidation, concurrency, and uncached behavior. - Generic cache bases use typed key and value parameters and concrete caches
implement subsystem-specific behavior. - Every production commit adds at least 40 deterministic unit cases covering
standard behavior, rejected behavior, failure cleanup, copying, serialization,
concurrency, and edge cases. - Integration tests compare cached and uncached YAML execution and exercise
parameter mutation, tracing, simulation cloning, and branch isolation. - PolicyEngine US and PolicyEngine UK can migrate without modifying cache
internals. - Phase 7 remains deferred.
- Dominant language
- Python
- Stars
- 22
- Forks
- 30
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 22
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing 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.
More from PolicyEngine/policyengine-core
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
PolicyEngine/policyengine-core#549 ·
Maintainers usually reply within 1 day
-
`restore_simulation` silently drops memberless group entitiesPossibly taken @Adelagric claimed this 30 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
PolicyEngine/policyengine-core#547 ·
Maintainers usually reply within 1 day
-
Remove transitional cache access after country migrationsMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 5/5 Over a week Newbie friendliness 35/100
PolicyEngine/policyengine-core#602 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
PolicyEngine/policyengine-core#583 ·
Maintainers usually reply within 1 day
-
set_input for one period leaves the variable's cached sum or twelfth over an overlapping period in placePossibly taken @MaxGhenis claimed this 4 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 68/100
PolicyEngine/policyengine-core#579 ·
Maintainers usually reply within 1 day
All issues in PolicyEngine/policyengine-core
Similar issues
-
area:space-accuracy good first issue track:data
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Sara-Managed-Projects/space-radar#904 ·
Maintainers usually reply within 1 day