PolicyEngine / PolicyEngine/policyengine-app-v2

Preserve and use resolved model/data provenance in policyengine-app-v2

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

Nobody has claimed this yet.

Dominant language
HTML
Stars
1
Forks
3
Avg merge
1d 50m
Merged PRs (30d)
39

Description

Problem

policyengine-app-v2 already carries some version-ish metadata, but it does not preserve or render a full immutable execution bundle for reports and simulations.

Current gaps:

  • the old metadata flow uses a single opaque version mostly as a load sentinel, not as reproducibility provenance
  • report and simulation domain models preserve apiVersion, but not model/data release identity
  • v2 request builders know about dataset IDs, but adapters drop provenance when hydrating responses into domain models
  • the reproducibility tab reconstructs code from current metadata defaults and floating dataset conventions instead of the report’s actual resolved bundle
  • there is still app-side reliance on “latest” model-version helpers for flows that should be historical and pinned

Relevant code paths include:

  • metadata loading and guard logic: app/src/api/metadata.ts, app/src/types/metadata.ts, app/src/reducers/metadataReducer.ts, app/src/routing/guards/MetadataGuard.tsx
  • report/simulation models and adapters: app/src/types/ingredients/Report.ts, app/src/types/ingredients/Simulation.ts, app/src/adapters/ReportAdapter.ts, app/src/adapters/SimulationAdapter.ts
  • v2 hydration points: app/src/api/v2/reportFull.ts, app/src/api/v2/simulations.ts, app/src/api/v2/economyAnalysis.ts
  • reproducibility UI and code generation: app/src/pages/report-output/SocietyWideReportOutput.tsx, app/src/pages/report-output/reproduce-in-python/PolicyReproducibility.tsx, app/src/utils/reproducibilityCode.ts
  • latest-version helper: app/src/api/v2/taxBenefitModels.ts

Desired contract

Once downstream APIs expose a structured execution bundle, the app should:

  • preserve that bundle in report/simulation domain objects
  • render it where users expect reproducibility information
  • use it when generating reproduce-in-Python code
  • stop reconstructing historical provenance from mutable “latest” metadata

At minimum the app should retain and display:

  • model package/version
  • data package/version
  • resolved dataset artifact or manifest revision
  • bundle or manifest ID if available

What should change

  1. Extend app domain models and adapters to preserve structured release provenance from API responses.
  2. Hydrate provenance at the report/simulation fetch layer instead of dropping it.
  3. Update the reproduce tab to generate code from the report’s actual resolved bundle, not current Redux defaults.
  4. Add a small provenance display on relevant report/simulation output pages.
  5. Remove reliance on app-side “latest” resolution for historical reports and replay flows.
  6. Keep backward compatibility for older saved objects where possible, but prefer server-supplied pinned provenance whenever available.

Acceptance criteria

  • Report and Simulation objects retain structured model/data provenance from API responses.
  • Historical report pages render or otherwise surface the resolved execution bundle.
  • Reproduce-in-Python uses the resolved bundle from the report/simulation being viewed.
  • App-side latest-version helpers are not used for replay or historical provenance.
  • Client-side caching and saved-object hydration do not discard release-bundle metadata.

Upstream dependencies

This depends on API/schema work in:

  • PolicyEngine/policyengine-api#3393
  • PolicyEngine/policyengine-api-v2#434
  • PolicyEngine/policyengine-api-v2-alpha#219

And on the data/orchestration contracts in:

  • PolicyEngine/policyengine-us-data#724
  • PolicyEngine/policyengine-uk-data#322
  • 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 reading the report and simulation models and adapters, then trace hydration through app/src/api/v2/reportFull.ts, simulations.ts, and economyAnalysis.ts. Review the reproducibility components and app/src/utils/reproducibilityCode.ts alongside the upstream API dependencies. Done means resolved provenance survives hydration, appears in historical output, and drives reproduce-in-Python without latest-version reconstruction.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.