Inspiration

Old JavaScript still runs critical logic in production: ES3 billing scripts, ES5/jQuery utilities, and early Node.js callback modules from a decade ago. Teams want to modernize these files into strict TypeScript, yet nobody remembers every edge case, and the original test suites are usually missing.

Asking a language model to translate a legacy file line by line produces code that looks modern, but appearances are deceiving. Did fixing var hoisting change a loop boundary? Did replacing == with === break an implicit string-to-number coercion that callers relied on? Codemods and syntax migrators add types, yet they do not check whether the rewritten code still behaves like the original.

For Kiroween 2026 (Resurrection), we built Lazarus around a simple idea: treat legacy modernization not as a blind translation, but as a structured pipeline that ends with empirical equivalence evidence from property-based tests.

What it does

Lazarus resurrects legacy JavaScript corpses (ES3, ES5/jQuery, and legacy Node) into strict TypeScript and checks with property-based tests whether the modern function agrees with the legacy function across generated inputs.

Every corpse moves through four stages:

  1. The Morgue & The Crypt — Anonymous visitors explore three precomputed sample corpses in The Morgue (computeInvoiceTotal, parseQueryString, and calculateBatch) with zero language model calls or database writes. Signed-in GitHub members also get The Crypt (private history) and can import their own .js files.
  2. The Hex Scanner — A deterministic acorn AST analyzer (@lazarus/mcp-curse-scanner) inspects the source as text without executing it. It detects six curses with exact line numbers and severities: GLOBAL_POLLUTION, VAR_HOISTING, IMPLICIT_COERCION, CALLBACK_HELL, EVAL_INJECTION, and PROTOTYPE_POLLUTION.
  3. The Séance Chamber — Extracts the business logic ("the soul") into a structured specification: EARS requirements (requirements.md), design.md, and input/output invariants, validated with Zod via the Vercel AI SDK and Groq. The owner reviews and approves the spec before code generation begins.
  4. The Laboratory — Generates a strict TypeScript module (the Reincarnation) alongside a fast-check property test, type-checks it in memory, and executes both the legacy function and the modern function on 1,000 generated inputs inside @lazarus/sandbox-runner. When they agree on every tried input, Lazarus reports empirical equivalence evidence with the exact run count: "Verified behavioral equivalence across 1,000 generated inputs." When they disagree, a failing run is reported as a first-class result showing the exact counterexample fast-check found.

Honest scope and security boundaries

  • Supported sources: Legacy JavaScript only (ES3, ES5/jQuery, legacy Node), targeting one pure, deterministic top-level named entry function per corpse.
  • Live sandbox switch: Signed-in members can run live verification on the reviewed sample corpses (Verify live). For member-imported code, the reincarnation and property test are generated and type-checked, while live execution ships switched off (USER_EXECUTION_ENABLED = false in apps/web/src/lib/verification/flags.ts) because in-process node:vm is not a hard security boundary.

How we built it

Architecture & Tech Stack

  • Monorepo: Node.js 24, pnpm workspaces, Turborepo, and strict TypeScript 6.
  • Web App (apps/web): Next.js 16 (App Router), React 19, Tailwind CSS 4, shadcn/ui, and GSAP (@gsap/react) with prefers-reduced-motion support.
  • Packages: @lazarus/mcp-curse-scanner (acorn + @modelcontextprotocol/sdk), @lazarus/pbt-verifier (fast-check equivalence runner), and @lazarus/sandbox-runner (Worker thread supervisor with fresh node:vm contexts, heap watchdog, and timeout limits).
  • Database & Auth: Supabase Postgres with GitHub OAuth, Flyway migrations (db/migrations/V1 to V4), and Row Level Security on every table. Route Handlers never use the service role key; every query runs under the caller's session token verified via supabase.auth.getClaims(), paired with SHA-256 code_hash caching and per-user rate limits.
  • Models: Vercel AI SDK 7 with Groq (openai/gpt-oss-120b) and an optional Google fallback.

Built spec-by-spec in Kiro IDE

Lazarus was built entirely in Kiro IDE using specs, steering, hooks, MCP, and skills:

  • 11 completed feature specs (.kiro/specs/01-lazarus-foundation through 11-multi-argument-entry): Every feature started as EARS requirements, a design with numbered correctness properties, and scoped implementation tasks before any code was written.
  • 8 steering files (.kiro/steering/): Only 3 core files (product.md, tech.md, structure.md) load always. Four load conditionally via fileMatch (database-and-exorcism.md, ui-components.md, testing-conventions.md, spec-execution.md) to keep context sharp, and writing-and-claims.md loads manually to enforce accurate technical claims.
  • 5 agent hooks (.kiro/hooks/ & scripts/hooks/):
    • guard-sensitive-writes (PreToolUse): blocks edits to applied Flyway migrations, blocks server secrets in client code, and intercepts overreaching accuracy claims in user-facing files before writes hit disk.
    • scanner-tests-on-save (PostFileSave): runs the scanner suite automatically on save.
    • verify-after-task (PostTaskExec): runs pnpm lint and affected package tests after each spec task.
    • spec-status-on-start (SessionStart): prints task progress across all specs when a session begins.
    • migration-checklist (PostFileCreate): surfaces RLS, index, and immutability rules whenever a new V*.sql migration is created.
  • Shared MCP server (.kiro/settings/mcp.json): @lazarus/mcp-curse-scanner runs both as Kiro's MCP server (scan_ast_curses and extract_function_signatures) and as the library backing POST /api/scan, so Kiro and the web app execute the exact same AST analyzer.
  • 3 workspace skills (.kiro/skills/): Step-by-step workflows for resurrect-corpse, add-curse-type, and add-flyway-migration.
  • 178 test files & 160 tagged property tests: Across the scanner, verifier, sandbox runner, web app, and disposable-Postgres database suite, 160 property tests carry // Feature: <spec>, Property <N> tags linking them directly to numbered design properties.

Challenges we ran into

  • The multi-argument equivalence trap: While reviewing a real multi-parameter import (calculateShipping(weightKg, zone, isExpress)), we discovered a subtle flaw in our original test contract. Calling a multi-parameter entry function through a single-argument assertEquivalent(input) helper passed the entire generated value into weightKg and left zone and isExpress as undefined. Both versions could return NaN and appear equivalent without ever testing real multi-argument behavior! Because live execution on user imports was off in production, no user saw a false verdict. We wrote spec 11-multi-argument-entry, added assertEquivalentArgs(args), made both runners reject single-argument calls for functions with two or more parameters (TEST_CODE_ERROR), and added static validation—which immediately caught the same bug hiding in a shared test fixture from spec 05.
  • Worker memory accounting in Node.js: During spec 07-sandboxed-execution, an early spike showed that process.memoryUsage().arrayBuffers on the host process stayed at 0 MB even while a Worker thread allocated 192 MB, meaning our planned watchdog would never have triggered. Measuring that assumption early led us to supervise memory via worker.getHeapStatistics() instead.
  • Dynamic code vs. safe live verification: One of our three sample corpses (batch-calculator) intentionally carries the EVAL_INJECTION curse (eval). Live sandbox runs forbid dynamic code generation, creating a tension between executing every sample live and enforcing strict runtime rules. Rather than weakening the sandbox or faking a test, we documented and tested the real outcome: two samples verify live, while batch-calculator returns an inconclusive dynamic-code result without mutating stored data.

Accomplishments that we're proud of

  • Turning legacy JS modernization into an auditable four-stage pipeline where counterexamples are surfaced openly rather than hidden.
  • Sharing a single deterministic acorn AST analyzer between Kiro IDE (over MCP stdio) and the Next.js production API (POST /api/scan).
  • Maintaining strict security hygiene: Row Level Security on every Postgres table, zero service-role usage in web routes, 1,024-byte request caps on Route Handlers, and honest feature gating around in-process code execution.
  • Shipping 178 test files—including 160 spec-linked property-based tests—enforced in CI against a real disposable Postgres 17 instance with Flyway migrations.

What we learned

  • Small specs beat vibe coding: Splitting Lazarus into 11 focused specs let us design UI panels against explicit API contracts (Open Item 15 in spec 06) before the backend routes even existed, and prevented cross-package scope creep when unrelated timeouts surfaced.
  • Turn critical conventions into PreToolUse hooks: Conditional fileMatch steering kept daily code generation clean, while promoting must-never-break rules (immutable migrations, secret boundaries, honest wording) into guard-sensitive-writes turned human reminders into automated pre-write checks.
  • A property test is only as good as how it calls the target: Generating 1,000 random inputs means nothing if trailing parameters receive undefined. Enforcing arity matching at both static-check time and runtime closed that gap.

What's next for Lazarus

  • Out-of-process isolation for imported code: Moving @lazarus/sandbox-runner from in-process Worker threads into ephemeral microVMs or isolated containers so live verification can be safely enabled for member-imported corpses.
  • Curse Grimoire & Stage Tabs: Implementing our two drafted follow-up specs (12-grimoire-and-curse-guidance for interactive remediation guidance per curse type, and 13-stage-tabs for faster navigation across the resurrection panels).
  • Broader module shapes: Extending verification beyond pure top-level entry functions to stateful closures, CommonJS exports, and callback-to-Promise adapters.

Built With

Share this project:

Updates

Submission history