|
| 1 | +// SPDX-License-Identifier: PMPL-1.0-or-later |
| 2 | +// Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk> |
| 3 | += ADR-002: Methodology Layer for AGENTIC.a2ml |
| 4 | +:doctype: article |
| 5 | +:toc: left |
| 6 | +:sectnums: |
| 7 | +:icons: font |
| 8 | + |
| 9 | +== Status |
| 10 | + |
| 11 | +Proposed (2026-03-23) |
| 12 | + |
| 13 | +== Context |
| 14 | + |
| 15 | +AGENTIC.a2ml currently defines **operational gating** — whether a permitted |
| 16 | +action may proceed now. It covers entropy budgets, risk thresholds, |
| 17 | +confirmation requirements, and decision recording. |
| 18 | + |
| 19 | +What it does NOT cover is **how agents should approach work** — methodology |
| 20 | +selection, constraint identification, coverage tracking, and divergent |
| 21 | +invariant preservation. This gap has been measured: |
| 22 | + |
| 23 | +* v2 meandering on ambientops used 296K tokens across 5 bots, found the |
| 24 | + critical constraint accidentally in wave 2, and visited only 21% of components |
| 25 | +* v3 constraint-first on the same target used 89K tokens across 2 bots, |
| 26 | + identified the constraint in Phase 0, and achieved 100% component visibility |
| 27 | +* A 70% token reduction with better outcomes |
| 28 | + |
| 29 | +The methodology layer has been field-tested across 6+ sessions on 3 project |
| 30 | +types (infrastructure, platform, formal verification) with consistent results. |
| 31 | + |
| 32 | +=== Evidence: Cross-Project Validation |
| 33 | + |
| 34 | +[options="header"] |
| 35 | +|=== |
| 36 | +| Project | Type | Mode | Constraint Found | v3 Score |
| 37 | + |
| 38 | +| ambientops | Infrastructure (Rust/Elixir/V) | Convergent | Evidence Envelope flow broken | 8/10 |
| 39 | +| burble | Platform (Elixir voice) | Convergent | Missing deps = silent fallbacks | 7/10 |
| 40 | +| proven | Research (Idris2 proofs) | Divergent | Build pipeline never verified | 8/10 |
| 41 | +|=== |
| 42 | + |
| 43 | +== Decision |
| 44 | + |
| 45 | +Extend AGENTIC.a2ml with a `[methodology]` section that declares per-repo |
| 46 | +methodology preferences, constraints, invariants, and session state. Add |
| 47 | +`agent_instructions/` to `.machine_readable/` as the directory for |
| 48 | +methodology-aware agent configuration. |
| 49 | + |
| 50 | +== Specification |
| 51 | + |
| 52 | +=== New AGENTIC.a2ml Section: `[methodology]` |
| 53 | + |
| 54 | +[source,toml] |
| 55 | +---- |
| 56 | +[methodology] |
| 57 | +# Default mode for this project (convergent | divergent | hybrid) |
| 58 | +# Agents infer if not set, but explicit is better |
| 59 | +default-mode = "divergent" |
| 60 | +
|
| 61 | +# What makes this project unique (divergent mode guidance) |
| 62 | +# Agents should deepen this, not broaden it |
| 63 | +unique-strength = "Formal verification with dependent types — Idris2 proofs" |
| 64 | +
|
| 65 | +# Invariants that divergent mode must NOT violate |
| 66 | +# These are the riverbanks — diverge within them, not across |
| 67 | +divergent-invariants = [ |
| 68 | + "Idris2 only for formal verification — no Lean4, Coq, Agda", |
| 69 | + "believe_me count must remain zero", |
| 70 | + "FFI architecture: Idris2 → RefC → Zig → C ABI (no shortcuts)", |
| 71 | +] |
| 72 | +
|
| 73 | +# Constraint identification hints |
| 74 | +# Help Phase 0 find the critical chain faster |
| 75 | +known-constraints = [ |
| 76 | + "End-to-end build (idris2 --build) has never been verified", |
| 77 | + "libproven.so does not exist yet — all bindings call stubs", |
| 78 | +] |
| 79 | +
|
| 80 | +# Coverage tracking from last session |
| 81 | +[methodology.coverage] |
| 82 | +last-session = "2026-03-23" |
| 83 | +visited = ["src/", "ffi/zig/", "bindings/rust/", "bindings/gleam/"] |
| 84 | +skipped-with-musts = ["bindings/python/", "apps/"] |
| 85 | +debt-file = "MEANDER-DEBT.md" |
| 86 | +---- |
| 87 | + |
| 88 | +=== New Directory: `.machine_readable/agent_instructions/` |
| 89 | + |
| 90 | +[source] |
| 91 | +---- |
| 92 | +.machine_readable/ |
| 93 | +├── 6a2/ # Existing: 6 A2ML checkpoint files |
| 94 | +├── bot_directives/ # Existing: gitbot-fleet rules |
| 95 | +├── agent_instructions/ # NEW: methodology-aware config |
| 96 | +│ ├── methodology.a2ml # Mode, invariants, constraints |
| 97 | +│ ├── coverage.a2ml # Session coverage tracking |
| 98 | +│ └── debt.a2ml # Meander debt from last session |
| 99 | +---- |
| 100 | + |
| 101 | +==== methodology.a2ml |
| 102 | + |
| 103 | +Declares the project's methodology preferences. Read by any AI agent |
| 104 | +(Claude, Gemini, Copilot, etc.) at session start. |
| 105 | + |
| 106 | +[source,toml] |
| 107 | +---- |
| 108 | +[methodology] |
| 109 | +version = "1.0.0" |
| 110 | +default-mode = "divergent" # convergent | divergent | hybrid |
| 111 | +ring-ceiling = 2 # Hard ceiling for ring expansion (default: 2) |
| 112 | +wave-cap = 2 # Max waves before requiring user "keep going" (default: 2) |
| 113 | +spike-required = true # Every session must ship code (default: true) |
| 114 | +
|
| 115 | +[methodology.priority-weights] |
| 116 | +must = 3 |
| 117 | +should = 2 |
| 118 | +could = 1 |
| 119 | +
|
| 120 | +[methodology.unique-strength] |
| 121 | +description = "Formal verification with dependent types" |
| 122 | +deepen-not-broaden = true |
| 123 | +language-invariant = "idris2" # Only this language for the core strength |
| 124 | +
|
| 125 | +[methodology.divergent-invariants] |
| 126 | +# These constraints survive divergent mode |
| 127 | +rules = [ |
| 128 | + "No additional proof languages (Lean4, Coq, Agda)", |
| 129 | + "believe_me count must remain zero", |
| 130 | + "assert_total count must remain zero", |
| 131 | + "FFI architecture: Idris2 → RefC → Zig → C ABI", |
| 132 | +] |
| 133 | +
|
| 134 | +[methodology.convergent-budget] |
| 135 | +structural = 70 # % of budget for structural work |
| 136 | +corrective = 20 # % for bug fixes |
| 137 | +perfective = 10 # % for docs, formatting, style |
| 138 | +---- |
| 139 | + |
| 140 | +==== coverage.a2ml |
| 141 | + |
| 142 | +Persists coverage state across sessions. Updated at session end. |
| 143 | + |
| 144 | +[source,toml] |
| 145 | +---- |
| 146 | +[coverage] |
| 147 | +version = "1.0.0" |
| 148 | +last-session = "2026-03-23" |
| 149 | +total-components = 29 |
| 150 | +visited-components = 6 |
| 151 | +coverage-percent = 21 |
| 152 | +
|
| 153 | +[coverage.visited] |
| 154 | +# Component → session date + ring reached |
| 155 | +"emergency-room" = { date = "2026-03-23", ring = 2 } |
| 156 | +"hardware-crash-team" = { date = "2026-03-23", ring = 2 } |
| 157 | +"observatory" = { date = "2026-03-23", ring = 2 } |
| 158 | +
|
| 159 | +[coverage.skipped-musts] |
| 160 | +# Components with known MUSTs that were not visited |
| 161 | +"session-sentinel" = "P0: 56 SIGABRTs, D-Bus race" |
| 162 | +"nano-aider" = "P1: wrong author email" |
| 163 | +"panoptes" = "P1: MIT license, should be PMPL" |
| 164 | +---- |
| 165 | + |
| 166 | +==== debt.a2ml |
| 167 | + |
| 168 | +Meander debt list persisted between sessions. |
| 169 | + |
| 170 | +[source,toml] |
| 171 | +---- |
| 172 | +[debt] |
| 173 | +version = "1.0.0" |
| 174 | +last-updated = "2026-03-23" |
| 175 | +
|
| 176 | +[[debt.should]] |
| 177 | +component = "system-tools/monitoring/observatory" |
| 178 | +issue = "Stale duplicate of root observatory/" |
| 179 | +effort = "easy" |
| 180 | +impact = "medium" |
| 181 | +
|
| 182 | +[[debt.could]] |
| 183 | +component = "cicada" |
| 184 | +issue = "RSR_OUTLINE.adoc references banned AGPL-3.0" |
| 185 | +effort = "easy" |
| 186 | +impact = "low" |
| 187 | +---- |
| 188 | + |
| 189 | +=== Relationship to Existing AGENTIC.a2ml Sections |
| 190 | + |
| 191 | +[options="header"] |
| 192 | +|=== |
| 193 | +| Existing Section | New Section | Relationship |
| 194 | + |
| 195 | +| `[agent-permissions]` |
| 196 | +| `[methodology]` |
| 197 | +| Permissions say WHAT agents can do. Methodology says HOW. |
| 198 | + |
| 199 | +| `[agent-constraints]` |
| 200 | +| `[methodology.divergent-invariants]` |
| 201 | +| Constraints are universal (never do X). Divergent invariants are |
| 202 | +mode-specific (in divergent mode, don't broaden). |
| 203 | + |
| 204 | +| `[entropy-budget]` |
| 205 | +| `[methodology.convergent-budget]` |
| 206 | +| Entropy budget tracks risk accumulation. Convergent budget tracks |
| 207 | +effort allocation (70/20/10 structural/corrective/perfective). |
| 208 | + |
| 209 | +| `[risk-thresholds]` |
| 210 | +| `[methodology.priority-weights]` |
| 211 | +| Risk classifies danger. Priority classifies importance (MUST 3x). |
| 212 | +|=== |
| 213 | + |
| 214 | +=== How This Informs the Agentic Server |
| 215 | + |
| 216 | +The agentic server is the runtime that reads and enforces these files. |
| 217 | +Its architecture maps to the methodology framework: |
| 218 | + |
| 219 | +[source] |
| 220 | +---- |
| 221 | +Agentic Server Architecture: |
| 222 | +
|
| 223 | + ┌─────────────────────────────────────────────────┐ |
| 224 | + │ Agent Request ("work on this repo") │ |
| 225 | + └──────────────────┬──────────────────────────────┘ |
| 226 | + │ |
| 227 | + ┌──────────────────▼──────────────────────────────┐ |
| 228 | + │ 1. READ: agent_instructions/methodology.a2ml │ |
| 229 | + │ → mode, invariants, ring ceiling, weights │ |
| 230 | + ├─────────────────────────────────────────────────┤ |
| 231 | + │ 2. READ: agent_instructions/coverage.a2ml │ |
| 232 | + │ → what was visited, what has MUSTs │ |
| 233 | + ├─────────────────────────────────────────────────┤ |
| 234 | + │ 3. READ: agent_instructions/debt.a2ml │ |
| 235 | + │ → carried debt from last session │ |
| 236 | + ├─────────────────────────────────────────────────┤ |
| 237 | + │ 4. READ: 6a2/STATE.a2ml │ |
| 238 | + │ → P1 items, current phase, blockers │ |
| 239 | + │ ⚠ VALIDATE: not a template placeholder │ |
| 240 | + ├─────────────────────────────────────────────────┤ |
| 241 | + │ 5. IDENTIFY CONSTRAINT │ |
| 242 | + │ → Build dependency graph from state + debt │ |
| 243 | + │ → Find critical chain │ |
| 244 | + │ → Locate first unresolved link │ |
| 245 | + ├─────────────────────────────────────────────────┤ |
| 246 | + │ 6. SELECT AGENT ROLE(S) │ |
| 247 | + │ ┌──────────────┐ │ |
| 248 | + │ │ convergent? │→ Converge agent │ |
| 249 | + │ │ divergent? │→ Diverge agent │ |
| 250 | + │ │ hybrid? │→ TSDM navigator + worker │ |
| 251 | + │ │ complex? │→ 3-agent (ADR-001) │ |
| 252 | + │ └──────────────┘ │ |
| 253 | + ├─────────────────────────────────────────────────┤ |
| 254 | + │ 7. ENFORCE AT RUNTIME │ |
| 255 | + │ → Check divergent invariants before edits │ |
| 256 | + │ → Check convergent budget (70/20/10) │ |
| 257 | + │ → Check ring ceiling before expansion │ |
| 258 | + │ → Validate bot claims before commit │ |
| 259 | + ├─────────────────────────────────────────────────┤ |
| 260 | + │ 8. PERSIST │ |
| 261 | + │ → Update coverage.a2ml │ |
| 262 | + │ → Update debt.a2ml │ |
| 263 | + │ → Feed outcomes to Hypatia learning loop │ |
| 264 | + └─────────────────────────────────────────────────┘ |
| 265 | +---- |
| 266 | + |
| 267 | +=== Contractile Tightening |
| 268 | + |
| 269 | +The contractile system (Mustfile/Trustfile/Dustfile/Intentfile/K9) |
| 270 | +should enforce methodology constraints: |
| 271 | + |
| 272 | +[source,toml] |
| 273 | +---- |
| 274 | +# In Mustfile: |
| 275 | +[methodology] |
| 276 | +mode = "divergent" |
| 277 | +language-invariant = "idris2" |
| 278 | +believe-me-ceiling = 0 |
| 279 | +assert-total-ceiling = 0 |
| 280 | +
|
| 281 | +# K9 validator: |
| 282 | +# k9/methodology-guard.k9.ncl |
| 283 | +# Checks that no commit introduces: |
| 284 | +# - Files in languages violating the divergent invariant |
| 285 | +# - believe_me or assert_total above the ceiling |
| 286 | +# - Changes to agent_instructions/ without user approval |
| 287 | +---- |
| 288 | + |
| 289 | +This turns methodology constraints from "things Claude reads in a prompt" |
| 290 | +into "things any CI system can enforce." |
| 291 | + |
| 292 | +=== State File Validation (from field testing) |
| 293 | + |
| 294 | +Phase 0 reads STATE.a2ml first. Field testing found two failure modes: |
| 295 | + |
| 296 | +1. **Template placeholder** (burble): STATE.a2ml was never customised from |
| 297 | + rsr-template-repo. Project name = "rsr-template-repo", completion = 95%. |
| 298 | + Agent would start with completely wrong data. |
| 299 | + |
| 300 | +2. **Empty after migration** (proven): STATE.a2ml was migrated from .scm |
| 301 | + but the content didn't carry over. Completion = 0%, no tasks. |
| 302 | + |
| 303 | +**Required validation before trusting STATE.a2ml:** |
| 304 | + |
| 305 | +[source] |
| 306 | +---- |
| 307 | +1. Check for {{PLACEHOLDER}} or {{PROJECT}} tokens → template, not real |
| 308 | +2. Check project name matches repo name → not template default |
| 309 | +3. Check last-updated is within 90 days → not stale |
| 310 | +4. If validation fails → fall back to TODO.md, ROADMAP.adoc, README.adoc |
| 311 | +5. Flag the broken STATE.a2ml as a P1 MUST in the audit |
| 312 | +---- |
| 313 | + |
| 314 | +== Consequences |
| 315 | + |
| 316 | +=== Positive |
| 317 | + |
| 318 | +* Methodology becomes a protocol, not a prompt — any agent server can implement it |
| 319 | +* Divergent invariants are machine-enforceable, not trust-based |
| 320 | +* Coverage tracking persists across sessions — no more starting blind |
| 321 | +* Meander debt survives session boundaries — nothing discovered is lost |
| 322 | +* Contractile K9 validators can block invariant violations in CI |
| 323 | +* Hypatia learning loop gets structured methodology outcome data |
| 324 | + |
| 325 | +=== Negative |
| 326 | + |
| 327 | +* More files in `.machine_readable/` (3 new files per repo) |
| 328 | +* Initial setup cost: every repo needs methodology.a2ml configured |
| 329 | +* Risk of over-specification — some projects don't need methodology config |
| 330 | +* The agentic server is a new runtime to build and maintain |
| 331 | + |
| 332 | +=== Mitigations |
| 333 | + |
| 334 | +* `rsr-template-repo` provides sensible defaults (hybrid mode, standard weights) |
| 335 | +* The `just init` recipe can generate methodology.a2ml from project type |
| 336 | +* Repos without methodology.a2ml fall back to v3 defaults (hybrid, 3x/2x/1x, Ring 2 ceiling) |
| 337 | +* The agentic server can start as a BoJ cartridge before becoming standalone |
| 338 | + |
| 339 | +== References |
| 340 | + |
| 341 | +* ADR-001: Three-Agent Architecture (Diverge/Converge/TSDM) |
| 342 | +* Productive Meandering v3-v5 prompt (methodologies repo) |
| 343 | +* AGENTIC-FORMAT-SPEC.adoc (this repo) |
| 344 | +* Field reports: ambientops, burble, proven evaluations (methodologies repo) |
| 345 | +* Hypatia learning loop: `hypatia/lib/learning_scheduler.ex` |
0 commit comments