Research-Stack/shared-data/schemas/claims-registry.schema.json
Devin AI f70552211b math-first: fix pre-commit evidence-gate filter bug, polish schema + validator
Follow-up to PR #10. Addresses comments left by Devin Review.

Primary fix (the BUG comment, .pre-commit-config.yaml:86-87):
  The receipt-required-for-math-content hook used files: '<math-track
  regex>' with pass_filenames: true. Pre-commit applies that regex to
  the staged file list BEFORE invoking the hook, so evidence files
  (receipts under shared-data/artifacts/deepseek_review/, claims.yaml)
  were stripped from argv. require_math_evidence.py then saw only the
  math-track files, found no evidence, and exited 1 -- even when proper
  evidence was committed alongside. The only case that worked was
  Lean-only commits, because Lean files are dual-classified as both
  math-track and evidence.

  Fix: drive the hook from the index instead of argv.
    * require_math_evidence.py grows a --staged mode that runs
      'git diff --cached --name-only' itself, plus a mutex check so
      --staged, --from-git-diff, and explicit FILES cannot be combined.
    * .pre-commit-config.yaml hook switches to always_run: true,
      pass_filenames: false, and 'entry: ... --staged'. The script
      exits 0 early when no math-track files are staged, so the cost
      of always_run is negligible.

Polish:
  * claims-registry.schema.json: add required: ["status"] inside each
    'if' subschema. Without it, an entry missing 'status' would also
    spuriously trip the 'then' clauses (review_receipts, lean) before
    the top-level required catch. Pure error-message cleanup.
  * validate_claims_registry.py: replace the catch-all
    re.compile(r'^[A-Za-z]+:') with a closed list of well-known URI
    schemes (http, https, arxiv, doi, isbn, mailto, urn).
    Module-name-shaped strings like 'Module:Theorem' will no longer
    silently bypass the on-disk path check.
  * validate_claims_registry.py: thread a FormatChecker through the
    Draft202012Validator so format-keyword behaviour matches
    validate_deepseek_receipts.py. No-op for today's schema but
    cheap insurance for the next contributor who adds 'format'.

Regression tests:
  * New scripts/math-first/test_require_math_evidence.py covers ten
    classification cases plus the actual --staged regression: it spins
    up a temp git repo, stages a math-track file + a receipt, invokes
    the script with --staged, and asserts exit 0. Without the fix this
    case fails, demonstrating the bug end-to-end.
  * math-check.yml runs the new self-tests in CI.

Docs: * docs/math-first-tooling.md: document the --staged contract, why
    always_run + pass_filenames: false is necessary, and how to run
    the new self-tests.
Co-Authored-By: Allaun Silverfox <bigdataiscoming+9i37y6j2@protonmail.com>
2026-05-12 04:40:20 +00:00

88 lines
2.8 KiB
JSON

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/allaunthefox/Research-Stack/shared-data/schemas/claims-registry.schema.json",
"title": "Research Stack Mathematical Claim Registry",
"description": "Schema for claims.yaml at the repo root. Tracks the rigor level of every mathematical claim the stack stands behind, plus the Lean proof and/or DeepSeek review receipts that back it. See docs/math-first-tooling.md.",
"type": "object",
"required": ["claims"],
"additionalProperties": false,
"properties": {
"claims": {
"type": "array",
"minItems": 1,
"items": { "$ref": "#/$defs/claim" }
}
},
"$defs": {
"claim": {
"type": "object",
"required": ["id", "title", "status"],
"additionalProperties": false,
"properties": {
"id": {
"type": "string",
"pattern": "^[a-z0-9][a-z0-9-]*$",
"description": "Stable kebab-case slug. Must remain unique across the registry."
},
"title": {
"type": "string",
"minLength": 1,
"description": "One-line natural-language statement of the claim."
},
"status": {
"type": "string",
"enum": ["conjecture", "verified-by-ai", "formally-proven", "published"],
"description": "Current rigor level for the claim."
},
"lean": {
"type": "string",
"minLength": 1,
"description": "Optional repo-relative Lean source file or `theorem` symbol carrying the proof obligation."
},
"review_receipts": {
"type": "array",
"uniqueItems": true,
"items": {
"type": "string",
"pattern": "\\.receipt\\.json$",
"description": "Repo-relative path to a DeepSeek review receipt."
}
},
"sources": {
"type": "array",
"uniqueItems": true,
"items": {
"type": "string",
"minLength": 1,
"description": "Repo-relative path or external citation supporting the claim."
}
},
"notes": {
"type": "string",
"description": "Free-form context. Keep short."
}
},
"allOf": [
{
"if": {
"required": ["status"],
"properties": { "status": { "const": "verified-by-ai" } }
},
"then": {
"required": ["review_receipts"],
"properties": {
"review_receipts": { "minItems": 1 }
}
}
},
{
"if": {
"required": ["status"],
"properties": { "status": { "const": "formally-proven" } }
},
"then": { "required": ["lean"] }
}
]
}
}
}