CDR: Cognitive Derivation & Reverse Engineering
How Fabriq extracts structured knowledge — behaviors, business rules, state machines — from your source code.
Your codebase contains business rules, state machines, and behavioral patterns that aren't written down anywhere. They're implicit in the code — in how functions call each other, how state transitions work, how data flows through the system.
CDR (Cognitive Derivation & Reverse Engineering) is Fabriq's pipeline that scans your source code and extracts this knowledge into structured, navigable assets.
What CDR produces
After a scan, you get a set of cognitive assets:
| Asset | What it captures | Example |
|---|---|---|
| Behavior | How components interact — which functions call which | SearchBar.onSubmit → ProductList.filter |
| Business Rule | Explicit business logic encoded in code | "Orders over $100 get free shipping" |
| State Machine | State transitions and their triggers | Order: Pending → Paid → Shipped → Delivered |
| Evidence | Sourced, validated observations | Code references that support each finding |
| Domain | Business domain boundaries and entities | "Order Management", "User Profile", "Inventory" |
The CDR pipeline
CDR runs as a multi-stage pipeline:
Bootstrap → Entries → Behavior → State → Domain → Generate
Mining Machine
| Stage | What happens |
|---|---|
| Bootstrap | Reads project metadata, configures scanners |
| Entries Candidate | Identifies entrypoints (routes, event handlers, API endpoints) |
| Behavior Mining | Traces call chains between components — who calls whom and why |
| State Machine | Detects state transitions (enums, status fields, conditional branches) |
| Domain Analysis | Groups related entities into business domains |
| Document Generation | Produces navigable cognitive assets |
Evidence levels
Every finding in CDR is tagged with an evidence level:
| Level | Meaning | Example |
|---|---|---|
| Fact | Sourced and validated against actual code | "Order status transitions from 'pending' to 'paid' in OrderService.pay()" — supported by a code reference |
| Inference | Derived from patterns, plausible but not directly validated | "This authentication middleware likely applies to all /api/admin routes" |
| Unknown | Knowledge gap — the scanner detected something but couldn't classify it | Need human review to determine what this pattern represents |
Facts are the most reliable. Inferences are useful but should be verified. Unknowns are opportunities for investigation.
Why CDR matters for agents
Without CDR, an agent must read the entire codebase from scratch for every feature — expensive and error-prone. With CDR:
- Agent queries the cognitive index instead of re-scanning
- Business rules are pre-extracted — the agent knows the rules before it modifies code
- State machines are navigable — the agent understands state transitions without tracing code
- Evidence is sourced — every finding links back to specific code locations
The cognitive index is available for context injection — you can send it to the agent before starting a feature.
When to run CDR
| When | Why |
|---|---|
| After significant code changes | Keep the cognitive index up to date |
| Before starting a complex feature | Give the agent structured context |
| When onboarding to an unfamiliar codebase | Understand the system without reading everything |
| Periodically (weekly) | Catch knowledge drift before it becomes a problem |
CDR scan time depends on your codebase size. A small project (50 files) takes under a minute. A large monorepo (5000+ files) may take several minutes.
Next steps
- Running Your First CDR Scan — step-by-step tutorial
- Injecting Context — send cognitive assets to your agent
- Audit Trail — every decision, recorded
Last updated on