PolicyEngine / PolicyEngine/policyengine-household-api

Expose the resolved model/data release bundle in policyengine-household-api

Open
#1,458 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1
Forks
3
Avg merge
6h 34m
Merged PRs (30d)
8

Description

Problem

policyengine-household-api is the simplest downstream consumer of the country packages, which also means its provenance story is currently the thinnest.

Today it:

  • instantiates the installed country package Simulation(...) directly
  • reports or logs API version metadata for analytics
  • does not expose model/data bundle identity in household calculation responses
  • does not let callers observe which immutable dataset/model release actually produced a result

Relevant code paths:

  • installed package metadata and direct simulation construction: policyengine_household_api/country.py
  • persisted analytics/version fields: policyengine_household_api/data/models.py, policyengine_household_api/decorators/analytics.py
  • household endpoint response surface: policyengine_household_api/endpoints/household.py
  • OpenAPI spec currently documents API versioning, not full execution-bundle provenance: policyengine_household_api/openapi_spec.yaml

Desired contract

Even for household-level calculations, the API should expose the resolved immutable execution bundle.

At minimum that means returning or persisting:

  • country model package version
  • country data package version when relevant
  • resolved dataset or release-manifest identity if household calculations rely on default package data
  • a structured bundle field rather than only API version metadata

This is important both for user trust and for debugging when results drift across releases.

What should change

  1. Resolve and surface the runtime model/data bundle used for each calculation.
  2. Extend response schemas and OpenAPI docs to expose structured provenance.
  3. Persist the bundle identity anywhere cached or saved household results are stored.
  4. Keep existing api_version analytics if useful, but do not rely on it as the only provenance field.
  5. Ensure future automated country-package bumps preserve or update bundle metadata rather than just package versions.

Acceptance criteria

  • Household responses expose structured model/data bundle provenance.
  • OpenAPI documentation includes the new provenance fields.
  • Saved or cached household calculations can be tied back to the resolved execution bundle.
  • Existing analytics/version fields remain optional metadata, not the sole execution identity.
  • The service can reconstruct which model/data bundle produced a historical household result.

Upstream dependencies

This should consume the release contracts from:

  • PolicyEngine/policyengine-us-data#724
  • PolicyEngine/policyengine-uk-data#322

And stay aligned with:

  • PolicyEngine/policyengine.py#270

Contributor guide

Open the contributing guide

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.

Research direction

Start by tracing household calculation responses in policyengine_household_api/endpoints/household.py and the installed-package construction in policyengine_household_api/country.py. Then review persistence and analytics in data/models.py and decorators/analytics.py, plus the contract in openapi_spec.yaml and the listed upstream dependencies. Done means responses and saved or cached results expose structured model/data bundle provenance and the OpenAPI documentation describes it.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend, database
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.