Validation: JSON Schemas + validator (the discipline, enforced)

The README claimed 'validated by JSON Schema' — now it is true.

/schemas holds a JSON Schema for each entity type (Person, Body,
Candidate, Jurisdiction): a stricter profile over OKF's permissive
base, tolerating unknown keys by design.

scripts/validate.py checks all 17,506 files with no third-party deps
(hand-rolled frontmatter parser + minimal schema engine):
  1. OKF conformance — every file has frontmatter with a non-empty type
  2. Schema conformance — required fields, property types, enums
  3. Link integrity — internal /-rooted links resolve

Non-zero exit on failure, so it is a CI gate. Verified with a negative
test: it catches bad enums and dead links. All 17,506 files pass today.

Makefile ties it together: make build / validate / check.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Fabio
2026-07-03 23:43:56 -04:00
parent 5b0712c31f
commit aefa65f5b3
6 changed files with 304 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Body",
"description": "A government body or institution — a chamber, committee, or subcommittee. The 'repos' of the government-as-code model.",
"type": "object",
"required": ["type", "title", "classification", "chamber", "code", "confidence", "tags", "timestamp"],
"properties": {
"type": { "type": "string", "enum": ["Body"] },
"title": { "type": "string" },
"classification": { "type": "string", "enum": ["house", "senate", "executive", "committee", "subcommittee"] },
"chamber": { "type": "string", "enum": ["house", "senate", "joint", "executive"] },
"code": { "type": "string" },
"parent": { "type": "string" },
"leadership": { "type": "array" },
"sources": { "type": "array" },
"confidence": { "type": "string", "enum": ["official", "reported", "inferred", "unverified"] },
"tags": { "type": "array" },
"timestamp": { "type": "string" }
}
}
+24
View File
@@ -0,0 +1,24 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Candidate",
"description": "A candidate for public office — someone running, distinct from a current officeholder. Sourced from FEC filings.",
"type": "object",
"required": ["type", "title", "office", "state", "confidence", "tags", "timestamp", "ids"],
"properties": {
"type": { "type": "string", "enum": ["Candidate"] },
"title": { "type": "string" },
"office": { "type": "string", "enum": ["U.S. House", "U.S. Senate"] },
"state": { "type": "string" },
"district": { "type": "string" },
"party": { "type": "string" },
"stance": { "type": "string", "enum": ["incumbent", "challenger", "open-seat"] },
"election_year": { "type": "integer" },
"status": { "type": "string" },
"committee": { "type": "object" },
"ids": { "type": "object" },
"sources": { "type": "array" },
"confidence": { "type": "string", "enum": ["official", "reported", "inferred", "unverified"] },
"tags": { "type": "array" },
"timestamp": { "type": "string" }
}
}
+20
View File
@@ -0,0 +1,20 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Jurisdiction",
"description": "A place with a government — a county or congressional district — carrying demographic context. A node in the fractal jurisdiction tree.",
"type": "object",
"required": ["type", "title", "classification", "confidence", "tags", "timestamp"],
"properties": {
"type": { "type": "string", "enum": ["Jurisdiction"] },
"title": { "type": "string" },
"classification": { "type": "string", "enum": ["county", "congressional-district"] },
"fips": { "type": "string" },
"state": { "type": "string" },
"district": { "type": "string" },
"demographics": { "type": "object" },
"sources": { "type": "array" },
"confidence": { "type": "string", "enum": ["official", "reported", "inferred", "unverified"] },
"tags": { "type": "array" },
"timestamp": { "type": "string" }
}
}
+23
View File
@@ -0,0 +1,23 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Person",
"description": "An officeholder — a person holding a public office at any level. OKF-conformant: only `type` is strictly required by OKF; this profile adds the fields Republic OS relies on. Unknown keys are tolerated.",
"type": "object",
"required": ["type", "title", "level", "confidence", "tags", "timestamp", "ids"],
"properties": {
"type": { "type": "string", "enum": ["Person"] },
"title": { "type": "string" },
"role": { "type": "string" },
"party": { "type": "string" },
"level": { "type": "string", "enum": ["federal", "state", "county", "municipal"] },
"branch": { "type": "string", "enum": ["executive", "legislative", "judicial"] },
"state": { "type": "string" },
"leadership": { "type": "array" },
"committees": { "type": "array" },
"ids": { "type": "object" },
"sources": { "type": "array" },
"confidence": { "type": "string", "enum": ["official", "reported", "inferred", "unverified"] },
"tags": { "type": "array" },
"timestamp": { "type": "string" }
}
}