Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Define explicit cache ownership contracts through Phase 6

Open
#598 0 comments 0 reactions 0 assignees View on GitHub

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
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
backend

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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from PolicyEngine/policyengine-core

All issues in PolicyEngine/policyengine-core

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.