for agents/docs/llms.txtv0.6.75 · 6 Oct 2026

Home / Briefs / Code review graphs in the repository

Code review graphs in the repository: a build brief for secrets.sgit.ai, and for every agent that writes code

A build brief from the sgit.ai site team, written to be executed. Status: ready to build; nothing in it exists yet as a whole. Written 6 October 2026 from a voice memo, for the SGit-AI__Website__Secrets repository first and for every repository an agent writes code in after that. It turns the two code review articles into a thing a repository carries: a folder of layered graphs, regenerated on every change, with a navigator, built as web components in the house style, that lets a person walk from a user story to a source line and back. The code review articles said the review itself, the thing that sits on a change and shows it at every layer, did not exist. This is the requirement for it.

Revised the same day it was published, after the author read it: the intent layers are written by a person or an agent, since the first draft of most briefs here is an agent's transcription of a voice memo; and the navigator is no longer one self-contained HTML file but a set of web components in the shape coding.sgit.ai documents, one visualiser per file shape, with a first proposal for its layout in section 7. The reasons are given where the changes are.

How to use this brief. Read it once, then work through section 10 in order; each step ends with a release and an entry in the project's reality file. Where it says PROPOSED or VERIFY FIRST, test before building on it. Where you find it wrong, write what you found in review/BRIEF-CORRECTIONS.md and carry on; this brief will be corrected from that file. The worked example behind it is the Code Review Graphs vault, whose scripts and file shapes you may lift wholesale; the argument behind it is in Code review as a fractal semantic graph and If somebody built a company on code review. The lesson of the evidence vault, that a hash router is dead inside the vault host, is in the vault-app guidance and applies to the navigator this brief asks for. The code style the navigator must follow is the one coding.sgit.ai measured out of the estate's own code, on its JavaScript, HTML and CSS pages. What every sgit repository carries regardless of what it is for, this folder among it, is on the repository guidance page.
The review folder a repository carries: one grammar, two directions, two review sets. Not a vault and not a service.

1. What this is

A folder, review/, at the root of the repository, that holds the project as layered graphs: what the software is meant to do, written top down from the brief as stories with their rules and examples, flows, components and the deploy shape; what the code actually is, derived bottom up from the syntax tree as files, methods and their calls, classes, modules, the surfaces the code exposes, the tests and the deploy; the join between the two; every commit read upwards to the stories it can reach; the code on one path as method streams; the house rules as queries over the graph with their results; and a navigator, a set of web components with one visualiser per file shape, that lets a person move through all of it down to the source lines, with no server, no framework and no build step.

It is a folder and not a vault because it travels with the code, is diffed with the code, is reviewed with the code and is regenerated by the pipeline that ships the code. A vault is how a snapshot of it is published to someone who does not hold the repository, and the Code Review Graphs vault shows that already. Nothing in this brief needs a vault to work.

It is regenerated, never hand-maintained, with two exceptions that are marked as such: the intent layers, which a person or an agent writes from the brief and a person accepts, and the proposals a model makes about things a parser cannot see, which carry "proposed": true until a person or a run confirms them.

2. Two modes, one folder

New projects start at full coverage. A project that begins after this brief, and secrets.sgit.ai is the first, writes review/intent/ from its brief before the first source file exists, and builds the derived layers for every file on every release from the first release. There is no period in which the code outruns the graph. The coverage figure, the share of projected nodes with a derived match beneath them, starts near zero because there is no code, and the point of the first weeks is to watch it climb. By the first customer-facing release, every story in the intent file has a derived path under it or an entry saying why not.

Existing projects start from the change. A repository with history, this site's and the sgit CLI's among them, does not begin by mapping everything. It begins with the next commit: derive the layers for the files that commit touched and for what they reach, write the change file, and stop. The next commit extends the graph a little further. The graph grows along the paths people actually walk, which are the paths worth having, and the first slice is dear while every later one is cheaper. A full derivation may be run when it is cheap, and for a repository the size of the sgit CLI it is cheap, forty seconds in the worked example, but it is never required for the review of a change to proceed.

In both modes the unit of review is the change, and the question the folder answers about a change is the same: which layers moved, which held, what the moved ones can reach, whether what the author said about the change matches what the graph shows, and which stories the change serves or breaks.

3. The grammar

One grammar at every layer, so that one page and one set of tools serve all of them. The grammar is the one at graphs.sgit.ai and in the fractal semantic graphs article: a node has a type and a name within a layer that owns the types; an edge is a verb with a named inverse; properties carry data, never meaning; zooming into a node enters a graph with its own ontology joined to the one above by a named edge. The layers this brief names are a starting set, and the project may add or rename them; the grammar may not change.

Every node carries its source: {"path": "…", "line": n, "end": n, "sha256": "…"} for anything derived from a file, and {"doc": "…", "section": "…"} for anything projected from a brief. That is what lets the page show the lines. Every derived file carries its provenance: the tool and version that wrote it, the commit it was derived from, the time, and the inputs' hashes, so that a reader can tell a fresh graph from a stale one and the build can refuse a stale one.

Node identifiers are stable across regenerations: a method is module.Class.method, a story is a slug of its title, a component is the name the brief gives it. Renames are recorded in the change file as a move, not as a delete and an add, where the fingerprint of the body is unchanged.

4. The folder

review/
  README.md                 what this is, the coverage figure, how to regenerate, how to read
  BRIEF-CORRECTIONS.md      where this brief was wrong and what was done instead
  intent/                   projected, top down, from the brief; written by people, marked as such
    stories.json            story > rules > examples; each example names the surface it will touch
    flows.json              the user and agent journeys the brief describes, as ordered steps
    components.json         the architecture as the brief draws it, as far down as design can see
    deploy.json             environments, pipelines, buckets, roles, as the brief specifies them
  graph/                    derived, bottom up, from the code; regenerated, never edited
    files.json              every source file: path, hash, language, size, syntax summary
    methods.json            methods and functions: signature, lines, fingerprint, resolved calls
    classes.json            classes and types: fields, methods, bases, the classes they hold
    modules.json            modules and packages: imports, exports, the architecture as built
    surfaces.json           what the code exposes: pages, routes, commands, public functions
    tests.json              test files, the units they import, the examples they satisfy
    deploy.json             what the pipeline and infrastructure files actually declare
    stories.json            proposed by a model from surfaces and tests, every node "proposed"
  join/
    matches.json            projected node to derived node, with how the match was made
    gaps.json               derived-not-projected and projected-not-derived, each a finding
  changes/
    <hash>.json             one commit read upwards: layers moved and held, reach, claim vs evidence
  streams/
    <entry>.json            the code on one path from an entry point, to a depth
  checks/
    rules.json              the house rules as queries over the graph
    results.json            each rule's violations and the count checked, per commit
  ui/                       the navigator: web components in the coding.sgit.ai shape; no framework, no build step
    README.md               which component renders which file shape, one to one
    index.html              the shell: loads the tokens and the components, holds the layout, nothing else
    tokens.css              the design tokens; the only file under ui/ where a colour is written
    components/
      review-base/          the base component the others extend: self-locating, loads its .html and
                            .css, reads a JSON file with the bundle as fallback, holds the route, emits events
      review-ladder/        the layers as a rail with counts; red where a selected change moved them
        review-ladder.js    behaviour
        review-ladder.html  markup, a fragment
        review-ladder.css   styles, tokens only
      review-tree/          story > rule > example, and module > class > method; one component, both shapes
      review-node/          one node: name, type, layer, source link, properties, edges in and out
      review-source/        code with line numbers, the node's lines marked, a change's lines highlighted
      review-reach/         who reaches this: callers, surfaces, flows, stories, by hop, with counts
      review-change/        one commit read upwards, from changes/<hash>.json
      review-join/          matched, derived only, projected only, and the coverage figure
      review-stream/        the code on one path in call order, from streams/<entry>.json
      review-checks/        rules, violations, trend; a violation opens its node
      review-search/        find a node by name across layers
      review-crumb/         the path walked so far, each step a way back
      review-set/           the switch between review/ and review/self/
  tools/
    derive.py               files, methods, classes, modules, surfaces, tests, deploy from the tree
    derive_js.py            the same file shapes for JavaScript and HTML, the first new parser
    join.py                 intent against graph
    change.py               one commit read upwards
    stream.py               a method stream from an entry point
    check.py                rules over the graph
    bundle.py               inlines ui/ and the data into dist/index.html for the vault host; the source stays split
    freshness.py            fails when review/ is older than the code it describes
  self/                     the same folder, for the code in review/tools and review/ui

The vault's scripts, analyse.py, delta.py and stream.py, are the first versions of derive.py, change.py and stream.py for Python. They are published in the vault and may be lifted. Languages other than Python need their own parser behind the same file shapes; JavaScript is the first the secrets project needs, and a parser that produces methods.json for it is the first new piece of tooling in this brief.

5. The intent layers, and who writes them

A person or an agent writes intent/, from the brief, before the code. In practice the first draft is usually an agent's: the brief itself is often an agent's transcription of a voice memo, and the same session can turn it into nodes. What makes it intent rather than a proposal is that a person reads it back as a graph and accepts it, and each node records who wrote it and who accepted it. It is written in the shape Example Mapping gave the top of the ladder: a story is a node whose children are rules, each rule a node whose children are examples, and an example is the smallest thing a test or a recorded run can satisfy. Each example names the surface it expects to touch, a page, a route, a command, a function, in the words the brief uses, which is how the join finds it later. Flows are ordered steps that name the surfaces they pass through. Components are the boxes the brief draws, with the edges the brief draws between them, and with "honest_depth" set where design stops seeing and wishful thinking would start. The deploy file says which environments exist, what runs in each, and what reaches what.

For secrets.sgit.ai the intent is already written, as prose, in the MVP build brief: the components in its section 3.1, the flows in 3.2, the pages and their checks in section 6, the keyring specification in section 8, the environments in section 4 and the pipeline in section 9. The first task, an agent's, is to turn that prose into intent/ without adding anything, with each node carrying the section it came from, so that the person who commissioned the brief can read it back as a graph and correct it before any code exists. That is the review the author of this brief wants to do first: read the design as a navigable graph, find the places where the brief has a component with nothing under it or a flow that touches a surface no component provides, and decide.

A node an agent writes from the brief at the person's request, and the person accepts, is intent. A node a model adds on its own, from the brief or later from the code, is a proposal, and every one it proposes is marked "proposed": true with the model, the prompt and the date until a person accepts it, at which point the mark is replaced by who accepted it and when. The page shows proposed nodes in a different colour. A proposed node never counts towards coverage.

6. The change file

Every commit that touches source produces review/changes/<hash>.json, written by change.py before the commit lands, with: the files touched and their hashes before and after; for each layer, the nodes added, removed, changed and moved, with signature changes called out; the reach, computed by climbing the call graph and the surface map from the changed methods to the surfaces and the stories, with dynamic dispatch resolved through base classes as the worked example does; the claim, taken from the commit message's first word or a Kind: trailer, fix, feature or refactor; the evidence for or against the claim, in the terms the second article set out, which layer the author says was held and whether it held; the tests added or changed and which examples they satisfy; and the checks, which rules now fail that did not and which pass that did not. The commit message links the file, and the pull request, where there is one, embeds the one-line-per-layer summary.

The report is one line per layer that moved and nothing for the layers that did not. A refactor that holds the class shapes reports two lines and a held-as-claimed; a fix reports the layers it climbed to the story that now holds and whether a test was added; a change that reached a layer its description did not mention reports that layer in a different colour.

7. The navigator: components, one per file shape

Not one file. The first draft of this brief asked for a single self-contained HTML page with inline CSS and JavaScript. That is the wrong shape for code that is to be reviewed by the same standard as the project. A four-thousand-line file has one node in methods.json worth the name, no classes, no module boundary and no call graph a reviewer can walk, so review/self/ would have almost nothing to show, and the tool would fail its own test on the first day. The vault apps this site has published so far are built that way, and the evidence vault's dead router is the kind of defect that shape hides.

The shape it takes instead is the one coding.sgit.ai counted out of the estate's own fifty JavaScript files and wrote down: native web components, no framework, no bundler, no build step; every component exactly three files with the same basename in its own directory, .js for behaviour, .html for markup as a fragment, .css for styles; a base component that supplies the lifecycle, so a component sets static jsUrl = import.meta.url to locate itself, names its resourceName and sharedCssPaths, and overrides onReady() rather than connectedCallback; events namespaced and dispatched through document with bubbles and composed set; state as underscore-prefixed instance fields; frozen, centralised constants. The HTML half follows the HTML page: semantic elements, ARIA on every control, data-* for behaviour and classes for styling, never mixed. The CSS half follows the CSS page: :host first, every colour a token from tokens.css and none written anywhere else, per-block alignment, no BEM because shadow DOM removes the problem it solved. The base component here is review-base, written on the pattern of the tools' SgComponent; whether it imports that class or is a sibling of it is the first entry for the corrections file, because the import would be the one external dependency in the folder.

One visualiser per file shape. The folder's JSON files are only as useful as the ways to look at them, so the rule is one to one and written down in ui/README.md: intent/stories.json and the derived trees render in review-tree; a node of any layer in review-node, with its lines in review-source; changes/<hash>.json in review-change; join/ in review-join; streams/ in review-stream; checks/ in review-checks; the layer counts in review-ladder. A new file shape in the folder is not finished until it has a component, and a component is not finished until review/self/ shows its methods and the change that added it.

The base component, review-base, is where the things every visualiser needs live once: reading a JSON file by path with the inlined bundle as fallback; resolving a node identifier to its layer, file and record; the event bus, review:select for a node, review:route for a view, review:set for the switch between the project and the tool; the route held in a variable and the hash touched only when the shell runs on its own, because inside the vault host a hash router is dead, the evidence vault shipped with that bug and this navigator does not; and the source resolver that opens a file at a range of lines. index.html is the only HTML document in the folder. It loads tokens.css and the components, lays them out, shows the version in its top bar as the vault guidance requires, and does nothing else.

A first proposal for the navigator's layout. Each region is one component; the names in the corners are the component names in section 4. The content is illustrative.

A first proposal for what it looks like. Five regions, each a component or a short stack of them, laid out by the shell:

The layout is a proposal and the component boundaries are the requirement. A project may lay the regions out differently; it may not merge two components into one because it was quicker, and it may not add a visualiser outside components/.

Where this goes next. The components carry nothing that belongs to one project. The file shapes are the folder's, the colours are in tokens.css, and the data is read by path. They are written so that they can be lifted into a repository of their own and served from a versioned path in the way the tools components are, components/<name>/v1/v1.0/v1.0.0/, with every review/ folder importing them at a pinned version, and that is the intended end state: a separate project, reviewed by its own review/ folder, that every other project's navigator is made of. For now they live in review/ui/components/ so that the first project can build them, review them and find out what they need to be. The cut to a separate repository is a step in the build order, not a decision to take now.

Where it runs. From the repository on a local static server; from GitHub Pages at /review/ when the project publishes it; and inside a vault when the folder is published as one, for which bundle.py inlines the components and the data into dist/index.html while the source stays split. Every link in every component is marked native and routes through the base component, so the same code works in all three places.

What a person can do on it, and the acceptance test for each:

The navigator is read-only. It never writes to the repository; acceptance of a proposed node is done by a script that edits the JSON and is committed like any other change, so that the graph's history is the repository's history.

8. The engineering standard for the tool

The code in review/tools and review/ui is as critical as the code it reviews, because a review tool that is wrong is worse than none: it produces confidence. It is therefore held to the same standard as the project, and in a project without a third-party review tool that standard is applied by the tool to itself.

9. The workflow, per change

  1. Before writing code, the agent reads the intent nodes the change serves and names them in the plan.
  2. After the code, before the commit, the agent runs derive.py --changed, join.py, change.py and check.py, and reads the change file it produced. If the reach includes a surface or story the plan did not name, the agent says so in the commit message and, if it was not intended, fixes the code first.
  3. The commit message carries the claim in its first word and a link to the change file. Where a layer was held, it says which.
  4. The pipeline's validate step runs freshness.py and the schema checks and fails on a stale or malformed folder.
  5. The person reviewing opens the page on the change, reads it upwards, and accepts or sends it back. Corrections that become rules are added to checks/rules.json in the same commit as the fix.
  6. Every release updates README.md with the coverage figure, the count of change files, the open gaps and the open proposals.

10. Build order

StepDeliverableDone when
0review/ skeleton, the schemas as JSON Schema files in tools/schemas/, the fixture repository, freshness.py wired into validate.The build fails on a stale folder and passes on a fresh empty one.
1intent/ for secrets.sgit.ai, from the MVP brief, every node carrying its section; the shell, tokens.css, review-base, review-tree, review-node and review-crumb, enough to walk the intent.The person who commissioned the brief has walked it as a graph and recorded corrections in BRIEF-CORRECTIONS.md.
2derive.py for Python lifted from the vault; derive_js.py for the components; review/self/ built for the tools and the components; review-set and review-ladder.The tool reviews itself; both sets open in the navigator; each component appears in the self set's tree.
3derive_js.py extended to the secrets site's pages and routes as surfaces; graph/ for the site as it exists at that step; review-join.Coverage figure appears on the README and in the join view, from the same script.
4change.py, review-change, the moved-layer marking on the ladder and the bottom strip; every commit from here on carries a change file.A commit read upwards renders with no network; the claim-versus-evidence line is right for a fix and for a refactor fixture.
5stream.py, review-source, review-reach and review-stream: the walk down to source lines with highlighting and the walk up with hop counts.Story to line in six clicks; method to its stories in two.
6check.py with the project's house rules as queries, including the coding.sgit.ai rules for the components; review-checks with trend.Every rule in the project's guidance has a query or an entry saying why it cannot have one; the self set's checks are green.
7bundle.py producing dist/index.html; the folder published once as a vault with a read key, as the Code Review Graphs vault was, and linked from the project's site.The navigator runs identically in the repo, on Pages and in the vault host.
8The delta-first mode applied to this site's repository and the sgit CLI's, starting from their next commit.Each has a review/ with at least one change file and a growing graph; the CLI's matches the published vault for the commit it covers.
9The components lifted into a repository of their own, served from a versioned path, with their own review/; the first two projects import them at a pinned version.Both projects' navigators run from the shared components with no local copy, and the components' own self set is green.

11. What not to do

12. Open questions, to be answered in the corrections file

13. The prompt to start with

You are working in the repository for secrets.sgit.ai, which carries a review/ folder as specified in
https://sgit.ai/docs/briefs/code-review-graphs-in-the-repository.html. Read that brief, then the MVP
build brief in docs/design/. Work through the brief's section 10 in order, starting at step 0. Rules
never to break: derived files come from parsers, never from you; every node carries its source;
the same inputs produce byte-identical files; review/self/ is built and green before any release;
the navigator is web components in the shape coding.sgit.ai documents, three files each on one
base component, one visualiser per file shape, no framework, no build step, colours only in
tokens.css, and it never assigns location.hash. Lift the vault's scripts where they fit and say
where you changed them. When the brief is wrong, write what you found in review/BRIEF-CORRECTIONS.md
and carry on. Step 1 is yours to draft and a person's to accept: turn the MVP brief into intent/
without adding anything, each node carrying its section, and stop for review.

Written 6 October 2026 by the sgit.ai site team from a voice memo, and revised the same day from a second one. Companion material: the two code review articles, the Code Review Graphs vault and its scripts, the vault-app guidance, and the secrets.sgit.ai design pack. Published under CC BY 4.0; to be corrected from the corrections file of the first repository that builds it.