diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 000000000..c16e82284 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,15 @@ +# The comparables gate (docs/engineering/skills/repository-guidance.md, +# "Research entries need a comparables record"): a change to what it checks, +# to the lists of entries and pages it exempts, or to the route map other +# repositories read, asks for Max's review. +/website/src/data/comparables.ts @MaxGhenis +/website/src/data/comparablesGrandfathered.json @MaxGhenis +/website/src/data/analysisRoutes.ts @MaxGhenis +/website/src/data/analysisRoutes.json @MaxGhenis +/website/scripts/build-analysis-routes.ts @MaxGhenis +/website/src/__tests__/content/comparables*.test.ts @MaxGhenis +/website/src/__tests__/content/posts-and-apps-data.test.ts @MaxGhenis +/website/src/__tests__/content/routing.ts @MaxGhenis +/website/src/__tests__/content/fixtures/comparables_fresh_cases.json @MaxGhenis +/.github/workflows/comparables-gate.yml @MaxGhenis +/.github/CODEOWNERS @MaxGhenis diff --git a/.github/workflows/comparables-gate.yml b/.github/workflows/comparables-gate.yml new file mode 100644 index 000000000..7d4d9c1f1 --- /dev/null +++ b/.github/workflows/comparables-gate.yml @@ -0,0 +1,122 @@ +name: Comparables gate + +# Every research entry not on the list of entries live before the gate +# (website/src/data/comparablesGrandfathered.json) must name a complete record +# of its comparables search in PolicyEngine/policyengine-scorecard. The Tests +# job checks each block's shape without the network; this job downloads the +# scorecard's published index from its main branch and checks that every +# block resolves to a search the index lists, and that the grandfather list +# has not grown after the cutover. The scorecard is public, so the download +# needs no token. A failed download fails the job: the gate fails closed. +# +# It runs on every pull request (no path filter, so it can be a required +# check), on every push to main, and weekly, so a record removed from the +# scorecard shows up without waiting for the next change. A failed weekly +# run opens an issue. + +on: + pull_request: + push: + branches: [main] + schedule: + - cron: "17 9 * * 1" + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +env: + # Pinned here, not read from the change under test, so a change cannot + # point the gate at another index. A test checks comparables.ts agrees. + SCORECARD_INDEX_URL: https://raw.githubusercontent.com/PolicyEngine/policyengine-scorecard/main/data/comparables/index.json + +jobs: + resolve: + name: Comparables resolve against the scorecard + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Bun + uses: oven-sh/setup-bun@v2 + + # Same Node as the Tests job (pr.yaml): vitest runs on Node. + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: "26" + + - name: Install dependencies + run: bun install --frozen-lockfile + + - name: Download the scorecard's comparables index + run: | + curl --fail --silent --show-error --location --retry 5 --retry-all-errors \ + --output "$RUNNER_TEMP/comparables-index.json" "$SCORECARD_INDEX_URL" + node -e "const i=JSON.parse(require('fs').readFileSync(process.argv[1],'utf8'));console.log(Object.keys(i.analyses).length+' records in the scorecard index ('+i.schema+')')" "$RUNNER_TEMP/comparables-index.json" + echo "COMPARABLES_INDEX_PATH=$RUNNER_TEMP/comparables-index.json" >> "$GITHUB_ENV" + + # The registries, grandfather list and featured banner on the branch this + # change merges into: the base of a pull request, or main before a push. + # None on a scheduled or manual run. A base the checkout cannot read + # fails the job, rather than passing as if there were none. + - name: The registries before this change + env: + BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.before }} + run: | + dir="$RUNNER_TEMP/comparables-base" + mkdir -p "$dir" + if [ -n "$BASE_SHA" ] && [ "$BASE_SHA" != "0000000000000000000000000000000000000000" ]; then + if ! git cat-file -e "$BASE_SHA^{commit}"; then + echo "::error::cannot read the base commit $BASE_SHA" + exit 1 + fi + for path in \ + app/src/data/apps/apps.json \ + app/src/data/posts/posts.json \ + website/src/data/comparablesGrandfathered.json \ + website/src/components/home/FeaturedResearchBanner.tsx; do + # a file the base does not have yet is absent, not an error + if git cat-file -e "$BASE_SHA:$path" 2>/dev/null; then + git show "$BASE_SHA:$path" > "$dir/$(basename "$path")" + fi + done + fi + ls -la "$dir" + echo "COMPARABLES_BASE_DIR=$dir" >> "$GITHUB_ENV" + + - name: Every research entry passes the gate + working-directory: ./website + env: + COMPARABLES_GATE: "1" + run: bun run test src/__tests__/content/comparables.live.test.ts + + report: + name: Report a failed weekly run + needs: resolve + if: failure() && github.event_name == 'schedule' + runs-on: ubuntu-latest + permissions: + issues: write + steps: + - name: Open or update the gate's issue + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + run: | + title="Comparables gate failing on main" + number=$(gh issue list --state open --search "\"$title\" in:title" --json number --jq '.[0].number') + body="The weekly comparables gate failed: $RUN_URL. A research entry's comparables block no longer resolves against the scorecard index, or the index changed shape. See website/src/data/comparables.ts." + if [ -n "$number" ]; then + gh issue comment "$number" --body "$body" + else + gh issue create --title "$title" --body "$body" + fi diff --git a/app/src/data/posts/README.md b/app/src/data/posts/README.md index dd328bce7..8400302b1 100644 --- a/app/src/data/posts/README.md +++ b/app/src/data/posts/README.md @@ -9,6 +9,13 @@ This folder contains the blog posts for PolicyEngine. - `authors.json` - Author information - `images/` - Legacy image folder (do not use for new posts) +## Comparables + +A new post needs a `comparables` block in its `posts.json` entry, a record of its +comparables search (or, for an event or announcement, a `no_estimate` declaration): see +"Research entries need a comparables record" in +`docs/engineering/skills/repository-guidance.md`. + ## Adding Images to Blog Posts **Important**: Images should be stored in `app/public/assets/posts/{post-name}/` and referenced with absolute paths. diff --git a/docs/engineering/skills/repository-guidance.md b/docs/engineering/skills/repository-guidance.md index bd6d3f47d..921622fed 100644 --- a/docs/engineering/skills/repository-guidance.md +++ b/docs/engineering/skills/repository-guidance.md @@ -10,6 +10,19 @@ The `app/` directory holds the calculator code. `calculator-app/` (Next.js) comp - `app/public/assets/` holds static assets that the website build copies in. `calculator-app/public` is a symlink to `app/public`, so everything in `app/public` is served on app.policyengine.org. - Website pages and components go in `website/src/`. New website rewrites go in `website/next.config.ts`, not `website/vercel.json`. +## Research entries need a comparables record + +A research entry is an `apps.json` app with `displayWithResearch` or the `policy` tag, or any `posts.json` post. Every research entry needs a `comparables` block naming the record of its comparables search in PolicyEngine/policyengine-scorecard (`docs/COMPARABLES.md` there; the `policyengine-comparables-review` skill runs the search), unless it is on `website/src/data/comparablesGrandfathered.json`, the list of entries live before the gate. The date an entry carries does not exempt it. + +- Merge the scorecard PR first, then paste the block `python -m scorecard_db.comparables record analysis--` prints (its latest search). The search is dated on or before the entry's date, no more than `MAX_SEARCH_AGE_DAYS` before it, and is not a backfill. +- On the day a change lists or re-lists an entry (a new entry, or a new date or block), the `Comparables gate` workflow also requires that the cited search is no more than `MAX_SEARCH_AGE_DAYS` old that day, whatever date the entry carries; that it compared the results files the analysis reads now; and that no gap it found is still pending. +- A post that is plainly not an analysis (tagged `org`, `event`, `giving`, `conferences`, `year-in-review` or `april-fools`, and none of the analysis tags in `comparables.ts`) may declare `{"status": "no_estimate", "reason": "..."}` instead. An app never may. +- Taking an entry off the site takes it off the grandfather list too, so it comes back only with a record. Entries may join the list only before `COMPARABLES_CUTOVER_DATE`; after it the list only shrinks. +- Every page the site proxies to another deployment (a rewrite in `next.config.ts`, most from `website/src/data/appZoneRoutes.ts`, in any form next.config accepts) is a research app's page, a page live before the gate, or on the grandfather file's `infrastructure` list of pages that publish no analysis. Add a dashboard through `appZoneRoutes.ts` with its `apps.json` entry. +- A card a change adds to the featured research banner must link a research entry whose comparables search is fresh that day under the scorecard's promotion window, grandfathered entries included. +- `website/src/data/analysisRoutes.json` maps every path and deployment host that leads to a research app, for PolicyEngine/newsletters' check; after a routing or registry change run `bun run scripts/build-analysis-routes.ts` in `website/` (a test fails while it is stale). +- The Tests job checks each block's shape and these lists. The `Comparables gate` workflow runs on every pull request, checks that each block resolves against the scorecard's index on main, the listing and banner rules above, and that the list has not grown after the cutover, and opens an issue when its weekly run fails. + ## Visual standards Detailed visual standards are documented in `docs/engineering/skills/`. Read the relevant document before changing interface code: diff --git a/website/scripts/build-analysis-routes.ts b/website/scripts/build-analysis-routes.ts new file mode 100644 index 000000000..68f667c32 --- /dev/null +++ b/website/scripts/build-analysis-routes.ts @@ -0,0 +1,40 @@ +/** + * Writes src/data/analysisRoutes.json, the map of every path and deployment + * host that leads to a research app (src/data/analysisRoutes.ts), which + * PolicyEngine/newsletters reads. posts-and-apps-data.test.ts fails while the + * committed file differs from what this builds. + * + * bun run scripts/build-analysis-routes.ts + */ +import { writeFileSync } from "node:fs"; +import appsData from "../src/data/apps.json"; +import postsData from "../src/data/posts/posts.json"; +import { + buildAnalysisRoutes, + unlistedPagePaths, +} from "../src/data/analysisRoutes"; +import { entryKey, researchEntries } from "../src/data/comparables"; +import { loadRouting } from "../src/__tests__/content/routing"; + +const { rewrites, redirects } = await loadRouting(); +const entries = researchEntries( + appsData as Parameters[0], + postsData as Parameters[1], +); +const appKeys = new Set(entries.filter((e) => e.kind === "app").map(entryKey)); +const routes = buildAnalysisRoutes( + rewrites, + redirects, + appsData as never, + appKeys, +); +writeFileSync( + new URL("../src/data/analysisRoutes.json", import.meta.url), + `${JSON.stringify(routes, null, 2)}\n`, +); +const unlisted = unlistedPagePaths(rewrites, appKeys); +console.log(`${routes.paths.length} paths, ${routes.hosts.length} hosts`); +console.log( + "proxied pages that are no research app's:", + JSON.stringify(unlisted), +); diff --git a/website/src/__tests__/content/comparables.live.test.ts b/website/src/__tests__/content/comparables.live.test.ts new file mode 100644 index 000000000..f26e89112 --- /dev/null +++ b/website/src/__tests__/content/comparables.live.test.ts @@ -0,0 +1,105 @@ +// @vitest-environment node +import { existsSync, readFileSync } from "node:fs"; +import { join } from "node:path"; +import { describe, expect, test } from "vitest"; +import appsData from "@/data/apps.json"; +import { + bannerHrefs, + changedEntries, + checkIndex, + type ComparablesIndex, + GRANDFATHERED, + type Grandfathered, + grandfatherAdditions, + promotionProblems, + publicationProblems, + requiresComparables, + researchEntries, + resolveComparables, + validateComparables, +} from "@/data/comparables"; +import postsData from "@/data/posts/posts.json"; + +// Every research entry against the scorecard's published index. The +// Comparables gate workflow downloads the index from +// PolicyEngine/policyengine-scorecard's main branch, sets +// COMPARABLES_INDEX_PATH, and sets COMPARABLES_GATE=1 so that a missing +// index fails rather than skips. COMPARABLES_BASE_DIR holds the registries, +// grandfather list and featured banner on the branch the change merges into +// (absent when there is none, as on a scheduled run). Without +// COMPARABLES_GATE (the Tests job, local runs) this file skips, and +// posts-and-apps-data.test.ts still checks every block's shape. +const gate = process.env.COMPARABLES_GATE === "1"; +const indexPath = process.env.COMPARABLES_INDEX_PATH; +const baseDir = process.env.COMPARABLES_BASE_DIR; +const BANNER = new URL( + "../../components/home/FeaturedResearchBanner.tsx", + import.meta.url, +); + +if (gate && !indexPath) { + throw new Error( + "COMPARABLES_GATE is set but COMPARABLES_INDEX_PATH is not: the gate has no index to check against", + ); +} + +function fromBase(name: string): T | null { + if (!baseDir) return null; + const path = join(baseDir, name); + if (!existsSync(path) || !readFileSync(path, "utf8").trim()) return null; + const text = readFileSync(path, "utf8"); + return (name.endsWith(".json") ? JSON.parse(text) : text) as T; +} + +describe.skipIf(!gate)("comparables against the scorecard index", () => { + // read inside the tests: a skipped describe still runs its body + const loadIndex = () => + JSON.parse(readFileSync(indexPath as string, "utf8")) as ComparablesIndex; + const entries = researchEntries( + appsData as Parameters[0], + postsData as Parameters[1], + ); + const today = new Date().toISOString().slice(0, 10); + + test("the index is the scorecard's, and applies the same entry rules", () => { + expect(checkIndex(loadIndex())).toEqual([]); + }); + + test("every research entry has a well-formed block where it needs one, and every block resolves to a complete scorecard record", () => { + const index = loadIndex(); + const errors = entries.flatMap((entry) => [ + ...validateComparables(entry), + ...resolveComparables(entry, index), + ]); + expect(errors).toEqual([]); + }); + + test("an entry this change lists cites a search fresh today, against the current results, with no gap pending", () => { + const apps = fromBase[0]>("apps.json"); + const posts = fromBase[1]>("posts.json"); + if (!apps || !posts) return; // no base: a scheduled run, or the first list + const index = loadIndex(); + const changed = changedEntries( + researchEntries(apps, posts), + entries, + ).filter((entry) => requiresComparables(entry)); + expect( + changed.flatMap((e) => publicationProblems(e, index, today)), + ).toEqual([]); + }); + + test("a card this change features links an analysis whose comparables are fresh today", () => { + const base = fromBase("FeaturedResearchBanner.tsx"); + if (base === null) return; + const before = new Set(bannerHrefs(base)); + const added = bannerHrefs(readFileSync(BANNER, "utf8")).filter( + (href) => !before.has(href), + ); + expect(promotionProblems(added, entries, loadIndex(), today)).toEqual([]); + }); + + test("the grandfather list grows only before the cutover", () => { + const base = fromBase("comparablesGrandfathered.json"); + expect(grandfatherAdditions(base, GRANDFATHERED, today)).toEqual([]); + }); +}); diff --git a/website/src/__tests__/content/comparables.test.ts b/website/src/__tests__/content/comparables.test.ts new file mode 100644 index 000000000..aebd55895 --- /dev/null +++ b/website/src/__tests__/content/comparables.test.ts @@ -0,0 +1,748 @@ +// @vitest-environment node +import { readFileSync } from "node:fs"; +import fc from "fast-check"; +import { describe, expect, test } from "vitest"; +import { + ANALYSIS_TAGS, + bannerHrefs, + changedEntries, + checkIndex, + COMPARABLES_CUTOVER_DATE, + COUNTRY_TAGS, + type ComparablesIndex, + DEFAULT_COUNTRY, + entryKey, + freshness, + type Grandfathered, + grandfatherAdditions, + INDEX_SCHEMA, + MAX_SEARCH_AGE_DAYS, + mayDeclareNoEstimate, + NO_ESTIMATE_TAGS, + postSlug, + promotionProblems, + publicationProblems, + requiresComparables, + type ResearchEntry, + resolveComparables, + type ReviewedComparables, + researchEntries, + routeEntryKey, + SEARCH_KINDS, + searchLogUrl, + validateComparables, +} from "@/data/comparables"; + +// Properties of the comparables gate (website/src/data/comparables.ts): +// - an entry off the grandfather list with a well-formed block whose search +// the scorecard index lists always resolves; +// - any one disagreement between the block and the index fails resolution; +// - any one malformation of a well-formed block fails validation; +// - an entry off the grandfather list needs a block whatever date it +// carries, and one on the list never does; +// - only a post that is plainly not an analysis may declare no_estimate; +// - researchEntries lists apps by the research or policy flag and every +// post, with the site's slugs, dates and countries; +// - the grandfather list may grow only before the cutover. + +const DAY = 86_400_000; + +function addDays(date: string, days: number): string { + return new Date(Date.parse(`${date}T00:00:00Z`) + days * DAY) + .toISOString() + .slice(0, 10); +} + +const NONE: Grandfathered = { + snapshotDate: "2026-10-22", + entries: [], + routes: [], +}; + +const slugArb = fc + .array(fc.stringMatching(/^[a-z0-9]{1,8}$/), { minLength: 1, maxLength: 4 }) + .map((parts) => parts.join("-")); +const producerArb = fc.stringMatching(/^[a-z]{2,8}(_[a-z]{2,6})?$/); +const producersArb = fc.uniqueArray(producerArb, { + minLength: 1, + maxLength: 20, +}); +const countryArb = fc.constantFrom(...COUNTRY_TAGS); +const kindArb = fc.constantFrom<"app" | "post">("app", "post"); +// days from the cutover the entry is listed (backdated ones too), and days +// before that it was searched +const listedArb = fc.integer({ min: -900, max: 900 }); +const searchLeadArb = fc.integer({ min: 0, max: MAX_SEARCH_AGE_DAYS }); +const listedKindArb = fc.constantFrom( + "prepublish", + "reharvest", + "prepromotion", +); + +interface Case { + entry: ResearchEntry; + record: ReviewedComparables; + index: ComparablesIndex; +} + +function entryRules() { + return { + analysis_tags: [...ANALYSIS_TAGS], + no_estimate_tags: [...NO_ESTIMATE_TAGS], + country_tags: [...COUNTRY_TAGS], + default_country: DEFAULT_COUNTRY, + search_kinds: [...SEARCH_KINDS], + }; +} + +const caseArb: fc.Arbitrary = fc + .record({ + slug: slugArb, + country: countryArb, + kind: kindArb, + listed: listedArb, + lead: searchLeadArb, + searchKind: listedKindArb, + producers: producersArb, + found: fc.nat({ max: 60 }), + otherSearches: fc.nat({ max: 3 }), + }) + .map( + ({ + slug, + country, + kind, + listed, + lead, + searchKind, + producers, + found, + otherSearches, + }) => { + const date = addDays(COMPARABLES_CUTOVER_DATE, listed); + const searchDate = addDays(date, -lead); + const source = `analysis-${country}-${slug}`; + const record: ReviewedComparables = { + status: "reviewed", + scorecardSource: source, + searchDate, + searchKind, + producersSearched: producers, + found, + searchLog: searchLogUrl(source), + }; + const entry: ResearchEntry = { + kind, + slug, + countryIds: [country], + date, + tags: [country, "policy"], + comparables: record, + }; + // the index lists producers sorted, and later re-harvests besides + const searches = [ + { + date: searchDate, + kind: searchKind, + producers_searched: [...producers].sort(), + found, + }, + ...Array.from({ length: otherSearches }, (_, i) => ({ + date: addDays(date, 7 * (i + 1)), + kind: "reharvest", + producers_searched: [...producers].sort(), + found: i, + })), + ]; + const index: ComparablesIndex = { + schema: INDEX_SCHEMA, + gap_threshold: 0.25, + entry_rules: entryRules(), + analyses: { + [source]: { + kind, + country_id: country, + slug, + searches, + search_log: searchLogUrl(source), + }, + }, + }; + return { entry, record, index }; + }, + ); + +function withBlock(entry: ResearchEntry, block: unknown): ResearchEntry { + return { ...entry, comparables: block }; +} + +describe("comparables gate properties", () => { + test("every well-formed entry off the grandfather list resolves against an index that lists its search", () => { + fc.assert( + fc.property(caseArb, ({ entry, index }) => { + expect(requiresComparables(entry, NONE)).toBe(true); + expect(validateComparables(entry, NONE)).toEqual([]); + expect(checkIndex(index)).toEqual([]); + expect(resolveComparables(entry, index)).toEqual([]); + }), + ); + }); + + test("any one disagreement with the index fails resolution", () => { + const at = (c: Case) => c.index.analyses[c.record.scorecardSource]; + const mutations: Array<(c: Case) => void> = [ + (c) => { + c.index.analyses = {}; + }, + (c) => { + at(c).searches[0].found += 1; + }, + (c) => { + at(c).searches[0].producers_searched.pop(); + }, + (c) => { + at(c).searches[0].producers_searched.push("zzz_extra"); + }, + (c) => { + at(c).searches[0].date = addDays(c.record.searchDate, -1); + }, + (c) => { + at(c).searches[0].kind = "backfill"; + }, + (c) => { + at(c).slug += "-x"; + }, + (c) => { + at(c).country_id = c.entry.countryIds[0] === "uk" ? "us" : "uk"; + }, + (c) => { + at(c).kind = c.entry.kind === "app" ? "post" : "app"; + }, + (c) => { + at(c).search_log += "#other"; + }, + (c) => { + c.index.schema = "comparables/index/0"; + }, + ]; + fc.assert( + fc.property( + caseArb, + fc.integer({ min: 0, max: mutations.length - 1 }), + (c, which) => { + mutations[which](c); + expect(resolveComparables(c.entry, c.index)).not.toEqual([]); + }, + ), + ); + }); + + test("any one malformation of a well-formed block fails validation", () => { + const malformations: Array< + (r: Record, e: ResearchEntry) => unknown + > = [ + (r) => ({ ...r, extra: 1 }), + (r) => ({ ...r, searchLog: `${r.searchLog}x` }), + (r) => ({ ...r, scorecardSource: "Analysis-UK-x" }), + (r, e) => { + const source = `analysis-${e.countryIds[0]}-${e.slug}-other`; + return { + ...r, + scorecardSource: source, + searchLog: searchLogUrl(source), + }; + }, + (r) => ({ ...r, searchDate: "2026-02-30" }), + (r) => ({ ...r, searchDate: "02/11/2026" }), + (r) => ({ ...r, searchKind: "later" }), + (r) => ({ ...r, searchKind: "backfill" }), + (r, e) => ({ ...r, searchDate: addDays(e.date as string, 1) }), + (r, e) => ({ + ...r, + searchDate: addDays(e.date as string, -(MAX_SEARCH_AGE_DAYS + 1)), + }), + (r) => ({ ...r, producersSearched: [] }), + (r) => ({ ...r, producersSearched: "obr" }), + (r) => ({ + ...r, + producersSearched: [ + ...(r.producersSearched as string[]), + (r.producersSearched as string[])[0], + ], + }), + (r) => ({ ...r, producersSearched: ["Not A Slug"] }), + (r) => ({ ...r, found: 1.5 }), + (r) => ({ ...r, found: -1 }), + (r) => ({ ...r, found: "3" }), + (r) => ({ ...r, status: "searched" }), + () => "reviewed", + () => null, + (r) => [r], + ]; + fc.assert( + fc.property( + caseArb, + fc.integer({ min: 0, max: malformations.length - 1 }), + ({ entry, record }, which) => { + const broken = withBlock( + entry, + malformations[which]({ ...record }, entry), + ); + expect(validateComparables(broken, NONE)).not.toEqual([]); + }, + ), + ); + }); + + test("an entry off the grandfather list needs a block, whatever date it carries", () => { + fc.assert( + fc.property(caseArb, ({ entry }) => { + const bare = withBlock(entry, undefined); + expect(validateComparables(bare, NONE).join()).toMatch( + /needs a comparables block/, + ); + }), + ); + }); + + test("an entry off the grandfather list needs a real listing date", () => { + fc.assert( + fc.property( + caseArb, + fc.constantFrom(null, "", "03/11/2026", "2026-13-01"), + ({ entry }, date) => { + expect(validateComparables({ ...entry, date }, NONE).join()).toMatch( + /needs a publication date/, + ); + }, + ), + ); + }); + + test("an entry on the grandfather list needs no block, but a block it carries must be well formed", () => { + fc.assert( + fc.property(caseArb, ({ entry, record }) => { + const listed: Grandfathered = { ...NONE, entries: [entryKey(entry)] }; + expect(requiresComparables(entry, listed)).toBe(false); + expect( + validateComparables(withBlock(entry, undefined), listed), + ).toEqual([]); + // a backfill is fine for an entry that was live before the gate + expect( + validateComparables( + withBlock(entry, { ...record, searchKind: "backfill" }), + listed, + ), + ).toEqual([]); + expect( + validateComparables( + withBlock(entry, { ...record, found: -1 }), + listed, + ), + ).not.toEqual([]); + }), + ); + }); + + test("only a post that is plainly not an analysis may declare no estimate", () => { + const tagArb = fc.uniqueArray( + fc.constantFrom( + ...ANALYSIS_TAGS, + ...NO_ESTIMATE_TAGS, + "featured", + "impact", + "uk", + "us", + ), + { maxLength: 5 }, + ); + fc.assert( + fc.property(caseArb, tagArb, ({ entry }, tags) => { + const declared = { + ...entry, + tags, + comparables: { + status: "no_estimate", + reason: "An event write-up with no estimate in it.", + }, + }; + const allowed = + entry.kind === "post" && + tags.some((t) => + (NO_ESTIMATE_TAGS as readonly string[]).includes(t), + ) && + !tags.some((t) => (ANALYSIS_TAGS as readonly string[]).includes(t)); + expect(mayDeclareNoEstimate(declared)).toBe(allowed); + expect(validateComparables(declared, NONE).length === 0).toBe(allowed); + }), + ); + }); + + test("a no_estimate block needs a reason and nothing else", () => { + const post: ResearchEntry = { + kind: "post", + slug: "an-event", + countryIds: ["uk"], + date: "2026-11-02", + tags: ["uk", "event"], + }; + const reason = "An event write-up with no estimate in it."; + expect( + validateComparables( + withBlock(post, { status: "no_estimate", reason }), + NONE, + ), + ).toEqual([]); + expect( + validateComparables( + withBlock(post, { status: "no_estimate", reason: "none" }), + NONE, + ).join(), + ).toMatch(/reason of 20\+/); + expect( + validateComparables( + withBlock(post, { status: "no_estimate", reason, found: 0 }), + NONE, + ).join(), + ).toMatch(/only status and reason/); + }); +}); + +describe("the scorecard index", () => { + test("an index of another shape, or with other entry rules, is refused", () => { + const good = { + schema: INDEX_SCHEMA, + gap_threshold: 0.25, + entry_rules: entryRules(), + analyses: {}, + }; + expect(checkIndex(good)).toEqual([]); + expect(checkIndex({ ...good, schema: "not-an-index" })).not.toEqual([]); + expect(checkIndex({ ...good, analyses: [] })).not.toEqual([]); + expect(checkIndex({ ...good, entry_rules: undefined })).not.toEqual([]); + expect( + checkIndex({ + ...good, + entry_rules: { ...entryRules(), analysis_tags: ["policy"] }, + }).join(), + ).toMatch(/analysis_tags/); + expect( + checkIndex({ + ...good, + entry_rules: { ...entryRules(), default_country: "uk" }, + }).join(), + ).toMatch(/default_country/); + expect(checkIndex(null)).not.toEqual([]); + }); + + test("a block matches any one of two searches on the same day", () => { + fc.assert( + fc.property(caseArb, fc.nat({ max: 60 }), (c, otherFound) => { + fc.pre(otherFound !== c.record.found); + const searches = c.index.analyses[c.record.scorecardSource].searches; + searches.unshift({ ...searches[0], found: otherFound }); + expect(resolveComparables(c.entry, c.index)).toEqual([]); + }), + ); + }); + + test("a record filed under another country than its name fails", () => { + fc.assert( + fc.property(caseArb, ({ entry, index, record }) => { + const other = entry.countryIds[0] === "uk" ? "us" : "uk"; + index.analyses[record.scorecardSource].country_id = other; + const both = { ...entry, countryIds: [entry.countryIds[0], other] }; + expect(resolveComparables(both, index).join()).toMatch(/under/); + }), + ); + }); +}); + +describe("research entries", () => { + const appArb = fc.record({ + slug: slugArb, + countryId: countryArb, + date: fc.option( + fc + .tuple( + fc.integer({ min: -400, max: 400 }), + fc.constantFrom("", " 12:00:00", " 09:30"), + ) + .map(([d, time]) => `${addDays(COMPARABLES_CUTOVER_DATE, d)}${time}`), + { nil: undefined }, + ), + tags: fc.uniqueArray( + fc.constantFrom("policy", "featured", "interactives", "tax", "uk", "us"), + { maxLength: 4 }, + ), + displayWithResearch: fc.option(fc.boolean(), { nil: undefined }), + }); + const postArb = fc.record({ + filename: fc + .tuple( + fc.stringMatching(/^[A-Za-z0-9]{1,6}(?:[_-][A-Za-z0-9]{1,6}){0,3}$/), + fc.constantFrom(".md", ".ipynb", ".v2.md"), + ) + .map(([stem, ext]) => `${stem}${ext}`), + date: fc + .tuple( + fc.integer({ min: -400, max: 400 }), + fc.constantFrom("", " 12:00:00"), + ) + .map(([d, time]) => `${addDays(COMPARABLES_CUTOVER_DATE, d)}${time}`), + tags: fc.uniqueArray( + fc.constantFrom(...COUNTRY_TAGS, "global", "policy", "org", "event"), + { maxLength: 4 }, + ), + }); + + test("apps are listed when shown with research or tagged policy; every post is", () => { + fc.assert( + fc.property( + fc.array(appArb, { maxLength: 6 }), + fc.array(postArb, { maxLength: 6 }), + (apps, posts) => { + const entries = researchEntries(apps, posts); + const listedApps = apps.filter( + (a) => a.displayWithResearch || a.tags.includes("policy"), + ); + expect(entries.filter((e) => e.kind === "app")).toHaveLength( + listedApps.length, + ); + expect(entries.filter((e) => e.kind === "post")).toHaveLength( + posts.length, + ); + for (const [entry, app] of entries + .filter((e) => e.kind === "app") + .map((e, i) => [e, listedApps[i]] as const)) { + expect(entry.countryIds).toEqual([app.countryId]); + expect(entry.date).toBe(app.date ? app.date.slice(0, 10) : null); + expect(entryKey(entry)).toBe(`app ${app.countryId}/${app.slug}`); + } + for (const [entry, post] of entries + .filter((e) => e.kind === "post") + .map((e, i) => [e, posts[i]] as const)) { + const countries = post.tags.filter((t) => + (COUNTRY_TAGS as readonly string[]).includes(t), + ); + expect(entry.countryIds).toEqual( + countries.length ? countries : [DEFAULT_COUNTRY], + ); + expect(entry.date).toBe(post.date.slice(0, 10)); + expect(entry.slug).toBe(postSlug(post.filename)); + expect(entry.slug).toMatch(/^[a-z0-9-]+$/); + expect(entry.slug).not.toMatch(/\./); + } + }, + ), + ); + }); + + test("a registry date that is not one stays as written, so the gate can refuse it", () => { + const [entry] = researchEntries( + [], + [{ filename: "a.md", date: "03/11/2026", tags: ["uk"] }], + ); + expect(entry.date).toBe("03/11/2026"); + expect(validateComparables(entry, NONE).join()).toMatch( + /needs a publication date/, + ); + }); + + test("an app route names its entry", () => { + expect(routeEntryKey("/uk/triple-lock")).toBe("app uk/triple-lock"); + expect(routeEntryKey("/:countryId/bill-tracker")).toBeNull(); + expect(routeEntryKey("/ai-beliefs")).toBeNull(); + expect(routeEntryKey("/uk/research/some-post")).toBeNull(); + }); +}); + +describe("the grandfather list", () => { + const base: Grandfathered = { + snapshotDate: "2026-10-22", + entries: ["app uk/a", "post b"], + routes: ["/x"], + }; + const dayArb = fc + .integer({ min: -60, max: 400 }) + .map((d) => addDays(COMPARABLES_CUTOVER_DATE, d)); + + test("it may grow before the cutover and only shrink after", () => { + fc.assert( + fc.property( + dayArb, + fc.subarray(base.entries), + fc.subarray(["app us/new", "post newer"]), + fc.boolean(), + (today, kept, added, addRoute) => { + const head: Grandfathered = { + ...base, + entries: [...kept, ...added], + routes: addRoute ? [...base.routes, "/y"] : base.routes, + }; + const grew = added.length > 0 || addRoute; + const errors = grandfatherAdditions(base, head, today); + expect(errors.length > 0).toBe( + grew && today >= COMPARABLES_CUTOVER_DATE, + ); + }, + ), + ); + }); + + test("a branch with no list yet starts one", () => { + expect(grandfatherAdditions(null, base, "2027-01-01")).toEqual([]); + }); +}); + +describe("listing and promotion on the day a change is checked", () => { + const PIN = "PolicyEngine/x@" + "b".repeat(40) + ":" + "a".repeat(64); + const TODAY = "2026-11-10"; + const source = "analysis-uk-x"; + const block: ReviewedComparables = { + status: "reviewed", + scorecardSource: source, + searchDate: "2026-11-02", + searchKind: "reharvest", + producersSearched: ["obr"], + found: 0, + searchLog: searchLogUrl(source), + }; + const entry: ResearchEntry = { + kind: "app", + slug: "x", + countryIds: ["uk"], + date: "2026-11-10", + tags: ["uk", "policy"], + comparables: block, + }; + const record = ( + over: Partial = {}, + ) => ({ + kind: "app", + country_id: "uk", + slug: "x", + search_log: searchLogUrl(source), + current_pins: [PIN], + searches: [ + { + date: "2026-11-02", + kind: "reharvest", + producers_searched: ["obr"], + found: 0, + results_pins: [PIN], + }, + ], + comparisons: [] as Array<{ + claim: string; + status: string; + found_on?: string; + }>, + ...over, + }); + const index = (over = {}): ComparablesIndex => ({ + schema: INDEX_SCHEMA, + gap_threshold: 0.25, + promotion_window_days: 7, + entry_rules: entryRules(), + analyses: { [source]: record(over) }, + }); + + test("a re-listing with a gap still pending is refused", () => { + expect(publicationProblems(entry, index(), TODAY)).toEqual([]); + const pending = index({ + comparisons: [ + { claim: "centax_static", status: "pending", found_on: "2026-11-02" }, + ], + }); + expect(resolveComparables(entry, pending)).toEqual([]); + expect(publicationProblems(entry, pending, TODAY).join()).toMatch( + /gaps still pending/, + ); + // a pending gap with no date counts as found + const undated = index({ comparisons: [{ claim: "c", status: "pending" }] }); + expect(publicationProblems(entry, undated, TODAY)).not.toEqual([]); + }); + + test("the search's age is judged on the day the change lists the entry, not the date it carries", () => { + fc.assert( + fc.property(fc.integer({ min: 0, max: 400 }), (lag) => { + const today = addDays("2026-11-02", lag); + const problems = publicationProblems(entry, index(), today); + expect(problems.some((p) => /more than 30 days/.test(p))).toBe( + lag > MAX_SEARCH_AGE_DAYS, + ); + }), + ); + }); + + test("a search against old results does not list the entry", () => { + const moved = index({ current_pins: [PIN.replace("b", "c")] }); + expect(publicationProblems(entry, moved, TODAY).join()).toMatch( + /did not compare the results/, + ); + }); + + test("only new, re-dated or re-blocked entries are judged as listed by the change", () => { + const base = [entry, { ...entry, slug: "y", comparables: undefined }]; + const head = [ + entry, + { ...entry, slug: "y", comparables: undefined }, + { ...entry, slug: "z" }, + ]; + expect(changedEntries(base, head).map((e) => e.slug)).toEqual(["z"]); + expect( + changedEntries(base, [{ ...entry, date: "2026-11-11" }]).map( + (e) => e.slug, + ), + ).toEqual(["x"]); + expect( + changedEntries(base, [{ ...entry, comparables: { ...block, found: 1 } }]), + ).toHaveLength(1); + }); + + test("a newly featured card needs a fresh search, grandfathered entries included", () => { + const grandfathered: ResearchEntry = { + ...entry, + slug: "free-childcare-reform", + comparables: undefined, + }; + expect( + promotionProblems( + ["/uk/free-childcare-reform"], + [grandfathered], + index(), + TODAY, + ).join(), + ).toMatch(/has no comparables record/); + // the window counts back seven days from the push, both ends included + expect( + promotionProblems(["/uk/x"], [entry], index(), "2026-11-09"), + ).toEqual([]); + expect( + promotionProblems(["/uk/x"], [entry], index(), "2026-12-01").join(), + ).toMatch(/no comparables search between/); + expect( + promotionProblems(["/uk/nowhere"], [entry], index(), TODAY).join(), + ).toMatch(/links no research entry/); + }); + + test("banner hrefs are read in any quote style", () => { + expect( + bannerHrefs(`{ href: "/uk/a" }, { href: '/uk/b' }, { href: \`/uk/c\` }`), + ).toEqual(["/uk/a", "/uk/b", "/uk/c"]); + }); + + test("freshness agrees with the scorecard's on its shared cases", () => { + const cases = JSON.parse( + readFileSync( + new URL("./fixtures/comparables_fresh_cases.json", import.meta.url), + "utf8", + ), + ) as Array<{ entry: never; on: string; window: number; fresh: boolean }>; + expect(cases.length).toBeGreaterThan(50); + for (const c of cases) { + expect(freshness(c.entry, c.on, c.window).length === 0).toBe(c.fresh); + } + }); +}); diff --git a/website/src/__tests__/content/fixtures/comparables_fresh_cases.json b/website/src/__tests__/content/fixtures/comparables_fresh_cases.json new file mode 100644 index 000000000..23d3bba85 --- /dev/null +++ b/website/src/__tests__/content/fixtures/comparables_fresh_cases.json @@ -0,0 +1,2258 @@ +[ + { + "entry": { + "comparisons": [], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-24", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-10-31", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-24", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-02", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-24", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-04", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-24", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-24", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-10-31", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-24", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-02", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-24", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-04", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-24", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-25", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-10-31", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-25", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-02", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-25", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-04", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-25", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-25", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-10-31", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-25", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-02", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-25", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-04", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-25", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-26", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-10-31", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-26", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-02", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-26", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-04", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-26", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-26", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-10-31", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-26", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-02", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-26", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-04", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-26", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-30", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": true, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-10-31", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-30", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-02", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-30", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-04", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-30", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": true, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-30", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-10-31", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-30", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-02", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-30", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-04", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-30", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-11-02", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": true, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-10-31", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-11-02", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-02", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-11-02", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-04", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-11-02", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": true, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-11-02", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-10-31", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-11-02", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-02", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-11-02", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-04", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-11-02", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-11-03", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-10-31", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-11-03", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-02", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-11-03", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-04", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-11-03", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-11-03", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-10-31", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-11-03", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-02", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-11-03", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-04", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-11-03", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 3 + }, + { + "entry": { + "comparisons": [], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-24", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-10-31", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-24", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-02", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-24", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-04", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-24", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-24", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-10-31", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-24", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-02", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-24", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-04", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-24", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-25", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-10-31", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-25", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-02", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-25", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-04", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-25", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-25", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-10-31", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-25", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-02", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-25", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-04", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-25", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-26", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": true, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-10-31", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-26", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-02", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-26", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-04", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-26", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": true, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-26", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-10-31", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-26", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-02", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-26", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-04", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-26", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-30", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": true, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-10-31", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-30", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-02", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-30", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-04", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-30", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": true, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-30", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-10-31", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-30", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-02", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-30", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-04", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-10-30", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-11-02", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": true, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-10-31", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-11-02", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-02", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-11-02", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-04", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-11-02", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": true, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-11-02", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-10-31", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-11-02", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-02", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-11-02", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-04", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-11-02", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-11-03", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-10-31", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-11-03", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-02", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-11-03", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-04", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-11-03", + "kind": "reharvest", + "results_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-11-03", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-10-31", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-11-03", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-02", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-11-03", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + }, + { + "entry": { + "comparisons": [ + { + "claim": "c0", + "found_on": "2026-11-04", + "status": "pending" + } + ], + "current_pins": [ + "PolicyEngine/test@bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "searches": [ + { + "date": "2026-11-03", + "kind": "reharvest", + "results_pins": ["x"] + } + ] + }, + "fresh": false, + "on": "2026-11-02", + "window": 7 + } +] diff --git a/website/src/__tests__/content/posts-and-apps-data.test.ts b/website/src/__tests__/content/posts-and-apps-data.test.ts index b8a35cae3..2e7674514 100644 --- a/website/src/__tests__/content/posts-and-apps-data.test.ts +++ b/website/src/__tests__/content/posts-and-apps-data.test.ts @@ -1,11 +1,35 @@ +// @vitest-environment node +import { readFileSync } from "node:fs"; +import { fileURLToPath } from "node:url"; import { describe, expect, test } from "vitest"; import appsData from "@/data/apps.json"; +import postsData from "@/data/posts/posts.json"; +import { + buildAnalysisRoutes, + pageRewriteProblems, + unlistedPagePaths, +} from "@/data/analysisRoutes"; +import { + bannerHrefs, + COMPARABLES_CUTOVER_DATE, + entryKey, + GRANDFATHERED, + isValidDate, + MAX_SEARCH_AGE_DAYS, + requiresComparables, + researchEntries, + routeEntryKey, + SCORECARD_INDEX_URL, + validateComparables, +} from "@/data/comparables"; import { getLocationTags, getPostsSorted, locationLabels, + postSlug, topicLabels, } from "@/data/posts/postTransformers"; +import { loadRouting } from "./routing"; // posts.json and apps.json live in app/src/data and feed the research pages // and the sitemap. These checks came over from the Vite app's tests when its @@ -123,3 +147,163 @@ describe("apps.json", () => { expect(incomplete.map((app) => app.slug)).toEqual([]); }); }); + +// Pre-publish comparables (website/src/data/comparables.ts): every research +// entry not on the list of entries live before the gate names a complete +// record in PolicyEngine/policyengine-scorecard. The Comparables gate workflow +// checks the record against the scorecard's index; these checks need no +// network. +describe("comparables", () => { + const entries = researchEntries( + apps, + postsData as Parameters[1], + ); + const keys = entries.map(entryKey); + const repoRoot = fileURLToPath(new URL("../../../../", import.meta.url)); + const appKeys = new Set(keys.filter((key) => key.startsWith("app "))); + const infrastructure = GRANDFATHERED.infrastructure ?? []; + + test("every research entry passes the gate's own checks", () => { + expect(entries.flatMap((entry) => validateComparables(entry))).toEqual([]); + }); + + test("each research entry has its own key, and each that needs a record its own record name", () => { + expect(duplicates(keys)).toEqual([]); + const records = entries.map((entry) => ({ + entry, + names: entry.countryIds.map( + (country) => `analysis-${country}-${entry.slug}`, + ), + })); + // the GiveCalc app and post share a name, and both were live before the + // gate; an entry that needs a record may share its name with nothing + const clashes = records + .filter(({ entry }) => requiresComparables(entry)) + .flatMap(({ entry, names }) => + names.filter((name) => + records.some( + (other) => other.entry !== entry && other.names.includes(name), + ), + ), + ); + expect(clashes).toEqual([]); + }); + + test("every post's file name gives it a slug", () => { + const slugs = (postsData as Array<{ filename: string }>).map((post) => + postSlug(post.filename), + ); + expect( + slugs.filter((slug) => !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(slug)), + ).toEqual([]); + expect(duplicates(slugs)).toEqual([]); + }); + + test("the grandfather list names only research entries on the site, listed before the cutover", () => { + const byKey = new Map(entries.map((entry) => [entryKey(entry), entry])); + expect(GRANDFATHERED.entries.filter((key) => !byKey.has(key))).toEqual([]); + const late = GRANDFATHERED.entries.filter((key) => { + const entry = byKey.get(key); + if (!entry) return false; + if (entry.date === null) return entry.kind === "post"; + return !isValidDate(entry.date) || entry.date >= COMPARABLES_CUTOVER_DATE; + }); + expect(late).toEqual([]); + expect(GRANDFATHERED.entries).toEqual( + [...new Set(GRANDFATHERED.entries)].sort(), + ); + expect(isValidDate(GRANDFATHERED.snapshotDate)).toBe(true); + expect(GRANDFATHERED.snapshotDate < COMPARABLES_CUTOVER_DATE).toBe(true); + }); + + test("every proxied page is a research app's, was live before the gate, or publishes no analysis", async () => { + // the evaluated rewrites, so any syntax next.config.ts accepts is seen + const { rewrites } = await loadRouting(); + expect(rewrites.length).toBeGreaterThan(50); + expect( + pageRewriteProblems( + rewrites, + appKeys, + GRANDFATHERED.routes, + infrastructure, + ), + ).toEqual([]); + const unlisted = unlistedPagePaths(rewrites, appKeys); + // a page taken down, or given a research entry, leaves the lists + expect( + [...GRANDFATHERED.routes, ...infrastructure].filter( + (path) => !unlisted.includes(path), + ), + ).toEqual([]); + expect( + GRANDFATHERED.routes.filter((p) => infrastructure.includes(p)), + ).toEqual([]); + for (const list of [GRANDFATHERED.routes, infrastructure]) { + expect(list).toEqual([...new Set(list)].sort()); + } + }); + + test("the committed analysis route map is the one the site's routing builds", async () => { + const { rewrites, redirects } = await loadRouting(); + const built = buildAnalysisRoutes(rewrites, redirects, apps, appKeys); + const committed = JSON.parse( + readFileSync(`${repoRoot}website/src/data/analysisRoutes.json`, "utf8"), + ); + // run `bun run scripts/build-analysis-routes.ts` in website/ to refresh it + expect(committed).toEqual(built); + // every research app's own path leads to it, unless a redirect sends + // the path to another app + const redirected = new Set( + redirects.flatMap((r) => (r.source.includes(":") ? [] : [r.source])), + ); + for (const key of appKeys) { + const path = `/${key.slice(4)}`; + const route = built.paths.find((p) => p.path === path); + expect(route?.entry === key || redirected.has(path)).toBe(true); + } + }); + + test("every featured research card links a research entry", () => { + const banner = readFileSync( + `${repoRoot}website/src/components/home/FeaturedResearchBanner.tsx`, + "utf8", + ); + const hrefs = bannerHrefs(banner); + expect(hrefs.length).toBeGreaterThan(0); + const entryKeys = new Set(keys); + const postKeys = new Set( + entries.filter((e) => e.kind === "post").map((e) => entryKey(e)), + ); + const orphans = hrefs.filter((href) => { + const app = routeEntryKey(href); + const post = href.match(/^\/[a-z]{2}\/research\/([a-z0-9-]+)$/); + return !( + (app && entryKeys.has(app)) || + (post && postKeys.has(`post ${post[1]}`)) + ); + }); + expect(orphans).toEqual([]); + }); + + test("the gate's settings stay where Max set them", () => { + // decision d1812: the cutover is 2026-10-29 or earlier + expect(isValidDate(COMPARABLES_CUTOVER_DATE)).toBe(true); + expect(COMPARABLES_CUTOVER_DATE <= "2026-10-29").toBe(true); + expect(MAX_SEARCH_AGE_DAYS).toBeGreaterThan(0); + expect(MAX_SEARCH_AGE_DAYS).toBeLessThanOrEqual(30); + }); + + test("the workflow downloads the index from the scorecard's main, and runs on every pull request", () => { + const workflow = readFileSync( + `${repoRoot}.github/workflows/comparables-gate.yml`, + "utf8", + ); + const pinned = workflow.match(/^\s*SCORECARD_INDEX_URL:\s*(\S+)\s*$/m); + expect(pinned?.[1]).toBe(SCORECARD_INDEX_URL); + expect(SCORECARD_INDEX_URL).toBe( + "https://raw.githubusercontent.com/PolicyEngine/policyengine-scorecard/main/data/comparables/index.json", + ); + expect(workflow).not.toMatch(/^\s*paths(-ignore)?:/m); + expect(workflow).toMatch(/COMPARABLES_GATE: "1"/); + }); +}); diff --git a/website/src/__tests__/content/routing.ts b/website/src/__tests__/content/routing.ts new file mode 100644 index 000000000..1d6d044f4 --- /dev/null +++ b/website/src/__tests__/content/routing.ts @@ -0,0 +1,27 @@ +import nextConfig from "../../../next.config"; +import type { Route } from "@/data/analysisRoutes"; + +/** The site's evaluated rewrites (all phases) and redirects. */ +export async function loadRouting(): Promise<{ + rewrites: Route[]; + redirects: Route[]; +}> { + const config = nextConfig as unknown as { + rewrites: () => Promise< + | Route[] + | { beforeFiles?: Route[]; afterFiles?: Route[]; fallback?: Route[] } + >; + redirects: () => Promise; + }; + const rewrites = await config.rewrites(); + return { + rewrites: Array.isArray(rewrites) + ? rewrites + : [ + ...(rewrites.beforeFiles ?? []), + ...(rewrites.afterFiles ?? []), + ...(rewrites.fallback ?? []), + ], + redirects: await config.redirects(), + }; +} diff --git a/website/src/data/analysisRoutes.json b/website/src/data/analysisRoutes.json new file mode 100644 index 000000000..bfcab4a96 --- /dev/null +++ b/website/src/data/analysisRoutes.json @@ -0,0 +1,722 @@ +{ + "schema": "analysis-routes/1", + "paths": [ + { + "path": "/ca/bill-tracker", + "prefix": true, + "entry": "app us/bill-tracker" + }, + { + "path": "/ca/state-legislative-tracker", + "prefix": true, + "entry": "app us/bill-tracker" + }, + { + "path": "/il/bill-tracker", + "prefix": true, + "entry": "app us/bill-tracker" + }, + { + "path": "/il/state-legislative-tracker", + "prefix": true, + "entry": "app us/bill-tracker" + }, + { + "path": "/ng/bill-tracker", + "prefix": true, + "entry": "app us/bill-tracker" + }, + { + "path": "/ng/state-legislative-tracker", + "prefix": true, + "entry": "app us/bill-tracker" + }, + { + "path": "/pe84", + "prefix": false, + "entry": "app us/pe84" + }, + { + "path": "/uk/2024-manifestos", + "prefix": true, + "entry": "app uk/2024-manifestos" + }, + { + "path": "/uk/autumn-budget-2025", + "prefix": true, + "entry": "app uk/autumn-budget-2025" + }, + { + "path": "/uk/bill-tracker", + "prefix": true, + "entry": "app us/bill-tracker" + }, + { + "path": "/uk/bus-fare-cap", + "prefix": true, + "entry": "app uk/bus-fare-cap" + }, + { + "path": "/uk/cancelling-fuel-duty-rise", + "prefix": true, + "entry": "app uk/cancelling-fuel-duty-rise" + }, + { + "path": "/uk/cliff-watch", + "prefix": true, + "entry": "app us/cliffwatch" + }, + { + "path": "/uk/cliffwatch", + "prefix": true, + "entry": "app us/cliffwatch" + }, + { + "path": "/uk/electricity-vat-cut", + "prefix": true, + "entry": "app uk/electricity-vat-cut" + }, + { + "path": "/uk/energy-autumn-budget", + "prefix": true, + "entry": "app uk/energy-autumn-budget" + }, + { + "path": "/uk/energy-price-shock", + "prefix": true, + "entry": "app uk/energy-price-shock" + }, + { + "path": "/uk/free-childcare-reform", + "prefix": true, + "entry": "app uk/free-childcare-reform" + }, + { + "path": "/uk/local-areas-dashboard", + "prefix": true, + "entry": "app uk/local-areas-dashboard" + }, + { + "path": "/uk/marriage", + "prefix": true, + "entry": "app uk/marriage" + }, + { + "path": "/uk/middle-east-war-living-standards", + "prefix": true, + "entry": "app uk/middle-east-war-living-standards" + }, + { + "path": "/uk/nics-exemption-inactive-employees", + "prefix": true, + "entry": "app uk/nics-exemption-inactive-employees" + }, + { + "path": "/uk/public-services-spending", + "prefix": true, + "entry": "app uk/public-services-spending" + }, + { + "path": "/uk/scotland-income-tax-reform", + "prefix": true, + "entry": "app uk/scotland-income-tax-reform" + }, + { + "path": "/uk/scottish-budget-2026-27", + "prefix": true, + "entry": "app uk/scottish-budget-2026-27" + }, + { + "path": "/uk/spring-statement-2026", + "prefix": true, + "entry": "app uk/spring-statement-2026" + }, + { + "path": "/uk/state-legislative-tracker", + "prefix": true, + "entry": "app us/bill-tracker" + }, + { + "path": "/uk/student-loan-visualisation", + "prefix": true, + "entry": "app uk/student-loan-visualisation" + }, + { + "path": "/uk/targeted-energy-discount", + "prefix": true, + "entry": "app uk/targeted-energy-discount" + }, + { + "path": "/uk/triple-lock", + "prefix": true, + "entry": "app uk/triple-lock" + }, + { + "path": "/uk/two-child-limit-comparison", + "prefix": true, + "entry": "app uk/two-child-limit-comparison" + }, + { + "path": "/uk/uc-rebalancing", + "prefix": true, + "entry": "app uk/uc-rebalancing" + }, + { + "path": "/uk/uk-cliff-watch", + "prefix": true, + "entry": "app uk/uk-cliff-watch" + }, + { + "path": "/uk/uk-land-value-tax", + "prefix": true, + "entry": "app uk/uk-land-value-tax" + }, + { + "path": "/uk/uk-salary-sacrifice-tool", + "prefix": true, + "entry": "app uk/uk-salary-sacrifice-tool" + }, + { + "path": "/uk/uk-student-loan-calculator", + "prefix": true, + "entry": "app uk/uk-student-loan-calculator" + }, + { + "path": "/uk/young-worker-nics", + "prefix": true, + "entry": "app uk/young-worker-nics" + }, + { + "path": "/us/2024-election-calculator", + "prefix": true, + "entry": "app us/2024-election-calculator" + }, + { + "path": "/us/aca-calc", + "prefix": true, + "entry": "app us/aca-calc" + }, + { + "path": "/us/aca-reforms-calculator", + "prefix": true, + "entry": "app us/aca-calc" + }, + { + "path": "/us/bill-tracker", + "prefix": true, + "entry": "app us/bill-tracker" + }, + { + "path": "/us/california-wealth-tax", + "prefix": true, + "entry": "app us/california-wealth-tax" + }, + { + "path": "/us/california-wealth-tax/embed", + "prefix": true, + "entry": "app us/california-wealth-tax" + }, + { + "path": "/us/child-poverty-impact-dashboard", + "prefix": true, + "entry": "app us/child-poverty-impact-dashboard" + }, + { + "path": "/us/child-tax-credit-2024-election-calculator", + "prefix": true, + "entry": "app us/child-tax-credit-2024-election-calculator" + }, + { + "path": "/us/child-tax-credit-calculator", + "prefix": true, + "entry": "app us/child-tax-credit-calculator" + }, + { + "path": "/us/cliff-watch", + "prefix": true, + "entry": "app us/cliffwatch" + }, + { + "path": "/us/cliffwatch", + "prefix": true, + "entry": "app us/cliffwatch" + }, + { + "path": "/us/coverage-compass", + "prefix": true, + "entry": "app us/coverage-compass" + }, + { + "path": "/us/encode-policy-multi-agent-ai", + "prefix": true, + "entry": "app us/encode-policy-multi-agent-ai" + }, + { + "path": "/us/futa-wage-base-dashboard", + "prefix": true, + "entry": "app us/futa-wage-base-dashboard" + }, + { + "path": "/us/givecalc", + "prefix": true, + "entry": "app us/givecalc" + }, + { + "path": "/us/keep-your-pay-act", + "prefix": true, + "entry": "app us/keep-your-pay-act" + }, + { + "path": "/us/marriage", + "prefix": true, + "entry": "app us/marriage" + }, + { + "path": "/us/missouri-income-tax-elimination", + "prefix": true, + "entry": "app us/missouri-income-tax-elimination" + }, + { + "path": "/us/nj-ctc-increase", + "prefix": true, + "entry": "app us/nj-ctc-increase" + }, + { + "path": "/us/ob3-households", + "prefix": true, + "entry": "app us/obbba-households" + }, + { + "path": "/us/obba-household-explorer", + "prefix": true, + "entry": "app us/obbba-households" + }, + { + "path": "/us/obbba-household-by-household", + "prefix": true, + "entry": "app us/obbba-households" + }, + { + "path": "/us/obbba-household-explorer", + "prefix": true, + "entry": "app us/obbba-households" + }, + { + "path": "/us/obbba-households", + "prefix": true, + "entry": "app us/obbba-households" + }, + { + "path": "/us/obbba-scatter", + "prefix": true, + "entry": "app us/obbba-households" + }, + { + "path": "/us/oregon-kicker-refund", + "prefix": true, + "entry": "app us/oregon-kicker-refund" + }, + { + "path": "/us/pe84", + "prefix": true, + "entry": "app us/pe84" + }, + { + "path": "/us/research/obbba-household-by-household", + "prefix": false, + "entry": "app us/obbba-households" + }, + { + "path": "/us/research/obbba-household-explorer", + "prefix": false, + "entry": "app us/obbba-households" + }, + { + "path": "/us/rhode-island-ctc-calculator", + "prefix": true, + "entry": "app us/rhode-island-ctc-calculator" + }, + { + "path": "/us/salternative", + "prefix": true, + "entry": "app us/salternative" + }, + { + "path": "/us/snap-district-map", + "prefix": true, + "entry": "app us/snap-district-map" + }, + { + "path": "/us/snap-payment-error-simulator", + "prefix": true, + "entry": "app us/snap-payment-error-simulator" + }, + { + "path": "/us/south-carolina-2026-tax-changes", + "prefix": true, + "entry": "app us/south-carolina-2026-tax-changes" + }, + { + "path": "/us/state-eitcs-ctcs", + "prefix": true, + "entry": "app us/state-eitcs-ctcs" + }, + { + "path": "/us/state-legislative-tracker", + "prefix": true, + "entry": "app us/bill-tracker" + }, + { + "path": "/us/tanf-calculator", + "prefix": true, + "entry": "app us/tanf-calculator" + }, + { + "path": "/us/taxation-of-benefits-reforms", + "prefix": true, + "entry": "app us/taxation-of-benefits-reforms" + }, + { + "path": "/us/utah-2026-tax-changes", + "prefix": true, + "entry": "app us/utah-2026-tax-changes" + }, + { + "path": "/us/watca", + "prefix": true, + "entry": "app us/watca" + }, + { + "path": "/us/working-parents-tax-relief-act", + "prefix": true, + "entry": "app us/working-parents-tax-relief-act" + }, + { + "path": "/us/wv-sb392-tax-cut", + "prefix": true, + "entry": "app us/wv-sb392-tax-cut" + } + ], + "hosts": [ + { + "host": "2024-election-dashboard-omega.vercel.app", + "pathPrefix": "/", + "entries": ["app us/2024-election-calculator"] + }, + { + "host": "2024-election-dashboard.vercel.app", + "pathPrefix": "/", + "entries": ["app us/2024-election-calculator"] + }, + { + "host": "aca-calc.vercel.app", + "pathPrefix": "/", + "entries": ["app us/aca-calc", "app us/aca-reforms-calculator"] + }, + { + "host": "aca-calc.vercel.app", + "pathPrefix": "/us/aca-calc", + "entries": ["app us/aca-calc"] + }, + { + "host": "april-fools-2026-two.vercel.app", + "pathPrefix": "/", + "entries": ["app us/pe84"] + }, + { + "host": "autumn-budget-local-area.vercel.app", + "pathPrefix": "/", + "entries": ["app uk/local-areas-dashboard"] + }, + { + "host": "bus-fare-cap.vercel.app", + "pathPrefix": "/", + "entries": ["app uk/bus-fare-cap"] + }, + { + "host": "california-wealth-tax.vercel.app", + "pathPrefix": "/", + "entries": ["app us/california-wealth-tax"] + }, + { + "host": "cancelling-fuel-duty-rise.vercel.app", + "pathPrefix": "/", + "entries": ["app uk/cancelling-fuel-duty-rise"] + }, + { + "host": "child-poverty-impact-dashboard-sigma.vercel.app", + "pathPrefix": "/", + "entries": ["app us/child-poverty-impact-dashboard"] + }, + { + "host": "cliff-watch.vercel.app", + "pathPrefix": "/", + "entries": ["app us/cliffwatch"] + }, + { + "host": "coverage-compass-policy-engine.vercel.app", + "pathPrefix": "/", + "entries": ["app us/coverage-compass"] + }, + { + "host": "crfb-tob-impacts.vercel.app", + "pathPrefix": "/", + "entries": ["app us/taxation-of-benefits-reforms"] + }, + { + "host": "ctc-calculator-seven.vercel.app", + "pathPrefix": "/", + "entries": ["app us/child-tax-credit-calculator"] + }, + { + "host": "ctc-calculator.vercel.app", + "pathPrefix": "/", + "entries": ["app us/child-tax-credit-calculator"] + }, + { + "host": "electricity-vat-cut.vercel.app", + "pathPrefix": "/", + "entries": ["app uk/electricity-vat-cut"] + }, + { + "host": "energy-price-shock.vercel.app", + "pathPrefix": "/", + "entries": ["app uk/energy-price-shock"] + }, + { + "host": "free-childcare-reform.vercel.app", + "pathPrefix": "/", + "entries": ["app uk/free-childcare-reform"] + }, + { + "host": "futa-wage-base-dashboard.vercel.app", + "pathPrefix": "/", + "entries": ["app us/futa-wage-base-dashboard"] + }, + { + "host": "givecalc.vercel.app", + "pathPrefix": "/", + "entries": ["app us/givecalc"] + }, + { + "host": "keep-your-pay-act.vercel.app", + "pathPrefix": "/", + "entries": ["app us/keep-your-pay-act"] + }, + { + "host": "local-area.vercel.app", + "pathPrefix": "/", + "entries": ["app uk/local-areas-dashboard"] + }, + { + "host": "marriage-zeta-beryl.vercel.app", + "pathPrefix": "/us/marriage", + "entries": ["app uk/marriage", "app us/marriage"] + }, + { + "host": "missouri-income-tax-elimination.vercel.app", + "pathPrefix": "/", + "entries": ["app us/missouri-income-tax-elimination"] + }, + { + "host": "nics-exemption-inactive-employees.vercel.app", + "pathPrefix": "/", + "entries": ["app uk/nics-exemption-inactive-employees"] + }, + { + "host": "nj-ctc-increase.vercel.app", + "pathPrefix": "/", + "entries": ["app us/nj-ctc-increase"] + }, + { + "host": "obbba-household-by-household.vercel.app", + "pathPrefix": "/", + "entries": ["app us/obbba-households"] + }, + { + "host": "oregon-kicker-refund.vercel.app", + "pathPrefix": "/", + "entries": ["app us/oregon-kicker-refund"] + }, + { + "host": "policyengine--state-legislative-tracker.modal.run", + "pathPrefix": "/", + "entries": ["app us/bill-tracker"] + }, + { + "host": "policyengine-utah-2026-tax-changes.vercel.app", + "pathPrefix": "/", + "entries": ["app us/utah-2026-tax-changes"] + }, + { + "host": "policyengine.github.io", + "pathPrefix": "/obbba-scatter", + "entries": ["app us/obbba-scatter"] + }, + { + "host": "policyengine.github.io", + "pathPrefix": "/snap-district-map", + "entries": ["app us/snap-district-map"] + }, + { + "host": "policyengine.github.io", + "pathPrefix": "/tanf-calculator", + "entries": ["app us/tanf-calculator"] + }, + { + "host": "policyengine.github.io", + "pathPrefix": "/uk-salary-sacrifice-analysis", + "entries": ["app uk/uk-salary-sacrifice-tool"] + }, + { + "host": "policyengine.github.io", + "pathPrefix": "/us-state-eitcs-ctcs", + "entries": ["app us/state-eitcs-ctcs"] + }, + { + "host": "post-scottish-budget-dashboard.vercel.app", + "pathPrefix": "/", + "entries": ["app uk/scottish-budget-2026-27"] + }, + { + "host": "ri-ctc-calculator-policy-engine.vercel.app", + "pathPrefix": "/", + "entries": ["app us/rhode-island-ctc-calculator"] + }, + { + "host": "salt-amt-calculator.vercel.app", + "pathPrefix": "/", + "entries": ["app us/salternative"] + }, + { + "host": "scotland-income-tax-reform.vercel.app", + "pathPrefix": "/", + "entries": ["app uk/scotland-income-tax-reform"] + }, + { + "host": "snap-district-map.vercel.app", + "pathPrefix": "/", + "entries": ["app us/snap-district-map"] + }, + { + "host": "snap-qc-sim.vercel.app", + "pathPrefix": "/", + "entries": ["app us/snap-payment-error-simulator"] + }, + { + "host": "south-carolina-2026-tax-changes.vercel.app", + "pathPrefix": "/", + "entries": ["app us/south-carolina-2026-tax-changes"] + }, + { + "host": "student-loan-visualisation.vercel.app", + "pathPrefix": "/", + "entries": ["app uk/student-loan-visualisation"] + }, + { + "host": "tanf-calculator.vercel.app", + "pathPrefix": "/", + "entries": ["app us/tanf-calculator"] + }, + { + "host": "uc-rebalancing.vercel.app", + "pathPrefix": "/", + "entries": ["app uk/uc-rebalancing"] + }, + { + "host": "uk-2024-manifestos-comparison.vercel.app", + "pathPrefix": "/", + "entries": ["app uk/2024-manifestos"] + }, + { + "host": "uk-autumn-budget-dashboard.vercel.app", + "pathPrefix": "/", + "entries": ["app uk/autumn-budget-2025"] + }, + { + "host": "uk-cliff-watch.vercel.app", + "pathPrefix": "/", + "entries": ["app uk/uk-cliff-watch"] + }, + { + "host": "uk-energy-autumn-budget.vercel.app", + "pathPrefix": "/", + "entries": ["app uk/energy-autumn-budget"] + }, + { + "host": "uk-energy-shock-impact.vercel.app", + "pathPrefix": "/", + "entries": ["app uk/middle-east-war-living-standards"] + }, + { + "host": "uk-land-value-tax.vercel.app", + "pathPrefix": "/", + "entries": ["app uk/uk-land-value-tax"] + }, + { + "host": "uk-public-services-imputation.vercel.app", + "pathPrefix": "/", + "entries": ["app uk/public-services-spending"] + }, + { + "host": "uk-salary-sacrifice-analysis.vercel.app", + "pathPrefix": "/", + "entries": ["app uk/uk-salary-sacrifice-tool"] + }, + { + "host": "uk-spring-statement-2026-policy-engine.vercel.app", + "pathPrefix": "/", + "entries": ["app uk/spring-statement-2026"] + }, + { + "host": "uk-student-loan-calculator.vercel.app", + "pathPrefix": "/", + "entries": ["app uk/uk-student-loan-calculator"] + }, + { + "host": "uk-targeted-energy-discount.vercel.app", + "pathPrefix": "/", + "entries": ["app uk/targeted-energy-discount"] + }, + { + "host": "uk-triple-lock.vercel.app", + "pathPrefix": "/", + "entries": ["app uk/triple-lock"] + }, + { + "host": "uk-two-child-limit-app.vercel.app", + "pathPrefix": "/", + "entries": ["app uk/two-child-limit-comparison"] + }, + { + "host": "us-state-eitcs-ctcs.vercel.app", + "pathPrefix": "/", + "entries": ["app us/state-eitcs-ctcs"] + }, + { + "host": "vance-harris-ctc-comparison.vercel.app", + "pathPrefix": "/", + "entries": ["app us/child-tax-credit-2024-election-calculator"] + }, + { + "host": "working-americans-tax-cut-act-one.vercel.app", + "pathPrefix": "/", + "entries": ["app us/watca"] + }, + { + "host": "wptra.vercel.app", + "pathPrefix": "/", + "entries": ["app us/working-parents-tax-relief-act"] + }, + { + "host": "wv-sb392-tax-cut.vercel.app", + "pathPrefix": "/", + "entries": ["app us/wv-sb392-tax-cut"] + }, + { + "host": "young-worker-nics.vercel.app", + "pathPrefix": "/", + "entries": ["app uk/young-worker-nics"] + } + ] +} diff --git a/website/src/data/analysisRoutes.ts b/website/src/data/analysisRoutes.ts new file mode 100644 index 000000000..17eab2017 --- /dev/null +++ b/website/src/data/analysisRoutes.ts @@ -0,0 +1,294 @@ +/** + * Where each research analysis is served (the comparables gate, + * comparables.ts). + * + * The site serves a dashboard by proxying one of its paths to another + * deployment (a rewrite in next.config.ts, most of them from + * appZoneRoutes.ts), and keeps old paths working with redirects. This module + * reads the evaluated rewrite and redirect objects, so a route written any + * way next.config.ts accepts is seen: + * + * - `pageRewriteProblems` names every proxied page that is neither a research + * entry's nor on the grandfather list (`routes`, live before the gate) or + * the infrastructure list (`infrastructure`, proxies that publish no + * analysis, such as the API docs); + * - `buildAnalysisRoutes` maps every public path and deployment host that + * leads to a research app, which PolicyEngine/newsletters reads + * (analysisRoutes.json) to recognise a link to an analysis however it is + * written. + */ + +import { COUNTRY_TAGS, routeEntryKey } from "./comparables"; + +export const ROUTES_SCHEMA = "analysis-routes/1"; + +export interface Route { + source: string; + destination: string; +} + +export interface PathRoute { + /** A path on policyengine.org, lowercased, with no trailing slash. */ + path: string; + /** Whether deeper paths under it lead to the same analysis. */ + prefix: boolean; + /** entryKey() of the research app it leads to. */ + entry: string; +} + +export interface HostRoute { + /** A deployment host, lowercased. */ + host: string; + /** The path under the host that belongs to the analysis; "/" for all of it. */ + pathPrefix: string; + /** entryKey()s of the research apps served there (more than one when shared). */ + entries: string[]; +} + +export interface AnalysisRoutes { + schema: string; + paths: PathRoute[]; + hosts: HostRoute[]; +} + +const COUNTRY_PARAM = ":countryId"; +const WILDCARD_SUFFIX = /\/:[A-Za-z]+[*+]?$/; +const ASSET_PREFIXES = ["/_zones/", "/_next/", "/ingest"]; + +/** + * The page paths a rewrite or redirect source matches, country parameters + * expanded and a trailing wildcard (`/:path*`) turned into a prefix. Null for + * a source this module cannot read, which the gate then refuses. + */ +export function expandSource( + source: string, +): { paths: string[]; prefix: boolean } | null { + let path = source.toLowerCase(); + let prefix = false; + if (WILDCARD_SUFFIX.test(path)) { + path = path.replace(WILDCARD_SUFFIX, ""); + prefix = true; + } + if (path === "") path = "/"; + const countries = path.includes(COUNTRY_PARAM.toLowerCase()) + ? [...COUNTRY_TAGS] + : [null]; + const paths = countries.map((country) => + country ? path.split(COUNTRY_PARAM.toLowerCase()).join(country) : path, + ); + if (paths.some((p) => p.includes(":") || p.includes("("))) return null; + return { paths, prefix }; +} + +/** Whether a source serves files, not a page: zone assets, analytics, a file name. */ +export function isAssetSource(source: string): boolean { + const last = source.split("/").filter(Boolean).pop() ?? ""; + return ( + ASSET_PREFIXES.some((p) => source.startsWith(p)) || + (/\.[a-z0-9]+$/i.test(last) && !last.startsWith(":")) + ); +} + +function isExternal(destination: string): boolean { + return /^https?:\/\//i.test(destination); +} + +/** Rewrites that proxy a page to another deployment. */ +export function pageRewrites(rewrites: Route[]): Route[] { + return rewrites.filter( + (r) => isExternal(r.destination) && !isAssetSource(r.source), + ); +} + +/** + * Every reason the proxied pages are not all research entries' or listed: + * an unreadable source, or a page path that is neither a research app's nor + * on `routes` or `infrastructure`. A page whose deployment is a research + * app's (one rewrite serving the tracker under every country, say) is that + * app's. + */ +export function pageRewriteProblems( + rewrites: Route[], + appKeys: Set, + routes: string[], + infrastructure: string[], +): string[] { + const listed = new Set([...routes, ...infrastructure]); + const appDeployments = new Set(); + for (const rewrite of pageRewrites(rewrites)) { + const paths = expandSource(rewrite.source)?.paths ?? []; + if (paths.some((p) => appKeys.has(routeEntryKey(p) ?? ""))) { + appDeployments.add(deploymentId(rewrite.destination)); + } + } + const problems: string[] = []; + for (const rewrite of pageRewrites(rewrites)) { + const expanded = expandSource(rewrite.source); + if (!expanded) { + problems.push( + `the rewrite ${rewrite.source} → ${rewrite.destination} proxies a page the comparables gate cannot read; use appZoneRoutes.ts's // form`, + ); + continue; + } + if (appDeployments.has(deploymentId(rewrite.destination))) continue; + for (const path of expanded.paths) { + if (listed.has(path)) continue; + problems.push( + `${path} (rewrite ${rewrite.source} → ${rewrite.destination}) is not a research app's page: add the app to apps.json with its comparables record, or, if it publishes no analysis, to the infrastructure list in comparablesGrandfathered.json`, + ); + } + } + return problems; +} + +/** Pages served from a research app's deployment count as the app's. */ +function deploymentId(destination: string): string { + const parts = urlParts(destination); + return parts ? `${parts.host}${parts.path}` : destination; +} + +/** The proxied page paths that are no research app's, for checking the lists. */ +export function unlistedPagePaths( + rewrites: Route[], + appKeys: Set, +): string[] { + return [ + ...new Set( + pageRewriteProblems(rewrites, appKeys, [], []).map( + (problem) => problem.split(" ")[0], + ), + ), + ].sort(); +} + +function urlParts(url: string): { host: string; path: string } | null { + try { + const parsed = new URL(url); + const path = parsed.pathname + .toLowerCase() + .replace(WILDCARD_SUFFIX, "") + .replace(/\/+$/, ""); + return { host: parsed.hostname.toLowerCase(), path: path || "/" }; + } catch { + return null; + } +} + +/** + * Every path and host that leads to a research app. Paths: each app's own + * path, each proxied page whose deployment is an app's, and each redirect + * that ends at one of those. Hosts: each app's deployment, from its rewrite + * and its registry source; a host shared by several apps (GitHub Pages, one + * deployment serving two countries) is narrowed to the path under it. + */ +export function buildAnalysisRoutes( + rewrites: Route[], + redirects: Route[], + apps: Array<{ slug?: string; countryId?: string; source?: string }>, + appKeys: Set, +): AnalysisRoutes { + const paths = new Map(); + const add = (path: string, prefix: boolean, entry: string) => { + const existing = paths.get(path); + if (!existing || (prefix && !existing.prefix)) { + paths.set(path, { path, prefix, entry }); + } + }; + for (const key of appKeys) { + const [, cs] = key.split(" "); + add(`/${cs}`, true, key); + } + + // deployments: where each app's pages are proxied to, and its registry source + const deployments: Array<{ host: string; path: string; entry: string }> = []; + const byDestination = new Map(); + for (const rewrite of pageRewrites(rewrites)) { + const expanded = expandSource(rewrite.source); + const parts = urlParts(rewrite.destination); + if (!expanded || !parts) continue; + for (const path of expanded.paths) { + const key = routeEntryKey(path); + if (key && appKeys.has(key)) { + deployments.push({ ...parts, entry: key }); + byDestination.set(`${parts.host}${parts.path}`, key); + } + } + } + for (const app of apps) { + const key = `app ${app.countryId}/${app.slug}`; + if (!appKeys.has(key) || !app.source) continue; + const parts = urlParts(app.source); + if (parts) deployments.push({ ...parts, entry: key }); + } + // a proxied page that is not an app's own path but serves an app's deployment + for (const rewrite of pageRewrites(rewrites)) { + const expanded = expandSource(rewrite.source); + const parts = urlParts(rewrite.destination); + if (!expanded || !parts) continue; + const entry = byDestination.get(`${parts.host}${parts.path}`); + if (!entry) continue; + // a zone route serves its deeper pages too, with or without a /:path* twin + for (const path of expanded.paths) add(path, true, entry); + } + // redirects that end at an analysis + const resolve = (path: string): PathRoute | undefined => { + const exact = paths.get(path); + if (exact) return exact; + for (const route of paths.values()) { + if (route.prefix && path.startsWith(`${route.path}/`)) return route; + } + return undefined; + }; + for (let pass = 0; pass < 3; pass += 1) { + for (const redirect of redirects) { + if (isExternal(redirect.destination)) continue; + const from = expandSource(redirect.source); + const to = expandSource(redirect.destination); + if (!from || !to) continue; + from.paths.forEach((path, i) => { + const target = resolve(to.paths[Math.min(i, to.paths.length - 1)]); + if (!target || target.path === path) return; + // a redirect runs before any page, so it decides where the path leads + const existing = paths.get(path); + const prefix = + from.prefix || + (existing?.entry === target.entry && existing.prefix) || + false; + paths.set(path, { path, prefix, entry: target.entry }); + }); + } + } + + // hosts: a host one app owns is all its; a shared one is narrowed by path + const owners = new Map>(); + for (const d of deployments) { + if (!owners.has(d.host)) owners.set(d.host, new Set()); + owners.get(d.host)!.add(d.entry); + } + const hosts = new Map(); + for (const d of deployments) { + const shared = (owners.get(d.host)?.size ?? 0) > 1; + // a GitHub Pages host serves one project per first path segment + const project = d.path.split("/").filter(Boolean)[0]; + const pathPrefix = d.host.endsWith(".github.io") + ? project + ? `/${project}` + : "/" + : shared + ? d.path + : "/"; + const id = `${d.host}${pathPrefix}`; + const route = hosts.get(id) ?? { host: d.host, pathPrefix, entries: [] }; + if (!route.entries.includes(d.entry)) route.entries.push(d.entry); + route.entries.sort(); + hosts.set(id, route); + } + + return { + schema: ROUTES_SCHEMA, + paths: [...paths.values()].sort((a, b) => a.path.localeCompare(b.path)), + hosts: [...hosts.values()].sort((a, b) => + `${a.host}${a.pathPrefix}`.localeCompare(`${b.host}${b.pathPrefix}`), + ), + }; +} diff --git a/website/src/data/comparables.ts b/website/src/data/comparables.ts new file mode 100644 index 000000000..f52cddabd --- /dev/null +++ b/website/src/data/comparables.ts @@ -0,0 +1,804 @@ +/** + * Pre-publish comparables (Max, 2026-10-21). + * + * Before an analysis is listed on policyengine.org, every external estimate + * of what it estimates is searched for, recorded in + * PolicyEngine/policyengine-scorecard (docs/COMPARABLES.md there), compared + * with the analysis's own figures, and every gap over the scorecard's + * threshold is explained. A research entry carries a `comparables` block + * naming that record: + * + * "comparables": { + * "status": "reviewed", + * "scorecardSource": "analysis-uk-some-dashboard", + * "searchDate": "2026-11-02", + * "searchKind": "prepublish", + * "producersSearched": ["academic", "centax", ...], + * "found": 4, + * "searchLog": "https://github.com/PolicyEngine/policyengine-scorecard/blob/main/sources/analysis-uk-some-dashboard/search_log.json" + * } + * + * `python -m scorecard_db.comparables record ` in the scorecard + * prints the block. `found` counts the comparables staged as claims; the + * search log also lists any seen but not staged. A post that is plainly not + * an analysis (an event, an announcement) may declare + * `{"status": "no_estimate", "reason": "..."}` instead; an app never may. + * + * Which entries need a block is decided by identity, not by the date an + * entry carries: every research entry needs one unless it is on the list of + * entries that were live before the gate (comparablesGrandfathered.json). + * An entry taken off the site leaves that list, so it comes back only with a + * record. Entries may join the list only before the cutover; after it the + * list only shrinks. + * + * `validateComparables` checks the block on its own (the Tests job). + * `resolveComparables` checks it against the scorecard's published index, + * and `publicationProblems` and `promotionProblems` check what a change + * lists or features against it on the day (the Comparables gate workflow, + * which downloads the index from the scorecard's main branch), so the + * scorecard record merges first. + */ + +import grandfatheredData from "./comparablesGrandfathered.json"; +import { postSlug } from "./posts/postTransformers"; + +/** + * After this day no entry may join the grandfather list. Pinned no later + * than 2026-10-29 by the tests: Max's call (decision d1812). + */ +export const COMPARABLES_CUTOVER_DATE = "2026-10-29"; + +/** A search more than this many days before an entry is listed is stale. */ +export const MAX_SEARCH_AGE_DAYS = 30; + +const SCORECARD = "https://github.com/PolicyEngine/policyengine-scorecard"; +/** The Comparables gate workflow downloads this literal; a test pins the two together. */ +export const SCORECARD_INDEX_URL = + "https://raw.githubusercontent.com/PolicyEngine/policyengine-scorecard/main/data/comparables/index.json"; +export const INDEX_SCHEMA = "comparables/index/1"; + +/** + * Which entries need a record, as the scorecard applies them + * (scorecard_db/comparables.py). The index publishes its own copy under + * `entry_rules`, and the gate checks the two agree. + */ +export const COUNTRY_TAGS = ["uk", "us", "ca", "ng", "il"] as const; +/** The website files a post with no country tag under us. */ +export const DEFAULT_COUNTRY = "us"; +export const ANALYSIS_TAGS = [ + "2024-election", + "autumn-budget", + "behavioral-responses", + "benefit", + "benefit-access", + "child-tax-credit", + "election", + "healthcare", + "inflation", + "interactives", + "policy", + "reconciliation", + "tariffs", + "tax", + "technical", + "vat", +] as const; +export const NO_ESTIMATE_TAGS = [ + "april-fools", + "conferences", + "event", + "giving", + "org", + "year-in-review", +] as const; +export const SEARCH_KINDS = [ + "prepublish", + "backfill", + "reharvest", + "prepromotion", +] as const; + +const SOURCE_PATTERN = /^analysis-(us|uk|ca|ng|il)-([a-z0-9]+(?:-[a-z0-9]+)*)$/; +const PRODUCER_PATTERN = /^[a-z0-9]+(?:_[a-z0-9]+)*$/; +const DATE_PATTERN = /^\d{4}-\d{2}-\d{2}$/; +const REGISTRY_DATE_PATTERN = + /^(\d{4}-\d{2}-\d{2})(?: \d{2}:\d{2}(?::\d{2})?)?$/; +const MIN_REASON_LENGTH = 20; +const REVIEWED_FIELDS = [ + "status", + "scorecardSource", + "searchDate", + "searchKind", + "producersSearched", + "found", + "searchLog", +] as const; + +export type SearchKind = (typeof SEARCH_KINDS)[number]; + +export interface ReviewedComparables { + status: "reviewed"; + scorecardSource: string; + searchDate: string; + searchKind: SearchKind; + producersSearched: string[]; + found: number; + searchLog: string; +} + +export interface NoEstimateComparables { + status: "no_estimate"; + reason: string; +} + +export type ComparablesRecord = ReviewedComparables | NoEstimateComparables; + +/** A research listing on policyengine.org: an app shown with research or tagged policy, or a post. */ +export interface ResearchEntry { + kind: "app" | "post"; + slug: string; + /** Countries the entry can be recorded under: an app's countryId, a post's country tags. */ + countryIds: string[]; + /** + * The day the entry is listed, YYYY-MM-DD; the registry's own string when + * it is not a date, and null when it has none. + */ + date: string | null; + tags: string[]; + comparables?: unknown; +} + +export interface Grandfathered { + snapshotDate: string; + /** entryKey() of each research entry live before the gate. */ + entries: string[]; + /** Proxied pages live before the gate that are not a research entry's. */ + routes: string[]; + /** Proxied pages that publish no analysis; may grow, with review. */ + infrastructure?: string[]; +} + +export const GRANDFATHERED: Grandfathered = grandfatheredData; + +export interface IndexSearch { + date: string; + kind: string; + producers_searched: string[]; + found: number; + /** The results files the search compared (repo@commit:sha256). */ + results_pins?: string[]; +} + +export interface IndexComparison { + claim: string; + status: string; + found_on?: string; +} + +export interface IndexEntry { + kind: string; + country_id: string; + slug: string; + searches: IndexSearch[]; + search_log: string; + /** The results files the analysis's estimates are read from now. */ + current_pins?: string[]; + comparisons?: IndexComparison[]; +} + +export interface EntryRules { + analysis_tags: string[]; + no_estimate_tags: string[]; + country_tags: string[]; + default_country: string; + search_kinds: string[]; +} + +export interface ComparablesIndex { + schema: string; + gap_threshold: number; + promotion_window_days?: number; + entry_rules?: EntryRules; + analyses: Record; +} + +interface AppLike { + slug?: string; + countryId?: string; + date?: string; + tags?: unknown; + displayWithResearch?: boolean; + comparables?: unknown; +} + +interface PostLike { + filename: string; + date: string; + tags: string[]; + comparables?: unknown; +} + +export { postSlug }; + +function registryDate(raw: unknown): string | null { + if (typeof raw !== "string" || raw === "") return null; + const match = raw.match(REGISTRY_DATE_PATTERN); + return match ? match[1] : raw; +} + +function stringTags(raw: unknown): string[] { + return Array.isArray(raw) + ? raw.filter((tag): tag is string => typeof tag === "string") + : []; +} + +/** The entries the comparables rules cover, as the scorecard's research_entries lists them. */ +export function researchEntries( + apps: AppLike[], + posts: PostLike[], +): ResearchEntry[] { + const fromApps: ResearchEntry[] = apps + .filter( + (app) => + app.slug && + app.countryId && + (app.displayWithResearch || stringTags(app.tags).includes("policy")), + ) + .map((app) => ({ + kind: "app", + slug: app.slug as string, + countryIds: [app.countryId as string], + date: registryDate(app.date), + tags: stringTags(app.tags), + comparables: app.comparables, + })); + const fromPosts: ResearchEntry[] = posts.map((post) => { + const countries = post.tags.filter((tag) => + (COUNTRY_TAGS as readonly string[]).includes(tag), + ); + return { + kind: "post", + slug: postSlug(post.filename), + countryIds: countries.length ? countries : [DEFAULT_COUNTRY], + date: registryDate(post.date), + tags: post.tags, + comparables: post.comparables, + }; + }); + return [...fromApps, ...fromPosts]; +} + +/** An entry's identity: an app by country and slug, a post by slug. */ +export function entryKey(entry: ResearchEntry): string { + return entry.kind === "app" + ? `app ${entry.countryIds[0]}/${entry.slug}` + : `post ${entry.slug}`; +} + +export function requiresComparables( + entry: ResearchEntry, + grandfathered: Grandfathered = GRANDFATHERED, +): boolean { + return !grandfathered.entries.includes(entryKey(entry)); +} + +/** Whether an entry may say it publishes no estimate (scorecard: may_declare_no_estimate). */ +export function mayDeclareNoEstimate(entry: ResearchEntry): boolean { + return ( + entry.kind === "post" && + entry.tags.some((tag) => + (NO_ESTIMATE_TAGS as readonly string[]).includes(tag), + ) && + !entry.tags.some((tag) => + (ANALYSIS_TAGS as readonly string[]).includes(tag), + ) + ); +} + +export function entryLabel(entry: ResearchEntry): string { + return `${entry.kind} ${entry.countryIds.join("/")}/${entry.slug}`; +} + +export function isValidDate(value: unknown): value is string { + if (typeof value !== "string" || !DATE_PATTERN.test(value)) return false; + const parsed = new Date(`${value}T00:00:00Z`); + return ( + !Number.isNaN(parsed.getTime()) && + parsed.toISOString().slice(0, 10) === value + ); +} + +function daysBetween(earlier: string, later: string): number { + return ( + (Date.parse(`${later}T00:00:00Z`) - Date.parse(`${earlier}T00:00:00Z`)) / + 86_400_000 + ); +} + +export function searchLogUrl(source: string): string { + return `${SCORECARD}/blob/main/sources/${source}/search_log.json`; +} + +const HOW_TO_FIX = + "run the comparables review (the policyengine-comparables-review skill; docs/COMPARABLES.md in PolicyEngine/policyengine-scorecard) and paste the block `python -m scorecard_db.comparables record ` prints"; + +/** + * Every reason an entry's comparables block is missing or malformed, read + * on its own. A grandfathered entry needs no block, but a block it carries + * must be well formed. + */ +export function validateComparables( + entry: ResearchEntry, + grandfathered: Grandfathered = GRANDFATHERED, +): string[] { + const label = entryLabel(entry); + const record = entry.comparables; + const required = requiresComparables(entry, grandfathered); + const errors: string[] = []; + if (required && !isValidDate(entry.date)) { + errors.push( + `${label}: a research entry needs a publication date, YYYY-MM-DD (got ${JSON.stringify(entry.date)})`, + ); + } + if (record === undefined) { + if (required) { + errors.push( + `${label} is not on the list of entries live before the comparables gate, so it needs a comparables block: ${HOW_TO_FIX}`, + ); + } + return errors; + } + if (typeof record !== "object" || record === null || Array.isArray(record)) { + return [...errors, `${label}: comparables must be an object`]; + } + const r = record as Record; + if (r.status === "no_estimate") { + if ( + typeof r.reason !== "string" || + r.reason.trim().length < MIN_REASON_LENGTH + ) { + errors.push( + `${label}: no_estimate needs a reason of ${MIN_REASON_LENGTH}+ characters`, + ); + } + if (!mayDeclareNoEstimate(entry)) { + errors.push( + `${label}: only a post tagged ${NO_ESTIMATE_TAGS.join(", ")} and none of ${ANALYSIS_TAGS.join(", ")} may declare no_estimate; ${HOW_TO_FIX}`, + ); + } + if (Object.keys(r).some((k) => k !== "status" && k !== "reason")) { + errors.push(`${label}: no_estimate carries only status and reason`); + } + return errors; + } + if (r.status !== "reviewed") { + return [ + ...errors, + `${label}: comparables.status must be "reviewed" or "no_estimate"`, + ]; + } + for (const key of Object.keys(r)) { + if (!(REVIEWED_FIELDS as readonly string[]).includes(key)) { + errors.push(`${label}: unknown field ${key}`); + } + } + const source = r.scorecardSource; + if (typeof source !== "string" || !SOURCE_PATTERN.test(source)) { + errors.push( + `${label}: scorecardSource must be analysis--, got ${JSON.stringify(source)}`, + ); + } else { + const expected = entry.countryIds.map( + (country) => `analysis-${country}-${entry.slug}`, + ); + if (!expected.includes(source)) { + errors.push( + `${label}: scorecardSource ${source} does not name this entry (expected ${expected.join(" or ")})`, + ); + } + if (r.searchLog !== searchLogUrl(source)) { + errors.push(`${label}: searchLog must be ${searchLogUrl(source)}`); + } + } + const searchDate = r.searchDate; + if (!isValidDate(searchDate)) { + errors.push(`${label}: searchDate must be a real YYYY-MM-DD date`); + } + if (!(SEARCH_KINDS as readonly unknown[]).includes(r.searchKind)) { + errors.push( + `${label}: searchKind must be one of ${SEARCH_KINDS.join(", ")}`, + ); + } + if (required && isValidDate(searchDate) && isValidDate(entry.date)) { + if (r.searchKind === "backfill") { + errors.push( + `${label}: a backfill is a search after publishing; an entry listed under the gate needs a search before it is listed`, + ); + } + if (searchDate > entry.date) { + errors.push( + `${label}: searched on ${searchDate}, after it was listed on ${entry.date}`, + ); + } else if (daysBetween(searchDate, entry.date) > MAX_SEARCH_AGE_DAYS) { + errors.push( + `${label}: the search (${searchDate}) is more than ${MAX_SEARCH_AGE_DAYS} days before the listing (${entry.date}); search again`, + ); + } + } + const producers = r.producersSearched; + if ( + !Array.isArray(producers) || + producers.length === 0 || + !producers.every( + (p) => typeof p === "string" && PRODUCER_PATTERN.test(p), + ) || + new Set(producers).size !== producers.length + ) { + errors.push( + `${label}: producersSearched must list each producer slug once`, + ); + } + if ( + typeof r.found !== "number" || + !Number.isInteger(r.found) || + r.found < 0 + ) { + errors.push( + `${label}: found must be a whole number (the comparables staged; 0 when none)`, + ); + } + return errors; +} + +function sameSet(a: string[], b: string[]): boolean { + if (a.length !== b.length) return false; + const sa = [...a].sort(); + const sb = [...b].sort(); + return sa.every((value, i) => value === sb[i]); +} + +/** Every reason the downloaded index is not one this gate can trust. */ +export function checkIndex(index: unknown): string[] { + if (typeof index !== "object" || index === null) { + return ["the scorecard index is not a JSON object"]; + } + const i = index as Record; + const errors: string[] = []; + if (i.schema !== INDEX_SCHEMA) { + errors.push( + `the scorecard index schema is ${JSON.stringify(i.schema)}, expected ${INDEX_SCHEMA}`, + ); + } + if ( + typeof i.analyses !== "object" || + i.analyses === null || + Array.isArray(i.analyses) + ) { + errors.push("the scorecard index has no analyses object"); + } + const rules = i.entry_rules as EntryRules | undefined; + if (!rules) { + errors.push("the scorecard index publishes no entry_rules"); + } else { + const ours: EntryRules = { + analysis_tags: [...ANALYSIS_TAGS], + no_estimate_tags: [...NO_ESTIMATE_TAGS], + country_tags: [...COUNTRY_TAGS], + default_country: DEFAULT_COUNTRY, + search_kinds: [...SEARCH_KINDS], + }; + for (const key of Object.keys(ours) as Array) { + const theirs = rules[key]; + const same = Array.isArray(ours[key]) + ? Array.isArray(theirs) && + sameSet(ours[key] as string[], theirs as string[]) + : ours[key] === theirs; + if (!same) { + errors.push( + `the scorecard's ${key} (${JSON.stringify(theirs)}) differs from comparables.ts (${JSON.stringify(ours[key])})`, + ); + } + } + } + return errors; +} + +/** + * Every reason a well-formed reviewed block does not resolve to a complete + * record in the scorecard's published index. The index lists only records + * that passed the scorecard's gate, so a match proves the record is + * complete; whether it is ready for the change that lists the entry (a + * search fresh that day, against the current results, with no gap pending) + * is publicationProblems's question. + */ +export function resolveComparables( + entry: ResearchEntry, + index: ComparablesIndex, +): string[] { + const label = entryLabel(entry); + const record = entry.comparables as ReviewedComparables | undefined; + if (!record || record.status !== "reviewed") return []; + if (index.schema !== INDEX_SCHEMA) { + return [ + `the scorecard index schema is ${index.schema}, expected ${INDEX_SCHEMA}`, + ]; + } + const recorded = index.analyses[record.scorecardSource]; + if (!recorded) { + return [ + `${label}: ${record.scorecardSource} is not in the scorecard index on main; merge its scorecard PR first`, + ]; + } + const errors: string[] = []; + if (recorded.kind !== entry.kind || recorded.slug !== entry.slug) { + errors.push( + `${label}: the scorecard records ${record.scorecardSource} as ${recorded.kind} ${recorded.slug}`, + ); + } + const sourceCountry = SOURCE_PATTERN.exec(record.scorecardSource)?.[1]; + if ( + recorded.country_id !== sourceCountry || + !entry.countryIds.includes(recorded.country_id) + ) { + errors.push( + `${label}: the scorecard records ${record.scorecardSource} under ${recorded.country_id}`, + ); + } + if (recorded.search_log !== record.searchLog) { + errors.push(`${label}: searchLog differs from the scorecard's`); + } + const sameDay = recorded.searches.filter( + (s) => s.date === record.searchDate && s.kind === record.searchKind, + ); + if (sameDay.length === 0) { + errors.push( + `${label}: the scorecard has no ${record.searchKind} search of ${record.scorecardSource} on ${record.searchDate}`, + ); + return errors; + } + const matches = sameDay.some( + (s) => + sameSet(s.producers_searched, record.producersSearched) && + s.found === record.found, + ); + if (!matches) { + const only = sameDay.length === 1 ? sameDay[0] : null; + if (only && !sameSet(only.producers_searched, record.producersSearched)) { + errors.push( + `${label}: producersSearched differs from the scorecard's search log`, + ); + } + if (only && only.found !== record.found) { + errors.push( + `${label}: found is ${record.found}, the scorecard's search found ${only.found}`, + ); + } + if (!only) { + errors.push( + `${label}: none of the scorecard's ${record.searchKind} searches on ${record.searchDate} has these producers and this count`, + ); + } + } + return errors; +} + +/** + * Every way the grandfather list has grown since `base`, which it may only + * do before the cutover. `base` is the list on the branch a change merges + * into; null when that branch has no list yet. + */ +export function grandfatherAdditions( + base: Grandfathered | null, + head: Grandfathered, + today: string, +): string[] { + if (!base) return []; + const added = [ + ...head.entries.filter((key) => !base.entries.includes(key)), + ...head.routes.filter((route) => !base.routes.includes(route)), + ]; + if (today < COMPARABLES_CUTOVER_DATE || added.length === 0) return []; + return [ + `the comparables grandfather list only shrinks after ${COMPARABLES_CUTOVER_DATE}, but this change adds ${added.join(", ")}: give each a comparables block instead`, + ]; +} + +/** An app route's path as an entry's (/uk/slug), or null for another shape. */ +export function routeEntryKey(route: string): string | null { + const match = route.match(/^\/(us|uk|ca|ng|il)\/([a-z0-9]+(?:-[a-z0-9]+)*)$/); + return match ? `app ${match[1]}/${match[2]}` : null; +} + +/** + * Why an analysis may not be published or promoted on ``on``: the + * scorecard's ``comparables.fresh``. It needs a search in the window up to + * and including ``on`` that compared the results files the analysis reads + * now, and no gap found by then still pending (a pending gap with no date + * counts as found). Tested against the scorecard's own cases. + */ +export function freshness( + entry: IndexEntry, + on: string, + windowDays: number, +): string[] { + const start = addDaysTo(on, -windowDays); + const reasons: string[] = []; + const pins = [...(entry.current_pins ?? [])].sort(); + const recent = entry.searches.filter((s) => start <= s.date && s.date <= on); + if (recent.length === 0) { + const earlier = entry.searches.map((s) => s.date).filter((d) => d <= on); + const last = earlier.length ? earlier.sort().at(-1) : "none"; + reasons.push( + `no comparables search between ${start} and ${on} (last: ${last}); run a prepromotion search first`, + ); + } else if ( + !recent.some((s) => sameList([...(s.results_pins ?? [])].sort(), pins)) + ) { + reasons.push( + `no search between ${start} and ${on} compared the results the page reads now; run a prepromotion search against them`, + ); + } + const pending = (entry.comparisons ?? []).filter( + (c) => c.status === "pending" && (c.found_on ?? "") <= on, + ); + if (pending.length) { + reasons.push( + `gaps still pending by ${on}: ${pending.map((c) => c.claim).join(", ")}; explain them first`, + ); + } + return reasons; +} + +function addDaysTo(date: string, days: number): string { + return new Date(Date.parse(`${date}T00:00:00Z`) + days * 86_400_000) + .toISOString() + .slice(0, 10); +} + +function sameList(a: string[], b: string[]): boolean { + return a.length === b.length && a.every((value, i) => value === b[i]); +} + +/** The index record an entry's block names, or the one its name implies. */ +export function recordFor( + entry: ResearchEntry, + index: ComparablesIndex, +): { source: string; record?: IndexEntry } { + const block = entry.comparables as Partial | undefined; + const candidates = + block?.status === "reviewed" && typeof block.scorecardSource === "string" + ? [block.scorecardSource] + : entry.countryIds.map((c) => `analysis-${c}-${entry.slug}`); + for (const source of candidates) { + const record = index.analyses[source]; + if (record && record.kind === entry.kind && record.slug === entry.slug) { + return { source, record }; + } + } + return { source: candidates[0] }; +} + +/** + * Entries a change lists or re-lists: new to the registry, or with a new + * date or comparables block. Unchanged entries are not re-judged, so the + * archive does not expire as time passes. + */ +export function changedEntries( + base: ResearchEntry[], + head: ResearchEntry[], +): ResearchEntry[] { + const before = new Map(base.map((e) => [entryKey(e), e])); + return head.filter((entry) => { + const old = before.get(entryKey(entry)); + return ( + !old || + old.date !== entry.date || + JSON.stringify(old.comparables) !== JSON.stringify(entry.comparables) + ); + }); +} + +/** + * Why a change may not list an entry today: the search its block cites must + * be no more than MAX_SEARCH_AGE_DAYS old on the day the change is checked + * (whatever date the entry carries), must have compared the results files + * the analysis reads now, and no gap found by today may still be pending. + */ +export function publicationProblems( + entry: ResearchEntry, + index: ComparablesIndex, + today: string, +): string[] { + const label = entryLabel(entry); + const block = entry.comparables as ReviewedComparables | undefined; + if (!block || block.status !== "reviewed") return []; + const record = index.analyses[block.scorecardSource]; + if (!record) return []; + const search = record.searches.find( + (s) => + s.date === block.searchDate && + s.kind === block.searchKind && + sameSet(s.producers_searched, block.producersSearched) && + s.found === block.found, + ); + if (!search) return []; + const problems: string[] = []; + if (search.date > today) { + problems.push( + `${label}: its search is dated ${search.date}, after today (${today})`, + ); + } else if (daysBetween(search.date, today) > MAX_SEARCH_AGE_DAYS) { + problems.push( + `${label}: its search (${search.date}) is more than ${MAX_SEARCH_AGE_DAYS} days before today (${today}), when this change lists it; search again`, + ); + } + if ( + !sameList( + [...(search.results_pins ?? [])].sort(), + [...(record.current_pins ?? [])].sort(), + ) + ) { + problems.push( + `${label}: its search did not compare the results the analysis reads now; cite the search that did`, + ); + } + const pending = (record.comparisons ?? []).filter( + (c) => c.status === "pending" && (c.found_on ?? "") <= today, + ); + if (pending.length) { + problems.push( + `${label}: gaps still pending in ${block.scorecardSource}: ${pending.map((c) => c.claim).join(", ")}; explain them before listing it`, + ); + } + return problems; +} + +/** The hrefs a featured research banner links. */ +export function bannerHrefs(source: string): string[] { + return [...source.matchAll(/href:\s*["'`]([^"'`]+)["'`]/g)].map((m) => m[1]); +} + +/** The research entry a featured card's href links, if any. */ +export function entryForHref( + href: string, + entries: ResearchEntry[], +): ResearchEntry | undefined { + const app = routeEntryKey(href); + const post = href.match(/^\/[a-z]{2}\/research\/([a-z0-9-]+)$/); + return entries.find( + (e) => + (app && entryKey(e) === app) || + (post && e.kind === "post" && e.slug === post[1]), + ); +} + +/** + * Why a change may not feature these cards: each card it adds must link a + * research entry whose comparables search is fresh today, under the + * scorecard's promotion window, grandfathered entries included. + */ +export function promotionProblems( + added: string[], + entries: ResearchEntry[], + index: ComparablesIndex, + today: string, +): string[] { + const window = index.promotion_window_days; + if (typeof window !== "number") { + return ["the scorecard index publishes no promotion_window_days"]; + } + return added.flatMap((href) => { + const entry = entryForHref(href, entries); + if (!entry) return [`featured card ${href} links no research entry`]; + if (mayDeclareNoEstimate(entry)) return []; + const { source, record } = recordFor(entry, index); + if (!record) { + return [ + `featured card ${href}: ${source} has no comparables record; run the comparables review (prepromotion) before featuring it`, + ]; + } + return freshness(record, today, window).map( + (reason) => `featured card ${href}: ${reason}`, + ); + }); +} diff --git a/website/src/data/comparablesGrandfathered.json b/website/src/data/comparablesGrandfathered.json new file mode 100644 index 000000000..c2ab58e69 --- /dev/null +++ b/website/src/data/comparablesGrandfathered.json @@ -0,0 +1,291 @@ +{ + "_what": "policyengine.org research entries and proxied pages that were live before the comparables gate (website/src/data/comparables.ts). An entry listed here needs no comparables block; any other needs one that names a complete record in PolicyEngine/policyengine-scorecard, whatever date it carries. An entry or route taken off the site leaves this list, so it comes back only with a record. Entries may be added only before the cutover; after it the list only shrinks (the Comparables gate workflow checks both).", + "snapshotDate": "2026-10-22", + "entries": [ + "app uk/2024-manifestos", + "app uk/autumn-budget-2025", + "app uk/bus-fare-cap", + "app uk/cancelling-fuel-duty-rise", + "app uk/electricity-vat-cut", + "app uk/energy-autumn-budget", + "app uk/energy-price-shock", + "app uk/free-childcare-reform", + "app uk/local-areas-dashboard", + "app uk/marriage", + "app uk/middle-east-war-living-standards", + "app uk/nics-exemption-inactive-employees", + "app uk/public-services-spending", + "app uk/scotland-income-tax-reform", + "app uk/scottish-budget-2026-27", + "app uk/spring-statement-2026", + "app uk/student-loan-visualisation", + "app uk/targeted-energy-discount", + "app uk/triple-lock", + "app uk/two-child-limit-comparison", + "app uk/uc-rebalancing", + "app uk/uk-cliff-watch", + "app uk/uk-land-value-tax", + "app uk/uk-salary-sacrifice-tool", + "app uk/uk-student-loan-calculator", + "app uk/young-worker-nics", + "app us/2024-election-calculator", + "app us/aca-calc", + "app us/aca-reforms-calculator", + "app us/bill-tracker", + "app us/california-wealth-tax", + "app us/child-poverty-impact-dashboard", + "app us/child-tax-credit-2024-election-calculator", + "app us/child-tax-credit-calculator", + "app us/cliffwatch", + "app us/coverage-compass", + "app us/encode-policy-multi-agent-ai", + "app us/futa-wage-base-dashboard", + "app us/givecalc", + "app us/keep-your-pay-act", + "app us/marriage", + "app us/missouri-income-tax-elimination", + "app us/nj-ctc-increase", + "app us/obbba-households", + "app us/obbba-scatter", + "app us/oregon-kicker-refund", + "app us/pe84", + "app us/rhode-island-ctc-calculator", + "app us/salternative", + "app us/snap-district-map", + "app us/snap-payment-error-simulator", + "app us/south-carolina-2026-tax-changes", + "app us/state-eitcs-ctcs", + "app us/tanf-calculator", + "app us/taxation-of-benefits-reforms", + "app us/utah-2026-tax-changes", + "app us/watca", + "app us/working-parents-tax-relief-act", + "app us/wv-sb392-tax-cut", + "post 2025-spm-poverty-prediction", + "post 2025-supplemental-poverty-measure", + "post american-family-act-2025", + "post american-worker-rebate-act", + "post analysing-autumn-budget-universal-credit-reforms-with-policyengine", + "post analysis-of-guaranteed-income-for-the-21st-century", + "post analysis-of-the-spring-budget-2023", + "post api-v2", + "post april-1st-2025", + "post arnold-ventures-congressional-districts-grant", + "post automate-policy-analysis-with-policy-engines-new-chatgpt-integration", + "post autumn-budget-2024-employer-nic-pension-contributions", + "post autumn-budget-2024-policy-choices", + "post autumn-budget-24-employer-ni", + "post autumn-budget-24-fuel-duty", + "post autumn-statement-2023", + "post behavioural-responses", + "post benefit-uprating-25", + "post biden-budget-2025", + "post breaking-down-policy-impacts-by-wealth-decile", + "post breaking-down-uk-poverty-impacts-by-sex", + "post breaking-down-us-poverty-impacts-by-sex", + "post building-the-roots-of-policyengine-nigeria", + "post california-billionaire-tax-marginal-rates", + "post california-income-tax", + "post cgt-autumn-budget", + "post charitable-contributions", + "post childcare-expansion-2023", + "post citizens-economic-council", + "post computing-your-oregon-earned-income-tax-credit", + "post conservative-2024-manifesto", + "post dc-financial-support-for-families-with-children", + "post dc-office-ai-coding", + "post digital-public-goods-alliance-recognizes-policyengine-as-a-digital-public-good", + "post district-child-tax-credit", + "post earth-day-2025", + "post electric-vehicle-tax-credits-under-current-law-and-the-inflation-reduction-act", + "post enhanced-cps-beta", + "post enhanced-cps-launch", + "post enhanced-premium-tax-credits-extension", + "post enhancing-the-current-population-survey-for-policy-analysis", + "post estimating-your-supplemental-security-income-benefits-in-policyengine", + "post family-first-act", + "post farage-speech-may-2025", + "post federal-tax-inflation-adjustments-2025", + "post final-2025-reconciliation-tax", + "post fisc-act", + "post fiscalsim", + "post from-idea-to-impact-scoring-a-policy-reform-on-the-new-policyengine-uk", + "post from-idea-to-impact-scoring-a-policy-reform-on-the-new-policyengine-us", + "post from-openfisca-to-policyengine", + "post fuel-duty-freeze", + "post givecalc", + "post gpt-analysis", + "post harris-ctc", + "post harris-eitc", + "post high-value-council-tax-surcharge", + "post hmt-policyengine-pilot", + "post how-developers-can-explore-the-policyengine-api", + "post how-machine-learning-tools-make-policyengine-more-accurate", + "post how-policyengine-estimates-the-effects-of-uk-carbon-taxes", + "post how-to-simulate-basic-and-guaranteed-income-policies-in-policyengine-us", + "post how-would-reforms-affect-cliffs", + "post idaho-2025-tax-change", + "post illinois-benefit-hub", + "post impact-of-tax-changes-2025-2026", + "post impact-of-the-chancellors-cost-of-living-support-package", + "post income-tax-cuts-rishi-sunak-is-reportedly-considering", + "post income-tax-freeze", + "post introducing-2024-election-calculator", + "post introducing-aca-calc", + "post introducing-obbba-household-explorer", + "post introducing-policybench", + "post introducing-salternative", + "post introducing-utah-state-income-tax-analysis-on-policyengine", + "post kansas-flat-income-tax-sb-169", + "post kansas-income-tax", + "post keep-your-pay-act-amt-interaction", + "post kentucky-cuts-income-tax-rate", + "post labour-2024-manifesto", + "post lib-dem-2024-manifesto", + "post lift-act", + "post louisiana-flat-tax", + "post make-everyone-a-policymaker", + "post malliotakis-steel-working-families-tax-cut-act", + "post managers-amendment-to-hr1", + "post maryland-standard-deduction", + "post massachusetts-governor-maura-healeys-fy-2024-budget-recommendation", + "post medlock-donation-calculator", + "post medlock-wins", + "post michigan-bill-hb4170", + "post mn-hf1938-walz", + "post montana-tax-cuts-2026", + "post multi-agent-workflows-policy-research", + "post myfriendben-nc", + "post neo-philanthropy", + "post new-mexico-income-tax-launch", + "post new-york-tanf", + "post niskanen-center-analysis", + "post nsf-pose-phase-1-grant", + "post nta-2024", + "post ny-hochul-budget", + "post ny-wftc", + "post nyc-ctc-s2238", + "post obr-forecast-2025", + "post obr-forecast-update-spring-24", + "post obr-november-2025-projections", + "post openfisca-wins-edge-of-government-innovation-award", + "post oregon-rebate", + "post oregons-nonrefundable-exemption-credit", + "post pip-and-freeze", + "post policyengine-10-downing-street", + "post policyengine-2-event-report", + "post policyengine-2022-year-in-review", + "post policyengine-at-the-basic-income-guarantee-conference-and-the-beeck-centers-rules-as-code-demo-day", + "post policyengine-atlanta-fed-mou-prd", + "post policyengine-atlas-pbif-grant", + "post policyengine-better-government-lab-collaboration", + "post policyengine-comes-stateside", + "post policyengine-joss-paper", + "post policyengine-launches-in-new-york-state", + "post policyengine-launches-in-washington-state", + "post policyengine-nber-mou-taxsim", + "post policyengine-usc-collaboration", + "post policyengines-2021-year-in-review", + "post poverty-race-ethnicity", + "post prime-minister-liz-trusss-energy-bill-price-cap", + "post pritzker-childrens-initiative-grant", + "post projected-impact-of-the-uks-extended-energy-price-guarantee", + "post rail-fares-freeze-2025", + "post raising-the-marriage-allowance-from-10-to-100", + "post reform-uks-emergency-recovery-plan", + "post rent-relief-act", + "post repealing-the-two-child-limit", + "post restoration-of-the-american-rescue-plan-acts-expanded-child-tax-credit", + "post restoring-arpa-eitc", + "post ri-ctc-calculator-press-release", + "post ri-governor-mckee-child-tax-credit", + "post rishi-sunaks-proposal-to-cut-the-basic-rate-to-16-percent", + "post salt-caucus-62k-cap", + "post sc-h3492-eitc-refundability", + "post school-vat", + "post sep-2025-london-event", + "post social-security-tax-exemption", + "post spring-budget-2024", + "post stamp-duties-in-policyengine-uk", + "post state-income-tax-2025-update", + "post state-tax-model-beta", + "post stronger-start-working-families-act", + "post tanf-50-state-coverage", + "post tax-cuts-for-workers-act", + "post tax-cuts-in-prime-minister-trusss-growth-plan", + "post tcja-extension", + "post the-child-tax-credit-in-2023", + "post the-green-party-manifesto-at-policyfest", + "post the-new-policyengine-us-population-impact-page", + "post trafwa-ctc", + "post trump-2024", + "post uk-2024-spring-budget", + "post uk-ai-study", + "post uk-benefits-post", + "post uk-calibration-2023-q4", + "post uk-carbon-tax-dividend", + "post uk-childcare-report", + "post uk-combined-reforms-autumn-budget-2025", + "post uk-giving-tuesday-2025", + "post uk-household-ai", + "post uk-income-tax-ni-reforms-2025", + "post uk-mansion-tax-autumn-budget", + "post uk-nuffield-grant", + "post uk-pip-reforms", + "post uk-poverty-analysis", + "post uk-salary-sacrifice-cap", + "post uk-spi-validation", + "post uk-taxes-post", + "post uk-the-new-policyengine", + "post uk-triple-lock-plus", + "post uk-two-child-limit", + "post uk-two-child-limit-reintroduction", + "post uk-vat-thresholds", + "post uk-year-in-review-2024", + "post updating-policyengine-to-reflect-snap-reform-in-the-omnibus-bill", + "post us-behavioral-responses", + "post us-giving-tuesday-2025", + "post us-household-ai", + "post us-the-new-policyengine", + "post us-year-in-review-2024", + "post utah-income-tax-changes", + "post utah-sb60-income-tax-reduction", + "post validating-unemployment-insurance-estimates", + "post vance-ctc", + "post vat-school-comparison", + "post ways-and-means-salt-cap", + "post wfa-means-test", + "post winship-individualized-eitc", + "post wyden-smith-ctc", + "post young-child-exemption-two-child-limit" + ], + "routes": [ + "/2025-year-in-review", + "/ai-beliefs", + "/uk/2025-year-in-review", + "/uk/ai-inequality", + "/us/2025-year-in-review", + "/us/ads-dashboard", + "/us/ai-inequality", + "/us/qbi-calculator", + "/us/refundable-credit-conversion", + "/us/spm-calculator", + "/us/taxsim" + ], + "_infrastructure": "Proxied pages that publish no analysis (API and model documentation, slides, the Belgium model demo, asset paths). They need no comparables record; a new one is added here with the reviewer's agreement that it publishes no estimate.", + "infrastructure": [ + "/_tracker", + "/be", + "/ca/model", + "/il/model", + "/ng/model", + "/plugin-blog", + "/slides", + "/uk/api", + "/uk/model", + "/uk/python", + "/us/api", + "/us/model", + "/us/python" + ] +} diff --git a/website/src/data/posts/postTransformers.ts b/website/src/data/posts/postTransformers.ts index 25b318b8c..428bd65cc 100644 --- a/website/src/data/posts/postTransformers.ts +++ b/website/src/data/posts/postTransformers.ts @@ -48,6 +48,18 @@ export function compareResearchItems( return compareNewestFirst(a, b) || Number(b.isApp) - Number(a.isApp); } +/** + * A post's URL slug: its file name up to the first dot, lowercased, with + * underscores as hyphens. The comparables gate (comparables.ts) and the + * scorecard's comparables records name posts by it. + */ +export function postSlug(filename: string): string { + return filename + .substring(0, filename.indexOf(".")) + .toLowerCase() + .replace(/_/g, "-"); +} + // Lazy-initialized processed data let _postsSorted: BlogPost[] | null = null; let _locationTags: string[] | null = null; @@ -59,11 +71,7 @@ function initPosts() { _postsSorted = [...(postsData as BlogPost[])].sort(compareNewestFirst); for (const post of _postsSorted) { - const filenameWithoutExt = post.filename.substring( - 0, - post.filename.indexOf("."), - ); - post.slug = filenameWithoutExt.toLowerCase().replace(/_/g, "-"); + post.slug = postSlug(post.filename); } const allTags = [...new Set(_postsSorted.flatMap((p) => p.tags))].sort();