-
-
The Morgue: browse precomputed legacy JavaScript corpses with zero model calls, or sign in with GitHub to import your own.
-
The Hex Scanner: deterministic acorn AST analysis detects curses with exact line numbers without executing the legacy code.
-
The Séance Chamber: extracts business logic into EARS requirements, design notes, and input/output invariants before rewrite.
-
The Laboratory: strict TypeScript reincarnation and fast-check test verifying behavioral equivalence across 1,000 inputs.
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:
- The Morgue & The Crypt — Anonymous visitors explore three precomputed sample corpses in The Morgue (
computeInvoiceTotal,parseQueryString, andcalculateBatch) with zero language model calls or database writes. Signed-in GitHub members also get The Crypt (private history) and can import their own.jsfiles. - The Hex Scanner — A deterministic
acornAST 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, andPROTOTYPE_POLLUTION. - 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. - The Laboratory — Generates a strict TypeScript module (the Reincarnation) alongside a
fast-checkproperty 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 counterexamplefast-checkfound.
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 = falseinapps/web/src/lib/verification/flags.ts) because in-processnode:vmis 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) withprefers-reduced-motionsupport. - Packages:
@lazarus/mcp-curse-scanner(acorn+@modelcontextprotocol/sdk),@lazarus/pbt-verifier(fast-checkequivalence runner), and@lazarus/sandbox-runner(Worker thread supervisor with freshnode:vmcontexts, heap watchdog, and timeout limits). - Database & Auth: Supabase Postgres with GitHub OAuth, Flyway migrations (
db/migrations/V1toV4), 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 viasupabase.auth.getClaims(), paired with SHA-256code_hashcaching 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-foundationthrough11-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) loadalways. Four load conditionally viafileMatch(database-and-exorcism.md,ui-components.md,testing-conventions.md,spec-execution.md) to keep context sharp, andwriting-and-claims.mdloads 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): runspnpm lintand 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 newV*.sqlmigration is created.
- Shared MCP server (
.kiro/settings/mcp.json):@lazarus/mcp-curse-scannerruns both as Kiro's MCP server (scan_ast_cursesandextract_function_signatures) and as the library backingPOST /api/scan, so Kiro and the web app execute the exact same AST analyzer. - 3 workspace skills (
.kiro/skills/): Step-by-step workflows forresurrect-corpse,add-curse-type, andadd-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-argumentassertEquivalent(input)helper passed the entire generated value intoweightKgand leftzoneandisExpressasundefined. Both versions could returnNaNand 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 spec11-multi-argument-entry, addedassertEquivalentArgs(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 spec05. - Worker memory accounting in Node.js: During spec
07-sandboxed-execution, an early spike showed thatprocess.memoryUsage().arrayBufferson the host process stayed at0 MBeven while a Worker thread allocated192 MB, meaning our planned watchdog would never have triggered. Measuring that assumption early led us to supervise memory viaworker.getHeapStatistics()instead. - Dynamic code vs. safe live verification: One of our three sample corpses (
batch-calculator) intentionally carries theEVAL_INJECTIONcurse (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, whilebatch-calculatorreturns 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
acornAST 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 15in spec06) before the backend routes even existed, and prevented cross-package scope creep when unrelated timeouts surfaced. - Turn critical conventions into
PreToolUsehooks: ConditionalfileMatchsteering kept daily code generation clean, while promoting must-never-break rules (immutable migrations, secret boundaries, honest wording) intoguard-sensitive-writesturned 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-runnerfrom 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-guidancefor interactive remediation guidance per curse type, and13-stage-tabsfor 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
- acorn
- docker
- fast-check
- flyway
- github-actions
- groq
- gsap
- javascript
- kiro
- model-context-protocol
- next.js
- node.js
- pnpm
- postgresql
- react
- shadcn-ui
- supabase
- tailwindcss
- turborepo
- typescript
- vercel-ai-sdk
- vitest
- zod