Repository navigation
Report: lock in the stored report schema - #1271
Merged
Merged
Conversation
reportSchema.ts holds the stored shape of a v3 report's provenance and record, a schemaVersion (2; unversioned is 1), and parsers that upgrade any older shape to the current one with safe defaults, or answer a typed ReportSchemaError. It also reads meta.baseline from the custom-baseline work, so either can merge first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every read of a report record or its provenance goes through the parser, and every write stamps the current schemaVersion. A list leaves out a record it can't read; entries this version can't read stay as stored, so a newer version's records survive. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A report whose stored provenance the schema can't read shows an error in place of the report: reload when a newer version saved it, open the report without it, or go back to Build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
POST checks each provision, and PATCH the validation pin, with the rules the client reads them back with, and names the bad field in the 400. Body limits and the schema guard are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- A provision's growth, growthStart, growthBase, growthRoundTo and growthRound read back, so "Edit in Build" keeps how a value grows. - Opening a report without damaged saved details removes them, so the next visit opens without asking; details a newer version saved stay. - The page reads the saved details once per report for the error. - ReportRecordError is now ReportDetailsError. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
v3 report records and their provenance now have one schema with a version. Every read goes through a parser that upgrades older shapes, and every write stamps the version. A report whose stored details can't be read shows an error on the report page, not a crash or an endless spinner.
What changed
libs/flagship/reportSchema.ts(new):REPORT_SCHEMA_VERSION = 2(unversioned data is 1). It has field rules forFlagshipReportMetaandFlagshipReportRecord; the rule maps do not compile until every field has a rule.parseReportMeta,parseReportRecordandparseReportRowupgrade any older shape and fill safe defaults, or return a typedReportSchemaError(not-an-object,invalid-fieldwith the field path, ornewer-version).stampReportMetaandstampReportRecordadd the version on write. A damaged validation pin is dropped, and the report pins again. The record does not fail.meta.baseline {reformId, policyId, label}through its ownReportMetaBaselinetype. This branch merges withfeat/v3-custom-baselinewith no conflicts in either order. The merged tree typechecks, and the flagship tests pass, including Compare a v3 report with a saved reform #1265's baseline tests.readReportMetaandsaveReportMeta(runReport.ts) and the localStorage report store use the parser and stamp on write. Lists leave out unreadable entries. Writes keep entries that this version can't read, so a record saved by a newer version survives. The central store parses each row it gets back./api/reportschecks each provision, and PATCH/api/reports/:idchecks the validation pin, with the same rules that the client uses to read them back. The 400 response names the bad field.guardSchemaand the body and text limits do not change.Merging with #1252 (sign-in)
#1252 replaces the central report store with
/v2/user-reportsand deletes the calculator-app report routes. A trial merge gives these conflicts:runReport.ts: one line inreadReportMeta. Resolve it asreturn accountReportMeta.get(userReportId) ?? (result?.ok ? result.value : null);.flagshipReportStore.ts: keep Stage 12A: Sign in to app v3 and save work to the account #1252's account store, and keep this branch's localStorage store (withFLAGSHIP_REPORTS_KEY).reportRoutes.test.ts: keep Stage 12A: Sign in to app v3 and save work to the account #1252's deletions.Report.page.tsxmerges with no conflicts.v2 impact
None. All changes are in flagship-only files:
components/flagship,pages/flagship,libs/flagship,api/flagshipReportStore.ts, a new flagship hook, and the v3/api/reportsroutes. No shared file is touched.Tests run
bun run typecheck: passcalculator-app:tsc --noEmitpassesbunx eslinton each changed file: pass. The calculator-app routes are outside the app's ESLint base path.bunx prettier --checkon each changed file: passbunx vitest runon the related suites: passbun run vitest(full suite): 392 files passed, 1 skipped; 4444 tests passed, 10 skipped🤖 Generated with Claude Code