SOP.md (v0.3): Decoupling Static DAG Contracts from Stigmergic Trail Decay for AI Agent Procedural Memory
Specification Repository: https://github.com/hooosberg/SOP.md
Archival DOI (CERN Zenodo): 10.5281/zenodo.24857582
License: CC BY 4.0 (Specification) / Apache 2.0 (Reference CLI & Skill)
Abstract
Current open standards for AI agents address tool connectivity (MCP) and stateless atomic capabilities (SKILL.md), while agent memory systems predominantly model episodic memory or semantic memory (Tulving, 1972).
In multi-project engineering and operational workspaces, however, recurring failures stem from unstandardized procedural memory ("knowing how"; Cohen & Squire, 1980; Squire, 2004): stateful step contracts, cross-document rule drift, irreversible human sign-off boundaries, and time-varying endpoint reliability.
This technical note introduces the design and empirical evaluation of SOP.md (v0.3.0), a plain-text, Git-native, zero-dependency specification composed of two decoupled layers:
- Layer 1 (Static Hard Skeleton): A 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), workspace constants (env), logical directory@mounts, lazy hub inheritance (extends:), and an episodic auto-resume state bus (run.yaml). - Layer 2 (Dynamic Stigmergic Overlay): An append-only 5-symbol execution log (
trails.log) evaluated lazily at read-time via exponential half-life decay, avoiding manual weight maintenance on static specification files while preserving negative procedural memory.
1. Problem Formulation
For single-repository coding tasks, static context files (AGENTS.md, CLAUDE.md) are generally sufficient.
Across concurrent multi-project workspaces (10+ active threads sharing compliance checks, build gates, or external publishing endpoints), three structural failure modes emerge:
- Linear Context Growth: Flat folders and append-only session diaries require fresh agent sessions to scan
O(|D|)historical text merely to identify active blockers and resume state. - Cross-Document Drift: Duplicating shared guardrails across project directories yields contradictory constraints once one branch evolves.
- Amnesia on Inhibited Paths: Deleting a failing or permanently restricted endpoint from documentation removes negative memory, causing subsequent stateless sessions to re-attempt known dead ends.
Conversely, introducing a heavy external orchestration server or vector database breaks Git auditability, portability across local/IDE agents, and plain-text diffing.
2. Dual-Layer Graph Formulation
2.1 Static Hard Skeleton: Layered Composition DAG G = (V, E_comp) & Pipeline Contracts
SOP.md models static composition topology as a finite layered composition DAG G = (V, E_comp), where V = V_master βͺ V_sub. Explicit edges connect Master flows to shared Sub-SOPs (and optionally nested Masters; shared nodes have in-degree β₯ 2, distinguishing the structure from a tree).
Within each Master, units: is verified as a sequential dataflow pipeline. Unlike classical execution DAG engines (e.g., Airflow, Make, Prefect), SOP.md never hardcodes Sub -> Sub edges, runs no scheduler daemon, and introduces controlled cross-run feedback (Field Notes + trails.log) while keeping every single execution acyclic.
- Typed Dataflow & Slot Binding: Each edge binds
inputs -> gate -> outputs, with optionalbind:slot mapping so domain-specific artifacts (ledger_summary,release_summary) attach to shared nodes without renaming either side. - Accountability Boundaries: Irreversible actions carry
gate: human_signoff(RFC 2119 normative hard stop). - Episodic Auto-Resume (
runs/<run_id>/run.yaml): A compact structured state bus (~3 kB) replaces multi-thousand-line session logs so any fresh agent session resumes deterministically. - Bounded Backpropagation: Operational lessons verified in execution are written back to shared Sub-SOP Field Notes tagged
[verified: YYYY-MM](soft cap β€ 12 entries/node).
2.2 Dynamic Overlay: Stigmergic Trail Decay (trails.log)
While a DAG captures structural legality, real-world endpoints change reliability over time (rate-limit cooldowns, permanent read-only locks, transient 502 timeouts, long-term disuse).
Naively storing mutable floating-point weights inside static node YAML assumes agents will reliably open multiple files and perform arithmetic after every run. In practice, bounded LLM agents exhibit high write inertia ("lazy agents"), leading to stale weights and spec churn.
Drawing on biological stigmergy (GrassΓ©, 1959), adaptive Physarum network reinforcement (Tero et al., Science 2010), and negative "no-entry" ant trail pheromones (Robinson et al., Nature 2005), SOP.md v0.3 leaves all static .sop.md contracts immutable and appends 1-line execution footprints to trails.log:
2026-12-01 | + | target-a | Verified clean execution
2026-12-03 | - | target-b | Mild friction / schema retry
2026-12-04 | x | target-c | Locked read-only (hard veto)
2026-12-04 | ~ | target-d | Rate cooldown until:2026-12-10
2026-12-05 | ! | target-e | Single 502 blip (0 penalty)
Routing salience is evaluated lazily at read-time (zero background daemon) via exponential half-life decay:
W(u, t) = Ξ£ s_i Β· 2^(-(t - t_i) / H_i)
+ (s = +1.0, H = 30d):Reinforces active pathways; unused pathways (β₯ 90d idle and|W| < 0.15) decay to regrown grass, preventing weight inflation.- (s = -0.6, H = 45d):Pruned whileW β€ -0.15; recovers once|W| < 0.15and β₯ 90d idle.x (s = -2.5, H = 150d):Highest precedence (overrides cooldown~). Hard negative procedural memory blocking auto-routing unless explicitly superseded by a newer verified+trail; surfaces a human re-check notice after 150 days.~ (s = 0.0):Refractory cooldown (until:YYYY-MM-DD); automatically re-opens after expiry without erasing positive history.! (s = 0.0):Transient incident logged for audit without distorting route weights (incident-only targets stay neutral).
3. Empirical Evaluation
Experiment 1: Flat Folders vs. SOP.md Layer 1 (N = 27 Real Docs, 257.8 kB)
Two isolated same-model subagents executed 5 multi-step tasks (20 scoring points; all byte metrics in decimal kB) over equivalent business rules. The SOP.md arm read plain-text files only, invoking zero CLI scripts:
| Metric | Flat Folders (Baseline) | SOP.md Layer 1 | Relative Change |
|---|---|---|---|
| Total Blind-Test Context Read | 309.1 kB | 57.3 kB | -81.5% |
| End-to-End Task Latency (5 Tasks) | 118 s | 58 s | -50.8% |
| File Lookups / Tool Calls | 27 | 15 | -44.4% |
| Cross-Session Resume Payload | 28.9 kB | 3.2 kB | -88.8% |
| Active Cross-Doc Rule Conflicts | 5 | 0 | -100% |
| 20-Point Rule Recall Accuracy | 20 / 20 | 20 / 20 | Parity |
Experiment 2: Explicit YAML Weights vs. trails.log Stigmergy (3-Era Relay, 185 Days)
Six isolated same-model subagents executed a 3-era amnesiac relay (Day 1 -> Day 12 -> Day 185) over 6 synthetic endpoints using the prototype trail evaluator (which surfaced the -0.035 boundary that motivated separating - and x in v0.3.0):
| Cumulative Metric (3 Eras) | Arm A (Explicit YAML Weights) | Arm B (trails.log Stigmergy) | Relative Change |
|---|---|---|---|
| Total Output Tokens | 27,048 | 13,995 | -48.3% |
| File Write Operations | 18 | 5 | -72.2% |
| Static Station .sop.md Mutated | 5 | 0 | -100% |
| Total Write Payload | 14.3 kB | 3.3 kB | -76.9% |
| Tool Calls / Latency | 55 / 153 s | 43 / 121 s | -21.8% / -20.9% |
| Tool-Output Read Volume (tradeoff) | 50.6 kB | 54.8 kB | +8.3% (sandbox smell.py reread) |
Threats to Validity: Experiment 1 evaluates a single real multi-project corpus (N = 27) on one model family; Experiment 2 simulates temporal progression across 3 discrete eras rather than a 6-month wall-clock deployment, and exposed a 4.6 kB smell.py file inside the sandbox (causing the +8.3% read increase across 3 amnesiac reads, which disappears once moved into sop_cli.py). Results represent controlled structural evidence rather than universal bounds.
4. Conditional Invocation, Storage Topology & Ecosystem Compatibility
A practical question for plain-text protocols is how an agent invokes SOPs without burning tokens on trivial prompts, and where trial-and-error lessons should live:
Conditional Implicit Triggering (Not Always-On): A 5-line routing hook in AGENTS.md / CLAUDE.md / GEMINI.md checks sop-workspace.yaml and trails.log only for multi-step workflows, external publishing, releases, or interrupted batches - while explicitly skipping one-off Q&A and single-file edits (0 SOP token overhead). When a multi-step run hits β₯ 2 retries or uncovers a reusable platform quirk, the agent prompts the user before appending a trail or Field Notes entry.
Four-Tier Lifespan Storage Partition: Knowledge is routed by half-life rather than dumped into one growing folder:
- Durable structure (years) β static
.sop.mdcontracts (masters/,shared/,units/); - Verified edge-case quirks (months) β bounded Field Notes (
[verified: YYYY-MM], soft cap β€ 12); - Time-varying reliability (days-months) β append-only
trails.logwith read-time decay; - Single-batch execution state (hours-days) β isolated
runs/<run_id>/run.yaml.
Because SOP.md is plain text with a zero-dependency Python 3.8+ stdlib CLI (scripts/sop_cli.py) and a drop-in skills/sop-runner/SKILL.md, it is protocol-portable alongside MCP, Agent Skills, and AGENTS.md across Claude Code, OpenAI Codex CLI, Google Antigravity, Cursor, Windsurf, GitHub Copilot, Cline, Roo Code, OpenHands, Aider, WorkBuddy, and local LLM runtimes (Ollama, llama.cpp, vLLM).
(End-to-end execution and CI have been empirically verified in Google Antigravity and headless Python 3 GitHub Actions; other clients are protocol-compatible by design.)
Progressive adoption follows three minimal steps: Level 0 (single SOP.md + run.yaml) β Level 1 (sop-workspace.yaml + extends:) β Level 2 (trails.log).
References
- Tulving, E. (1972). Episodic and semantic memory. In Organization of Memory, Academic Press, pp. 381-403.
- Cohen, N. J., & Squire, L. R. (1980). Preserved learning and retention of pattern-analyzing skill in amnesia: Dissociation of knowing how and knowing that. Science, 210(4466), 207-210.
- Squire, L. R. (2004). Memory systems of the brain: A brief history and current perspective. Neurobiology of Learning and Memory, 82(3), 171-177.
- GrassΓ©, P.-P. (1959). La thΓ©orie de la stigmergie. Insectes Sociaux, 6(1), 41-80.
- Tero, A. et al. (2010). Rules for Biologically Inspired Adaptive Network Design. Science, 327(5964), 439-442.
- Robinson, E. J. H. et al. (2005). Insect communication: 'No entry' signal in ant foraging. Nature, 438(7067), 442.
- Bradner, S. (1997). Key words for use in RFCs to Indicate Requirement Levels. IETF RFC 2119.
Feedback, critiques on the graph model or decay parameters, and formal edge-case reports are welcome on GitHub: https://github.com/hooosberg/SOP.md
Comments
No comments yet. Start the discussion.