Skip to content

v3's Household tab on the detailed-save API, unused until v3 moves to the /v2/ routes - #1611

Draft
anth-volk wants to merge 46 commits into
v2plan/1e-113-household-report-saved-householdsfrom
v2plan/d2-3-household-tab-detailed-save
Draft

anth-volk wants to merge 46 commits into
v2plan/1e-113-household-report-saved-householdsfrom
v2plan/d2-3-household-tab-detailed-save

Conversation

@anth-volk

@anth-volk anth-volk commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #1609

Stacked on #1392.

What changes

v3's Household tab gets its calculation code on API v1's /v2/ routes (the detailed-save API). It sits behind V3_API_ROUTES (app/src/libs/flagship/v3ApiRoutes.ts), which stays 'v1', so users see no change: every new path runs only when that constant is 'v2', and on 'v1' the tab calculates through v1's household routes as today.

Calculations (api/v2HouseholdCalculations.ts, api/v2Polling.ts, api/v2Households.ts, libs/flagship/v2HouseholdRun.ts):

  • The household is stored once with POST /v2/households, for the report's year (its default_year), as it is sent: as householdAsSent (v3 standalone household report and saved households, unreachable until v3 moves to the v2 routes #1392) prepares it, so a UK household carries its claimant and partner roles (v2CreateBodyFromV1Payload of the run's payload, the one the v1 run sends). It is then calculated under the baseline and the reform at once with POST /v2/household-calculations, each adding every variable the household lacks, as v1's household routes do.
  • Each calculation is read with GET /v2/household-calculations/{id} every 2 seconds, for at most 10 minutes. The submission answers with the calculation's state alone, so one that has already finished is read once at once. A read that fails with 503 or no answer is asked again up to 3 times, the read after a finished submission included; a submission is never sent again. Both calculations wait on one abort signal, which each request is handed, so when one fails, or the page no longer needs the result, the other is no longer read.
  • Current law (no ID, or the catalog's current-law ID) is sent as no policy, and a reform by its v2 policy ID. A policy known only by its v1 number fails the run, saying so, rather than being calculated as current law.
  • The calculated household comes back keyed by record IDs; householdDataFromV2Calculation gives it its v1 names (source_name), so every reader of a v1 run keeps working. Each side's provenance is its policyengine_version and country_package_version (as model_version), with its SPM settings and receipt.
  • Failures read as on v1: no answer from API v1 says PolicyEngine could not be reached, and a wait past its limit says the calculation took too long; an answer the app could not read keeps its own reason.
  • useRequestedHouseholdRun, which the Household tab and the standalone household report share, picks the run by V3_API_ROUTES. On v2, the stored household goes into the query cache (v2StoredHouseholdKeys), where the variation reads it, and the caller hears its v2 ID once it is stored, as on v1.
  • The saved-household store from v3 standalone household report and saved households, unreachable until v3 moves to the v2 routes #1392 now sends its POST and GET of /v2/households through api/v2Households; its requests are unchanged.

Variation charts (hooks/useV2HouseholdVariation.ts, components/flagship/report/household/V2HouseholdVariation.tsx, HouseholdBreakdowns.tsx): on v2, Varying earnings and Marginal tax rates calculate the stored household across its head's earnings under each policy, with one axes group (v2EarningsVariationAxes: employment_income from 0 to the variation's maximum, 401 points, for the head by position among the stored people). The two calculations are handed to the existing pages through their baselineVariation and reformVariation props, so the pages send nothing and no policy's parameters load. HouseholdVariationKeeper, which the tab starts once the household is stored (and the standalone report when a chart first opens), runs the same two calculations under the same query key (v2HouseholdVariationKeys), so opening a chart calculates nothing more. A failed variation shows its reason with Try again.

SPM geography choice (api/publicApi/modelCatalog.ts): on v2 the model metadata's spm comes from /v2/model-catalog's spm, so the US household builder offers the choice exactly when the catalog version does.

Variables: #1392 now wraps the standalone household report in V3VariablesGate, and ReportView already waits for the Household tab, so this PR changes neither page's wait. It adds tests that a failed load of v3's variables says so with Try again on the standalone report, and that the household builder panel leaves the wait to its callers (HouseholdReportVariables.test.tsx), and the report's note now says it calculates through /v2/household-calculations once V3_API_ROUTES is 'v2'.

Saved households (api/flagshipHouseholdStore.ts): each household the tab calculates on v2 is saved to the user in the background as a /v2/user-households row with household_id (looked up by household_id first, so a household is saved once per user), named with its summary, as #1505 saves v1 households by legacy_household_id. Nothing reachable shows these rows. /v2/households returns the existing household for identical content, so the same inputs calculated again name the same row. The body is #1392's UserHouseholdCreateBody; the v1-only copy in types/v2User is gone.

Same-origin route (libs/publicApiRoute/allowList.ts): the calculator's route to API v1 now forwards POST /v2/household-calculations and GET /v2/household-calculations/{id}, not cached. #1392 forwards the stored-household routes this code also calls. Nothing sends the new ones while V3_API_ROUTES is 'v1'.

Before the switch

  • ApiSavedHouseholdStore.list (v3 standalone household report and saved households, unreachable until v3 moves to the v2 routes #1392) lists every /v2/user-households row of the user, so after the switch the rows saved in the background here, and v3 households: save each calculated household to its user, shown nowhere #1505's v1 rows, would show in "Your households". API v1's rows have no field to tell them apart; how the list treats them is to be decided before the switch.
  • The policies the tab names on v2 are created elsewhere (v2ReformPolicyBody in api/reformStore.ts), which keeps gov.simulation and US simulation values out of them in a later change. This PR sends no policy body.
  • Model assumptions on household pages (dynamic_id) come later.
  • The model catalog's spm.available is null while catalog publication has not recorded a version's SPM support; that reads as not available, so a US household with SPM settings is refused for such a version, as before this change.

Tests

New or changed, each run on its own by name (bun run vitest -- <file> -t "<name>"), failing first for the reason given, then passing:

  • v2DocumentCodec.test.ts (5 new): names from source_name, record IDs kept without one, a record the household lacks named; a body from a household's own payload, and none without a year. Red: not a function.
  • v2Polling.test.ts (10, new file): reads until finished, first read, abort while waiting and while reading, time limit, transient retries, a refused read, a submission not sent again. Red: module missing.
  • v2HouseholdCalculations.test.ts (14, new file): request bodies, polling to success, a finished submission read once and asked again after a 503, failure reason and code, API v1's refusals, aborts, time limit. Red: module missing (the retry after a finished submission: the 503 rejected).
  • v2Households.test.ts (3, new file). Red: module missing.
  • v2HouseholdRun.test.ts (20, new file): one store and two calculations, the household stored as sent, the stored household handed over before calculating, v1 names and changes, one calculation for one policy, provenance, failures, the other calculation no longer read after one fails, plain errors, another year sending nothing, v2PolicyIdFor, plainV2HouseholdError, spmOfV2Calculation. Red: module missing (an unreadable answer: it read "Could not reach PolicyEngine").
  • allowList.test.ts (2 forwarded routes, 3 refused neighbours, and the two coverage tests). Red: the two routes and both coverage tests; the refusals passed before and after.
  • modelCatalog.test.ts (2 new), SPMGeographyChoiceV2.test.tsx (2, new file). Red: no spm in the metadata; the "without SPM settings" choice test passed before and after.
  • flagshipHouseholdStore.test.ts (2 new, 1 changed), useFlagshipHousehold.test.tsx (1 new). Red: "is not a v1 household"; the refusal test passed before and after.
  • householdVariationAxes.test.ts (2 new). Red: not a function. The "you" test stores "you" second, and fails with the fallback taken out.
  • queryKeys.test.ts (3 new). Red: undefined.
  • useRequestedHouseholdRunV2.test.tsx (5, new file), useRequestedHouseholdRunV1.test.tsx (1, new file). Red: on v2 the v1 path ran (the household as sent: the run was given the described household); the v1 test passed before and after.
  • HouseholdBreakdownsV2.test.tsx (8, new file): requests with axes and every variable, the pages given both variations, progress, Try again, one pair of calculations for both charts, baseline-only, the stored household read from the cache, the background variation read by the charts. Red: the v1 path ran.
  • UKHouseholdClaimantRolesV2.test.tsx (1, new file): a UK lone parent and their adult child are stored as claimant and dependant, not a couple. Fails with the hook as it was before the household was stored as sent (no role stored).
  • HouseholdImpactSectionV2.test.tsx (2, new file): Calculate on the tab stores once, calculates under both policies, starts both variations, and saves by the v2 ID. Written after the code it covers, so it passed at once; with the background variation on the v1 path it fails (2 calculations, not 4).
  • HouseholdReportVariables.test.tsx (3, new file). Red, before v3 standalone household report and saved households, unreachable until v3 moves to the v2 routes #1392 added its wrapper: no Try again; the loaded report and the builder panel tests passed before and after. Its loading-placeholder test was dropped once v3 standalone household report and saved households, unreachable until v3 moves to the v2 routes #1392's page test covered it.
  • householdEntryPoints.test.tsx (the import check, changed): the v2 codec is no longer a household-only module, since the calculations use it.

Prettier, ESLint (no warnings) and the type check are clean on every commit. Existing tests of the modules changed here were not run locally; CI runs the suite.

Review

The first round of adversarial review (review-code format) found no bug. Its quality findings were fixed: plain errors for unreadable answers, the retried read after a finished submission, one create-body type, comments, the variation's query key and how long the stored household stays cached, the head lookup's country, and stronger tests, including the tab test above.

Merging #1392 brought #1386's UK claimant and partner roles, which the v2 run did not store; storing the household as it is sent is a follow-up with its own round, which found no bug. #1392 then moved the roles into householdAsSent inside useRequestedHouseholdRun; the tests the merge had to adapt had a third round, which found no bug. Its quality findings were fixed: the v2 run is given the household as sent (RequestedHousehold.sent) with its payload, and the adapted hook test checks householdAsSent's arguments and is named for what it checks. Its quality findings were fixed: the run's payload is required, storing stays async, and the UK test above.

Environment variables

None added or changed. The new requests go through the calculator's existing same-origin route (/api/policyengine/…), which reads API v1's address and its server credential from POLICYENGINE_API_URL and the POLICYENGINE_API_AUTH0_* variables in the Vercel project's environment (calculator-app/src/app/api/calculatorPublicApi.ts). Their Vercel values were not re-checked here.

🤖 Generated with Claude Code

anth-volk and others added 30 commits November 28, 2026 01:20
/v2/household-calculations answers with the stored household's people and
groups keyed by their record IDs ("person-1"). These tests describe
householdDataFromV2Calculation, which gives each person, group and group
member its record's v1 name (source_name), keeps the record ID when there
is none, and fails, naming the record, when the calculation names one the
stored household lacks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
householdDataFromV2Calculation turns the household a
/v2/household-calculations calculation answers with, whose people and
groups are keyed by record IDs, into the v1 household routes' names: each
person and group takes its stored record's source_name (else its ID), and
so does each group's member list. Collections the stored document does not
hold pass through, so every reader of a v1 calculated household keeps
working.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pollUntilFinished reads work API v1 runs in the background (a household
calculation) until it has finished: at an interval, within a time limit
that ends the wait with a message, and stopping at once when its abort
signal fires, which each request is also handed. A read that fails with
503 or no answer is asked again a few times; any other failure, and a
failed submission, ends the wait.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pollUntilFinished sends the work (or reads it first), then reads it every
2 seconds until it has finished, for at most 10 minutes. Its abort signal
stops the timer and is passed to each request, so a read in progress is
cancelled; a read that fails with 503 or no answer is asked again up to 3
times in a row; a submission is never sent again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
calculateV2Household submits a stored household with a stored policy, or
none for current law, optional axes and add_missing_variables, then reads
the calculation until it has succeeded, returning it with its output, or
failed, rejecting with the simulation service's reason and code. A
submission that has already finished is read once at once, since API v1's
submission answer holds no result. API v1's refusals keep their status and
message; an aborted wait cancels the read in progress and reads no more;
the wait ends after its time limit.

The fixtures answer as API v1 does today: a submission with the
calculation's state, a read with the calculation in result.item, its .py
and country package versions on the item and its output's household keyed
by record IDs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
calculateV2Household submits a stored household under a stored policy, or
current law, with any axes and add_missing_variables, and waits for it
through pollUntilFinished. It returns the succeeded calculation (its
output, and the .py and country package versions on the item) or rejects
with V2HouseholdCalculationFailedError, naming the simulation service's
reason and code. A submission that has already finished is read once at
once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
storeV2Household stores a household's content through POST
/v2/households in its country and returns the stored record, and
fetchV2Household reads a stored household in its country. The
saved-household store sends the same POST when it saves a household.

The import check no longer lists the v2 household codec among the modules
only the household features may import: the household calculations on
the v2 routes store households (api/v2Households) and read their
calculations (libs/flagship/v2HouseholdRun) with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
api/v2Households holds the one POST /v2/households (store a household's
content, or find the identical stored one) and the one GET of a stored
household, sent with no credential unless a client is given. The
saved-household store now sends both through it, as the account; its
requests are unchanged. The household calculations use the same POST.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
runV2FlagshipHousehold stores the household once (POST /v2/households),
hands over the stored record before calculating, then calculates it under the
baseline and the reform at once, each with every variable it lacks, and
gives the run the v1 path gives: both households in their v1 names, what
the reform changes, and each calculation's SPM settings and receipt with
the .py and country package versions it ran with. One policy serves both
sides when baseline and reform are the same; when one calculation fails,
the other is no longer read; failures read in plain words, and a
household set up for another year sends nothing.

v2PolicyIdFor sends current law (no ID, or the catalog's current-law ID)
as no policy and a v2 policy by its ID, and refuses a v1 policy number.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…h policy

runV2FlagshipHousehold stores the household through api/v2Households,
hands onStored the stored record, then calculates it under the baseline and the
reform at once through calculateV2Household, each adding every missing
variable, for the household's default year. Both calculations wait on one
signal, so when one fails, or the caller stops waiting, the other is no
longer read. The run is the v1 run's shape: households in their v1 names
(householdDataFromV2Calculation), compareHouseholds' changes, and each
side's provenance: the .py version as policyengine_version, the country
package version as model_version, and the SPM settings and receipt.
v2PolicyIdFor maps the policy IDs v3 holds to what a v2 calculation names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…calculations

The household calculations on the /v2/ routes send POST /v2/households,
POST /v2/household-calculations and GET /v2/household-calculations/{id},
and the saved-household store reads GET /v2/households/{id}. The route's
allow list must forward each, and still refuse the neighbours the
calculator never sends (listing either collection, deleting a record, a
malformed ID).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…gin route

The allow list of app.policyengine.org's route to API v1 gains POST
/v2/households, GET /v2/households/{id}, POST /v2/household-calculations
and GET /v2/household-calculations/{id}, none of them cached. Nothing
sends them while v3 uses the v1 routes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On the v2 routes v3's model metadata comes from /v2/model-catalog. These
tests describe the catalog's spm (whether the catalog version offers SPM
settings, their schema and defaults) becoming the metadata's spm in the
shape v1's metadata gave it, so the US household builder offers the SPM
geography choice exactly when the catalog version does. The shared catalog
fixture keeps offering none; a second fixture offers them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…utes

fetchV2ModelCatalogMetadata now gives the metadata's spm from the
catalog's: { available: false } when the catalog version offers no SPM
settings, else available with the settings schema and the certified
defaults where the catalog gives them, as v1's metadata gave them. So on
the v2 routes the US household builder offers the SPM geography choice
exactly when the catalog version does. v1's metadata is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On the v2 routes a calculated household is a stored /v2/households
record. Saving it to the user looks up the user's /v2/user-households row
by household_id and creates one naming the v2 household only when there is
none, as a v1 household is saved by legacy_household_id. An ID that is
neither still sends nothing.

useSaveCalculatedHousehold, the Household tab's background save, sends
the same lookup and row for the stored v2 household a run on the v2
routes calculated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ApiFlagshipHouseholdStore.saveCalculated now takes a stored v2 household's
ID as well as a v1 household's: it looks up the user's /v2/user-households
row by household_id and creates one with household_id and the household's
summary when there is none. v1 households are saved by
legacy_household_id as before. The create body's type names one of the
two references, never both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
v2EarningsVariationAxes gives the /v2/household-calculations axis the
variation charts send: the person's employment income from zero to the
variation's maximum (the 200,000 floor, or twice their earnings), across
the variation's points, for the head, else "you", else the first person,
named by their position among the stored people.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
v2EarningsVariationAxes builds the one-axis grid the v2 variation charts
send to /v2/household-calculations: employment_income for the year, from
zero to getHouseholdVariationMaxEarnings of the person's earnings, across
HOUSEHOLD_VARIATION_POINT_COUNT points, for the head, else "you", else
the first person, by position among the stored people.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
v2StoredHouseholdKeys.byId names a stored /v2/households record by
country and ID, so the household runs that store it and the variation
charts that read it share one cache entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
v2StoredHouseholdKeys.byId(country, id) is ['v2-stored-household',
country, id].

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
useRequestedHouseholdRun, which the Household tab and the standalone
household report share, picks its run by V3_API_ROUTES. On the v2 routes
it runs runV2FlagshipHousehold, current law as no policy and a reform by
its v2 policy ID, and refuses a policy known only by its v1 number. Once
the household is stored, the caller hears its stored ID and the household
sent (the Household tab starts its variation then), and the session keeps
the stored household under its stored-household key. On the v1 routes it
runs as today.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
useRequestedHouseholdRun now picks its run by V3_API_ROUTES (still 'v1').
On the v1 routes the household is created and calculated through v1's
household routes, as today. On the v2 routes it runs
runV2FlagshipHousehold, sending current law (no policy, or the catalog's
current-law ID) as no policy and a reform by its v2 policy ID; a policy
known only by its v1 number fails the run, saying so. Once stored, the
household goes into the session's cache under v2StoredHouseholdKeys and
the caller's onCreated hears its stored ID, so the Household tab's
background variation starts and its background save names the v2
household.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On the v2 routes, Varying earnings and Marginal tax rates calculate the
stored household across its head's earnings under each policy through
/v2/household-calculations, with every variable, and the pages are given
those calculations in the v1 names: no v1 policy is read. The variation
shows its progress while it calculates, says why when it fails with Try
again, serves both charts with the same two calculations, calculates only
current law for a baseline-only household, and reads the stored household
from the session when the run kept it. The Household tab's background
variation, started once the household is stored, is the one the charts
read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…routes once v3 uses them

On the v2 routes (V3_API_ROUTES, still 'v1'), Varying earnings and
Marginal tax rates calculate the stored household across its head's
earnings under each policy through /v2/household-calculations
(useV2HouseholdVariation, with v2EarningsVariationAxes and every missing
variable), reading the stored household from the session's cache, which
the run fills, or GET /v2/households/{id}. V2HouseholdVariation hands the
two calculations, in the v1 names, to the existing pages through their
baselineVariation and reformVariation props, so the pages send nothing and
no policy's parameters load; a failed variation shows ErrorState with Try
again. The Household tab's background variation (HouseholdVariationKeeper)
starts the same two calculations once the household is stored. On the v1
routes both are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The standalone household report (#1392) reads every variable of the
model, which load in the background on the v2 routes. These tests describe
it waiting behind a placeholder while they load, and saying so with Try
again when they fail, as the other v3 views that read variables do
(V3VariablesGate). With the variables loaded it shows as before, and the
household builder panel leaves the wait to its callers: ReportView already
waits for the Household tab.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hen they fail

The household report's builder, results and inputs read every variable of
the model, which load in the background on the v2 routes. They now wait
behind V3VariablesGate ("Loading the household report"), as ReportView's
Household tab and the other v3 views that read variables do: a
placeholder while they load, and a failure that says so with Try again.
On the v1 routes the variables are always ready, so the page shows as
before. The diff is mostly re-indentation inside the new wrapper; the
household builder panel is unchanged and leaves the wait to its callers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The /v2/ clients report a request that got no answer as V2ApiError status
0, so on these routes a TypeError comes from reading an answer, not from
the network, and must not read as "Could not reach PolicyEngine" (review
round 1, quality 1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
plainV2HouseholdError now returns a TypeError as it is: on the /v2/
routes a request that got no answer is V2ApiError status 0, which still
reads "Could not reach PolicyEngine. Check your connection.", and a
timed-out wait still reads "The calculation took too long." (review round
1, quality 1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n after a 503

A household calculation that answers its submission already finished is
read at once; that read should be asked again after a failure that may
pass, as every later read is (review round 1, quality 2).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ssion

readRetryingTransientFailures is the read pollUntilFinished asks again
after a failure that may pass; calculateV2Household now sends its read
after an already finished submission through it, so a 503 or no answer
there is asked again as on any later read (review round 1, quality 2).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk and others added 8 commits November 28, 2026 01:20
The background save of calculated households now builds the body #1392's
saved-household store sends (types/v2Households: a v2 household_id, a v1
legacy_household_id, or both), and the v1-only copy in types/v2User is
gone (review round 1, quality 3).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… on the v2 routes

useSaveCalculatedHousehold saves a stored v2 household by its v2 ID on
the v2 routes, the standalone household report calculates through
/v2/household-calculations once V3_API_ROUTES is 'v2', and the
saved-households list from #1392 lists the background-saved rows, which is
to be decided before the switch (review round 1, quality 4). Comments
only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
v2HouseholdVariationKeys.byParams names a policy's calculation of a
stored household across earnings, so the Household tab's background
variation and the charts read it under one key built in one place (review
round 1, quality 5).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sehold kept as long

useV2HouseholdVariation now names its query with
v2HouseholdVariationKeys.byParams, and reads the stored household with the
variation's gcTime, so the entry the household run puts in the cache is
kept as long as the variation that reads it. The notes on the run and the
variation say what is cached and for how long, and the hook test's name
says what it checks (review round 1, quality 5).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e charts do

variationPersonName passed the head lookup a household without its
country, behind a cast, so it read only the households group where the
charts read the country's groups (tax units first in the US). It now
passes the country. Every v3 household has "you", whom the lookup
returns first, so no household v3 builds varies another person (review
round 1, quality 6).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The test stored "you" first, where the default position would also have
found them, so it could not tell whether the fallback works. With "you"
stored after the dependent it passes, and it fails once the fallback is
taken out (review round 1, quality 7).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…round save

With V3_API_ROUTES 'v2', Calculate on the Household tab stores the
household once, calculates it under current law and the reform, starts
both policies' variations across earnings in the background, and saves
the household to the user by its stored v2 ID. No earlier test rendered
the tab on the v2 routes (review round 1, quality 7). It covers behaviour
the earlier commits built, so it passed when written; with the
background variation on the v1 path it fails (2 calculations, not 4).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-save API

Conflicts resolved:
- The same-origin route's allow list: #1392 now forwards the stored
  households (POST /v2/households, GET /v2/households/{id}) and a saved
  household's row under the same operation names this branch used, so
  this branch keeps only its two household-calculation operations and
  their test rows; the refused neighbours of both are kept.
- HouseholdBreakdowns: #1392's description of the variation keeper (who
  starts and keeps it) goes on the keeper this branch picks by
  V3_API_ROUTES; the head lookup keeps the country.
- HouseholdReport.page: #1392's page, with this branch's V3VariablesGate
  wrapper and its note on the v2 routes applied again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
policyengine-calculator-next Ready Ready Preview Nov 27, 2026 10:56pm UTC
policyengine-website Ready Ready Preview Nov 27, 2026 10:56pm UTC

Request Review

anth-volk and others added 3 commits November 28, 2026 01:31
…-save API

#1386's UK claimant and partner roles reach useRequestedHouseholdRun as
payloadOf, the payload a household is sent as. The one conflict, the
hook's arguments, keeps both payloadOf and this branch's onCreated type.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since #1386, the Household tab sends a UK household with its claimant and
partner roles (useRequestedHouseholdRun's payloadOf), which the household
model itself lacks. On the v2 routes the stored household must be that
payload: v2CreateBodyFromV1Payload builds the /v2/households body from a
v1 payload and the household's year, runV2FlagshipHousehold stores the
payload it is given, and the hook gives it the payload it sends.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tner roles included

useRequestedHouseholdRun's v2 run now gets the payload the household is
sent as (payloadOf, from #1386), and runV2FlagshipHousehold stores that
payload: v2CreateBodyFromV1Payload builds the /v2/households body from it
and the household's year, and storeV2HouseholdBody sends it. Before, the
v2 run stored the household model, so a UK household lost the claimant
and partner roles the v1 run sends. householdToV2CreateBody is
v2CreateBodyFromV1Payload of the household's own payload, so the
saved-household store's requests are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk and others added 2 commits November 28, 2026 01:44
… and partner roles

On the v2 routes, the Household tab's lone parent and their adult child
are stored through POST /v2/households as claimant and dependant, as the
v1 routes send them, so policyengine-uk does not read them as a couple.
The test passes on this branch and fails (no role stored) with the hook
as it was before the household was stored as sent. The hook test's
comment now says what its payload is (review round 2, quality 3).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…old stays async

runV2FlagshipHousehold now takes the payload the household is sent as,
always, and stores only that, so the household it is given is read only
for its year; its one caller already passes the payload. storeV2Household
is async again, so a household it cannot store (no year, a country
without v2 households) rejects its promise rather than throwing (review
round 2, quality 1 and 2).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-save API

#1392 now sends every v3 household as householdAsSent prepares it (UK
claimant and partner roles): useRequestedHouseholdRun applies it itself,
its payloadOf option is gone, and RequestedHousehold's payload is the
household as sent, which this branch's v2 run stores. #1392 also wraps
the standalone household report in V3VariablesGate, as this branch did.

Conflicts resolved:
- useFlagshipHousehold: #1392's arguments without payloadOf, with this
  branch's onCreated type.
- HouseholdReport.page: #1392's page (its wrapper is the same), with this
  branch's note on the v2 routes.

Tests adapted: the v2 hook test that passed payloadOf now has
householdAsSent prepare a household that differs from the one described,
and checks the v2 run is given that household's payload (it fails when
the run is given the described household's). This branch's test of the
report's loading placeholder is dropped, as #1392's page test covers it;
its tests of a failed load and of the builder panel stay.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk and others added 2 commits November 28, 2026 02:54
…ts payload

useRequestedHouseholdRun prepares each household with householdAsSent,
given the session's model information and the run's year; on the v2
routes the run should get that household and its payload, so the year it
checks and the household it stores come from the same household. The
test's name now says what it checks (review round 3, quality 1 and 2).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On the v2 routes useRequestedHouseholdRun now gives runV2FlagshipHousehold
the household as sent (RequestedHousehold.sent, from householdAsSent)
along with its payload, so the year the run checks and the content it
stores come from one household (review round 3, quality 1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch was successfully deployed

2 active deployments
Preview – policyengine-website — 6ad04b0e Deployed Nov 27, 2026 by vercel[bot]
Preview – policyengine-calculator-next — 6ad04b0e Deployed Nov 27, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant