Inspiration

Modern backend and platform teams rely on OpenAPI specifications to prevent breaking changes from reaching production. Yet while researching real developer pain points across open-source API diffing and linting issue trackers (oasdiff, Spectral, and openapi-changes), we uncovered five critical blind spots that repeatedly break production or cause severe CI alert fatigue:

  1. Silent allOf Overlay Drops (oasdiff#1383): When an OpenAPI schema composes a strict base (additionalProperties: false) with an allOf overlay that marks new fields as required, standard flatteners drop the overlay properties—silently hiding breaking 400/422 changes.
  2. Cosmetic oneOf False Alarms (oasdiff#1403 & openapi-changes#286): Editing documentation descriptions inside oneOf branches or updating example values triggers false-positive breaking alerts that block innocent PRs.
  3. Unresolved Percent-Encoded $ref Chains (spectral#3108): JSON Pointer $ref chains passing through percent-encoded path keys (#/paths/~1v1~1merchants~1%7Bmerchant%252Fid%7D...) fail to resolve.
  4. Missed Accelerated x-sunset Deadlines (oasdiff#1363): Pulling an API x-sunset date earlier violates deprecation SLAs, yet legacy tools ignore it if the new date is still in the future.
  5. Zero Consumer Call-Site Context: Schema diff tools operate in a vacuum—they cannot tell an engineer which exact file and line in their TypeScript frontend or SDK will break, nor can they generate a server-side compatibility adapter to keep existing clients alive during rollout.

We built ContractPulse to bridge contract governance and real client code in a single deterministic workbench.

What it does

ContractPulse is a browser-and-API studio that performs a 3-Way Contract-to-Call-Site AST Audit across Baseline OpenAPI (v1), Candidate OpenAPI (v2), and downstream TypeScript consumer code (fetch, axios, and SDK property chains):

  • Pre-Seal allOf & Canonical oneOf Normalizer: Merges allOf overlays before enforcing closed additionalProperties: false constraints (CP-101-ALLOF-OVERLAY-REQUIRED) and strips cosmetic metadata (description, summary, example) before structural branch hashing (CP-001-ONEOF-COSMETIC-FILTERED).
  • 3-Column Cross-Linked Trace Matrix: Selecting any detected contract change highlights (1) the wire-level before/after diff and JSON Pointer breadcrumb, (2) the step-by-step composed AST resolution trace, and (3) the exact broken TypeScript file:line:column expressions (BLAST_RADIUS_CONFIRMED vs 0 Client Call-Sites Affected).
  • Live Compatibility Shim & Self-Verification Sandbox: Automatically synthesizes an Express/Fastify backwards-compatible request/response middleware (contractPulseCompatibilityShim) plus a unified .patch diff for the TypeScript client, and runs an in-memory payload verification test proving v2 payloads are adapted back to the v1 contract.

How we built it

Deterministic 4-Stage AST Engine (src/engine/)

  • refResolver.ts: Implements RFC 6901 (~1/~0) and multi-pass URI percent-decoding (%7B...%7D) with visited-set cycle guards so self-referential recursive schemas terminate safely.
  • composedNormalizer.ts: Recursively normalizes root and nested property allOf compositions, traverses additionalProperties dictionary value schemas, and computes canonical wire signatures for oneOf/anyOf branches.
  • callSiteScanner.ts: Scans TypeScript/JavaScript source buffers to extract endpoint invocations (fetch, axios), request body keys/enum literals, and response variable dot-property accesses (payload.total_cents, receipt.ingestion_cursor.slice(...)), scoping hits strictly to the invoked HTTP method and path.
  • breakingDiffEngine.ts & remediationGenerator.ts: Evaluates rules CP-100 through CP-106 and CP-001, synthesizes the Express adapter middleware and unified client .patch, and executes live assertions against sample v2 payloads.

AI Integration and Responsible Use

Instead of using an ungrounded LLM wrapper that hallucinates schema paths or false breaking rules, ContractPulse enforces Responsible Hybrid AI Architecture:

  • All JSON Pointer resolution, allOf/oneOf structural hashing, x-sunset ISO-8601 delta math (O(N + E) traversal), and TypeScript line matching are 100% deterministic and reproducible.
  • Synthesized remediation advisories, Express compatibility shims, and client migration patches are strictly grounded in the verified AST diff and validated by in-memory payload assertions before being presented to the engineer.

Frontend & Serverless API Stack

  • Built with React 19, TypeScript 5.7, Vite 6, and js-yaml, paired with serverless API endpoints (/api/analyze and /api/health) deployed on Vercel.

Challenges we ran into

  1. Nested property.allOf and additionalProperties Value Maps on External Specs: When we tested our initial engine against 12 real external YAML fixtures from the oasdiff/oasdiff test suite in Stage 3.5, 3 intermediate/advanced cases initially failed (9/12 pass rate, 75.0%): nested properties.wrapper.allOf compositions, maxLength constraint tightening (10 -> 5), and additionalProperties defined as a nested Schema Object map. We re-architected composedNormalizer.ts to recursively flatten nested property allOf arrays and traverse additionalProperties value schemas while avoiding premature visited-ref cycle exits.
  2. ESM Module Resolution in Serverless Production: During Stage 3 real-browser QA on Vercel (Node.js 22 native ESM), /api/analyze initially returned HTTP 500 due to extensionless relative TypeScript imports. Adding explicit .js specifiers across the shared engine resolved the serverless runtime error and brought both local and production QA suites to 14/14 passing.

Accomplishments that we're proud of

  • 100% Post-Fix Accuracy on External oasdiff Corpus: Improved from 9/12 (75.0%) initial accuracy to 12/12 (100.0%) across Basic, Intermediate, Advanced, Edge, Negative, and Adversarial cases (evidence/stage-3.5-validation/), with a mean 3-way AST execution latency of 1.01ms.
  • 14/14 Real-Browser QA Verification: Passed all 14 P0/P1 end-to-end scenarios in headless Firefox across Desktop (1440x900) and Mobile (390x844) viewports on both local and deployed builds (evidence/stage-3-qa/).
  • Zero-Cliché Forensic Workbench UX: Designed a high-density dark industrial blueprint interface (#0B0F14 / #111720 with Signal Amber #F59E0B) featuring our signature 3-Column Cross-Linked Contract-to-Call-Site Trace Matrix.

What we learned

  • Never trust self-authored happy-path tests alone: Running external benchmark files from oasdiff/oasdiff/data/checker immediately revealed nested allOf and additionalProperties schema map edge cases that unit tests on our own fixtures did not cover.
  • Schema diffs are only half the problem: Separating Confirmed Client Breaks (checkoutClient.ts:22) from Unreferenced Schema Removals (0 client references) dramatically reduces release-gate friction.

What's next for ContractPulse

  • GitHub Pull Request Bot & CLI Package: Publish contractpulse as an npm CLI and GitHub Action that posts the PR Gate Markdown table and attaches the .patch and Express shim directly to pull requests.
  • Multi-File TypeScript Project Graph: Extend callSiteScanner.ts to follow cross-file TypeScript imports and generated OpenAPI SDK clients across monorepos.

Built With

Share this project:

Updates

Submission history