跳到正文
DEV Community· F Lalchawiliana·· 49 分鐘前AI 評分57

SUTURE:整合 SQL、Python 與試算表公式的模糊測試工具

SUTURE : A spreadsheet that proves its own bugs

AI 導讀

F Lalchawiliana 開發 SUTURE,將 SQL、Python 和試算表公式整合至瀏覽器中的同一依賴圖,並以模糊測試找出錯誤案例。其 Exorcist 測試器會縮小仍能觸發錯誤的輸入,並提供重播連結;MCP server 可讓 Kiro 驗證修補方案及執行 1,000-run audit。

正文

 # I built a spreadsheet that attacks itself: Suture, made with Kiro

This post was written as part of the Kiroween 2026 hackathon.

My runway model said 21.76 months. Then I let it fuzz itself, and in about three seconds it found inputs that made runway -179.88 months, with a status cell cheerfully telling the company to "RAISE NOW". The formula was one line, =Inputs!B2/B4, and nothing about it looked wrong.

That's the kind of bug Suture finds. Here's what I built, and how Kiro shaped the way I built it.

The problem: spreadsheets break silently

Field audits compiled by researcher Raymond Panko found errors in most of the real business spreadsheets examined. Famous failures, like the debt-and-growth paper whose average left out five countries, or the "London Whale" risk model that divided by a sum instead of an average, share one pattern: the numbers looked plausible, so nobody checked.

Modern models make it harder still, because they mix SQL queries, Python and formulas, and no tool checks the whole chain at once.

Frankenstein: three engines, one graph

Suture stitches three engines into one dependency graph that runs entirely in the browser:

  • =SQL("…") cells run in DuckDB-WASM
  • =PY("…") cells run in Pyodide with NumPy
  • ordinary formulas (SUMIFS, VLOOKUP, IRR and 27 more) run in Suture's own evaluator

In the runway model, a SQL cohort table feeds a NumPy least-squares burn projection, which feeds the runway formula. There's no server and no upload.

Property-based testing as a product feature

The Exorcist is a fuzzer built on fast-check. You declare rules ("runway >= 0") and input ranges. It pushes scenarios through all three engines, checks your rules plus five universal invariants (no NaN leaks, SQL and NumPy agreeing, results not depending on edit order…), and when something breaks it shrinks the failure to the smallest inputs that still break it.

Then:

  • Apply Counterexample loads those inputs, and X-Ray draws a crimson fracture from the shrunk inputs through SQL, Python and formulas.
  • Copy Replay Link gives you a URL that reproduces the exact failure in a fresh page. A bug report is just a link.

It scales, too: a built-in audit generates 100,000 orders in DuckDB, pivots them in NumPy, and finds a real policy bug. The discount cap was applied to each discount instead of the stacked total.

How Kiro shaped the build

I built the whole thing in Kiro Web. Four things made the difference.

1. Spec first. Before any code, Kiro and I wrote 5 specs with 291 acceptance criteria in EARS form ("WHEN … THE SYSTEM SHALL …"). The most important one pinned the value contract that three engines must agree on: error codes, -0, NaN and Infinity, and who owns Arrow buffers. Every task lists the test that proves it and the commit that delivered it. One performance test stayed failing for a whole phase, with its 50 ms limit unchanged, until the spec described the incremental scheduler that fixed it. With vibe coding I would have just loosened the limit.

2. Steering turned into checks. Three steering files hold the non-negotiables, and each rule became something a machine checks. The core package can't use DOM or Node APIs (it's a compile error), every dependency license is audited, and colors and trademarks are scanned in tests.

3. Hooks that test while I build. A hook reruns the property tests every time the agent edits core code, and logs any new counterexample. Property tests caught bugs I'd never have written a unit test for: MOD(1, -3) returned the wrong sign, and a formula like AA(#N/A/FALSE) stopped parsing after it was printed.

4. "Discuss first". I saved a rule as a Kiro learning: before any edit, propose options and trade-offs, then wait for my approval. Every phase started with a plan I agreed to, not with surprise code.

MCP: an agent that proves fixes

The same engine ships as an MCP server on npm:

npx -y @g4stein/suture-mcp@0.1.0

It gives Kiro four tools. The interesting one is suture_verify_patch: Kiro proposes a fix like =IF(B4<=0,120,Inputs!B2/B4), and Suture replays the counterexample against it, runs a fresh 1,000-run audit, and reports counterexampleFixed: true with zero regressions. The agent proves the fix instead of guessing.

Kiro Crew: the nightly auditor

I also built Suture Crew, a Kiro Crew app with three agents. Schema Archaeologist maps lineage, Invariant Adversary runs the fuzzer and posts X-Ray links, and Formula Surgeon only recommends a fix after it's been proven. It has a nightly schedule and a dashboard.

What I learned

  • Writing the spec before the code is what made three very different engines agree.
  • A rule only stays true if a machine checks it.
  • Property-based testing finds the bugs you didn't think to look for, in your tests and in your users' spreadsheets.

Try it

I'm a student at Mizoram University, and this is the biggest project I've built. I'd love feedback!

來源:DEV Community · dev.to