Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/site-provenance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,7 @@ jobs:
python3 tools/prerender_math.py --check
- name: Global navigation is consistent
run: python3 site_nav.py
- name: Every served path is under the base path
run: python3 site_paths.py
- name: Public model inventory and evidence are complete
run: python3 site_contract.py
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ heading here; `tests/test_repo_hygiene.py` asserts that they do.

## [Unreleased]

### Served under policyengine.org/macro

- **Base path.** Every link, image, stylesheet, object, font and fetch on the site now names a path under `/macro` (`site_paths.py`, `BASE_PATH`), so the site works when www.policyengine.org/macro proxies to this project. The project's own Vercel host still serves every page at its root as well.
- **`vercel.json`.** Rewrites serve the tree under `/macro`; each of the 81 redirects and the 10 path-scoped header rules has a `/macro` twin.
- **Generators.** `site_nav.render` and every generator that writes a page or a block mount their output, so each `--check` gate compares mounted pages. A new CI step, `python3 site_paths.py`, fails on a root path left without the prefix in any shape it mounts: an `href`, `src`, `data`, `action` or `poster` attribute or a CSS selector on one, a CSS `url()`, or a `fetch`. It also fails on such a path spelled in anything but ASCII letters, digits and `-._~/`, which `--write` leaves for a person to respell. It checks pages a generator has created but nobody has added yet, too. `models/model-pages.css` v25, for its two mounted `[href^=…]` selectors.
- **PolicyEngine site shell.** Every page now opens with PolicyEngine's wordmark and its Research, Model, API, Python and Donate links (`site_nav.pe_shell`), and its footer gains a row of PolicyEngine's own footer links: About us, Donate, Developer tools, Privacy policy, and Terms and conditions (`site_nav.PE_FOOTER_LINKS`). policyengine.org's shell rule asks every page it serves for both. `style.css` v54. The bar's links wrap rather than scroll, so none is ever clipped, and Python drops below 460 px. `tests/test_site_shell.py` checks the bar and the footer row in each page's markup, though not the drawn layout the website's audit measures.
- **Paths policyengine.org keeps.** The website's own `/:countryId/...` redirects and icon rewrites run before it proxies `/macro`, so `/macro/blog`, `/macro/methodology`, `/macro/<dir>/favicon.svg` and the other paths that `WEBSITE_RULES` in `tests/test_site_paths.py` lists never reach this project. That test fails on a page, file, redirect or rewrite there. No current path is affected.
- **Not changed yet**: the canonical, `og:url` and `og:image` tags, `sitemap.xml`, `robots.txt`, the paper pages' citations and the papers' LaTeX and BibTeX sources, the API code samples, the README, `CITATION.cff`, `integration/pyproject.toml`, the `URL:` lines in `data/calendar.ics` and the User-Agent in `data/fetch.py` still name policyengine-macro.vercel.app (PolicyEngine/macro#295 lists all 327 mentions). They move once www.policyengine.org/macro is live. The calendar's event UIDs stay as they are, since a changed UID duplicates every subscriber's events.

### BoE SVAR re-pin to `17f5d82`

- **Pin.** BoE SVAR `c827ab86` → `17f5d824` (boe-var-model #34, world CPI seasonal adjustment; #35, November 2026 MPR comparator and 2026Q3 scoring). After a redeploy the hosted `forecast_uk` and `latest_shocks` run this pin.
Expand Down
51 changes: 50 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ hand-written and part generated. Edit outside the markers freely; never inside.
| generator | what it owns | `--check` in CI |
|-----------|--------------|-----------------|
| `site_nav.py` | the global `<header class="nav">`, the pathway crumbs and the footer link row on **every** page. `--write` rewrites them; the bare invocation is the check, and it also fails on any page with no nav that is not in `NAV_EXEMPT`. | `site-provenance.yml` |
| `site_paths.py` | the base path, `/macro`, on every root path in every served HTML, CSS, SVG and site JavaScript file (`href`, `src`, `<object data>`, CSS `url()`, CSS `[href=…]` and `[href^=…]` selectors, `fetch`). Write root paths (`/models`) anywhere; `site_nav.py --write` and every generator mount their output, and `--write` here mounts the rest that it can read for certain. The bare invocation is the check. See *Served under policyengine.org/macro* below. | `site-provenance.yml` |
| `site_contract.py` | not a generator — a check-only contract over the public model inventory, the economy navigation, editorial claims, the documented MCP tool count, the `model NN` ordinals and every cross-page fragment anchor. | `site-provenance.yml` |
| `data/fetch.py` | the append-only vintage store under `data/vintages/` and the flattened `data/latest/`, from ONS, the Bank of England and FRED. `--check` validates the store and fetches nothing. | `data-immutability.yml` |
| `data/build_page.py` | the **data-store block inside `economy/index.html`** (between the `data-store` markers) and **`data/calendar.ics`**. There is no `/data` page; `/data` 308s to `/economy#data`. | `site-provenance.yml` |
Expand All @@ -96,6 +97,54 @@ Run the generator, commit both the script change and its output, and check that
`economy-topics` and `generated-release-notes` blocks are generated, so any
other new page needs a `<loc>` added by hand (see *Adding a model* below).

### Served under policyengine.org/macro

The public address is https://www.policyengine.org/macro. The policyengine.org
website proxies `/macro` and everything under it to this Vercel project (an app
zone in PolicyEngine/policyengine-app-v2's `website/src/data/appZoneRoutes.ts`),
and `vercel.json` serves the tree under `/macro` as well as at the project's
root. So:

- **Every path on a page carries the prefix**: `/macro/models`, not `/models`.
Through policyengine.org a bare `/models` is the website's namespace and
404s. Write root paths if you like, then run `python3 site_paths.py --write`
(or `site_nav.py --write`, which mounts every page it stamps); CI fails on
any that are left in the shapes `site_paths.py` mounts. It cannot see a
`srcset`, a `window.location = "/..."`, a `data-href` that a script turns
into a link, a CSS `@import` without `url()`, or a path a script assembles
without a quoted leading `/`, so write those with the prefix yourself.
- **Spell paths plainly.** CI fails on a root path that holds anything but
ASCII letters, digits and `-._~/` before its `?` or `#`, or a `.` or `..`
segment, and on `"/macro" + slug` (write `"/macro/" + slug`). A path runs to
its own closing quote, so one that a script string or a template breaks off
fails too: write `fetch("/data/" + id + ".json")`, not
`` fetch(`/data/${id}.json`) ``. So do a backslash or `${` anywhere in the
value, and a root path inside another value. `--write` leaves such a path,
and any after one whose end it can't tell, for you to respell. The docstring
of `site_paths.py` says why.
- **Every redirect and every path-scoped header rule in `vercel.json` has a
`/macro` twin.** Vercel matches both on the requested path, before the
rewrite, so `/papers` never sees a request for `/macro/papers`.
`tests/test_site_paths.py` names any twin that is missing.
- **Every page carries the PolicyEngine site bar** above the Macro header
(`site_nav.pe_shell`): the wordmark and the Research, Model, API, Python and
Donate links. policyengine.org's app-zone shell audit fails a zone without
them. The footer carries PolicyEngine's own footer links in one row
(`site_nav.PE_FOOTER_LINKS`), which the website's shell rule also asks for.
`tests/test_site_shell.py` checks both in the markup; only the website's
audit checks how the bar is drawn.
- **Some paths under `/macro` never reach this project.** policyengine.org
runs its own redirects and icon rewrites before it proxies `/macro`, and
those written `/:countryId/...` match `/macro/...` too: `/macro/blog`
redirects to `/macro/research`, and `/macro/<dir>/favicon.svg` serves
PolicyEngine's icon. `WEBSITE_RULES` in `tests/test_site_paths.py` lists
those paths, and the test there fails on a page, file, redirect or rewrite
that sits at one. Compare a rule whose source is itself a pattern by hand.
- **Generators and `mount()` read the prefix from `BASE_PATH` in
`site_paths.py`**, but the committed pages and the `vercel.json` twins
carry it literally. Moving the site means changing all three: setting
`BASE_PATH = ""` alone leaves every page and twin under `/macro`.

### 2. The archives are append-only

`data/vintages/**` and `forecasts/rounds/**` may be **added to, never edited or
Expand Down Expand Up @@ -337,7 +386,7 @@ CI on a pull request runs, on every PR:
| workflow | what it gates |
|----------|---------------|
| `site-tests.yml` | the repo-root suite — `tests/test_site_integrity.py`, `tests/test_data_store.py`, `tests/test_repo_hygiene.py`. pytest and nothing else installed. |
| `site-provenance.yml` | nine generator `--check` gates, then `site_nav.py` and `site_contract.py`. |
| `site-provenance.yml` | ten generator `--check` gates, then `site_nav.py`, `site_paths.py` and `site_contract.py`. |
| `data-immutability.yml` | `data/vintages/**` is append-only, plus `data/fetch.py --check`. |
| `forecast-archive.yml` | `forecasts/rounds/**` is append-only, plus `archive.py`, `ingest_outturns.py`, `score.py`, `make_open_fans.py` and `make_us_baseline.py` `--check`, and the `forecasts/tests` unittest suite. |
| `test-integration.yml` | the fast integration suite — **only when `integration/**` changes** (path-filtered), or on manual dispatch. |
Expand Down
3 changes: 2 additions & 1 deletion assets/make_current_outlooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT))
import chartkit # noqa: E402 (stdlib-only, repo root)
import site_paths # noqa: E402 (every site path goes under the base path)


def points(values, xs, ymap):
Expand Down Expand Up @@ -168,7 +169,7 @@ def render(page: Path, name: str, content: str) -> str:
)
if count != 1:
raise RuntimeError(f"expected one {name} block in {page}, found {count}")
return updated
return site_paths.mount(updated)


if __name__ == "__main__":
Expand Down
3 changes: 2 additions & 1 deletion assets/make_hero.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT))
import chartkit # noqa: E402 (stdlib-only, repo root)
import site_paths # noqa: E402 (every site path goes under the base path)
PAGE = ROOT / "index.html"
SRC = ROOT / "papers" / "boe-svar" / "figures" / "current_forecast.json"

Expand Down Expand Up @@ -228,7 +229,7 @@ def main():
args = ap.parse_args()

html = PAGE.read_text()
new = render_page(html)
new = site_paths.mount(render_page(html))
if args.check:
if new != html:
print(f"{PAGE} is out of date; run: python3 assets/make_hero.py")
Expand Down
3 changes: 2 additions & 1 deletion assets/make_joins_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT))
from site_nav import icon, MODEL_ICONS # noqa: E402
import site_paths # noqa: E402 (every site path goes under the base path)

PAGES = {"index.html": "/", "models/index.html": "/models"}
OPEN, CLOSE = "<!-- joins-hub:begin -->", "<!-- joins-hub:end -->"
Expand Down Expand Up @@ -136,7 +137,7 @@ def main() -> int:
path = ROOT / page
src = path.read_text()
a, b = src.index(OPEN), src.index(CLOSE) + len(CLOSE)
new = src[:a] + render(page) + src[b:]
new = site_paths.mount(src[:a] + render(page) + src[b:])
if new != src:
stale.append(page)
if not check:
Expand Down
4 changes: 2 additions & 2 deletions connect/connect.css
Original file line number Diff line number Diff line change
Expand Up @@ -319,5 +319,5 @@
/* client marks: monochrome, in the tab's own colour (the bare-icon rule) */
.use-mark { display: inline-block; flex: none; width: 18px; height: 18px; background: currentColor;
-webkit-mask: var(--mark) center / contain no-repeat; mask: var(--mark) center / contain no-repeat; }
.use-mark-claude { --mark: url("/assets/claude-mark.svg"); }
.use-mark-chatgpt { --mark: url("/assets/chatgpt-mark.svg"); }
.use-mark-claude { --mark: url("/macro/assets/claude-mark.svg"); }
.use-mark-chatgpt { --mark: url("/macro/assets/chatgpt-mark.svg"); }
Loading