Contributing
Code is Apache-2.0. Contributions to SPEC.md are CC0. Read SPEC.md and ARCHITECTURE.md first: the record's rules are there, and a change that needs to break one is wrong.
There is one way to do each thing here. Where this page and a habit disagree, this page wins.
Set up once
git clone https://github.com/bighydro/logbook && cd logbook
uv sync --group dev # Python 3.12, every dependency, the dev tools
uv run pre-commit install # ruff, gitleaks, the PII check, on every commit
git config gpg.format ssh && git config user.signingkey ~/.ssh/id_ed25519.pub # or your GPG key
Register the signing key on GitHub (how) so the pull request shows Verified. Then create ~/.config/logbook/pii-patterns, one case-insensitive regular expression per line for your own identifiers (your names, numbers, addresses, account ids, the names of your contacts). The pre-commit hook scripts/check_pii.py greps every added line against it and stops you before CI does. The file is never committed, printed or pasted anywhere.
The hook reads more than a commit. Run by pre-commit run check-pii --from-ref origin/main --to-ref HEAD, it checks the lines the branch adds: pre-commit names the range in PRE_COMMIT_FROM_REF and PRE_COMMIT_TO_REF and stages nothing, so the script reads git diff FROM..TO instead of the staged diff (--from-ref and --to-ref on the script itself do the same). python scripts/check_pii.py --tree main reads every line of every file tracked on main, for a one-time sweep. Every run ends with one line of counts, check-pii: 18 patterns, 9879 lines, 0 matches in the staged diff, which pre-commit shows on a pass too. With no patterns file, a file of comments only, or nothing to read, that line is a warning: and the hook passes, so "checked, clean" never looks like "checked nothing". A match prints the file, the line number and the pattern's name, never the text: the name is the pattern's first named group, (?P<phone>…), or else line N, its line in the patterns file.
Do one change
- Pick or open one issue. The pull request closes it and nothing else. A second change is a second branch.
- One branch, one worktree, one session.
git worktree add ../logbook-<issue> -b <branch>, thenuv sync --group devanduv run pre-commit installin it, since each worktree has its own.venvand hooks. Work there and nowhere else, never check out another branch in it, and never run anything against a real record:tests/conftest.pypinsLOGBOOK_HOMEand the home directory to a temp dir, and nothing unsets that. - Test first. Write the failing test, run it, implement, run it again:
uv run pytest tests/test_<area>.py # the test you wrote uv run pytest -n auto # the whole suite, as CI runs it uv run ruff check --fix . && uv run mypy logbook - Commit after each step, signed and signed off.
git commit -s -S, thengit log -1 --format='%G?'printsG. Anything else means unsigned; fix it before pushing. Conventional commit prefixes:feat:,fix:,spec:,docs:,adapter:. - Add a changelog fragment, never a line in CHANGELOG.md.
changelog.d/<short-slug>.mdholds one or a few-lines in the changelog's own wording, optionally under### Added,### Fixedor another heading the changelog already uses (changelog.d/README.md). A change with nothing to tell the user gets theno-changeloglabel on its pull request instead. - Push and open the pull request against
main. Fill in the template. CI must be green before review; a first-time contributor's workflows wait until a maintainer approves them, which is GitHub's default and not a judgement on the change. - When it merges,
git worktree remove ../logbook-<issue>and delete the branch.
The rules every pull request keeps
- Nothing real enters the tree. Not a record, not an export, not a screenshot, not a line in a pull request description. Every fixture, test, example and docs page uses the sample person, who lives in Oslo and does not exist, and her circle (
docs/try-it.md, Who). Phone numbers come from the UK's fictional block07700 900xxxor the persona's+47 9000 000xblock already in the fixtures. Email addresses are atexample.org. Addresses, places, businesses, the airlineXY, the aircraftZZ-ABC, the yachts Solvind and Nordlys on the unassigned MMSI999000001are invented. An identifier that looks like a service's own (a JID, a Matrix event id, a bank transaction id) is re-patterned by hand, never copied from a real export. A fixture is written by hand or generated by code checked in beside it (logbook/contrib/demo.py,conformance/make_sample.py). - Scrub, then check the scrub. A fixture that started life as your own export is swapped identifier by identifier for ones from the reserved ranges, so it still reads as a record; a blanked field is a fixture that no longer tests what it tested. The check is the pre-commit hook, or
/usr/bin/grepor Python'sreby hand, never baregrep: on a Mac wheregrepis ugrep a pattern that matches nothing proves nothing. Checks print counts only. Record demos from a throwaway home directory; a prompt can leak what a file does not. - The log is written only through
Logbook.append. No code path updates or deletes a line. A correction is a new line that retracts an old one. - No network on an adapter's default path, no write to any source. An adapter that reads an app's own store confirms the columns it needs with
PRAGMA table_infofirst and tolerates drift: a column it does not need may be missing or renamed and the rows still read; a table it needs that is absent is a counted skip or one clear error naming the store, never a traceback. - The envelope (SPEC §2 and §3) changes only with a spec version bump, a regenerated conformance fixture and an ADR in
docs/adr/. - Windows runs the tests too, and it has caught a bug in every pull request that forgot it. Paths through
pathlib, never as strings;zoneinfoneedstzdatathere; a subprocess is read withencoding="utf-8", nevertext=True; every SQLite connection and file is closed before an unlink; digests are taken over the bytes written withwrite_bytes, never over the string formatted; a test that needs a real shell skips onwin32; a test that needs its own home directory monkeypatchesPath.homeor sets bothHOMEandUSERPROFILE. Filesystems on macOS and Windows are case-insensitive, so files are never told apart by case.
Write an adapter
The easiest and most useful thing to build is an adapter for the export you already have. The ones wanted, with their export formats, profiles and tiers, are in the bounty list; the ones marked good first adapter are a few hours each.
- Copy
adapters/template/tologbook/contrib/adapters/<source>.pywith its tests andtests/fixtures/<source>/. - Put a small, synthetic export in the fixture folder. Never real data, not even yours.
- Write
NAME,sniff(path) -> boolandrun(input_path, since)yielding observations with apayload.schemafrom an existing RFC. A new shape is a new RFC first (below). - Register the module once, in
pyproject.tomlunder[project.entry-points."logbook.adapters"], wherelogbook addshould try it (the order isfind's precedence);tests/test_adapter_registry.pyfails on a module that is not there. Add a page underdocs/adapters/when the source needs explaining. - Run the tests; the expected output is generated on the first run and checked in.
- Open the pull request as
adapter: <source>.
A source that has both an export and a live API is one adapter with one mapping: backfill and live share it, so the same observation arrives once, with one shape and one raw_id, whichever way it came (ADR 0017).
Propose a profile or a spec change
A payload profile or a change to SPEC.md is an RFC: open an issue with the RFC template, then a pull request adding rfcs/NNNN-<name>.md with a JSON Schema, one synthetic example line and the backwards-compatibility note. Two weeks of comment; the captain merges or declines with reasons (GOVERNANCE.md). A change to the envelope is a major version and ships with a migration tool.
The clean-room rule for logbook-ts
logbook-ts exists to prove that SPEC.md is enough to implement the format (SPEC §6: two independent implementations must agree before 1.0 is frozen). It proves that only while it stays independent. A contributor to logbook-ts works from SPEC.md, the RFCs and conformance/, never from this repository's source, tests or diffs; if you had to read the Python to understand a rule, the rule is underspecified, so file that against the spec instead of carrying the answer across. Nothing is ported in either direction: a fix found by one implementation becomes a spec question, is resolved in SPEC.md with a changelog line naming the finder, and only then is implemented on each side from the spec's words. Keep the two in separate checkouts and separate sessions; an agent that has one open does not open the other.
Slow tests
The suite runs in parallel (uv run pytest -n auto) and a pull request's CI should finish in minutes, so a test is marked by how long it takes. No marker: under about five seconds, run on every push and pull request. @pytest.mark.slow: over about five seconds and still a plain correctness test, skipped unless LOGBOOK_SLOW=1, which CI sets on a push to main and nightly; run them once before opening a pull request with LOGBOOK_SLOW=1 uv run pytest -n auto -m slow. @pytest.mark.stress: the generated millions-of-lines tests with timing and memory assertions, skipped unless LOGBOOK_STRESS=1 and never run in CI. A test owns nothing but its tmp_path: no fixed port, no file in the working tree, no order it relies on.
Before a rename merges, run the fuzz readers. A pull request that renames a command or changes a reader's output gets one run of LOGBOOK_SLOW=1 uv run pytest tests/test_fuzz_readers.py before it merges, and ticks the box in the template. Those tests are slow-tier, so the pull-request CI tier skips them and a regression only shows on the push to main after the merge: #215 (the 22-command rename) turned main red that way on 4 October 2026, and #217 fixed it forward.
What CI checks
Every pull request and every push to main: ruff and mypy; the suite on Linux, macOS and Windows with Python 3.12 and 3.13; the conformance rule (logbook verify on conformance/sample-logbook prints the head in conformance/expected.json); the Nix and Docker builds; cross-impl, which builds logbook-ts at its main, checks that it prints the same head on the sample, appends one note to a copy with this CLI and verifies the copy with that one; and changelog, which fails a pull request that edits CHANGELOG.md or adds no fragment unless it carries the no-changelog label.
Where does my code go
One package, three tiers (ARCHITECTURE.md; logbook/layout.py declares them, tests/test_layout.py holds the tree to it):
logbook/core/— the format and what SPEC.md freezes with it: the chain, the record, the index, the attachment store, the tiers, and a reader whose JSON a second implementation is compared on (§6.1). A change here is a spec change until proven otherwise.logbook/contrib/— an adapter (contrib/adapters/<source>.py, one module per source, registered once inpyproject.toml;BUILT_INis generated from that table), an import or sync, an export, or a derived reader whose output is a reader's own. Imports core and contrib, never labs.logbook/labs/— anything that runs a model, or is still an experiment. Imported only when its command runs.logbook/commands/— the command itself:<name>_arguments(sub)andcmd_<name>(a)in the family's module, a line inparser.py; an adapter or a labs module imported inside the function, sologbook --helpstays cheap.- A module that moves keeps its old import path for one minor version (
layout.MOVED,docs/migration-0.6.md).