You are working on ripwire's own source. This file is the orientation an agent needs before it touches this repo; it is not a manual for using the tool.
ripwire is a zero-runtime-dependency C++23 CLI. It crawls a codebase, extracts symbols with
tree-sitter, resolves references into a call graph, ranks the graph with Personalized PageRank, and
streams a deterministic minified XML map to stdout. Around that core sits the verb catalog in
docs/COMMANDS.md — navigation, diff-awareness, quality, retrieval — and an MCP server so an agent
can call them mid-task.
| Question | File |
|---|---|
| What does the tool do? Which flag answers which question? | README.md, docs/COMMANDS.md, ./build/ripwire --help |
| How is it built internally? Pipeline, data model, determinism contract | docs/ARCHITECTURE.md |
| How is any published number measured? | docs/EVALS.md |
| Changing a DEFAULT, a legend, a ceiling or a cut? Read this first | docs/METHODOLOGY.md §9 — terminality is the objective, the ceiling is a constraint, honesty lives in attributes |
| C++ style, guardrails, gate discipline, submission checklist | CONTRIBUTING.md |
Index of everything under docs/ |
docs/README.md |
./build/ripwire --help is generated from the binary's own flag table and is always current. When
--help and a document disagree, --help wins and the document is a bug.
cmake -S . -B build && cmake --build build -j # dev build — no build type, deliberately
cmake -S . -B asan -DRIPWIRE_ASAN=ON && cmake --build asan -jDo not configure a local dev tree with -DCMAKE_BUILD_TYPE=Release. Release defines NDEBUG,
which compiles the DISCLOSE( msg ) trace out; any gate that asserts a degrade path then passes blind.
CI builds both flavours on purpose — Release catches optimizer-only bugs, the plain build catches
degrade paths. If you add a degrade path, the plain run is what proves it.
Never edit the tree while a build is running, and never background a build you then edit around. This is not a style preference — it silently produces a binary that cannot exist from any single commit, and it costs hours to diagnose because every symptom points somewhere else.
Make decides what to recompile by comparing mtimes. Header tracking is correct and complete (the
compiler writes real depfiles: build/CMakeFiles/ripwire.dir/src/ingest.cpp.o.d lists src/model.h
among ~1100 headers, and pagerank.cpp.o.d correctly lists none). But mtime ordering is only
meaningful if the sources hold still. If you edit src/model.h — or git checkout a branch that
does — while a build is in flight, that build writes .o files whose mtime is newer than the
header but whose content predates it. Make then correctly concludes "up to date" and never
recompiles them again. cmake --build build -j reports success, exit 0, no warnings, forever.
Three ways this was hit, all from building across (or editing under) a branch switch:
- A
cmake --build asanstarted on one branch and finished after agit checkoutto another that changedSymbol. Half the objects hadsizeof(Symbol)==96, half104. ASan reported a heap-buffer-overflow iningest— a real report, of a fake bug. The tell: the overflowing buffer was 1344 bytes = 14 × 96, an exact multiple of the previous struct size. If a sanitizer report's region size divides evenly by an oldsizeof, stop debugging and rebuild. src/quality.h'skIngestParserVerMirroredited while a clean rebuild ran. The binary kept emitting the old value through repeated successful rebuilds;qextractionkeycheckfailed withparserVer=41, expected 12/42and looked like a missed mirror update.touching the header fixed it, which is the diagnosis: the object was newer than the source it disagreed with.- The same
sizeof(Symbol)mix can surface as an uncaughtstd::length_error— SIGABRT withvector<unsigned int>::__appendin the stack, thrown from aresize( symbols.size() )deep iningest(triaged 2026-08-07:--quality-delta'scomputeHeadSnapshotre-ingest, ten identical reports in one morning of worktree churn). A.size()of avector<Symbol>whose element size half the objects disagree on is garbage; the resize that consumes it is just the first bounds check it fails. Zero repro in 38 runs on clean rebuilds of the same commit. If an "impossible" length_error/bad_alloc comes from a resize fed by.size()of a struct that changed size across a recent branch switch, rebuild--clean-firstbefore debugging the exception.
If sources may have moved under a build — after any branch switch, or if you are unsure — do not trust an incremental rebuild:
cmake --build build --clean-first -j # and the same for asan/ if that tree is in playtest/g1freshcheck.sh catches the ordinary stale binary (binary older than source) and is worth
believing when it fires — it is not noise. It cannot catch this variant, because here the binary is
newer than the source and only its contents are stale. Nothing in CMake can repair a source that
changed mid-compile; the discipline is the fix. When this variant is suspected, --doctor's layout
row reports the cross-translation-unit sizeof/alignof evidence; treat state="disagree" as a
clean-rebuild requirement. state="agree" compares only the types= registered in src/model.h; a
same-size layout change or a stale constant is invisible, so agree does not rule out a mixed binary.
./build/ripwire . --quality-delta --legend=compact # the "am I done" checkpoint — see the note below
python3 test/pargates.py . ./build/ripwire -j 6 # the full gate suite, in parallel
test/regression.sh # the same set, sequentially (authoritative list)
LSAN_OPTIONS=suppressions=lsan_suppressions.txt ./asan/ripwire <dir> >/dev/null
t=$(mktemp -d); ./build/ripwire <dir> >"$t/a"; ./build/ripwire <dir> >"$t/b"; diff -q "$t/a" "$t/b" # determinism gate (outputs outside <dir>)
./build/ripwire <dir> | xmllint --noout - # well-formedness gate--legend=compact on the checkpoint run is not cosmetic: on a clean report the legend is nearly the
whole document, and dropping it takes the run from 2,776 B to 454 B (measured 2026-09-10 on a
two-function fixture; 15,601 B to 8,775 B on this repo mid-change). The findings are byte-identical
either way — only the dictionary in front of them is shorter, and you already know it.
Run gates in the foreground. A new test/*check.sh must be listed in test/regression.sh in
the same commit — test/manifestcheck.sh fails otherwise.
- G1 — memory safety, adversarially verified.
-fsanitize=address,undefined,integer,float-divide-by-zero,float-cast-overflow -fno-sanitize-recover=all -O2 -g. The-fno-sanitize-recover=allis the linchpin: without it a run with undefined behavior still exits 0. LeakSanitizer uses the committedlsan_suppressions.txt(tree-sitter grammars never free their static parse tables). ThreadSanitizer is a separate, mutually exclusive target. - G2 — cache locality over abstraction. DOD, POD, SoA, 32-bit handles, no generic graph library. The no-allocation rule is scoped to our own code inside the PageRank power-iteration loop; tree-sitter allocates internally and is out of scope.
- G3 — one deterministic build step. CMake only, dependencies pinned and vendored, tree-sitter
linked statically, no host-installed dependencies, no OpenMP. "Self-contained", not "static" — a
fully static binary is impossible on macOS, so never pass
-static. Platforms: Unix/Linux/macOS first, native Windows second (clang-cl primary; MSVCcl.exemust also build). Acl.exeportability finding is worth fixing but does not block a POSIX-only code path. - G4 — maximum token density. Minified XML, no inter-tag whitespace, terse attributes. The legend is emitted
once per answer on the CLI (
--legend=full|compact) or once per session on agent surfaces (--legend=ref, served only after the session dictionary was delivered in that process; the answer then ends with<about … legend="ref" dict= dictv=/>). Every attribute a default answer emits is defined in that answer's own legend — gateslegendcoveragecheck(G) andcompactlegendcheck(UG); a ref answer carries the same attributes as its inline twin, and every definition it leans on is bytes that session was already sent or that the answer carries itself — gatelegendrefcheck. Output pipes clean throughxmllint --noout; no newline outside CDATA. - G5 — modular zero-dependency CLI. Hand-rolled argument parser; a flagless run is the core map; every flag is purely additive.
- Write the gate before the code it measures. A ranking, a token estimate, and a call graph all look plausible whether or not they are correct.
- Determinism is a contract, not a nicety. Crawl order is sorted before IDs are assigned; reductions use fixed block partials in canonical order; the PageRank translation unit is compiled without floating-point reassociation. Anything that makes output depend on thread timing is a bug even when the ranking still "looks right".
- Honesty in output is a feature. Counts that cannot be totals are labelled floors
(
counts_floor="1"); a zero means "none found", never "none exists"; every truncation is disclosed in the header. Do not add a surface that quietly rounds, guesses, or omits. - Never
ASSUME( false )(or anEXPECTS/ENSURESof false) on a degrade path. Release deletes the fallback behind it. Guard the path and disclose it:DISCLOSE( sink, why ), whose sink sets the output field the reader sees, orDISCLOSE( Diagnostics::answerUnchanged, "reason" )when the answer truly cannot change. A one-argumentDISCLOSE( msg )ships nothing and may not be added. External input isVALIDATEd, neverASSUMEd. - Never
std::map/std::unordered_map— see the container rule inCONTRIBUTING.md.
Allman braces, braces on every control-statement body (no braceless if( x ) f(); — inline
{ … } inside one-line lambdas), spaces inside parens (f( x )), ~160–200 column wraps, index-vs-count naming,
structured-binding returns, tolerance-band float tests. Output goes through rw::emitTo (src/infra/emit.h:
std::print, falling back to std::format+fputs by feature test, and --version says which as emit=) —
never a new printf-family call site; a not-yet-converted help/legend string is still a printf FORMAT, so a
literal % in it must be %%. The full rules — with the reasoning — are in
CONTRIBUTING.md §3. Read that before writing C++ here; it is self-contained.