{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "gno://schemas/status@1.0",
  "title": "GNO Status",
  "description": "Index status and health information",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "indexName",
    "collections",
    "totalDocuments",
    "totalChunks",
    "embeddingBacklog",
    "healthy",
    "recentErrors",
    "activePreset",
    "capabilities",
    "contentTypeBoost",
    "activation",
    "onboarding",
    "health",
    "background",
    "bootstrap",
    "resident"
  ],
  "properties": {
    "chunking": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "configured",
        "applied",
        "state",
        "pendingDocuments",
        "pendingMirrors"
      ],
      "properties": {
        "configured": {
          "$ref": "#/properties/chunking/definitions/params"
        },
        "applied": {
          "oneOf": [
            {
              "$ref": "#/properties/chunking/definitions/params"
            },
            {
              "type": "null"
            }
          ]
        },
        "state": {
          "type": "string",
          "enum": ["empty", "legacy-default", "current", "pending", "mixed"]
        },
        "pendingDocuments": {
          "type": "integer",
          "minimum": 0
        },
        "pendingMirrors": {
          "type": "integer",
          "minimum": 0
        }
      },
      "definitions": {
        "params": {
          "type": "object",
          "additionalProperties": false,
          "required": ["maxTokens", "overlapPercent"],
          "properties": {
            "maxTokens": {
              "type": "integer",
              "minimum": 10,
              "maximum": 2251799813685247
            },
            "overlapPercent": {
              "type": "number",
              "minimum": 0,
              "maximum": 0.5
            }
          }
        }
      }
    },
    "resident": {
      "$ref": "gno://schemas/resident-status@1.0"
    },
    "indexName": {
      "type": "string",
      "description": "Name of the index"
    },
    "configPath": {
      "type": "string",
      "description": "Path to config file"
    },
    "dbPath": {
      "type": "string",
      "description": "Path to SQLite database"
    },
    "collections": {
      "type": "array",
      "description": "Collection statistics",
      "items": {
        "type": "object",
        "required": [
          "name",
          "path",
          "documentCount",
          "chunkCount",
          "embeddedCount"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Collection name"
          },
          "path": {
            "type": "string",
            "description": "Collection root path"
          },
          "documentCount": {
            "type": "integer",
            "description": "Number of active documents",
            "minimum": 0
          },
          "chunkCount": {
            "type": "integer",
            "description": "Number of content chunks",
            "minimum": 0
          },
          "embeddedCount": {
            "type": "integer",
            "description": "Number of chunks with embeddings",
            "minimum": 0
          }
        }
      }
    },
    "totalDocuments": {
      "type": "integer",
      "description": "Total documents across all collections",
      "minimum": 0
    },
    "totalChunks": {
      "type": "integer",
      "description": "Total chunks across all collections",
      "minimum": 0
    },
    "embeddingBacklog": {
      "type": "integer",
      "description": "Chunks awaiting embedding",
      "minimum": 0
    },
    "recentErrors": {
      "type": "integer",
      "description": "Recent ingest errors in the last 24 hours",
      "minimum": 0
    },
    "lastUpdated": {
      "type": ["string", "null"],
      "description": "Last index update time as an RFC 3339 UTC timestamp",
      "format": "date-time"
    },
    "healthy": {
      "type": "boolean",
      "description": "Overall health status"
    },
    "activePreset": {
      "type": "object",
      "required": ["id", "name"],
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        }
      }
    },
    "capabilities": {
      "type": "object",
      "required": ["bm25", "vector", "hybrid", "answer"],
      "properties": {
        "bm25": {
          "type": "boolean"
        },
        "vector": {
          "type": "boolean"
        },
        "hybrid": {
          "type": "boolean"
        },
        "answer": {
          "type": "boolean"
        }
      }
    },
    "contentTypeBoost": {
      "type": "object",
      "additionalProperties": false,
      "required": ["rulesFingerprint", "rules"],
      "properties": {
        "rulesFingerprint": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "rules": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["id", "searchBoost"],
            "properties": {
              "id": {
                "type": "string",
                "minLength": 1
              },
              "searchBoost": {
                "type": "number",
                "minimum": 0.5,
                "maximum": 2
              }
            }
          }
        }
      }
    },
    "activation": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "schemaVersion",
        "usable",
        "healthy",
        "collections",
        "connectors",
        "connectorProjection"
      ],
      "properties": {
        "schemaVersion": {
          "const": "1.0"
        },
        "usable": {
          "type": "boolean"
        },
        "healthy": {
          "type": "boolean"
        },
        "collections": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "collection",
              "ready",
              "generatedAt",
              "stages",
              "semanticAvailability",
              "remediation"
            ],
            "properties": {
              "collection": {
                "type": "string"
              },
              "ready": {
                "type": "boolean"
              },
              "generatedAt": {
                "type": ["string", "null"],
                "format": "date-time"
              },
              "stages": {
                "type": "object",
                "additionalProperties": false,
                "required": ["index", "lexical", "semantic", "connector"],
                "properties": {
                  "index": {
                    "$ref": "#/properties/activation/definitions/stage"
                  },
                  "lexical": {
                    "$ref": "#/properties/activation/definitions/stage"
                  },
                  "semantic": {
                    "$ref": "#/properties/activation/definitions/stage"
                  },
                  "connector": {
                    "$ref": "#/properties/activation/definitions/stage"
                  }
                }
              },
              "semanticAvailability": {
                "type": "object",
                "additionalProperties": false,
                "required": ["status", "code", "command"],
                "allOf": [
                  {
                    "if": {
                      "properties": {
                        "code": {
                          "const": "vector_unavailable"
                        }
                      },
                      "required": ["code"]
                    },
                    "then": {
                      "properties": {
                        "status": {
                          "const": "skipped"
                        }
                      }
                    }
                  },
                  {
                    "if": {
                      "properties": {
                        "code": {
                          "enum": [
                            "models_missing",
                            "embeddings_pending",
                            "semantic_not_checked"
                          ]
                        }
                      },
                      "required": ["code"]
                    },
                    "then": {
                      "properties": {
                        "status": {
                          "const": "pending"
                        }
                      }
                    }
                  }
                ],
                "properties": {
                  "status": {
                    "enum": ["pending", "skipped"]
                  },
                  "code": {
                    "enum": [
                      "models_missing",
                      "embeddings_pending",
                      "vector_unavailable",
                      "semantic_not_checked"
                    ]
                  },
                  "command": {
                    "type": "string"
                  }
                }
              },
              "remediation": {
                "type": ["object", "null"],
                "additionalProperties": false,
                "required": ["stage", "code", "command", "message"],
                "properties": {
                  "stage": {
                    "enum": ["index", "lexical", "semantic", "connector"]
                  },
                  "code": {
                    "$ref": "#/properties/activation/definitions/code"
                  },
                  "command": {
                    "type": "string"
                  },
                  "message": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "connectors": {
          "type": "array",
          "maxItems": 64,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["collection", "target", "status", "remediation"],
            "properties": {
              "collection": {
                "type": "string"
              },
              "target": {
                "type": "string"
              },
              "status": {
                "enum": ["passed", "pending", "failed", "skipped"]
              },
              "code": {
                "$ref": "#/properties/activation/definitions/code"
              },
              "remediation": {
                "type": ["string", "null"]
              }
            }
          }
        },
        "connectorProjection": {
          "type": "object",
          "additionalProperties": false,
          "required": ["total", "projected", "truncated"],
          "properties": {
            "total": {
              "type": "integer",
              "minimum": 0,
              "description": "All configured collection and connector target pairs before projection bounds."
            },
            "projected": {
              "type": "integer",
              "minimum": 0,
              "maximum": 64,
              "description": "Pairs included in connectors; always equals connectors.length."
            },
            "truncated": {
              "type": "boolean",
              "description": "True exactly when total is greater than projected; omitted pairs have no claimed result."
            }
          }
        }
      },
      "definitions": {
        "code": {
          "enum": [
            "no_documents",
            "index_out_of_sync",
            "no_probe_term",
            "index_query_failed",
            "retrieval_mismatch",
            "semantic_not_checked",
            "connector_not_requested",
            "connector_not_configured",
            "connector_probe_unavailable",
            "connector_unsupported_config",
            "connector_start_failed",
            "connector_timeout",
            "connector_missing_tools",
            "connector_status_failed",
            "connector_search_failed",
            "connector_result_mismatch",
            "target_runtime_unverifiable"
          ]
        },
        "stage": {
          "type": "object",
          "additionalProperties": false,
          "required": ["status", "startedAt", "completedAt", "latencyMs"],
          "properties": {
            "status": {
              "enum": ["passed", "pending", "failed", "skipped"]
            },
            "startedAt": {
              "type": ["string", "null"],
              "format": "date-time"
            },
            "completedAt": {
              "type": ["string", "null"],
              "format": "date-time"
            },
            "latencyMs": {
              "type": ["integer", "null"],
              "minimum": 0
            },
            "code": {
              "$ref": "#/properties/activation/definitions/code"
            }
          }
        }
      }
    },
    "onboarding": {
      "type": "object",
      "required": [
        "ready",
        "stage",
        "headline",
        "detail",
        "suggestedCollections",
        "steps"
      ],
      "properties": {
        "ready": {
          "type": "boolean"
        },
        "stage": {
          "type": "string",
          "enum": ["add-collection", "models", "indexing", "ready"]
        },
        "headline": {
          "type": "string"
        },
        "detail": {
          "type": "string"
        },
        "suggestedCollections": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["label", "path", "reason"],
            "properties": {
              "label": {
                "type": "string"
              },
              "path": {
                "type": "string"
              },
              "reason": {
                "type": "string"
              }
            }
          }
        },
        "steps": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["id", "title", "status", "detail"],
            "properties": {
              "id": {
                "type": "string"
              },
              "title": {
                "type": "string"
              },
              "status": {
                "type": "string",
                "enum": ["complete", "current", "upcoming"]
              },
              "detail": {
                "type": "string"
              },
              "action": {
                "enum": ["add-collection", "download-models", "sync", "embed"]
              }
            }
          }
        }
      }
    },
    "health": {
      "type": "object",
      "required": ["state", "summary", "checks"],
      "properties": {
        "state": {
          "type": "string",
          "enum": ["healthy", "needs-attention", "setup-required"]
        },
        "summary": {
          "type": "string"
        },
        "checks": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["id", "title", "status", "summary", "detail"],
            "properties": {
              "id": {
                "type": "string"
              },
              "title": {
                "type": "string"
              },
              "status": {
                "type": "string",
                "enum": ["ok", "warn", "error"]
              },
              "summary": {
                "type": "string"
              },
              "detail": {
                "type": "string"
              },
              "actionLabel": {
                "type": "string"
              },
              "actionKind": {
                "type": "string",
                "enum": [
                  "add-collection",
                  "open-collections",
                  "sync",
                  "embed",
                  "download-models",
                  "free-space"
                ]
              }
            }
          }
        }
      }
    },
    "background": {
      "type": "object",
      "required": ["watcher", "embedding", "events"],
      "properties": {
        "watcher": {
          "type": "object",
          "required": [
            "expectedCollections",
            "activeCollections",
            "failedCollections",
            "queuedCollections",
            "syncingCollections",
            "lastEventAt",
            "lastSyncAt"
          ],
          "properties": {
            "expectedCollections": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "activeCollections": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "failedCollections": {
              "type": "array",
              "items": {
                "type": "object",
                "required": ["collection", "reason"],
                "properties": {
                  "collection": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  }
                }
              }
            },
            "queuedCollections": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "syncingCollections": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "lastEventAt": {
              "type": ["string", "null"],
              "format": "date-time"
            },
            "lastSyncAt": {
              "type": ["string", "null"],
              "format": "date-time"
            }
          }
        },
        "embedding": {
          "type": "object",
          "required": [
            "available",
            "pendingDocCount",
            "running",
            "nextRunAt",
            "lastRunAt",
            "lastResult"
          ],
          "properties": {
            "available": {
              "type": "boolean"
            },
            "pendingDocCount": {
              "type": "integer",
              "minimum": 0
            },
            "running": {
              "type": "boolean"
            },
            "nextRunAt": {
              "type": ["integer", "null"]
            },
            "lastRunAt": {
              "type": ["integer", "null"]
            },
            "lastResult": {
              "type": ["object", "null"],
              "required": ["embedded", "errors"],
              "properties": {
                "embedded": {
                  "type": "integer",
                  "minimum": 0
                },
                "errors": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            }
          }
        },
        "events": {
          "type": "object",
          "required": ["connectedClients", "retryMs"],
          "properties": {
            "connectedClients": {
              "type": "integer",
              "minimum": 0
            },
            "retryMs": {
              "type": "integer",
              "minimum": 0
            }
          }
        }
      }
    },
    "bootstrap": {
      "type": "object",
      "required": ["runtime", "policy", "cache", "models"],
      "properties": {
        "runtime": {
          "type": "object",
          "required": [
            "kind",
            "strategy",
            "currentVersion",
            "requiredVersion",
            "ready",
            "managedByApp",
            "summary",
            "detail"
          ],
          "properties": {
            "kind": {
              "type": "string",
              "enum": ["bun"]
            },
            "strategy": {
              "type": "string",
              "enum": ["manual-install-beta"]
            },
            "currentVersion": {
              "type": "string"
            },
            "requiredVersion": {
              "type": "string"
            },
            "ready": {
              "type": "boolean"
            },
            "managedByApp": {
              "type": "boolean"
            },
            "summary": {
              "type": "string"
            },
            "detail": {
              "type": "string"
            }
          }
        },
        "policy": {
          "type": "object",
          "required": ["offline", "allowDownload", "source", "summary"],
          "properties": {
            "offline": {
              "type": "boolean"
            },
            "allowDownload": {
              "type": "boolean"
            },
            "source": {
              "type": "string",
              "enum": [
                "default",
                "hf-hub-offline",
                "gno-offline",
                "no-auto-download"
              ]
            },
            "summary": {
              "type": "string"
            }
          }
        },
        "cache": {
          "type": "object",
          "required": ["path", "totalSizeBytes", "totalSizeLabel"],
          "properties": {
            "path": {
              "type": "string"
            },
            "totalSizeBytes": {
              "type": "integer",
              "minimum": 0
            },
            "totalSizeLabel": {
              "type": "string"
            }
          }
        },
        "models": {
          "type": "object",
          "required": [
            "activePresetId",
            "activePresetName",
            "estimatedFootprint",
            "downloading",
            "cachedCount",
            "totalCount",
            "summary",
            "entries"
          ],
          "properties": {
            "activePresetId": {
              "type": "string"
            },
            "activePresetName": {
              "type": "string"
            },
            "estimatedFootprint": {
              "type": ["string", "null"]
            },
            "downloading": {
              "type": "boolean"
            },
            "cachedCount": {
              "type": "integer",
              "minimum": 0
            },
            "totalCount": {
              "type": "integer",
              "minimum": 0
            },
            "summary": {
              "type": "string"
            },
            "entries": {
              "type": "array",
              "items": {
                "type": "object",
                "required": [
                  "role",
                  "uri",
                  "cached",
                  "path",
                  "sizeBytes",
                  "statusLabel"
                ],
                "properties": {
                  "role": {
                    "type": "string",
                    "enum": ["embed", "rerank", "expand", "gen"]
                  },
                  "uri": {
                    "type": "string"
                  },
                  "cached": {
                    "type": "boolean"
                  },
                  "path": {
                    "type": ["string", "null"]
                  },
                  "sizeBytes": {
                    "type": ["integer", "null"],
                    "minimum": 0
                  },
                  "statusLabel": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "memory": {
      "type": "object",
      "description": "Managed-memory diagnostics: record counts and malformed files excluded from recall",
      "additionalProperties": false,
      "required": ["managedCollections", "records", "malformed", "collections"],
      "properties": {
        "managedCollections": {
          "type": "integer",
          "minimum": 0
        },
        "records": {
          "type": "integer",
          "minimum": 0
        },
        "malformed": {
          "type": "integer",
          "minimum": 0
        },
        "collections": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "collection",
              "documents",
              "records",
              "malformed",
              "malformedRecords",
              "truncated"
            ],
            "properties": {
              "collection": {
                "type": "string"
              },
              "documents": {
                "type": "integer",
                "minimum": 0
              },
              "records": {
                "type": "integer",
                "minimum": 0
              },
              "malformed": {
                "type": "integer",
                "minimum": 0
              },
              "truncated": {
                "type": "boolean"
              },
              "malformedRecords": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": ["uri", "relPath", "codes", "diagnostics"],
                  "properties": {
                    "uri": {
                      "type": "string"
                    },
                    "relPath": {
                      "type": "string"
                    },
                    "codes": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "diagnostics": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": false,
                        "required": ["code", "message"],
                        "properties": {
                          "code": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "typedMetadata": {
      "type": "object",
      "additionalProperties": false,
      "required": ["pending", "invalid"],
      "properties": {
        "pending": {
          "type": "integer",
          "minimum": 0
        },
        "invalid": {
          "type": "integer",
          "minimum": 0
        }
      }
    }
  }
}
