Skip to main content
The Mega Brain pipeline is a semantic processing system that ingests expert materials and transforms them into structured, traceable knowledge across 5 DNA layers.

Pipeline Overview

Core Constraint: Process 100% of content. No summarization, no omission. Every insight must trace back to source with full lineage.

Phase 1: Initialization + Validation

Validate input files, extract metadata from paths, load state files, and check for duplicate processing.
1

Validate Input

2

Extract Path Metadata

Parse file path to extract:
  • SOURCE_PERSON - Folder after inbox/
  • SOURCE_COMPANY - Content in parentheses
  • SOURCE_TYPE - Material type (MASTERMINDS, COURSES, etc.)
  • SOURCE_ID - Unique hash (e.g., “CG003”)
  • SCOPE - course | company | personal
  • CORPUS - Derived from SOURCE_COMPANY
3

Load State Files

Load or create:
  • CHUNKS-STATE.json
  • CANONICAL-MAP.json
  • INSIGHTS-STATE.json
  • NARRATIVES-STATE.json
4

Check Already Processed

Search existing chunks for SOURCE_ID. If found, ask user whether to reprocess.
Output: Validated input, metadata extracted, state files loaded

Phase 2: Chunking

Segment content into semantic chunks (~300 words) while preserving context, timestamps, and speaker labels.
Protocol: core/templates/PIPELINE/PROMPT-1.1-CHUNKING.md

Chunking Rules

  • Chunk size: ~300 words (~1000 tokens)
  • Preserve: Timestamps, speaker labels, formatting
  • Extract: People (raw mentions), themes (raw topics)
  • Generate: Sequential chunk_id like chunk_CG003_001

Process

1

Read Full Content

Load entire source file, count words
2

Execute Chunking

Apply semantic segmentation while maintaining context boundaries
3

Merge and Save

Merge new chunks into CHUNKS-STATE.json, deduplicate by chunk_id
Checkpoint: count(new_chunks) > 0, each chunk has unique ID, state file saved

Phase 3: Entity Resolution

Normalize entity names (people, companies, themes) to canonical forms to prevent duplication.
Protocol: core/templates/PIPELINE/PROMPT-1.2-ENTITY-RESOLUTION.md

Resolution Rules

  • Threshold: 0.85 confidence for merging
  • Prefer: Longest/most explicit form as canonical
  • NEVER merge: Across different corpus
  • Flag collisions: For human review

Examples

Output: Canonicalized chunks, updated CANONICAL-MAP.json, review queue for ambiguous cases

Phase 4: Insight Extraction

Extract actionable insights from chunks, classify by priority, and detect contradictions.
Protocol: core/templates/PIPELINE/PROMPT-2.1-INSIGHT-EXTRACTION.md

Insight Structure

Priority Levels

High

Immediately actionable, high-impact insights

Medium

Important context, strategic guidance

Low

Supporting details, background information
Output: Insights organized by person and theme in INSIGHTS-STATE.json

Phase 5: Narrative Synthesis

Synthesize insights into coherent narratives for each person and theme, tracking tensions and open questions.
Protocol: core/templates/PIPELINE/PROMPT-3.1-NARRATIVE-SYNTHESIS.md

Narrative Structure

Merge Rules (CRITICAL)

  • narrative: CONCATENATE with update separator
  • insights_included[]: APPEND (never replace)
  • tensions[]: APPEND new ones
  • open_loops[]: APPEND new, mark RESOLVED when answered
  • next_questions[]: REPLACE (only exception)
Output: Updated NARRATIVES-STATE.json with synthesized narratives

Phase 6: Dossier Compilation

Compile comprehensive dossiers for persons and themes with full source traceability.
Protocol: core/templates/PIPELINE/DOSSIER-COMPILATION-PROTOCOL.md

Dossier Types

Output: Markdown dossiers in knowledge/dossiers/persons/ and knowledge/dossiers/themes/

Phase 7: Agent Enrichment

Update agent knowledge and memory files with new insights, respecting agent boundaries.

Process

1

Compile Knowledge Payload

Extract frameworks, techniques, metrics, and high-priority insights discovered
2

Check Role Threshold

  • >=10 mentions: Flag “Create New Agent”
  • >=5 mentions: Flag “Monitor Role”
3

Present Options

4

Execute Updates

Update relevant agent files with new knowledge, maintaining agent voice and structure
5

Template Evolution Check

If new knowledge doesn’t fit existing template structure, trigger evolution protocol
Output: Updated agent memories, optionally updated agent definitions

Phase 8: Finalization

Execute automatic cleanup, generate execution report, and verify pipeline integrity.

Automatic Actions

1

RAG Index

python scripts/rag_index.py --knowledge --force
2

File Registry

python scripts/file_registry.py --scan
3

Session State

Update SESSION-STATE.md with processed file
4

Role Tracking

Update agents/DISCOVERY/role-tracking.md
5

Audit Log

Append to logs/AUDIT/audit.jsonl

Final Verification (9 Items)

Execution Report

Pipeline Commands

Next Steps

DNA Schema

Learn about the 5-layer knowledge extraction

Architecture

Understand the system architecture