SOP.md: Decoupling Static DAG Workflow Contracts from Stigmergic Trail Decay for AI Agents
Abstract
Modern AI agents execute isolated tool calls well, yet lose track of multi-session workflows, forget transient environment constraints (such as rate limits, maintenance windows, or deprecated paths), and repeatedly collide with identical operational traps. Static instruction files (AGENTS.md) cannot track mutable batch state, while atomic tool skills (SKILL.md) do not encode cross-session routing or negative procedural memory. SOP.md v0.3 introduces a domain-agnostic, plain-text architectural layer that strictly separates immutable Layered Composition DAG workflow contracts (*.sop.md), resumable batch checkpoints (run.yaml), and append-only stigmergic routing trails (trails.log) evaluated via read-time exponential half-life decay.
1. Problem & Architectural Split
When transient operational logs, time-varying constraints, and step-by-step instructions are appended into a single static Markdown file, context windows bloat, Git diffs turn noisy, and stale incidents poison future runs forever. SOP.md completes the three-layer plain-text stack without replacing existing conventions:
| Layer / Artifact | Primary Responsibility | State & Memory Scope |
|---|---|---|
AGENTS.md / CLAUDE.md | Repository rules, coding style, architectural boundaries | Static · Always loaded |
SKILL.md / MCP Tools | Atomic capabilities, CLI/API wrappers, and execution primitives (shell, OS, browser) | Stateless · Invoked per step |
SOP.md (v0.3) | Multi-step DAG choreography, human sign-off gates, resumable runs, and decaying routing memory | Stateful · Sparse-activated across sessions |
2. Layered Composition DAG & Resumable Checkpoints
Projects declare a thin sop-workspace.yaml that can inherit shared policies via extends: (e.g., cross-project compliance guardrails, release policies, or shared environment
constraints) while composing local SOP nodes into an acyclic graph. Agents read only the sparse subset of
nodes required for the active stage—never the entire repository.
# sop-workspace.yaml
workspace_version: "0.3"
name: "cross-domain-memory-network"
# Optional lazy inheritance from an upstream hub:
extends:
- "../_shared-hub/sop-workspace.yaml"
env:
hash_algorithm: "sha256"
mounts:
release: "../release-governance"
finance: "../financial-reconciliation"
registry:
shared/integrity-audit: "shared/integrity-audit.sop.md"
shared/human-signoff: "shared/human-signoff.sop.md"
masters:
- "masters/software-release.sop.md"
- "masters/financial-close.sop.md"
trails_file: "trails.log"
Mutable execution state lives strictly in runs/<batch>/run.yaml (recording completed_units, current stage, receipts, and human_signoff gates). Finished runs
move cleanly into runs/archive/, which the activation scanner skips automatically to preserve O(1) auto-resume latency over years of operation.
3. Stigmergic Trail Routing & Read-Time Exponential Decay
Inspired by biological stigmergy (ant pheromone trails and slime-mold network pruning), agents never mutate
static .sop.md files just to record transient successes, degradation, cooldowns, or hard
inhibitions. Instead, each execution appends a single plain-text line to trails.log. Effective
routing weight is computed lazily at read time:
+, 45d for -, 150d for x with top precedence and
mandatory retention across compactions).
| Signal | Protocol Semantics (Domain-Agnostic) | Routing Behavior | Illustrative Cross-Domain Examples |
|---|---|---|---|
+ | Positive reinforcement (verified healthy path) |
Prioritized during routing (s = +1.0, H = 30d); fades to neutral if unused
>= 90d
| Stable CI runner, healthy API mirror, verified channel |
- | Soft friction / mild degradation |
Temporarily deprioritized while W <= -0.15 (s = -0.6, H = 45d); recovers naturally once faded
| High-latency RPC node, flaky test mirror, low-yield source |
~ |
Refractory cooldown (until:YYYY-MM-DD, optional req:<cond>)
|
Skipped until date T without erasing prior + depth; after T,
surfaces [PRECONDITION GATE] if req: tokens remain unverified
| API HTTP 429 rate limit, scheduled maintenance, platform frequency cap |
x | Hard inhibition (negative procedural memory) |
Highest precedence (s = -2.5, H = 150d): never auto-routed; preserved
across compactions; prompts human re-check after 150d
| Deprecated DB/endpoint, compliance/security red line, read-only locked target |
! | Transient incident (audit-only marker) |
Zero weight penalty (s = 0.0): logged for traceability without falsely inhibiting
healthy paths
| Single HTTP 502/network blip, temporary upstream schema/UI shift |
Domain-Agnostic Note: Target identifiers in trails.log are opaque
abstractions. Operational examples such as API rate limits, CI degradation, deprecated databases, or web
platform restrictions are purely illustrative—the underlying state machine and decay equations have zero
coupling to any specific domain or execution tool.
# Compaction Policy: soft_cap=150 | archive_to=archive/trails-YYYY.log
# Rules: drop expired (~) & >30d (!); fold repetitive (+)/(-); ALWAYS preserve active (x).
2026-12-05 | + | ci-eu-runner | Clean build & canary pass on release pipeline
2026-12-05 | - | llm-fallback-b | Elevated p99 latency; prefer primary cluster
2026-12-05 | ~ | api-billing-v2 | until:2026-12-10 req:quota>=80% Rate-limit cooldown
2026-12-01 | x | db-legacy-replica | Hard inhibit: deprecated & compliance-locked
2026-12-05 | ! | web-partner-sync | Transient HTTP 502 blip (audit log, zero penalty) 4. Conditional Invocation & 4-Tier Storage Lifecycle
A practical procedural memory layer must cost zero tokens when it is not needed. SOP.md relies on conditional auto-discovery: simple Q&A, explanations, and single-file edits bypass SOP discovery completely. Only multi-step workflows, external-system integrations (APIs, CI/CD, databases, or web platforms), release cycles, or interrupted batches trigger workspace activation and trail smelling—shared seamlessly across OpenCode, Claude Code, Antigravity, OpenAI Codex, Cursor, Zed, and Gemini CLI via standard instruction hooks.
SOP Nodes & Workspace Graph
Versioned in Git (*.sop.md, sop-workspace.yaml). Updated only when a verified,
reusable lesson emerges—never polluted with single-run timestamps.
Active Batch Checkpoints (run.yaml)
Tracks active multi-session progress, completed items, and human sign-off gates. Enables instant relay handoff between independent agent sessions.
Append-Only Trails (trails.log)
Atomically append 1 canonical line per cross-project routing signal via sop-md trail
(supporting until: cooldowns, req: precondition gates, and [TRAIL-LINT] checks). Soft cap at 150 lines folds old +/-
entries while keeping active x vetoes intact.
Isolated Cold Storage (archive/)
Completed runs and annual trail logs rest in runs/archive/ and archive/trails-YYYY.log—100% auditable on disk while excluded from hot activation scans.
5. Quick Install, Zero-Dependency CLI & GitHub Action
Install sop-runner across 40+ SKILL.md-compatible agents (OpenCode, Claude Code,
Codex, Gemini CLI, Cursor, Zed, Kilo Code, Qwen Code, CodeBuddy/WorkBuddy, Trae, Qoder) with one command,
run the zero-dependency Python 3 stdlib CLI via uvx, or drop uses: hooosberg/[email protected] directly into GitHub Actions CI.
# 1. One-line Agent Skill install (OpenCode, Claude Code, Codex, Gemini CLI, Cursor, Zed, CodeBuddy, etc.)
npx skills add hooosberg/SOP.md --skill sop-runner
# 2. Run the zero-dependency CLI directly via uvx (no repo clone required)
uvx --from git+https://github.com/hooosberg/SOP.md sop-md validate-graph sop-workspace.yaml
uvx --from git+https://github.com/hooosberg/SOP.md sop-md smell sop-workspace.yaml
uvx --from git+https://github.com/hooosberg/SOP.md sop-md trail sop-workspace.yaml "~" registry-x "Cooldown" --until 2026-06-01 --req "age>=30d"
# 3. Or add a zero-dependency GitHub Action check to any PR workflow:
# uses: hooosberg/[email protected]
# with:
# path: "."
# workspace: "sop-workspace.yaml"
# sanitize: "true"
# 4. Zero-package-manager option (pure Python 3.8+ stdlib)
git clone https://github.com/hooosberg/SOP.md.git && cd SOP.md
python3 scripts/sop_cli.py activate examples/multi-project-network/sop-workspace.yaml --query "software release"
python3 scripts/sop_cli.py sanitize . 6. Execution-Agnostic Design & Ecosystem Synergy
SOP.md is strictly execution-layer agnostic: the same DAG contracts, checkpoints, and trail routing work identically across shell/CLI pipelines, CI/CD runners, database/API MCP servers, native desktop drivers, or browser agents. Inside the Hooosberg open-source stack, pairing SOP.md with AgentLimb provides a concrete, 100% local reference loop for browser-based workflows:
SOP.md (v0.3.1)
Defines multi-step DAG contracts, tracks cooldown windows (~) and hard inhibitions (
x) across sessions for any target, and enforces human_signoff gates before
irreversible transitions.
AgentLimb (v0.9.0)
MIT open-source Chrome extension (5.0★ Chrome Web Store) + local 127.0.0.1 MCP bridge—one concrete execution layer that lets any AI agent run web-facing SOP units inside your real signed-in Chrome profiles without stealing focus.
Explore 18+ local-first macOS/iOS apps, open-source AI agent tools, and practical engineering build notes on the main site.
7. Citation
If you reference SOP.md in engineering RFCs, benchmarks, or research papers, please cite the Zenodo archival release:
@software{hu_2026_sop_md,
author = {Hu, Yuanbo},
title = {{SOP.md: Open Specification for Stateful Information Flows,
Layered Composition DAGs, and Stigmergic Procedural Memory}},
version = {0.3.0},
year = {2026},
publisher = {Zenodo},
doi = {10.5281/zenodo.24857582},
url = {https://hooosberg.com/sop/}
}