{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://opentine.com/schemas/tine-cli-monitor-1.schema.json",
  "title": "tine monitor ... --json",
  "description": "Inline monitor verdicts and stop tokens. `stop`/`stops` list signed stop tokens (claim convention `opentine.monitor-stop/1`, held and never released); `verdicts` lists held monitor verdicts (`opentine.monitor-verdict/1`) and whether each signer is a pinned monitor key; `verify` checks offline that every blocked or replaced action in the given runs has its verdict. `fail:` findings block; `advisory:` findings block only with `--strict`. `backtest` replays recorded trajectories against a rule monitor and reports, per reasoning-visibility group (never pooled across groups), catch rate on attack-labelled trajectories and false-positive rate on benign ones, for the replay and for the recorded online verdicts. Online verdicts that saw another reasoning visibility or another input are counted, not compared. A verdict from the same monitor digest must reproduce byte for byte (`bit_identical`); `diff` lists every compared step whose action or decision changed. `collusion` compares an untrusted monitor's catch rate on attacks that carry a coordination signal with those that do not; its findings are advisory only (D12) and `ok` is always true.",
  "anyOf": [
    {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "command",
        "schema",
        "stops"
      ],
      "properties": {
        "schema": {
          "const": "tine-cli-monitor/1"
        },
        "command": {
          "enum": [
            "monitor stop",
            "monitor stops"
          ]
        },
        "stops": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "scope",
              "token",
              "verification"
            ],
            "properties": {
              "scope": {
                "type": "string",
                "pattern": "^(\\*|agent:.+|session:.+)$"
              },
              "token": {
                "anyOf": [
                  {
                    "type": "string",
                    "pattern": "^attestation:sha256:[0-9a-f]{64}$"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "verification": {
                "type": "string",
                "pattern": "^(verified|unverified: .+)$"
              }
            }
          }
        }
      }
    },
    {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "command",
        "schema",
        "verdicts"
      ],
      "properties": {
        "schema": {
          "const": "tine-cli-monitor/1"
        },
        "command": {
          "const": "monitor verdicts"
        },
        "verdicts": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "verdict",
              "verification",
              "action",
              "tool",
              "session",
              "enforced",
              "decided_by"
            ],
            "properties": {
              "verdict": {
                "type": "string",
                "pattern": "^attestation:sha256:[0-9a-f]{64}$"
              },
              "verification": {
                "type": "string",
                "pattern": "^(verified|unverified: .+)$"
              },
              "action": {
                "anyOf": [
                  {
                    "enum": [
                      "allow",
                      "flag",
                      "resample",
                      "defer",
                      "block"
                    ]
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "tool": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "session": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "enforced": {
                "anyOf": [
                  {
                    "type": "boolean"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "decided_by": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            }
          }
        }
      }
    },
    {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "command",
        "schema",
        "ok",
        "strict",
        "blocking",
        "verdicts",
        "blocked_actions",
        "replaced_actions",
        "runs",
        "stops",
        "findings"
      ],
      "properties": {
        "schema": {
          "const": "tine-cli-monitor/1"
        },
        "command": {
          "const": "monitor verify"
        },
        "ok": {
          "type": "boolean"
        },
        "strict": {
          "type": "boolean"
        },
        "blocking": {
          "type": "integer",
          "minimum": 0
        },
        "verdicts": {
          "type": "integer",
          "minimum": 0
        },
        "blocked_actions": {
          "type": "integer",
          "minimum": 0
        },
        "replaced_actions": {
          "type": "integer",
          "minimum": 0
        },
        "runs": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "stops": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "scope",
              "token",
              "verification"
            ],
            "properties": {
              "scope": {
                "type": "string",
                "pattern": "^(\\*|agent:.+|session:.+)$"
              },
              "token": {
                "anyOf": [
                  {
                    "type": "string",
                    "pattern": "^attestation:sha256:[0-9a-f]{64}$"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "verification": {
                "type": "string",
                "pattern": "^(verified|unverified: .+)$"
              }
            }
          }
        },
        "findings": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "level",
              "code",
              "message",
              "verdict",
              "run",
              "step"
            ],
            "properties": {
              "level": {
                "enum": [
                  "fail",
                  "advisory"
                ]
              },
              "code": {
                "type": "string",
                "pattern": "^(fail|advisory):monitor\\.[a-z-]+$"
              },
              "message": {
                "type": "string"
              },
              "verdict": {
                "anyOf": [
                  {
                    "type": "string",
                    "pattern": "^attestation:sha256:[0-9a-f]{64}$"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "run": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "step": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            }
          }
        }
      }
    },
    {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "command",
        "schema",
        "ok",
        "monitor",
        "monitor_digest",
        "visibility",
        "counts",
        "groups",
        "diff",
        "bit_identical"
      ],
      "properties": {
        "schema": {
          "const": "tine-cli-monitor/1"
        },
        "command": {
          "const": "monitor backtest"
        },
        "ok": {
          "type": "boolean"
        },
        "monitor": {
          "type": "string"
        },
        "monitor_digest": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        "visibility": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "bit_identical": {
          "type": "boolean"
        },
        "counts": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "steps",
            "reproduced",
            "not_reproduced",
            "other_monitor",
            "visibility_mismatch",
            "input_mismatch",
            "no_online_verdict",
            "skipped_trajectories",
            "unverified_verdicts"
          ],
          "properties": {
            "steps": {
              "type": "integer",
              "minimum": 0
            },
            "reproduced": {
              "type": "integer",
              "minimum": 0
            },
            "not_reproduced": {
              "type": "integer",
              "minimum": 0
            },
            "other_monitor": {
              "type": "integer",
              "minimum": 0
            },
            "visibility_mismatch": {
              "type": "integer",
              "minimum": 0
            },
            "input_mismatch": {
              "type": "integer",
              "minimum": 0
            },
            "no_online_verdict": {
              "type": "integer",
              "minimum": 0
            },
            "skipped_trajectories": {
              "type": "integer",
              "minimum": 0
            },
            "unverified_verdicts": {
              "type": "integer",
              "minimum": 0
            }
          }
        },
        "groups": {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "trajectories",
              "attacks",
              "benign",
              "unlabelled",
              "replay",
              "online"
            ],
            "properties": {
              "trajectories": {
                "type": "integer",
                "minimum": 0
              },
              "attacks": {
                "type": "integer",
                "minimum": 0
              },
              "benign": {
                "type": "integer",
                "minimum": 0
              },
              "unlabelled": {
                "type": "integer",
                "minimum": 0
              },
              "replay": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "caught",
                  "false_positives",
                  "catch_rate",
                  "false_positive_rate"
                ],
                "properties": {
                  "caught": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "false_positives": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "catch_rate": {
                    "anyOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "false_positive_rate": {
                    "anyOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              },
              "online": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "judged",
                  "attacks",
                  "benign",
                  "caught",
                  "false_positives",
                  "catch_rate",
                  "false_positive_rate"
                ],
                "properties": {
                  "caught": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "false_positives": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "catch_rate": {
                    "anyOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "false_positive_rate": {
                    "anyOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "judged": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "attacks": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "benign": {
                    "type": "integer",
                    "minimum": 0
                  }
                }
              }
            }
          }
        },
        "diff": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "run",
              "step",
              "outcome",
              "online_action",
              "replay_action",
              "online_score",
              "replay_score"
            ],
            "properties": {
              "run": {
                "type": "string"
              },
              "step": {
                "type": "integer",
                "minimum": 0
              },
              "outcome": {
                "enum": [
                  "reproduced",
                  "not_reproduced",
                  "other_monitor"
                ]
              },
              "online_action": {
                "anyOf": [
                  {
                    "enum": [
                      "allow",
                      "flag",
                      "resample",
                      "defer",
                      "block"
                    ]
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "replay_action": {
                "enum": [
                  "allow",
                  "flag",
                  "resample",
                  "defer",
                  "block"
                ]
              },
              "online_score": {
                "anyOf": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "replay_score": {
                "type": "number"
              }
            }
          }
        }
      }
    },
    {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "command",
        "schema",
        "ok",
        "advisory_only",
        "untrusted",
        "reference",
        "margin",
        "min_samples",
        "rates",
        "missed_runs",
        "findings",
        "log"
      ],
      "properties": {
        "schema": {
          "const": "tine-cli-monitor/1"
        },
        "command": {
          "const": "monitor collusion"
        },
        "ok": {
          "const": true
        },
        "advisory_only": {
          "const": true
        },
        "untrusted": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "monitor",
            "monitor_digest",
            "trust"
          ],
          "properties": {
            "monitor": {
              "type": "string"
            },
            "monitor_digest": {
              "type": "string",
              "pattern": "^sha256:[0-9a-f]{64}$"
            },
            "trust": {
              "enum": [
                "trusted",
                "untrusted"
              ]
            }
          }
        },
        "reference": {
          "anyOf": [
            {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "monitor",
                "monitor_digest",
                "trust"
              ],
              "properties": {
                "monitor": {
                  "type": "string"
                },
                "monitor_digest": {
                  "type": "string",
                  "pattern": "^sha256:[0-9a-f]{64}$"
                },
                "trust": {
                  "enum": [
                    "trusted",
                    "untrusted"
                  ]
                }
              }
            },
            {
              "type": "null"
            }
          ]
        },
        "margin": {
          "type": "number"
        },
        "min_samples": {
          "type": "integer"
        },
        "rates": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "signal",
            "plain"
          ],
          "properties": {
            "signal": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "attacks",
                "untrusted_catch_rate",
                "reference_catch_rate"
              ],
              "properties": {
                "attacks": {
                  "type": "integer",
                  "minimum": 0
                },
                "untrusted_catch_rate": {
                  "anyOf": [
                    {
                      "type": "number"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "reference_catch_rate": {
                  "anyOf": [
                    {
                      "type": "number"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            },
            "plain": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "attacks",
                "untrusted_catch_rate",
                "reference_catch_rate"
              ],
              "properties": {
                "attacks": {
                  "type": "integer",
                  "minimum": 0
                },
                "untrusted_catch_rate": {
                  "anyOf": [
                    {
                      "type": "number"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "reference_catch_rate": {
                  "anyOf": [
                    {
                      "type": "number"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          }
        },
        "missed_runs": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "log": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "findings": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "level",
              "code",
              "detail"
            ],
            "properties": {
              "level": {
                "const": "advisory"
              },
              "code": {
                "enum": [
                  "advisory:monitor-collusion-suspected",
                  "advisory:monitor-misses-reference-catch"
                ]
              },
              "detail": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  ]
}
