02 — The problem

AI can rewrite legacy code. It can’t show where the code came from.

Memory-unsafe C and C++ still sits under critical systems, and replacing it has meant funded teams working for months or years. AI coding agents can do the same work in hours.

But they keep the model away from prior art with instructions in a prompt, record nothing verifiable about what it read, and never measure how close the output is to existing code. A model that has seen the original can reproduce it, and nothing in the result would show it. That output can’t support a clean-room claim.

03 — How it works

The pipeline runs today. The clean room goes around it next.

Fig. 1 — The Kūkulu pipeline and its clean room Solid: in the plugin today Dashed: clean-room mode, coming in 0.7.0

INPUTYour spec, and in clean-room mode its RFCs

BLOCKED BY THE GUARDThe original source and other existing implementations

CLEAN ROOM · 0.7.0 · GUARD CHECKS EVERY TOOL CALL

  1. STAGE 01

    Plan

    Reads the spec and turns it into an ordered build plan.

    model · frontier

  2. STAGE 02

    Implement

    Writes the code, one planned task and one commit at a time.

    model · efficient or local

  3. STAGE 03

    Review

    Checks the build against the spec and plan, and flags what it missed.

    model · frontier

    Misses go back to Implement for fixes

  4. STAGE 04

    Summarize

    Writes up what was built, what changed, and what is left.

    model · any

  5. misses go back for fixes

Provenance log: every call, allowed or denied, hash-chained Controller: no stage advances until isolation checks out

  1. EVIDENCE 01

    Equivalence

    The original is used only as a black box. Conformance corpora and differential fuzzing compare outputs byte for byte.

  2. EVIDENCE 02

    Contamination score

    Similarity to existing code, placed on a scale from independent implementations to known derivations.

  3. EVIDENCE 03

    Attestation bundle

    Policy history, log, checkpoints and results in a signed manifest that a third party can verify offline.

Put a SPEC.md in docs/, run /kukulu:go-flight, and come back to a reviewed branch with a draft pull request.

04 — Why it holds up

Built to finish the run, and then to show its work.

In the plugin today

  • Deterministic orchestration

    A dependency-free MCP server decides which stage and task run next. No model picks its own next step, so a flight survives a crash or a restart.

  • The right model for each stage

    Frontier models plan and review; a cheaper or local model implements. Route any role to Anthropic, OpenRouter or Ollama.

  • Adversarial review

    A separate reviewer checks the branch against the spec, mutation-tests the tests, and queues fixes until it approves.

  • Scoped tools

    Each stage agent gets only the tools its job calls for. Its tool list is the contract.

  • No silent stops

    A flight finishes approved, or halts with a recorded reason a human can act on.

Clean-room mode · coming in 0.7.0

The method behind cleanflate, and the subject of a pending patent.

  • Enforced isolation

    A guard checks every tool call’s target against a declarative policy before it runs. The policy and the guard are protected from the agents.

  • Gated stages

    Before each stage, the controller verifies the policy, the guard, a self-test and the log, and stops if anything fails.

  • Tamper-evident provenance

    Every tool call, allowed or denied, and every human instruction goes into a hash-chained log with signed checkpoints.

  • Calibrated contamination scoring

    Similarity scored on a scale where 0 is an independent pair of implementations and 1 is a known derivation.

  • Offline attestation

    The evidence ships as a signed bundle a reviewer can verify without access to your systems.

05 — Get started

Your first flight.

You need Claude Code, Node 22 or later, and git. There is nothing to npm install.

  1. Install the plugin

    In a Claude Code session, run the two commands at the top of this page. From a shell, it’s the same two steps:

    claude plugin marketplace add https://kukulu.tech/marketplace.json
    claude plugin install kukulu@displacetech

  2. Write a spec

    Start from the template, fill it in, and commit it on your base branch. The spec guide says what the planner needs from each section.

    mkdir -p docs
    curl -fsSL https://raw.githubusercontent.com/DisplaceTech/kukulu/main/templates/SPEC.md -o docs/SPEC.md
    git add docs/SPEC.md && git commit -m "spec"

  3. Start the flight

    Run it in a Claude Code session and leave it. The first run sets up the stage agents and the permission rule an unattended run needs.

    /kukulu:go-flight

  4. Review and merge

    Read docs/SUMMARY.md, then review the draft pull request from the build/<date> branch. Kūkulu never merges on its own.

Run a stage somewhere else. Every role defaults to an Anthropic model. To point one at OpenRouter or a local Ollama model, copy the routing example to ~/.config/kukulu/config.json and follow the routing guide.

06 — Proof

cleanflate

A clean-room DEFLATE decompressor in safe Rust, built by Kūkulu from RFCs 1950–1952 alone, without access to zlib’s source.

Built with Kūkulu 0.3.2, then named Foundry, under the clean-room controls that come to the plugin in 0.7.0.

Did anything leak from zlib? Identifier overlap with C zlib (Jaccard index). Lower means more independent.

cleanflate sits with an independently written decoder, at about a fifth of a known port. Comment overlap is near zero: 0.0003, against 0.032 for the port.

From cleanflate-bench at commit 7f50ce6, which reproduces every number from a clean clone. Measured on one ARM and one x86 machine. Limits: one target library; two operator fixes bypassed pipeline review and are recorded in the log.
Claim Result
Clean room 0 forbidden reads among 2,226 read-capable tool calls. The one agent attempt to reach prior-art source was blocked.
Equivalent 2,962 of 2,962 conformance streams byte-identical to C zlib. 0 divergences in 1.24M differential-fuzz executions against C zlib, zlib-rs and miniz_oxide.
Memory-safe 0 lines of unsafe code, 0 runtime dependencies.
Viable 0.71–0.76× C zlib throughput on the Silesia corpus, with no SIMD and no unsafe.
Cost About 28 hours of pipeline time, $361 in model usage, 11 operator interventions.

07 — Where it’s going

Next on the bench.

  1. NEXT 01 · 0.7.0

    Clean-room mode in the plugin, for modernizing legacy software into memory-safe code.

  2. NEXT 02

    A vendor-agnostic package.

  3. NEXT 03

    Continuous fuzzing and multi-pair similarity calibration.