Dashboards report drift. Repository guards can stop structural drift from merging.
Codee3 turns structural repository-knowledge rules into local CI gates instead of remote dashboard scores. The checks are zero-dependency Node scripts. They run on your machine, exit non-zero on violation, and can be placed in any CI system that respects an exit code.
Scope, stated first. These checks read the governed .ai/ directory and check its structure. They do not read your source tree, do not evaluate whether a sentence is true, and do not observe anything at runtime.
A structural violation, from commit to green
Five steps at your pace. The change is reasonable, the failure is specific, the correction is named rather than guessed, and the record of what happened ends up in the ledger instead of in a filename.
Everything shown is the real output shape of check:no-versioning and its real remedy line — rendered as text, never as a screenshot.
- .ai/domains/payments/architecture-v2.md
- .ai/domains/payments/00_INDEX.md
- A new architecture document lands beside the existing one. The index is updated to point at it. Reviewed, approved, entirely reasonable.
Step 1 of 5
5 checks, each enforcing one invariant
Each guard is a zero-dependency Node script wired into package.json. It runs locally, prints what it found, and exits non-zero when the invariant is violated — which is what lets any CI system fail the build on it.
- Checks
- Governed document and reference names for version-suffix patterns — `v2`, `mk2`, `FooV2`, `api-v2` and equivalents.
- Exits non-zero when
- A versioned name appears anywhere inside the governed brain.
- Scope · will not look outside this
- The governed `.ai/` directory only. It will not fail your build over `apiV2Client.ts` in application source — Codee3 imposes no naming policy on your code.
- Why it is worth a gate
- A version suffix declares a successor and forks truth. Once two documents both claim to describe the same concept, every reference becomes ambiguous and every reader has to work out which one governs.
Implements: Every concept has exactly one timeless identity
- Checks
- That every folder holding governed documents has an index, and that no two siblings share an ordering prefix. Warns when an index declares no Authority-Class.
- Exits non-zero when
- A document-bearing folder has no index, or two siblings share an ordering prefix.
- Scope · will not look outside this
- The governed `.ai/` directory.
- Why it is worth a gate
- Index-first navigation is the mechanism that keeps the loaded set small. A folder with no index cannot be entered through an index, so its contents are unreachable by the intended discipline. Duplicate ordering prefixes make routing non-deterministic.
Implements: Every folder holding governed documents has an index; structural ordering is unambiguous
- Checks
- That the skill-routing contract is valid and internally consistent.
- Exits non-zero when
- The routing contract is malformed or inconsistent.
- Scope · will not look outside this
- The governed routing configuration.
- Why it is worth a gate
- Routing that silently fails sends work to the wrong place, or nowhere. A malformed contract is better caught at merge than discovered during a session.
Implements: All agent surfaces route to one governed source
- Checks
- A registry declaring each canonical fact, its path and its rename history, against every mention of those facts across the governed corpus.
- Exits non-zero when
- A retired name still has surviving mentions after a rename — the reference-drift condition.
- Scope · will not look outside this
- The governed `.ai/` directory and its registry.
- Why it is worth a gate
- A reference that no longer resolves is a silent lie. Renames are the most common way a governed corpus quietly breaks, because the rename succeeds and the stale mentions stay behind looking perfectly valid.
Implements: Every reference to a governed fact resolves
- Checks
- The decisions ledger itself, and whether what each agent surface presents as a decision still matches it.
- Exits non-zero when
- The ledger is missing, unreadable, truncated, or carries two records under one id; or a surface presents an authority-shaped line that is in no ledger, or shows superseded text as current.
- Scope · will not look outside this
- The governed `.ai/DECISIONS-LEDGER.md` and the agent-surface blocks that quote it.
- Why it is worth a gate
- The record is the one asset the product exists to protect. The other guards can pass while the ledger is silently deleted, contradicted, or misquoted into every agent surface — this is the guard that fails closed over that.
Implements: What agents read as a decision matches the record, and the record is intact
What the reference registry is for
Given a canonical fact, returns every governed document that references it. Run it before a rename so the whole fan-out is fixed in one pass, rather than discovering the stragglers when the reference guard fails.
$ npm run brain:refs:radius -- payments-providerA rename that misses one document leaves a reference that no longer resolves. Running brain:refs:radius before the rename lists the whole fan-out; brain:check:references fails the build if one is missed.
check:no-versioning FAILED — 3 versioned reference(s) in .ai: .ai/domains/payments/00_INDEX.md:1 [v<n>] v2 .ai/domains/payments/00_INDEX.md:5 [<name>-v<n>] i-v2The brain owns change — rename to a timeless name; record evolution in the changelog. Codee3 · Your Repository Brain A living project brain your AI agents can use — regenerated from your repository, owns nothing. ────────────────────────────────────────────────────────────────────────── ● HEALTHY — Your brain is in good shape; nothing needs attention. 9 documents tracked · 0 loose ends Brain health ✓ Every document's origin is tracked ✓ No contradictions left unresolved ✓ Generated summaries stay labelled and current ✓ No loose ends dropped silently ✓ Only the right files can define the truth What you own — active now ✓ Repository Intelligence your repository explains itself in one glance ✓ Brain health guards no-versioning, structure, skills routing, references & the decision record stay correct ✓ Agent adoption connect the brain to every AI tool you use ✓ Skills router route work to the right on-demand skill ✓ Reference blast-radius see what a change touches before you make it ✓ Brain version the kit release this brain is running ✓ Update check know when a newer kit release is available ✓ Upgrade the brain adopt a newer kit release non-destructively Also included — the full reference discipline (advanced, opt-in) · Advanced governance the full self-governing discipline — advanced, opt-in for teams that want it What needs attention ✓ Nothing. Your brain is healthy — every check is green. This is a read-only summary, generated fresh from your own files — not a second copy to maintain. Prefer machine-readable output? Run `npm run brain:status -- --json`. ✗ ACTION REQUIRED — 1 issue(s) to fix before relying on the brain. 12 documents tracked · 0 loose ends Brain health ✓ Every document's origin is tracked ✓ No contradictions left unresolved ✗ Generated summaries stay labelled and current — 1 to look at ✓ No loose ends dropped silently ✓ Only the right files can define the truth What needs attention ✗ Teach: projection carries no `Verified-At:` — its staleness is not detectableScaffolded scalable-brain filing system into /path/to/your/repo (brain kit v0.2.2) created (69): + .ai/00_NAVIGATION.md + .ai/CHANGELOG-DELTA.md + .ai/CURRENT-REALITY.md + .ai/DECISIONS-LEDGER.md + .ai/EXECUTION-QUEUE.md + .ai/PROJECT-BRAIN.md + .ai/domains/00_INDEX.md + .ai/domains/example/00_INDEX.md + .ai/domains/example/01_OVERVIEW.md + .cursor/rules/brain-routing.mdc + AGENTS.md + tools/brain/... (57 files: guards, engines, CLIs) wired into package.json: brain:status, brain:check:no-versioning, brain:check:structure, brain:check:skills-router, brain:check:references, brain:check:record, brain:check, brain:refs:radius, brain:adopt, brain:skills, brain:version, brain:check:updates, brain:upgrade agent tools detected: Cursor → connect the brain to them so it works no matter which one you run: `npm run brain:adopt` (preview — shows exactly what it would add) `npm run brain:adopt -- --apply` (wire them; only adds a removable redirect block)What these guards do not prove
The guards establish that the knowledge layer has not structurally broken. That is a narrower claim than it first sounds, and the difference is the whole reason to trust the rest of this page.
- Factual inaccuracy in prose
- The guards do not read a sentence and decide whether it is true. A governed document can pass every check and be entirely wrong.
- Semantic divergence between documentation and code
- Nothing compares the content of a document against the implementation it describes. Codee3 reads the governed Markdown, not your source tree.
- Runtime behaviour
- No part of the product observes a running system. These are file-structure checks executed at merge time.
- Production correctness or safety
- Passing guards do not indicate that a release is safe. They indicate that the knowledge layer has not structurally broken.
A passing brain:check means the structure holds: nothing is versioned, every folder is indexed, every reference resolves, routing is valid. It does not mean the contents are correct. Somebody still has to be right about the system, and write it down.
Local gate, not remote score
Codee3 turns structural repository-knowledge rules into local CI gates instead of remote dashboard scores. The difference is where the check runs and what happens when it fails.
| Dimension | Remote scheduled reporting | Local repository guards |
|---|---|---|
| Where the check runs | A vendor backend, on the vendor’s schedule | Your machine and your CI runner, on your commit |
| When you find out | When the dashboard next refreshes | Before the merge completes |
| What happens on violation | A score drops; a notification may be sent | A non-zero exit code, which fails the build if you wire it to |
| What the check needs | An account, an integration, and your repository contents transmitted | Node 18 or newer, and the files already in your working tree |
| Who owns the result | The vendor stores it | It is stdout and an exit code; nothing is transmitted |
This is a difference in architecture, not a claim that other products cannot fail a build. Plenty can — linters, static analysis, policy engines and PR gates all block merges every day. The distinction is what is being gated: those tools gate the code. These gate the structure of the repository’s own knowledge layer.
Wiring it in
# .github/workflows/brain.yml
name: brain
on: [push, pull_request]
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
# Non-zero exit fails the job. No account, no token, no network call.
- run: npm run brain:checkTurning it on without a big bang
The first run on an existing corpus usually finds things. A gate that blocks everybody on day one is a gate that gets removed in week two, so adoption is staged.
Run it locally
Run `brain:check` on the repository as it stands. The first run on an existing corpus usually finds things; none of it is blocking anyone yet.
Run it in CI, non-blocking
Add the job but let it report. The team sees what the guards catch before the guards can stop anyone merging.
Make it required
Once the corpus is clean and the team recognises the failures as fair, promote the job to a required check.