{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://www.neurarch.com/schema/gate-record-v1.json",
  "title": "neurarch gate record",
  "description": "What `neurarch gate` checked before a change went live: each model with the commit it is pinned to or resolved to, each launch with its card and engine release, each prompt comparison, every finding, the verdict, and what was not checked.",
  "type": "object",
  "required": [
    "$schema",
    "tool",
    "at",
    "paths",
    "verdict",
    "exit",
    "because",
    "counts",
    "models",
    "launches",
    "prompts",
    "notChecked"
  ],
  "properties": {
    "$schema": {
      "const": "https://www.neurarch.com/schema/gate-record-v1.json"
    },
    "tool": {
      "type": "object",
      "required": [
        "name",
        "version"
      ],
      "properties": {
        "name": {
          "const": "neurarch"
        },
        "version": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "at": {
      "type": "string",
      "description": "When the gate ran, ISO 8601, UTC."
    },
    "paths": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "verdict": {
      "enum": [
        "admit",
        "review",
        "refuse"
      ],
      "description": "refuse: a high scan finding or a launch blocker. review: nothing blocks and there is something to read, or something could not be read. admit: nothing above low and everything was read."
    },
    "exit": {
      "enum": [
        0,
        1
      ]
    },
    "because": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "counts": {
      "type": "object",
      "required": [
        "scan",
        "serve",
        "promptDiffers",
        "unread"
      ],
      "properties": {
        "scan": {
          "type": "object",
          "required": [
            "high",
            "medium",
            "low"
          ],
          "properties": {
            "high": {
              "type": "integer",
              "minimum": 0
            },
            "medium": {
              "type": "integer",
              "minimum": 0
            },
            "low": {
              "type": "integer",
              "minimum": 0
            }
          },
          "additionalProperties": false
        },
        "serve": {
          "type": "object",
          "required": [
            "block",
            "warn"
          ],
          "properties": {
            "block": {
              "type": "integer",
              "minimum": 0
            },
            "warn": {
              "type": "integer",
              "minimum": 0
            }
          },
          "additionalProperties": false
        },
        "promptDiffers": {
          "type": "integer",
          "minimum": 0
        },
        "unread": {
          "type": "integer",
          "minimum": 0,
          "description": "Things the gate set out to check and could not read. Above zero, the verdict is never admit."
        },
        "evalFailed": {
          "type": "integer",
          "minimum": 0,
          "description": "The team's own --eval commands that ran and exited non-zero. Absent when no --eval was given."
        }
      },
      "additionalProperties": false
    },
    "models": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "pinned",
          "resolvedTo",
          "sites",
          "findings"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "pinned": {
            "type": [
              "string",
              "null"
            ],
            "description": "The commit the reference pins, or null when it pins none."
          },
          "resolvedTo": {
            "type": [
              "string",
              "null"
            ],
            "description": "The commit the id resolved to on the Hub when the gate ran."
          },
          "sites": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "findings": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "lane",
                "severity",
                "kind",
                "message"
              ],
              "properties": {
                "lane": {
                  "enum": [
                    "security",
                    "behavior",
                    "hygiene"
                  ]
                },
                "severity": {
                  "enum": [
                    "high",
                    "medium",
                    "low"
                  ]
                },
                "kind": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                },
                "source": {
                  "enum": [
                    "modelaudit"
                  ],
                  "description": "Set when another tool reported the finding: modelaudit is ModelAudit (github.com/promptfoo/modelaudit), run with --modelaudit."
                }
              },
              "additionalProperties": false
            }
          },
          "adapterOf": {
            "type": "string",
            "description": "For a LoRA adapter: the base it is served on."
          }
        },
        "additionalProperties": false
      }
    },
    "hostedModels": {
      "type": "array",
      "description": "Hosted API models the code names (OpenAI, Anthropic and others), with their findings: a retired one is a call that fails. Present only when the scan found one.",
      "items": {
        "type": "object",
        "required": [
          "id",
          "sites",
          "findings"
        ],
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string"
          },
          "sites": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "findings": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "lane",
                "severity",
                "kind",
                "message"
              ],
              "additionalProperties": false,
              "properties": {
                "lane": {
                  "enum": [
                    "security",
                    "behavior",
                    "hygiene"
                  ]
                },
                "severity": {
                  "enum": [
                    "high",
                    "medium",
                    "low"
                  ]
                },
                "kind": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "launches": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "file",
          "command",
          "engine",
          "engineVersion",
          "card",
          "gpus",
          "findings"
        ],
        "properties": {
          "file": {
            "type": "string"
          },
          "command": {
            "type": "string"
          },
          "engine": {
            "enum": [
              "vllm",
              "sglang"
            ]
          },
          "engineVersion": {
            "type": [
              "string",
              "null"
            ]
          },
          "engineVersionAssumed": {
            "type": "boolean",
            "description": "True when the file states no engine version and the newest release the tables were read from was used."
          },
          "card": {
            "type": [
              "string",
              "null"
            ],
            "description": "The card the launch was checked on; null when none was given, so memory and fit were not checked."
          },
          "gpus": {
            "type": [
              "integer",
              "null"
            ]
          },
          "findings": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "severity",
                "rule",
                "title"
              ],
              "properties": {
                "severity": {
                  "enum": [
                    "block",
                    "warn"
                  ]
                },
                "rule": {
                  "type": "string"
                },
                "title": {
                  "type": "string"
                }
              },
              "additionalProperties": false
            }
          },
          "model": {
            "type": "string",
            "description": "The Hub id the launch serves, when the line names one."
          },
          "environment": {
            "type": "array",
            "description": "Engine variables in the launch's environment (on the line, or exported before it), and what the check did with each: modelled, no-effect, or not-modelled (the launch then counts as not fully read).",
            "items": {
              "type": "object",
              "required": [
                "name",
                "value",
                "effect"
              ],
              "properties": {
                "name": {
                  "type": "string"
                },
                "value": {
                  "type": "string"
                },
                "effect": {
                  "enum": [
                    "modelled",
                    "no-effect",
                    "not-modelled"
                  ]
                }
              },
              "additionalProperties": false
            }
          },
          "revision": {
            "type": [
              "string",
              "null"
            ],
            "description": "The revision the launch pins with --revision, as written, or null."
          },
          "tp": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "description": "Tensor parallel size as the check resolved it. With the model, the revision, pp and maxModelLen: the launch identity a benchmark of it is joined on (`neurarch ledger outcome`)."
          },
          "pp": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1
          },
          "maxModelLen": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "description": "The served context length as the check resolved it (the flag, or the model's own when the launch states none)."
          },
          "blocked": {
            "type": "boolean",
            "description": "True when a finding on this launch blocks."
          },
          "predicted": {
            "type": [
              "object",
              "null"
            ],
            "description": "What the check predicted for the launch's KV cache; null when no card was given.",
            "properties": {
              "kvTokens": {
                "type": [
                  "number",
                  "null"
                ],
                "minimum": 0
              },
              "kvBlocks": {
                "type": [
                  "number",
                  "null"
                ],
                "minimum": 0,
                "description": "vLLM KV cache blocks per engine, the unit vLLM's own num_gpu_blocks counts."
              },
              "maxConcurrency": {
                "type": [
                  "number",
                  "null"
                ],
                "minimum": 0
              }
            },
            "additionalProperties": false
          }
        },
        "additionalProperties": false
      }
    },
    "prompts": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "engine",
          "verdict"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "engine": {
            "type": "string"
          },
          "verdict": {
            "type": "string"
          },
          "at": {
            "type": "string",
            "description": "The revision the template was read at: the commit the launch pins, or main."
          },
          "templateSha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$",
            "description": "sha256 of the chat template that was read there."
          }
        },
        "additionalProperties": false
      }
    },
    "evals": {
      "type": "array",
      "description": "The team's own eval commands (--eval), when given: what ran, its exit code and a sha256 of its output. The output itself is not stored.",
      "items": {
        "type": "object",
        "required": [
          "command",
          "commandSha256",
          "exit",
          "durationMs",
          "outputSha256"
        ],
        "properties": {
          "command": {
            "type": "string"
          },
          "commandSha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$",
            "description": "sha256 of the command; the ledger line carries this instead of the command."
          },
          "exit": {
            "type": [
              "integer",
              "null"
            ],
            "description": "null when the command did not finish (timed out or could not start)."
          },
          "durationMs": {
            "type": "number",
            "minimum": 0
          },
          "outputSha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "timedOut": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      }
    },
    "modelaudit": {
      "type": "object",
      "description": "Present when ModelAudit was asked for (--modelaudit). Whether it ran, its version, how many files it was given, and every finding it reported; the ones on a cached Hub model also sit under that model. What it could not cover is in notChecked.",
      "required": [
        "ran",
        "version",
        "files",
        "findings"
      ],
      "additionalProperties": false,
      "properties": {
        "ran": {
          "type": "boolean"
        },
        "version": {
          "type": [
            "string",
            "null"
          ]
        },
        "reason": {
          "type": "string",
          "description": "Why it did not run: not installed, timed out, no report, no model files on this machine."
        },
        "files": {
          "type": "integer",
          "minimum": 0
        },
        "findings": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "severity",
              "kind",
              "file",
              "message"
            ],
            "additionalProperties": false,
            "properties": {
              "severity": {
                "enum": [
                  "high",
                  "medium"
                ]
              },
              "kind": {
                "type": "string"
              },
              "file": {
                "type": "string"
              },
              "model": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      }
    },
    "notChecked": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "What the gate did not check, and why."
    },
    "subject": {
      "type": "object",
      "description": "The change the gate ran on. In GitHub Actions and GitLab CI it is filled from the CI variables; --repo, --commit, --ref, --by and --run-url set it by hand; elsewhere commit and ref come from git. Optional: records written by earlier releases do not carry it.",
      "required": [
        "repo",
        "commit",
        "ref",
        "by",
        "runUrl"
      ],
      "properties": {
        "repo": {
          "type": [
            "string",
            "null"
          ]
        },
        "commit": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^[0-9a-f]{40}$"
        },
        "ref": {
          "type": [
            "string",
            "null"
          ]
        },
        "by": {
          "type": [
            "string",
            "null"
          ],
          "description": "The CI system's account name for whoever triggered the run, or --by. Never the operating-system user."
        },
        "runUrl": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "additionalProperties": false
    },
    "override": {
      "type": "object",
      "description": "Present when someone let a review or refuse through with --override or NEURARCH_OVERRIDE. verdict, exit and because stay what the gate decided; the command exited 0 because of this. Never present on an admit.",
      "required": [
        "by",
        "reason",
        "at"
      ],
      "properties": {
        "by": {
          "type": [
            "string",
            "null"
          ],
          "description": "GITHUB_ACTOR, else GITLAB_USER_LOGIN, else git config user.email, else $USER, recorded as given."
        },
        "reason": {
          "type": "string",
          "minLength": 1,
          "maxLength": 300
        },
        "at": {
          "type": "string",
          "description": "When the override was applied (ISO 8601)."
        }
      },
      "additionalProperties": false
    },
    "standing": {
      "type": "object",
      "description": "Where the repository stands against the public change record (neurarch.com/changes): each model, whether it is pinned, and what the record holds since the pin or over the last windowDays days. Informational: it never changes verdict or exit, and the ledger line does not carry it. Absent with --no-summary.",
      "required": [
        "recordUrl",
        "recordStartsOn",
        "windowDays",
        "today",
        "recordRead",
        "models"
      ],
      "additionalProperties": false,
      "properties": {
        "recordUrl": {
          "type": "string"
        },
        "recordStartsOn": {
          "type": "string",
          "description": "The day the daily record starts; earlier rows come from Hub git history."
        },
        "windowDays": {
          "type": "integer"
        },
        "today": {
          "type": "string"
        },
        "recordRead": {
          "type": "boolean"
        },
        "models": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "id",
              "pinned",
              "sites",
              "mainMoved",
              "status",
              "window",
              "events",
              "page"
            ],
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string"
              },
              "pinned": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "sites": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "file:line of each reference."
              },
              "mainMoved": {
                "type": [
                  "boolean",
                  "null"
                ],
                "description": "Whether the Hub's main has moved past the pin; null when unpinned or main was not read."
              },
              "status": {
                "enum": [
                  "changed",
                  "unchanged",
                  "not-checked"
                ],
                "description": "not-checked when the record could not say (not read, the model not tracked, the pin not placed): never read as unchanged."
              },
              "window": {
                "type": "object",
                "required": [
                  "kind"
                ],
                "properties": {
                  "kind": {
                    "enum": [
                      "since-pin",
                      "last-days"
                    ]
                  },
                  "from": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "days": {
                    "type": "integer"
                  }
                },
                "additionalProperties": false
              },
              "events": {
                "type": "array",
                "items": {
                  "type": "object",
                  "required": [
                    "date",
                    "kinds",
                    "what",
                    "source"
                  ],
                  "additionalProperties": false,
                  "properties": {
                    "date": {
                      "type": "string",
                      "description": "When it happened upstream (commit date, or when the daily tracker saw it)."
                    },
                    "kinds": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "enum": [
                          "chat-template",
                          "weights",
                          "erased-commit",
                          "licence",
                          "remote-code",
                          "retirement",
                          "repository",
                          "structural",
                          "tokenizer",
                          "generation-defaults",
                          "new-commit"
                        ]
                      },
                      "description": "structural is a config change; licence includes gating; repository is an owner change or a repository that stopped answering."
                    },
                    "what": {
                      "type": "string"
                    },
                    "source": {
                      "type": "string",
                      "description": "The upstream commit, or the repository."
                    }
                  }
                }
              },
              "reason": {
                "type": "string",
                "description": "Why it was not checked."
              },
              "page": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The model's page in the change record."
              },
              "latest": {
                "type": "string",
                "description": "Unpinned, nothing in the window: the date of the newest recorded change."
              }
            }
          }
        }
      }
    }
  },
  "additionalProperties": false
}
