From fe85bb14fcccb8866c1b1e94b1e9d69916c5295f Mon Sep 17 00:00:00 2001 From: callumreid <75899979+callumreid@users.noreply.github.com> Date: Mon, 23 Nov 2026 10:05:51 +0000 Subject: [PATCH 1/2] chore(cli): refresh API parity report --- api-coverage-report.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/api-coverage-report.md b/api-coverage-report.md index a116bfd..aa9a68c 100644 --- a/api-coverage-report.md +++ b/api-coverage-report.md @@ -17,15 +17,15 @@ and update `reviewed_at`. | Metric | Value | | --- | ---: | -| Reconciliation status | PASS | -| Published operations | 199 | +| Reconciliation status | ACTION REQUIRED | +| Published operations | 201 | | First-class CLI operations | 131 | | Reviewed gaps | 68 | | 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 gaps overdue for re-review | 0 | @@ -39,7 +39,8 @@ Catalog: https://api.coval.dev/v1/openapi ## New published operations without CLI commands -- None. +- `GET /organization/caller-id` +- `PATCH /organization/caller-id` ## Reviewed gaps no longer present @@ -63,7 +64,8 @@ Catalog: https://api.coval.dev/v1/openapi ## Coverage snapshot mismatches -- None. +- `published_operations: recorded 199, current 201` +- `published_parameters: recorded 196, current 197` ## Client-only operations @@ -92,6 +94,7 @@ Catalog: https://api.coval.dev/v1/openapi - `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` @@ -111,6 +114,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}` @@ -162,7 +166,7 @@ Catalog: https://api.coval.dev/v1/openapi ## New published parameters the CLI cannot send -- None. +- `GET /metrics/{id} query include` ## Reviewed parameter gaps no longer present @@ -208,6 +212,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` From 782a422645b3db43e00e1e6d9d5f4ff5c6b556b4 Mon Sep 17 00:00:00 2001 From: Callum Reid Date: Tue, 24 Nov 2026 14:37:53 -0400 Subject: [PATCH 2/2] fix: reconcile catalog-backed API parity --- api-coverage-report.md | 23 +++-- api-coverage.toml | 58 +++++++++++- scripts/audit_api_coverage.py | 51 ++++++++--- scripts/test_audit_api_coverage.py | 140 +++++++++++++++++++++++++++++ 4 files changed, 249 insertions(+), 23 deletions(-) diff --git a/api-coverage-report.md b/api-coverage-report.md index aa9a68c..3c67db3 100644 --- a/api-coverage-report.md +++ b/api-coverage-report.md @@ -17,17 +17,17 @@ and update `reviewed_at`. | Metric | Value | | --- | ---: | -| Reconciliation status | ACTION REQUIRED | -| Published operations | 201 | +| Reconciliation status | PASS | +| 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 | 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 | @@ -39,8 +39,7 @@ Catalog: https://api.coval.dev/v1/openapi ## New published operations without CLI commands -- `GET /organization/caller-id` -- `PATCH /organization/caller-id` +- None. ## Reviewed gaps no longer present @@ -64,8 +63,7 @@ Catalog: https://api.coval.dev/v1/openapi ## Coverage snapshot mismatches -- `published_operations: recorded 199, current 201` -- `published_parameters: recorded 196, current 197` +- None. ## Client-only operations @@ -82,12 +80,18 @@ 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` @@ -126,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` @@ -166,7 +171,7 @@ Catalog: https://api.coval.dev/v1/openapi ## New published parameters the CLI cannot send -- `GET /metrics/{id} query include` +- None. ## Reviewed parameter gaps no longer present diff --git a/api-coverage.toml b/api-coverage.toml index 3363ec5..729237e 100644 --- a/api-coverage.toml +++ b/api-coverage.toml @@ -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] @@ -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" diff --git a/scripts/audit_api_coverage.py b/scripts/audit_api_coverage.py index 5031bc8..17e2a2d 100644 --- a/scripts/audit_api_coverage.py +++ b/scripts/audit_api_coverage.py @@ -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]: @@ -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( @@ -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. """ @@ -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: diff --git a/scripts/test_audit_api_coverage.py b/scripts/test_audit_api_coverage.py index fecbb1d..0e9c99c 100644 --- a/scripts/test_audit_api_coverage.py +++ b/scripts/test_audit_api_coverage.py @@ -2,6 +2,7 @@ import datetime import io +import json import tempfile import tomllib import unittest @@ -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"),