AmpersandBoxDesign AmpersandBoxDesign/prompts/DUAL_LOOP_MACHINES.md
Graphonomous exposes 29 MCP tools. PRISM specifies 47. When both run in the same session (the benchmarking use case), the client sees 76 tools. Research shows:

Dual- and Triple-Loop Machine Architecture

PULSE update (OS-010, 2026-04): With the introduction of OS-010 PULSE, the loop-interlock pattern documented here is now formalized as a manifest standard. Graphonomous, PRISM, AgenTroMatic, and every other portfolio loop declare their phases in <loop>.pulse.json files (see /PULSE/manifests/), validated against pulse-loop-manifest.v0.1.json. The "dual loop" is a special case of arbitrarily nestable PULSE loops — the same machine grouping works at any depth, and PRISM's interact phase reads the inner system's PULSE manifest to discover the retrieve boundary at runtime rather than hard-coding the integration. See "Triple loop and beyond" below.

The Problem

Graphonomous exposes 29 MCP tools. PRISM specifies 47. When both run in the same session (the benchmarking use case), the client sees 76 tools. Research shows:

  • Tool selection accuracy degrades past ~30 tools (Opus 4: 49% correct at that scale)

  • Each tool definition consumes 500–2,000 tokens of context before conversation starts

  • 76 tools can burn 40–80K tokens just on schema overhead

The Insight: Machine Around the Loop, Not the Category

Instead of grouping tools by what they touch (graph write, graph read, belief, etc.), group them by which phase of the closed loop the agent is in when it calls them.

Both Graphonomous and PRISM are closed-loop systems. Their loops are structurally parallel and interlock when PRISM evaluates Graphonomous:

Graphonomous (memory loop)          PRISM (evaluation loop)
──────────────────────────          ───────────────────────
retrieve  "What do I know?"         compose    "What should I test?"
route     "What should I do?"       interact   "Run the test"
act       "Do it"                   observe    "Judge the result"
learn     "Did it work?"            reflect    "What should change?"
consolidate "Clean up"              diagnose   "What's actionable?"

Graphonomous: 29 tools → 5 machines

retrieve — "What do I know?"

The agent calls this when it needs context before reasoning or acting.

ActionReplacesDescription
contextretrieve_contextκ-aware ranked retrieval with topology annotations
episodicretrieve_episodicTime-range filtered episodic nodes
proceduralretrieve_proceduralSemantic search scoped to procedural nodes
coveragecoverage_queryStandalone epistemic coverage (act/learn/escalate)
trace_evidencetrace_evidence_pathWeighted Dijkstra evidence path between nodes
frontierepistemic_frontierWilson interval uncertainty analysis

route — "What should I do?"

The agent calls this to decide whether to act, learn, deliberate, or escalate.

ActionReplacesDescription
topologytopology_analyzeSCC/κ analysis with routing recommendation
deliberatedeliberateκ-driven deliberation over cyclic regions
attention_surveyattention_surveyPriority survey across active goals
attention_cycleattention_run_cycleFull triage → dispatch attention cycle
review_goalreview_goalCoverage-driven act/learn/escalate gate

act — "Do it"

The agent calls this to mutate the knowledge graph.

ActionReplacesDescription
store_nodestore_nodeStore a knowledge node
store_edgestore_edgeStore a relationship edge
delete_nodedelete_nodeRemove a node
manage_edgemanage_edgeCRUD on edges
manage_goalmanage_goalGoal CRUD + lifecycle transitions
belief_revisebelief_reviseExpand/contract/replace beliefs
forget_nodeforget_nodeSoft-hide from retrieval
forget_policyforget_by_policyBudget-aware priority pruning
gdpr_erasegdpr_eraseHard delete with audit trail

learn — "Did it work?"

The agent calls this after acting, to close the feedback loop.

ActionReplacesDescription
from_outcomelearn_from_outcomeCausal confidence updates from action results
from_feedbacklearn_from_feedbackPositive/negative/correction feedback
detect_noveltylearn_detect_noveltySimilarity-based novelty scoring
from_interactionlearn_from_interactionFull pipeline: novelty → store → extract → link
contradictionsbelief_contradictionsDetect belief conflicts in the graph

consolidate — "Clean up"

The agent calls this to maintain graph quality, typically at session boundaries.

ActionReplacesDescription
runrun_consolidationTrigger a consolidation cycle
statsgraph_statsAggregate counts, distributions, confidence
queryquery_graphOperation-based graph inspection
traversegraph_traverseBFS walk with depth/relationship filters

Total: 5 tools exposed to the model.

PRISM: 47 tools → 5 machines + 1 admin

compose — "What should I test?"

ActionReplacesDescription
scenarioscompose_scenariosBuild scenarios from repo anchors + CL specs
validatevalidate_scenariosCL coverage validation on draft scenarios
listlist_scenariosList with filters (kind, domain, dimension, difficulty)
getget_scenarioFull scenario details + IRT params
retireretire_scenarioRetire a scenario with reason
importimport_externalImport from BEAM/LongMemEval with CL tagging
byor_registerbyor_register_repoRegister a personal repo
byor_discoverbyor_discover_eventsAuto-discover CL events in commit history
byor_generatebyor_generate_scenariosGenerate scenarios from discovered events

interact — "Run the test"

ActionReplacesDescription
runrun_interactionOne scenario × one system
run_sequencerun_sequenceScenario sequence, no memory reset
run_matrixrun_matrixN systems × M models × all scenarios
statusget_run_statusCheck in-progress run
transcriptget_transcriptFull interaction transcript
cancelcancel_runCancel in-progress run
byor_evaluatebyor_evaluateFull BYOR evaluation
byor_comparebyor_compareHead-to-head on your repo

observe — "Judge the result"

ActionReplacesDescription
judge_transcriptjudge_transcriptL2: all 9 dimensions for one transcript
judge_dimensionjudge_dimensionL2: one specific dimension (debug)
meta_judgemeta_judgeL3: meta-judge one L2 judgment
meta_judge_batchmeta_judge_batchL3: meta-judge all L2 judgments for a run
overrideoverride_judgmentHuman override with audit trail

reflect — "What should change?"

ActionReplacesDescription
analyze_gapsanalyze_gapsUnder-tested dims, saturated scenarios, domain gaps
evolveevolve_scenariosRetire, extend, fork, promote
advance_cycleadvance_cycleRun all 4 phases (Compose → Interact → Observe → Reflect)
calibrate_irtcalibrate_irtRecalibrate IRT difficulty/discrimination
cycle_historyget_cycle_historyFull history of cycles and improvements
byor_recommendbyor_recommendSystem recommendation for your use case
byor_infer_profilebyor_infer_profileInfer task profile from repo patterns

diagnose — "What's actionable?"

ActionReplacesDescription
reportget_diagnostic_reportFull diagnostic (failures, fixes, regressions)
failure_patternsget_failure_patternsClustered failure analysis per dimension
retestrun_retestRe-run specific scenarios after a fix
verifyget_verification_reportBefore/after comparison from retest
regressionsget_regression_alertsCross-cycle regression analysis
suggest_fixessuggest_fixesAI-generated fix suggestions
leaderboardget_leaderboardRankings with domain filter
leaderboard_historyget_leaderboard_historyScores over time
compare_systemscompare_systemsHead-to-head across all 9 dimensions
dimension_leadersget_dimension_leadersTop system per CL dimension
fit_recommendationget_fit_recommendationSystem rec for a task profile
compare_fitcompare_fitCompare two systems for a specific task
task_profileslist_task_profilesList pre-built and custom profiles

config — Admin/setup (outside the loop)

ActionReplacesDescription
set_weightsset_cl_weightsUpdate 9-dimension weight vector
register_systemregister_systemRegister memory system + MCP endpoint
list_systemslist_systemsList registered systems
get_configget_configCurrent full configuration
create_profilecreate_task_profileDefine custom task profile

Total: 6 tools exposed to the model (5 loop + 1 admin).

Combined Impact

ScenarioBeforeAfter
Graphonomous alone29 tools5 tools
PRISM alone47 tools6 tools
Both in same session76 tools11 tools

Context savings: ~80% reduction in tool schema tokens. Selection accuracy: from ~49% (76 tools) to ~95% (11 tools).

The Interlocking Loops

When PRISM benchmarks Graphonomous, the loops nest:

PRISM compose ──→ PRISM interact ──→ PRISM observe ──→ PRISM reflect ──→ PRISM diagnose
                       │
                       ▼
              ┌─── Graphonomous ───┐
              │  retrieve → route  │
              │  → act → learn     │
              │  → consolidate     │
              └────────────────────┘

PRISM's interact phase drives the system-under-test through its own closed loop. PRISM's observe phase judges how well that inner loop performed. PRISM's reflect phase evolves scenarios based on where the inner loop failed.

This is the knockout feature: two self-improving loops, one inside the other. The outer loop (PRISM) improves the benchmark. The inner loop (Graphonomous) improves the memory. Each makes the other sharper.

Implementation Pattern

Both systems use the same Elixir pattern: a single MCP component module per machine with an action field that dispatches internally.

defmodule Graphonomous.MCP.Retrieve do
  use Anubis.Server.Component, type: :tool

  schema do
    field(:action, :string,
      required: true,
      description: "context | episodic | procedural | coverage | trace_evidence | frontier"
    )
    # Union of all action-specific fields, each documented with which action uses it
    field(:query, :string, description: "Search query (context, episodic, procedural, frontier)")
    field(:limit, :number, description: "Max results (context, episodic, procedural)")
    # ... etc
  end

  def execute(%{action: "context"} = params, frame), do: do_context(params, frame)
  def execute(%{action: "episodic"} = params, frame), do: do_episodic(params, frame)
  # ...
end

Each machine module delegates to the existing Graphonomous.* functions — the internal API doesn't change, only the MCP surface.

Migration Strategy

  1. Phase 1: Add machine modules alongside existing tools. Both surfaces work.

Register machines in server.ex with a v2_ prefix for testing.

  1. Phase 2: Update skill prompts to reference machine verbs instead of

individual tools. Run PRISM benchmarks comparing v1 vs v2 tool selection accuracy.

  1. Phase 3: Deprecate individual tools. Remove from server.ex, keep modules

for reference.

  1. Phase 4: Remove deprecated modules. Clean cut.

Backward Compatibility

Existing clients calling retrieve_context directly will break at Phase 3. Mitigation: the adapter layer in Prism.MCP.Adapter can translate legacy tool names to machine + action pairs during the transition.

Triple loop and beyond — PULSE generalization

The Graphonomous ↔ PRISM dual loop is the canonical example, but the [&] ecosystem actually runs at least three nested loops today:

PRISM (outer)        compose → interact → observe → reflect → diagnose
  │
  └─ Graphonomous    retrieve → route → act → learn → consolidate
       │
       └─ Deliberation    survey → triage → dispatch → act → learn

OS-010 PULSE encodes this nesting in each manifest's nesting block:

  • prism.benchmark declares inner_loops: [graphonomous.continual_learning]

  • graphonomous.continual_learning declares inner_loops: [graphonomous.deliberate] and parent_loop: prism.benchmark

  • graphonomous.deliberate declares parent_loop: graphonomous.continual_learning

PULSE supports unbounded nesting depth. OS-008 (Agent Harness, draft) is expected to add a fourth outer layer that wraps PRISM itself — when it ships, the only change required is a new manifest with inner_loops: [prism.benchmark]. No code changes to existing machines.

Why this matters for the machine architecture

The 5/6/11-tool count documented above is a floor, not a ceiling. Adding a third loop adds at most 5 more machines (one per phase kind), and because PULSE manifests declare the inner-loop boundary explicitly, the outer machines do not need to learn about inner machines individually. PRISM's interact machine, for example, drives any PULSE-conforming inner loop through its declared retrieve phase — it does not need a Graphonomous-specific code path.

Layers in sessionTool count (machines)Tool count (legacy v1)
Graphonomous alone529
Graphonomous + PRISM1176
Graphonomous + PRISM + OS-008 Harness~16~100+
Graphonomous + PRISM + OS-008 + AgenTroMatic deliberation~21~130+

The savings compound with depth, and PULSE's manifest standard is what makes the composition algebraic instead of ad-hoc.

Three-protocol stack at runtime

┌──────────────────────────────────────────────────────────┐
│  PRISM    — measures loops over time      (diagnostic)   │ OS-009
├──────────────────────────────────────────────────────────┤
│  PULSE    — declares loops + circulation   (temporal)    │ OS-010
├──────────────────────────────────────────────────────────┤
│  [&]      — composes capabilities          (structural)  │ AmpersandBoxDesign
└──────────────────────────────────────────────────────────┘

A loop is PULSE-conforming if its manifest validates against pulse-loop-manifest.v0.1.json and its runtime passes all 12 conformance tests. A system is PRISM-evaluable automatically once it is PULSE-conforming — PRISM's compose phase reads the manifest, injects scenarios at the declared retrieve boundary, and observes outcomes via the declared learn phase. No bespoke per-system integration required.

See /PULSE/manifests/ for the canonical reference manifests and opensentience.org/docs/spec/OS-010-PULSE-SPECIFICATION.md for the full PULSE protocol spec.

Open in the interactive atlas