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.
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.
Four stages, one purpose: make code knowledge provable.
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.
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.
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.
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.
Eight types of cognitive assets.
CDR produces structured YAML artifacts organized into a standard directory layout under docs/as-is/.
Technical repository profile — language, stack, API surface, dependency count.
Physical entrypoints that trigger business logic — APIs, jobs, events.
End-to-end behavioral chains with writes, events, and cross-service calls.
Entity state transitions with triggers, guards, and terminal states.
Five rule types: invariant, constraint, authorization, SLA, compensation.
Business domain models with derived_from traceability to source behaviors.
Product-level functional map — what the system can do, not just how.
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.
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.
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.
Derived from one or more facts by combining evidence. Useful for higher-level patterns that span multiple files, but always traceable back to facts.
A gap identified but not yet verified. The system knows something exists but can't confirm the details. Aplaceholder that drives further analysis.
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.
