Back to Archive
REVOLUTIONProduct

Blueprints Before Refactors

How extracting bounded computation from an existing codebase can make rewrites and target changes easier to review.

2026-03-21T00:00:00.000Z
Editorial cover for Blueprints Before Refactors

The PCD Roundtrip — One feature. Every language. Mathematical certainty.

The Problem Nobody Talks About

Every codebase starts clean. Pristine. Beautiful. Six months later? Patches on patches. Edge cases nobody documented. Functions that "work" but nobody on the team knows why. Tests? Some, maybe. Documentation? Laughably outdated. Confidence that any of it is correct? Absolute zero.

You know this feeling in your bones. You open a file and see a function with a comment that says // TODO: fix this later — dated three years ago. Four different developers have modified it since then. There are no tests. There is no specification. There is only the code itself, and the code is supposed to be the truth — except nobody on your team is sure what truth it is telling.

The "big rewrite" takes months, costs a fortune, and usually fails. Refactoring? That is lipstick on a pig — you reorganize the mess without ever proving it was correct in the first place. Both options are broken. But what if there was a third option?

What if you could extract the computational essence of your messy code, verify it mathematically, and recompile it into clean code — with auto-generated tests — in any language you want? What if the mess goes in and certainty comes out?

The Roundtrip

Your messy JS →
brikc lift → PCD blueprint →
brikc build --target js → Clean JS + tests

This is the PCD Roundtrip. It is not transpilation — transpilers just move your bugs to a new syntax. It is not refactoring — refactoring rearranges code without proving anything. It is not a linter with opinions. It is something fundamentally different:

Extract the computational essence. Verify it formally. Recompile from the specification.

What goes in: spaghetti code with no tests, inconsistent naming, undocumented edge cases, magic numbers everywhere, and functions that "probably work" — your entire legacy nightmare.

What comes out:

Clean code — regenerated from the mathematical specification, not from your formatting preferences

Auto-generated tests — derived from the formal verification, not from a developer guessing what to test

The PCD blueprint — a permanent, language-independent specification of what your code actually does

Let me say that again because it is the most important idea in this entire article: the blueprint is the product. The clean code is a side effect.

A Real Example

Here is a function that exists in thousands of codebases right now. You have seen it. You have probably written something like it. A pricing calculation written under deadline pressure, modified twice by two different people, never tested:

// TODO: fix this later
function calcPrice(qty, price, tax, disc) {
var total = qty * price
if(disc > 0) total = total - (total * disc / 100) total = total + (total * tax / 100)
return Math.round(total * 100) / 100
// cents hack }

Look at this. No types. No validation. A comment that says "fix this later" — from who knows when. A rounding trick labeled "cents hack." The variable disc could be a percentage or a decimal — nobody documented it. Does tax apply before or after the discount? You have to read the code carefully to find out. And if you read the code wrong, you bill your customers wrong. Real money. Real liability.

Step 1: Lift

$ brikc lift pricing.js [LIFT] pricing.js Found: calcPrice (4 params, 1 return) Liftability: 0.92 (pure arithmetic, no side effects) Monomers: 4 (arithmetic family) Status: CORE (Φc = 1) Output: pricing.pcd

The Lifter reads your JavaScript function and strips away everything that does not matter — variable names, formatting, comments, the "cents hack." It sees the computational essence underneath: multiplication, conditional subtraction, addition, division. Pure arithmetic. Liftability score: 0.92 — nearly perfect. The 0.08 deduction is for the Math.round rounding behavior, which maps to a specific monomer. Even the hack gets formalized.

Step 2: The PCD Blueprint

PC calcPrice { let qty = 0; let price = 0; let tax = 0; let disc = 0; let subtotal = qty * price; let after_discount = subtotal - (subtotal * disc / 100); let with_tax = after_discount + (after_discount * tax / 100); OUTPUT with_tax; }Read this. Even if you have never seen PCD before in your life, you know exactly what this function does. The inputs are explicit. The computation is step-by-step. There are no tricks, no hacks, no "TODO" comments, no "cents hack." This is the mathematical specification of your pricing logic. Pure. Clear. Permanent.

The TCE certifies Phi C = 1: the circuit is closed. Every input produces a deterministic output. Every single operation is mathematically certified. The blueprint is the truth — and for the first time, the truth is not just correct. It is readable.

Step 3: Build

$
brikc build calcPrice.pcd --target js [BUILD] calcPrice.pcd → calcPrice.js Target: JavaScript (ES2020) Monomers: 4 (arithmetic family) Tests: 12 generated Status: CERTIFIED (Φc = 1) Output: calcPrice.js, calcPrice.test.js

The emitted JavaScript is clean, typed, and beautifully structured. But the real breakthrough is calcPrice.test.js — twelve tests auto-generated from the mathematical certification. Not random inputs someone threw together. Not edge cases a developer guessed at during a sprint. Tests derived from the mathematical properties of the circuit itself: boundary conditions, zero inputs, maximum values, the discount-before-tax ordering. The math writes the tests.

Step 4: The Auto-Generated Tests

// Auto-generated from PCD certification (Φc = 1)
// calcPrice: 4 inputs → 1 output, 4 monomers test('zero quantity
returns zero', () => { expect(calcPrice(0, 100, 10, 5)).toBe(0); }); test('zero discount applies full price', () => { expect(calcPrice(10, 50, 10, 0)).toBe(550); }); test('discount applies before tax', () => {
const withDisc = calcPrice(1, 100, 10, 20);
const withoutDisc = calcPrice(1, 100, 10, 0); expect(withDisc).toBeLessThan(withoutDisc); }); test('100% discount results in tax on zero', () => { expect(calcPrice(10, 50, 10, 100)).toBe(0); });
// ... 8 more tests covering all monomer boundariesThese tests are not opinions. They are not guesses. They are mathematical consequences of the specification itself. The PCD blueprint defines the
function. The tests prove the emitted code matches the blueprint. This is not "we think it works." This is not "it passed CI." This is "the math says it works, and here is the proof."

But Wait — Export to ANY Language

Now watch this. The PCD blueprint is language-independent. It does not describe syntax — it describes computation. From the exact same calcPrice.pcd blueprint:

brikc build calcPrice.pcd --target rust # Rust with ownership semantics
brikc build calcPrice.pcd --target python # Python with
type hints
brikc build calcPrice.pcd --target go # Go with error handling
brikc build calcPrice.pcd --target c # C with headers
brikc build calcPrice.pcd --target cobol # Yes, even COBOLSame logic. Same verification. Same auto-generated tests, adapted to each language's native testing framework. Five languages from one single blueprint. The PCD does not care what language you started with or what language you are going to. It cares about one thing: what your code actually does.

Your CTO says "we are migrating to Rust"? You do not rewrite 500,000 lines of JavaScript. That is insane. You lift, verify, and emit. The blueprint guarantees behavioral equivalence across every target. The auto-generated tests prove it. The migration that would take two years and probably fail? Two weeks. Done.

The Two-Tier Certification

"But my code has API calls. It reads from databases. It writes to the filesystem. You can't formally verify fetch."

Correct. And BRIK64 does not pretend to. Instead, it uses a two-tier certification system that handles real-world code honestly:

CORE (Phi C = 1): Pure logic — arithmetic, string manipulation, control flow, data transformation. These operations are mathematically proven correct. The circuit is closed. The verification is absolute. under declared constraints.

CONTRACT (Phi C = CONTRACT): Side effects — fetch, console.log, filesystem operations, database queries, async operations. These map to extended monomers with a contract: "this operation performs X." The verification proves that all the logic surrounding the side effect is mathematically correct.

Think of it this way: BRIK64 cannot prove that your API will return a 200. But it can prove that when the API returns a 200, your code processes the response correctly. And when it returns a 500, your error handling does the right thing. The pure logic is certified. The side effects are contracted. Together, they cover your entire application.

Your React app with fetch calls? Liftable. Your Node.js API with database queries? Liftable. Your Python data pipeline with file I/O? Liftable. Every real-world application you actually build gets the roundtrip treatment.

The Blueprint Is the Product

Most developers think the clean code is the output. They are wrong. The PCD blueprint is the output. The clean code is just one possible rendering — one view — of that blueprint.

Let me tell you why the blueprint matters more than any code you will ever write:

1. Single source of truth. The PCD defines what your code does — mathematically. Not what a developer intended. Not what a test suite happens to cover. What the code actually computes, proven for all inputs.

2. Language-independent. Change your entire stack without rewriting a single line of logic. The blueprint persists across every language migration, every framework change, every platform shift. It outlives your technology choices.

3. Self-documenting. The blueprint IS the documentation. Read the PCD and you know exactly what the function does. No Javadoc. No JSDoc. No "see README for details" that leads to a 404. The specification is the documentation. They are the same thing.

4. Permanently verifiable. Run brikc check anytime, anywhere, to re-verify. The blueprint does not rot. It does not become outdated. It is mathematically true today and it will be mathematically true in ten years. Truth does not have an expiration date.

5. Composable. Combine certified circuits from the BRIK64 registry. Build complex systems from verified building blocks. Every connection is type-checked. Every composition is certified.

The Business Case

The Roundtrip — Business Impact ────────────────────────────────────────────────── PROBLEM PCD ROUNDTRIP ────────────────────────────────────────────────── "Big rewrite" (2 years, fails) Lift incrementally, one function at a time "Add tests later" (never) Tests auto-generated from specification "Only Bob knows this code" Blueprint explains it — Bob can retire "Can't switch to Rust" (500K JS) Emit to Rust from the same blueprints "Docs are outdated" Blueprint IS the documentation "How do we prove compliance?" Φc = 1 is the proof — auditable, permanent ──────────────────────────────────────────────────The roundtrip does not just improve your code. It fundamentally changes the economics of software maintenance. Every function you lift becomes a function that any developer on Earth can understand, any language can render, and any auditor can verify in seconds. The cost of understanding code drops to zero — because the blueprint IS the understanding.

What This Is Not

Let me be very precise about what the PCD Roundtrip is not, because clarity matters:

It is not transpilation. Transpilers convert syntax — they turn your messy JavaScript into messy TypeScript with the exact same structure and the exact same bugs. The roundtrip does something entirely different: it extracts the computation, verifies it mathematically, and regenerates from the specification. The output is not a translation — it is a recompilation from truth.

It is not a linter. Linters enforce style — they tell you to use const instead of var and add semicolons. The roundtrip does not care about your style, your tabs versus spaces, or your bracket placement. It cares about one thing: what your code computes, and whether that computation is mathematically correct.

It is not AI-powered refactoring. AI refactoring tools guess what your code should look like — sophisticated guessing, but guessing nonetheless. The roundtrip does not guess. It extracts, verifies mathematically, and regenerates deterministically. Same input, same output, every single time. No hallucinations. No "it looks right." No surprises.

It is not magic. We are honest about what we can do. Code with side effects gets CONTRACT certification, not CORE. Functions with deeply dynamic behavior may have lower liftability scores. The Lifter tells you exactly what it can and cannot verify — honestly, transparently, with a number between 0.0 and 1.0. No hand-waving. No false promises.

Getting Started

Then emit it back. Clean code. Auto-generated tests. A permanent specification. Do it for one function. See the difference. Then do it for ten. Then do it for the entire module. Then watch your team start sleeping at night.

Your codebase is not broken. It is undocumented, unverified, and locked into one language. The roundtrip fixes all three — permanently. Not temporarily. Not until the next sprint. Permanently.

The Messy Code Goes In. The Blueprint Comes Out.

Your code already works. Probably. But let me ask you four questions. Can you prove it works? Can you export it to another language in one command? Can you auto-generate tests from a mathematical specification? Can you hand that specification to a new developer and have them understand your entire system in an afternoon?

Now you can. The messy code goes in. The blueprint comes out. And from that blueprint: clean code in any language, with tests, with verification, with mathematical certainty.

That is not refactoring. That is not transpilation. That is recompilation from truth. And it changes everything.

More reading

Continue the archive

Full archive
Technical BRIK64 diagram showing an AI coding prompt transformed into a reviewable blueprint, human review checkpoint, and target outputs.
AI safetyUncategorized

Reviewable AI Coding Pipelines: From Prompt to Blueprint

AI-generated code workflows become more reviewable when teams separate the prompt, generated code, structural blueprint, human review, and target compilation.

Open article
BRIK64 editorial image showing AI-generated software becoming inspectable, certified, and compiled across targets.
AI-generated softwareUncategorized

Making AI-Generated Software Reviewable

AI-generated software can move quickly, but it still needs structure, traceability, and review boundaries. BRIK64 helps teams preserve the blueprint behind generated code.

Open article
Editorial cover for AI Governance Workflows Need Reviewable Technical Evidence
AI SAFETYAI Safety

AI Governance Workflows Need Reviewable Technical Evidence

How bounded software evidence can help teams carry AI governance reviews into compliance workflows without implying full legal coverage.

Open article
Editorial cover for Compiler Evidence: Targets, Proof Files, and Test Scope
ENGINEERINGEngineering

Compiler Evidence: Targets, Proof Files, and Test Scope

A summary of the public numbers that can be stated responsibly and the limits of what those numbers prove.

Open article
Editorial cover for Safety-Critical Software Needs a Readable Assurance Path
PRODUCTProduct

Safety-Critical Software Needs a Readable Assurance Path

How bounded software evidence can support engineering review in high-consequence domains without replacing the broader safety program.

Open article
Editorial cover for Bounded Contract Logic Before Deployment
PRODUCTProduct

Bounded Contract Logic Before Deployment

Why smart contract workflows benefit from explicit state boundaries, value constraints, and reviewable rule sets before deployment.

Open article
Editorial cover for What the Proof Material Means for Users
VISIONFoundations

What the Proof Material Means for Users

A practical note on the proof files behind the compiler and what remains invisible to a normal authoring workflow.

Open article
Editorial cover for Why a New Format Instead of Another General-Purpose Language
VISIONFoundations

Why a New Format Instead of Another General-Purpose Language

Why BRIK64 introduces PCD as a bounded computational format rather than extending a conventional language with another annotation layer.

Open article
Editorial cover for Adversarial Testing Against the Compiler Chain
ENGINEERINGEngineering

Adversarial Testing Against the Compiler Chain

How the team tries to break the compiler and what those tests can and cannot prove about the formal system.

Open article
Editorial cover for Translation Validation Across Two Targets
RESEARCHResearch

Translation Validation Across Two Targets

A look at cross-target output comparison, what it can support, and what still depends on the bounded intermediate form.

Open article
Editorial cover for Why Tests Passing Is Not the Same as Closure
VERIFICATIONEngineering

Why Tests Passing Is Not the Same as Closure

A look at sampled testing versus bounded verification, with examples of logic that passed tests but still required stronger structural checks.

Open article
Editorial cover for One Blueprint Across Multiple Targets
PRODUCTProduct

One Blueprint Across Multiple Targets

How the transpilation chain uses PCD as a bounded intermediate form, what 10 source languages and 14 targets mean in practice, and where the equivalence claim stops.

Open article
Editorial cover for What AI Intuition Still Cannot Verify
AI SAFETYAI Safety

What AI Intuition Still Cannot Verify

Why intuition without an external proof path remains a risk, and where BRIK64 fits in that boundary.

Open article
Editorial cover for API and MCP Access Around the Registry
PLATFORMProduct

API and MCP Access Around the Registry

How discover-and-execute workflows expose registry and platform operations to humans and agents without enlarging the proof claim.

Open article
Editorial cover for A Bounded JavaScript-to-Rust Workflow
TUTORIALGetting Started

A Bounded JavaScript-to-Rust Workflow

Lift the logic, review the bounded blueprint, then emit a target language while keeping the claim attached to the intermediate circuit.

Open article
Editorial cover for Lifting Existing Code into a Reviewable Blueprint
TOOLINGProduct

Lifting Existing Code into a Reviewable Blueprint

What the Lifter preserves, where liftability evidence exists in the repo, and how bounded blueprints help before migration.

Open article
Editorial cover for COBOL Migration Through Bounded Lift-and-Review
MIGRATIONProduct

COBOL Migration Through Bounded Lift-and-Review

Why legacy modernization benefits from lifting review-critical logic into a bounded blueprint before transpilation or replacement.

Open article
Editorial cover for Why AI-Generated Code Needs Blueprints and External Checks
PRODUCTAI Safety

Why AI-Generated Code Needs Blueprints and External Checks

Generated code and generated tests can fail together. This note explains why BRIK64 keeps verification outside the model loop.

Open article
Editorial cover for Which Parts of a Codebase Are Ready for Stronger Review?
PRODUCTProduct

Which Parts of a Codebase Are Ready for Stronger Review?

Use lifting and bounded analysis to identify review-critical functions before migration or certification work.

Open article
Editorial cover for Laszlo B. Kish and the Information-Theory Thread
RESEARCHResearch

Laszlo B. Kish and the Information-Theory Thread

A research profile on the ideas that influenced the information-theoretic framing behind Digital Circuitality.

Open article
Editorial cover for Informational Entropy Is Not Thermal Entropy
RESEARCHResearch

Informational Entropy Is Not Thermal Entropy

Why the distinction matters for the foundations story and how it sharpens the claim boundary around Digital Circuitality.

Open article
Editorial cover for From Preferences to Enforced Action Boundaries
AI SAFETYAI Safety

From Preferences to Enforced Action Boundaries

Why robotics and agent systems need explicit action gates, bounded state, and reviewable fallback paths.

Open article
Editorial cover for First PCD Circuit: A Minimal Walkthrough
TUTORIALGetting Started

First PCD Circuit: A Minimal Walkthrough

Install the CLI, write a small circuit, and inspect the bounded output path. A practical introduction to the format and the compile step.

Open article
Editorial cover for EVA Algebra: Sequence, Parallel, Conditional
DEEP DIVETheory

EVA Algebra: Sequence, Parallel, Conditional

How three composition operators carry sequencing, fan-out, and branching through the circuit model, and what that means for compiler readability and closure.

Open article
Editorial cover for Working with the SDKs Without Leaving the Bounded Model
SDKSGetting Started

Working with the SDKs Without Leaving the Bounded Model

How the Rust, JavaScript, and Python SDKs expose BRIK64 patterns while keeping the formal core distinct from host-language code.

Open article
Editorial cover for Why Software Verification Still Looks Different from Hardware
RESEARCHResearch

Why Software Verification Still Looks Different from Hardware

A comparison between sampled software testing and the compositional review posture hardware teams expect.

Open article
Editorial cover for 128 Operations and the Boundary Between Core and Bridges
ENGINEERINGEngineering

128 Operations and the Boundary Between Core and Bridges

A tour of the reviewed core, the contract-bounded extensions, and what that split means for technical scope.

Open article
Editorial cover for PCD for AI Agents: A Small Format with an External Proof Loop
AI AGENTSAI

PCD for AI Agents: A Small Format with an External Proof Loop

How a finite grammar helps agents author bounded logic while the compiler and policy checks stay outside the model.

Open article
Editorial cover for Precision as a Declared Domain
ENGINEERINGEngineering

Precision as a Declared Domain

Why bounded numeric domains matter for floating behavior, decimal handling, and reviewable arithmetic.

Open article
Editorial cover for BPU: Policy Enforcement as a Hardware Roadmap
HARDWAREHardware

BPU: Policy Enforcement as a Hardware Roadmap

Why software-only guardrails share execution context with the model they constrain, and how the BPU roadmap moves policy enforcement toward FPGA and silicon.

Open article
Editorial cover for Policy Circuits for AI Safety Workflows
AI SAFETYAI Safety

Policy Circuits for AI Safety Workflows

How external policy circuits can gate generated code and agent actions without claiming to solve general alignment.

Open article
Editorial cover for What Digital Circuitality Tries to Formalize
VISIONFoundations

What Digital Circuitality Tries to Formalize

A bounded programming model built from reviewed operations, explicit composition, and closure checks.

Open article