Fabriq

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:

AssetWhat it capturesExample
BehaviorHow components interact — which functions call whichSearchBar.onSubmit → ProductList.filter
Business RuleExplicit business logic encoded in code"Orders over $100 get free shipping"
State MachineState transitions and their triggersOrder: Pending → Paid → Shipped → Delivered
EvidenceSourced, validated observationsCode references that support each finding
DomainBusiness 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
StageWhat happens
BootstrapReads project metadata, configures scanners
Entries CandidateIdentifies entrypoints (routes, event handlers, API endpoints)
Behavior MiningTraces call chains between components — who calls whom and why
State MachineDetects state transitions (enums, status fields, conditional branches)
Domain AnalysisGroups related entities into business domains
Document GenerationProduces navigable cognitive assets

Evidence levels

Every finding in CDR is tagged with an evidence level:

LevelMeaningExample
FactSourced and validated against actual code"Order status transitions from 'pending' to 'paid' in OrderService.pay()" — supported by a code reference
InferenceDerived from patterns, plausible but not directly validated"This authentication middleware likely applies to all /api/admin routes"
UnknownKnowledge gap — the scanner detected something but couldn't classify itNeed 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

WhenWhy
After significant code changesKeep the cognitive index up to date
Before starting a complex featureGive the agent structured context
When onboarding to an unfamiliar codebaseUnderstand 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

Edit on GitHub

Last updated on

On this page