{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/trooth-co/json-schema/trooth-co-public-mesh-schema.json",
  "title": "PublicMesh",
  "x-generated": "2026-11-27",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/trooth-co-openapi.json#/components/schemas/PublicMesh",
  "type": "object",
  "required": [
    "company",
    "frameworks",
    "pillars",
    "providers",
    "controls"
  ],
  "properties": {
    "sample": {
      "type": "boolean"
    },
    "company": {
      "type": "object",
      "required": [
        "name",
        "handle",
        "updatedAt"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "handle": {
          "type": "string"
        },
        "updatedAt": {
          "type": "string",
          "description": "The last edit to the company. Not an observation time."
        }
      }
    },
    "frameworks": {
      "type": "array",
      "maxItems": 0,
      "description": "Retired 2026-09-26; always empty."
    },
    "pillars": {
      "type": "array",
      "description": "One entry per area, on /api/public-mesh/{handle} (lib/public-pillars.ts).",
      "items": {
        "type": "object",
        "required": [
          "id",
          "label",
          "status",
          "observedAt",
          "sourceRef"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "restricted": {
            "type": "boolean",
            "description": "Present, and true, only when the area is held behind access controls. Restricted is not the same as not published."
          },
          "observedAt": {
            "type": [
              "string",
              "null"
            ],
            "description": "Added 2026-10-04; always present since 2026-10-09. When Trooth last read this area, as the upstream states it for the area. null when no per-area read time is recorded or the area is restricted: an unrecorded date reads as unknown, never borrowed from another area, a provider's lastSync or company.updatedAt."
          },
          "sourceRef": {
            "type": [
              "string",
              "null"
            ],
            "description": "Added 2026-10-04; always present since 2026-10-09. The upstream's reference to the reading behind this area. null when it gives none or the area is restricted."
          }
        }
      }
    },
    "providers": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "label",
          "status"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "lastSync": {
            "type": "string",
            "description": "Kept for older readers. Since 2026-10-04 it dates no area and no badge: the newest provider read says nothing about the age of an unrelated area."
          }
        }
      }
    },
    "rollup": {
      "type": "array",
      "description": "Added 2026-10-04. Every area as one fact, held to its own category window (lib/evidence.ts FRESHNESS_POLICY). observedAt is null and freshness unknown when no per-area read time is published; unknown is never shown as current.",
      "items": {
        "type": "object",
        "required": [
          "pillarId",
          "label",
          "status",
          "counted",
          "evidenceClass",
          "observation",
          "sourceRef",
          "observedAt",
          "validity",
          "freshness",
          "scope",
          "unknown"
        ],
        "properties": {
          "pillarId": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "status": {
            "enum": [
              "witnessed",
              "attention",
              "failing",
              "not_started",
              "restricted"
            ]
          },
          "counted": {
            "type": "boolean"
          },
          "evidenceClass": {
            "enum": [
              "trooth_observation",
              "no_evidence",
              "restricted"
            ]
          },
          "observation": {
            "type": "string"
          },
          "sourceRef": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "type": "string"
              }
            ]
          },
          "observedAt": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "type": "string"
              }
            ]
          },
          "validity": {
            "type": "object",
            "required": [
              "category",
              "windowDays",
              "validUntil"
            ],
            "properties": {
              "category": {
                "type": "string"
              },
              "windowDays": {
                "type": "integer"
              },
              "validUntil": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "type": "string"
                  }
                ]
              }
            }
          },
          "freshness": {
            "enum": [
              "current",
              "due",
              "stale",
              "unknown"
            ]
          },
          "scope": {
            "type": "object",
            "required": [
              "subject",
              "scope",
              "area"
            ],
            "properties": {
              "subject": {
                "type": "string"
              },
              "scope": {
                "const": "company"
              },
              "area": {
                "type": "string"
              }
            }
          },
          "unknown": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      }
    },
    "badge": {
      "type": "object",
      "description": "Added 2026-10-04. The state and the two lines the badge script and the badge image print, derived from rollup.",
      "required": [
        "kind",
        "line",
        "detail",
        "asOf",
        "counted",
        "witnessed",
        "staleAreas",
        "undatedAreas",
        "restrictedAreas"
      ],
      "properties": {
        "kind": {
          "enum": [
            "witnessed",
            "partial",
            "listed"
          ]
        },
        "line": {
          "type": "string"
        },
        "detail": {
          "type": "string"
        },
        "asOf": {
          "oneOf": [
            {
              "type": "null"
            },
            {
              "type": "string"
            }
          ],
          "description": "The oldest read of the witnessed areas, only when every one is dated."
        },
        "counted": {
          "type": "integer"
        },
        "witnessed": {
          "type": "integer"
        },
        "staleAreas": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "undatedAreas": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "restrictedAreas": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "controls": {
      "type": "array",
      "maxItems": 0
    },
    "freshness30d": {
      "type": "integer"
    },
    "disclaimer": {
      "type": "string"
    },
    "retired": {
      "type": "object"
    }
  }
}