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
Nodedeclares its ownInputs (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::freezerefuses 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; acutoffnode leaves its dependencies' stamps out because its value already summarises them).planagainst the savedStategives the dirty targets;affectedthe same set from changed inputs;originsthe reverse model of a page.build::buildmakes 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 acurrentlink).build::verifyremakes 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.
- 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::censusand the reports count nodes by that prefix. - Give every node its own inputs, and an edge for everything else it reads.
- a file:
Input::File(path)(size and time;Input::Contentwhen 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
codestring (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) setscutoff = true: a touch that leaves the value equal stops there.
- a file:
- Make the targets. Either a
Builder(return the outputs; read throughCtxβcx.node(id),cx.read(key)β so an undeclared read is refused) with aPublisher(FileTreefor files served in place,StampStorefor a folder per stamp), or your own maker for the dirty setplangives (a site's existing batch steps), recordingState::recordfor what it made. Keep the state file beside your other state; a failed node keeps its old output. - Check.
build::verifyon 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.
This page in Markdown https://md.mova.elamur.ai/free/en/docs/tools/sitegraph/