Skip to content

Latest commit

 

History

History
105 lines (88 loc) · 6.67 KB

README.md

File metadata and controls

105 lines (88 loc) · 6.67 KB

Knowledge graph

graph.json is a machine-readable map of the published part of this knowledge base, built around concepts a reader recognizes: guides, the techniques they document, investigations (case studies), the symptoms INDEX.md routes to them, and the projects whose commits they draw on. Commits are kept as evidence. Every edge names the file and line it came from.

Markdown is the source of truth. The graph is generated from it by general/tools/kg_build.py (Python 3.9+, standard library only); never edit graph.json or graph.meta.json by hand.

Schema 2

Every name and every relationship comes from the text of an included document. Nothing is guessed.

Nodes (kind). Each one has label (the full readable title) and short (the graph label).

Kind What it is
guide An included document that isn't a case study
investigation A document whose own structure marks it as a case. Either its H1 starts with Case: (case_signal: "h1"), or it has a Symptoms H2 and a Root cause or Fix H2 (case_signal: "sections")
technique An H2 section of a guide. href is the section's GitHub anchor; status is set only when the heading ends in a status parenthetical ((VERIFIED, …), (method), (note), …), which is then dropped from label
symptom A row of INDEX.md whose targets include an included document
project A project named in a citation, such as ReCarbon 540970f
commit A cited commit. advanced: true: evidence, not a primary concept

Some H2s are not techniques:

  • the case structure of CONTRIBUTING.md (Symptoms, Evidence, Root cause, Fix, Regression tests or guard, Verification, Limitations, Failed hypotheses, Source commits), even in a guide. They are parts of one investigation, not concepts you can reuse on their own;
  • numbered steps (## 3. Recompile). They are ordered steps of one procedure, and the guide itself stands for the procedure. So general/bring-up-checklist.md is a guide with no techniques.

Anchors follow GitHub's rules (github-slugger): the heading's rendered text in lower case, with every character except letters, digits, _, - and spaces dropped and each space turned into - (so A: b / c gives a-b--c). A repeated slug gets -1, -2, … in document order. The anchor uses the full heading, status included.

short drops a leading Case: (and capitalizes the next letter) and any trailing parentheticals, then cuts the text to at most 32 characters at a word boundary and adds …. It stays a prefix of the corpus text, so the leak check can verify it.

Edges (relation). Each one has label and inverse (from the fixed vocabulary in config.json, which the build refuses if a label claims a cause or a fix), evidence [{file, line}] and weight.

Relation From → to Confidence Evidence
documents guide → technique EXTRACTED The heading line
answered_by symptom → guide or investigation ("is documented in" / "is investigated in") EXTRACTED The INDEX.md row
references document → document EXTRACTED The line with the link or path
draws_on technique, investigation or guide → project, with commits EXTRACTED The citation line
shares_evidence two nodes that cite the same commit, with commits DERIVED Both citation lines (side: source or target)
cites technique, investigation or guide → commit (advanced) EXTRACTED The citation line
in_project commit → project (advanced) EXTRACTED The citation line

A citation belongs to the technique whose section it's in. Otherwise it belongs to the document (an investigation, or a guide's introduction).

shares_evidence is DERIVED: no document states it, but two extracted citations of the same commit imply it. It means only "cites the same evidence as". It doesn't mean that one topic causes, explains or is the same as the other. There is one edge per pair (source < target), and never a self-edge.

Files

File Purpose
allowlist include / exclude per Markdown file. Only included files are read
config.json Graph version, document base URL, projects (whether their commits are public), areas, relation labels
inferred.json Reviewed inferred relationships. Empty in production
graph.json The generated graph: sorted, no timestamps, no absolute paths
graph.meta.json Schema, version, the sha256 of graph.json, and counts (per node kind, relation and confidence)

Commands (from the repository root)

python3 -I general/tools/kg_build.py --out knowledge-graph/graph.json --meta knowledge-graph/graph.meta.json
python3 -I general/tools/kg_build.py --verify
python3 -I general/tools/kg_build.py --check knowledge-graph/graph.json
python3 -I general/tools/test_kg_build.py

Exit codes: 0 ok, 2 refused (allowlist or input), 3 leak check failed, 4 committed files stale. --verify rebuilds in memory and fails unless graph.json and graph.meta.json match the fresh build byte for byte and the recorded sha256 matches graph.json. CI runs it on every push.

Adding a document

  1. Every new Markdown file needs an allowlist line, or the build fails (fail closed). Add it as exclude by default.
  2. Change it to include only after it passes the review in CONTRIBUTING.md as public-safe: no private content, legal notes, host names, absolute paths, credentials or game file names.
  3. Rebuild, bump the version, run the tests, and commit the Markdown, the allowlist and both generated files together.

A reference to an excluded document is counted (dropped_references) but never named.

The leak check accepts only schema words, configured URLs and labels, ids and anchors built from included paths, and text from included documents (a short label may end in …). Nothing may match the denylist (paths, emails, host names, legal terms, credentials, game file names).

Inferred relationships

inferred.json holds relationships no document states. The production build doesn't use them: they're added only with --with-inferred. Each entry needs a genuine maintainer review: source and target (included documents), relation (related_to or same_pattern_as), rationale, reviewed_by and reviewed_on. Unreviewed or unknown entries make the build fail. Never commit placeholder or example entries.

Version

version in config.json, copied into graph.meta.json (semantic versioning):

  • patch: content-only changes in included documents;
  • minor: a document added to (or removed from) the graph;
  • major: a change to the graph schema (schema in graph.json). Schema 2, the concept-centric model above, is version 2.0.0.