Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions api-coverage-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ and update `reviewed_at`.
| Metric | Value |
| --- | ---: |
| Reconciliation status | PASS |
| Published operations | 199 |
| Published operations | 208 |
| First-class CLI operations | 131 |
| Reviewed gaps | 68 |
| Reviewed gaps | 77 |
| Client operations | 155 |
| Published request fields on covered operations | 477 |
| Request fields modeled by the CLI | 476 |
| Reviewed request-field gaps | 1 |
| Published header and query parameters on covered operations | 196 |
| Published header and query parameters on covered operations | 197 |
| Parameters the CLI can send | 144 |
| Reviewed parameter gaps | 52 |
| Reviewed parameter gaps | 53 |
| Reviewed gaps overdue for re-review | 0 |
| Earliest re-review deadline | 2026-11-27 |

Expand Down Expand Up @@ -80,18 +80,25 @@ Catalog: https://api.coval.dev/v1/openapi
- `GET /alerts`
- `GET /alerts/{alert_id}`
- `GET /alerts/{alert_id}/events`
- `GET /clustering-assignments`
- `GET /clustering-runs`
- `GET /clustering-runs/latest`
- `GET /clustering-runs/{run_id}`
- `GET /conversation-python-analyses/{analysis_id}`
- `GET /conversations/simulated/{conversation_id}/comments`
- `GET /conversations/simulated/{conversation_id}/comments/{comment_id}`
- `GET /conversations/uploaded/{conversation_id}/comments`
- `GET /conversations/uploaded/{conversation_id}/comments/{comment_id}`
- `GET /integrations/slack`
- `GET /metrics/catalog`
- `GET /metrics/catalog/{entry_id}`
- `GET /metrics/flows`
- `GET /metrics/recently-deleted`
- `GET /metrics/sql-schema`
- `GET /metrics/tags`
- `GET /metrics/template-variables`
- `GET /metrics/{metric_id}/baselines/{baseline_id}/history`
- `GET /organization/caller-id`
- `GET /organization/conversation-metrics`
- `GET /organization/monitoring-metrics`
- `GET /organization/users`
Expand All @@ -111,6 +118,7 @@ Catalog: https://api.coval.dev/v1/openapi
- `GET /webhooks`
- `PATCH /alerts/{alert_id}`
- `PATCH /metrics/flows/{flow_id}`
- `PATCH /organization/caller-id`
- `PATCH /organization/conversation-metrics`
- `PATCH /organization/monitoring-metrics`
- `PATCH /webhooks/{webhook_id}`
Expand All @@ -122,6 +130,7 @@ Catalog: https://api.coval.dev/v1/openapi
- `POST /conversation-python-analyses`
- `POST /conversations/simulated:rerunMetrics`
- `POST /integrations/slack/connect`
- `POST /metrics/catalog/{entry_id}/copy`
- `POST /metrics/flows`
- `POST /metrics/outputs:batchGet`
- `POST /metrics/sql:test`
Expand Down Expand Up @@ -208,6 +217,7 @@ Catalog: https://api.coval.dev/v1/openapi
- `GET /conversations/uploaded/{id}/metrics query page_token`
- `GET /conversations/uploaded/{id}/metrics query view`
- `GET /metrics query tag_filters`
- `GET /metrics/{id} query include`
- `GET /metrics/{id}/baselines query agent_id`
- `GET /metrics/{id}/baselines query persona_id`
- `GET /metrics/{id}/baselines query sigma_levels`
Expand Down
58 changes: 55 additions & 3 deletions api-coverage.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

[snapshot]
catalog_url = "https://api.coval.dev/v1/openapi"
reviewed_at = "2026-11-16"
published_operations = 199
reviewed_at = "2026-11-24"
published_operations = 208
cli_supported_operations = 131
published_request_fields = 477
cli_modeled_request_fields = 476
published_parameters = 196
published_parameters = 197
cli_supported_parameters = 144

[gap_review]
Expand Down Expand Up @@ -902,3 +902,55 @@ operation = "GET /api-keys"
in = "query"
name = "environment"
reason = "Served by the public API, which filters keys by environment, but omitted from its published OpenAPI parameters."

[[known_gap]]
operation = "GET /clustering-assignments"
reason = "Cluster-assignment browsing needs dedicated command and pagination UX; this new command family remains to be modeled under COVAL-2079."
reviewed_at = "2026-11-24"

[[known_gap]]
operation = "GET /clustering-runs"
reason = "Clustering-run discovery and pagination need a dedicated command family under COVAL-2079."
reviewed_at = "2026-11-24"

[[known_gap]]
operation = "GET /clustering-runs/latest"
reason = "Latest clustering-run lookup remains part of the unmodeled clustering command family under COVAL-2079."
reviewed_at = "2026-11-24"

[[known_gap]]
operation = "GET /clustering-runs/{run_id}"
reason = "Clustering-run details remain part of the unmodeled clustering command family under COVAL-2079."
reviewed_at = "2026-11-24"

[[known_gap]]
operation = "GET /metrics/catalog"
reason = "Shared metric-catalog discovery needs dedicated command and pagination UX under COVAL-2079."
reviewed_at = "2026-11-24"

[[known_gap]]
operation = "GET /metrics/catalog/{entry_id}"
reason = "Shared metric-catalog entry inspection remains part of the unmodeled catalog command family under COVAL-2079."
reviewed_at = "2026-11-24"

[[known_gap]]
operation = "POST /metrics/catalog/{entry_id}/copy"
reason = "Copying a shared catalog entry into the active organization requires explicit destination and mutation UX under COVAL-2079."
reviewed_at = "2026-11-24"

[[known_gap]]
operation = "GET /organization/caller-id"
reason = "Organization caller-ID pool and carrier-authorized ANI configuration have no first-class CLI command yet; track the new command family under COVAL-2079."
reviewed_at = "2026-11-24"

[[known_gap]]
operation = "PATCH /organization/caller-id"
reason = "Replacing carrier-verified organization ANI allowlists needs dedicated validation and mutation UX under COVAL-2079; this audit does not introduce caller-ID administration."
reviewed_at = "2026-11-24"

[[known_parameter_gap]]
operation = "GET /metrics/{metric_id}"
in = "query"
name = "include"
reason = "The reviewed_audit_admission expansion exposes a bounded human-review capability; dedicated audit-admission UX remains to be modeled under COVAL-2079."
reviewed_at = "2026-11-24"
51 changes: 40 additions & 11 deletions scripts/audit_api_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,25 @@ def _canonical_operation(method: str, path: str) -> str:
return f"{method.upper()} {path}"


class PublishedSpecs(list):
def __init__(self, documents: dict[str, dict]):
super().__init__(documents.values())
self.documents = documents


def _published_specs(catalog_url: str, allowed_origins: frozenset[str]) -> list[dict]:
"""Fetch the catalog index and every per-resource spec exactly once."""

catalog = json.loads(_fetch(catalog_url, allowed_origins))
return [
yaml.safe_load(_fetch(entry["url"], allowed_origins))
for entry in catalog["specs"]
]
documents = {}
for entry in catalog["specs"]:
stem = urlsplit(entry["url"]).path.rsplit("/", 1)[-1].removesuffix(".yaml")
if not re.fullmatch(r"[A-Za-z0-9][A-Za-z0-9_-]*", stem):
raise RuntimeError(f"invalid catalog document stem {stem!r}")
if entry.get("name", stem) != stem or stem in documents:
raise RuntimeError(f"ambiguous catalog document stem {stem!r}")
documents[stem] = yaml.safe_load(_fetch(entry["url"], allowed_origins))
return PublishedSpecs(documents)


def _published_operations(specs: list[dict]) -> dict[str, str]:
Expand Down Expand Up @@ -217,17 +228,33 @@ def _parameter_key(location: str, name: str) -> tuple[str, str]:
return (location, name.lower() if location == "header" else name)


def _resolve_parameter(parameter: dict, components: dict) -> dict:
def _resolve_parameter(
parameter: dict,
components: dict,
documents: dict[str, dict] | None = None,
seen: frozenset[tuple[int, str]] = frozenset(),
) -> dict:
reference = parameter.get("$ref")
if reference is None:
return parameter
prefix = "#/components/parameters/"
if not reference.startswith(prefix):
document, separator, fragment = reference.partition("#")
prefix = "/components/parameters/"
if not separator or not fragment.startswith(prefix):
raise RuntimeError(f"unsupported parameter reference {reference!r}")
target = components.get(reference.removeprefix(prefix))
if document:
document = document.removeprefix("./")
stem = document.removesuffix(".yaml")
if document != f"{stem}.yaml" or stem not in (documents or {}):
raise RuntimeError(f"unsupported parameter reference {reference!r}")
components = (documents[stem].get("components") or {}).get("parameters") or {}
name = fragment.removeprefix(prefix)
identity = (id(components), name)
if identity in seen:
raise RuntimeError(f"cyclic parameter reference {reference!r}")
target = components.get(name)
if target is None:
raise RuntimeError(f"parameter references unknown component {reference!r}")
return _resolve_parameter(target, components)
return _resolve_parameter(target, components, documents, seen | {identity})


def _published_parameters(
Expand All @@ -236,7 +263,7 @@ def _published_parameters(
"""Map each published operation to its header and query parameter keys.

Path-level parameters apply to every operation on the path, and references
to ``components/parameters`` are resolved within the same spec. The second
to ``components/parameters`` use only documents fetched from the catalog. The second
value maps each key to its published spelling for the report.
"""

Expand All @@ -252,7 +279,9 @@ def _published_parameters(
continue
keys = parameters.setdefault(_canonical_operation(method, path), set())
for parameter in [*shared, *(operation.get("parameters") or [])]:
parameter = _resolve_parameter(parameter, components)
parameter = _resolve_parameter(
parameter, components, getattr(specs, "documents", {})
)
location = parameter.get("in")
name = parameter.get("name")
if location not in PARAMETER_LOCATIONS or not name:
Expand Down
140 changes: 140 additions & 0 deletions scripts/test_audit_api_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import datetime
import io
import json
import tempfile
import tomllib
import unittest
Expand Down Expand Up @@ -1371,6 +1372,145 @@ def test_rejects_a_reference_outside_components_parameters(self):
with self.assertRaisesRegex(RuntimeError, "unsupported parameter reference"):
audit_api_coverage._published_parameters([spec])

@staticmethod
def _catalog_specs(documents):
catalog = {
"specs": [
{"name": name, "url": f"https://api.coval.dev/v1/openapi/{name}"}
for name in documents
]
}
with patch("scripts.audit_api_coverage._fetch") as fetch:
fetch.side_effect = [
json.dumps(catalog).encode(),
*(json.dumps(document).encode() for document in documents.values()),
]
specs = audit_api_coverage._published_specs(
audit_api_coverage.CATALOG_URL,
audit_api_coverage.DEFAULT_ALLOWED_ORIGINS,
)
self_calls = fetch.call_count
if self_calls != len(documents) + 1:
raise AssertionError("References must not fetch additional documents")
return specs

def test_resolves_only_catalog_backed_cross_spec_parameter_refs(self):
specs = self._catalog_specs(
{
"metric-catalog": {
"paths": {
"/metric-catalog": {
"get": {
"parameters": [
{
"$ref": "metrics.yaml#/components/parameters/WorkspaceId"
}
]
}
}
},
"components": {
"parameters": {
"WorkspaceId": {"name": "wrong-local-name", "in": "query"}
}
},
},
"metrics": {
"components": {
"parameters": {
"WorkspaceId": {"$ref": "#/components/parameters/Actual"},
"Actual": {"name": "X-Coval-Workspace-Id", "in": "header"},
}
}
},
}
)
parameters, _ = audit_api_coverage._published_parameters(specs)
self.assertEqual(
{"GET /metric-catalog": {("header", "x-coval-workspace-id")}}, parameters
)

def test_accepts_publisher_dot_prefix_and_manifest_slug_spelling(self):
specs = self._catalog_specs(
{
"metrics": {
"paths": {
"/metrics": {
"get": {
"parameters": [
{
"$ref": "./Metric_1.yaml#/components/parameters/WorkspaceId"
}
]
}
}
}
},
"Metric_1": {
"components": {
"parameters": {
"WorkspaceId": {
"name": "X-Coval-Workspace-Id",
"in": "header",
}
}
}
},
}
)
parameters, _ = audit_api_coverage._published_parameters(specs)
self.assertEqual(
{"GET /metrics": {("header", "x-coval-workspace-id")}}, parameters
)

def test_rejects_unlisted_external_documents_without_network_fetch(self):
for reference in [
"other.yaml#/components/parameters/WorkspaceId",
"../metrics.yaml#/components/parameters/WorkspaceId",
"./../metrics.yaml#/components/parameters/WorkspaceId",
"/metrics.yaml#/components/parameters/WorkspaceId",
"./other.yaml#/components/parameters/WorkspaceId",
"https://api.coval.dev/metrics.yaml#/components/parameters/WorkspaceId",
"file:///metrics.yaml#/components/parameters/WorkspaceId",
]:
with self.subTest(reference=reference):
specs = self._catalog_specs(
{
"metrics": {
"paths": {
"/metrics": {
"get": {"parameters": [{"$ref": reference}]}
}
}
}
}
)
with self.assertRaisesRegex(
RuntimeError, "unsupported parameter reference"
):
audit_api_coverage._published_parameters(specs)

def test_rejects_parameter_reference_cycles(self):
spec = {
"paths": {
"/metrics": {
"get": {"parameters": [{"$ref": "#/components/parameters/A"}]}
}
},
"components": {
"parameters": {
"A": {"$ref": "#/components/parameters/B"},
"B": {"$ref": "#/components/parameters/A"},
}
},
}
with self.assertRaisesRegex(RuntimeError, "cyclic parameter reference"):
audit_api_coverage._published_parameters([spec])

def test_rejects_ambiguous_catalog_aliases(self):
with self.assertRaisesRegex(RuntimeError, "ambiguous catalog document"):
self._catalog_specs({"metrics": {}, "metrics.yaml": {}})

def test_matches_header_names_without_regard_to_case(self):
self.assertEqual(
("header", "if-match"),
Expand Down
Loading