Inspiration
- Dependabot tells you a newer version exists. Great. But the question that actually wakes people up at 3 a.m. is: upstream changed their API, does my code care? A removed endpoint at least has the decency to throw a 4xx. A changed default or a new enum value just sits quietly and shows up weeks later as wrong data, and changelogs often skip exactly this class of change. We watched teams learn about PayPal and Stripe changes from production, and decided that’s a terrible place to find out.
What it does
- Driftwatch reads a provider’s OpenAPI spec and generated SDK, flattens each revision into a surface index, and set-diffs two revisions into classified changes: renamed, deprecated, newly required, enum value added or removed. Then it scans your repo. It skips repos that don’t use the SDK, finds candidate files, and uses tree-sitter to resolve the real client (new Stripe(), this.stripe, getStripe()) and bind each call to a surface, with a confidence score. When the fix is mechanical, it writes a one-line patch and reparses the file before showing it to you. On PayPal, one command does the whole thing with no database: 41 operations, 82 bindings, an Orders v2 diff, a fixture scan, and a real $49.00 USD sandbox order. A local review desk lets a person mark each finding true, false, or unsure, so precision is measured instead of claimed.
How we built it
- Python 3.12, FastAPI, Pydantic, PostgreSQL, Typer, and tree-sitter for Python and TypeScript. A poller stores raw provider payloads, a worker builds the index, and Stripe and PayPal share one vocabulary, so a new provider is just a new indexer. The model sits behind a validator and must quote the spec as evidence for every classification. Set OPENAI_API_KEY and it calls OpenAI; skip it and an offline grounded client does the same job. That means judges can run uv run driftwatch paypal-showcase right now with no setup. Checkout only talks to api-m.sandbox.paypal.com.
Challenges we ran into
Real merchant code looks nothing like the SDK README. Our first scans of JS/TS repos found nothing, because the matcher only opened Python files. Class fields and factories failed until we stopped trusting tree-sitter node identity, which changes between walks. The PayPal SDK is APIMATIC-generated, so a line regex saw zero operations. Parsing the controllers with Python’s AST gave us 41. Along the way, a dict passed positionally was scored as a removed enum value named body, which is a bold way to read a function call.
Then came the sandbox. A placeholder Client ID returns invalid_client. Logging in as the seller is blocked. An INR buyer gets rejected by a US business app. What finally worked: a US Personal buyer, a US Business app, and the order ID from the API response. Also, the example.com page after approval is PayPal’s placeholder return URL, not our bug.
Accomplishments that we're proud of
- On a month of Stripe releases, the spec diff found 63 material changes and suppressed 90.7% as additive noise. On a fixture with 5 real usages and 5 decoys, it returned 1 finding and 0 false positives, with a +1 / −1 patch that reparsed cleanly. It derives 585 Stripe operations and 3,888 bindings in 1.5 seconds, and a self-diff of a spec produces zero phantom changes. The PayPal sandbox order returned 201 and capture completed. The showcase test builds its own tiny SDK and OpenAPI pair, so CI passes without a fetched .cache/.
What we learned
- The valuable change is often the silent one. Across four days of Stripe, the only real delta was an enum gaining final_payment_failure and first_payment_failure: no 4xx, no changelog entry. We also learned that a known miss beats a confident wrong hit. Dropping calls that touch two surfaces kept the decoys out. Trust has to be earned in the review desk before Driftwatch is allowed near a pull request, and the model is only useful when every sentence it writes can be checked against a spec quote.
What's next for DriftWatch
- First, a hand audit of real public repositories, and if precision falls under about 0.8, we fix the matcher before anything else. Then surface maps pinned to the SDK version each repo actually depends on, instead of SDK master, and codemods for the TypeScript and PayPal cases that are still alert-only. We also want OpenAI model-shutdown dates as a first-class provider. And finally, a production sandbox with no network, so a hostile test suite in a scanned repo can’t run with our credentials.