From 203b304729199f8cb59c6ec319ac5d206c1e81a7 Mon Sep 17 00:00:00 2001 From: billlyzhaoyh Date: Sun, 29 Nov 2026 21:36:35 +0000 Subject: [PATCH 1/6] docs: lead the README with the positioning line and the shared top The first line now says what Analects is in the words of the repository description. The top adds links to the docs, Discussions and the contributing guide, a refusal from the data centre example as the picture, and a Try it section. --- README.md | 44 ++++++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index c589178..8ede200 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,25 @@ # Analects -**A research knowledge graph where every value cites a source.** +**An open research record: what you and your agents find, kept per entity in the source's own words, with every change on file.** -Analects is for research that has to stand up: who is building which data centre, which -company is behind it, how a representative voted, what a register says now and -what it said last month. You and the agents working for you record what you find -as claims about entities. Every claim cites an event — a document, a locator and -the exact words, checked against a saved copy of the page. Nothing is written from -memory, and nothing is overwritten: a newer value supersedes an older one, or -contests it, and the history stays readable. +[Docs](https://kindtechuk.github.io/analects/) · [Questions and ideas](https://github.com/KindTechUK/uk-open-data/discussions) · [Contribute](CONTRIBUTING.md) -It runs as a CLI and as an MCP server, so it works with Claude Code, Claude -Desktop, claude.ai (through a hosted peer) and any MCP client. +[Billy: Discussions is off on every Kindtech repo today. Turn it on in uk-open-data before this merges, or this link leads nowhere.] + +```text +$ analects check sources/apatura/ravenscraig-the-project.txt --source https://consult.apatura.energy/ravenscraig/the-project ... +check https://consult.apatura.energy/ravenscraig/the-project [management_statement] refused 1 new 2 + +refused — not staged — the document does not support this + Ravenscraig capex=GBP 3.9bn + this quote is not in the document. Re-read it and copy the exact words, or drop the claim. +``` + +From [`examples/uk-data-centres.sh`](examples/uk-data-centres.sh), which runs on saved pages with no network. Every headline reports a £3.9bn investment in the campus. The developer's own page does not say it, so Analects refuses to record it from that page. -## Install +## Try it + +You need [uv](https://docs.astral.sh/uv/) and Python 3.11 or newer. ```bash uv tool install "git+https://github.com/KindTechUK/analects" @@ -22,7 +28,21 @@ analects schema test ``` Then connect your agent — `claude mcp add analects -- analects mcp` for Claude Code — and read -[your first research run](docs/getting-started/first-research-run.md). +[your first research run](docs/getting-started/first-research-run.md). To watch it work first, run +the example above from a clone: `uv sync`, then `bash examples/uk-data-centres.sh`. + +## About + +Analects is for research that has to stand up: who is building which data centre, which +company is behind it, how a representative voted, what a register says now and +what it said last month. You and the agents working for you record what you find +as claims about entities. Every claim cites an event — a document, a locator and +the exact words, checked against a saved copy of the page. Nothing is written from +memory, and nothing is overwritten: a newer value supersedes an older one, or +contests it, and the history stays readable. + +It runs as a CLI and as an MCP server, so it works with Claude Code, Claude +Desktop, claude.ai (through a hosted peer) and any MCP client. ## What it does From eb5837454f84c4a560f41b637ead22ebe9d6f295 Mon Sep 17 00:00:00 2001 From: billlyzhaoyh Date: Sun, 29 Nov 2026 21:54:57 +0000 Subject: [PATCH 2/6] docs: make the first research run runnable from a clone Step 1 used page.txt and mentions.json and step 3 basic-subset.csv and tec.json, without saying where they are. The steps now say to run from the top of a clone and name the captured files the example uses. Running them also showed that under the default `confirm` policy `merge --all` holds the new campus, so step 2 found nothing merged, and the truth in step 4 stayed staged. Both merges now confirm what you have read. Step 3 shows the grid queue query, since the brief does not change there, and step 4 writes a real truth and question in place of placeholders. --- docs/getting-started/first-research-run.md | 44 +++++++++++++++------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/docs/getting-started/first-research-run.md b/docs/getting-started/first-research-run.md index 6592f2b..00cea35 100644 --- a/docs/getting-started/first-research-run.md +++ b/docs/getting-started/first-research-run.md @@ -3,24 +3,37 @@ This walks the loop on captured pages, with no network: the same investigation the [examples](../../examples/README.md) run end to end. +The captured pages are in the repository. Run the steps from the top folder of a +clone: + +```bash +git clone https://github.com/KindTechUK/analects && cd analects +``` + ## 1. A claim, from a developer's own page A developer's consultation page says what it will build. `analects check` reads the page's text and the facts you extracted from it, checks every quote is on the page, and says what is new, what contradicts what you hold, and what cannot be -matched — writing nothing: +matched — writing nothing. Here the page is Apatura's page on Ravenscraig, and the +facts are in `examples/data/ravenscraig-mentions.json`: ```bash -analects check page.txt --source https://example.org/the-project \ - --type management_statement --mentions mentions.json --ops-out ops.json -analects write --ops ops.json # stage them -analects review # what is waiting, and why -analects merge --all # under `confirm`, after you have looked +analects check tests/golden/sources/apatura/ravenscraig-the-project.txt \ + --source https://consult.apatura.energy/ravenscraig/the-project \ + --type management_statement --published-at 2026-09-22 \ + --mentions examples/data/ravenscraig-mentions.json --ops-out ops.json +analects write --ops ops.json # stage them +analects review # what is waiting, and why +analects merge --all --confirm entity # after you have looked ``` A figure that is reported everywhere but is not on this page is refused by name: the page is the evidence, not the headline. +Under `confirm`, `merge --all` holds a new entity for you. `--confirm entity` says +you have read it. + ## 2. Ask the graph ```bash @@ -33,21 +46,26 @@ analects get "Ravenscraig" --as-of 2026-01-01 ## 3. Corroborate from a register ```bash -analects import companies-house basic-subset.csv -analects import neso-tec tec.json -analects brief "Ravenscraig" # the grid queue now corroborates, or contests +analects import companies-house tests/golden/sources/companies-house/basic-subset.csv +analects import neso-tec tests/golden/sources/neso/tec-apatura.json +analects import neso-tec tests/golden/sources/neso/tec-newarthill.json +analects query --type interconnection_request --where "customer ~ APATURA" ``` -A second, independent source raises confidence; a different value makes the -property contested, and both stay visible. +The grid queue holds eighteen of Apatura's connections, and none is called +Ravenscraig. A second, independent source raises confidence; a different value +makes the property contested, and both stay visible. ## 4. Leave it better ```bash -analects truth "Ravenscraig" --set "Two to six sentences: what it is, what changed, what is unknown." -analects defer "a fact you could not place" --reason no_site +analects truth "Ravenscraig" --set "An announced 550MW AI data campus. The only source is the developer's own page, and the widely reported £3.9bn is not on it. No connection in the grid queue is tied to it yet." +analects defer "Which grid connection is Ravenscraig's? The PSC register would settle it." \ + --reason missing_entity --entity Ravenscraig +analects merge --all --confirm truth # you wrote it: land it ``` +A truth is two to six sentences: what it is, what changed, what is unknown. Next time anyone — you or an agent — runs `analects brief`, it starts from here. ## Run the full examples From d41b16de400b6f11c60189a9b3f89336ac091029 Mon Sep 17 00:00:00 2001 From: billlyzhaoyh Date: Sun, 29 Nov 2026 21:54:57 +0000 Subject: [PATCH 3/6] docs: give the fixture count schema test prints today analects schema test says 20 fixtures well-formed, not 17. --- docs/getting-started/install.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting-started/install.md b/docs/getting-started/install.md index 7a44a5f..e409bd2 100644 --- a/docs/getting-started/install.md +++ b/docs/getting-started/install.md @@ -19,7 +19,7 @@ votes, statements) — ship with it. Check they load: ```bash analects schema test -# 3 packs load; 12 entity types; 17 fixtures well-formed +# 3 packs load; 12 entity types; 20 fixtures well-formed ``` ## Optional extras From 809a516bdcc71b8d3201d2f6ad9ae2c2480b4ee0 Mon Sep 17 00:00:00 2001 From: billlyzhaoyh Date: Sun, 29 Nov 2026 21:54:57 +0000 Subject: [PATCH 4/6] docs: say how the graph's folder is found The configure guide said the graph is in the current folder or the nearest one above it with a graph.db. repo_root() also stops at the nearest folder with a packs/ folder, of any kind, so the graph can land a few folders up. Say what the code does, and to check the path init prints. --- docs/getting-started/configure.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/getting-started/configure.md b/docs/getting-started/configure.md index e9ad5d4..39b6e45 100644 --- a/docs/getting-started/configure.md +++ b/docs/getting-started/configure.md @@ -22,10 +22,14 @@ It says where each thing is: | What | Where | Change it with | | --- | --- | --- | -| the graph (`graph.db`, SQLite) | the current folder, or the nearest one above it that has a `graph.db` | `--db`, `$ANALECTS_DB` | +| the graph (`graph.db`, SQLite) | the nearest folder, starting at the current one, that has a `packs/` folder or a `graph.db`; the current folder if none does | `--db`, `$ANALECTS_DB` | | the config (`analects.yaml`) | `~/.analects/analects.yaml` | `$ANALECTS_CONFIG` | | the packs | the ones Analects ships with, plus a project's own `packs/` folder (`analects schema new`) | `$ANALECTS_PACKS` | +Any folder called `packs/` counts, even one that holds no Analects packs, so the +graph can land in a folder above the one you are in. `analects init` prints the path +it chose: check it. + Analects was called kg. An old `~/.kg/kg.yaml`, the `kg` command and any `$KG_…` setting still work; a `$ANALECTS_…` setting wins over its `$KG_…` twin ([D69](../decisions/D69-kg-is-renamed-analects-and-the-old-names-keep-working.md)). From 165c41c84c890b333a06d478e5489952e46b213b Mon Sep 17 00:00:00 2001 From: billlyzhaoyh Date: Sun, 29 Nov 2026 21:54:57 +0000 Subject: [PATCH 5/6] fix: remove an example's work folder when it ends The examples made a mktemp folder holding a 1 MB graph.db and never removed it. Remove it on exit. A folder named by ANALECTS_DEMO_DIR is still kept. --- examples/_lib.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/examples/_lib.sh b/examples/_lib.sh index dd96d5f..578a81f 100755 --- a/examples/_lib.sh +++ b/examples/_lib.sh @@ -1,6 +1,8 @@ # Shared plumbing for the demos. Each demo builds a fresh graph in a temporary # directory from the sources captured in tests/golden/sources/, so running one -# never touches your own graph.db and never makes a network request. +# never touches your own graph.db and never makes a network request. The +# directory is removed when the demo ends, unless ANALECTS_DEMO_DIR names one +# to keep. set -u ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" @@ -8,7 +10,12 @@ SOURCES="$ROOT/tests/golden/sources" DEMOS="$ROOT/examples" ANALECTS="${ANALECTS:-uv run --project $ROOT --quiet analects}" -WORK="${ANALECTS_DEMO_DIR:-$(mktemp -d)}" +if [ -n "${ANALECTS_DEMO_DIR:-}" ]; then + WORK="$ANALECTS_DEMO_DIR" +else + WORK="$(mktemp -d)" + trap 'rm -rf "$WORK"' EXIT +fi mkdir -p "$WORK" export ANALECTS_DB="$WORK/graph.db" export ANALECTS_CONFIG="$WORK/analects.yaml" From a4dc0666beed5b90f5cea2d4b5ca447c562821c1 Mon Sep 17 00:00:00 2001 From: billlyzhaoyh Date: Sun, 29 Nov 2026 22:19:59 +0000 Subject: [PATCH 6/6] docs: drop the placeholders now that Discussions is on --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 8ede200..d833450 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,6 @@ [Docs](https://kindtechuk.github.io/analects/) · [Questions and ideas](https://github.com/KindTechUK/uk-open-data/discussions) · [Contribute](CONTRIBUTING.md) -[Billy: Discussions is off on every Kindtech repo today. Turn it on in uk-open-data before this merges, or this link leads nowhere.] - ```text $ analects check sources/apatura/ravenscraig-the-project.txt --source https://consult.apatura.energy/ravenscraig/the-project ... check https://consult.apatura.energy/ravenscraig/the-project [management_statement] refused 1 new 2