feat(conformance): vendor API contract; add staleness, type, and baseline checks#47
Merged
Merged
Conversation
…line checks - vendor canonical contract at contracts/filter_shape_contract.json (schema_version 2, generated from tango staging; refresh with new scripts/refresh_contract.py — sibling checkout or gh fallback) - checker: staleness direction (SDK arg the API dropped = error), type conformance vs contract type metadata, known-gaps baseline (contracts/conformance_baseline.json), --suggest scaffold mode - CI: conformance runs unconditionally against the vendored contract (closes the silent skip when TANGO_API_REPO_ACCESS_TOKEN is absent); token now only powers a staleness notice vs tango HEAD - baseline 7 real coverage gaps found on first run: key (contracts/ idvs/otas/otidvs), cage (entities), id (forecasts), opportunity_id (opportunities) - docs: DEVELOPERS.md + scripts/README.md conformance sections; pr_review.py defaults to the vendored contract Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
3184966 to
c5b8f44
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Turns the SDK's conformance check into a contract-first system that works out of the box and catches drift in both directions. Companion to makegov/tango#2589 (which adds type metadata to the contract).
contracts/filter_shape_contract.json(schema_version: 2, generated from tango staging). Newscripts/refresh_contract.pyre-vendors from the../tangosibling checkout or the GitHub API viagh.scripts/check_filter_shape_conformance.py):date/choice/ordering→str,boolean→bool,number→int/float/str;stringis the API's catch-all and doesn't constrain).contracts/conformance_baseline.json): accepted missing params downgrade to warnings — tracked backlog instead of silent drift. Removing the entry belongs in the PR that adds the param.--suggestprints ready-to-paste typed parameter scaffolds for missing filters.orderingis treated as accepted when the resource hasordering_fields/ordering_aliases(DRF ordering backends don't appear in FilterSets).lint.yml): conformance now runs unconditionally against the vendored contract — no token, works on forks. This closes the previous silent skip whenTANGO_API_REPO_ACCESS_TOKENwas absent; the token now only powers a best-effort staleness notice comparing the vendored contract to tango HEAD.pr_review.pyconformance step defaults to the vendored contract (override withTANGO_CONTRACT_MANIFEST); docs updated (DEVELOPERS.md,scripts/README.md).Why
SDK conformance was one-directional, name-only, and CI silently skipped it without a private-repo token. With the contract vendored and type-aware, drift between the tango API and this SDK is a hard, reproducible CI failure — in both directions — and new-filter work starts from generated scaffolds instead of archaeology.
Proof of value: the first run found 7 real coverage gaps the old setup missed (now baselined):
keyon contracts/IDVs/OTAs/OTIDVs,cageon entities,idon forecasts,opportunity_idon opportunities. Follow-up PR will close them via--suggest.Testing
uv run python scripts/check_filter_shape_conformance.py→ 0 errors, 11 warnings (7 baselined gaps + 4 unimplemented resources: events, news, offices, protests).ruff format/ruff check/ strictmypy tango/clean; 332 unit tests pass. (tests/production/test_production_smoke.py::test_search_filtersfails pre-existing on a clean tree — live-API smoke, unrelated.)tests/test_shapes.pyincludes a one-line canonicalruff formatfix picked up along the way.Risks / notes
scripts/refresh_contract.py). A scheduled refresh PR job is a possible follow-up.🤖 Generated with Claude Code