Skip to content
Merged
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
17 changes: 14 additions & 3 deletions .github/workflows/site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,25 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Install PyYAML and jsonschema (a venv; hash-locked wheels only)
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 24.5.0
- name: Install the site's packages (exact versions from site/package-lock.json)
working-directory: site
run: npm ci --ignore-scripts --no-fund
- name: Install PyYAML for the tests (a venv; hash-locked wheels only)
run: |
python3 -m venv "$RUNNER_TEMP/site"
"$RUNNER_TEMP/site/bin/pip" install --quiet --only-binary=:all: --require-hashes -r requirements.lock
- name: Test the build
- name: Test the build (each test runs it)
env:
MORPHOGEN_SITE_TESTS: "1"
run: '"$RUNNER_TEMP/site/bin/python" -m unittest tests.test_site -v'
- name: Build
run: '"$RUNNER_TEMP/site/bin/python" site/build.py --out site/_build'
working-directory: site
env:
ASTRO_TELEMETRY_DISABLED: "1"
run: npm run build
- uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6.0.0
- uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
with:
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ docs/restart/LESSONS.md.
- `tests/`: the core's tests and red team; fixture projects in `tests/fixture*.py`, the timed
sample's files in `tests/fixtures`.
- `demos/`: projects Morphogen can build and drive. The core never imports from them.
- `site/`: the research site, static HTML built by `site/build.py` from the evidence claims, the map and the
- `site/`: the research site, static HTML built with Astro (`site/src/`) from the evidence claims, the map and the
options (`site/README.md`); `.github/workflows/site.yml` deploys it to Pages when started by hand.

## Rules
Expand Down
2 changes: 1 addition & 1 deletion morphogen/research.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ def catalog(p: Project, draft_path: Path, cache: Path, by: str, http: Http | Non

LABELS = {"research:prioritise": "prioritise", "research:prioritize": "prioritise", "research:reject": "reject",
"research:question": "question"}
# The `research-action:` line the claim site (site/build.py, PR #108) writes into every issue body: the primary signal,
# The `research-action:` line the claim site (site/src/lib/steer.mjs; PR #108 first) writes into every issue body: the primary signal,
# since GitHub drops a prefilled link's labels for anyone without triage access.
ACTIONS = {"prioritise", "reject", "dispute", "question", "propose-role", "propose-option"}
TOPICAL = {"question", "propose-role", "propose-option"} # these become a watch topic waiting for terms
Expand Down
4 changes: 4 additions & 0 deletions site/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
node_modules/
_build/
.astro/
# copied from node_modules/@alpinejs/csp by astro.config.mjs on every build and dev start
public/assets/vendor/
4 changes: 4 additions & 0 deletions site/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
save-exact=true
engine-strict=true
fund=false
audit=true
133 changes: 103 additions & 30 deletions site/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,129 @@

A static site for the research loop ([docs/research-loop.md](../docs/research-loop.md)): the claims the research
agent has catalogued, their status for this system, its transfer predictions against outcomes, and the roles it
watches for. `build.py` reads the files named in `config.toml` (EvidenceClaim files,
[schemas/evidence-claim.v1.json](../schemas/evidence-claim.v1.json); the map and options as Backstage entity files)
and writes plain HTML into `_build/`. No server, no database, no tracking, nothing loaded from another host.

`config.toml` points at [demos/research-loop](../demos/research-loop): the claims under `claims/` (searched
recursively, so `claims/arxiv-ID/` is found), the map, `options.yaml` and the agent's `found.yaml` (a catalog file
that does not exist yet is skipped), and the agent's own files in `research/` (its README, "Files a website reads"):
`queue.json`, `watch.yaml`, `seen.jsonl`, and `index.json`, which the build checks against the claim files.
watches for, with a page for every claim, paper, trial, model, option and role and the links between them. Built
with [Astro](https://astro.build) 7 into plain HTML in `_build/`; the interactive parts use
[Alpine.js](https://alpinejs.dev)'s CSP build, served from the site itself. No server, no database, no tracking,
nothing loaded from another host.

## Build and preview

Needs Node 22.23.4 or later (the workflow uses 24.5.0).

```sh
uv run python site/build.py # or: python3 site/build.py (needs PyYAML; validates with jsonschema if installed)
python3 -m http.server 8000 -d site/_build # then open http://localhost:8000
uv run python site/build.py --root ../other-checkout --out /tmp/site # build another checkout's data
uv run python -m unittest tests.test_site -v
cd site
npm ci # the exact versions in package-lock.json
npm run dev # http://localhost:4321/index.html, rebuilt as you edit (YAML too, on reload)
npm run build # writes _build/
npm run preview # serves _build/
npm test # the data layer's unit tests (node --test)
cd .. && MORPHOGEN_SITE_TESTS=1 uv run python -m unittest tests.test_site -v # builds and checks real and hostile input
```

`SITE_CONFIG`, `SITE_ROOT`, `SITE_CONTENT` and `SITE_OUT` point a build at another config, checkout, content folder or
output directory (the tests use them). The scripts set `ASTRO_TELEMETRY_DISABLED=1`. Without `npm ci` in `site/`,
`tests/test_site.py` is skipped (and fails instead when `MORPHOGEN_SITE_TESTS=1`).

## Adding a page: drop Markdown into `content/`

Every `.md` file under `site/content/` becomes a page with the shared layout: `content/how.md` is `how.html`,
`content/notes/2026-11-27-inkling.md` is `notes/2026-11-27-inkling.html`. Front matter (checked by
`src/content.config.mjs`; a page that breaks it stops the build):

```yaml
---
title: Inkling 2 Mini was tested against the 27B+ finding # required
description: One sentence, shown under the title and in search
kind: note # note (default) or announcement: also listed on notes.html, newest first; page: not listed
date: 2026-11-27
refs: # entities the page is about; each one's page links back here
- resource:inkling-2-mini-q4-k
- trial:E-04a
- claim:gates-likelihood-readout-27-31b-matches-jev
- paper:arXiv:2610.00346
- role:decision-backend
- option:likelihood-readout
nav: 50 # optional: put it in the header's navigation, ordered by this number
blocks: [statuses, steering, files] # optional generated sections after the text
draft: true # optional: leave it out of the build
---
```

Every claim is validated against the schema first; an invalid file stops the build.
A ref to something that is not on the site stops the build. Links inside the text are relative to the page
(`../claims/<name>.html` from `notes/`). The Markdown is ours, not a paper's, so raw HTML in it is passed through;
the content security policy still blocks any inline script.

## Where the data comes from

`config.toml` points at [demos/research-loop](../demos/research-loop): the claims under `claims/` (searched
recursively), the map, `options.yaml` and the agent's `found.yaml` (a missing catalog file is skipped), and the
agent's own files in `research/`: `queue.json`, `watch.yaml`, `seen.jsonl`, and `index.json`, which the build checks
against the claim files. `src/lib/data.mjs` reads them all, validates every claim against
[schemas/evidence-claim.v1.json](../schemas/evidence-claim.v1.json) (Ajv, draft 2020-12; an invalid claim or a name
used twice stops the build), and joins them into one graph: entities, typed references, and the backlinks of each.

| Entity | Page | From |
| --- | --- | --- |
| claim | `claims/<name>.html` | an EvidenceClaim file |
| paper | `papers/<id>.html` | a claim's `source` when it is outside work (`arxiv-2610.00346`) |
| trial | `trials/<id>.html` | a claim's `source` when it is our trial or probe, and every outcome's `trial.id` (`e-04a`) |
| resource | `resources/<name>.html` | a Resource: a model, engine, GPU or dataset |
| option | `options/<name>.html` | a Component with `lifecycle: candidate` |
| role | `roles/<name>.html` | a Component with `type: role` |
| system | `systems/<name>.html` | the System |
| page | `<path>.html` | a Markdown file in `content/` |

References: a claim's `about` (option), `role`, `source` (paper or trial), `conditions.*.ref` (measured on),
`assessments[].against` (assessed on, with the status), `outcome.trial` (tested in), `outcome.observed` and
`see_also` (claims); an option's `fills`; a role's `subcomponentOf`; `spec.system`; a page's `refs`. Every entity page
ends with all of them, both ways ("Links to", "Linked from"), and adds its own views: a claim's "tested on" table
(model by result); a model's claims tested with it and each result, its trials and our measurements on it; a trial's
outcomes and the models it ran, and related trials (E-17, E-17b...); a paper's claims; a role's options, open
questions (`watch.yaml`), what has been tested and what is next in the queue.

## Pages

| Page | What it shows |
| --- | --- |
| `index.html` | the feed, newest first, filtered in the page by search, role, source and status (kept in the address, so a view can be shared); works without JavaScript, unfiltered |
| `claims/<name>.html` | one claim: the quote and whether it was checked, the measure and effect, the conditions and what the source left unstated, the transfer prediction and its reason, the cheapest trial that would settle it (`assessments[].trial`) and its place in the queue, the outcome with its trial and verdict |
| `queue.html` | next to test: the agent's `queue.json`, best first, with its plan, cost, score and any steering, and buttons to prioritise or reject |
| `index.html` | the feed, newest first, filtered in the page by search, role, source and status (kept in the address); without JavaScript, unfiltered |
| `queue.html` | next to test: `queue.json`, best first, with plan, cost, score, steering, and buttons to prioritise or reject |
| `predictions.html` | predictions waiting for a trial, and a calibration chart with the Brier score once predictions written before an outcome have one |
| `roles.html` | what the agent watches (`watch.yaml`'s topics, and what became of the papers in `seen.jsonl`), the roles in the map, the options catalogued for each, and this system's conditions |
| `how.html` | the loop: watch, read, catalogue, predict, test behind the judge, score the prediction |
| `data/claims.json` | the same records, for other tools |
| `roles.html` | what the agent watches (`watch.yaml`, `seen.jsonl`), the roles, the options for each, and this system's conditions |
| `map.html` | the relations graph, laid out at build time (`src/lib/layout.mjs`); a static SVG of links, with highlighting and filters in Alpine |
| `search.html` | everything by kind; with JavaScript, a search over `data/search.json` (the header's box lands here) |
| `notes.html` | notes and announcements from `content/` |
| `data/claims.json`, `data/graph.json`, `data/search.json` | the records, the whole graph (with the calibration pairs and Brier score), the search index |

## Layout of this folder

`src/layouts/Base.astro` is the frame of every page; `src/pages/<type>/[name].astro` is the layout of one entity type,
written once; `src/components/` holds the shared pieces (status badges, the "tested on" table, the references
panel). `public/assets/` is copied as is: `style.css` (light and dark themes), `theme.js` (applies the chosen theme
before the page paints), `site.js` (the Alpine components). `astro.config.mjs` copies Alpine's CSP build from
`node_modules/@alpinejs/csp` into `public/assets/vendor/` (not committed) on every build and dev start.

## Steering

The buttons open a prefilled GitHub new-issue page (title, body, labels); nothing is sent until the person submits
it. Each body ends with a `research-action:` line (`prioritise`, `reject`, `dispute`, `question`, `propose-role`,
`propose-option`), with `research-claim:` and `claim-file:` for a claim and `role:` for an option proposed for a
role; the agent reads those lines first (`morphogen/research.py`, `parse_issue`). The labels in `config.toml` are
the fallback: `research:prioritise`, `research:reject`, and `research:question` for the rest. GitHub applies labels
from a link only for people who can triage the repository. Text from papers never goes into an issue body, since it is rendered as Markdown.
`propose-option`), with `research-claim:`, `claim-file:` and `status:` for a claim and `role:` for an option proposed
for a role; the agent reads those lines first (`morphogen/research.py`, `parse_issue`). They are written by
`src/lib/steer.mjs`. The labels in `config.toml` are the fallback. Text from papers never goes into an issue body,
since it is rendered as Markdown.

## Safety

Claim text comes from papers. Every string from a file is HTML-escaped where it is written, a link from a file is
written only if it is http or https, and each page sets a content security policy that allows only its own
scripts and styles. `tests/test_site.py` builds a claim full of markup and a `javascript:` link and checks that
none of it comes through.
Claim text comes from papers. Astro escapes every value written into a page (`&`, `<` and `>` in text; `&` and `"`
in a quoted attribute, where `<` cannot open a tag), and no page uses `set:html`. A link from a file is written only
if it is http or https (`safeUrl`). Each page's content security policy allows only its own scripts, styles and
data (`default-src 'none'; script-src 'self'; style-src 'self'; connect-src 'self'`, no `unsafe-inline` or
`unsafe-eval`): there are no inline scripts or style attributes, and Alpine's CSP build evaluates directives without
`new Function`, from components registered by name with `Alpine.data`. `tests/test_site.py` builds claims full of
markup and a `javascript:` link and checks that none of it comes through.

## Deploying

`.github/workflows/site.yml` tests, builds and deploys `_build/` to GitHub Pages. It runs only when started by hand
until its `push` trigger is uncommented, and it needs Pages set to "GitHub Actions" in the repository's settings.
Links are relative, so the site works at `https://<owner>.github.io/Morphogen/` or on a custom domain.
`.github/workflows/site.yml` installs the locked packages, runs the tests, builds and deploys `_build/` to GitHub
Pages. It runs only when started by hand until its `push` trigger is uncommented, and it needs Pages set to "GitHub
Actions" in the repository's settings. Links are relative, so the site works at `https://<owner>.github.io/Morphogen/`
or on a custom domain.
37 changes: 37 additions & 0 deletions site/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// The research site (site/README.md). Static output only; every page is a file such as claims/<name>.html, and
// every link is relative, so the site works under https://<owner>.github.io/Morphogen/ or on its own domain.
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { defineConfig } from "astro/config";

const HERE = path.dirname(fileURLToPath(import.meta.url));
process.env.SITE_DIR ||= HERE; // read by src/lib/data.mjs

// Alpine's CSP build (no `new Function`, so the content security policy needs no 'unsafe-eval'), served from the
// site itself: copied from the pinned package into public/assets/vendor before every build and dev start.
function alpineCsp() {
return {
name: "alpine-csp",
hooks: {
"astro:config:setup": () => {
const pkg = path.join(HERE, "node_modules", "@alpinejs", "csp");
const out = path.join(HERE, "public", "assets", "vendor");
fs.mkdirSync(out, { recursive: true });
const { version, license } = JSON.parse(fs.readFileSync(path.join(pkg, "package.json"), "utf8"));
const code = fs.readFileSync(path.join(pkg, "dist", "cdn.min.js"), "utf8");
fs.writeFileSync(path.join(out, "alpine-csp.min.js"),
`/*! @alpinejs/csp ${version} | ${license} licence | https://github.com/alpinejs/alpine */\n${code}`);
},
},
};
}

export default defineConfig({
output: "static",
outDir: process.env.SITE_OUT || "./_build",
build: { format: "file" },
compressHTML: true,
devToolbar: { enabled: false },
integrations: [alpineCsp()],
});
Loading