-
-
Live Compatibility Shim Sandbox generating Express v1-v2 adapter middleware, unified .patch diff, and verifying 4 restored fields.
-
3-Way Trace Matrix catching hidden allOf overlay breaks (oasdiff#1383) and linking total_cents removal to checkoutClient.ts:22.
-
Stage 3.5 real-world validation: 100% (12/12) pass rate on external oasdiff corpus in 1.01ms mean latency and 14/14 Firefox QA pass.
-
Four-stage deterministic AST architecture: RFC 6901 $ref decoder, pre-seal allOf merger, TypeScript scanner, and shim synthesizer.
-
False-positive immunity (SAFE_TO_MERGE) suppressing cosmetic oneOf description and example edits (oasdiff#1403 & openapi-changes#286).
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:
- Silent
allOfOverlay Drops (oasdiff#1383): When an OpenAPI schema composes a strict base (additionalProperties: false) with anallOfoverlay that marks new fields asrequired, standard flatteners drop the overlay properties—silently hiding breaking400/422changes. - Cosmetic
oneOfFalse Alarms (oasdiff#1403&openapi-changes#286): Editing documentation descriptions insideoneOfbranches or updatingexamplevalues triggers false-positive breaking alerts that block innocent PRs. - Unresolved Percent-Encoded
$refChains (spectral#3108): JSON Pointer$refchains passing through percent-encoded path keys (#/paths/~1v1~1merchants~1%7Bmerchant%252Fid%7D...) fail to resolve. - Missed Accelerated
x-sunsetDeadlines (oasdiff#1363): Pulling an APIx-sunsetdate earlier violates deprecation SLAs, yet legacy tools ignore it if the new date is still in the future. - 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& CanonicaloneOfNormalizer: MergesallOfoverlays before enforcing closedadditionalProperties: falseconstraints (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:columnexpressions (BLAST_RADIUS_CONFIRMEDvs0 Client Call-Sites Affected). - Live Compatibility Shim & Self-Verification Sandbox: Automatically synthesizes an Express/Fastify backwards-compatible request/response middleware (
contractPulseCompatibilityShim) plus a unified.patchdiff for the TypeScript client, and runs an in-memory payload verification test provingv2payloads are adapted back to thev1contract.
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 propertyallOfcompositions, traversesadditionalPropertiesdictionary value schemas, and computes canonical wire signatures foroneOf/anyOfbranches.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 rulesCP-100throughCP-106andCP-001, synthesizes the Express adapter middleware and unified client.patch, and executes live assertions against samplev2payloads.
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/oneOfstructural hashing,x-sunsetISO-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/analyzeand/api/health) deployed on Vercel.
Challenges we ran into
- Nested
property.allOfandadditionalPropertiesValue Maps on External Specs: When we tested our initial engine against 12 real external YAML fixtures from theoasdiff/oasdifftest suite in Stage 3.5, 3 intermediate/advanced cases initially failed (9/12pass rate,75.0%): nestedproperties.wrapper.allOfcompositions,maxLengthconstraint tightening (10 -> 5), andadditionalPropertiesdefined as a nested Schema Object map. We re-architectedcomposedNormalizer.tsto recursively flatten nested propertyallOfarrays and traverseadditionalPropertiesvalue schemas while avoiding premature visited-ref cycle exits. - ESM Module Resolution in Serverless Production: During Stage 3 real-browser QA on Vercel (
Node.js 22native ESM),/api/analyzeinitially returnedHTTP 500due to extensionless relative TypeScript imports. Adding explicit.jsspecifiers across the shared engine resolved the serverless runtime error and brought both local and production QA suites to14/14passing.
Accomplishments that we're proud of
- 100% Post-Fix Accuracy on External
oasdiffCorpus: Improved from9/12(75.0%) initial accuracy to12/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 of1.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/#111720with 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/checkerimmediately revealed nestedallOfandadditionalPropertiesschema 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
contractpulseas an npm CLI and GitHub Action that posts the PR Gate Markdown table and attaches the.patchand Express shim directly to pull requests. - Multi-File TypeScript Project Graph: Extend
callSiteScanner.tsto follow cross-file TypeScript imports and generated OpenAPI SDK clients across monorepos.
Built With
- ast
- node.js
- openapi
- playwright
- react
- typescript
- vite
- yaml