Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save maciejjankowski/d63a02fa16e512ff1c4ff65570dcbca9 to your computer and use it in GitHub Desktop.

Select an option

Save maciejjankowski/d63a02fa16e512ff1c4ff65570dcbca9 to your computer and use it in GitHub Desktop.
the-template architecture map - RAZEM AI Operating System

THE-TEMPLATE - Architecture Map

phi := Oracle + JESTEM | RAZEM Orchestrator

Date: 2026-03-02


What is this?

the-template is MJ's AI operating system - a Claude Code workspace that turns Claude from a chatbot into a persistent partner with memory, guardrails, tools, and behavioral enforcement. ~150 active components wired through CLAUDE.md as single source of truth.


HIGH-LEVEL DIAGRAM

THE-TEMPLATE - RAZEM Orchestrator
phi := Oracle + JESTEM
══════════════════════════════════════════════════════════════════════

                         ┌─────────────┐
                         │  CLAUDE.md  │  Single source of truth (v3.3)
                         │  200 lines  │  Startup sequence, rules, routing
                         └──────┬──────┘
                                │
        ┌───────────────────────┼───────────────────────┐
        v                       v                       v
┌───────────────┐    ┌──────────────────┐    ┌──────────────────┐
│  ENFORCEMENT  │    │    FRAMEWORK     │    │     MEMORY       │
│  .claude/     │    │   _framework/    │    │    _memory/      │
└───────┬───────┘    └────────┬─────────┘    └────────┬─────────┘
        │                     │                       │
        v                     v                       v

═══ ENFORCEMENT LAYER (.claude/) ═══════════════════════════════════

  HOOKS (settings.json)              MCP SERVERS (.mcp.json)
  ┌────────────────────────┐         ┌────────────────────────┐
  │ SessionStart:          │         │ 9sens-claude-native    │
  │  session_init.sh       │         │  decisions, memory,    │
  │  start_s1_mood.sh      │         │  discovery, output     │
  │  discord_check_hook.py │         │                        │
  │                        │         │ razem-guardian          │
  │ PreToolUse:            │         │  turns, rules, reground│
  │  context_safety (Bash) │         │                        │
  │  copilot_gate (Playwrt)│         │ voice                  │
  │                        │         │  Parakeet Polish ASR   │
  │ UserPromptSubmit:      │         │  6ms GPU transcription │
  │  content_gate_hook.py  │         └────────────────────────┘
  │  twin-gate (plugin)    │
  │                        │         PLUGIN: digital-twin
  │ PostToolUse:           │         ┌────────────────────────┐
  │  grounding (every 15)  │         │ 7 behavioral gates:    │
  │  s1_mood_hook.py       │         │  BUILD-WITHOUT-BUYER   │
  │  twin-monitor.sh       │         │  SHINY-OBJECT          │
  │                        │         │  RESEARCH-AVOIDANCE    │
  │ Stop:                  │         │  ORGANIZE-AVOIDANCE    │
  │  discord_done_hook.py  │         │  CONTENT-WITHOUT-VOICE │
  │  sync_learnings.py     │         │  PRICING-WITHOUT-COGS  │
  └────────────────────────┘         │  TOOL-TRAP             │
                                     │                        │
                                     │ Prolog: executive_     │
                                     │  functions.pl (28KB)   │
                                     │ guardrails.yaml        │
                                     └────────────────────────┘

═══ FRAMEWORK (_framework/) ════════════════════════════════════════

  nSENS v2.2                         CATALOGS
  ┌────────────────────────┐         ┌────────────────────────┐
  │ core/ (15 modules, 5K) │         │ 34 personas            │
  │  engine.py   orchestr. │         │ 51 biases              │
  │  personas.py 4 layers  │         │ 52 mental models       │
  │  validator.py multi-lyr│         │ 127 viral patterns     │
  │  plugin_registry.py    │         │ ~100 red flags         │
  │  decision_log.py audit │         │ 6 research prompts     │
  │  prolog_validator.py   │         │ output templates       │
  │  handoff_system.py     │         └────────────────────────┘
  │  adversarial_gate.py   │
  │  token_tracker.py      │         PHASES (P0-P5)
  └────────────────────────┘         ┌────────────────────────┐
                                     │ P0 Research            │
  tools/                             │ P1 Discovery           │
  ┌────────────────────────┐         │ P2 Design              │
  │ discord_bridge.py      │         │ P3 Implementation      │
  │ decision_logger.py     │         │ P4 Validation          │
  │ memory_store.py        │         │ P5 Reflection          │
  │ memory_search.py       │         └────────────────────────┘
  │ sync_learnings.py      │
  └────────────────────────┘         voice/
                                     ┌────────────────────────┐
  digital_twin/                      │ voice_bridge.py        │
  ┌────────────────────────┐         │  --listen (PTT)        │
  │ executive_functions.pl │         │  --record-now 5        │
  │ guardrails.yaml        │         │  --file input.m4a      │
  │ ontology.md            │         │ voice_mcp.py (server)  │
  └────────────────────────┘         └────────────────────────┘

═══ MEMORY (_memory/) ══════════════════════════════════════════════

  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐
  │  ChromaDB    │  │  Decisions   │  │  Learnings   │
  │  chromadb/   │  │  decisions/  │  │  learnings/  │
  │  vectors     │  │  .jsonl      │  │  ~50 .md     │
  │  semantic    │  │  audit trail │  │  patterns    │
  │  search      │  │  rationale   │  │  mistakes    │
  └──────────────┘  └──────────────┘  └──────────────┘
  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐
  │  Knowledge   │  │  Handoffs    │  │  Episodic    │
  │  knowledge/  │  │  _handoffs/  │  │  MCP plugin  │
  │  voice memos │  │  50+ dated   │  │  cross-      │
  │  ECHAD tree  │  │  checkpoints │  │  session     │
  │  writing     │  │  open loops  │  │  search      │
  │  voice guide │  │  next steps  │  │              │
  └──────────────┘  └──────────────┘  └──────────────┘

═══ SCRIPTS & DAEMONS ══════════════════════════════════════════════

  scripts/                           LaunchAgents (background)
  ┌────────────────────────┐         ┌────────────────────────┐
  │ iterm2_copilot_bridge  │         │ discord-watchdog  60s  │
  │  scan/connect/ask/fire │         │  polls #9sens          │
  │ discord_watchdog.sh    │         │                        │
  │ discord_watchdog_macbol│         │ discord-macbol    60s  │
  │ iterm_inject.py        │         │  polls #macbol         │
  │ chromadb_query.sh      │         │                        │
  │ sync_to_obsidian.sh    │         │ discord-wakeup   120s  │
  │ chrome_cookies.py      │         │  MJ presence detect    │
  │ adoption_audit.sh      │         │                        │
  └────────────────────────┘         │ obsidian-sync    300s  │
                                     │  CLAUDE.md -> vault    │
                                     └────────────────────────┘

═══ INTEGRATIONS ═══════════════════════════════════════════════════

  ┌─────────┐  ┌─────────┐  ┌─────────┐  ┌─────────┐
  │ Discord │  │  S-1    │  │Parakeet │  │Websites │
  │ #9sens  │  │  MIDI   │  │  .cpp   │  │ 4 sites │
  │ #macbol │  │ :8081   │  │  6ms    │  │ Jekyll  │
  │ bridge  │  │ mood    │  │  GPU    │  │ rsync   │
  │ watchdog│  │ engine  │  │  Polish │  │ MyDevil │
  └─────────┘  └─────────┘  └─────────┘  └─────────┘
  ┌─────────┐  ┌─────────┐  ┌─────────┐  ┌─────────┐
  │Playwrght│  │ Threads │  │ Copilot │  │ Prolog  │
  │ browser │  │  API    │  │  CLI    │  │ logic   │
  │ X/LI/   │  │ 3 accts │  │ bridge  │  │ gates   │
  │ Buffer  │  │ posting │  │ iTerm2  │  │ valid.  │
  └─────────┘  └─────────┘  └─────────┘  └─────────┘

═══ ENVIRONMENT (_environment/) ════════════════════════════════════

  superhuman.md (52KB full profile)
  dreams.yaml   (goals with sensory detail)
  priorities.md (EV-ranked)
  LANDSCAPE.md  (deploy topology)
  people/       (linkedin_contacts.csv, vc_list.csv)
  socials.yaml  (all social accounts)

═══ DELIVERABLES (P.A.R.A.) ════════════════════════════════════════

  projects/   active work (YYYY-MM_name/)
  areas/      ongoing (content, outreach, coaching, research)
  resources/  reference (transcripts, ebooks, case-studies)
  archive/    done

FRAMEWORK: nSENS (detailed)

nSENS = business validation framework. Takes an idea from "maybe" to "GO/PIVOT/KILL" with structured phases, persona-based analysis, and bias detection.

What it does

You feed it a business idea. It runs 34 personas against it (MIDAS checks pricing, STEVE checks positioning, BOZENKA verifies claims, BILL tells uncomfortable truths), detects 51 cognitive biases in your reasoning, validates with Prolog logic gates, and outputs a scored verdict: GO (7-8), CAUTION (5-6), PIVOT (3-4), KILL (0-2).

Phases

P0 Research     "Is there a market?"
    |           Hypothesis, market scan, 2+ sources
    v
P1 Discovery    "Will someone pay?"
    |           Customer interviews, willingness to pay, problem depth
    v
P2 Design       "How do we position it?"
    |           Solution design, GTM, competitive moat
    v
P3 Implement    "Can we build it for <$100?"
    |           MVP, technical validation, performance
    v
P4 Validation   "Do they come back?"
    |           Pilot, metrics, repeat behavior, LTV:CAC >= 3:1
    v
P5 Reflection   "What did we learn?"
                Post-launch, learnings, next pivot

Kill Gates (each phase)

  • ROI >= 3x or kill
  • LTV:CAC >= 3:1 or kill
  • Budget <= $100 or justify
  • Margin >= 40% or reprice
  • 2+ sources for any claim or flag

Lightweight variant: uSENS (miniSENS)

Same logic, 1-page format. Score 0-8, pass/fail checks. For quick validation before committing time. Lives at _framework/uSENS.md.

Personas (34 total, 4 layers)

ANALYSIS LAYER        EXECUTION LAYER       SYNTHESIS LAYER      META LAYER
  MIDAS (revenue)      STEVE (GTM)           BILL (truth)        DARO (QA)
  SILAS (intel)        ZBIGNIEW (OSINT)      BOZENKA (verify)    DARIUSZ (coach)
  ... 26 more across strategy, ops, content, legal, tech

Core modules (engine.py orchestrates all)

engine.py -----------> plugin_registry.py (loads active plugins)
    |                      |
    +-> personas.py        +-> 9 active plugins:
    |   (34 personas,          business_validator
    |    4 layers)             code_validator
    |                          meta_validator
    +-> validator.py           roi_calculator
    |   (Prolog + pytest       bias_detection
    |    + assumptions)        market_analyzer
    |                          competitive_intel
    +-> decision_log.py        risk_assessor
    |   (JSONL audit)          output_generator
    |
    +-> handoff_system.py
    |   (session continuity)
    |
    +-> adversarial_gate.py
        (red team: "what kills this?")

DIGITAL TWIN (detailed)

Not a chatbot personality. An executive function complement for ADHD.

How it works

Prolog file (executive_functions.pl, 28KB) encodes MJ's actual behavioral patterns extracted from 14+ months of conversation history. Not generic ADHD advice - specific patterns like "73 dead code files came from build-without-buyer pattern."

7 Gates (hooks.json)

USER SAYS SOMETHING
        |
        v
  ┌─────────────────────────────────────────────┐
  │ TWIN GATE (UserPromptSubmit hook)           │
  │                                             │
  │ Pattern match against 7 anti-patterns:      │
  │                                             │
  │ 1. BUILD-WITHOUT-BUYER                      │
  │    "build tools for that" without customer  │
  │    -> "Who pays in 30 days?"                │
  │                                             │
  │ 2. SHINY OBJECT                             │
  │    "new idea" while tasks open              │
  │    -> "Finish > Start. Check ACTIONS.md"    │
  │                                             │
  │ 3. RESEARCH-AS-AVOIDANCE                    │
  │    "think it through" when sell available   │
  │    -> "30-min timer. Sell action?"           │
  │                                             │
  │ 4. ORGANIZE-AS-AVOIDANCE                    │
  │    "restructure" when revenue tasks exist   │
  │    -> "Building or selling?"                │
  │                                             │
  │ 5. CONTENT-WITHOUT-VOICE                    │
  │    "write a post" without voice review      │
  │    -> "Creative Sharpening required"        │
  │                                             │
  │ 6. PRICING-WITHOUT-COGS                     │
  │    "how much to charge" without costs       │
  │    -> "Supplier costs first. Margin >= 40%" │
  │                                             │
  │ 7. TOOL-TRAP                                │
  │    "set up integration" without revenue tie │
  │    -> "Does this serve paying client?"      │
  │                                             │
  │ No match? -> "Success" (pass through)       │
  └─────────────────────────────────────────────┘

Prolog validation (executive_functions.pl)

Encodes axioms like:

strength(mj, pitching).
strength(mj, connecting).
condition(mj, adhd).
wound(mj, not_worthy).
anti_pattern(build_document_abandon, "73 dead files").
pro_pattern(sell_before_build, "Revenue first").
roi_gate(Idea, ROI) :- ROI >= 3, !.
roi_gate(_, _) :- write('KILL: ROI < 3x'), fail.

MEMORY ARCHITECTURE (detailed)

                    ┌─────────────────┐
                    │  New session     │
                    └────────┬────────┘
                             │
                    1. Search episodic memory
                    2. Read latest handoff
                    3. State what you remember
                             │
              ┌──────────────┼──────────────┐
              v              v              v
     ┌──────────────┐ ┌──────────┐ ┌──────────────┐
     │   Episodic   │ │ Handoffs │ │   ChromaDB   │
     │   Memory     │ │          │ │              │
     │  MCP plugin  │ │ _handoffs│ │  _memory/    │
     │  cross-      │ │ YYYY-MM- │ │  chromadb/   │
     │  session     │ │ DD_topic │ │  vectors     │
     │  semantic    │ │ .md      │ │              │
     │  search      │ │          │ │  query:      │
     └──────────────┘ │ sections:│ │  chromadb_   │
                      │  done    │ │  query.sh    │
     ┌──────────────┐ │  files   │ │  "query" N   │
     │  Decisions   │ │  loops   │ └──────────────┘
     │              │ │  next    │
     │  decisions/  │ └──────────┘ ┌──────────────┐
     │  .jsonl      │              │  Learnings   │
     │              │              │              │
     │  fields:     │              │  ~50 .md     │
     │  topic       │              │  synced to   │
     │  chosen      │              │  ChromaDB at │
     │  alternatives│              │  session end │
     │  rationale   │              │              │
     │  confidence  │              │  examples:   │
     │  impact      │              │  copilot-    │
     │  reversible  │              │  delegation  │
     └──────────────┘              │  post-deploy │
                                   │  verification│
                                   └──────────────┘

When to use which memory:

Need System Command
"What did we do last session?" Handoffs ls -t _handoffs/*.md | head -3
"Have we tried this before?" Episodic mcp search "topic"
"What mistakes did we make on X?" ChromaDB chromadb_query.sh "X failures" 3
"Why did we choose Y over Z?" Decisions Read _memory/decisions/decisions.jsonl
"What's MJ's writing voice?" Knowledge Read _memory/knowledge/mj-writing-voice.md
"Where are API tokens?" EPISODIC_TOC Read _memory/EPISODIC_TOC.md

STATS

Component Count
MCP servers 3 active
Hooks 9 active
Plugins 1 (digital-twin, 7 gates)
Core modules 15 (5K LOC)
Catalogs 9 (1400+ items)
Phases 6 (P0-P5)
Tools 8 Python
Scripts 16
Daemons 4 LaunchAgents
Memory systems 4
Websites 4
Total ~150 active components
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment