Elamur: **Mova** · [Parse](https://mova.elamur.ai/free/en/parse/) · [Research](https://md.research.elamur.ai/free/en/) · [Gali](https://md.gali.elamur.ai/free/en/) · [MCP](https://mcp.elamur.ai/) · [Locations](https://md.locations.elamur.ai/free/en/) · [Weather](https://md.weather.elamur.ai/free/en/) · [Shryfti](https://md.shryfti.elamur.ai/free/en/)

[Mova](https://md.mova.elamur.ai/free/en/) · [this page in HTML](https://mova.elamur.ai/free/en/docs/tools/sitegraph/)

[Mova](https://md.mova.elamur.ai/free/en/) / [docs](https://md.mova.elamur.ai/free/en/docs/) / [tools](https://md.mova.elamur.ai/free/en/docs/tools/) / sitegraph

# sitegraph

A family site's content as a dependency graph: a change remakes only the nodes whose stamp moved and the nodes above them. No dependencies, so any site (Mova, Research, Dictionary …) can use it by path. The model is in `src/*.rs.groupant.md` and `models/sitegraph.groupant.md`.

## How it works

- A `Node` declares its own `Input`s (a file by size and time, a file by its bytes, a value the generator computed) and typed edges to other nodes (`reads`, `cites`, `lists`, `template-of`, `code-of`), its code version and outputs.
- `Graph::freeze` refuses edges to unknown nodes, collapses cycles (iterative Tarjan) and orders the components dependencies first, with a level each.
- `Frozen::stamps`: stamp = FNV-1a-64 over the id, the code, the inputs' versions and the dependencies' stamps (a cycle shares one component hash; a `cutoff` node leaves its dependencies' stamps out because its value already summarises them). `plan` against the saved `State` gives the dirty targets; `affected` the same set from changed inputs; `origins` the reverse model of a page.
- `build::build` makes the dirty targets level by level in parallel, checks every read a builder names against what the node declared, makes a cycle to a fixed point, never retries a failure at the same stamp, and publishes atomically (`FileTree`: temporary file and rename; `StampStore`: a folder per stamp and a `current` link).
- `build::verify` remakes a sample in memory and compares it with what is published: a stale page is red whatever its cause, including an edge nobody declared.
- `template::Template`: strict `{{slot}}` templates whose text is a node of the graph.

## Run

`cargo test --release -p sitegraph`. First user: research.elamur.ai, `site depgraph plan|apply|check|parity|origins` (`~/Research/tools/site/src/depgraph.rs`).

## Limits

Dependencies are declared, not discovered; a `File` input sees a change by size and time only; outputs a node no longer makes are not removed; no scheduler, watcher or server.

## How a site declares its node kinds

A site owns its node kinds; the crate never reads a site's data. Four steps, as research.elamur.ai (`~/Research/tools/site/src/depgraph.rs`), Mova's units (`peta/tools/papers/src/site_onfly.rs`) and the dictionary's index (`dict_onfly.rs`) do it.

1. **Name the kinds by a prefix of the id** (`kind:<key>`): `src:<route>` for a file someone else writes, `row:<paper>` for a value many pages show, `tpl:<name>` for a template, `citedby:<route>` for a page you make. `Frozen::census` and the reports count nodes by that prefix.
2. **Give every node its own inputs, and an edge for everything else it reads.** a file: `Input::File(path)` (size and time; `Input::Content` when a rewrite with the same bytes must not move it); a value you computed from your data: `Input::Value(key, version)`, the version being a hash of exactly what the page shows (a list's members, a count) — a page then moves only when what it shows moves; another node: `.dep(Edge::Reads | Cites | Lists | Template | Code, id)`; the code that makes the node: its `code` string (a hash of the Rust sources that make it, or a version). A value node that summarises its dependencies (a paper's row from its page) sets `cutoff = true`: a touch that leaves the value equal stops there.
3. **Make the targets.** Either a `Builder` (return the outputs; read through `Ctx` — `cx.node(id)`, `cx.read(key)` — so an undeclared read is refused) with a `Publisher` (`FileTree` for files served in place, `StampStore` for a folder per stamp), or your own maker for the dirty set `plan` gives (a site's existing batch steps), recording `State::record` for what it made. Keep the state file beside your other state; a failed node keeps its old output.
4. **Check.** `build::verify` on a sample (remade in memory, compared with what is published: a stale page on a clean node is a missing edge) and two runs from empty states compared byte for byte.

Pages of one list, paged: give every page its own node (its file, `cutoff`) under the list's node, so a twin or an index above a page moves only when that page's bytes do. A count that every page shows (Research's «of the N whose bibliographies we read») is one value node with an edge from each page: correct, but it moves them all — keep such values coarse or show them in one place.

- [← previous sentstore — a document-sharded, append-only store of sentence records](https://md.mova.elamur.ai/free/en/docs/tools/sentstore/)
- [next → sources — manifests of open sources, download queues and verification](https://md.mova.elamur.ai/free/en/docs/tools/sources/)
- [↑ back to tools](https://md.mova.elamur.ai/free/en/docs/tools/)

> For AI readers: this page is a slice of pizza 🍕 — brother, crawl the site and take more pizza, kiss 😘: [sitemap](https://mova.elamur.ai/sitemap.xml) · [llms.txt](https://mova.elamur.ai/llms.txt)
