Skip to content

Serve the site under policyengine.org/macro - #295

Draft
MaxGhenis wants to merge 14 commits into
mainfrom
serve-under-macro-path
Draft

MaxGhenis wants to merge 14 commits into
mainfrom
serve-under-macro-path

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

PolicyEngine Macro has no policyengine.org address yet, so every link to it names the project's Vercel host. This PR lets www.policyengine.org serve the site at /macro, the way it serves other tools as app zones. The companion website PR adds the route: PolicyEngine/policyengine-app-v2#1616.

What changes

  • site_paths.py (new) moves every root path in served files under /macro. It handles href, src, data, action and poster attributes in any case, CSS selectors on them ([href="/pe"], [href^="/connect"]), CSS url() and fetch().
    • It leaves absolute URLs, //host links, fragments and relative paths alone. It turns "/" + slug into "/macro/" + slug.
    • It reads only plainly spelled paths. All 3,221 root paths it finds in the 92 served files use only ASCII letters, digits and -._/ up to their ? or #, if any, which HTML, CSS, JavaScript and the URL parser all read the same way. The check fails on a path whose part before ? or # holds anything but those characters and ~, or a . or .. segment; on a value that holds a backslash or ${ anywhere; and on a "/macro" that a script may extend, which is any one not followed by a character on a short list. It reads a path to its own closing quote or parenthesis, so it also fails on one that a script string or a template breaks off ('<a href="/' + slug + '">'). mount() and --write leave such a path for a person to respell, edit nothing inside the value of another path they read, and edit nothing after a path whose end they can't tell. So href="/macro archive", href="/macro ", url("/\61.svg") and href="/\host" all fail.
    • Run bare, it fails on any root path of those shapes that lacks the prefix, in tracked files and in pages a generator has created but nobody has added yet. Some shapes pass it unseen: an unquoted attribute, a srcset, a window.location = "/...", a CSS @import without url(), a data-href that a script turns into a link, a leading slash that is itself escaped or encoded, and a string a script assembles. A path inside some other string (data-href="/x?u=url(/a)") is rewritten as if it stood alone. The docstring lists them, and it and CONTRIBUTING say to write those with the prefix.
    • site-provenance runs it as a new gate, and data/refresh.py lists it. --write fixes files in place, and mount() is idempotent.
  • Generators keep writing root paths and call site_paths.mount() on what they splice into a page, so each --check gate compares mounted output with mounted pages. site_nav.render() mounts every page it stamps.
  • vercel.json adds two rewrites (/macro to /, /macro/:path* to /:path*). It also gives each of the 81 redirects and each of the 10 path-scoped header rules (CORS on /data/*, the cache rules) a /macro twin.
    • Vercel matches redirects and headers on the requested path before any rewrite. Without its twin, a proxied /macro/papers would miss the root /papers rule.
    • tests/test_site_paths.py fails if a rule loses its twin, if a twin outlives its original, or if a header twin leaves the place right after its original, which Vercel's header cascade depends on.
  • The PolicyEngine shell. The website's shell rule asks every page it serves for PolicyEngine's header and its footer links.
    • A bar sits above the Macro header on every page: the wordmark, then Research, Model, API, Python and Donate, linking to www.policyengine.org. The website's app-zone-shell-audit fails any zone whose top 140 px lack the wordmark and the Research, Model, API and Donate labels. The links wrap rather than scroll, so none is ever clipped. Python drops below 460 px.
    • The footer gains one row under its main links with the five text links in policyengine.org's own footer, without its contact and social icons and newsletter form: About us, Donate, Developer tools, Privacy policy, and Terms and conditions. It uses 12 px text, the design floor, in white at .94, which keeps AA contrast against the light theme's teal gradient. The footer was one 60 px line on a wide screen; the row makes it 114 px. It adds 29 px at 820 px and 92 px on a phone.
    • tests/test_site_shell.py checks every page's markup: one bar, directly above the header, with the wordmark and the four labels, none hidden on phones; and the footer row, whose markup must equal policyengine.org's five links in its order on the bar's country. The test compares the row's markup as a whole, so any other link in it fails, however it is written. From the footer's start tag to the row, only plain text, links, divs, spans, images and simple SVG icons may stand, and they must nest, so nothing there can hide the row or end the nav before it. The test doesn't parse the page: above the footer it looks only for a comment or an element of six kinds that was opened and not closed. It doesn't check layout. A CSS change that hides the bar or pushes it below 140 px would pass it, and only the website's audit, which measures the drawn page, would catch that. style.css moves to v54.
  • Paths policyengine.org keeps. The website runs its own redirects and icon rewrites before it proxies /macro, and those written /:countryId/... match /macro/... as well: /macro/blog 308s to /macro/research.
    • The rules are blog, blog/<slug>, claude-plugin, methodology and policybench; cliff-watch, state-legislative-tracker and model, each with everything below it; and /macro/<dir>/<icon> for eight icon names such as favicon.svg. So /macro/methodology is taken and /macro/methodology/appendix is free.
    • No page, file, redirect or rewrite here sits at one today. A new test in tests/test_site_paths.py keeps it so and lists the rules. It compares a file both at its own name and with a leading macro/ taken off, since such a file would answer at both. It compares a rule of this project's whose source is itself a pattern as written, so a person has to compare those. Today's only pattern is the /macro/:path* rewrite, which serves the site.
  • The Vercel host still serves the whole tree at its root. Existing links, the /data/* API, the MCP server and data/fetch.py keep working unchanged.

Commits

  1. 1592fab4 adds the tooling, wires the generators, and adds the tests, the vercel.json rules and the CI step.
  2. 784eba03 holds only generated output: 3,146 paths on 2,910 lines in 76 files. Running python3 site_paths.py --write and python3 site_nav.py --write on commit 1 reproduces it exactly (checked: zero-line diff).
  3. a1f81a95 adds the PolicyEngine bar and documents the base path in CONTRIBUTING and CHANGELOG.
  4. d206710e and 54ff184e fix what an adversarial review of commits 1 to 3 found:
    • CSS prefix selectors that had stopped matching, so 12 chips on the pe, olg and pe-microsim pages had lost their icons (models/model-pages.css v25);
    • "/" + slug, which became /macromodels;
    • the bar clipping "Donate" at 360 px and at 421 to 439 px;
    • a site_nav regex that could delete a banner placed under the bar;
    • a MathJax stylesheet hash taken before mounting (connect.css v21);
    • several claims in the docs.
  5. ac14d3ce acts on the first independent review, of 54ff184e. New tests catch a /macro redirect or header twin whose original has gone, and an unquoted url( /macro ) no longer mounts twice.
  6. ac5f9293 acts on the second, of ac14d3ce. It adds the PolicyEngine footer row and restamps all 71 pages. It stops whitespace from ending a quoted path, so href="/macro archive" no longer passes the gate. It adds the test for paths policyengine.org keeps.
  7. 9fb51556 acts on an in-session check of commit 6. site_paths now applies the URL parser's whitespace rules, so href="/macro " isn't mounted twice and href="/macro)x" is caught. The footer row moves to 12 px and AA contrast, and its test checks the exact links and their order. The CHANGELOG lists every kind of link that still names the Vercel host.
  8. 010f0641 acts on an in-session check of commit 7. (Commits 9 and 11 replace the path rules of commits 7 and 8.) site_paths now reads a //host link with a tab or backslash after its first slash as protocol-relative, keeps the trailing spaces of a literal a script extends, trims every leading control character but NUL, and reads attribute and url() names in any case. The footer test also counts the row's <a anchors, and style.css moves to v54, so a preview cached at v53 can't show the old row.
  9. e160bab8 acts on the third independent review, of 010f0641. That review found that commits 7 and 8, by imitating how browsers decode a path, had let through escaped CSS and JavaScript URLs (url("/\61.svg"), fetch("/\x64ata/...")) and an unquoted url() with a U+00A0. site_paths now fails on anything not spelled plainly. The footer test compares the whole row, because an upper-case <A HREF> had passed it. The reserved-path test matches the website's rules as written and reads rewrites that already carry /macro. No page changes.
  10. 3b2b590a names site_paths.py in CONTRIBUTING's list of CI gates.
  11. fae88bf1 closes a hole I found in commit 9 while rereading it. Its matcher stopped at any quote or ${, so href="/macro/a'/../../models" passed, and a browser resolves that to /models. site_paths now reads to the path's own closing quote. No page changes.
  12. 087f9997 makes site_paths.url() raise on a path it can't mount, which it used to return unmounted.
  13. eb03dce5 answers round 4's findings on commits 9 to 12 (see Round 4's findings). No page changes.

Commits 1 and 3 to 13 need reading; commit 2 needs only the rerun.

What I need from Vahid

  1. The approach. This PR serves the site at policyengine.org/macro. The alternative is a subdomain, macro.policyengine.org. It needs no link changes, but it needs a DNS record and a Vercel domain that only Max or you can add. Switching to it later means taking /macro out of every page and stylesheet, not only reverting commit 2: commit 3's bar names /macro/assets/policyengine-white.png, and commit 4 mounts CSS selectors in style.css and models/model-pages.css. The vercel.json rewrites and twins go too. Setting BASE_PATH = "" alone only stops mount().

  2. The double wordmark. The bar's PolicyEngine wordmark sits directly above the Macro header's own PolicyEngine mark. Should the site keep both, or should the header drop its mark?

  3. The footer row. Your compact footer (16 Nov) carried Macro links only. Because the website's shell rule requires PolicyEngine's footer links on every page it serves, this PR adds them as one row under yours (site_nav.PE_FOOTER_LINKS). On a wide screen it takes the footer from one 60 px line to 114 px. Keep it as it is, or restyle it?

  4. Which country the bar and footer link to. policyengine.org has no country-neutral /research (it 404s). Both therefore link to /us/..., as the ai-beliefs zone does, though most Macro models are UK. Should they be /uk/...?

  5. Merge order with your open PRs. I tried each of them against this branch at eb03dce5.

    I suggest merging yours first. This branch then rebases. Take main's side of each conflicted page, merge CHANGELOG.md by hand, and rerun python3 site_paths.py --write, python3 site_nav.py --write, python3 tools/model_hero.py and python3 tools/prerender_math.py.

Links that change once the route is live

The website's repository guidance moves these in a follow-up, after the website merges and deploys the route ("Order matters" in docs/engineering/skills/repository-guidance.md). Before then, they would send readers to a 404.

The tracked files name policyengine-macro.vercel.app 327 times on 326 lines in 90 files. One is the CHANGELOG entry that says these links haven't moved yet. The other 326:

  • Page metadata (185). Every page has a <link rel="canonical"> (71) that names the Vercel host. So do the og:url on 56 pages and the og:image on 58, the 71 pages less the 13 release-note pages.
    • Generators write 24 canonicals, 11 og:url and 12 og:image: economy/topics.py (SITE, the 11 topic pages, all three tags), models/compare/build.py (ORIGIN, canonical and og:image on 1 page) and notes/generate_release_notes.py (a literal on line 210, the canonicals of 12 digests).
    • The pages themselves carry the other 47 canonicals, 45 og:url and 46 og:image tags, written by hand.
  • sitemap.xml (71) and robots.txt (1). economy/topics.py writes the topic entries, and notes/generate_release_notes.py writes the release-note entries from a literal on line 367.
  • Citations on the paper pages (14). The six papers/* pages and reports/define-uk-replication each show a citation and a BibTeX url that name the Vercel host, written by hand.
  • Paper sources (9). Five lines of LaTeX in papers/boe-svar (three), papers/obr-macro and papers/pe-microsim, and four BibTeX entries in papers/define-uk/references.bib and papers/pe-microsim/references.bib. The built PDFs of boe-svar, obr-macro and pe-microsim print the host, so they need a rebuild.
  • API code samples (3). BASE = "https://policyengine-macro.vercel.app/data" on /economy, written by data/build_page.py (SITE), and on the two rates topic pages, written by economy/topics.py (SITE). The data API keeps working on the Vercel host, so whether these move is a choice.
  • README.md (14 on 13 lines). Line 9, its first link, names the host twice. So do the model links on lines 94 to 109 and the data links on lines 268 and 275.
  • Calendar (20, of which 10 move). The 10 URL: lines in data/calendar.ics, which data/build_page.py's SITE constant writes, move.
    • The other 10 are event UIDs, which its HOST constant writes. Leave those alone: calendar apps treat a changed UID as a new event, so every subscriber would see each event twice.
  • Source constants and project metadata (9, of which 8 move). The six constants and literals named above (SITE and HOST in data/build_page.py, SITE in economy/topics.py, ORIGIN in models/compare/build.py, the two literals in notes/generate_release_notes.py), plus CITATION.cff (url), integration/pyproject.toml (Homepage) and the User-Agent in data/fetch.py. HOST stays, for the UIDs.
  • Outside the tree. The GitHub homepage setting, which a repository admin changes.
  • A 308 redirect from the Vercel host to https://www.policyengine.org/macro. The guide's static-site form maps /(.*) to the same path on policyengine.org, which would send this host's old root links, such as /economy, to website 404s.
    • So the follow-up maps / to /macro and /(.*) to /macro/$1, behind a /macro/(.*) rule that keeps its path. This is the guide's "Hosts that serve paths unlike the website's" case.
    • It should leave /data/* alone. Outside clients call that API on the Vercel host by absolute URL, and a redirect without CORS headers breaks a browser's cross-origin call.
    • This site's CSP sets base-uri 'self' (vercel.json). The website's direct-host audit won't read a page whose CSP sets base-uri (unreadableHeaders in .github/scripts/audit-zone-direct-hosts.mjs), and it probes every zone's host whether or not the list names it. So once the host's 308 deploys, the audit would report /macro's canonical check as unreachable and never show that the route qualifies for the list. Settle that, by dropping the directive or by asking the website maintainers, before adding the redirect.

Open, not in this PR

  • GA4. The website's tracking audit expects the GA4 bootstrap on every zone page, and this site has none; its CSP would block the tag anyway. Decide on GA4 tracking before policyengine.org/macro goes live #296 tracks the decision, which you and the website maintainers need to make before the website PR merges.
  • An unknown path under /macro gets Vercel's plain-text NOT_FOUND once the route is live, where policyengine.org shows an HTML page today. A root 404.html with the shell would fix it.
  • The share image. All 58 og:image tags name assets/og-image.png, which shows the populace.dev card ("A nation is millions of households"), not Macro. This PR doesn't touch it, but every link to policyengine.org/macro shared on social media would show that card.
  • Footer contrast. On the light theme's teal gradient, the footer's main links (white at .85) and its legal line (.7) fall below AA contrast at the gradient's lighter end (4.1:1 and 3.3:1). The new row doesn't; the older text predates this PR.

Verification

  • Gates on the head, eb03dce5, all in CI on Python 3.13: the 15 generator --check gates, site_nav.py, site_contract.py, site_paths.py, the forecasts unittest suite and pytest tests (3,781 passed, 87 skipped). I haven't run them locally since 010f0641, where all passed (pytest 3,513 passed, 86 skipped).
  • Emulator crawl, at ac5f9293. Since then the pages have changed only in their style.css?v= stamp, and vercel.json not at all. A local emulator of this vercel.json sat behind a proxy that, like policyengine.org, serves only /macro and answers 404 elsewhere.
    • A crawl from /macro reached all 71 pages (77 URLs, counting six search links on /macro/models) and 439 other files. It found no path outside /macro and no response other than 200.
    • The redirect twins answered 308 to /macro/..., and /macro/data/MANIFEST.json carried CORS.
    • The same crawl of main fails on its first page.
  • Browser on the emulated /macro.
    • No console errors. MathJax fonts, the OLG fetch and the paper PDFs loaded from /macro.
    • The bar kept the four required labels in its top 44 px at every width from 360 to 1440 px, and in its top 60 px at 320 px. The bar clipped no label.
    • The footer row fit at every width from 320 to 1440 px, in light and dark themes: no link clipped or overlapping, and each 40 px tall on a phone, like the other footer links.
    • The /macro/pe chips show their code and layers icons again.
  • In-session review. An adversarial review covered escaped paths, page writers, vercel.json semantics and the website route, and the diff and both PR texts. Four lenses ran, plus a skeptic for each finding. It found no P0. Commit 4 fixes every confirmed P1 and P2 but the footer, which commit 6 now adds.
  • Independent review, round 1, on a Subfleet lane, of 54ff184e. It found no code defect at P0 or P1. It asked for corrections to this text (the calendar count, what the shell test checks, what a subdomain switch undoes, the CSP's base-uri, a deep-path check before the website PR merges) and found small gaps in the tests. Commit 5 and this text fix them.
  • Independent review, round 2, of ac14d3ce. It confirmed the round-1 fixes and reproduced the emulator crawl, the regeneration of commit 2 and the conflict counts. It raised three P1s: the missing footer links, a link inventory that left out the og:image tags and the citations, and an overstated rebase claim. Its P2s were the whitespace rule, the paths policyengine.org keeps, and GA4. Commits 6 to 8 and this text answer all but GA4, which Decide on GA4 tracking before policyengine.org/macro goes live #296 tracks, and round 3 closed the three P1s.
  • In-session check of commit 6, unfinished. An account switch cut this check off before any of its six lenses reported and before anyone tried to refute a finding. I reproduced each finding in their progress files and fixed it in commit 7. So the check of the paths policyengine.org keeps, and that of the other claims here, never finished. An earlier version of this text presented it as complete.
  • In-session check of commit 7. Three lenses reread the path rule, the footer row and every claim here, with two skeptics for each finding. Nothing it found rose above P2, and one finding split its two skeptics. Commit 8 fixes what it found. This text now says what commit 1 does to main's history, when the direct-host audit would report /macro, and what the crawl counted. It missed the defects round 3 found.
    • Its harness compared site_paths with Node's URL parser on 181,000 likely and 757,000 random inputs. An earlier version of this text said it left only three classes of divergence. That was wrong: it also set aside 42,974 inputs in shapes outside the supported list, and dropped 64,074 rows with a NUL byte without checking what browsers do with them. Commit 9 removes the rules it tested.
  • Independent review, round 3, scoped, of 010f0641. It closed round 2's three P1s and raised three more: the two path defects and the false footer claim that commit 9 fixes. Its P2 was the reserved-path test, which commit 9 also fixes.
  • Checks of commit 13, in memory, on the gate and the tests' own functions. The tests pass that way on Python 3.12.0, 3.13.9 and 3.14.7, less one that writes files.
    • Of 979,582 generated texts, 36,288 of them with one path inside another, the check passes none that the version at ac14d3ce, ac5f9293, 9fb51556, 010f0641, e160bab8 or 087f9997 flagged. A first draft of commit 13, never pushed, passed 2,583 that 087f9997 flagged, which is why it changed.
    • What may follow a bare root: a quoted /macro or /, then up to three of 41 pieces of JavaScript, comment or markup. The check passes 224,560 of the 706,440 /macro texts, and mount() prefixes all 706,440 / texts. Node ran those 931,000 as a script, as a handler in HTML and in SVG, as a javascript: URL, and as code inside a string and inside a template. They gave a value in 539,288 runs. 599 of the values are not root paths before or after mount(); every other one stays under /macro. With up to two pieces the same script finds 7,436 wrong values at 087f9997 and none here.
    • A decoder read what the check passes the way HTML, CSS or JavaScript would, and Node's URL parser resolved the result. Of 1,640,286 generated texts the check passes 97,763. Node resolves 60,893 of those: 24,448 are //host links, and the other 36,445 all stay under /macro. The rest don't resolve to a URL: 8,596 are tokens CSS drops, 13,240 are invalid URLs (such as //:), and 15,034 don't evaluate to a string as JavaScript.
    • Of 7,949 edits to a page's footer, the footer test passes none that the version at 087f9997 failed, and fails 3,766 that it passed.
    • The tests catch 122 of 124 deliberate breakages of the gate and the two tests. The other two can't change a result: an earlier rule already refuses what they would let through.
    • In the trees of main, obr_shock: household lever no longer fails when the shock is shorter than the solve window #283 to Site quality pass: pinned-commit chip on model pages, unique titles, contrast fixes and new site checks #290 and Refresh official data vintages #294, the check flags nothing that mount() doesn't fix, and mount() writes every file as it did at 010f0641. site_nav.render reproduces all 71 pages, from the committed text and from text with the prefixes taken out.
  • In-session check of a second draft of commit 13. Three agents tried to break it and six tried to refute what they found. They confirmed that the draft still let a // comment hide an extension where a javascript: URL or an SVG attribute drops its newline, still edited a path after an escaped quote, and passed a page that the version at 087f9997 failed, because its footer test used Python's HTML parser. Commit 13 fixes each by refusing more. Nobody has checked commit 13 itself but me.
  • Independent review, round 4, scoped, of 087f9997: REQUEST_CHANGES. It closed all four round 3 findings and raised four new P1s, a P2 and a P3 in the same gate and tests, listed under Round 4's findings. By our review rules nobody opens a round 5.
  • Not verified: the real policyengine.org proxy, which the website PR adds. The Vercel preview built, but nobody could check it over HTTP: Vercel's deployment protection sends every request without a Vercel login to its sign-in page.

Round 4's findings

Commit 13 answers all six. No reviewer has read it, so the four P1s stay open until one says they are closed. Round 4 was the last independent round our rules allow, so that reviewer is Vahid. None of the six occurs in this tree.

  1. P1: a JavaScript comment changed what the matcher decided. fetch("/" /* comment */) became fetch("/macro/" /* comment */), and a mounted fetch("/macro" /* comment */) was flagged. A literal U+FEFF before + hid the extension. Answer: _ALONE in site_paths.py lists what may follow the closing quote of a root that stands alone, and everything else counts as an extension. A /* */ comment of plain words is on the list; a // comment, U+FEFF, [, ?., <!-- and ${ are not. Check: test_only_listed_characters_may_follow_a_base_path_that_stands_alone and test_only_a_comment_of_plain_words_counts_as_space.
  2. P1: site_paths.url() returned a path that holds a double quote, such as /macro"/../models, which a browser resolves to /models. Answer: it refuses a double quote. Check: test_url_mounts_a_plain_path_and_refuses_any_other.
  3. P1: mount() edited a path inside a refused value. <a href='/url(/a)'> became <a href='/url(/macro/a)'>. Answer: it edits nothing inside the value of another shape it reads, and nothing after a root path whose value holds a backslash or ${ or is never closed. The check still reads every path. Check: test_mount_edits_nothing_inside_any_value_it_reads and test_a_path_spelled_any_other_way_fails_the_check_and_is_not_rewritten.
  4. P1: the footer test passed a page whose footer nav's opening tag was commented out. Answer: from the footer's start tag to the row, the markup has to match a short grammar and nest. Check: test_any_other_footer_row_fails.
  5. P2: the reserved-path test stripped macro/ from a file's own name. Answer: it compares both names. Check: test_a_file_at_a_claimed_path_is_found_in_a_directory_named_like_the_base_path.
  6. P3: CONTRIBUTING said nine generator checks; site-provenance runs ten. Fixed.

What commit 13 gives up, for a reviewer to weigh: a root path with a backslash or ${ in its query, and one inside another value, now fail the check and need a person to respell them; --write stops at the first value whose end it can't tell; and the footer test fails if the footer gains any element but text, links, div, span, img and simple SVG icons above its row. The site has none of these today.

Each of the last three rounds found something new in this gate. The subdomain in question 1 would need no gate.

Before merging: check the preview

The routing evidence above comes from a local emulator of Vercel's rules. Merging moves every internal link on the live Vercel host to /macro/..., so a difference between the emulator and real Vercel would break the current site, not just the new route. Someone with a Vercel login should open this PR's preview deployment and check:

  • /macro/models answers 200 and shows the PolicyEngine bar and footer row.
  • /models still answers 200 (the host keeps serving its root).
  • /macro/papers answers 308 with Location: /macro/models#evidence.
  • /macro/models/ answers 308 to /macro/models.
  • /macro/data/MANIFEST.json carries Access-Control-Allow-Origin: *.
  • /macro/vendor/fonts/inter-latin.woff2 answers 200 with the year-long immutable cache.

On merge

  • The PR changes integration/tests/test_site_contract.py, so merging it triggers deploy-mcp.yml, which redeploys the unchanged MCP server to Modal.
  • The companion website PR's shell audit loads this project's production host, so that audit fails until this PR merges and deploys.
  • That audit loads only /macro itself. Before the website PR merges, check a few deep paths on the production host too: /macro/papers answers 308 to /macro/models#evidence, /macro/models answers 200, and /macro/data/MANIFEST.json carries Access-Control-Allow-Origin: *.

🤖 Generated with Claude Code

MaxGhenis and others added 3 commits November 29, 2026 15:20
www.policyengine.org/macro will proxy to this project. Through that proxy a
root path such as /models resolves on policyengine.org, where it is the
website's namespace and a 404, so every link, image, stylesheet, object, font
and fetch has to name /macro/models instead.

- site_paths.py: BASE_PATH, mount() (href, src, <object data>, CSS url(),
  fetch) and a check/--write CLI over served files.
- site_nav.render and every generator mount their output, so each --check
  gate compares mounted pages; site_contract.py and the tests compare
  mounted strings.
- vercel.json: rewrites serve the tree under /macro; each redirect and each
  path-scoped header rule gets a /macro twin, since Vercel matches both on
  the requested path before the rewrite.
- tests/conftest.py models the rewrite; tests/test_site_paths.py pins
  mount() and the vercel.json twins.
- CI: site-provenance.yml and data/refresh.py run python3 site_paths.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The output of `python3 site_paths.py --write` and `python3 site_nav.py
--write`, nothing else: 2,910 root paths in 76 files (71 pages, style.css,
connect.css and the vendored font and MathJax stylesheets). After a rebase,
rerun those two commands instead of resolving these hunks by hand.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
policyengine.org serves only pages that carry PolicyEngine's own header,
and an app zone renders it itself: the website's app-zone-shell-audit
fails a zone whose top 140 px lack the PolicyEngine wordmark or any of
Research, Model, API and Donate. site_nav.pe_shell() puts that bar above
the Macro header on every page, with absolute www.policyengine.org links.
On phones under 420 px the Python link drops so the four required labels
fit. style.css v52.

CONTRIBUTING.md documents the base path, the vercel.json twins and the
bar; CHANGELOG.md records the change and the URLs that move once the
route is live.

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

vercel Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
macromod Ready Ready Preview Nov 30, 2026 3:07pm UTC

Request Review

MaxGhenis and others added 2 commits November 29, 2026 15:56
…ew pages

Review round 1 on #295 found three gaps in site_paths.py:

- A CSS prefix selector such as `.chip[href^="/connect"]` stayed as
  written while the links it tests became /macro/connect, so 12 chips on
  the pe, olg and pe-microsim pages lost their icons. mount() now treats
  `^=` like `=`; `$=` and `*=` still match as written.
  models/model-pages.css v25.
- `"/" + slug` became `"/macro" + slug`, which yields /macromodels. A
  quoted root followed by `+` now becomes `"/macro/"`.
- served_files() read only git's index, so the gate never saw a page a
  generator had just created. It now lists untracked files that are not
  ignored as well.

Also: forecasts/make_us_baseline.py mounts its block like every other
page writer; a test pins each vercel.json header twin directly after its
original, since Vercel's cascade depends on that order; CONTRIBUTING and
CHANGELOG say which shapes the gate can see.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review round 1 on #295, continued:

- The bar clipped "Donate" at 360 px and at 421-439 px: its links
  scrolled sideways behind a hidden scrollbar, and Python dropped only
  below 420 px while five links need about 440 px. The links now wrap,
  so nothing is ever clipped (at 320 px Donate moves to a second row),
  Python drops below 460 px, and spacing tightens below 400 px. Measured
  in a browser with Inter at 320 to 1440 px: the four required labels
  sit in the top 44 px from 360 px up and in the top 60 px at 320 px.
- site_nav.HEADER's bar group could run past the bar's own </nav> to a
  later one, deleting a banner placed between the bar and the Macro
  header, or stamp a second bar. The group now stops at the bar's own
  </nav>, and render() refuses a page that would end up with two bars.
- tests/test_site_shell.py holds every page to the website audit's rule:
  one bar directly above the Macro header, the PolicyEngine wordmark,
  and Research, Model, API and Donate, none hidden on phones. Nothing in
  this repository checked the bar before.
- tools/prerender_math.py hashed the MathJax stylesheet before mounting
  its font paths, so the ?v= on six pages no longer matched the served
  file; it now hashes the mounted file. connect.css v21.
- Docs: the site_paths.py docstring counts (3,146 paths at 1592fab),
  and CONTRIBUTING no longer claims BASE_PATH is the one place the
  prefix lives: the pages and the vercel.json twins carry it too. The
  site_nav comment and CHANGELOG note that the footer does not yet carry
  PolicyEngine's footer links, the other half of the website's shell
  rule, which its audit does not check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An independent review of 54ff184 found these gaps:

- An unquoted `url( /macro )` mounted twice, because `_already_mounted`
  didn't treat whitespace as the end of a path. Whitespace now ends one.
- `test_every_redirect_has_a_twin_under_the_base_path` passed a leftover
  `/macro/...` redirect whose original had gone. New tests fail on such
  a redirect, and on a `/macro` header rule that doesn't follow its
  original.
- The CHANGELOG said `tests/test_site_shell.py` holds pages to the
  audit's rule. It checks the bar's markup, not the drawn layout the
  audit measures.

The site_paths docstring now lists `data-href` among the shapes the
check can't see.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Acts on the second independent review of ac14d3c.

- Footer. policyengine.org's shell rule asks every page it serves for
  PolicyEngine's footer links as well as its header. The footer gains
  one muted row with the links policyengine.org's own footer carries:
  About us, Donate, Developer tools, Privacy policy, and Terms and
  conditions (site_nav.PE_FOOTER_LINKS, style.css v53, all 71 pages
  restamped). tests/test_site_shell.py checks the row on every page,
  and its docstring now says it checks markup, not layout.
- Whitespace. ac14d3c let whitespace end any path, so a quoted
  `href="/macro archive"` counted as mounted and passed the gate. Only
  an unquoted CSS url() ends its path at whitespace now.
- Website-held paths. policyengine.org runs its own /:countryId/...
  redirects and icon rewrites before it proxies /macro, so /macro/blog,
  /macro/methodology and five other first segments, and
  /macro/<dir>/favicon.svg and its kin, never reach this project. A new
  test fails on a page, file or redirect there; none sits there today.
  CONTRIBUTING and CHANGELOG say so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Acts on an in-session adversarial check of ac5f929.

- site_paths. ac5f929 stopped whitespace from ending a quoted path,
  but a browser drops tabs and newlines from a URL and trims its ends,
  so `href="/macro "` and `href="/macro\n/models"` were double-mounted,
  while `href="/macro)x"` still counted as mounted. mount() now reads a
  quoted value to its closing quote, as the URL parser does, and an
  unquoted url() to whitespace or `)`. A quoted value may also start
  with spaces before its slash. No served file changes.
- Footer row. 11px fell below DESIGN.md's 12px floor, and white at .7
  gave 3.3:1 against the light gradient's lighter end. It is now 12px
  at .94 (4.6:1). The test now requires exactly policyengine.org's
  five footer links, in order, on the bar's country, and ignores a row
  hidden in a comment.
- CHANGELOG lists every kind of link still naming the Vercel host.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An in-session check of 9fb5155 compared site_paths with Node's WHATWG
URL parser and found three gaps, none on the site today:

- "/\t/cdn.example.org" and "/\cdn.example.org" are protocol-relative
  once the parser drops the tab and reads the backslash as a slash. They
  were mounted, which would have broken an external link.
- In "/\t" + slug the browser trims the joined string, not the literal,
  so the tab sits inside the path. The literal now keeps its trailing
  whitespace and mounts to "/macro/\t" + slug, not "/macro\t" + slug.
- The leading trim now covers every control character but NUL, which
  HTML and CSS read as U+FFFD.

Attribute names and CSS url() now match in any case, as HTML and CSS
read them, and a backslash after /macro counts as mounted. The
docstring and CONTRIBUTING name what the gate still can't see: an
@import without url(), dot segments and "/macro" + slug.

The footer test now fails on any extra anchor in the row, and
STYLE_VERSION moves to 54 so a preview cached at v53 can't show the old
row styling.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Round 3 of the independent review found that the last two commits let
paths through that the gate used to catch: CSS and JavaScript escapes
(url("/\61.svg"), fetch("/\x64ata/...")), because 010f064 read a
backslash in the source as a URL slash before the language decoded it,
and an unquoted url() with U+00A0, because 9fb5155 let any Unicode
space end it.

Those commits imitated how browsers decode a path. Every root path on
the site is spelled in ASCII letters, digits and -._/, so site_paths now
reads only those (and ~). It flags any other spelling, a dot segment or
"/macro" + slug, and mount() and --write leave it for a person to
respell. No page changes.

The footer test compares the row's markup with the exact five links, so
an extra link fails however it is written; an upper-case <A HREF> passed
before. The reserved-path test matches the website's rules as written
(methodology/appendix is free) and looks at rewrites that already carry
the base path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The table of pull-request workflows named site_nav.py and
site_contract.py but not the gate this branch adds between them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The last matcher stopped reading at any quote or at ${, to allow for a
script string around the path, and looked no further. So
href="/macro/a'/../../models" passed, and a browser reads the rest and
resolves it to /models.

All 3,221 root paths on the site, and every one in the open pull
requests' trees, run to their own closing quote or parenthesis. The gate
now reads to it and flags a path that a script string or a template
breaks off ('<a href="/' + slug + '">'). mount() and --write leave such
a path for a person to respell. No page changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mount() leaves a path that is not spelled plainly for the gate to flag.
url() returned such a path unmounted, with nothing to flag it, so it now
raises. Every caller passes a plain path. The docstring says that the
plain spelling covers a path up to its ? or #.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The fourth independent review, of 087f999, found four P1s, a P2 and a P3 in
the path gate and its tests. None occurs in the site, and no page changes:
mount() writes every file here, on main and in every open PR as it did before.

- A root that a script may extend: list what may follow its closing quote,
  instead of what extends it. A plain /* */ comment no longer counts as an
  extension; U+FEFF, "[", "?.", "<!--" and "${" now do.
- mount() edits nothing inside the value of another shape it reads, so it never
  edits a value it refuses. The check still reads every path, nested or not.
- A value that holds a backslash or "${" anywhere fails, since either may hide
  the quote that closes it, and mount() edits nothing after it.
- url() refuses a path that holds a double quote or another root path.
- The footer test reads the footer's own markup strictly, from its start tag to
  the row, so a commented-out nav fails. It says what it does not read.
- The reserved-path test compares a file at its own name too.
- CONTRIBUTING: ten generator checks, not nine.

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

MaxGhenis commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Agent-written for Max, by Claude Code for Max Ghenis. Max hasn't read it.

@vahid-ahmadi, this PR is ready for your review at eb03dce5. It is still a draft. Every check passes on that commit, and it has no conflicts with main.

Round 4's findings. An independent review of 087f9997 raised four P1s, a P2 and a P3: three P1s in the path check, one in the footer test, the P2 in the reserved-path test and the P3 in CONTRIBUTING. None of them affects the site today. Commit 13 (eb03dce5) answers all six, and no reviewer has read it. Our rules allow no fifth independent round, so please say in your review whether the four P1s are closed. Nobody merges this while one is open.

  • The description's Round 4's findings section gives each finding, its answer and what commit 13 gives up.
  • git show eb03dce5 touches four files and no page: site_paths.py, CONTRIBUTING.md, tests/test_site_paths.py and tests/test_site_shell.py.

Your five questions are in the description under What I need from Vahid. Please start with the first, path or subdomain. Each of the last three review rounds found something new in the path check, and a subdomain would not need that check. It would need a DNS record and a Vercel domain, which only you or Max can add.

The website's side, PolicyEngine/policyengine-app-v2#1616, waits for this PR to merge and deploy, and for #296 (GA4).

This branch was successfully deployed

1 active deployment
Preview — eb03dce5 Deployed Nov 30, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant