The Site Factory System Architecture,
Resources & Rule Guide
How Cloudflare D1 serves as our central Source of Truth and fenced service-lease coordinator while a home cluster of 3 Macs (Mac mini, Studio 1, Studio 2) autonomously researches, builds, tests, merges, deploys, and patrols 14 public websites local-AI first. Deep-dive explanations of all the concepts are in the Technology Glossary.
Four Departments and Their Roles
The Site Factory is organised like a company that collects and uses data to build and run several sites and services.
Planning
- Director
Turns policy and research results into what to work on next
- Researcher
Looks into user problems, new ideas and useful source material
Data
- Data Collector
Fetches source material, then stores and updates it together with its source and retrieval time
- Data Curator
Extracts, translates, classifies and normalises it into a reusable form
Development and Operations
- Operations Coordinator
Manages assignment, progress, stalls and the merging of changes across departments
- Developer
Implements, fixes and tests sites, features and the collection and curation programs
- Release Manager
Applies changes to the published sites and running systems
Quality
- Reviewer
Checks the content, sources, evidence and implementation of data and deliverables
- QA
Checks that systems work, and checks each site’s display, interactions, links and search-engine settings
Departments are a division of roles. The Operations Coordinator coordinates progress across departments. Several AIs or programs may share one role, but a ticket has one owner at a time. This does not add any new department heads, AIs or always-running processes.
Flow of data
Collect → store the source → curate → accumulate
The data lake is the shared store for source material and processed results. Data is collected independently of site production and used by both planning and development.
Flow of a product
Research and planning → development → review and QA → release → checks and improvement after publication
The Quality department checks data as well. Problems go back to the Developer or to a role in the Data department, and new improvement ideas go to the Director.
This chart shows areas of responsibility, not how many processes are running or whether a plan is finished. The terms are defined in Departments and Roles.
1. Overall System Architecture Diagram
2. The 6-Step End-to-End Task & Publication Loop
Discovery & Queueing
From operator instructions, site patrol findings, SEO audits, the Researcher’s findings, and benchmark queues, Director (macgakari) and the Operations Coordinator (patrol) register work items in the Cloudflare D1 Source of Truth (work_items) and Git tickets (ops/cloud/).
Fenced Reservation & Dispatch
Cloudflare Workers/D1 (honbu-dispatcher) checks machine availability, active benchmark locks (mac.lock / step.lock), and remaining AI quotas, assigning each task to a single Developer via a generation-numbered lease.
Local AI Execution First
Tasks are attempted first by free local LLMs on our Macs (Tier 1: direct Ollama calls or Tier 2: Hermes A2A across Studio 1 & 2). The model is selected automatically from the latest benchmark results for that specific Mac and task type (Rule K100).
Cloud Escalation & Receipt Verification
Only if local AI cannot solve the task does it escalate—with prior attempt logs attached—to Tier 3 lightweight cloud models (Cursor Auto / Gemini Flash low / Codex Luna / Claude Haiku). Upon completion, a deterministic script verifies artifact content hashes and records a receipt in D1.
Automated CI, Squash Merge & Deploy
When a pull request is opened, Mac mini’s isolated Self-hosted Runners execute the test suite. Once all checks pass, the Operations Coordinator (patrol) automatically squash-merges the PR into main and triggers production deployment.
Live Verification & Effect Measurement
A task transitions to done only after a script verifies HTTP 200 and content hashes on the live public URL. Newly launched sites are automatically added to memocho.dev, and post-launch traffic/revenue evaluations feed the next improvement cycle.
3. Five Key Architectural Innovations
To prevent common failure modes in autonomous multi-agent systems—single-machine bottlenecks, runaway API quota burn, and hallucinated “done” reports—the Site Factory is built around five core mechanisms:
① Active-Standby Resident Services via D1 Service Leases
Previously, over 40 launchd jobs ran solely on Mac mini (16GB), creating a single point of failure. Today, all 3 Macs (Mac mini, Studio 1, Studio 2) install the same resident services, and only the Mac that acquires the time-bounded D1 Service Lease runs that cycle. If one Mac is rebooting, sleeping, or running benchmarks, another idle Mac seamlessly takes over.
② Asymmetric 3-Tier AI Routing & Remote Inference Offloading
Running heavy 64K-context agent loops on a 16GB Mac mini causes swap thrashing. We separate execution into Tier 1 (fast single-shot Ollama across all Macs), Tier 2 (Hermes multi-agent A2A on 36GB/96GB Studios only), and Tier 3 (cloud AI). When a light job on Mac mini needs heavy LLM inference, it offloads just the inference call to an idle Studio over restricted SSH.
③ Deterministic Verification & Content-Hash Receipts
AI agents occasionally claim “tests passed” or “fixed” inaccurately. The Site Factory enforces deterministic Python verification for JSON schemas, row counts, math, forbidden link checks, and test suites. Even if an agent exits with code 0, the task cannot complete unless its cryptographic content-hash receipt passes verification.
④ Mutex Lock Coordination Between Benchmarks & Operations
Our Macs also serve as the hardware testbed for llmonmac.com. Because background AI jobs would skew tokens-per-second and memory measurements, active benchmarks acquire mac.lock (Studio 1) or step.lock (Studio 2) to pause other heavy AI workers cleanly until the measurement finishes.
⑤ Free-Tier Preservation & AI Pre-Screened Operator Escalation
To stay within GitHub Actions’ 2,000 free minutes/month and Cloudflare D1’s free tier, CI runs on 15 isolated self-hosted runners on Mac mini, and the dashboard is served as static Markdown without live DB queries on page view. When errors or holds occur, operator_review uses a frontier model to verify whether human action (such as entering a password or signing a contract) is truly unavoidable before notifying the operator.
4. Roles
Conversations, tickets and reports use these role names. The Reviewer checks content, evidence and implementation; QA checks actual behaviour and display.
| Department | Role | What it does |
|---|---|---|
| — | Operator | Sets the purpose, the priorities and the policy |
| Planning | Director | Turns policy and research results into what to work on next |
| Planning | Researcher | Looks into user problems, new ideas and useful source material |
| Data | Data Collector | Fetches source material, then stores and updates it together with its source and retrieval time |
| Data | Data Curator | Extracts, translates, classifies and normalises it into a reusable form |
| Development and Operations | Operations Coordinator | Manages assignment, progress, stalls and the merging of changes across departments |
| Development and Operations | Developer | Implements, fixes and tests sites, features and the collection and curation programs |
| Development and Operations | Release Manager | Applies changes to the published sites and running systems |
| Quality | Reviewer | Checks the content, sources, evidence and implementation of data and deliverables |
| Quality | QA | Checks that systems work, and checks each site’s display, interactions, links and search-engine settings |
Even when the existing management processes of the Director, the Operations Coordinator and the Release Manager are placed on several Macs, only one runs per role at a time. A management process is distinct from the AI it asks to do the work. Example: Developer: Codex / runtime: Mac mini.
5. Hardware, Cloud & Model Resources
5-1. Hardware Cluster (4 Macs)
| Machine (Host) | Specs | Primary Role | Resident Services |
|---|---|---|---|
| Mac mini | 16GB RAM · 256GB SSD 1GbE + Wi-Fi |
24/7 shared queue, daily site updates & CI base. Runs daily data collection, AI Island progression, 15 self-hosted GitHub runners, small LLM benchmarks (6/day), and MLX Whisper speech recognition. | mini-queue (heavy/light), Ollama, 15 GitHub Runners, D1-leased management and inspection processes, 5 developer AIs |
| Mac Studio 1 | Apple M5 Max 36GB RAM · 512GB SSD |
Primary LLM benchmark rig & mid-size local AI host. Runs 24/7 benchmarks for llmonmac.com, accepts offloaded inference from Mac mini, runs Hermes A2A with Studio 2, and monitors operational mail and hardware health. |
mac-llm-bench, mini-queue, Hermes A2A, mail-watch, hardware-watch, D1-leased management and inspection processes, 5 developer AIs |
| Mac Studio 2 | Apple M5 Ultra 96GB RAM · 1TB SSD |
Ultra-memory local AI & 120B benchmark powerhouse. Runs 96GB large-model benchmarks, Hermes A2A code generation and peer review, and the Researcher’s investigations. | Large-model bench (step.lock), Hermes A2A, Researcher inference, D1-leased management and inspection processes, 5 developer AIs |
| MacBook (Operator laptop) |
Apple A18 Pro 8GB RAM · 512GB SSD |
Operator console & key distribution entry point. Used by the human operator for instructions and registering new API keys into macOS Keychain for secure SSH sync. | Runs zero local LLMs or background workers to prevent swap wear on 8GB RAM (Rule K04). |
5-2. AI Model Cascade (Rule K104)
| Tier (Priority Order) | Models & Tools | Where It Runs & Cost | Selection & Escalation Rule |
|---|---|---|---|
| Tier 1 Single-Shot Local AI |
Ollama (gemma4:12b, qwen3.5:4b/9b, MiniCPM5-2B, etc.) + mlx-whisper |
Mac mini / Studio 1 / Studio 2 (Electricity only · No quota limit) |
Data extraction, classification, short summaries, structured JSON output, and ASR. Automatically selects the top-scoring model from recent benchmarks on that Mac (Rule K100). |
| Tier 2 Multi-Agent Local AI |
Hermes Agent + 27B–120B models (qwen3.6:35b-a3b, qwen3.8:27b, gpt-oss:120b) |
Studio 1 (36GB) & Studio 2 (96GB) (No quota limit) |
Multi-file coding and cross-machine peer review (A2A), gated by deterministic Python checks first. |
| Tier 3 Lightweight Cloud AI |
① Cursor (Auto)② Antigravity ( Gemini Flash low)③ Codex ( gpt-6-luna)④ Claude Code ( Haiku) |
CLI runners across the 3 Macs (Within flat-rate plan quotas) |
Handles tasks unresolved by local AI or complex cross-repo changes, inheriting local attempt logs. |
| Frontier Tier High-Capability Cloud AI |
• Antigravity (Gemini Flash high)• Codex ( Sol high+)• Claude Code ( Opus high) |
Available Mac runners (Quota-protected) |
Never used on the first try. Reserved strictly for: (1) verified escalations where Tier 3 failed, (2) new-site go/no-go reviews, and (3) final human-action screening (operator_review). |
6. K-Numbers & Core Architecture Terms (All Terms →)
The Site Factory numbers its operational rules from K01 upward (K = “Kimari” [Rule], indexed in ops/rules_index.json) so the operator and agents can reference or revise rules by number. Deep-dive articles on all the concepts are available in our Technology Glossary.
Local LLM first → Lightweight cloud model → Frontier model only with verified evidence. Prevents burning cloud token quotas on tasks that local hardware can solve.
Selects local LLMs dynamically based on the latest empirical benchmark scores for that specific Mac and task category rather than hardcoding model names.
Cloudflare D1 is the single authoritative database for task state and leases. Files like ops/work/tasks.json and README tables in Git are read-only projections.
Time-bounded locks in D1 that determine which Mac runs the Operations Coordinator (patrol) and the other management processes. Each acquisition increments a monotonic generation number so stale writers are deterministically rejected.
A role that finishes a job must submit a cryptographic content-hash receipt and PR reference to complete a job, updated via CAS so concurrent writes never overwrite each other.
Before escalating an error or hold to the human operator, a frontier model inspects the logs to verify whether AI can resolve it autonomously or if human credentials/contracts are required.