{
  "openapi": "3.0.3",
  "info": {
    "title": "rossdata.dev API",
    "version": "1",
    "description": "REST / JSON access to the standard Ross ERP 8.0 schema (FIN + MAN) — tables, columns, keys, DDL, search, knowledge-graph traversal, and the application layer of UI facilities. This is structure, not data: schema definitions only — no business data, customer records, or program source. Read-only, CORS-open, no key required. Please stay under a few requests per second; the data is static and CDN-cached (max-age 1h / s-maxage 24h), so heavy pulls should hit cache. Please cite rossdata.dev. No rights are claimed in the vendor's product, dictionary or documentation.",
    "contact": {
      "name": "rossdata.dev",
      "email": "ross@ryanbrents.com",
      "url": "https://rossdata.dev"
    }
  },
  "servers": [
    {
      "url": "https://api.rossdata.dev"
    }
  ],
  "tags": [
    {
      "name": "Schema",
      "description": "Objects, columns, search."
    },
    {
      "name": "Search",
      "description": "Cross-domain search spanning schema, facilities and programs."
    },
    {
      "name": "Exports",
      "description": "Per-table DDL, SELECT and CSV."
    },
    {
      "name": "Graph",
      "description": "Knowledge-graph neighbours and path-finding."
    },
    {
      "name": "Lineage",
      "description": "Field-level lineage: which column populates which, via which program (derived from DML assignment flow)."
    },
    {
      "name": "Facilities",
      "description": "Application-layer menu facilities (screens, reports, inquiries)."
    },
    {
      "name": "Programs",
      "description": "Application-source program catalog (metadata only), cross-linked to tables."
    },
    {
      "name": "Meta",
      "description": "Service metadata: live usage counters and the contact endpoint."
    }
  ],
  "paths": {
    "/v1/stats": {
      "get": {
        "tags": [
          "Schema"
        ],
        "summary": "Schema overview",
        "description": "One-call overview: counts by type, modules, top tables/columns, coupling.",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Stats"
                }
              }
            }
          }
        }
      }
    },
    "/v1/tables": {
      "get": {
        "tags": [
          "Schema"
        ],
        "summary": "List / filter objects",
        "description": "List / filter objects (tables, views, procedures, functions).",
        "parameters": [
          {
            "name": "type",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "TABLE",
                "VIEW",
                "PROCEDURE",
                "FUNCTION"
              ]
            }
          },
          {
            "name": "db",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "FIN",
                "MAN"
              ]
            }
          },
          {
            "name": "module",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "example": "20"
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ObjectList"
                }
              }
            }
          }
        }
      }
    },
    "/v1/tables/{name}": {
      "get": {
        "tags": [
          "Schema"
        ],
        "summary": "Full object detail",
        "description": "Full object: columns, keys, FKs in/out, related tables, usage.",
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "GL_ACCOUNTS"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TableDetail"
                }
              }
            }
          },
          "404": {
            "description": "No object with that name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/tables/{name}/ddl": {
      "get": {
        "tags": [
          "Exports"
        ],
        "summary": "CREATE TABLE DDL",
        "description": "CREATE TABLE with column-comment docs, PKs and FK constraints. Tables only.",
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "GL_ACCOUNTS"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "Not a table",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/tables/{name}/select": {
      "get": {
        "tags": [
          "Exports"
        ],
        "summary": "Ready SELECT statement",
        "description": "A ready SELECT of every column. Tables only.",
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "GL_ACCOUNTS"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "Not a table",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/tables/{name}/csv": {
      "get": {
        "tags": [
          "Exports"
        ],
        "summary": "Column catalog as CSV",
        "description": "Column catalog as CSV (type, description, valid values, keys). Tables only.",
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "GL_ACCOUNTS"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "Not a table",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/tables/{name}/columns/{col}/lineage": {
      "get": {
        "tags": [
          "Lineage"
        ],
        "summary": "Field-level lineage for one column on one table",
        "description": "Field lineage scoped to a single TABLE.COL: which fields populate it and which it feeds, with the program(s) carrying each flow and direct/via-local + guard/loop tags. Same edge shape as /v1/columns/{name}/lineage.",
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "VENDORS"
          },
          {
            "name": "col",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "LAST_PAYMENT_DATE"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FieldLineage"
                }
              }
            }
          },
          "404": {
            "description": "No field lineage for that column",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/columns/{name}": {
      "get": {
        "tags": [
          "Schema"
        ],
        "summary": "Column across the schema",
        "description": "A single column across the schema: description, valid values, every table carrying it.",
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "POSTING_DATE"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ColumnInfo"
                }
              }
            }
          },
          "404": {
            "description": "No column with that name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/columns/{name}/lineage": {
      "get": {
        "tags": [
          "Lineage"
        ],
        "summary": "Field-level lineage for a column",
        "description": "How a column's data flows, derived from GEMBASE DML assignment flow: which fields populate it and which it feeds, with the program(s) carrying each flow. {name} may be a bare column (schema-wide — aggregated across every table carrying it) or an exact TABLE.COL. Edges are tagged direct (single-statement, EXTRACTED) or via-local (recovered through a #local def-use closure, INFERRED), with guard/loop metadata. Array-element and cross-PERFORM lineage are not yet resolved.",
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "PAYEE_NUMBER"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FieldLineage"
                }
              }
            }
          },
          "404": {
            "description": "No field lineage for that column",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/search": {
      "get": {
        "tags": [
          "Schema"
        ],
        "summary": "Search objects and columns",
        "description": "Search object and column names (and column descriptions).",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "account"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "example": "20"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchResult"
                }
              }
            }
          }
        }
      }
    },
    "/v1/search/all": {
      "get": {
        "tags": [
          "Search"
        ],
        "summary": "Cross-domain search",
        "description": "Search schema objects, columns, UI facilities and programs in one call. Scope with type=object|column|facility|program (default all); limit is per domain.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "check register"
          },
          {
            "name": "type",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "object",
                "column",
                "facility",
                "program"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "example": "10"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnifiedSearchResult"
                }
              }
            }
          }
        }
      }
    },
    "/v1/graph/{name}": {
      "get": {
        "tags": [
          "Graph"
        ],
        "summary": "Knowledge-graph neighbours",
        "description": "Connected programs, tables, views, procedures.",
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "GL_ACCOUNTS"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "example": "100"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GraphResult"
                }
              }
            }
          },
          "404": {
            "description": "No graph node with that name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/path": {
      "get": {
        "tags": [
          "Graph"
        ],
        "summary": "Shortest path between two objects",
        "description": "How A reaches B in the knowledge graph.",
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "GL_ACCOUNTS"
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "GL_POSTINGS"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PathResult"
                }
              }
            }
          },
          "400": {
            "description": "Missing ?from= or ?to=",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/facilities/stats": {
      "get": {
        "tags": [
          "Facilities"
        ],
        "summary": "Application-layer overview",
        "description": "UI facilities by system, database and class.",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FacilityStats"
                }
              }
            }
          }
        }
      }
    },
    "/v1/facilities": {
      "get": {
        "tags": [
          "Facilities"
        ],
        "summary": "List / filter menu facilities",
        "description": "List / filter menu facilities (screens, reports, inquiries, maintenance).",
        "parameters": [
          {
            "name": "system",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "database",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "FIN",
                "MAN"
              ]
            }
          },
          {
            "name": "class",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "REPORT",
                "MAINTENANCE",
                "INQUIRY",
                "UPDATE",
                "TRANSACTION",
                "ARCHIVE",
                "CODES"
              ]
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "withTables",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "",
                "1"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "example": "20"
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FacilityList"
                }
              }
            }
          }
        }
      }
    },
    "/v1/facilities/{code}": {
      "get": {
        "tags": [
          "Facilities"
        ],
        "summary": "Facility detail",
        "description": "A facility in full: program, help, menu paths, and the tables it touches (core + reference).",
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "AP_A_002"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FacilityDetail"
                }
              }
            }
          },
          "404": {
            "description": "No facility with that code",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/facilities/{code}/programs": {
      "get": {
        "tags": [
          "Facilities"
        ],
        "summary": "Programs that implement a facility",
        "description": "Cross-link: the program(s) that run this screen, each tagged with a declared / titleId match label. Complements /v1/programs/{id}/facilities.",
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "AP_A_002"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FacilityPrograms"
                }
              }
            }
          }
        }
      }
    },
    "/v1/facilities/search": {
      "get": {
        "tags": [
          "Facilities"
        ],
        "summary": "Search facilities",
        "description": "Find a screen by code, name, help text, program or tag.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "check register"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "example": "20"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FacilitySearchResult"
                }
              }
            }
          }
        }
      }
    },
    "/v1/tables/{name}/facilities": {
      "get": {
        "tags": [
          "Facilities"
        ],
        "summary": "Reverse: facilities touching a table",
        "description": "Which facilities touch a table — core, reference/lookup, and which of those actually write to it.",
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "GL_ACCOUNTS"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TableFacilities"
                }
              }
            }
          }
        }
      }
    },
    "/v1/programs/stats": {
      "get": {
        "tags": [
          "Programs"
        ],
        "summary": "Program-catalog overview",
        "description": "Program catalog by module and type, with titled / with-tables / vendor-core counts, total program→table edges, read/write counts (withWrites programs, writeEdges program→table write edges), program→program call-graph counts (withCalls, callEdges) and how many programs back a menu facility (withFacilities).",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProgramStats"
                }
              }
            }
          }
        }
      }
    },
    "/v1/programs": {
      "get": {
        "tags": [
          "Programs"
        ],
        "summary": "List / filter programs",
        "description": "List / filter application-source programs (metadata only, no source body).",
        "parameters": [
          {
            "name": "module",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "ap"
          },
          {
            "name": "type",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "r"
          },
          {
            "name": "layer",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "base",
                "vendor-core"
              ]
            }
          },
          {
            "name": "titled",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "",
                "1"
              ]
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "example": "20"
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProgramList"
                }
              }
            }
          }
        }
      }
    },
    "/v1/programs/{id}": {
      "get": {
        "tags": [
          "Programs"
        ],
        "summary": "Program detail",
        "description": "A program in full: module, type, layer, procedures, the Data Dictionary tables it references (each classified read vs read-write), its program→program call graph (calls / calledBy), the menu facilities it backs, and a display name (registry description for untitled programs). Lookup by TITLE id or basename.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "AP_A_002"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProgramDetail"
                }
              }
            }
          },
          "404": {
            "description": "No program with that id or basename",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/programs/{id}/facilities": {
      "get": {
        "tags": [
          "Programs"
        ],
        "summary": "Facilities a program backs",
        "description": "Cross-link: the UI facilities (screens / reports / inquiries) this program implements — one program often serves several. Lookup by TITLE id or basename. Complements /v1/facilities/{code}/programs.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "ap_i_vendors"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProgramFacilities"
                }
              }
            }
          }
        }
      }
    },
    "/v1/programs/search": {
      "get": {
        "tags": [
          "Programs"
        ],
        "summary": "Search programs",
        "description": "Find a program by basename, TITLE id, title, module or type.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "check register"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "example": "20"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProgramSearchResult"
                }
              }
            }
          }
        }
      }
    },
    "/v1/tables/{name}/programs": {
      "get": {
        "tags": [
          "Programs"
        ],
        "summary": "Reverse: programs referencing a table (read/write split)",
        "description": "Which programs reference a table (validated against the Data Dictionary), each classified read vs read-write against this table with a write-site count, writers first. writerCount = how many mutate it. Complements /v1/tables/{name}/facilities.",
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "GL_ACCOUNTS"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TablePrograms"
                }
              }
            }
          }
        }
      }
    },
    "/v1/usage": {
      "get": {
        "tags": [
          "Meta"
        ],
        "summary": "Live API + MCP usage counters",
        "description": "Best-effort server-side call counters for the REST API and MCP server — totals, daily volume, top endpoints/tools. Live (never cached); returns an HTML dashboard when requested with Accept: text/html.",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UsageReport"
                }
              }
            }
          }
        }
      }
    },
    "/contact": {
      "post": {
        "tags": [
          "Meta"
        ],
        "summary": "Send a message to the maintainer",
        "description": "The one write endpoint: emails ross@ryanbrents.com with the submitter set as Reply-To. Honeypot-guarded. Requires the server to be configured with a mail key (503 otherwise).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ContactRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactResult"
                }
              }
            }
          },
          "400": {
            "description": "Body was not valid JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Invalid email or empty message",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Mail service could not be reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Contact is not configured on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Error": {
        "type": "object",
        "description": "Error envelope. `error` is a stable machine code; `message` is human-readable.",
        "properties": {
          "error": {
            "type": "string",
            "example": "not_found"
          },
          "message": {
            "type": "string",
            "example": "No object named NOPE"
          }
        },
        "required": [
          "error",
          "message"
        ]
      },
      "ObjectSummary": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "example": "ACCOUNT_TYPES"
          },
          "type": {
            "type": "string",
            "enum": [
              "table",
              "view",
              "procedure",
              "function"
            ]
          },
          "database": {
            "type": "string",
            "enum": [
              "FIN",
              "MAN"
            ],
            "nullable": true
          },
          "module": {
            "type": "string",
            "nullable": true,
            "example": "ACCOUNT"
          },
          "class": {
            "type": "string",
            "nullable": true,
            "description": "e.g. 'ref' for a lookup table",
            "example": "ref"
          },
          "columns": {
            "type": "integer",
            "example": 9
          },
          "hasPrimaryKey": {
            "type": "boolean"
          },
          "usedByPrograms": {
            "type": "integer",
            "example": 20
          },
          "usedByViewsProcs": {
            "type": "integer",
            "example": 1
          },
          "url": {
            "type": "string",
            "format": "uri",
            "example": "https://dd.rossdata.dev/#ACCOUNT_TYPES"
          }
        }
      },
      "ObjectList": {
        "type": "object",
        "properties": {
          "total": {
            "type": "integer",
            "description": "Total matches before pagination",
            "example": 3130
          },
          "offset": {
            "type": "integer",
            "example": 0
          },
          "limit": {
            "type": "integer",
            "example": 100
          },
          "count": {
            "type": "integer",
            "description": "Objects in this page",
            "example": 100
          },
          "objects": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ObjectSummary"
            }
          }
        }
      },
      "Column": {
        "type": "object",
        "properties": {
          "position": {
            "type": "integer",
            "example": 2
          },
          "name": {
            "type": "string",
            "example": "ACCOUNT_TYPE"
          },
          "type": {
            "type": "string",
            "example": "varchar(1)"
          },
          "nullable": {
            "type": "boolean"
          },
          "primaryKey": {
            "type": "boolean"
          },
          "identity": {
            "type": "boolean"
          },
          "default": {
            "type": "string",
            "nullable": true
          },
          "computedFormula": {
            "type": "string",
            "nullable": true
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "validValues": {
            "type": "string",
            "nullable": true,
            "description": "Enumerated valid values, when documented"
          },
          "notes": {
            "type": "string",
            "nullable": true
          },
          "foreignKey": {
            "type": "object",
            "nullable": true,
            "description": "FK target if this column references another table",
            "properties": {
              "table": {
                "type": "string"
              },
              "column": {
                "type": "string"
              }
            }
          }
        }
      },
      "TableDetail": {
        "type": "object",
        "description": "Full object detail. Additional key/relationship arrays may accompany the fields below.",
        "additionalProperties": true,
        "properties": {
          "object": {
            "type": "string",
            "example": "GL_ACCOUNTS"
          },
          "type": {
            "type": "string",
            "enum": [
              "table",
              "view",
              "procedure",
              "function"
            ]
          },
          "database": {
            "type": "string",
            "enum": [
              "FIN",
              "MAN"
            ],
            "nullable": true
          },
          "module": {
            "type": "string",
            "nullable": true,
            "example": "GL"
          },
          "class": {
            "type": "string",
            "nullable": true
          },
          "source": {
            "type": "string"
          },
          "counts": {
            "type": "object",
            "properties": {
              "columns": {
                "type": "integer"
              },
              "primaryKey": {
                "type": "integer"
              },
              "notNull": {
                "type": "integer"
              },
              "identity": {
                "type": "integer"
              },
              "computed": {
                "type": "integer"
              },
              "foreignKeysOut": {
                "type": "integer"
              },
              "foreignKeysIn": {
                "type": "integer"
              }
            }
          },
          "archiveTwin": {
            "type": "string",
            "nullable": true,
            "description": "Companion archive table, if any"
          },
          "columns": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Column"
            }
          }
        }
      },
      "ColumnInfo": {
        "type": "object",
        "properties": {
          "column": {
            "type": "string",
            "example": "POSTING_DATE"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "validValues": {
            "type": "string",
            "nullable": true
          },
          "notes": {
            "type": "string",
            "nullable": true
          },
          "tableCount": {
            "type": "integer",
            "example": 23
          },
          "tables": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Every table carrying this column"
          },
          "foreignKeyRoles": {
            "type": "array",
            "description": "FK relationships this column participates in",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "url": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "FieldLineageEdge": {
        "type": "object",
        "description": "One field→field flow edge.",
        "properties": {
          "field": {
            "type": "string",
            "example": "VENDORS.PAYEE_NUMBER"
          },
          "table": {
            "type": "string"
          },
          "column": {
            "type": "string"
          },
          "tag": {
            "type": "string",
            "enum": [
              "direct",
              "via-local"
            ],
            "description": "direct = single-statement rhs field ref; via-local = recovered through a #local def-use closure"
          },
          "confidence": {
            "type": "string",
            "enum": [
              "EXTRACTED",
              "INFERRED"
            ]
          },
          "programs": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Programs that carry the flow (up to 6 shown)"
          },
          "programCount": {
            "type": "integer"
          },
          "guarded": {
            "type": "boolean",
            "description": "Present when the write only ever fires inside a conditional"
          },
          "inLoop": {
            "type": "boolean",
            "description": "Present when the write was seen inside a loop body"
          }
        }
      },
      "FieldLineage": {
        "type": "object",
        "additionalProperties": true,
        "description": "Field-level lineage for a column. scope=field for an exact TABLE.COL; scope=schema-wide for a bare column (aggregated across every table carrying it, in `fields`). Edges appear under populatedFrom (in) and feeds (out).",
        "properties": {
          "scope": {
            "type": "string",
            "enum": [
              "field",
              "schema-wide"
            ]
          },
          "schema": {
            "type": "string",
            "example": "Ross ERP 8.0 (standard release)"
          },
          "field": {
            "type": "string",
            "example": "PURCHASE_INVOICES.PAYEE_NUMBER"
          },
          "column": {
            "type": "string",
            "example": "PAYEE_NUMBER"
          },
          "tableCount": {
            "type": "integer",
            "description": "schema-wide only: tables carrying this column that have lineage"
          },
          "counts": {
            "type": "object",
            "properties": {
              "populatedFrom": {
                "type": "integer"
              },
              "feeds": {
                "type": "integer"
              }
            }
          },
          "populatedFrom": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FieldLineageEdge"
            }
          },
          "feeds": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FieldLineageEdge"
            }
          },
          "fields": {
            "type": "array",
            "description": "schema-wide only: per-table lineage nodes",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          }
        }
      },
      "Stats": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "schema": {
            "type": "string",
            "example": "Ross ERP 8.0 (standard release)"
          },
          "modules": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [
              "FIN",
              "MAN"
            ]
          },
          "counts": {
            "type": "object",
            "properties": {
              "table": {
                "type": "integer"
              },
              "view": {
                "type": "integer"
              },
              "procedure": {
                "type": "integer"
              },
              "function": {
                "type": "integer"
              }
            }
          },
          "totalColumns": {
            "type": "integer",
            "example": 36978
          },
          "distinctColumnNames": {
            "type": "integer",
            "example": 8327
          },
          "auditTwinPairs": {
            "type": "integer",
            "example": 195
          },
          "insights": {
            "type": "object",
            "additionalProperties": {
              "type": "integer"
            }
          },
          "topModules": {
            "type": "array",
            "description": "[module, objectCount] pairs, most objects first",
            "items": {
              "type": "array",
              "items": {},
              "example": [
                "SYS",
                158
              ]
            }
          }
        }
      },
      "SearchResult": {
        "type": "object",
        "properties": {
          "query": {
            "type": "string",
            "example": "account"
          },
          "objectCount": {
            "type": "integer"
          },
          "columnCount": {
            "type": "integer"
          },
          "objects": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ObjectSummary"
            }
          },
          "columns": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          }
        }
      },
      "GraphResult": {
        "type": "object",
        "properties": {
          "node": {
            "type": "object",
            "properties": {
              "label": {
                "type": "string",
                "example": "GL_ACCOUNTS"
              },
              "type": {
                "type": "string"
              },
              "module": {
                "type": "string",
                "nullable": true
              },
              "connections": {
                "type": "integer",
                "description": "Total degree of this node",
                "example": 458
              }
            }
          },
          "neighborCount": {
            "type": "integer"
          },
          "neighbors": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "label": {
                  "type": "string"
                },
                "type": {
                  "type": "string",
                  "example": "program"
                },
                "module": {
                  "type": "string",
                  "nullable": true
                },
                "relation": {
                  "type": "string",
                  "example": "accesses"
                },
                "direction": {
                  "type": "string",
                  "enum": [
                    "in",
                    "out"
                  ]
                }
              }
            }
          },
          "links": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "format": "uri"
            }
          }
        }
      },
      "PathResult": {
        "type": "object",
        "properties": {
          "from": {
            "type": "string",
            "example": "GL_ACCOUNTS"
          },
          "to": {
            "type": "string",
            "example": "GL_POSTINGS"
          },
          "found": {
            "type": "boolean"
          },
          "hops": {
            "type": "integer",
            "description": "Edges traversed; 0 when not found",
            "example": 1
          },
          "path": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Ordered node labels from → to"
          },
          "error": {
            "type": "string",
            "nullable": true,
            "description": "Present when found=false, e.g. unknown_from / unknown_to / no_path"
          }
        }
      },
      "FacilityStats": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "schema": {
            "type": "string"
          },
          "layer": {
            "type": "string",
            "example": "application (client menu TOC)"
          },
          "source": {
            "type": "string"
          },
          "counts": {
            "type": "object",
            "additionalProperties": {
              "type": "integer"
            }
          },
          "systems": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string",
                  "example": "ACCOUNTS_PAYABLE"
                },
                "n": {
                  "type": "integer"
                }
              }
            }
          }
        }
      },
      "FacilitySummary": {
        "type": "object",
        "properties": {
          "facility": {
            "type": "string",
            "example": "AP_A_002"
          },
          "name": {
            "type": "string",
            "example": "Check Register"
          },
          "system": {
            "type": "string",
            "example": "ACCOUNTS_PAYABLE"
          },
          "database": {
            "type": "string",
            "enum": [
              "FIN",
              "MAN"
            ],
            "nullable": true
          },
          "class": {
            "type": "string",
            "nullable": true,
            "example": "ARCHIVE"
          },
          "program": {
            "type": "string",
            "nullable": true,
            "example": "GEMAP:AP_A_CHECK_REGISTER"
          },
          "coreTables": {
            "type": "integer",
            "description": "Count of core working-set tables"
          },
          "referenceTables": {
            "type": "integer",
            "description": "Count of reference/lookup tables"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "example": "https://toc.rossdata.dev/#AP_A_002"
          }
        }
      },
      "FacilityList": {
        "type": "object",
        "properties": {
          "total": {
            "type": "integer",
            "example": 2327
          },
          "offset": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          },
          "count": {
            "type": "integer"
          },
          "facilities": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FacilitySummary"
            }
          }
        }
      },
      "FacilitySearchResult": {
        "type": "object",
        "properties": {
          "query": {
            "type": "string",
            "example": "check register"
          },
          "count": {
            "type": "integer"
          },
          "facilities": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FacilitySummary"
            }
          }
        }
      },
      "FacilityTable": {
        "type": "object",
        "properties": {
          "table": {
            "type": "string",
            "example": "COMPANY_CONTROLS"
          },
          "accesses": {
            "type": "integer",
            "description": "Times the program source references this table"
          },
          "database": {
            "type": "string",
            "enum": [
              "FIN",
              "MAN"
            ],
            "nullable": true
          },
          "writes": {
            "type": "integer",
            "description": "Write hits (FIND…/LOCK=WRITE, ADD TO, DELETE FROM); 0 = read-only"
          },
          "url": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "FacilityDetail": {
        "type": "object",
        "properties": {
          "facility": {
            "type": "string",
            "example": "AP_A_002"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "help": {
            "type": "string",
            "nullable": true
          },
          "system": {
            "type": "string"
          },
          "database": {
            "type": "string",
            "enum": [
              "FIN",
              "MAN"
            ],
            "nullable": true
          },
          "class": {
            "type": "string",
            "nullable": true
          },
          "program": {
            "type": "string",
            "nullable": true
          },
          "tag": {
            "type": "string",
            "nullable": true,
            "example": "CHECKREG"
          },
          "aliases": {
            "type": "array",
            "nullable": true,
            "items": {
              "type": "string"
            }
          },
          "menuPaths": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "tables": {
            "type": "object",
            "properties": {
              "core": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/FacilityTable"
                },
                "description": "Working-set tables"
              },
              "reference": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/FacilityTable"
                },
                "description": "Control/lookup tables"
              }
            }
          }
        }
      },
      "FacilityRef": {
        "type": "object",
        "properties": {
          "facility": {
            "type": "string",
            "example": "SOP_M_023"
          },
          "name": {
            "type": "string"
          },
          "system": {
            "type": "string",
            "nullable": true
          },
          "class": {
            "type": "string",
            "nullable": true
          },
          "accesses": {
            "type": "integer",
            "description": "Read/reference count (asCore/asReference lists)"
          },
          "writes": {
            "type": "integer",
            "description": "Write count (asWriter list only)"
          },
          "url": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "TableFacilities": {
        "type": "object",
        "properties": {
          "table": {
            "type": "string",
            "example": "GL_ACCOUNTS"
          },
          "found": {
            "type": "boolean"
          },
          "asCoreCount": {
            "type": "integer"
          },
          "asReferenceCount": {
            "type": "integer"
          },
          "asWriterCount": {
            "type": "integer"
          },
          "asCore": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FacilityRef"
            }
          },
          "asReference": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FacilityRef"
            }
          },
          "asWriter": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FacilityRef"
            }
          },
          "note": {
            "type": "string"
          },
          "links": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "format": "uri"
            }
          }
        }
      },
      "ProgramSummary": {
        "type": "object",
        "properties": {
          "basename": {
            "type": "string",
            "example": "ap_a_check_register"
          },
          "programId": {
            "type": "string",
            "nullable": true,
            "description": "Declared TITLE id; null for internal programs",
            "example": "AP_A_002"
          },
          "title": {
            "type": "string",
            "nullable": true,
            "example": "Check Register Cleardown Report"
          },
          "name": {
            "type": "string",
            "nullable": true,
            "description": "Display name — the TITLE label, or the registry description of a menu facility it backs for untitled programs"
          },
          "module": {
            "type": "string",
            "example": "ap"
          },
          "moduleName": {
            "type": "string",
            "nullable": true,
            "example": "Accounts Payable"
          },
          "type": {
            "type": "string",
            "nullable": true,
            "description": "Program-type letter",
            "example": "a"
          },
          "typeName": {
            "type": "string",
            "nullable": true,
            "example": "archive"
          },
          "layer": {
            "type": "string",
            "enum": [
              "base",
              "vendor-core"
            ]
          },
          "tableCount": {
            "type": "integer",
            "description": "Data Dictionary tables referenced"
          },
          "writeCount": {
            "type": "integer",
            "description": "Of the referenced tables, how many the program writes to (FIND IN.../LOCK=WRITE, ADD, or DELETE)"
          },
          "procedureCount": {
            "type": "integer",
            "description": "PROCEDURE_FORM blocks"
          },
          "callsCount": {
            "type": "integer",
            "description": "Programs this one invokes (outbound call edges)"
          },
          "calledByCount": {
            "type": "integer",
            "description": "Programs that invoke this one"
          },
          "menuCount": {
            "type": "integer",
            "description": "Menu facilities this program backs"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "example": "https://pg.rossdata.dev/#ap_a_check_register"
          }
        }
      },
      "ProgramCallEdge": {
        "type": "object",
        "description": "One end of a program→program invocation (PERFORM \"GEM<mod>:<prog>\").",
        "properties": {
          "basename": {
            "type": "string",
            "example": "gl_s_post_engine"
          },
          "name": {
            "type": "string",
            "nullable": true,
            "description": "TITLE label or registry description of the target program"
          },
          "calls": {
            "type": "integer",
            "description": "Number of call sites"
          },
          "external": {
            "type": "boolean",
            "description": "An explicit EXTERNAL_ENTRY launch"
          },
          "url": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "ProgramMenuFacility": {
        "type": "object",
        "description": "A menu facility this program backs (GEM_FACILITIES /DML). See /v1/programs/{id}/facilities for match provenance.",
        "properties": {
          "facility": {
            "type": "string",
            "example": "AP_A_002"
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "url": {
            "type": "string",
            "format": "uri",
            "example": "https://toc.rossdata.dev/#AP_A_002"
          }
        }
      },
      "ProgramList": {
        "type": "object",
        "properties": {
          "total": {
            "type": "integer",
            "example": 3327
          },
          "offset": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          },
          "count": {
            "type": "integer"
          },
          "programs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProgramSummary"
            }
          }
        }
      },
      "ProgramSearchResult": {
        "type": "object",
        "properties": {
          "query": {
            "type": "string",
            "example": "check register"
          },
          "count": {
            "type": "integer"
          },
          "programs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProgramSummary"
            }
          }
        }
      },
      "ProgramDetail": {
        "type": "object",
        "properties": {
          "basename": {
            "type": "string",
            "example": "ap_a_check_register"
          },
          "programId": {
            "type": "string",
            "nullable": true,
            "example": "AP_A_002"
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "name": {
            "type": "string",
            "nullable": true,
            "description": "Display name — TITLE label, or the registry description of a menu facility it backs for untitled programs"
          },
          "registryDescription": {
            "type": "string",
            "nullable": true,
            "description": "Canonical description of a menu facility this program backs (GEM_FACILITIES)"
          },
          "module": {
            "type": "string",
            "example": "ap"
          },
          "moduleName": {
            "type": "string",
            "nullable": true,
            "example": "Accounts Payable"
          },
          "type": {
            "type": "string",
            "nullable": true,
            "example": "a"
          },
          "typeName": {
            "type": "string",
            "nullable": true,
            "example": "archive"
          },
          "layer": {
            "type": "string",
            "enum": [
              "base",
              "vendor-core"
            ]
          },
          "overrides": {
            "type": "string",
            "nullable": true,
            "description": "Layer this vendor-core program overrides"
          },
          "procedureCount": {
            "type": "integer"
          },
          "procedures": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "PROCEDURE_FORM block names"
          },
          "tableCount": {
            "type": "integer"
          },
          "writeCount": {
            "type": "integer",
            "description": "Of the referenced tables, how many the program writes to"
          },
          "tables": {
            "type": "array",
            "description": "Data Dictionary tables the program references, each classified read vs read-write. Writes are parsed from the source (FIND IN.../LOCK=WRITE update, ADD insert, DELETE); everything else is read-only.",
            "items": {
              "type": "object",
              "properties": {
                "table": {
                  "type": "string",
                  "example": "AP_CONTROLS"
                },
                "access": {
                  "type": "string",
                  "enum": [
                    "read",
                    "read-write"
                  ],
                  "description": "read-write if the program writes to the table, else read"
                },
                "writes": {
                  "type": "integer",
                  "description": "Number of write sites (0 for a read-only reference)"
                },
                "url": {
                  "type": "string",
                  "format": "uri"
                }
              }
            }
          },
          "calls": {
            "type": "object",
            "nullable": true,
            "description": "Program→program call graph. null when the program neither calls nor is called.",
            "properties": {
              "callsCount": {
                "type": "integer"
              },
              "calledByCount": {
                "type": "integer"
              },
              "calls": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ProgramCallEdge"
                },
                "description": "Programs this one invokes"
              },
              "calledBy": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ProgramCallEdge"
                },
                "description": "Programs that invoke this one"
              },
              "note": {
                "type": "string"
              }
            }
          },
          "menu": {
            "type": "array",
            "nullable": true,
            "items": {
              "$ref": "#/components/schemas/ProgramMenuFacility"
            },
            "description": "Menu facilities this program backs; null if none"
          },
          "source": {
            "type": "string"
          },
          "links": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "format": "uri"
            }
          }
        }
      },
      "ProgramStats": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "schema": {
            "type": "string"
          },
          "layer": {
            "type": "string",
            "example": "application source (program catalog)"
          },
          "source": {
            "type": "string"
          },
          "counts": {
            "type": "object",
            "additionalProperties": {
              "type": "integer"
            }
          },
          "modules": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string",
                  "example": "ap"
                },
                "name": {
                  "type": "string",
                  "nullable": true
                },
                "n": {
                  "type": "integer"
                }
              }
            }
          },
          "types": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string",
                  "example": "r"
                },
                "name": {
                  "type": "string",
                  "nullable": true,
                  "example": "report"
                },
                "n": {
                  "type": "integer"
                }
              }
            }
          }
        }
      },
      "TablePrograms": {
        "type": "object",
        "properties": {
          "table": {
            "type": "string",
            "example": "GL_ACCOUNTS"
          },
          "found": {
            "type": "boolean"
          },
          "count": {
            "type": "integer"
          },
          "programs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProgramSummary"
            }
          },
          "note": {
            "type": "string"
          },
          "links": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "format": "uri"
            }
          }
        }
      },
      "UnifiedSearchResult": {
        "type": "object",
        "description": "Cross-domain search hits across all four layers. Each array is capped at `limit` (per domain).",
        "properties": {
          "query": {
            "type": "string",
            "example": "check register"
          },
          "type": {
            "type": "string",
            "enum": [
              "all",
              "object",
              "column",
              "facility",
              "program"
            ],
            "example": "all"
          },
          "counts": {
            "type": "object",
            "properties": {
              "objects": {
                "type": "integer"
              },
              "columns": {
                "type": "integer"
              },
              "facilities": {
                "type": "integer"
              },
              "programs": {
                "type": "integer"
              },
              "total": {
                "type": "integer"
              }
            }
          },
          "objects": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ObjectSummary"
            }
          },
          "columns": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "facilities": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FacilitySummary"
            }
          },
          "programs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProgramSummary"
            }
          },
          "note": {
            "type": "string"
          }
        }
      },
      "LinkMatch": {
        "type": "string",
        "enum": [
          "declared",
          "titleId",
          "declared+titleId"
        ],
        "description": "How the facility↔program link was derived: declared = named by the facility's menu entry (authoritative); titleId = TITLE id equals the facility code; declared+titleId = both agree."
      },
      "FacilityPrograms": {
        "type": "object",
        "description": "The program(s) that implement a UI facility.",
        "properties": {
          "facility": {
            "type": "string",
            "example": "AP_A_002"
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "declares": {
            "type": "string",
            "nullable": true,
            "description": "The GEM<mod>:<program> the menu entry launches",
            "example": "GEMAP:AP_A_CHECK_REGISTER"
          },
          "found": {
            "type": "boolean"
          },
          "count": {
            "type": "integer"
          },
          "programs": {
            "type": "array",
            "items": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/ProgramSummary"
                },
                {
                  "type": "object",
                  "properties": {
                    "match": {
                      "$ref": "#/components/schemas/LinkMatch"
                    }
                  }
                }
              ]
            }
          },
          "note": {
            "type": "string"
          },
          "links": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "format": "uri"
            }
          }
        }
      },
      "ProgramFacilities": {
        "type": "object",
        "description": "The UI facilities (screens / reports / inquiries) a program backs. One program often serves several.",
        "properties": {
          "program": {
            "type": "string",
            "example": "ap_i_vendors"
          },
          "programId": {
            "type": "string",
            "nullable": true,
            "example": "AP_I_001"
          },
          "found": {
            "type": "boolean"
          },
          "count": {
            "type": "integer"
          },
          "facilities": {
            "type": "array",
            "items": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/FacilitySummary"
                },
                {
                  "type": "object",
                  "properties": {
                    "match": {
                      "$ref": "#/components/schemas/LinkMatch"
                    }
                  }
                }
              ]
            }
          },
          "note": {
            "type": "string"
          },
          "links": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "format": "uri"
            }
          }
        }
      },
      "ContactRequest": {
        "type": "object",
        "description": "Contact-form submission. `company` / `website` are honeypots — leave them empty.",
        "required": [
          "email",
          "message"
        ],
        "properties": {
          "name": {
            "type": "string",
            "nullable": true,
            "example": "Jane Analyst"
          },
          "email": {
            "type": "string",
            "format": "email",
            "example": "jane@example.com"
          },
          "message": {
            "type": "string",
            "example": "Question about the GL_ACCOUNTS FK layout…"
          },
          "source": {
            "type": "string",
            "nullable": true,
            "description": "Where the message originated",
            "example": "rossdata.dev"
          }
        }
      },
      "ContactResult": {
        "type": "object",
        "required": [
          "ok"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "id": {
            "type": "string",
            "nullable": true,
            "description": "Provider message id, on success"
          },
          "error": {
            "type": "string",
            "nullable": true,
            "description": "Stable machine code when ok=false"
          },
          "message": {
            "type": "string",
            "nullable": true,
            "description": "Human-readable detail"
          }
        }
      },
      "UsageReport": {
        "type": "object",
        "additionalProperties": true,
        "description": "Best-effort server-side call counters, durable across deploys. Live — never cached.",
        "properties": {
          "configured": {
            "type": "boolean",
            "description": "Whether a counter store (Vercel KV / Upstash) is linked"
          },
          "generated": {
            "type": "string",
            "format": "date-time"
          },
          "totals": {
            "type": "object",
            "properties": {
              "all": {
                "type": "integer"
              },
              "mcp": {
                "type": "integer"
              },
              "rest": {
                "type": "integer"
              }
            }
          },
          "firstSeen": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          },
          "lastSeen": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          }
        }
      }
    }
  }
}
