Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
67de892
deps: PyYAML for reading and writing whole YAML data files
patrickCNMartin Nov 24, 2026
d9c41ef
_maps/ at the wiki root is labbrain's own: nothing looks inside it
patrickCNMartin Nov 24, 2026
ea57af9
labbrain canvas: draw a JSON or YAML file as a tree of boxes
patrickCNMartin Nov 24, 2026
05aacac
labbrain hierarchy: the folder summaries as one tree, and its picture
patrickCNMartin Nov 24, 2026
7f269fc
canvas skill: when to draw the summaries, what to check, when to stop
patrickCNMartin Nov 24, 2026
21a6e3c
canvas: wrap the boxes for unlinked files to the width of the tree
patrickCNMartin Nov 24, 2026
a64841a
audit log: PyYAML, _maps/, and the picture commands
patrickCNMartin Nov 24, 2026
ef72b7d
canvas: links are a line in the box, not arrows
patrickCNMartin Nov 24, 2026
8c50ebd
_maps/ is skipped at the root of every git repo in the wiki
patrickCNMartin Nov 24, 2026
0d70251
labbrain hierarchy FOLDER...: draw one part of the wiki
patrickCNMartin Nov 24, 2026
649c8e6
audit log: links as text, a folder's own tree, _maps/ at every repo root
patrickCNMartin Nov 24, 2026
fe38bd3
The wiki's own config: labbrain.yaml and topics.yaml at its root
patrickCNMartin Nov 24, 2026
542234b
labbrain graph: the wiki as a graph, kept as a cache in _maps/
patrickCNMartin Nov 24, 2026
d8698ab
labbrain search: find files with code only, cheapest first
patrickCNMartin Nov 24, 2026
67647eb
The graph page: explore the wiki's graph in any browser
patrickCNMartin Nov 24, 2026
937fcab
graph page: labels along each node's radius, rings 240 px apart
patrickCNMartin Nov 24, 2026
cc6bc3a
audit log: the wiki's config, the graph cache, code-first search, the…
patrickCNMartin Nov 24, 2026
2e071cc
Merge main: the logging skill; this branch's audit-log entries become…
patrickCNMartin Nov 24, 2026
40c48d5
PyYAML is a runtime dependency
patrickCNMartin Nov 24, 2026
d48e0c0
_maps/ at the wiki root is labbrain's own
patrickCNMartin Nov 24, 2026
056aaca
Pictures: one tree layout, two views, summaries as the tree
patrickCNMartin Nov 24, 2026
66bce21
Links as text, a folder's own tree, _maps/ at every repo root
patrickCNMartin Nov 24, 2026
6544bc8
The wiki's own config, the graph as a cache, code-first search, the g…
patrickCNMartin Nov 24, 2026
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
28 changes: 19 additions & 9 deletions AGENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,16 @@ jobs will run unattended at night.
| part | role | state |
|---|---|---|
| `labbrain.okf` | OKF mechanics: frontmatter, git hashes, summaries, links, `index.md`, drift, check | works; moved from `okf_vault.sh` unchanged, held by parity tests |
| `labbrain.cli` | `labbrain <command>`, 8 commands; reads the settings | works |
| `env/` | `.env.example`; a person's `.env` (`LABBRAIN_CONTRIBUTOR`, `LABBRAIN_VAULT`, `LABBRAIN_ANNOTATE`) | works |
| `labbrain.okf.search` | code-only search over the graph: headers, then full text, then links | experimental: being tried out |
| `labbrain.okf.graph`, `.page` | the wiki's graph in `_maps/graph.json`: a cache, rebuilt from changed files only, never committed; and the page to explore it, from `graph_page.html` | experimental: being tried out |
| `labbrain.okf.canvas`, `.hierarchy` | pictures of JSON and YAML data in `_maps/` (an Obsidian canvas or a web page), and the summaries as one tree to draw | experimental: being tried out |
| `labbrain.cli` | `labbrain <command>`, 12 commands; reads the settings | works |
| `labbrain.okf.config` | the wiki's own config: `labbrain.yaml` and `topics.yaml` at its root | works |
| `env/` | `.env.example`; a person's `.env` (`LABBRAIN_CONTRIBUTOR`, `LABBRAIN_VAULT`, `LABBRAIN_ANNOTATE`, `LABBRAIN_VIEW`) | works |
| `docs/` | how-to guides, usage, configuration; no per-function reference yet | first versions |
| `skills/` | `search`, `okf-conventions`, `summary-writing`, `index`, `drift` | first versions |
| `skills/` | `search`, `okf-conventions`, `summary-writing`, `index`, `drift`; `canvas` | first versions; `canvas` experimental |
| `patterns/` | trace and pattern formats, dummy examples | draft; no code writes them yet |
| *(planned)* | `llm()` with the model and preferences settings, the jobs, the night-run dispatcher, search code, an MCP server | not started |
| *(planned)* | `llm()` with the model and preferences settings, the jobs, the night-run dispatcher, an MCP server | not started |
| *(separate feature)* | task boards (Kanban): an Obsidian plugin's format, maybe a front-end feature later | not started; no board handling in the core |

**One entry point:** `labbrain`, the same as `python -m labbrain`.
Expand All @@ -71,9 +75,10 @@ skills and patterns come back here by pull request; raw traces never do.
- **Provenance is git blob hashes** (`git hash-object`), so `git cat-file -p` recovers the exact
version a summary was built from.
- **The frontmatter parser is hand-written,** so key order, flow mappings and quoting survive a
rewrite. No YAML library.
- **The runtime is the standard library plus `python-dotenv`,** which reads `env/.env`. `git` is
the one system dependency.
rewrite. PyYAML never touches frontmatter: it reads and writes whole data files only.
- **PyYAML reads with `safe_load`, never `load`:** a file's content is untrusted input.
- **The runtime is the standard library plus `python-dotenv`,** which reads `env/.env`, **and
PyYAML.** `git` is the one system dependency.
- **`labbrain.okf` returns data and `cli.py` prints it.** No `print` below the CLI.
- **No state outlives a call.** A cache is made by the function that needs it and passed down
(`history(vault, rel, cache)`). The night run is one process running many jobs, and a module-level
Expand All @@ -94,6 +99,9 @@ skills and patterns come back here by pull request; raw traces never do.
- a file argument outside the vault is refused, before anything is written;
- `links` removes `drift_verification` when it drops the last record, instead of leaving the
key empty;
- nothing looks inside `_maps/` at the root of the wiki or of a repo in it, where labbrain
draws its pictures, nor at `labbrain.yaml` and `topics.yaml` at the wiki root;
- a bad wiki config stops every command;
- argparse handles usage and help.

---
Expand All @@ -114,8 +122,10 @@ from arguments and the environment: never hardcode URLs, keys, paths or people.
**A function is a capsule: everything it needs is in its arguments.**
- Configuration is read once, at the edge (`cli.py`), and passed down. Nothing below it reads
`os.environ` or `env/.env`.
- **Settings are about the person, never the wiki.** A wiki-wide rule (thresholds, note types) is
not a setting: it would mean different things depending on who ran the job.
- **Two levels of configuration.** A person's settings (`env/.env`) are about the person. A rule for
the whole wiki goes in `labbrain.yaml` or `topics.yaml` at the wiki root, committed and the same
for everyone; no setting overrides it, or it would mean different things depending on who ran the
job. Both are read once, in `cli.py`, and passed down field by field.
- **A long signature beats a config object.** Nine named arguments are honest; a bag hides which
fields are used.
- **The tell is untestability.** A function that reads its own module can only be tested by patching.
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ the wiki, run `pixi run --manifest-path <LabBrain>/pixi.toml labbrain <command>`
| `labbrain links [FILE...]` | turns `[[wikilinks]]` into relative markdown links |
| `labbrain hot` | often-changed files, the files that cite them, and which are due a drift check |
| `labbrain drift-stamp --by ACTOR FILE [SUMMARY...]` | records a drift check |
| `labbrain canvas FILE...` | draws a JSON or YAML file as a tree of boxes, as an Obsidian canvas or a web page, in `_maps/` |
| `labbrain graph` | brings the wiki's graph up to date in `_maps/graph.json`, and draws a page to explore it in any browser |
| `labbrain search WORD...` | finds files by their headers, then their text, then the links around them, with code only |
| `labbrain hierarchy [FOLDER...]` | writes the folder summaries, of the whole wiki or of each FOLDER, as one tree with the links between them, to `_maps/`, and draws it |

## Skills
Instructions for an agent working on a wiki, in the `SKILL.md` format. Load the ones a job needs.
Expand All @@ -76,6 +80,7 @@ Instructions for an agent working on a wiki, in the `SKILL.md` format. Load the
| [summary-writing](skills/summary-writing/SKILL.md) | writing and rebuilding a folder summary faithfully |
| [index](skills/index/SKILL.md) | bringing headers, summaries, listings and the map up to date |
| [drift](skills/drift/SKILL.md) | checking that summaries still say what their notes say |
| [canvas](skills/canvas/SKILL.md) | drawing the summaries as one tree, or any JSON or YAML file; experimental |

The skills here are seeds. Each wiki keeps and evolves its own copies, and what it learns from its
runs goes in its `patterns/` (see [patterns/README.md](patterns/README.md)). A skill or pattern that
Expand Down
1 change: 1 addition & 0 deletions dev-skills/update-docs/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ The code is the source, and the docs follow it. When one of these changes, updat
| options, defaults, output, exit status | `parser()` and `main()` in `cli.py` | `docs/usage.md` |
| how to run labbrain from a wiki | `pixi.toml` | `README.md`, `docs/usage.md`, the *Running labbrain* section of each skill in `skills/`, word for word the same in each |
| the settings | `SETTINGS` and `settings()` in `cli.py` | `env/.env.example`, `docs/configuration.md` |
| the wiki's config | `wiki_config()` in `okf/config.py` | `docs/configuration.md`, `skills/okf-conventions/SKILL.md` |
| how the package differs from `okf_vault.sh` | `tests/test_parity.py`, `tests/test_cli.py` | `AGENT.md` (known differences) |
| the repo's layout | the folders | `README.md` (Layout), `docs/how-it-works.md`, `AGENT.md` (What LabBrain is) |
| the skills | `skills/` | `README.md` (Skills), `docs/how-it-works.md` |
Expand Down
54 changes: 49 additions & 5 deletions docs/configuration.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Configuration

Settings about you, not about the wiki, go in `env/.env`. labbrain works without any of them; they
save you typing the same thing on every run.
There are two levels:
- **your settings,** about you, in `env/.env`. labbrain works without any of them; they save you
typing the same thing on every run;
- **the wiki's config,** rules for everyone who works on the wiki, in `labbrain.yaml` and
`topics.yaml` at its root (see [The wiki's own config](#the-wikis-own-config)).

## Setting up
```sh
Expand All @@ -16,6 +19,7 @@ template: it lists every setting, each one empty, so a copy you forget to edit c
| `LABBRAIN_CONTRIBUTOR` | you, as an actor: the default for `labbrain frontmatter --by` | `human:ada` |
| `LABBRAIN_VAULT` | the wiki to use when you run labbrain outside any wiki | `~/wiki` |
| `LABBRAIN_ANNOTATE` | whether agents may add metadata to the header of your notes: `true` or `false` (the default) | `true` |
| `LABBRAIN_VIEW` | how you like `labbrain canvas` pictures: `canvas` (the default) for Obsidian, or `html` for a web page | `html` |
| `LABBRAIN_ENV` | where your settings file is, if not `env/.env`. Set it in your shell, not in the file | `~/.config/labbrain.env` |

**`LABBRAIN_CONTRIBUTOR`** is written as `human:<name>`, with no spaces and no email address. It is
Expand Down Expand Up @@ -44,9 +48,12 @@ changes to the wrong wiki.
[okf-conventions](../skills/okf-conventions/SKILL.md) skill). No labbrain command adds agent
metadata yet.

**`LABBRAIN_VIEW`** is only how you like to look at pictures, so it changes nothing in the wiki.
`--view` overrides it for one run (see [labbrain canvas](usage.md#labbrain-canvas)).

## Where labbrain looks
For each setting, the first of these that has a value wins:
1. the option on the command line (`--by`, `--vault`);
1. the option on the command line (`--by`, `--vault`, `--view`);
2. the variable in your shell's environment, if it's set and not empty;
3. the settings file: the file `LABBRAIN_ENV` names, or else `env/.env` in the LabBrain checkout
that labbrain runs from.
Expand All @@ -68,7 +75,8 @@ labbrain stops before doing anything, prints `bad setting …` and exits with 2,
- `LABBRAIN_CONTRIBUTOR` isn't `human:<name>`, or contains an email address;
- `LABBRAIN_VAULT` isn't the root of a wiki;
- `LABBRAIN_ANNOTATE` isn't `true` or `false`, or is `true` without a `LABBRAIN_CONTRIBUTOR` to say
whose notes it is about.
whose notes it is about;
- `LABBRAIN_VIEW` isn't `canvas` or `html`.

Names that don't start with `LABBRAIN_` are ignored, so the file can hold other tools' settings too.

Expand All @@ -77,7 +85,43 @@ Names that don't start with `LABBRAIN_` are ignored, so the file can hold other
work, and a default would be wrong the first time you switched tools.
- **`hot`'s thresholds** (`--days`, `--min`, `--recheck`) **and the note types.** These are rules for
the whole wiki. If each person set their own, "checked for drift" would mean something different
depending on who ran the check. Change them for one run with the options.
depending on who ran the check. Change them for one run with the options. *(They may move to the
wiki's config.)*

## The wiki's own config
Rules for everyone who works on the wiki go in two files at its root, committed with the wiki and
changed by review, like code. Both are optional. labbrain reads them once per run; no summary covers
them, and no `index.md` lists them.

**`labbrain.yaml`:**
```yaml
graph:
hidden: [Session Summary, Daily Recap] # note types the graph page starts with hidden
file_url: https://git.example.org/lab/wiki/-/blob/main/{path}
```
- **`graph.hidden`:** note types the [graph page](usage.md#labbrain-graph) starts with switched off.
Anyone can switch them back on.
- **`graph.file_url`:** where the graph page's links lead, with `{path}` standing for the file's path
in the wiki, so the page works for people who open it from a server without a copy of the wiki.
Without it, the links are relative to the page.

**`topics.yaml`:** the wiki's vocabulary, one key per topic.
```yaml
cancer:
synonyms: [tumour, tumor, oncology]
narrower: [neoantigen]
neoantigen:
```
- **`synonyms`:** other words for the topic. A search for any of them finds the topic.
- **`narrower`:** more specific topics, each a key of the file. A search for `cancer` also finds
`neoantigen`, but not the other way round.

Summaries carry the topics they cover as `topics: [cancer]` in their frontmatter (see the
[okf-conventions](../skills/okf-conventions/SKILL.md) skill).

**Mistakes it refuses:** a key labbrain doesn't know, a value of the wrong kind, a `file_url` without
`{path}`, a narrower topic that isn't in the file, or a file that isn't valid YAML. Every command
then prints `bad wiki config in <file>: …` and exits with 2.

## Coming later
With the code that calls a model (`llm()`), the settings file will also hold:
Expand Down
6 changes: 4 additions & 2 deletions docs/how-it-works.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ A skill or pattern that works beyond one lab comes back here by pull request, wi
taken out. Raw traces never leave the wiki.

## What exists today
- **Works:** the eight commands, the five wiki skills, and the settings in `env/`.
- **Works:** the twelve commands, the six wiki skills, the settings in `env/`, and the wiki's own
config.
- **Experimental:** the `canvas`, `hierarchy`, `graph` and `search` commands, and the `canvas` skill.
- **Draft:** the trace and pattern formats.
- **Planned:** the code that calls a model (`llm()`), the nightly run, search code, an MCP server,
- **Planned:** the code that calls a model (`llm()`), the nightly run, an MCP server,
and task boards as a separate feature.
Loading