Illustrative Simulation — Pre-Launch Interactive Preview

Inspect a simulated CodeLoom AI migration run

Select a module from the illustrative legacy repository below to inspect how CodeLoom AI resolves its dependency order, generates baseline characterization tests, repairs edge-case regressions, and packages an audit-ready pull request.

01. Map Graph → 02. Lock Characterization Suite → 03. Modernize & Verify PR
Verified: src/utils/currency.js → src/utils/currency.ts
Topological Order: Leaf #1 • 0 Outbound Deps
Blast Radius Analysis: Low (Leaf utility imported by ledger.js and taxCalc.js)
src/utils/currency.js (Legacy Original) READ-ONLY INPUT
var Money = require('./money-dict');

// Legacy fee & FX conversion
exports.convert = function(amt, cur, cb) {
  if (amt == null) return cb(new Error('NO_AMT'));
  var rate = Money.rates[cur] || 1.0;
  var cents = Math.round(amt * rate * 100);
  return cb(null, { cents: cents, iso: cur });
};
Generated Characterization Suite Locked Before Edit
  • converts standard currency rate to integer cents PASS (Baseline)
  • falls back to 1.0 multiplier on unknown ISO code PASS (Baseline)
  • preserves half-up rounding on fractional inputs PASS (Baseline)
  • rejects with Error('NO_AMT') on both null and undefined PASS (Baseline)
Verify-and-Repair Diagnostic Log Initial rewrite used strict `amt === null`, which failed test #4 when `undefined` was passed. Repaired to loose nullish check `amt == null`.
src/utils/currency.ts (Modernized & Verified) Target Stack
import { rates, type IsoCode } from './money-dict.js';

export async function convert(
  amt: number | null | undefined,
  cur: IsoCode
): Promise<{ cents: number; iso: IsoCode }> {
  if (amt == null) throw new Error('NO_AMT');
  const rate = rates[cur] ?? 1.0;
  const cents = Math.round(amt * rate * 100);
  return { cents, iso: cur };
}
AUDIT-READY PR #104 codeloom/leaf-currency-ts

Modernize utils/currency to typed async ES module

WHAT CHANGED

Replaced CommonJS require and error-first callback with typed async function export while preserving fallback rate and cent rounding.

WHY IT CHANGED

Scheduled as Migration Unit #1 (leaf node with zero local outbound dependencies) to unblock ledger.js and taxCalc.js.

WHAT VERIFIED IT

Verified against 4 characterization tests in currency.char.spec.js, including automated repair of null/undefined input guard.