跳到正文
DEV Community· Ashlesha Anjarkar·· 8 天前AI 評分49

Lazarus:如何利用 Kiro Specs、自訂 MCP 與差分模糊測試復活舊有 JavaScript 模組

How I Built Lazarus: Autonomous Legacy Resurrection with Kiro Specs, Custom MCP, and Differential Fuzzing

AI 導讀

作者構建了 Lazarus,一個以隔離執行沙盒、4 個 Agent 組成的 Kiro Crew 和 fast-check 差分模糊測試,協助安全地現代化舊有 JavaScript 模組的引擎。系統會找出新舊程式行為差異、縮減至最小反例,再交由 Agent 自動修正。Lazarus 的 10 個測試套件共有 86 項測試通過。

正文

Ashlesha Anjarkar

Engineering teams sit on unmaintained legacy JavaScript modules they are afraid to touch because manual rewrites introduce silent edge-case regressions. For Kiroween 2026 (Frankenstein category), I built Lazarus — an autonomous legacy resurrection engine that stitches an isolated execution sandbox together with a 4-agent Kiro Crew and fast-check property-based differential fuzzing.

Why Unit Tests Miss Legacy Regressions

Consider a classic ES5 32-bit integer truncation expression: (n / 2) | 0. A naive modernization replaces | 0 with Math.floor(n / 2). On positive integers, both match. On negative odd integers like -3, (-3 / 2) | 0 evaluates to -1, whereas Math.floor(-3 / 2) evaluates to -2.

How Lazarus Proves Behavioral Parity

  1. Isolated Sandbox (src/sandbox/): Executes untrusted legacy code in a locked-down Node child process with strict memory, timeout, filesystem, and network restrictions.
  2. Custom MCP Server (lazarus-sandbox): Exposes run_legacy_probe over stdio in .kiro/settings/mcp.json so agents safely probe legacy expressions.
  3. 4-Agent Kiro Crew (.kiro/agents/):
    • Archaeologist probes boundary inputs to capture baseline runtime traces.
    • Architect synthesizes observed behavior into formal Kiro specifications.
    • Necromancer modernizes the code to ES2022+.
    • Exorcist runs fast-check differential fuzzing (Object.is parity checks for -0 vs +0, NaN, and integer truncation). When Exorcist finds a divergence, it shrinks the input to a minimal counterexample and feeds it back to Necromancer to self-heal automatically.

Engineered with Kiro Spec-Driven Development

Every subsystem in Lazarus was designed using formal requirements, architecture designs, and implementation task lists inside .kiro/specs/, paired with repository-wide steering guidelines (.kiro/steering/) and an automated on-save Vitest hook (.kiro/hooks/run-tests-on-save.json) verifying 86 passing tests across 10 suites.

來源:DEV Community · dev.to