Skip to content

feat(api): Rust consumer contracts and fail-closed artifact compatibility - #424

Open
VPRamon wants to merge 10 commits into
mainfrom
codex/api-contract-hardening
Open

VPRamon wants to merge 10 commits into
mainfrom
codex/api-contract-hardening

Conversation

@VPRamon

@VPRamon VPRamon commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Independent Server/Cloud, frontend and MCP releases now verify their exact API contracts before image publication. This is P0 of #423; global versioning, deployment orchestration and image provenance remain separate.

Contract and compatibility

  • Rust owns consumer discovery, selection, artifact identity/policy, traffic validation and CLI orchestration. Tree-sitter follows direct calls, shared transports, dynamic project paths, multipart/downloads, session/OAuth dependencies and API navigation. Unresolved calls, unsupported alternative clients and unknown dynamic navigation fail closed; the narrow UI/external-provider exceptions are documented.
  • All 217 distinct consumed operations are audited against Rust: 195 frontend and 79 MCP. Strict validation and type generation reject unverified operations. One unconsumed backend index-status operation remains explicitly unverified and outside the consumer gate.
  • Checksum-pinned oasdiff 1.34.0 validates OpenAPI and breaking changes in request/response direction. Small Rust checks cover Marreq authorization/scopes and CSRF semantics.
  • Immutable bundles identify component, independent version, exact source SHA, selected operations/schemas and policy. Plans pin bundle bytes with SHA-256; missing, tampered or mismatched evidence fails. Historical evidence never falls back to current main. A contract checksum does not authenticate an image.
  • Consumer-specific declarations retain only imported schemas and dependencies, 922 → 364 lines combined. Consumer Docker builds remain independent of Rust/global contract generation.

Regression evidence and CI fixes

  • Existing Rocket integration clients now assert real response status/media/headers/JSON against the contract: 444 tests, including a deliberately incompatible HTTP response. Actual Rust request deserializers and serialized report models have additional schema checks; compiled Server/Cloud route inventory is checked.
  • 45 compatibility tests exercise compatible independent backend/frontend/MCP updates, additive/unrelated changes, removed endpoints/response guarantees, incompatible request fields/types/enums/authentication/media, missing/tampered history and exact candidate identity.
  • Isolated PostgreSQL plus real Server/Cloud and frontend/MCP transport smoke: 87 validated exchanges, zero unverified. Critical read/write/scope/project-boundary evidence is required independently for both variants.
  • Boxed Rocket launch errors in the HTTP test helper for current stable Clippy. Installed the same pinned oasdiff tool in workspace coverage CI; deterministic generated-type checks stay enabled. Removed the obsolete unverified-selection bypass and tightened source/config identity checks.
  • Targeted calamine 0.38.0 fixes RUSTSEC-2026-0436. No security suppression was added; main's existing crypto-bigint policy remains tracked by Resolve RUSTSEC-2026-0387 in OpenID Connect's crypto-bigint dependency chain #425.
  • Stabilized the report editor test by waiting for its default-form restoration after deletion.

Cleanup and scope

Removed the abandoned Python artifacts (eight bytecode files), five newly tracked MCP compiled files and obsolete paths; ignore rules prevent recurrence. Previously tracked MCP output matches main. The retained Rust analyzer and established standards engine avoid a second compatibility implementation. Main is merged without replacing upstream changes.

The complete audit and reusable HTTP assertions expand the PR from 59 files, +9,886/−407 initially to 74 files, +13,916/−415 against current main; no binary diff remains. Most added lines are the single authoritative wire contract, not duplicated snapshots.

Validation

Local: rustfmt; workspace Clippy with warnings denied; locked workspace tests (2,115 passed, one ignored); contract tests; six route/DTO tests; strict coverage/validation; generated-type drift; frontend/MCP builds; 720 frontend / 51 MCP tests; isolated Server/Cloud smoke; cargo-deny advisories — pass.

CI for final commit 397d7ed0f76fb75921a8e6b56603e8af0df85399 passed all 8 jobs, including strict consumer verification, real Server/Cloud smoke, workspace coverage, builds, lint and security. Rust line coverage: 83.22%.

Exact bundles exported from the final clean SHA also pass all six candidate checks (backend/frontend/MCP × Server/Cloud) with independently numbered test versions. These test plans are not presented as historical release evidence.

Release prerequisite and limits

Every existing image publisher requires exact candidate/deployment verification. MARREQ_RELEASE_CONTRACTS_SHA must reference genuine retained bundles and an immutable deployment plan before publication; it is currently unprovisioned. No historical evidence was fabricated. See the provisioning procedure. This source PR does not claim published historical releases exist.

The analyzer supports the documented transport grammar and rejects unsupported patterns until explicitly modeled. The smoke exercises representative real flows; the complete consumer selection is audited separately against Rust. Unconsumed backend operations are outside P0. No merge or deployment performed.

Run locally

scripts/install-oasdiff.sh
export PATH="$HOME/.cache/marreq-contracts:$PATH"
npm ci
cargo test --locked -p marreq-contracts
cargo run --locked -p marreq-contracts -- validate
node scripts/generate-api-types.mjs --check
cargo test --locked -p marreq-cloud --test api_contract_inventory
cargo test --locked -p marreq-core --features test-helpers --test it
scripts/test-api-contracts.sh

Contract guide.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Frontend Code Coverage

Frontend SPA coverage (by module)

Module Line Rate Branch Rate Function Rate Health
api 89.3% (316 / 354) 82.7% 86.3% ✔
components 74.1% (2234 / 3015) 62.6% 70.5% ➖
components/graph 100.0% (9 / 9) 66.7% 100.0% ✔
components/reports 86.1% (87 / 101) 70.6% 74.1% ✔
components/table 100.0% (7 / 7) 80.0% 100.0% ✔
context 77.8% (56 / 72) 40.0% 69.6% ➖
hooks 72.3% (146 / 202) 71.1% 70.0% ➖
lib 100.0% (18 / 18) 100.0% 100.0% ✔
pages 69.3% (2395 / 3457) 55.8% 61.8% ➖
pages/catalog 34.8% (162 / 465) 24.5% 18.3% ❌
pages/groups 0.0% (0 / 219) 0.0% 0.0% ❌
src (root) 33.3% (8 / 24) 38.1% 60.0% ❌
types 100.0% (0 / 0) 100.0% 100.0% ✔
utils 97.2% (620 / 638) 89.1% 98.8% ✔
Summary 70.6% (6058 / 8581) 59.2% 65.4% ➖

Generated from Vitest @vitest/coverage-v8 (frontend/src).

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Code Coverage

Package Line Rate Complexity Health
marreq-cloud.src 71% 0 ➖
marreq-core.src.services 93% 0 ✔
marreq-core.src.reqif 97% 0 ✔
marreq-core.src 86% 0 ✔
marreq-core.src.generators 90% 0 ✔
marreq-core.src.routes 64% 0 ➖
marreq-core.src.models 82% 0 ✔
marreq-core.src.validation 96% 0 ✔
marreq-core.src.repository.cache 100% 0 ✔
marreq-core.src.storage 93% 0 ✔
marreq-core.src.diff 100% 0 ✔
marreq-core.src.services.semantic_search 75% 0 ➖
tools.marreq-contracts.src 83% 0 ✔
marreq-cloud.src.api 78% 0 ✔
marreq-core.src.auth.guards 70% 0 ➖
marreq-server.src 57% 0 ➖
marreq-core.src.reports 95% 0 ✔
marreq-cloud.src.services 91% 0 ✔
marreq-cloud.src.fairings 100% 0 ✔
marreq-core.src.api 83% 0 ✔
marreq-core.src.auth.rate_limiter 96% 0 ✔
marreq-core.src.repository.diesel_repo 39% 0 ❌
marreq-core.src.deployment 84% 0 ✔
marreq-core.src.fairings 90% 0 ✔
marreq-core.src.use_case_document 94% 0 ✔
marreq-core.src.helper_functions 95% 0 ✔
marreq-core.src.auth 91% 0 ✔
marreq-core.src.importers 74% 0 ➖
marreq-core.src.repository 88% 0 ✔
Summary 84% (48517 / 57750) 0 ✔

@VPRamon VPRamon changed the title feat(api): bootstrap contract inventory and fail-closed compatibility gates feat(api): Rust consumer contracts and fail-closed artifact compatibility Nov 3, 2026
@VPRamon
VPRamon marked this pull request as ready for review November 4, 2026 18:53
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-11-04T18:53:13.112928Z 397d7ed Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

1 participant