How it uses Relate
Patch Precedent keeps its evidence in one embedded Relate store, data/precedent.rl, and asks every question of it in Cypher.
The store
2,557 nodes and 6,844 relationships in data/precedent.rl.
What it relies on
Embedded store
Single file, no server.
Cypher reads and writes
The store is built and queried with Cypher.
Parameter binding
Queries bind values such as $path and $key instead of splicing strings.
Read-only opens
The committed store is only ever opened read-only; each demo run writes its observations into a copy.
MCP server
The relate CLI's
serve --mcp stdio --read-onlyexposes raw Cypher over MCP.
The four queries
Decision chain for a file
Joins a file's curated citation to its decision, implementing commit and checks. Used by explain, demo and mcp.
MATCH (f:File {path: $path})-[c:CITES {curated: true}]->(d:Decision), (d)-[:CHECKED_BY]->(k:Check), (m:Commit)-[:IMPLEMENTS]->(d) RETURN f.path AS file, d.id AS decision, d.title AS title, d.status AS status, d.rule AS rule, d.reason AS reason, d.url AS decision_url, c.url AS citation_url, d.consequences_url AS consequences_url, m.sha AS implementation, m.subject AS commit_subject, m.url AS commit_url, k.name AS check, k.kind AS check_kind, k.number_at_pin AS check_number_at_pin, k.url AS check_url, k.evidence AS check_evidence
Every decision a file cites
Includes scanned, unreviewed citations that have no linked checks. Used by explain, demo and mcp.
MATCH (f:File {path: $path})-[c:CITES]->(d:Decision) OPTIONAL MATCH (d)-[:CHECKED_BY]->(k:Check) RETURN f.path AS file, d.id AS decision, d.title AS title, d.status AS status, d.url AS decision_url, c.url AS citation_url, c.curated AS curated, c.scanned AS scanned, count(CASE WHEN c.curated = true THEN k END) AS n_checks
Patch to observed result join
Runs on the replay copy, linking each patch to the checks observed in its run. Used by demo.
MATCH (p:Patch)-[:CHANGES]->(f:File)-[:CITES]->(d:Decision)-[:CHECKED_BY]->(t:Check),
(p)-[:PRODUCED]->(o:Observation)-[:FOR_CHECK]->(t),
(c:Commit)-[:IMPLEMENTS]->(d)
RETURN p.id AS patch, f.path AS file, d.id AS decision, d.reason AS reason,
c.sha AS implementation, t.name AS assertion, o.tap AS observed,
p.label AS label, o.number AS tap_number
ORDER BY patch, assertion
Observed results for a patch key
Reads back what a demo run observed for one patch. Used by mcp.
MATCH (p:Patch {patch_key: $key})-[:PRODUCED]->(o:Observation)-[:FOR_CHECK]->(k:Check) RETURN k.name AS check, o.tap AS tap, o.number AS number
One tool for your agent
The MCP server exposes precedent_for_patch: give it a diff and it returns the decision chain and any observed results. relate serve --mcp stdio --read-only serves the raw store over MCP instead, for arbitrary Cypher.