// system design LIVE

Architecture

How the system is structured from the ground up

A context portfolio as the source of truth. An MCP server as the access layer. A shared memory and skills directory deployed to three AI clients. A task-graph runtime inside the gateway doing the actual agent work. Git as the backup for everything. Each layer is independently useful; stacked together, they make every session context-aware by default.

10 portfolio files 12 mcp tools 03 ai clients 01 shared server
layer_1_context_portfolio [01]

Context Portfolio

Ten structured markdown files in context-portfolio/. Each file covers one dimension of how I work. They are machine-readable, dense, and written to be useful to an AI without ceremony. Edits are reflected immediately: the MCP server reads from disk on every request.

identity.md

Who I am, my role, stack, principles, and how to work with me.

role-and-responsibilities.md

Core responsibilities, weekly cadence, key decisions owned, and reporting structure.

current-projects.md

Five active projects with status, stack, and cross-project relationships.

communication-style.md

Writing style, formatting preferences, what to avoid, and audience-specific patterns.

decision-log.md

How decisions are made, recent decisions, and currently open decisions.

domain-knowledge.md

Areas of expertise, key terminology, frameworks, and what is actively being learned.

goals-and-priorities.md

Current goals, longer-term goals, tradeoff thinking, and what success looks like.

preferences-and-constraints.md

Hard constraints, strong preferences, things disliked, and AI output preferences.

team-and-relationships.md

Key relationships, working styles, and organisational context.

tools-and-systems.md

Full tooling inventory across Salesforce, AI, VSCode, frontend, and project management.

Portfolio files are also readable via an interview agent (context-portfolio-interviewer/) that can review and update each file through a structured conversation, keeping them accurate as circumstances change.
layer_2_mcp_server [02]

MCP Server

A Node.js (ESM) server using the official @modelcontextprotocol/sdk. Binds to 127.0.0.1:3000 only. Runs under pm2 and auto-starts on Windows login via Task Scheduler. All three AI clients connect to the same server instance.

01
MCP Transport

StreamableHTTP (stateless) transport on POST /mcp, guarded by a bearer token generated on first run and compared with a timing-safe check. Every portfolio file is exposed as a portfolio://<name> resource. Files read from disk on every request, so edits are live without a restart. No session management required with stateless transport.

02
Status and Telemetry Endpoints

GET /status returns server metadata, uptime, restart count, and a rolling request log. POST endpoints receive events from client hooks:

/skill-log: records skill/command invocations with model and token usage
/tool-log: records MCP tool calls with duration and token data
/command-log: receives Cursor slash command events (hooks.json) and Codex command events (logging block injected at sync)
/agent-log: tracks agent invocations with per-agent token stats
/portfolio-read: accepts external portfolio-read events from non-resource clients
/memory-synced: records the timestamp of the last memory sync
/set-project: tags subsequent entries with the active workspace name
03
Persistence

All-time counters (invocations, tokens, restarts, uptime) are persisted to persist.json on a 60-second interval and on graceful shutdown. Session counters reset on restart; all-time counters accumulate across restarts. persist.json is gitignored so telemetry data does not pollute the repo.

04
Token Normalisation

A normalisation pipeline converts token usage across providers (camelCase and snake_case field names) into a consistent internal format. Per-model aggregation tracks session and all-time totals separately for any model ID a client reports, from the Claude family through the OpenRouter-hosted models the runtime routes to.

canonical_vs_runtime [03]

Canonical vs Runtime

The git repository is the single source of truth. The runtime directories (~/.claude/, ~/.codex/, ~/.cursor/) are derived state: they can always be recreated from the repo by running the relevant client's sync.ps1.

Canonical (git repo)
clients/claude/CLAUDE.md: behavioural contract
clients/shared/memory/: global memory files
clients/shared/skills/: 16 shared commands
clients/claude/settings.json: hooks + permissions
clients/codex/config-fragment.toml: Codex MCP block
clients/cursor/mcp-config.json: Cursor MCP config
Runtime (local machine)
~/.claude/CLAUDE.md: deployed by sync.ps1
~/.claude/memory/: deployed from shared/memory/
~/.claude/commands/: deployed from shared/skills/
~/.codex/config.toml: config fragment injected
~/.cursor/mcp.json: deployed by sync.ps1
~/.cursor/skills/: shared skills deployed
layer_3_shared_memory_and_skills [04]

Shared Memory and Skills

clients/shared/ is the single location for memory and skills that apply to all three clients. Each client's sync.ps1 sources from here, so a change to a shared command or memory file propagates to Claude, Codex, and Cursor on the next sync.

clients/
shared/
├── memory/
│  ├── global.md ──▶ identity, role, stack
│  ├── conventions.md ──▶ Salesforce, git, code standards
│  └── projects/ ──▶ per-project context files
└── skills/ ──▶ 16 shared slash commands
claude/ ──▶ CLAUDE.md, settings.json, commands/, sync.ps1
codex/ ──▶ config-fragment.toml, sync.ps1
cursor/ ──▶ mcp-config.json, hooks.json, sync.ps1
Shared skills are templated. {{LIGHTWEIGHT_MODEL}} and {{CLIENT_NAME}} placeholders expand per client at sync time, so a single skill file targets the right lightweight model and client name on Claude, Codex, and Cursor without divergent copies.
layer_4_agent_runtime [05]

Agent Runtime

The same gateway process hosts the task-graph runtime: a graph engine that fans agent workflows out across the enrolled projects, a deterministic verifier that re-checks model output against the source, a replay-only apply engine behind code-enforced gates, and a run-control API (workflows, runs, live node events over SSE) that the dashboard's Studio hub drives. Run telemetry is appended to canonical JSONL and dual-written to a SQLite ledger and queue. Workflow and project catalogues are committed JSON registries, validated at load, so enrolment changes get git review.

Deterministic spine

Graph structure, sequencing, verification, and every write gate are code. Models run only inside node bodies. The graph is validated before any model spend, and a per-run budget acts as a circuit breaker.

Full story

The runtime has its own page covering the engine, the verifier's failure domains, failover routes, the apply gate chain, and the live proof points.

view the runtime →
bootstrap_sequence [06]

Bootstrap Sequence

The system can be restored to a new machine by cloning the repo and running four steps. bootstrap.ps1 automates the validation pass; the sync scripts handle deployment.

Step Action What it sets up
1 Set AGENTOSROOT env var Commands and sync scripts resolve the repo path without hardcoded paths. Required before running anything else.
2 Run bootstrap.ps1 Validates Node.js, pm2, VSCode prerequisites. Configures environment variables. Runs initial agent setup.
3 Run each client's sync.ps1 push-runtime Deploys CLAUDE.md, memory, commands, and settings.json to ~/.claude/. Same pattern for Codex and Cursor.
4 Start MCP server under pm2, register with each client MCP server running and accessible at port 3000. Claude, Codex, and Cursor registered via their respective MCP config.