Check a knowledge base and work as a team
The check command validates the files of a knowledge base. It checks the fields at the top of
each document, such as the ID, the status, and the tags. It also checks the required sections, the
links between documents, and the wiki pages. The skills validate the knowledge base after each
change that they make. Run the check yourself before a commit, and after you edit a file by hand.
A knowledge base is a git repository, so a team shares it the way it shares code: on branches and through pull requests. This guide also covers what differs from code: document IDs on parallel branches, the generated graph, and the rules that a team sets for itself.
Run the check before a commit
In the knowledge base's folder, run the check:
npx -y @push-based/reasonry@2 check
The command prints one line for each area and ends with PASSED or FAILED. The following output
comes from Reasonry's test knowledge base:
[warn] source 0 error(s), 2 warning(s)
[ ok ] xrefs 0 error(s), 0 warning(s)
[ ok ] wiki 0 error(s), 0 warning(s)
[ ok ] initiative 0 error(s), 0 warning(s)
PASSED — 0 error(s), 2 warning(s)
The source area covers the documents, xrefs covers the references between documents, wiki
covers the wiki pages, and initiative covers each initiative's initiative.json file.
An error fails the check. The command lists each error after the lines for the areas, with the ID of the document. For example, a status that the configuration doesn't define produces this error:
source errors:
- DEC-VT-0001: Invalid status "approved" (expected: draft, accepted, rejected, superseded)
A warning doesn't fail the check, and the output counts the warnings without listing them. To read
the warnings, run validate:
npx -y @push-based/reasonry@2 validate
The report names each file and its warning:
# Validation Report (all)
**Valid:** Yes
**Errors:** 0 | **Warnings:** 2
## Source Issues
- **source/initiatives/test-initiative/decisions/DEC-VT-0009-return-to-service-checks-what-runs-when-and-who-is-answerable.md**: ⚠️ Line 14: states "four checks" but the list below it has 3 items
- **source/initiatives/test-initiative/evidence/EVID-VT-0007-return-to-service-check-coverage-a-census-of-300-network-assets.md**: ⚠️ Table at line 28: column "Assets" totals 300 but its 3 rows sum to 296
To make a warning fail the check too, add --strict:
npx -y @push-based/reasonry@2 check --strict
The output for the same knowledge base then ends with
FAILED — 0 error(s), 2 warning(s) (strict: warnings fail).
Add a pre-commit hook
A pre-commit hook runs the check before each commit. If the check fails, git doesn't create the
commit. If the knowledge base still has warnings, leave out --strict in step 1 until you fix
them, because one warning blocks every commit.
-
Create the
.githooks/pre-commitfile with this content:#!/bin/shnpx -y @push-based/reasonry@2 check --strict -
Make the file executable:
chmod +x .githooks/pre-commit -
Tell git to use the folder. Each person runs this command once in their own clone, because git doesn't share the setting:
git config core.hooksPath .githooks -
Commit the
.githooks/pre-commitfile.
Run the check in pull requests
A check in continuous integration keeps a failing document off the main branch. The following GitHub Actions workflow runs the check on every pull request, and on every push to the main branch:
name: check
on:
pull_request:
push:
branches: [main]
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/setup-node@v7
with:
node-version: 22
- run: npx -y @push-based/reasonry@2 check --strict
The workflow fetches the full history, because the check reads git to learn when each document
last changed. If the knowledge base still has warnings, leave out --strict until the team fixes
them.
Make a change on a branch
Keep one piece of work on one branch: one intake, one decision, or one review pass.
- Pull the main branch, and create a branch from it. A branch that starts from the current main branch lowers the chance that two people take the same document ID.
- Do the work with the skill for the task.
- Run the check: see Run the check before a commit.
- Commit, push, and open a pull request.
- Merge the pull request. Don't leave it open for days: the longer a branch stays open, the more likely it is that another branch takes the same document ID.
Review a pull request
The check covers the form of the documents, not what they say. As a reviewer, read these points yourself:
- For a decision that the pull request accepts, read the
## Challengesection. The section lists each finding of the challenge gate and the answer that a person gave. If the section is missing, someone accepted the decision without the gate. - For a status change, confirm that the document says why. A superseded document names its successor or carries a banner with the reason, and a rejected decision gives the reason in its Context section.
- For documents from intake, read them against the writing rules in the knowledge base's
AGENTS.mdfile, such as the preset's rule that a document names roles and teams, not people. - For every change, confirm that the check passes.
Resolve two documents with the same ID
The engine gives a document the next free number in its initiative. If two branches each create a
document of the same type, both take the same number. After the second merge, the check fails with
a Duplicate id error for each of the two files. The following output comes from a copy of
Reasonry's test knowledge base in which two files carry the ID DEC-VT-0008:
source errors:
- DEC-VT-0008: Duplicate id "DEC-VT-0008" — also declared by: source/initiatives/test-initiative/decisions/DEC-VT-0008-run-line-4-on-sundays.md
- DEC-VT-0008: Duplicate id "DEC-VT-0008" — also declared by: source/initiatives/test-initiative/decisions/DEC-VT-0008-build-a-second-depot-at-westbrook.md
To fix the collision on the branch that merges second, follow these steps:
- Merge the main branch into your branch.
- Choose the next free number for your document: one more than the highest number of that type in the initiative.
- Change the
idfield and the first-level heading of your document, and rename the file so that its name starts with the changed ID. - Replace the earlier ID in every document that your branch wrote: in the
links,resolves,succeeded_by, andrefined_byfields and in the text. - If git tracks
graph.json, rebuild the graph. - Run the check.
Keep the graph current
The graph.json file in the knowledge base's folder lists the documents and the links between
them. The engine generates the file, the skills rebuild it after each change, and every rebuild
changes it. Choose one of two ways to handle the file:
-
Track the file in git. The check then fails when the file doesn't match the documents, and adds a line such as this one:
[FAIL] graph tracked, stale: 3 file(s) changed since it was builtTwo branches also conflict in a tracked file, and the check fails after a merge until someone rebuilds the graph. To fix the failure, and after each merge, rebuild the graph and commit the result:
npx -y @push-based/reasonry@2 graph build -
Ignore the file. Add
graph.jsonto the.gitignorefile. The skills rebuild the graph when they need it, and the check skips the file. If git already tracks the file, also stop tracking it with the following command, which keeps the file on disk:git rm --cached graph.json
If several people change the knowledge base, ignore the file.
Check part of the knowledge base
To run one area of the check, use validate with a target. The targets are source, wiki,
xrefs, initiative, and all:
npx -y @push-based/reasonry@2 validate --target=wiki
To check only the files that you changed and haven't committed, use --files. This form runs the
source and wiki areas on those files and skips the references between documents. It prints
nothing when the files pass:
npx -y @push-based/reasonry@2 validate --files
To check specific files, add their paths after --files. The command exits with 0 even when it
reports an error. To get a failing exit status, add --strict.
See the configuration that the engine reads
To print the configuration as the engine reads it, run compile:
npx -y @push-based/reasonry@2 compile
The command prints JSON with two keys: config, which holds the content of the
reasonry.config.json file, and initiatives, which lists the initiatives. To add the content of
one initiative's initiative.json file under a third key, manifest, add --initiative=SLUG.
Replace SLUG with the name of the initiative's folder.
If the engine refuses the configuration, the command names the file and the field instead:
reasonry: /path/to/team-knowledge/reasonry.config.json is invalid:
types.decision.folder: Invalid input: expected string, received number
View the graph and the status board
To look at the knowledge base in a browser, start the viewer in the knowledge base's folder:
npx -y @push-based/reasonry@2 viz
The command prints the address of each page, and runs until you press Ctrl+C:
reasonry viz: http://127.0.0.1:3000/ (graph) · http://127.0.0.1:3000/board.html (board)
reasonry viz: serving 37 git-visible files under /files/ and the page data; loopback only; Ctrl+C to stop
The graph page shows the documents and the links between them. The board has a tab for each document type and a column for each status.
The viewer has these limits:
- The viewer needs a git repository. In a folder that git doesn't manage, the command ends with an error.
- The viewer leaves out the files that git ignores, so a document in a file that
.gitignoreexcludes doesn't appear. - The viewer listens on
127.0.0.1only, so no other machine can open the pages. The port is3000. To use another port, add--port=PORT. - The viewer reads the knowledge base when it starts. To see a change, restart the viewer.
- The pages load their libraries and fonts from the internet, so the browser needs a network connection.
Agree on the team's rules
Reasonry leaves these choices to the team. Decide them, and write them in the "Local rules" section
of the knowledge base's AGENTS.md file, so that every agent follows them:
- Who accepts a decision. The engine records an acceptance and doesn't check who gave it. The
ownersandreviewersfields of a document carry team names, and a team can require that someone from the owning team answers the challenge gate. - Whether the team accepts a decision before the pull request or during its review. If the review decides, open the pull request with the decision as a draft, and accept the decision on the branch after the discussion.
- Who runs the review pass, how often, and where the team records the date of each pass. The following pass needs that date.
- Who handles the reports that agents in other repositories file.
- Whether the team commits raw material, such as a transcript. Intake deletes a transcript after you confirm, and keeps its analysis.