Skip to content

cowork-bot: automated improvements (cowork/improve-api-contract-guardian)#56

Merged
Coding-Dev-Tools merged 8 commits into
mainfrom
cowork/improve-api-contract-guardian
Jul 21, 2026
Merged

cowork-bot: automated improvements (cowork/improve-api-contract-guardian)#56
Coding-Dev-Tools merged 8 commits into
mainfrom
cowork/improve-api-contract-guardian

Conversation

@Coding-Dev-Tools

Copy link
Copy Markdown
Owner

Automated improvement PR from the Cowork repo-improver rotation. Changes: detect operation-level (per-endpoint) security changes in diff engine, diff inline request/response schemas within media types, add actions/checkout step to cowork-auto-pr.yml.

DevForge Engineer and others added 8 commits July 11, 2026 04:02
… diff engine

The diff engine only compared the global `security` requirement, so a spec
that dropped auth from a single endpoint (making it public), newly required
auth, or switched security schemes on one operation produced NO change — the
gate reported green while a real security-relevant contract change shipped.

Add _diff_operation_security(): compares each shared operation's own
`security` (which overrides global), normalizing requirement/scope ordering to
a set of scheme-name groups so only genuine changes surface. Transitions are
classified DANGEROUS, mirroring the existing global-security treatment:
operation_security_added / _removed / _changed, with human-readable
descriptions (e.g. 'DELETE /admin no longer requires authentication').

+8 targeted tests (172->173 suite total, all green); README + CHANGELOG updated.
Previously the diff engine only compared content-type presence within
requestBody/responses; inline schemas sharing a content type were never
compared, so a response dropping a field or a request adding a required
field passed silently (green while broken). Add _diff_media_type_schema /
_diff_inline_schema with direction-aware breaking semantics (request:
new required field breaks; response: dropped/no-longer-guaranteed field
breaks; type changes break both). $ref targets are only flagged when the
ref itself changes, deferring component detail to _diff_schemas to avoid
double-reporting. Adds 13 regression tests.
Previously _diff_inline_schema only compared top-level properties, so a
breaking change buried one level down (e.g. a required field added deep in a
request body, or a field dropped from a nested response object / array-of-object
items) was reported as 'no change' -- the silent-green failure class this tool
exists to catch.

Now recurse into nested object properties and array-of-object item schemas with
the same request/response-aware breaking semantics, guarded by a depth limit and
skipping nested $ref targets (component-level diffing owns those).

+4 regression tests (nested response field removal, nested required request
field, array-item field removal, and a no-false-positive guard); 188 tests pass,
ruff clean.
api-contract-guardian is NOT on public PyPI. The badge 404s and
'pip install api-contract-guardian' fails. Replace with a note
directing users to the git+ install method.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@github-actions

Copy link
Copy Markdown

🤖 Automated Code Review

✅ Ruff Lint — No issues

⚠️ Ruff Format — Formatting needed

Would reformat: src/api_contract_guardian/cli.py
Would reformat: src/api_contract_guardian/diff.py
Would reformat: src/api_contract_guardian/gate.py
Would reformat: src/api_contract_guardian/loader.py
Would reformat: src/api_contract_guardian/migration.py
Would reformat: tests/test_diff.py
Would reformat: tests/test_edge_cases.py
Would reformat: tests/test_gate.py
Would reformat: tests/test_migration.py
9 files would be reformatted, 6 files already formatted

✅ Secret Detection — Clean

✅ Large Files — Within limits

📊 Diff Stats — 4 file(s) changed

 .github/workflows/ci.yml             | 2 +-
 .github/workflows/cowork-auto-pr.yml | 2 +-
 .github/workflows/publish.yml        | 6 +++---
 src/api_contract_guardian/diff.py    | 4 +++-
 4 files changed, 8 insertions(+), 6 deletions(-)

Verdict: ⚠️ Warnings — Lint/format issues found. Recommend fixing before merge.

Automated by Coding-Dev-Tools/.github reusable workflow.

@Coding-Dev-Tools
Coding-Dev-Tools merged commit 907aa86 into main Jul 21, 2026
5 of 6 checks passed
@Coding-Dev-Tools
Coding-Dev-Tools deleted the cowork/improve-api-contract-guardian branch July 21, 2026 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants