Skip to content

test: check if code is API breaking#2141

Open
fl0rianr wants to merge 1 commit into
mainfrom
fl0rianr/ci_validate_api
Open

test: check if code is API breaking#2141
fl0rianr wants to merge 1 commit into
mainfrom
fl0rianr/ci_validate_api

Conversation

@fl0rianr

@fl0rianr fl0rianr commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add a static public API route contract manifest for Lemonade's HTTP and websocket routes
  • add a dependency-free CI check that compares the manifest with the C++ route registrations
  • run the check on PRs, pushes to main, and merge queue entries

Fixes #2137

Why

Issue #2137 asks for CI protection against breaking API changes. The public API is spread across Lemonade's OpenAI-compatible routes, Lemonade-specific routes, Ollama-compatible routes, Anthropic-compatible /v1/messages, and websocket endpoints.

This PR adds a lightweight guardrail that fails when a protected public route is accidentally removed, renamed, or has its HTTP method changed. It intentionally avoids building the server or downloading models, so it stays fast and reliable in CI.

Scope

This protects the public route-level contract: HTTP method + path, including dynamic path segments and websocket paths. It does not validate request or response JSON schemas; those should be added later once the API has a generated OpenAPI/schema source of truth.

Testing

python test/test_api_contract.py

Expected output:

Public API contract check passed (143 expected routes).

I also checked that removing a protected route makes the test fail with a focused missing-route message.

@fl0rianr fl0rianr requested a review from jeremyfowers June 8, 2026 18:01
@github-actions github-actions Bot added enhancement New feature or request area::api HTTP REST API surface and route handlers labels Jun 8, 2026
@superm1

superm1 commented Jun 11, 2026

Copy link
Copy Markdown
Member

Probably from other code that merged but I notice:

The regex r"path\s*==\s*"([^\"]+)"" in extract_websocket_routes() does not match the actual code in websocket_server.cpp. The comparison uses stripped == "/realtime" and stripped == "/logs/stream", not
path == "...".

@superm1 superm1 force-pushed the fl0rianr/ci_validate_api branch from 0ee23d1 to add6f7c Compare June 11, 2026 23:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area::api HTTP REST API surface and route handlers enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI to protect against breaking API changes

2 participants