{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/agentdrives-com/json-schema/agentdrives-com-audit-fixes-schema.json",
  "title": "AuditFixes",
  "description": "An Audit's fix list, its drives and its new drives after fixes",
  "x-generated": "2026-10-31",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/agentdrives-com-openapi.json#/components/schemas/AuditFixes",
  "type": "object",
  "properties": {
    "ready": {
      "type": "boolean",
      "description": "false before the Audit's report: no list yet, fix says when (every other field absent)"
    },
    "fix": {
      "type": "string",
      "description": "ready false only"
    },
    "order": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "url": {
          "type": [
            "string",
            "null"
          ]
        },
        "report_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "fix_days": {
          "type": "integer",
          "description": "The Audit year in days, from report_at"
        }
      }
    },
    "level": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Today's level: the Audit's drive's"
    },
    "target_level": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Your goal, never a promise"
    },
    "reachable": {
      "type": "integer",
      "description": "The highest level the fixes reach (L5 apart)"
    },
    "l5_path": {
      "type": "boolean",
      "description": "A fix leads to L5 (it needs agent payments)"
    },
    "counts": {
      "type": "object",
      "properties": {
        "open": {
          "type": "integer"
        },
        "fixed": {
          "type": "integer"
        },
        "as_is": {
          "type": "integer"
        },
        "doesnt_apply": {
          "type": "integer"
        },
        "all": {
          "type": "integer"
        },
        "done": {
          "type": "integer",
          "description": "A drive passed every checkpoint the fix names"
        },
        "still_there": {
          "type": "integer",
          "description": "A drive after you marked it fixed still failed it: to do again"
        },
        "new": {
          "type": "integer",
          "description": "Found by a later drive"
        }
      }
    },
    "fixes": {
      "type": "array",
      "description": "Open fixes first, then the done ones (fixed, as_is, doesnt_apply), each by n (the drive's rank, most important first)",
      "items": {
        "type": "object",
        "properties": {
          "n": {
            "type": "integer"
          },
          "title": {
            "type": "string"
          },
          "why": {
            "type": [
              "string",
              "null"
            ]
          },
          "how": {
            "type": [
              "string",
              "null"
            ]
          },
          "checkpoints": {
            "type": "array",
            "items": {
              "enum": [
                "docs",
                "signup",
                "verify",
                "credentials",
                "first_call",
                "first_action",
                "pay",
                "cancel",
                "delete"
              ]
            },
            "description": "The checkpoints of the drive this fix is about (empty: it names none)"
          },
          "effort": {
            "enum": [
              "small",
              "medium",
              "large",
              null
            ]
          },
          "team": {
            "type": [
              "string",
              "null"
            ]
          },
          "level_after": {
            "type": [
              "integer",
              "null"
            ],
            "description": "The level the fixes up to this one reach"
          },
          "lifts_to": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Where this fix lifts the level"
          },
          "state": {
            "enum": [
              "open",
              "fixed",
              "as_is",
              "doesnt_apply"
            ]
          },
          "reason": {
            "type": [
              "string",
              "null"
            ],
            "description": "as_is and doesnt_apply: your reason"
          },
          "marked_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "result": {
            "enum": [
              "done",
              "still_there",
              null
            ],
            "description": "What the last drive that touched it found: done (every checkpoint it names passed by our agent on its own) or still_there (a drive after you marked it fixed still failed one; it's to do again)"
          },
          "result_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "result_note": {
            "type": [
              "string",
              "null"
            ],
            "description": "still_there: what our agent saw"
          },
          "new_since": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Found by a later drive than the Audit's first drive"
          },
          "closed_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "A fix that names no checkpoint, closed because a later drive given it no longer found it: that drive's id"
          },
          "closed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When that drive's report went out"
          },
          "review": {
            "enum": [
              "asked",
              "refused",
              null
            ],
            "description": "doesnt_apply: our answer is on its way (asked); refused: we checked and it does apply (back to open, our reason in answer). Agreed ones leave the list."
          },
          "answer": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "n",
          "title",
          "state"
        ]
      }
    },
    "drives": {
      "type": "array",
      "description": "GET only: the Audit's first drive, then each new drive after fixes",
      "items": {
        "type": "object",
        "properties": {
          "kind": {
            "enum": [
              "audit",
              "redrive"
            ]
          },
          "n": {
            "type": "integer"
          },
          "status": {
            "type": "string",
            "description": "queued, running, report (done, its report in its last check), done, failed"
          },
          "queued_at": {
            "type": "string",
            "format": "date-time"
          },
          "done_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "level": {
            "type": [
              "integer",
              "null"
            ]
          },
          "report_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "left_behind": {
            "type": [
              "object",
              "null"
            ],
            "description": "A finished drive: what our agent left behind at your product (its plan cancelled, its account deleted, or its address for you to delete); line says it in words",
            "properties": {
              "line": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "account": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "cancelled": {
                "type": [
                  "boolean",
                  "null"
                ]
              },
              "deleted": {
                "type": [
                  "boolean",
                  "null"
                ]
              },
              "at": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          }
        },
        "required": [
          "kind",
          "n",
          "status"
        ]
      }
    },
    "certificate": {
      "type": [
        "object",
        "null"
      ],
      "description": "GET only: the certificate the Audit ends in, only when an agent uses the product fully with no person (L5). none: not yet, and why; pending: your drives agree and we're checking it; declined (with why); valid, expired, lapsed, withdrawn or renewed once issued, with its page, its live badge, the badge snippets for your site and the words you may use",
      "properties": {
        "status": {
          "enum": [
            "none",
            "pending",
            "declined",
            "valid",
            "expired",
            "lapsed",
            "withdrawn",
            "renewed"
          ]
        },
        "why": {
          "type": [
            "string",
            "null"
          ]
        },
        "from": {
          "type": "integer",
          "description": "The lowest level a certificate is issued at"
        },
        "level": {
          "type": "integer"
        },
        "level_name": {
          "type": "string"
        },
        "issued_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "expires_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "ended_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "page": {
          "type": "string",
          "format": "uri"
        },
        "badge": {
          "type": "string",
          "format": "uri",
          "description": "The live badge (SVG): it always shows the certificate as it stands"
        },
        "snippet": {
          "type": "string",
          "description": "HTML for your site: the wide badge, linked to the certificate's page (rel=nofollow)"
        },
        "snippet_compact": {
          "type": "string",
          "description": "The same, the compact badge"
        },
        "words": {
          "type": "string",
          "description": "What you may say about it, word for word"
        }
      },
      "required": [
        "status"
      ]
    },
    "redrive": {
      "type": "object",
      "description": "GET only: new drives after fixes in the Audit year: one at a time, at most one a day",
      "properties": {
        "used": {
          "type": "integer",
          "description": "Drives after fixes used this year (a drive that failed on our side, one that confirms the certificate and the lapse check use none)"
        },
        "left": {
          "type": "integer",
          "description": "Drives after fixes left this year"
        },
        "max": {
          "type": "integer"
        },
        "until": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "The end of the Audit year"
        },
        "busy": {
          "type": "boolean",
          "description": "A drive of this Audit waits or runs"
        },
        "open": {
          "type": "boolean",
          "description": "One can start now (POST /api/orders/{id}/followup)"
        },
        "why": {
          "enum": [
            "busy",
            "today",
            "drives_used",
            "closed",
            "finished",
            "not_ready",
            null
          ],
          "description": "What stops one now: busy (one runs), today (one a day: next_at), drives_used (this year's are used), closed (the Audit year ended), finished (you finished it)"
        },
        "next_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "today: when the next can start"
        },
        "finished": {
          "type": "boolean"
        },
        "free": {
          "enum": [
            "confirm",
            "lapse",
            null
          ],
          "description": "The next drive uses none of this year's: confirm (the certificate needs one more drive to agree) or lapse (it checks a fix while your certificate lapses)"
        }
      }
    }
  }
}