richfrem/agent-plugins-skills / plugins/agent-orchestration/.apm/skills/orchestrating-agent-work
orchestrating-agent-work
VerifiedInteractive orchestrator for complex engineering work. Analyzes the task, conducts a diagnostic interview to select the appropriate execution strategy (Directed Acyclic Graph versus Loop, and which Loop type), plans the artifact, and supervises execution and verification. Use for "how should I orchestrate this", "plan this workflow", "should this be a DAG or a loop", "run these jobs in parallel", "delegate this to a worker agent", or "run/resume this graph manifest". Not for single trivial edits or skill self-improvement.
references/graph-execution.md
View on GitHub# Graph execution (deterministic DAG runner)
Deterministic executor for task graphs compiled by graph planning ([graph-planning.md](graph-planning.md)). Enforces total ordering for mutations, concurrency caps for reads, and automated rollback upon failure.
## Constraints
- **Workspace Confinement**: Mutations require an isolated git worktree via `--worktree` or `--create-worktree`. `--no-workspace` is permitted only for read-only DAGs and never resets or cleans the checkout.
- **Caller Governance Contract**: Caller environment owns workspace lifecycle and human approval. The runner never pushes, merges, or deletes worktrees.
- **Zero Autonomous Merge**: Merging is strictly caller-managed; the runner stops after recording terminal state.
- **Mutation Boundaries**: Mutations must touch only declared `mutation_targets` and never modify `forbidden_paths`.
- **Human-Bound Manifest SHA**: Under `--approval none`, `--expect-manifest-sha256` must come from a human approval step (for example the control plane's signed Gate 1). Never compute it yourself for a manifest you wrote or edited.
- **Fail Closed**: If `--approval prompt` is selected in a non-interactive shell (including an agent's Bash tool), execution halts immediately before any mutation. Ask the human to run the command in their terminal instead.
## Quick start
```bash
# Execute compiled manifest inside an isolated worktree (human runs this in a terminal)
python3 scripts/graph_runner.py graph-manifest.json --worktree .worktrees/task-001 --approval prompt
# Autonomous run of a human-approved manifest
python3 scripts/graph_runner.py graph-manifest.json --worktree .worktrees/task-001 \
--approval none --expect-manifest-sha256 <approved-sha256>
# Run read-only graph in current directory
python3 scripts/graph_runner.py read-manifest.json --no-workspace --approval none
```
## State Machine
The runner is a ready-set scheduler, not a fixed phase sequence: each loop it runs every ready `parallel_read` as one bounded batch, otherwise the first ready non-read node.
See [graph_execution_state_machine.mmd](diagrams/graph_execution_state_machine.mmd) for the full transition diagram: VALIDATE -> PREFLIGHT -> SCHEDULE -> (READ_BATCH | SINGLE_NODE) -> SCHEDULE ... -> SUCCESS, with FALLBACK and HALT branches.
## Workflow
1. **VALIDATE**: Check manifest SHA (when given), schema, and topology. Mutation or irreversible graphs under `--approval none` need `--expect-manifest-sha256` and a root `verifier_gate` with `role: "approval"`.
2. **PREFLIGHT**: Verify working tree is clean (`git status --porcelain`; skipped for `--no-workspace`). Record starting commit SHA.
3. **READ BATCHES**: Execute ready read-only nodes concurrently up to `max_parallel_concurrency`. After each batch, fail if `git status` or HEAD changed.
4. **SINGLE NODES**: Run ready gates, barriers, and mutations one at a time. Check `verifier_hash` first. Each node is judged by exit code; `output_contract` checks belong in the node's command.
5. **MUTATIONS**: Enforce `mutation_targets` and `forbidden_paths`, then commit once per mutation that changed files. A mutation with no changes succeeds without a commit.
6. **FAILURE**: Retry up to `max_retries_per_node` (mutation debris reset between attempts), then run `fallback_node_id` once its dependencies are complete.
7. **TERMINAL**: Record `success`, `rolled_back` (worktree reset to `<start_sha>` with `git clean -fd`), or `halted` (`--no-workspace`, checkout untouched) in `state.json`.
## Limitations
- `tier` is a planning label; every `command_or_eval` runs with `bash -c`, so model nodes must call a CLI inside the command.
- `input_bindings` and `output_contract` are not enforced by the runner. Nodes pass data through `$GRAPH_SCRATCH_DIR` sibling directories.
- Boundary checks see only what git reports: writes to gitignored paths or outside the repo are not detected or rolled back.
## Verification
```bash
# Inspect append-only execution receipts (anchored in git common dir to survive rollback)
cat "$(git rev-parse --git-common-dir)/graph-run/<graph_id>/<run_id>/receipts.jsonl"
# Audit runner state and exit status
cat "$(git rev-parse --git-common-dir)/graph-run/<graph_id>/<run_id>/state.json"
```
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 470k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |