Skip to content

[codex] Add hermetic OpenAPI contract drift check - #8629

Merged
Git-on-my-level merged 2 commits into
mainfrom
codex/wave2-8546-openapi-contract
Jun 29, 2026
Merged

Git-on-my-level merged 2 commits into
mainfrom
codex/wave2-8546-openapi-contract

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Jun 29, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Adds a hermetic OpenAPI exporter/checker for the public Developer API contract.
  • Adds route inventory, audited route drift, operation ID, auth/security, side-effect, and schema checks.
  • Regenerates docs/api-reference/openapi.json from the audited route surface and adds CI coverage.

Validation

  • .venv/bin/python scripts/export_openapi.py --check ../docs/api-reference/openapi.json -> passed
  • .venv/bin/pytest tests/unit/test_openapi_contract.py -q -> 14 passed
  • bash backend/test-preflight.sh passed during prep with optional local warnings
  • Pre-push hook passed
  • Oracle pre-implementation and pre-PR reviews passed after repair rounds.

Fixes #8546

Review in cubic

@mintlify

mintlify Bot commented Jun 29, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
deepeninc 🟡 Building – Jun 29, 2026, 10:19 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@mintlify

mintlify Bot commented Jun 29, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
omi 🟢 Ready View Preview Jun 29, 2026, 10:22 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2425f1892e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +143 to +144
class DeveloperMemory(BaseModel):
model_config = ConfigDict(title='DeveloperMemory')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restore memory metadata in developer responses

When clients call the Developer memory endpoints for records that contain scoring, reviewed, user_review, or edited, this replacement response model now filters those fields out of the live FastAPI response; previously CleanerMemory exposed the review fields on list/update and MemoryResponse exposed scoring on create/batch. This changes production API payloads, not just the generated OpenAPI contract, so integrations that rely on memory review state or scoring lose data.

Useful? React with 👍 / 👎.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 issues found across 6 files

Confidence score: 2/5

  • backend/routers/developer.py switches developer memory responses to a model that drops scoring, reviewed, user_review, and edited, which is a concrete API contract break for clients consuming list/create/update/batch payloads; merging as-is is likely to cause downstream parsing/UI regressions — restore those fields (or version the endpoint and update consumers) before merging.
  • backend/routers/developer.py has DeveloperFolder defaults that can diverge from Folder, so legacy docs without color/icon may trigger 500s in listFolders; this creates a user-facing reliability risk on existing data — align defaults with Folder and add a regression test for legacy folder documents before merging.
  • backend/tests/unit/test_openapi_contract.py uses an overly broad route match for the "exact" audit, so the test can pass while validating the wrong endpoint and miss real contract drift; this weakens protection around API changes — tighten the pattern with an end anchor (or equivalent precise match) before merge.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="backend/test-preflight.sh">

<violation number="1" location="backend/test-preflight.sh:143">
P3: Redundant stderr redirect after `&>/dev/null`. Use `&>/dev/null` alone or `>/dev/null 2>&1`, not both.</violation>
</file>

<file name="backend/routers/developer.py">

<violation number="1" location="backend/routers/developer.py:925">
P2: Keep DeveloperFolder defaults aligned with Folder; otherwise legacy folder docs missing color/icon can turn listFolders into a 500.</violation>
</file>

<file name="backend/tests/unit/test_openapi_contract.py">

<violation number="1" location="backend/tests/unit/test_openapi_contract.py:88">
P3: Test name says "exact" route is audited but match pattern is too broad — it matches both `/v1/conversations` and `/v1/conversations/from-segments`. Use `$` anchor or a more precise match to isolate the target route.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread backend/routers/developer.py Resolved
Comment on lines +925 to +926
color: str
icon: str

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Keep DeveloperFolder defaults aligned with Folder; otherwise legacy folder docs missing color/icon can turn listFolders into a 500.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/routers/developer.py, line 925:

<comment>Keep DeveloperFolder defaults aligned with Folder; otherwise legacy folder docs missing color/icon can turn listFolders into a 500.</comment>

<file context>
@@ -873,7 +916,23 @@ def normalize_client_session_id(cls, value: Optional[str]) -> Optional[str]:
+    id: str
+    name: str
+    description: Optional[str] = None
+    color: str
+    icon: str
+    created_at: datetime
</file context>
Suggested change
color: str
icon: str
color: str = '#6B7280'
icon: str = 'folder'

Comment thread backend/test-preflight.sh
bad "backend unit test selection failed"
fi

if [[ -n "$PYTHON_BIN" ]] && "$PYTHON_BIN" scripts/export_openapi.py --help &>/dev/null 2>&1; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: Redundant stderr redirect after &>/dev/null. Use &>/dev/null alone or >/dev/null 2>&1, not both.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/test-preflight.sh, line 143:

<comment>Redundant stderr redirect after `&>/dev/null`. Use `&>/dev/null` alone or `>/dev/null 2>&1`, not both.</comment>

<file context>
@@ -140,6 +140,12 @@ else
   bad "backend unit test selection failed"
 fi
 
+if [[ -n "$PYTHON_BIN" ]] && "$PYTHON_BIN" scripts/export_openapi.py --help &>/dev/null 2>&1; then
+  ok "OpenAPI export script is runnable"
+else
</file context>
Suggested change
if [[ -n "$PYTHON_BIN" ]] && "$PYTHON_BIN" scripts/export_openapi.py --help &>/dev/null 2>&1; then
if [[ -n "$PYTHON_BIN" ]] && "$PYTHON_BIN" scripts/export_openapi.py --help &>/dev/null; then

def create_first_party_conversation():
return {'ok': True}

with pytest.raises(export_openapi.OpenAPIContractError, match='POST /v1/conversations'):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: Test name says "exact" route is audited but match pattern is too broad — it matches both /v1/conversations and /v1/conversations/from-segments. Use $ anchor or a more precise match to isolate the target route.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/tests/unit/test_openapi_contract.py, line 88:

<comment>Test name says "exact" route is audited but match pattern is too broad — it matches both `/v1/conversations` and `/v1/conversations/from-segments`. Use `$` anchor or a more precise match to isolate the target route.</comment>

<file context>
@@ -0,0 +1,235 @@
+    def create_first_party_conversation():
+        return {'ok': True}
+
+    with pytest.raises(export_openapi.OpenAPIContractError, match='POST /v1/conversations'):
+        export_openapi.build_public_openapi(app)
+
</file context>
Suggested change
with pytest.raises(export_openapi.OpenAPIContractError, match='POST /v1/conversations'):
with pytest.raises(export_openapi.OpenAPIContractError, match=r'POST /v1/conversations\b(?!/)'):

@Git-on-my-level
Git-on-my-level merged commit e46fdd8 into main Jun 29, 2026
6 checks passed
@Git-on-my-level
Git-on-my-level deleted the codex/wave2-8546-openapi-contract branch June 29, 2026 23:22

This branch was successfully deployed

1 active deployment
staging - docs — 348bbf80 Deployed Jun 29, 2026 by mintlify[bot]
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.

[tech-debt] Make OpenAPI spec authoritative + CI route-contract drift check

2 participants