USE CASE · CASE STUDY
A Clearing Platform in One Working Day.
The brief landed in the morning: a clearing, settlement, and collateral-management engine for five trade types, on strict Clean Architecture where Spring is a swappable adapter — not the architecture. v1.0.0 shipped that evening. Flexor orchestrated the build: four knowledge tiers, three coding agents, one source of truth.
The Problem
Post-Trade Systems Get Welded to Their Framework
Clearing and collateral systems are typically built around one framework and one instrument type. Every new trade type is open-heart surgery; migrating off the incumbent stack is a multi-year program. The client — a fintech product studio (name withheld by agreement) — wanted a reference architecture that proves the opposite is possible: instrument-extensible by design, framework-independent by construction.
The catch: reference implementations of this scope usually take a team weeks. The studio wanted it at agent speed — without sacrificing the discipline that makes a reference implementation worth referencing.
Five trade types as a sealed hierarchy
Buy/sell (DvP), repo, securities loan, deposit, swap. Adding a sixth touches one permit + one record.
Dependency rule enforced by the build
The domain module has no framework on its classpath. Module dependencies point inward only.
Framework as an adapter
Bean-container SPI with a pure-JDK default; Spring swaps in via one env var, zero business-code change.
Working demo, margining, runnable, showcase
Netting + CCP novation demo, collateral margining with haircuts, runs on bare JDK 17, animated showcase site.
The Solution
The Project Started With Context, Not Code
One command attached the four-tier vault stack — platform engineering rules, company stack canon, project PRD, personal working style — materialized it into a single context, and projected it into the native format of each coding agent. Claude Code, Cursor, and Codex read the same rules from the same vaults. No onboarding, no per-tool configuration.
Discipline Isn't a Document. It's the Runtime.
Every Flexor rule ships with an enforcement mechanism — a hook, a check, or a blocking protocol. Four rules shaped this delivery the most.
Before any new library, the agent must check the company's canonical inventory and justify divergence with a concrete missing capability — not taste.
Result: the core runs on pure JDK 17. Across two releases, exactly one runtime dependency entered the project (vavr) — with a recorded justification.
Every agent claim carries a status: Verified, Inferred, Assumed, or Unknown. A guess presented as fact is a violation caught automatically.
The brief named “five trade types” while listing four. The agent didn't silently guess — the gap became recorded decision D1 (swap chosen as the fifth, reversible by design). Zero fabricated facts in the docs.
Irreversible actions require explicit human consent. Assumptions are classified before acting: satisfied, violated, or unknown — and unknown blocks until answered.
Contested forks (in-memory vs JDBC, pure-JDK vs Spring default) became decisions D2–D3 with rollback criteria — not silent assumptions buried in code.
After every substantial edit block, a hook forces a simplification pass — killing over-engineering, dead error handling, and premature abstraction while context is hot.
Visible in the numbers: the whole engine is 4,769 lines across 114 files. Average file: 42 lines. Density instead of bloat.
From Init to Freeze in Twelve Days
One command wires the four-tier vault stack, three configured coding agents, and the event daemon. The first artifact is not code — it's a PRD: 7 requirements with acceptance criteria, 3 recorded decisions, explicit scope boundaries.
Six modules in strict Clean Architecture layers: the five-type trade domain, netting and CCP novation, collateral margining with haircuts, REST on the bare JDK HttpServer, container SPI with two implementations. Plus an end-to-end demo, nine documents, and an animated showcase site — all offline-runnable on JDK 17.
Second iteration raised the rigor: vavr collections and Option/Try in port signatures, domain-typed use cases, and a transactional outbox with at-least-once delivery — aggregate writes and event records commit in one unit of work. 40 self-tests including commit atomicity and delivery retry.
All 7 PRD requirements closed against acceptance criteria. The v1.1.0 artifacts were packaged and handed over. The domain model, decisions, and rules stayed in the vault — the next post-trade project starts from a non-empty knowledge layer.
Density Instead of Volume
Client anonymized; every technical metric below is factual — file counts, module structure, demo results, and release chronology come from the delivered repository and its changelog.
Full engine, demo, nine documents, and showcase site shipped the same day the project started.
Six modules. Average file 42 lines. The simplify hook kept density high and bloat out.
vavr — the only third-party runtime dependency across two releases, justified and recorded.
89.7M gross reduced to 49.3M net across the demo clearing cycle; 44 domain events through the outbox.
Every requirement closed against its written acceptance criterion. No scope drift.
Money arithmetic, netting, haircut math, outbox atomicity and retry — all runnable on bare JDK.
Claude Code, Cursor, and Codex read identical rules from the same vaults. Switching tools cost zero reconfiguration.
Two releases, full documentation trail, and a versioned decision log — then a clean handover.
The Vault Outlived the Code Freeze
The same team's next build — a custody core — starts from the knowledge layer this project left behind: shared value objects, a proven outbox pattern, and agents that need no onboarding.
Read the Custody Core BlueprintYour next project can start with context, not a blank page.
We'll walk through your delivery workflow and show where a governed knowledge stack compresses the most time.
Request a Demo