Skip to content

Nexus SecOps AI Architecture

Internal documentation -- This document describes the AI systems powering Nexus SecOps. It is included in the repository for transparency and academic review but is not linked from the live site navigation.


Overview

Nexus SecOps operates with three interconnected AI layers that work together to build, maintain, and improve the site autonomously:

Layer Purpose Scale
Knowledge Graph Structured domain model of cybersecurity concepts and their prerequisite relationships 448 nodes, 620 edges, 10 taxonomy categories
Nexus Brain 10-phase autonomous agent that perceives the project state, reasons about improvements, and creates pull requests Runs Monday + Thursday via GitHub Actions
GraphRAG Retrieval-augmented generation that injects relevant graph context into LLM prompts for higher-quality AI responses 4 LLM providers, zero cost

These layers are not independent. The Brain consumes the Knowledge Graph during its reasoning phases, and GraphRAG uses the graph to ground LLM responses in structured prerequisite relationships.


Knowledge Graph Schema

The knowledge graph is stored in docs/learning-graph/graph.json (vis.js compatible) with a CSV interchange format in docs/learning-graph/concepts.csv and docs/learning-graph/dependencies.csv.

Node Schema

{
  "id": "C001",
  "label": "CIA Triad",
  "group": "T01",
  "shape": "box",
  "title": "Confidentiality, Integrity, Availability — the foundational security model",
  "url": "chapters/ch01-introduction/"
}
Field Description
id Unique concept identifier (C001--C448)
label Human-readable concept name
group Taxonomy category (T01--T10)
shape Visual encoding of concept type (see below)
title Tooltip description shown on hover
url Link to the chapter covering this concept

Node Shapes (Concept Types)

Shape Meaning Example
box Foundation -- no prerequisites, entry point CIA Triad (C001), Log Sources (C005)
ellipse Intermediate -- has prerequisites and dependents Detection Engineering (C024), SIEM Correlation (C018)
star Goal -- advanced synthesis concept, many prerequisites Threat Hunting at Scale (C310), Purple Team Operations (C285)

Edge Schema

{
  "from": "C001",
  "to": "C002"
}

Edges are directed: from is a prerequisite of to. This means "you should understand C001 before learning C002."

Taxonomy Categories

ID Category Description
T01 Foundations Core security principles (CIA, AAA, risk)
T02 Data & Telemetry Log sources, normalization, data pipelines
T03 Detection & Analytics SIEM, correlation, detection engineering
T04 Response & Recovery Incident response, SOAR, forensics
T05 Threat Intelligence CTI, threat actors, IOCs, feeds
T06 Offensive Security Penetration testing, red teaming, exploitation
T07 Cloud & Infrastructure Cloud security, containers, network architecture
T08 Application Security AppSec, DevSecOps, API security
T09 AI & Machine Learning ML in SOC, LLM security, adversarial AI
T10 Governance & Leadership Compliance, risk management, security programs

Graph Validation Rules

The knowledge graph enforces 6 structural rules during CI validation:

  1. Prerequisite coverage: Every non-foundation node (shape != box) must have at least 1 incoming edge
  2. No self-dependencies: No node can list itself as a prerequisite
  3. Acyclic: The graph must be a DAG (directed acyclic graph) -- no circular prerequisite chains
  4. No orphans: Every node must be reachable from at least one foundation node
  5. Fully connected: The graph forms a single connected component (no isolated subgraphs)
  6. Category balance: No single taxonomy category may contain more than 30% of all nodes

10-Phase Cognitive Cycle

The Nexus Brain executes a 10-phase cognitive cycle on each run. This is implemented in .github/workflows/brain.yml and the supporting Python scripts.

graph LR
    P[PERCEIVE] --> RC[RECALL]
    RC --> A[ANALYZE]
    A --> R[REASON]
    R --> CR[CRITIQUE]
    CR --> RF[REFINE]
    RF --> ACT[ACT]
    ACT --> E[EVALUATE]
    E --> L[LEARN]
    L --> RM[REMEMBER]
    RM -.->|next cycle| P

Phase Descriptions

# Phase What It Does
1 PERCEIVE Gathers signals from the environment: file counts and modification dates, git history, open GitHub issues and PRs, threat intelligence feeds (CISA KEV, etc.), knowledge graph structure, Plausible analytics (when available). Produces a structured signal payload.
2 RECALL Loads brain-memory.json -- the persistent memory store containing learned patterns, past decision outcomes, provider performance stats, and exploration parameters. This gives the Brain continuity across runs.
3 ANALYZE Processes raw signals into actionable insights. Computes a project health score (0--100). Identifies stale content (>90 days since last update). Traverses knowledge graph prerequisite chains to find content gaps -- concepts that exist in the graph but lack adequate chapter coverage. Performs content connectivity analysis to find weakly-linked topics.
4 REASON The core intelligence phase. Sends the analyzed signals to an LLM with a multi-persona council prompt. Four expert personas debate the best next actions: Threat Analyst (what threats are emerging?), Educator (what learning gaps exist?), Quality Engineer (what is broken or stale?), Growth Strategist (what will attract practitioners?). The LLM receives relevant knowledge graph subgraph context -- prerequisite chains and concept metadata for the topics under discussion.
5 CRITIQUE Applies domain quality gates to the proposed plan. Checks include: IP address safety (only RFC 5737/1918), ATT&CK technique ID format validation (T####.###), KQL/SPL query syntax validation, content depth thresholds (minimum word counts, required sections), domain safety (no real malware, credentials, or weapization). Any gate failure sends the plan back to REFINE.
6 REFINE Adjusts the plan based on critique feedback. May drop, modify, or reorder proposed actions. Ensures the final plan passes all quality gates before proceeding.
7 ACT Executes the refined plan by creating GitHub pull requests. Actions include: generating new detection rules (KQL/SPL), writing attack scenarios, creating blog posts with current threat intel, updating stale content, expanding the knowledge graph. Each PR includes a structured description with the Brain's reasoning trace.
8 EVALUATE Reviews outcomes from the previous cycle: which PRs were merged, which were rejected, which issues were resolved. Computes a cycle effectiveness score.
9 LEARN Extracts patterns from evaluation results. Updates the multi-armed bandit reward estimates for each LLM provider. Identifies which types of content get merged vs. rejected. Adjusts future behavior accordingly.
10 REMEMBER Persists all learned state back to brain-memory.json: updated provider scores, new patterns, cycle outcomes, exploration rate decay. This memory is loaded in the next cycle's RECALL phase.

Cycle Scheduling

gantt
    title Brain Execution Schedule
    dateFormat  YYYY-MM-DD
    section Weekly Cycles
    Monday Run     :active, mon, 2026-03-30, 1d
    Thursday Run   :active, thu, 2026-04-02, 1d
    Monday Run     :active, mon2, 2026-04-06, 1d
    Thursday Run   :active, thu2, 2026-04-09, 1d

The Brain runs automatically via GitHub Actions on Monday and Thursday mornings. Each run takes 3--5 minutes and produces 1--3 pull requests.


Multi-LLM Router

The Brain does not rely on a single LLM. It uses an epsilon-greedy multi-armed bandit algorithm to route requests across four free-tier providers.

Provider Pool

Provider Model Free Tier Primary Use
Mistral Mistral Small 1M tokens/month Primary -- highest baseline quality
Google Gemini 2.0 Flash 1M tokens/month Fast reasoning, good for ANALYZE phase
Groq Llama 3.3 70B 500K tokens/day Low latency, good for CRITIQUE phase
Cohere Command R+ 1000 req/month Strong at structured output

Total cost: $0. All providers offer free tiers sufficient for the Brain's twice-weekly execution schedule.

Routing Algorithm

flowchart TD
    REQ[New LLM Request] --> RAND{Random < epsilon?}
    RAND -->|Yes: Explore| RANDOM[Pick random provider]
    RAND -->|No: Exploit| BEST[Pick highest-reward provider]
    RANDOM --> CALL[Call LLM API]
    BEST --> CALL
    CALL --> SUCCESS{Success?}
    SUCCESS -->|Yes| REWARD[Update reward: quality score]
    SUCCESS -->|No| FALLBACK[Try next provider in chain]
    FALLBACK --> CALL
    REWARD --> DECAY[Decay epsilon]
  • Epsilon starts at 0.3 (30% exploration) and decays toward 0.05 over time
  • Rewards are tracked per-phase (a provider good at REASON may not be good at CRITIQUE)
  • Fallback chain: Mistral -> Gemini -> Groq -> Cohere. If the selected provider fails, the next in chain is tried automatically
  • Performance history is persisted in brain-memory.json across cycles

Self-Monitoring Infrastructure

count_validator.py

Problem: The site announces content counts in many places (homepage, nav descriptions, chapter headers, CLAUDE.md). When content is added, these counts go stale silently.

Solution: scripts/count_validator.py scans all markdown files for numeric content claims and validates them against actual file counts. Runs in CI on every push.

flowchart LR
    PUSH[Git Push] --> CI[GitHub Actions]
    CI --> CV[count_validator.py]
    CV --> SCAN[Scan .md files for count patterns]
    SCAN --> COUNT[Count actual files in each category]
    COUNT --> COMPARE{Counts match?}
    COMPARE -->|Yes| PASS[CI passes]
    COMPARE -->|No| FAIL[CI fails with specific mismatches]

content_refresh.py

Scans all content files and flags anything not updated in the last 90 days. Generates CONTENT_STATUS.md with a freshness report. Used by the Brain's PERCEIVE phase to identify stale content.

PR Validation Workflow

Every pull request (both human and Brain-generated) must pass:

  1. mkdocs build --strict -- zero warnings, zero errors
  2. Broken link check -- all internal links resolve
  3. Synthetic data compliance -- no real IPs, credentials, or domains
  4. Count validation -- announced numbers match reality

Brain Auto-Merge

Brain-generated PRs can be auto-merged after passing 6 quality gates:

  1. CI pipeline passes (build + validation)
  2. No merge conflicts
  3. Content count validation passes
  4. All quality gate checks from CRITIQUE phase logged
  5. PR description includes reasoning trace
  6. No structural changes (nav, config, or schema modifications require human review)

How AI Built This Site

Claude Code (Primary Development Tool)

Nexus SecOps was built across 17 iterative sessions using Claude Code as the primary development tool. Each session followed a structured protocol:

  1. Read NEXT_SESSION.md for priorities
  2. Run mkdocs build --strict to establish baseline
  3. Execute prioritized tasks (content creation, tooling, infrastructure)
  4. Update all state files (CLAUDE.md, NEXT_SESSION.md, EVOLUTION_LOG.md)
  5. Commit and push

Claude Code wrote all 50 chapters, 40 MicroSims, 26 labs, the gamification system, the knowledge graph, the Brain infrastructure, CI/CD pipelines, and the custom theme.

Nexus Brain (Autonomous Maintenance)

Between human sessions, the Brain runs autonomously to:

  • Generate threat intelligence blog posts from real feed data
  • Create new detection rules (KQL and SPL)
  • Update stale content with current references
  • Expand the knowledge graph with new concepts
  • File issues for gaps it cannot fix autonomously

Graph-Aware Reasoning

The Brain's key differentiator is that it reasons about content structurally, not just textually. When the ANALYZE phase identifies that concept C245 (Cloud Container Security) has weak coverage, it doesn't just flag the gap. It traverses the prerequisite chain:

C001 (CIA Triad) -> C042 (Cloud Fundamentals) -> C178 (Container Basics) -> C245 (Cloud Container Security)

This prerequisite chain is injected into the REASON phase prompt, so the LLM understands not just what to write, but where it fits in the learning progression and what concepts it should reference.

Architecture Diagram

flowchart TB
    subgraph "Human Layer"
        CC[Claude Code Sessions]
        HR[Human Review]
    end
    subgraph "AI Layer"
        BRAIN[Nexus Brain]
        ROUTER[Multi-LLM Router]
        GRAPH[Knowledge Graph]
    end
    subgraph "Infrastructure"
        GHA[GitHub Actions]
        CF[Cloudflare Pages]
        CI[CI Pipeline]
    end

    CC -->|commits| GHA
    BRAIN -->|PRs| GHA
    GHA -->|build| CI
    CI -->|deploy| CF
    BRAIN --> ROUTER
    ROUTER -->|Mistral/Gemini/Groq/Cohere| BRAIN
    BRAIN -->|reads| GRAPH
    BRAIN -->|expands| GRAPH
    HR -->|merge/reject| GHA

Technical References

Component Location
Knowledge Graph data docs/learning-graph/graph.json
Concept catalog (CSV) docs/learning-graph/concepts.csv
Dependency catalog (CSV) docs/learning-graph/dependencies.csv
Graph viewer (interactive) docs/learning-graph/graph-viewer.html
Brain workflow .github/workflows/brain.yml
Brain memory brain-memory.json (root)
Count validator scripts/count_validator.py
Content freshness scripts/content_refresh.py
PR validation .github/workflows/pr-validation.yml
Auto-merge logic .github/workflows/brain-auto-merge.yml
MkDocs config mkdocs.yml
Project state CLAUDE.md
Session priorities NEXT_SESSION.md
Evolution history EVOLUTION_LOG.md