CDR

Cognitive Discovery & Reverse-engineering

CDR is Fabriq's knowledge production engine. It scans code repositories, extracts structured cognitive assets — behaviors, state machines, business rules, domains — and makes them browsable, searchable, and verifiable.

Why CDR

Code is the only source of truth — but it's an unreadable black box.

Traditional documentation rots. Pure static analysis lacks semantics. Pure LLM analysis hallucinates. CDR combines all three approaches where each excels.

The static analysis trap

SonarQube, Sourcegraph, regex rules — they're brittle, framework-bound, and can't answer 'why' a call exists. Rules break the moment you use a custom framework.

The LLM hallucination trap

Dumping code into a prompt works for small files but fails at scale. LLMs hallucinate file paths, line numbers, and call chains — producing unverifiable 'evidence'.

The Fabriq approach: AI as Scanner, Engine as Validator

LLMs extract semantic intent from code slices. A deterministic engine validates every claim against the actual source. Separate what can be computed from what must be inferred.

Pipeline

Four stages, one purpose: make code knowledge provable.

01

Skeleton Extraction & Profiling

The engine scans the repository to build a CodeMap — a high-compression symbolic map of files, classes, methods, imports and annotations. No LLM is involved at this stage.

02

Entrypoint Discovery

The engine identifies physical entrypoints — HTTP APIs, message queue consumers, cron jobs, CLI commands — using AST-level analysis. These become the starting points for behavioral analysis.

03

Cognitive Extraction

LLM agents receive focused code slices with the extracted CodeMap and entrypoints. They produce structured YAML artifacts — behavior flows, state machines, business rules — each with sourced evidence chains.

04

Validation & Commit

The deterministic engine revalidates every claim: Are the file paths real? Do the line numbers match? Is the call chain verifiable? Only artifacts that pass validation are committed to the workspace.

Assets

Eight types of cognitive assets.

CDR produces structured YAML artifacts organized into a standard directory layout under docs/as-is/.

Profiles

Technical repository profile — language, stack, API surface, dependency count.

Entries

Physical entrypoints that trigger business logic — APIs, jobs, events.

Behavior

End-to-end behavioral chains with writes, events, and cross-service calls.

State Machines

Entity state transitions with triggers, guards, and terminal states.

Business Rules

Five rule types: invariant, constraint, authorization, SLA, compensation.

Domains

Business domain models with derived_from traceability to source behaviors.

Capabilities

Product-level functional map — what the system can do, not just how.

Cross-Repo

Cross-repository views: domain suggestions and cross-links between services.

These assets are stored as YAML files under docs/as-is/, indexed in .dapei/cognitive/index.yaml, and rendered as interactive React components in the Fabriq desktop app.

Evidence

Three confidence levels. Mandatory evidence for each.

Every cognitive artifact carries a confidence level with strict evidence requirements. No claim enters the workspace without justification.

Fact

Directly observed from code. The artifact has exact file paths, line numbers, and repo references. This is the gold standard — verifiable by anyone at any time.

Requires: Must include sources[] with {file, line, repo}
🔍Inference

Derived from one or more facts by combining evidence. Useful for higher-level patterns that span multiple files, but always traceable back to facts.

Requires: Must include derived_from[] referencing fact behavior IDs
⚠️Unknown

A gap identified but not yet verified. The system knows something exists but can't confirm the details. Aplaceholder that drives further analysis.

Requires: Must include reason explaining why it's unknown
Desktop

CDR assets at your fingertips.

The Fabriq desktop app renders CDR artifacts as interactive React components — no external portal needed.

Search across assets

Search every behavior, state machine, rule, and domain from a single search box in the Feature Workbench.

Visualize behavior flows

BehaviorFlowCard shows the complete call chain with source references. Click through to see exact file locations.

Cross-repo navigation

Trace calls across repositories. See which services communicate and how data flows between them.

Drift detection

CDR assets include staleness checks. The Advisor alerts you when documented behavior no longer matches the code.

Turn your codebase into a knowledge graph.

Download Fabriq, point it at your repository, and run your first CDR scan. See what your code knows about itself.