Documentation Index
Fetch the complete documentation index at: https://mintlify.com/thiagofinch/mega-brain/llms.txt
Use this file to discover all available pages before exploring further.
Workflows
Workflows orchestrate tasks into complete processing pipelines. All workflows are defined in YAML and executed by JARVIS.
Workflow Structure
workflow:
id: wf-example
name: Example Workflow
version: 1.0.0
description: Short description
metadata:
created: 2026-03-01
updated: 2026-03-05
author: @jarvis
status: active
stages:
- id: stage-1
name: Stage Name
tasks:
- task_id: TSK-001
inputs:
param1: value1
outputs:
result: ${stage-1.result}
on_success: stage-2
on_failure: error-handler
- id: stage-2
name: Next Stage
tasks:
- task_id: TSK-002
inputs:
data: ${stage-1.result}
Available Workflows
wf-pipeline-full
Complete 5-phase processing pipeline.
ID: wf-pipeline-full
Purpose: Transform raw content into structured knowledge, dossiers, and agent memories.
Stages:
Tasks:
TSK-001: Split content into semantic chunks (500-1500 words)
TSK-002: Generate chunk embeddings (Voyage)
TSK-003: Write CHUNKS-STATE.json
Output: /processing/chunks/{source-id}.jsonQuality Gate: QG-001
- Minimum 1 chunk
- No chunk > 2000 words
- Valid JSON schema
Show Stage 2: Entity Resolution
Tasks:
TSK-008: Normalize persons
TSK-012: Detect roles
TSK-015: Analyze themes
TSK-009: Update CANONICAL-MAP.json
Output: /processing/canonical/CANONICAL-MAP.jsonQuality Gate: QG-002
- All entities canonicalized
- No unresolved aliases
- Registry updated
Show Stage 3: Insight Extraction
Tasks:
TSK-018: Extract DNA layers (L1-L5)
TSK-019: Classify by priority (HIGH/MEDIUM/LOW)
TSK-020: Write INSIGHTS-STATE.json
Output: /processing/insights/INSIGHTS-STATE.jsonQuality Gate: QG-003
- Minimum 5 insights per person
- All insights have priority
- Source attribution complete
Show Stage 4: Narrative Synthesis
Tasks:
TSK-022: Synthesize person narratives
TSK-023: Synthesize theme narratives
TSK-024: Identify tensions and open loops
TSK-025: Write NARRATIVES-STATE.json
Output: /processing/narratives/NARRATIVES-STATE.jsonQuality Gate: QG-004
- Coherent narrative per person
- Patterns identified
- Tensions documented
Tasks:
TSK-028: Update agent memories
TSK-029: Create/update dossiers
TSK-030: Populate knowledge base
TSK-031: Update entity registry
TSK-032: Validate cascade completeness
Outputs:
/knowledge/dossiers/persons/{person}.md
/knowledge/dossiers/themes/{theme}.md
/knowledge/SOURCES/{source}/{category}/{topic}.md
/agents/{category}/{agent}/MEMORY.md
Quality Gate: QG-005
- All artifacts created
- Cross-references valid
- No orphaned data
Checkpoints:
- Created after each stage
- Stored in
/.claude/jarvis/CHECKPOINTS/
- Format:
CP-{timestamp}-{workflow-id}-{stage-id}.json
Resume:
/jarvis resume
# Auto-detects last checkpoint
Rollback:
/jarvis rollback CP-20260305120000-wf-pipeline-full-stage-3
Source: core/workflows/wf-pipeline-full.yaml:1-xxx
wf-ingest
Ingest new material into inbox.
ID: wf-ingest
Purpose: Download, transcribe, and organize external content.
Stages:
Show Stage 1: Acquisition
Tasks:
TSK-101: Download from URL (YouTube, Drive, etc.)
TSK-102: Copy local files to inbox
TSK-103: Generate source hash
Supported Sources:
- YouTube (video/audio)
- Google Drive (docs/folders)
- Local files (.txt, .md, .pdf, .docx, .mp3, .wav)
Show Stage 2: Transcription
Tasks:
TSK-110: Transcribe audio (Whisper)
TSK-111: Extract text from PDF/DOCX
TSK-112: Save as .txt in inbox
Requirements:
OPENAI_API_KEY for Whisper
Show Stage 3: Organization
Tasks:
TSK-120: Detect person from filename/content
TSK-121: Classify content type
TSK-122: Standardize filename (UPPERCASE)
TSK-123: Move to {PERSON}/{TYPE}/
TSK-124: Register in INBOX-REGISTRY.md
Filename Pattern: TOPIC-NAME [youtube-id].txt
Output: Organized file in inbox/{PERSON}/{TYPE}/{filename}.txt
Source: core/workflows/wf-ingest.yaml:1-xxx
Extract DNA from narratives and assign to agent.
ID: wf-extract-dna
Purpose: Create cognitive DNA structure (5 layers) for mind clones.
Stages:
Show Stage 1: DNA Extraction
Task: TSK-020 (extract-dna)Input: NARRATIVES-STATE.json for specific personOutput: DNA-CONFIG.yaml with 5 layers
Show Stage 2: Agent Assignment
Task: TSK-140 (trigger-agent)Checks:
- Does agent exist for this person?
- If yes: Update DNA reference
- If no: Check creation threshold
Threshold:
weighted_score >= 10
sources >= 2
Show Stage 3: Agent Creation (if triggered)
Task: TSK-141 (create-agent)Creates:
agents/minds/{person}/AGENT.md
agents/minds/{person}/SOUL.md
agents/minds/{person}/MEMORY.md
agents/minds/{person}/DNA-CONFIG.yaml
Updates:
agents/AGENT-INDEX.yaml
ENTITY-REGISTRY.json (has_agent: true)
Source: core/workflows/wf-extract-dna.yaml:1-xxx
wf-conclave
Multi-agent deliberation workflow.
ID: wf-conclave
Purpose: Constitutional decision-making with critic, advocate, and synthesizer.
Stages:
Show Stage 0: Constitutional Foundation
Task: TSK-200 (invoke-constitution)Principles:
- Empiricism (data over opinions)
- Pareto (80/20 leverage)
- Inversion (what causes failure?)
- Antifragility (benefit from volatility)
Task: TSK-201 (run-debate)Agents: Auto-selected by query relevance
- Financial question → CFO, CRO
- Sales question → CRO, CMO, Sales-Lead
- Operations → COO, CTO
Output: Structured debate log with positions
Task: TSK-202 (apply-critic)Agent: critico-metodologicoScoring (0-100):
- Premissas declaradas: /20
- Evidencias rastreaveis: /20
- Logica consistente: /20
- Cenarios alternativos: /20
- Conflitos resolvidos: /20
Output: Quality score + gaps identified
Show Stage 3: Devil's Advocate
Task: TSK-203 (apply-advocate)Agent: advogado-do-diaboOutputs:
- Weakest premise identified
- Undiscussed risk
- Regret scenario (12 months)
- Ignored alternative
Task: TSK-204 (synthesize-decision)Agent: sintetizadorOutputs:
- Unified recommendation
- Confidence score (0-100%)
- Residual risks + mitigations
- Next steps with owners
- Reversal criteria
Decision Logic:
- Confidence ≥ 60%: Recommend action
- Confidence < 60%: Escalate to human
Anti-loop Rule: Council runs once per query. No recursive re-runs.
Source: core/workflows/wf-conclave.yaml:1-xxx
Workflow Execution
Via JARVIS
# Execute workflow
/jarvis run wf-pipeline-full --input source_file="inbox/..."
# Resume from checkpoint
/jarvis resume
# Rollback to checkpoint
/jarvis rollback CP-{id}
Via Slash Command
# Workflows mapped to commands
/process-jarvis "file.txt" # → wf-pipeline-full
/ingest "https://..." # → wf-ingest
/conclave "question" # → wf-conclave
Programmatic
from core.workflows import execute_workflow
result = execute_workflow(
workflow_id="wf-pipeline-full",
inputs={"source_file": "inbox/source.txt"},
checkpoint_dir=".claude/jarvis/CHECKPOINTS"
)
Checkpointing
Automatic Checkpoints
Created after each stage:
{
"checkpoint_id": "CP-20260305120000-wf-pipeline-full-stage-2",
"workflow_id": "wf-pipeline-full",
"stage_id": "stage-2",
"timestamp": "2026-03-05T12:00:00Z",
"state": {
"inputs": {...},
"outputs": {...},
"context": {...}
},
"artifacts": [
"/processing/chunks/source-001.json",
"/processing/canonical/CANONICAL-MAP.json"
]
}
Manual Checkpoints
/jarvis checkpoint "before-risky-operation"
Checkpoint Retention
- Last 10 checkpoints per workflow kept
- Older checkpoints archived to
.claude/jarvis/CHECKPOINTS/archive/
- Critical checkpoints (marked) never deleted
Error Handling
Retry Strategy
stages:
- id: stage-1
retry:
max_attempts: 3
backoff: exponential
delay_seconds: 5
Failure Handlers
stages:
- id: stage-1
on_failure: error-handler
error_handlers:
- id: error-handler
tasks:
- task_id: TSK-999
inputs:
error: ${stage-1.error}
Rollback on Failure
workflow:
rollback_on_failure: true
rollback_to: last_checkpoint
Quality Gates
Each stage can define quality gates:
stages:
- id: stage-1
quality_gate:
id: QG-001
checks:
- condition: ${output.chunk_count} > 0
message: "Must have at least 1 chunk"
- condition: ${output.schema_valid} == true
message: "Must pass schema validation"
on_fail: rollback
Failure Actions:
rollback: Restore from last checkpoint
retry: Retry stage up to max_attempts
skip: Skip stage and continue
abort: Abort entire workflow
Creating Workflows
Workflow Template
workflow:
id: wf-custom
name: Custom Workflow
version: 1.0.0
description: Purpose and scope
metadata:
created: 2026-03-01
author: @human
status: active
tags: [category1, category2]
inputs:
- name: param1
type: string
required: true
description: What this param does
outputs:
- name: result
type: object
location: /path/to/output
stages:
- id: stage-1
name: Stage Name
tasks:
- task_id: TSK-001
inputs:
param: ${workflow.inputs.param1}
on_success: stage-2
- id: stage-2
name: Next Stage
tasks:
- task_id: TSK-002
on_success: complete
Validation
# Validate workflow YAML
python core/intelligence/validate_workflow.py wf-custom.yaml
Registration
Add to core/workflows/README.md:
| ID | Name | Stages | Purpose |
|----|------|--------|--------|
| wf-custom | Custom Workflow | 2 | Brief description |
See Also