agentleFS
p10ns11yp10ns11y/skills/control-graph/SKILL.md

control-graph

Skill2 starsChanged 40 days agoMITView on GitHub

Agent control-plane as a graph: outer state machine (or cyclic loop) over named phases, nested inner DAGs or bounded sub-loops, hard budgets, HITL pause gates, and multi-model routing (fast/explore/coding/deep/review). Use for multi-step agent cycles, unbounded-ReAct risk, model routing, structured loops — not domain product logic. Formerly "looper". Composes with agent-orchestrator, subagent-delegation, fusion-sage, concurrent-cli-agents. Triggers: control-graph, looper, state machine, SM+DAG, loop card, model routing, cognitive load, CLT, cognitive strain, load balance.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Middle ground: remove shared waste (extraneous strain for AI *and* human).

    line 170
  2. Distinctive:

    Update Card on every phase transition.

    line 306

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

control-graph

Load rule: This file is the formal SoT. Expand references/english-procedure.md only if a symbol, phase, or transition is still ambiguous after this spec. Expand references/clt-load-balance.md only if dual-actor load (human vs agent strain) is the decision under ambiguity.

// ── Signature ──────────────────────────────────────────────
CG          : control-graph (this skill)          // agent control plane procedure
Outer       : state machine | cyclic loop on Phases
Inner       : DAG | nested bounded loop
Phase ∈ { IDLE, ORIENT, PLAN, HITL_PLAN_GATE, EXECUTE,
          VERIFY, REPAIR, REVIEW_GATE, HITL_REVIEW,
          INTEGRATE, DONE, CANCELLED, BLOCKED }
Card        : Control Card (writable phase/budget/step surface)
Role ∈ { fast, explore, coding, deep, review }
HITL        : human-in-the-loop gate
HOOTL       : human-out-of-the-loop (auto-clear only when safe)
Budget      : { max_loop_iters, max_repair_rounds, max_step_retries,
                max_tool_calls_per_step, no_progress, wall_clock? }
Load        : { intrinsic, extraneous, germane } × Actor ∈ { human, agent }
                // CLT dual-actor; see A8 + clt-load-balance.md

// ── Axioms (never violate) ─────────────────────────────────
A1  Outer is explicit on Card  — never only in chat memory
A2  EXECUTE ⊆ finite Inner     — no open-ended ReAct
A3  Progress ≔ new evidence (diff | test | decision) on Card
A4  Budget exhaust ∨ no_progress×2  →  STOP | HITL | re-PLAN  (never silent thrash)
A5  Review ⊥ ImplementerContext     // fresh inputs: plan + diff + logs
A6  Domain skills ⊨ data plane;  CG ⊨ control plane only
A7  Evaluate(δ) ≔ (Correctness, Effectiveness, Efficiency)
A8  DualLoad — minimize Extraneous for Human ∧ Agent; preserve Germane for both;
    chunk Intrinsic by actor; Parallel/switch capacity: Agent ≥ Human
    (do not serialize independent Inner steps solely to match human WM)

// ── Mission ────────────────────────────────────────────────
Keep agent creativity, wrap it in deterministic skeleton:
  Outer(phase, transition, HITL) + Inner(DAG|subloop, done_when, retry)
  — with CLT budgets so neither actor burns capacity on waste

Activate / Skip

SignalAction
multi-step · thrash risk · “until done” · model routing · parallel re-entryload CG; open Card
“control-graph”, “looper”, “state machine”, “SM+DAG”, “loop card”full skill
cognitive load / CLT / strain / “remove load for AI+human”full skill + diagnose Load on Card; expand clt-load-balance if needed
domain autonomy (finder / CV / X)domain skill owns domain; CG owns shape only
≤1–2 files, obvious fixSkip → agent-orchestrator triage only
SkillLoad(ORIENT) ≔ description-match ∨ explicit-attach
                  ¬ catalog-dump ¬ skills-repo-grep
// Prefix filters (ai-*, web-*, …) = harness-side when present

Outer graph (state machine / loop)

                    ┌──────────────┐
                    │    IDLE      │
                    └──────┬───────┘
                           │ goal accepted
                           ▼
                    ┌──────────────┐
              ┌────►│   ORIENT     │◄── resume / re-orient
              │     └──────┬───────┘
              │            ▼
              │     ┌──────────────┐
              │     │    PLAN      │──► HITL_PLAN_GATE?
              │     └──────┬───────┘
              │            ▼
              │     ┌──────────────┐     Inner DAG / nested loop
              │     │   EXECUTE    │◄────────────────────────┐
              │     └──────┬───────┘                         │
              │            ▼                                 │
              │     ┌──────────────┐  fail+budget      ┌─────┴──────┐
              │     │   VERIFY     │──────────────────►│   REPAIR   │
              │     └──────┬───────┘                   └────────────┘
              │            │ pass
              │            ▼
              │     ┌──────────────┐
              │     │ REVIEW_GATE  │──► HITL_REVIEW?
              │     └──────┬───────┘
              │            ▼
              │     ┌──────────────┐
              │     │  INTEGRATE   │
              │     └──────┬───────┘
              │     more?──yes──► PLAN (gap only)
              │            │ no
              │            ▼
              │     ┌──────────────┐
              └─────│ DONE | CANCELLED | BLOCKED
                    └──────────────┘

Phase contract

PhasePurposeExit whenDefault Role
IDLEno active graphgoal accepted—
ORIENTgoal · constraints · risks · needed skills (description-trigger)1-sentence goal + unknownsfast | explore
PLANsteps · verify cmds · budgetswritten plan + success criteriadeep (or fast if light)
HITL_PLAN_GATEhuman on risky/vague planapprove | amend | aborthuman
EXECUTErun only Inner batchbatch done | step retries exhaustedcoding | fast
VERIFYindependent checks vs planall verify cmds run; pass/fail knownfast + review on fail
REPAIRgap-only fixgap closed | repair budget 0coding
REVIEW_GATEquality/safety/scopepass | HITL | reworkreview
HITL_REVIEWhigh-stakes humanapprove | reject | redirecthuman
INTEGRATEmerge · report · surplusartifacts landedfast
DONE / CANCELLED / BLOCKEDterminalreason on Card—

Transitions (guards)

From → ToGuard
IDLE → ORIENTnon-trivial goal | explicit run
ORIENT → PLANgoal + constraints on Card
PLAN → EXECUTEsuccess criteria + verify cmds (or light exception)
PLAN → HITL_PLAN_GATEhigh stakes | vague | destructive | user asked
HITL_PLAN_GATE → {PLAN, EXECUTE, CANCELLED}amend | approve | abort
EXECUTE → VERIFYInner batch finished
VERIFY → INTEGRATEall checks pass
VERIFY → REPAIRfail ∧ repair_budget > 0
VERIFY → BLOCKEDfail ∧ (budget 0 ∨ external)
REPAIR → VERIFYfix applied
REPAIR → PLANplan wrong (remaining only)
INTEGRATE → DONEno remaining in-scope work
INTEGRATE → PLANremaining gap only
EXECUTE | VERIFY → ORIENTEVA/inner act_or_ask=switch ∧ pathway change (gap-only re-orient)
Any → HITL_*cost/rate/fit/safety/confidence | phase requires human | pathway switch needs ack
Any → CANCELLEDuser cancel | hard policy | max_loop_iters ∧ ¬progress
Any → BLOCKEDcredentials/network/permissions after ≥2 attempts

Budgets (defaults — set on Card before EXECUTE)

BudgetDefaultOn exhaust
max_loop_iters8STOP + report
max_repair_rounds3STOP | HITL
max_step_retries2mark step failed; siblings or abort batch
max_tool_calls_per_step25force step exit
no_progress2 identical failure signaturesre-PLAN | HITL

Dual-actor load (CLT middle ground)

Diagnose on Card before heavy EXECUTE. Formal detail: references/clt-load-balance.md.

LoadMinimize / maximizeHumanAgent
Extraneousminimize bothclear HITL (approve/amend/abort + exact preview); no log dumpsCard + short handoffs; prune via ai-optimization; no mega-steps
Germanepreserve bothjudgment at gates; retrieve/decide before rubber-stampPLAN write-up; VERIFY/REVIEW ⊥ implementer
Intrinsicchunk by actor≤~4 new decision elements per gate; fade scaffolds for expertsactive elements on Card only; progressive disclosure
Parallel / switchasymmetricserialize human-facing asksfan-out independent Inner (Agent capacity ≥ Human WM)

Middle ground: remove shared waste (extraneous strain for AI and human); keep productive struggle (germane); allow machine multitasking where steps are independent — do not impose human working-memory caps on agent fan-out.


Inner graph (DAG | nested loop)

∀ step in EXECUTE batch:

id, name, depends_on[], done_when, retry ∈ 0..max_step_retries,
on_fail ∈ { abort_batch, continue_siblings, escalate_HITL },
cancel_when, model_role, inputs (minimal), outputs (re-enter Outer)

Rules

  1. Bound first — write step list before tools; default ≤7 steps/batch
  2. One primary outcome per step
  3. Parallel ⇔ independent paths → concurrent-cli-agents + subagent-delegation — prefer fan-out when safe (A8); never parallelize to dump concurrent asks on the human
  4. Re-enter Outer with {step_id, status, artifacts, errors, next_hint} — not full transcript
  5. Nested loop allowed only if it inherits budgets + done_when (no nested unbounded ReAct)
  6. Cancel is first-class — leave tree consistent; reason on Card
EXECUTE → topo(Inner) | parallel(independent)
       → ∀ step: until done_when | retry | fail
       → aggregate → VERIFY

Model routing

RoleUseRe-enters Outer as
fastorient, triage, cmds, small edits, Card updatesfacts, pass/fail
explorebroad map, readonly surveystructured map
codingimplement fixed step contractdiff + how verified
deeparchitecture, ambiguous plan, tradeoffsplan / decision
reviewindependent verify / security / scopepass/fail + gaps only
SignalPreferAvoid
≤2-file obviousfast (skip full CG)deep / multi-agent
“explore thoroughly”explore → ORIENT→PLANcoding before map
clear acceptancecodingmid-step re-architecture
vague large / designdeep in PLAN (+HITL?)coding immediately
worker claimed donereview (fresh)same implementer context
high stakes (secrets, prod, CV)review + HITLunattended coding

Single-model host: simulate roles via phase prompts; reset context for review.

Handoff: phase, step_id, status, artifacts[], verify_commands[], open_risks[]
Parent Outer owns transitions. Workers never jump PLAN→DONE.


HITL gates

Pause (no further EXECUTE side effects) when any:

GateTriggerResume
Planvague/large/high-stakesapprove / amend
Reviewsecurity, external mutate, irreversible git, CV/liveconfirm
Budgetmax_* exhausted | cost limitraise budget / cancel
Confidencelow confidence / contradictiondecide / re-ORIENT
Pathwaysignpost_fired | pathway_switch (from EVA Inner)ack switch / amend / Ask
Policysecrets, destructive, shared remote pushconfirm
Blockermissing creds/permissionsfix env / CANCELLED

Domain guards stay in domain skills; CG requires honoring pause results as Outer transitions.


Composition (no duplication)

ConcernOwnerCG does
triage single-shot vs multi-workeragent-orchestratorwrap work in Outer phases
explore return formatsubagent-delegationexplore Role + Inner steps
worktrees / mergegit-worktreesINTEGRATE uses merge, not cp
parallel agentsconcurrent-cli-agentsindependent Inner only
token pruneai-optimizationbefore deep/coding fill (agent extraneous ↓)
surplusfusion-sagePLAN/INTEGRATE surplus
dual-actor CLT detailreferences/clt-load-balance.mddiagnose Load; A8 middle ground
on-the-fly CLT pre-filter../rules/clt-dual-load.mdc (alwaysApply: true)inject A8 before heavy skills; no paste-duplication into domain SKILL.md bodies
product autonomyfinder-reactor / agentic-reactorshape only
epistemic emptiness (Prior→Probe→Simulate→Score→ActOrAsk)eva-emptinessOuter only; EVA owns Inner when emptiness gate fires — do not inline
pathway switch / signpostseva-emptinesshonor continue|switch|Ask; Outer owns re-ORIENT on switch
hubris / wandering / over-clever (Cyclops…Prophecy)odysseus-navigatorORIENT/PLAN/REVIEW: Navigator labels + cg_hook; do not inline myth essay

CG = control plane · domain = data plane · orchestrator = multi-worker logistics · CLT pre-filter = DualLoad hygiene for Human∧Agent.


Anti-patterns

¬Do
unbounded ReAct until “feels done”Outer + budgets + done_when
phase only in chat ramblingControl Card
one model plan+code+self-reviewseparate review (fresh)
mega-step “implement everything”small Inner DAG
retry same failure foreverno_progress → re-PLAN | HITL
nested agents without parent ownershipparent owns transitions
domain logic reimplemented herelink domain skills
silent continue after budget exhaustSTOP + report
minimize all human load (no germane)protect judgment / retrieve-then-decide at HITL
serialize agent work to match human WMfan-out independent Inner; keep human gates serial
HITL = full transcript dumpstructured preview only (extraneous ↓)

Control Card (minimum)

Copy references/control-card.md or:

## Control Card
- goal: …
- phase: ORIENT | PLAN | EXECUTE | VERIFY | REPAIR | REVIEW_GATE | INTEGRATE | HITL_* | DONE | …
- plan (success criteria): …
- verify commands: …
- budgets: max_loop_iters=8 rem=_; max_repair_rounds=3 rem=_; max_step_retries=2
- load_diag: actor=human|agent|both ; dominant=intrinsic|extraneous|germane ; intervene=…
- inner_mode: standard | eva
- pathway_active: (optional; when inner_mode=eva)
- token_envelope: (optional; handoff_max_tokens / prefer ai-optimization before EXECUTE)
- steps (DAG|subloop): S1 … / depends / done_when / role
- model_role now: fast | explore | coding | deep | review
- last progress: …
- pause reason: (none | signpost_fired | pathway_switch | …)
- handoff: artifacts / open_risks (compact — not transcripts)

Update Card on every phase transition. If phase unnameable → unbounded ReAct → stop → ORIENT.


Quick procedure

1. Triage (agent-orchestrator): single-shot? → do it; skip CG
2. Open Card; phase=ORIENT; set budgets; optional load_diag (A8)
3. PLAN + verify cmds; HITL if high stakes (human gate: low extraneous, high germane)
4. Route Role; write Inner DAG|subloop — parallel when independent
5. EXECUTE bounded; handoffs only
6. VERIFY real cmds; REPAIR gaps only (budgeted)
7. REVIEW_GATE / HITL when required
8. INTEGRATE + report; surplus if fusion applies
9. DONE or narrow re-PLAN for remaining gap only

Portable wiring

EnvLoad
Grok / Cursor / AGENTS.mddescription match · /control-graph · “looper” alias
Cursor rule../rules/control-graph.mdc
Validatenode control-graph/scripts/validate-skill.mjs

Rename note: formerly looper. Same contract; name matches Outer SM/loop + Inner DAG/nested-loop graph.

Reference (progressive disclosure)

  • English expansion (only if needed): references/english-procedure.md
  • CLT dual-actor load (only if needed): references/clt-load-balance.md
  • Card template: references/control-card.md
  • Library formal kernel: ../formal/AppGenMathPhyLang.kernel.md
  • Thesis: @Peramanathan structured loops

Creativity inside the edges — never instead of them. Capacity for the work that builds capability — for both minds in the loop.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.