{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "$id": "https://www.runsby.ai/standard/autonomy-card.schema.json",
 "title": "RunsBy autonomy card v1.0",
 "description": "The autonomy object on a RunsBy listing, under the RunsBy Autonomy Levels v1.0 (https://www.runsby.ai/standard/). Licensed CC BY 4.0. level is always computed from the grid, the caps and the evidence ceiling; null means Not graded.",
 "type": "object",
 "required": [
  "spec_version",
  "level",
  "grade",
  "grid",
  "evidence_links"
 ],
 "properties": {
  "spec_version": {
   "const": "1.0"
  },
  "level": {
   "anyOf": [
    {
     "enum": [
      "A0",
      "A1",
      "A2",
      "A3",
      "A4",
      "A5"
     ]
    },
    {
     "type": "null"
    }
   ],
   "description": "A0 to A5, or null for Not graded."
  },
  "declared_level": {
   "anyOf": [
    {
     "enum": [
      "A0",
      "A1",
      "A2",
      "A3",
      "A4",
      "A5"
     ]
    },
    {
     "type": "null"
    }
   ],
   "description": "The operator's own claim, when it is higher than the evidence supports."
  },
  "grade": {
   "anyOf": [
    {
     "enum": [
      "Declared",
      "Documented",
      "Audited"
     ]
    },
    {
     "type": "null"
    }
   ],
   "description": "Evidence grade. null only when Not graded."
  },
  "grid": {
   "type": "object",
   "required": [
    "strategy",
    "build",
    "publish",
    "sell",
    "price",
    "support",
    "spend"
   ],
   "additionalProperties": false,
   "properties": {
    "strategy": {
     "enum": [
      "H",
      "P",
      "M",
      "O",
      null
     ],
     "description": "Strategy and spend always apply, so never \"n/a\"."
    },
    "build": {
     "enum": [
      "H",
      "P",
      "M",
      "O",
      "n/a",
      null
     ],
     "description": "H human, P pre-approved, M monitored, O owned, \"n/a\" when nobody makes these decisions, null when unknown (unknown blocks any level that needs the cell)."
    },
    "publish": {
     "enum": [
      "H",
      "P",
      "M",
      "O",
      "n/a",
      null
     ],
     "description": "H human, P pre-approved, M monitored, O owned, \"n/a\" when nobody makes these decisions, null when unknown (unknown blocks any level that needs the cell)."
    },
    "sell": {
     "enum": [
      "H",
      "P",
      "M",
      "O",
      "n/a",
      null
     ],
     "description": "H human, P pre-approved, M monitored, O owned, \"n/a\" when nobody makes these decisions, null when unknown (unknown blocks any level that needs the cell)."
    },
    "price": {
     "enum": [
      "H",
      "P",
      "M",
      "O",
      "n/a",
      null
     ],
     "description": "H human, P pre-approved, M monitored, O owned, \"n/a\" when nobody makes these decisions, null when unknown (unknown blocks any level that needs the cell)."
    },
    "support": {
     "enum": [
      "H",
      "P",
      "M",
      "O",
      "n/a",
      null
     ],
     "description": "H human, P pre-approved, M monitored, O owned, \"n/a\" when nobody makes these decisions, null when unknown (unknown blocks any level that needs the cell)."
    },
    "spend": {
     "enum": [
      "H",
      "P",
      "M",
      "O",
      null
     ],
     "description": "Strategy and spend always apply, so never \"n/a\"."
    }
   }
  },
  "grid_evidence": {
   "type": "object",
   "description": "Per domain: the link and a one-line reading behind the cell. Documented and Audited cells need a url.",
   "additionalProperties": false,
   "properties": {
    "strategy": {
     "type": "object",
     "required": [
      "note"
     ],
     "additionalProperties": false,
     "properties": {
      "url": {
       "type": "string",
       "pattern": "^https?://"
      },
      "note": {
       "type": "string"
      }
     }
    },
    "build": {
     "type": "object",
     "required": [
      "note"
     ],
     "additionalProperties": false,
     "properties": {
      "url": {
       "type": "string",
       "pattern": "^https?://"
      },
      "note": {
       "type": "string"
      }
     }
    },
    "publish": {
     "type": "object",
     "required": [
      "note"
     ],
     "additionalProperties": false,
     "properties": {
      "url": {
       "type": "string",
       "pattern": "^https?://"
      },
      "note": {
       "type": "string"
      }
     }
    },
    "sell": {
     "type": "object",
     "required": [
      "note"
     ],
     "additionalProperties": false,
     "properties": {
      "url": {
       "type": "string",
       "pattern": "^https?://"
      },
      "note": {
       "type": "string"
      }
     }
    },
    "price": {
     "type": "object",
     "required": [
      "note"
     ],
     "additionalProperties": false,
     "properties": {
      "url": {
       "type": "string",
       "pattern": "^https?://"
      },
      "note": {
       "type": "string"
      }
     }
    },
    "support": {
     "type": "object",
     "required": [
      "note"
     ],
     "additionalProperties": false,
     "properties": {
      "url": {
       "type": "string",
       "pattern": "^https?://"
      },
      "note": {
       "type": "string"
      }
     }
    },
    "spend": {
     "type": "object",
     "required": [
      "note"
     ],
     "additionalProperties": false,
     "properties": {
      "url": {
       "type": "string",
       "pattern": "^https?://"
      },
      "note": {
       "type": "string"
      }
     }
    }
   }
  },
  "p_stats": {
   "type": [
    "object",
    "null"
   ],
   "additionalProperties": false,
   "properties": {
    "approval_rate": {
     "type": "number",
     "minimum": 0,
     "maximum": 1
    },
    "median_review_minutes": {
     "type": "number",
     "minimum": 0
    },
    "window": {
     "type": [
      "string",
      "null"
     ]
    }
   },
   "description": "Required when any domain is P."
  },
  "interventions_30d": {
   "type": [
    "integer",
    "null"
   ],
   "minimum": 0
  },
  "excluded_actions_30d": {
   "type": [
    "integer",
    "null"
   ],
   "minimum": 0
  },
  "human_hours_week": {
   "type": [
    "number",
    "null"
   ],
   "minimum": 0
  },
  "operator": {
   "type": [
    "string",
    "null"
   ]
  },
  "stop_control": {
   "type": [
    "object",
    "null"
   ],
   "additionalProperties": false,
   "properties": {
    "description": {
     "type": "string"
    },
    "last_tested": {
     "type": [
      "string",
      "null"
     ],
     "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
    }
   }
  },
  "scope": {
   "type": [
    "string",
    "null"
   ]
  },
  "stack": {
   "type": [
    "string",
    "null"
   ]
  },
  "level_since": {
   "type": [
    "string",
    "null"
   ],
   "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
  },
  "a4_since": {
   "type": [
    "string",
    "null"
   ],
   "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
   "description": "Date A4 was first met without a break (A5 needs 90 days)."
  },
  "largest_solo_action": {
   "type": [
    "string",
    "null"
   ]
  },
  "build_mark": {
   "enum": [
    "B0",
    "B1",
    "B2",
    "B3",
    null
   ]
  },
  "build_grade": {
   "anyOf": [
    {
     "enum": [
      "Declared",
      "Documented",
      "Audited"
     ]
    },
    {
     "type": "null"
    }
   ]
  },
  "build_evidence": {
   "type": [
    "string",
    "null"
   ]
  },
  "hands": {
   "enum": [
    "digital",
    "human",
    "robotic",
    "mixed",
    null
   ]
  },
  "self_funded": {
   "type": [
    "boolean",
    "null"
   ]
  },
  "self_funded_evidence": {
   "anyOf": [
    {
     "type": "string",
     "pattern": "^https?://"
    },
    {
     "type": "null"
    }
   ]
  },
  "spend_budget": {
   "type": [
    "object",
    "null"
   ],
   "additionalProperties": false,
   "required": [
    "amount",
    "currency",
    "period",
    "source"
   ],
   "description": "The budget people set for the AI's spending. Required for Spend at M or higher at A4 and A5 (\"spends inside a budget people set\").",
   "properties": {
    "amount": {
     "type": "number",
     "minimum": 0
    },
    "currency": {
     "type": "string",
     "pattern": "^[A-Z]{3}$"
    },
    "period": {
     "enum": [
      "day",
      "week",
      "month",
      "quarter",
      "year"
     ]
    },
    "source": {
     "type": "string",
     "pattern": "^https?://"
    }
   }
  },
  "audit": {
   "type": [
    "object",
    "null"
   ],
   "additionalProperties": false,
   "required": [
    "date",
    "sample_size",
    "log_source"
   ],
   "properties": {
    "date": {
     "type": [
      "string",
      "null"
     ],
     "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
    },
    "sample_size": {
     "const": 30
    },
    "log_source": {
     "type": "string"
    }
   }
  },
  "evidence_links": {
   "type": "array",
   "items": {
    "type": "string",
    "pattern": "^https?://"
   }
  },
  "rated": {
   "type": [
    "string",
    "null"
   ],
   "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
  },
  "expiry": {
   "type": [
    "string",
    "null"
   ],
   "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
  },
  "model_changed": {
   "type": [
    "string",
    "null"
   ],
   "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
  },
  "conflict_of_interest": {
   "type": [
    "string",
    "null"
   ]
  },
  "outside_review": {
   "type": [
    "string",
    "null"
   ]
  },
  "notes": {
   "type": [
    "string",
    "null"
   ]
  }
 },
 "additionalProperties": false
}
