# SOP.md (v0.3.1) — Machine-Readable Specification Index > An open, domain-agnostic, plain-text specification for stateful information flows, Procedural Memory Graphs (DAG), and stigmergic trail routing across AI agents. > Canonical Repository: https://github.com/hooosberg/SOP.md > Technical Whitepaper: https://hooosberg.com/sop/ > Archival DOI (CERN Zenodo): https://doi.org/10.5281/zenodo.24857582 ## What SOP.md Is & Who It Is For - **Problem**: `MCP` standardizes tool connectivity; `SKILL.md` standardizes stateless atomic capabilities; `AGENTS.md` / `CLAUDE.md` capture single-repository rules. None of them standardize **cross-project procedural memory**—stateful `inputs -> gate -> outputs` workflow contracts, irreversible `human_signoff` locks, cross-session resume state, or time-decaying empirical routing. - **Target Audience**: AI agent developers, systems/release engineers, operations researchers, financial/compliance workflow owners, and multi-project solo practitioners running autonomous or semi-autonomous AI agents. - **Mathematical Model**: 1. **Layer 1 (Static Hard Skeleton)**: Finite Layered Composition DAG `G = (V, E_comp)` (`Master -> shared Sub-SOP` with optional Master nesting) combined with sequential intra-master dataflow pipeline verification (`inputs -> gate -> outputs` + `bind:`), coordinated via `sop-workspace.yaml` (`extends:`, `env` SSOT, `@mounts`, `registry`) and `runs//run.yaml`. Unlike classical execution DAG engines (e.g., Airflow/Make), `SOP.md` has no background daemon, avoids hardcoded `Sub -> Sub` edges, and adds controlled cross-run feedback (`Field Notes` + `trails.log`). 2. **Layer 2 (Dynamic Stigmergic Overlay)**: Append-only 5-symbol `trails.log` (`+`, `-`, `x`, `~`, `!`, with optional `until:YYYY-MM-DD` and `req:` precondition gates, written atomically via `sop_cli.py trail`) evaluated lazily at read-time via exponential half-life decay `W(u, t) = sum(s_i * 2^(-(t - t_i)/H_i))` with strict precedence (`x` > `~` > `req:` > friction `W <= -0.15` > regrown grass `|W| < 0.15 & >= 90d` > active/neutral), keeping static station specs immutable. ## Compatible AI Agents, IDEs & Runtimes - **CLI Coding Agents**: Claude Code, OpenAI Codex CLI, Gemini CLI, OpenCode, Qwen Code, Goose, Crush, OpenHands, Aider - **AI IDEs & Desktop Clients**: Google Antigravity, Cursor, Zed, Windsurf, GitHub Copilot (VS Code), Kilo Code, Cline, Cherry Studio, WorkBuddy / CodeBuddy, Trae, Qoder - **Local, Personal & Self-Hosted Agents**: Ollama, llama.cpp, vLLM, OpenClaw, nanobot, ZeroClaw (zero external dependencies; pure Python 3.8+ stdlib CLI) - **Verification Scope**: Empirically verified in Google Antigravity and headless Python 3 GitHub Actions CI; protocol/plain-text portable to all other listed tools. - **Complementary Protocols**: MCP (Model Context Protocol), Agent Skills (`SKILL.md`), `AGENTS.md` / `CLAUDE.md`, JSON Schema 2020-12, IETF RFC 2119 - **Reference Execution Pairing (Browser MCP)**: AgentLimb (https://agentlimb.com/ · https://github.com/hooosberg/AgentLimb) — MIT open-source Chrome extension + local 127.0.0.1 MCP bridge; one concrete execution layer for web-facing workflows (while `SOP.md` itself remains execution-agnostic across CLI, CI/CD, APIs, desktop, and browser tools). ## Invocation & Storage Rules - **Quick Install (One-Line CLI, uvx, GitHub Action, or Zero-Dependency Manual Copy)**: Run `npx skills add hooosberg/SOP.md --skill sop-runner` (via skills.sh), run the zero-dependency CLI directly via `uvx --from git+https://github.com/hooosberg/SOP.md sop-md validate-graph ...`, add CI checks via `uses: hooosberg/SOP.md@v0.3.1` (`action.yml`), or copy `skills/sop-runner/SKILL.md` manually to `/sop-runner/SKILL.md` plus the ~5-line conditional trigger hook. - **Conditional Implicit Trigger**: Pair a single Meta-Skill (`skills/sop-runner/SKILL.md`) with a ~5-line hook in `AGENTS.md` / `CLAUDE.md` / `GEMINI.md` that activates ONLY for multi-step/recurring workflows, cross-session resumes (`run.yaml`), or constrained external targets (`trails.log`)—skipping trivial one-off Q&A. - **Storage & Knowledge Lifespan Partition**: Project-local SOPs stay in their project repo; shared guardrails & `trails.log` live in an optional parent hub (`extends:`); legacy folders stay unmoved via `@mounts`. Single-run state goes to `runs//run.yaml`, time-varying target health appends 1 line to `trails.log`, and durable trial-and-error lessons go to unit `## Field Notes` (`[verified: YYYY-MM]`, soft cap <= 12). - **Long-Term Bounded Growth & Self-Compaction**: Completed runs move to cold `runs/archive/YYYY-QN/` (skipped automatically by `sop_cli.py activate` for O(1) resume); `trails.log` carries a 3-line `# Compaction Policy` header (soft cap: 150 entries) with read-only CLI sentinel hints to fold stale lines into cold `archive/trails-YYYY.log` (dropping expired `~` and >30d `!`, folding repetitive `+`/`-` by frequency, ALWAYS preserving active `x` hard vetoes). ## Core Specification & Reference Files - [README.md](./README.md): Formal English overview, mathematical model, agent compatibility matrix, empirical benchmarks, academic references, BibTeX. - [README.zh-CN.md](./README.zh-CN.md): Simplified Chinese edition. - [SPEC.md](./SPEC.md): Normative RFC 2119 specification (`v0.3`). - [schema/sop-frontmatter.schema.json](./schema/sop-frontmatter.schema.json): JSON Schema Draft 2020-12 for Master & Sub-SOP contracts. - [schema/sop-workspace.schema.json](./schema/sop-workspace.schema.json): JSON Schema Draft 2020-12 for `sop-workspace.yaml`. - [skills/sop-runner/SKILL.md](./skills/sop-runner/SKILL.md): Drop-in `agentskills.io`-compatible agent skill. - [scripts/sop_cli.py](./scripts/sop_cli.py): Zero-dependency Python 3 stdlib CLI (`validate`, `validate-graph`, `activate`, `trail`, `smell`, `impact`, `graph`, `backprop`, `sanitize`, `init-run`). - [examples/multi-project-network/sop-workspace.yaml](./examples/multi-project-network/sop-workspace.yaml): Multi-domain Procedural Memory Graph & Stigmergy reference implementation. - [SAFETY_AND_COMPLIANCE.md](./SAFETY_AND_COMPLIANCE.md): Governance, privacy, and anti-abuse charter. - [CITATION.cff](./CITATION.cff): Machine-readable scholarly citation metadata. ## Empirical Summary (Controlled Blind A/B Benchmarks, Decimal kB) - **Experiment 1 (Flat Folders vs. SOP.md Layer 1, N=27 docs, 257.8 kB, plain-text only)**: Context read `-81.5%` (309.1 kB -> 57.3 kB), Latency `-50.8%` (118 s -> 58 s), Tool calls `-44.4%` (27 -> 15), Resume payload `-88.8%` (28.9 kB -> 3.2 kB), Rule conflicts `5 -> 0`, Accuracy `20/20` parity. - **Experiment 2 (Explicit YAML Weights vs. `trails.log` Prototype, 6 isolated agents, 3 eras / 185 days)**: Output tokens `-48.3%` (27,048 -> 13,995), File writes `-72.2%` (18 -> 5), Station SOPs mutated `5 -> 0`, Write payload `-76.9%` (14.3 kB -> 3.3 kB), Tool-output read volume `+8.3%` (50.6 -> 54.8 kB due to sandbox `smell.py` rereads). ## Theoretical References - Tulving (1972) — Episodic vs. semantic memory (*Organization of Memory*) - Cohen & Squire (1980); Squire (2004) — Declarative vs. procedural ("knowing how") memory (*Science*, 210; *NLM*, 82) - Grassé (1959) — Stigmergy theory (*Insectes Sociaux*, 6) - Tero et al. (2010) — Biologically inspired adaptive network design (*Science*, 327) - Robinson et al. (2005) — Inhibitory 'No entry' ant trail pheromones (*Nature*, 438) - Bradner (1997) — IETF RFC 2119