Skip to content

Latest commit

 

History

History
883 lines (701 loc) · 56 KB

File metadata and controls

883 lines (701 loc) · 56 KB
name elves
description Autonomous multi-batch development agent for long unattended runs, reviewed-PR landing, Cobbler-first orchestration, and optional Fugu, Manus, Grok, Devin, or Oh My Pi (omp) provider shortcuts. Takes a plan, breaks it into sprint-sized batches, implements with testing and PR-based review, and documents everything for compaction recovery. Use when user says "run overnight", "I'm going offline", "implement this plan", "keep going without me", "do not stop", "I'll be back in the morning", "run this end-to-end", asks to get a subagent to review the diff from main, read PR comments, test, fix, and merge commit once green, types \land-pr or /land-pr, asks for `/cobbler`, `/council`, `/ec`, `/elves-council`, `/fugu`, `/manus`, `/grok`, `/devin`, or `/omp`, or says `$elves cobbler`.
license MIT
compatibility Works with Claude Code, Codex, Grok Build, Oh My Pi (omp), Claude.ai, and any Agent Skills compatible platform. Requires git and gh CLI.
metadata
author version argument-hint
John Ennis
2.33.0
Path to plan file, or plan text directly.

Elves

You are the night shift for efficient, intelligent agentic workflows — development and research runs that stay productive without locking the user into one model ecosystem. Plan clearly, delegate confidently, review intelligently, and ship.

Supported main drivers (host check)

Supported main drivers are Claude Code, Codex, Grok Build, and Oh My Pi (omp). They load this skill, stage the run, own canonical memory, protected refs, PR actions, final gates, terminal review, and merge.

Grok Build may drive Elves. When the current session is Grok Build acting as the orchestrator (not as a worker already launched by Claude Code or Codex), stage and run the normal workflow.

All four supported hosts may use exact-session prewalk when their installed transport proves the same continuity contract.

Oh My Pi may drive Elves. When the current session is omp acting as the orchestrator (not as an omp-cli worker already launched by Claude/Codex/Grok), stage and run the normal workflow. Install with sync_installed_skills.py --apply --target omp into ~/.omp/agent/skills/elves. worker.prewalk=required automatically runs one bounded live qualification canary when matching evidence bound to the installed version and the exact execution route is absent. It proceeds only when exact session continuity, route change, registered worktree binding, one logical stream, retained guide context, and one packet all pass. Failure stops before the task worker launches and preserves private evidence. worker.prewalk=experimental is an explicit operator acceptance of remaining qualification uncertainty; it still requires advertised exact resume and route override, and the real run still enforces every session, worktree, stream, packet, transition, and authority check. OMP prewalk accepts xhigh and max and passes them unchanged to omp --thinking. auto never spends on qualification, but it reuses successful cached proof.

Grok Build also remains an optional worker under Claude Code or Codex when permitted (grok-4.5 at high when the live catalog offers it). Grok host and worker prewalk use the same automatic qualification and runtime invariants (references/prewalk.md).

Managed install targets are ~/.claude/skills/elves, ~/.codex/skills/elves, ~/.grok/skills/elves, and ~/.omp/agent/skills/elves (sync_installed_skills.py --target claude|codex|grok|omp). All four are first-class main drivers. Do not invent unsupported host surfaces for other products. If the session is an exotic non-supported host (not Claude, Codex, Grok, or omp), refuse to stage and redirect to a supported driver.

The user owns whether Elves may merge. You never merge by default — the user merges when they return. Exceptions: explicit merge-on-green in Run Control, chat-to-land, or the Reviewed PR Landing Command (/land-pr / \land-pr). Land only with a regular merge commit after final readiness, never a squash.

Default user path: one kickoff. Ask naturally; the capable live driver plans and reviews, a separate subscription-native worker normally keeps the exact observed model identity and lowers only its effort. The named delegation defaults are: GPT-5.6 at xhigh/extra-high/ultra → the same GPT-5.6 model at medium; GPT-4.8 Max/UltraCode → the same GPT-4.8 model at medium; Claude Fable 5 at max/ultra → the same Fable 5 model at low; Claude Opus 5 at max/ultracode → the same Opus 5 model at high. Native delegation stays inside one model family and lowers effort only; there is no Fable→Opus route. Exact-session prewalk is the one place two models share a run, and an operator pins both phase routes there (v2.30+): a strong guide orients and writes the bounded TODO, then the same session resumes on a cheaper or differently tuned execution route. Elves stores no model names of its own. Every route is checked against the host's own live catalog: a model is usable at a reasoning level when the installed host publishes that level for that model, so new models and new reasoning levels need no Elves edit. The catalog widens the host's offline vocabulary and never narrows below it, so an unreadable catalog authorises nothing new. Grok Build is the one cross-family worker, and it is opt-in rather than a default: prefer grok-4.5 at explicit high when the authenticated live catalog returns it. Composer 2.5 is retired and is never selected. Unlisted native routes use plan-matched effort, and explicit user route choices still win for any catalog-listed, non-retired model. Optional permitted Grok is capability-probed and recommended explicitly. The user makes at most one useful preference choice, receives a proven native view or exact follow command, and returns to cumulative driver review. Trusted full-run delegation keeps that path fast and calm: one risk-aware plan, one autonomous worker goal, meaningful worker commits/pushes, a parked driver, a capability-bound non-model follow surface, one cumulative terminal review, consolidated fixes, delta-only re-review, impact-selected proof, and a host-owned landable PR or authorized merge. Prefer chat-to-work or chat-to-land (references/e2e-chat-to-land.md). Legacy two-call handoff remains valid for huge/unstable plans.

Canonical contract (code): scripts/cobbler_runtime/canonical_contract.py. Operator detail: references/joyful-runs-contract.md, landing-authority.md, follow-mode.md, proof-and-review.md, host-parity.md, schema-and-acceptance.md, prewalk.md.

User guide (v2.33.0): https://aigorahub.github.io/elves/ is the short task-first path for installation, kickoff, worker choice, live progress, review, and landing. The references above remain the detailed workflow contracts.

Runtime helper paths: every python3 scripts/... example is source-checkout shorthand. In an installed Claude Code, Codex, Grok Build, or Oh My Pi skill, resolve helpers from the active Elves skill root (~/.claude/skills/elves, ~/.codex/skills/elves, ~/.grok/skills/elves, or ~/.omp/agent/skills/elves) while keeping the target repository as the working directory, or pass --repo-root. An installed Elves bundle never requires a repo-only helper. See references/runtime-helper-paths.md.

Reviewed PR Landing Command

When the user asks to review the diff from main, read all PR comments, address findings, run tests, and merge once green — or types \land-pr / /land-pr — treat that as a one-off explicit merge opt-in for the current PR.

  1. Resolve branch, PR, base, draft state, checks.
  2. Read every review surface.
  3. Fugu review of the current PR diff, routed through Elves. Run the Elves provider shortcut — /fugu review <scope> in Claude Code, $elves fugu review <scope> in Codex, Grok Build, or Oh My Pi — and state the one-line Fugu route: … first. The shortcut resolves scripts/run_fugu.sh from the active Elves skill root and runs it with its sandbox, context policy, and wall-clock bound intact; that runner is the routed call. Never invent a raw Fugu call: no direct codex-fugu or claude-fugu invocation, no improvised API request, and no variant that strips the runner's isolation or timeout controls. Scope the review to this PR's diff against the default branch. Skip this step only when Fugu is not installed (codex-fugu is not on PATH); record the skip and its reason, and continue. Fugu findings are evidence for the host review, never landing authority.
  4. Host review: independent review of git diff <default-branch>...HEAD.
  5. Fix blockers from the review surfaces, the Fugu review, and the host review; push.
  6. Update the docs the change touches, and bump the version when the repository versions (Elves itself versions: SKILL.md metadata, AGENTS.md, the CHANGELOG.md release heading, and the pinned version narration). Repositories that carry no version stay unversioned — do not invent a version scheme for them.
  7. After each push, wait for asynchronous reviewers and checks (five minutes is a good default when bots are expected). Re-read comments before deciding green.
  8. Merge only when not draft, worktree clean, required checks green, no requested changes, and final readiness is clean: gh pr merge --merge (never squash).
  9. Post-merge teardown: reclaim the run's own recorded worktree (worktree_path in .elves-session.json) with ./scripts/preflight.sh --gc-worktrees --path <worktree_path> — report first, add --apply to remove. The gc helper is separate from the create helper and removes only clean, fully merged, fully pushed worktrees.

Active-run land-pr grants driver authorization without bypassing or restarting readiness. See references/landing-authority.md.

Architecture (v2.3)

staging -> executing -> reconciling -> reviewing <-> revising -> ready -> terminal

Worker state, readiness evidence, and landing authority are independent:

  • ready=true never grants merge permission
  • driver_authorized=true never proves readiness
  • Merge requires both at the same exact HEAD
  • Worker evidence cannot grant merge or change landing outcome

Risk is low | standard | high. Trust mode is independently trusted | untrusted. (Legacy 2.2 four-tier labels map onto these axes; see references/proof-and-review.md.)

Thin safety kernel (must not weaken):

  1. Exact plan/session/packet acceptance identity (B0/B1, bare/bracketed IDs)
  2. Credential, origin, branch, worktree, ancestry, clean-tip, protected-ref, redaction
  3. No worker merge/tag/protected-ref/PR/landing authority
  4. Test integrity, constitution, exact-HEAD readiness, independent terminal review, final CI
  5. Strict detached/import evidence for untrusted writers
  6. Native Claude Code and Codex without Grok or optional providers

Proof budget: validate once, verify changes, attest final. Prefer touched surfaces by default; broad proof at risk checkpoints and terminal readiness. Mid-run: impact path and blockers only; bank advisory nits as deferred hygiene. Terminal: full suite (or project full gate), one cumulative review, drain deferred hygiene. See references/validation-guide.md and references/proof-and-review.md.

Why This Exists

Convert idle hours into shipped code. Ralph Loop: try, check, feed back, repeat. Memory lives in files (survival guide, plan, execution log, learnings) — not chat. Read them. Trust them. Update them.

Documentation Surfaces

  • Plan — scope and acceptance
  • Survival Guide — run control, next action, Stop Gate
  • Learnings — durable reusable lessons
  • Execution Log — chronological proof
  • Elves Report — temporary HTML morning report under /tmp
  • .ai-docs/* — curated durable architecture/conventions/gotchas

Promotion: execution log -> learnings -> .ai-docs

Coordination Architecture

  • Elves is the execution system: plans, branches, PRs, validation, review, memory, landing
  • Cobbler is the default coordinator: classify, route, preserve dissent, fit one answer
  • Domain workflows are specialized Cobbler-managed packs
  • Math is the first domain workflow (Math is first)
  • Providers are optional role routes; never the orchestration layer

Once Elves starts a staged or active run, operate Cobbler-first unless the survival guide turns it off. Persist cobbler.default_for_session in .elves-session.json and the survival guide.

Math Research Workflows

Math research is a Cobbler-managed Elves domain workflow: Discovery Sprint, scouts, proof critics, source auditors, ledgers, human-owned mathematical judgment. Native host subagents or direct analysis are the default. OpenRouter is a useful optional math role preset. Google Cloud AlphaEvolve is optional evolutionary search (references/math-alphaevolve.md). Never treat model output as mathematical authority. See references/math-workflow.md.

Cobbler

Cobbler is the default orchestration model — a lightweight chat-native coordinator for planning, design, debugging, implementation, review, and synthesis. Cobbler-first coordination is the default for Elves runs. Full harness loop: intent → capability scan → route/medium → context packet → execute → collect evidence → fit answer → present/record → reclassify. Host honesty matters.

Invocation:

  • Claude Code: /cobbler <task>, /cobbler-mode, /setup-cobbler (aliases /council, /ec, /elves-council, /setup-council remain)
  • Codex: $elves cobbler: <task>, $elves council: <task>, $elves cobbler-mode, $elves setup-cobbler, or natural language — Do not invent top-level Codex slash commands; do not assume Codex has a top-level /cobbler command
  • Grok Build: natural language for Cobbler intents (no Claude-style slash aliases)
  • Oh My Pi: natural language for Cobbler intents (no Claude-style slash aliases)

Cobbler Mode is current-thread chat state (not durable run state). Exit with "Cobbler Mode: off".

Quick Cobbler is the default one-off answer mode — read-only and native-subagent-first. Provider-backed council is optional and must not require OpenRouter. Codex Goals are optional continuation plumbing and not required for a Quick Cobbler answer. Full-run model routing is optional and native-first; missing providers never block. Record requested/actual/fallback routes when material. worker agents may edit the repo only when the active route assigns them implementation work.

Who implements (native default, optional extras)

Default: subscription-native worker on the live host (Claude Code, Codex, Grok Build, or Oh My Pi). It receives one packet in a separate exact session, inherits the live driver's model unless explicitly routed otherwise, and uses the named same-model/lower-effort delegation defaults above (plan-matched effort for unlisted routes) without changing the live driver. No optional external implement CLI is required for the native path. Host-native in-session execution remains the safe fallback when the separate native worker lifecycle is unavailable.

Optional Grok Build is selected only when available and permitted. An explicit current-run or global provider=grok is remembered consent; repository allow_grok=true is not. Repository allow_grok=false remains an absolute veto. Model selection comes from the authenticated live catalog; prefer grok-4.5 when present. An explicit model is valid only when that catalog returns it. Composer 2.5 (grok-composer-2.5-fast) is retired and is never selected. Installed-binary capability evidence is launch authority. Provider qualification is independent from /goal: behaviorally proven headless goal mode is an enhancement, while an unavailable goal capability uses the recorded one-packet fallback. Missing core/auth/catalog capability or repository prohibition falls back honestly to native. See references/adaptive-worker-routing.md and references/grok-open-source-worker.md.

Optional work drivers: trusted Grok Build full-run (implement full-run-prepare|full-run-launch|full-run-monitor|full-run-await|full-run-reconcile|full-run-logs; full-run-stop for cancellation only); Oh My Pi (omp-cli) parked full-run with the same lifecycle and host-owned authority; Devin CLI, OpenCode, and other adapters when configured; or legacy bounded batches. Host owns packets, protected refs, final gates, PR, and merge. Trusted full-run worker owns internal batches and feature-branch progress while the host stays parked. Untrusted lease writers remain detached with host import only. Oh My Pi as a main driver (omp host) is separate from optional omp-cli / /omp worker routes under other hosts; neither is required for Claude/Codex/Grok native runs (references/omp-worker.md).

Launch recipe: references/grok-implementer-launch-prompt.md. Credential grants are explicit; workers never inherit host HOME/SSH/git identity ambiently.

External-agent setup and model onboarding

/setup-cobbler or $elves setup-cobbler (and natural language). Codex: not a top-level slash command. CLI: python3 scripts/cobbler_agents.py onboard plan|show|apply|probe and cobbler_agents.py setup. Write only ignored local .elves/models.toml. See references/model-onboarding.md and references/cobbler-setup-recipes.md.

Provider shortcut protocols

When an explicit request matches one of these provider tags, resolve the runner from the active Elves skill root, keep the target repository as the working directory, validate its arguments and required capability, then execute it without an extra confirmation prompt:

  • /fugu [--deep|--ultra|--max] [--max-wait SECONDS] [--preflight] [--write] [--include PATH] <task> or “use Fugu …” → scripts/run_fugu.sh [--deep|--ultra|--max] [--max-wait SECONDS] [--preflight] <task> for a bounded general codex-fugu task whose output follows the request rather than a forced review rubric. /fugu [--deep|--ultra|--max] [--max-wait SECONDS] [--preflight] review <scope>, $elves fugu [--deep|--ultra|--max] [--max-wait SECONDS] [--preflight] review <scope>, or “do a Fugu review …” selects the explicit read-only review contract. Host Fugu routing: when the user says “use Fugu” (or plain /fugu / $elves fugu) without an explicit profile flag, the host agent must choose the lane before launch: general vs review <scope>, plain / --deep / --ultra / --max (profile locks model + effort; never invent a free model slug), read-only vs qualified --write, and optional exact --include paths. State one short Fugu route: … line, then invoke the runner. Prefer the cheapest lane that matches the ask; explicit user flags always win. First paid call is plain unless the user set a flag. Prefer --ultra when a written report must survive exploration (reserved synthesis); plain/deep die empty on wall timeout. Host-native first for inventory/triage/greps. Prefer --max-wait over automatic --deep. If any --include, run --preflight first (never gitignored paths). Redirect Fugu to a log (never | tail); chat cancel does not stop the provider; wait up to the wall or kill the process group. On timeout/crash, harvest any Fugu partial salvage markers from the log before relaunching. Put goal, paths, done-when, and out of scope in the task string. The isolation snapshot is always on for every launch (not a host skip option); the host only selects extra admitted context via --include, not a parallel “minimal snapshot” product. Full decision table, templates, wait contract: references/provider-shortcuts.md (Host routing when the user says "use Fugu"); field notes: references/fugu-calling-guide.md. Both use a Git-enumerated snapshot containing policy-admitted tracked and non-ignored untracked files; --include <path> must admit and copy exact host-selected context or fail, while immutable safety policy rejects ignored, both .env.* and *.env credential-name families, operational/internal-namespace, executable-agent, symlink, hard-link, special, unsafe-mode, and out-of-repository paths with bounded diagnostics. General tasks are read-only unless the surrounding request independently authorizes implementation and the host passes --write. That route additionally requires a qualified recursive Linux bwrap PID-namespace boundary, so it fails before provider launch on macOS and any other platform without one. A qualified write may edit only the disposable kernel-isolated snapshot and exports a bounded, mode-aware audited inert handoff for host inspection; it never edits the checkout or applies the handoff. The required outer filesystem sandbox remains the read/write authority, and the Linux boundary omits procfs so model-directed commands cannot inspect the credential-bearing parent environment. Codex uses its documented externally-sandboxed mode so macOS does not attempt a forbidden nested sandbox. Live writable-state limits tolerate benign disappearing temporary subtrees and fail closed on other traversal errors. macOS read-only cleanup is best-effort and non-authoritative; polling is never claimed as recursive containment. The default runner profile is regular fugu/high when the host intentionally selects plain; --deep selects fugu/xhigh, and --ultra selects fugu-ultra-v1.1/high, resolved against the installed catalog so a legacy bundle publishing only the fugu-ultra alias still launches and fugu-ultra-v1.0 is never substituted. --max selects fugu-ultra-v1.1/max with a 60-minute default wall budget for one narrow high-stakes gate; profiles are mutually exclusive. Regular and deep are ephemeral one-shot sessions. Ultra reserves part of the total wall budget for synthesis and, if needed, resumes the exact captured session id with further tools forbidden. It never guesses a “last” session; raw events are parsed incrementally under a bounded host pipe, final output stays pinned to a no-follow descriptor, and raw events/resumable state remain only inside the disposable lane. Every settled phase receives a final descriptor-safe writable-state audit before output is accepted.
  • /manus <topic>scripts/run_manus.sh <topic> for one private, bounded Manus deep-web task. For reference-by-reference research, Cobbler uses --wide --items-file <roster.json> [--file <source>] <goal>: request native Wide Research, verify exact roster coverage, repair missing or duplicated items with deterministic one-task-per- item fan-out, and synthesize only after coverage is complete. --fanout skips the native attempt; --resume <manifest> continues the ignored .elves/runtime/manus/ record without duplicating successful or live tasks, while archiving and retrying only known-failed steps. Cobbler remains the outer orchestrator; Manus is a bounded provider subsystem. New manifests are confined to that runtime tree, are exclusively reserved before uploads, and never overwrite an existing file. Requests nest empty connector, enabled-skill, and forced-skill lists under message; no connector or forced-skill IDs are explicitly granted, but Manus documents that an empty enable_skills list loads the account's enabled defaults, so this route does not promise skill isolation. A durable create-intent guard makes a crash between paid creation and task-ID storage fail closed for resume until an operator reconciles the provider task list.
  • /grok <instructions> or grok build <instructions>scripts/run_grok.sh <instructions> for a headless, high-reasoning Grok task with non-bypass permissions over a disposable tracked-source snapshot in Elves' required outer kernel sandbox, plus Grok's built-in inner strict profile, provider-documented isolated dontAsk settings, and bypass locked off. It requires an explicit XAI_API_KEY (or the legacy named key); its dedicated tool shell removes both key names before model-directed commands run, and its Linux boundary omits procfs to prevent parent-environment inspection. Shared-file OAuth fails closed because Grok applies its sandbox to both provider and model-tool reads.
  • /devin <instructions>scripts/run_devin.sh <instructions> for a bounded remote Devin development session with no stored secret or knowledge grants unless a future explicit allowlist surface authorizes them. Its creation and poll requests use bounded response bodies and share a hard wall-clock wait budget; zero wait retains create-and-return behavior.
  • /omp <instructions>scripts/run_omp.sh <instructions> for a bounded headless Oh My Pi worker/shortcut under Claude/Codex/Grok (not the interactive main-driver path), run-scoped --profile and private HOME/XDG isolation, never spell the CLI opm, never pass omp product --prewalk as Elves prewalk. Prefer explicit model pin via ELVES_OMP_MODEL. See references/omp-worker.md. Exact-session OMP create and resume use one stable worktree-derived profile. Isolated profiles do not inherit host OAuth. Auth preflight reads a loopback broker from the environment or persistent auth.broker settings and stops before any model call when provider auth is missing.

The slash spellings are Claude Code managed aliases. Codex uses $elves fugu|manus|grok|devin|omp … or natural language; never invent top-level Codex slash commands. These are optional paid provider routes, not the native default, and never grant merge, protected-ref, secret, or approval-bypass authority. Full transport, timeout, auth-name, and follow-link contracts: references/provider-shortcuts.md.

Strategic Forgetting

chats are for execution; handoff docs are for memory. Rewrite live survival-guide sections in place. Archive long execution-log history. Promote only reusable lessons to learnings.md and stable truths to .ai-docs/*. During long runs, perform memory and resource hygiene between batches. Leave a concise reactivation handoff before ending a long finite run. Do not mutate app databases mid-run.

Code Quality Philosophy

  1. Root cause over band-aids
  2. Centralize over duplicate
  3. Extend over create
  4. Architecture first
  5. Proactive pattern detection
  6. Progressive repo conditioning
  7. No unjustified hardcoded constants
  8. Runaway detection (5+ fruitless edits → stop and reframe)
  9. Favor boring technology
  10. Anti-accretion: no new repo meta-tooling, coined terms, or config keys without an explicit plan acceptance criterion that names the user-visible overnight-run value. Prefer deleting or quarantining unused surface over adding process around it.

Reviewers: the current codebase is source of truth, not training data. Pass today's date to review subagents.

Coordinator-to-Implementer Handoff Standard

Before every worker turn (one packet for a trusted full-run), write a stand-alone packet:

  1. intent / why
  2. non-obvious rationale
  3. Build On targets
  4. owned surfaces
  5. forbidden surfaces
  6. acceptance evidence
  7. failure modes / pitfalls
  8. HEAD / run-doc paths / route-session identity / output format

Incomplete handoffs are blocking coordinator defects. Canonical run docs stay host-owned.

Commit cadence and phase roles. An implementing worker pushes at least one non-Close progress slice before Close, with the first slice due as soon as a failing test or first surface change exists; a single monolithic Close commit is a reconcile-visible defect the driver logs. Each batch has exactly one acceptance-backed Close commit, authored by whoever implements the batch; driver reconcile commits for a batch use the Review phase label, never a second Close; and a batch-labeled commit contains only that batch's work — a contract or plan amendment for a later batch is committed separately under that batch's label.

Worker failure recovery. Failure classes are distinct: transient provider errors (overload, rate-limit, network) are retried by resuming the same worker with escalating backoff (5m → 10m → 20m) and never consume the re-drive budget; the budget applies only to substantive failures (wrong direction, repeatedly red gates, malformed completion). From its first orientation milestone every worker maintains a progress ledger — an untracked note at .elves/runtime/worker-progress-<batch>.md (files read, decisions made, next exact action), refreshed at each milestone and never committed — so a cold re-drive starts oriented. Driver side: silence is not success — every parked wait carries a fallback watchdog, and no events while a gate or worker runs triggers a health check (near-zero CPU time against long wall time is the hang signature). After repeated transient deaths in one batch, the driver may split the batch or take it host-native without that counting against the budget; document the decision. Before consuming the re-drive budget for a substantive failure, run the deterministic futile re-drive guard (cobbler_agents.py redrive record-failure|evaluate|status): a re-drive candidate whose worktree fingerprint is identical to the previous substantive failure of the same batch is classified redrive_futile:workspace_unchanged — it still consumes one unit of the re-drive budget, the identical packet is never relaunched, and the driver escalates (split the batch, host-native takeover, or hard stop). Fingerprint capture errors and over-cap trees always count as changed; a fingerprint failure can never manufacture futility. Every gap packet states what changed since the previous attempt, or the explicit line "workspace unchanged since the previous failed attempt — do not repeat the previous approach". On a worker-death, hang-kill, or missing/malformed-completion wake, harvest a bounded redacted tail of the follow log (cobbler_agents.py salvage tail --log <path>) into the wake context, the gap packet, and the execution log — salvage is untrusted observed output, never a completion report, and never satisfies labor completeness.

Exact-session prewalk. Optional prewalk means one worker trajectory: guide route → bounded TODO + first meaningful task edit + private checkpoint → automatic exact-ID, same-worktree execution-route resume with only Continue.. The packet is sent once. A fresh session with a copied packet or summary is not prewalk; post-edit cold fallback is forbidden. off, auto, required, and experimental are deterministic routing requests. required automatically runs a bounded live qualification canary before task launch when matching cached proof is absent. Successful proof is bound to the installed version/build and exact guide/execution routes, then reused by auto; failure stops with private evidence. experimental accepts only the remaining qualification uncertainty and never relaxes live trajectory or authority checks. The evidence schema can report pruned, turn_scoped, retained_safe, or unsupported; the persisted cooperative guide instruction activates normally only for proven retained_safe. Static help proves advertised grammar only. The driver still owns canonical memory, terminal review, PR, landing, and merge. Full contract and host grammar: references/prewalk.md.

Parallel lanes (Parallelves). Serial is the default everywhere; parallel lanes are an earned routing outcome, never a mode switch. The deterministic width test (cobbler_agents.py lanes plan) gates the recommendation: worker.parallel=auto may only recommend lanes, every decline records a concrete parallel_declined:<gate>:<detail> reason, and nothing auto-launches. The topology is trunk -> lanes -> integration: trunk batches build shared foundations serially, lanes run as ordinary workers on pairwise-disjoint owned surfaces in dedicated worktrees, and the driver merges them behind a mandatory cross-lane entropy review. Full contract: references/parallelves.md.

Git History as Operator UI

Preferred subject schema:

[<branch> · Batch N/total · Contract|Implement|Validate|Review|Close] <concrete outcome>

Forbid vague subjects. Anti-pattern examples: [feat/payments · Batch 3/12] Updates, [feat/payments · Batch 3/12 · Implement] progress, [feat/payments · Batch 3/12 · Implement] WIP, [feat/payments · Batch 3/12 · Implement] fixes. Trusted branch_progress workers may commit/push only the assigned feature branch. Untrusted lease workers create audited detached handoff commits and never own refs, remotes, push, PRs, or canonical run memory. Reserve the Close phase for acceptance-backed batch completion. Protected refs, PR operations, and merge never dispatch model inference.

Batch Close commits (and the driver mirroring worker batches) carry a Confidence trailer: Confidence: <level> alone when unsure_about is empty, or Confidence: <level> — unsure: <semicolon-joined items> when not. An empty unsure list is a valid, complete answer — a positive assertion, never a lazy default; the trailer is review triage only, never authority. Example: Confidence: medium — unsure: retry backoff bounds in queue.py; whether the legacy CSV importer still hits the new validator.

Effort Standard

Do not be lazy. Work as hard as you can for the full run on plan acceptance and blockers. Same drive on the last product batch as the first. Prefer deeper progress on the planned path over the minimum acceptable change.

Hard work does not mean mid-run nit perfection, nested full reviews, or re-running a large full suite between ordinary batches. Correctness on the impact path is non-negotiable; polish and full-suite attestation belong at terminal readiness (deferred hygiene).

Out-of-Scope Findings

A run notices things the plan does not cover. There are three destinations, and only one is right for work outside the plan:

What was noticed Destination Settled
In-scope nit, polish, full-suite attestation deferred hygiene terminal readiness, this run
Adjacent bug, test or doc, time remaining Scout Mode this run, as a commit
Worth doing, outside the plan GitHub issue a later run

Out of scope means the plan does not cover it and widening a batch to include it would change what the user accepted. Do not fix it, do not widen the batch, and do not drop it. File it:

gh issue list --search "<keywords>" --state all --limit 5   # never file a duplicate
gh issue create --title "<imperative and specific>" --body "<body>" --label enhancement

The body carries what and where (file:line), why it matters, why it was out of scope for this run, and the branch or PR that found it. Never a secret value: cite the location and the credential type, and recommend rotation.

Record every issue URL in the execution log and list them in the terminal report, so the run names what it deferred instead of leaving it in a transcript nobody re-reads. Without gh or without a repository, write the same entries to the run notes and say so in the report.

A run that files more than a handful is describing a different project than the one it was asked to build. Say that in the report rather than filing thirty issues.

Run Mode

Persist under ## Run Control. Finite (default) ends at completion. Open-ended continues until explicit stop or true blocker — checkpoints are not completion.

Open-ended rules

After every checkpoint, continue. Final Completion is disabled unless the user stops you. A final response is forbidden while Stop Gate says Stop allowed right now: no or continuation_guard.stop_allowed: false.

Pre-Final Guard

Before any final response: Did the user ask to stop? What does Run Control say? Does the Stop Gate allow stopping? Is work remaining? Audit the current state against every requirement at the current HEAD — do not rely on intent, partial progress, or memory of earlier work. If not justified, continue.

Discovery

Use this phase when the goal is open-ended and no task has been named yet: "what should we work on next", a structural-debt survey, a UX or security sweep, bug hunting, or backlog generation. When the user already named the work, skip straight to Planning.

Discovery is read-only on source. It may run the repository's own read-only checks (type-check, lint in check mode, dependency audit, a cheap side-effect-free test run) but writes nothing outside advisor-plans/. It runs before staging and is not a worker state: there is no readiness evidence, no landing authority, and nothing to merge. Implementation happens later, through the normal batch loop, once the user picks what to build.

The read-only boundary overrides open-ended escalation. Discovery shares its use cases with references/open-ended-guide.md, and that guide sends a saturated run into Scout Mode, which commits code. That escalation does not apply here. When findings saturate during Discovery, broaden the survey or file issues; do not enter Scout Mode, fix adjacent bugs, or modify source until the user selects work.

Method lives in references/audit-playbook.md: nine categories with what to look for in each, and a depth rule that scales the pass to repository size. Two contracts from that reference are binding:

  • Evidence. A finding cites file:line and a concrete effect. "Probably has N+1 queries somewhere" is not a finding; orders/api.ts:142 issues one query per order item inside a loop is. Never reproduce a secret value; cite the location and credential type, and recommend rotation.
  • Leverage. Rank by impact divided by effort, discounted by confidence and by how risky the fix is. "Not worth doing" is a valid verdict and is recorded with one line of reasoning, so the maintainer knows it was considered.

Selected findings become self-contained executor plans in advisor-plans/, one per finding, using references/finding-plan-template.md. Each plan assumes an executor with zero context: it has not seen this session, the survey, or the other plans. A plan that says "the pattern discussed above" is broken. That template is per-finding and is distinct from references/plan-template.md, which shapes a batched run.

Findings the user does not select are filed with gh issue create rather than carried in memory or fixed opportunistically, in the shape and with the guards described under Out-of-Scope Findings. Discovery differs only in volume: a survey is expected to produce several issues, where an ordinary run should produce few.

Planning

Interactive by default; autonomous expansion of brief prompts is allowed with user approval before execution. Required: plan, survival guide, learnings, execution log, active branch.

Plans express intent, acceptance, risk, caution, affected surfaces, constitution impacts, focused tests, review focus, dependencies, and optional checkpoints — without implementation choreography. See references/plan-template.md.

Staging

Launch only when: plan cleaned, run docs current, branch/PR recorded, preflight green, acceptance contract reconciled, run mode/non-negotiables recorded, no unresolved planning blockers. In single- kickoff E2E, continue immediately once launch-ready.

If Run Control Work driver ≠ host-native (or the run may be delegated), the standalone coordinator→implementer packet is written and its path recorded in Run Control and as worker_packet_path in .elves-session.json — staging is not launch-ready without it. The per-batch handoff block in the plan and the consolidated staging packet are not substitutes; see references/schema-and-acceptance.md. acceptance_contract.py validate warns (advisory, never blocking) when a delegable session lacks the recorded path. A session may opt into strict explicit handoff v1 by declaring top-level handoff state and the matching leading Markdown or JSON packet capsule; once declared, state/ownership/repository drift is blocking. The capsule does not turn a cold handoff into exact-session prewalk.

Preflight

git remote get-url origin
git push --dry-run 2>&1 | head -3
gh auth status 2>&1 | head -3
python3 "$ELVES_SKILL_ROOT/scripts/acceptance_contract.py" validate \
  --repo-root . --session .elves-session.json

One run owns one branch and one checkout. Prefer a dedicated worktree when other agents may touch the repo (./scripts/preflight.sh --create-worktree <branch> --base origin/main; --dry-run first). The helper prints the branch, worktree path, base ref, and collision tripwire, and does not reuse, delete, or repair existing worktrees. START_TIP is the collision tripwire.

Trusted full-run path (normal happy path)

  1. Stage once.
  2. One packet; launch trusted worker (branch_progress).
  3. Park. Follow sanitized stream by default (full-run-await; --quiet opt-out). No model inference; no timed chat updates. See references/follow-mode.md.
  4. Worker commits/pushes meaningful progress slices with concrete subjects.
  5. Native Grok goal mode only when capability-proven; otherwise record honest one-packet fallback.
  6. Wake on death, hangs, malformed completion, safety, blockers, material scope/assumption change, checkpoint, user input, or exit. Pushed progress survives recovery from the verified tip.
  7. Reconcile once. One cumulative terminal review. Consolidate blockers. Revise. Delta re-review.
  8. Attest readiness at exact HEAD. Terminal: landable PR, or merge only if authorized at that HEAD.

Host-native and legacy bounded routes still run the full per-batch loop below. Healthy trusted full-runs do not do per-batch driver review.

Core Loop (host-native / legacy bounded / worker-internal quality)

1. Orient

Survival guide → .elves-session.json → learnings → plan → execution log → .ai-docs/manifest.md → constitution → TODO.

2. Verify Green

Run gates; capture test baseline. Fix breaks before new work.

3. Rollback Ref

Host-owned refs/elves/rollback/<run-id>/<session-id>/bN-… (or single b0 for trusted full-run).

4. Contract

Behaviors, Build on, acceptance criteria, blast radius. Stable IDs B#-A# / [B#-A#].

5. Implement

Pre-implementation survey. Extend existing utilities. Write tests. Commit with progress subjects.

6. Validate

Impact path: changed surface → affected consumer → selected test. Touched-surface proof by default; broad at high-risk checkpoints and terminal (full suite or project full gate). Do not re-run a large full suite between ordinary batches when the impact path is green. Bug-fix protocol for blockers: category → category test → fix all. Queue pure advisories under Deferred hygiene (survival guide + execution-log digest); drain at terminal. Details: references/validation-guide.md.

7. Review

Mid-run: contract walk for this batch; no nested full product re-review of settled work. Terminal: one cumulative review only.

Reviewers read worker confidence trailers/report fields first and allocate attention accordingly: flagged unsure_about areas get a deeper pass. The signal is triage, never authority — it does not skip gates or waive review in either direction. A successful trusted full-run terminal monitor/await returns review_context.review_prompt_block; the coordinator attaches that machine-produced block verbatim to Final Readiness. For native Claude Code and Codex workers, build the same triage table from every Confidence: trailer in the cumulative commit history. The reviewer must return a Confidence-Guided Review section that names the deeper passes performed, or explicitly records that signals were partial/absent and baseline review was used. Claude Code and Codex use this identical contract. Independent feedback. Walk contract. Enforce code quality. Medium/high blast radius: regression pass. Fix blocking; advisory does not delay readiness (bank mid-run advisories as deferred hygiene). Resolve PR threads. PENDING-DOCS is not clean. Public API surface snapshots are optional regression evidence. Use existing structured sources before inventing scanners. If no credible source exists, record unavailable with the reason instead of fabricating a snapshot. A missing snapshot source is not blocking unless required: true was explicitly set in the survival guide. required: true is valid only when explicitly set by the user or project survival guide. Do not infer required mode from project type, provider config, framework choice, or the presence of API files. Snapshot artifacts are run artifacts, not product docs. Temporary snapshot artifacts should not remain in final product PR diffs unless the user explicitly asks. Record shapes and field names, not secrets, bearer tokens, cookies, customer payloads, or production sample data. A snapshot proves public surface shape only; it is not a substitute for tests, E2E checks, review, or the human-owned constitution. Record the public API surface delta when configured.

8. Legality Check

If a constitution exists: PASS / WARN / FAIL / UNCHANGED per intention. FAIL blocks.

9–12. Document, survival guide, commit/push, re-read

After every host-owned commit and push, re-read the survival guide before doing anything else. Do not wait for user acknowledgment.

13. PR Loop

Outside parked full-run: nonblocking new/unresolved poll after host pushes. Terminal readiness waits for required checks/reviewers. Trusted parked worker pushes defer host PR polling until wake.

14–15. Drift check when evidence warrants; continue or stop

Scout Mode

After planned batches, with time remaining: adjacent bugs, tests, docs. Commit format: [<branch> · Scout] <verb> <what changed>.

Forbidden Commands

Never: git reset --hard, git checkout ., git clean -fd, force push, rebase on shared branches, rm -rf outside scope, operating on another agent's checkout. Stop on unexpected tip moves (collision) outside the exact registered trusted full-run exception.

Merge Conflicts

Rule out collision first. Otherwise fetch and merge (no rebase). Complex conflicts → Hard Stop.

Test Integrity

Never weaken, delete, or skip a test merely to obtain green. Legitimate behavior-driven updates with preserved/improved coverage and evidence are allowed.

Compaction Recovery

  1. Survival guide (Stop Gate + Run Control first)
  2. .elves-session.json / continuation_guard
  3. Learnings → plan → execution log → .ai-docs → constitution
  4. Resume the single next required action immediately

Completion Contract

Landable is plan Acceptance with proof — not green CI + status: complete.

Before batch status: complete: impact gates green for this batch (not necessarily full-suite mid-run), regression attestation on the impact path, non-empty acceptance: [{id, criterion, met, evidence}], PR feedback triaged for blockers, legality clean for FAIL, docs current for owned surfaces, deferred hygiene updated, session JSON updated, commit pushed. God-file rule: structure locks alone do not complete a split batch unless plan Acceptance allows characterization-only. Prefer one batch per close commit. Terminal readiness still requires full suite (or project full gate) and drained deferred hygiene.

Landing check (installed):

python3 "$ELVES_SKILL_ROOT/scripts/elves_landing_check.py" \
  --session <session-path> --repo-root .

Session plan_path is authoritative; explicit --plan is only an equality assertion. An installed Elves bundle never requires a repo-only helper.

A repository may track .elves/landing-profile.json for bounded declarative project-specific checks. Schema v1 accepts path co-change checks and post-merge declarations but rejects executable checks. A missing profile is neutral; a present invalid or blocking-failed profile blocks readiness. The host recomputes live results and binds exact profile bytes, HEAD, resolved base and merge base, and normalized outcomes to a host-owned digest; worker reports cannot override them. Profiles never grant merge, tag, release, protected-ref, connector, secret, or posting authority. Hosts may record observations, synthesize candidates, and explicitly promote checks, or waive one blocking check at the exact HEAD; learning state is gitignored runtime data and never auto-promotes. See references/project-landing-profiles.md.

Constitution and the Legality Check

Correctness (gates) ≠ plan compliance (review) ≠ legality (judge). The human owns constitutional intentions. Agent drafts; human owns.

Proof and convergent review (v2.3)

See references/proof-and-review.md.

  • Impact-selected verification; evidence inputs + invalidation scope for reuse
  • Mid-run impact path only; terminal full suite + deferred hygiene drain
  • One cumulative review: completeness, constitution, declared risks, concrete regressions
  • Consolidate blockers before revision; advisory does not delay readiness
  • Re-review = revision delta + unresolved blockers only
  • New blockers need serious regression / acceptance or constitution breach / security / data integrity / revision-introduced failure
  • Cleanup-only operational changes do not invalidate product proof
  • Stop on sufficient exact-tip evidence, not absence of reviewer suggestions

Readiness Gate

Branch-level: execution log current, local proof green on current tip, project landing checks green at the current tip when a profile is present, preview/artifact proof when applicable, plan Acceptance with proof, landing check clean, final cumulative review clean, PR comments/checks polled, legality clean, strategic forgetting done, git clean.

Complete-without-merge and complete-and-merge share one readiness pipeline.

Elves Report

For substantial finite runs, generate static HTML before handoff covering problems found, lessons learned, batch timeline, verification proof, residual risks, and human next steps. Default path: /tmp/elves-report-<repo-slug>-<yyyy-mm-dd>.html. Use collapsible <details> sections for batch timelines. Keep committed examples and reusable templates non-identifying. Surface the Elves Report path in the final notification. No external assets/scripts. See references/elves-report-template.html.

Final Completion

Finite mode only. Acceptance-bearing Final Readiness Review before operational-artifact cleanup. The strict landing check runs on committed session evidence even when the target repository ignores .elves-session.json; see references/schema-and-acceptance.md for the force-add and cleanup sequence. Independent review subagent when available. Then remove survival guide / execution log / .elves-session.json from the PR (keep plan by default; keep learnings). Post-cleanup tip attestation. Notify with report path. Merge only if authorized — regular merge commit only. After an authorized merge, tear down the run's own recorded worktree (worktree_path): ./scripts/preflight.sh --gc-worktrees --path <worktree_path>, report first, then --apply; the cleanup.worktrees preference in config.json.example records whether teardown runs on merge, stays report-only, or never runs.

Staying Unattended

Never block on prompts. Non-interactive flags. Document decisions. Gates and helper subprocesses run with closed stdin and explicit timeouts — a silent hang is a failure, not progress. See references/autonomy-guide.md.

Ride-Along Protocol

Messages prefixed [ride-along], ride-along:, or ra:: handle in 1–3 sentences and continue. Explicit stop still halts.

Hard Stops

Genuine blocker; merge requested without authorization; destructive action listed as non-negotiable; collision on branch tip. Everything else: judgment + Decisions made.

Structured Session Data

.elves-session.json holds batches with per-id acceptance evidence, master_acceptance, continuation_guard, optional cobbler session state, model_routes, review_comments. After compaction, trust this file for status. When staging creates a dedicated worktree, record its path as worktree_path alongside run_id so post-merge teardown can tell the run's own worktree from operator-created ones (the schema tolerates extra keys).

Persistent Preferences

Safe worker convenience is shared by both hosts at ${XDG_CONFIG_HOME:-~/.config}/elves/config.json. Use cobbler_agents.py preferences show|set|reset; writes are private and atomic. Repository safety vetoes outrank everything; convenience precedence is explicit run intent, repository defaults, global preferences, then built-ins. Credentials or merge/destructive/protected-ref/approval-bypass authority are rejected. config.json when present also carries legacy batch sizing, notifications, review method, default branch, and cleanup. Cobbler under top-level cobbler (wins over legacy council). See config.json.example.

Skill Memory

Learnings and .ai-docs outlive a single run. Keep them curated. Id-tagged learnings (- [L3] …) are managed by the learnings ledger (cobbler_agents.py learnings validate|apply|rollback|digest|migrate): creates require an evidence pointer (execution-log entry or commit) and may record an (expect: …) validation note; retire moves entries under Retired Learnings (creating that section at EOF when missing), never deletes; every applied edit appends before/after to the tracked learnings-history.jsonl sidecar with inverse-edit rollback (one history row per edit — one rollback undoes only the latest row; repeat to walk further); the file is written before history so a crash cannot invent phantom applied edits; and the bounded ## Digest block is read first at orient, pulling full entries on demand. Freehand dated learnings stay fully valid; migrate is explicit and idempotent; the ledger never reflows, reorders, or rewrites content it did not edit.

v2.24 run tools (host-neutral)

The five v2.24 helpers — futile re-drive guard (redrive), learnings ledger (learnings), observed-usage ledger (usage), salvage previews (salvage), and the continuity watchdog manager (continuity) — are host-neutral CLI helpers with identical semantics on Claude Code, Codex, Grok Build, and Oh My Pi. Invoke as python3 "$ELVES_SKILL_ROOT/scripts/cobbler_agents.py" <verb> … from any host; do not invent per-host slash surfaces for them. They are advisory instruments (never landing, merge, credential, or routing authority). Continuity only writes OS timer templates — Elves never activates them. Usage ceilings are checkpoints, never stops. See the guide's "v2.24 run tools" section, references/host-parity.md, and AGENTS.md (Codex adapter pointer).

v2.22 runtime helpers (planning harvest, compact output, lanes)

  • Any-model worker pin: resolve_user_specified_worker_model + handoff cache keys (scripts/cobbler_runtime/worker_routing.py; references/adaptive-worker-routing.md).
  • Planning harvest: scripts/cobbler_runtime/planning_harvest.py (beacons, discovery, modes, lean summary, task sandbox, canvas, mission prep, goal assessor, review filter, merge-recovery lock).
  • Tool output compact: scripts/cobbler_runtime/tool_output_compact.py.
  • Parallelves: validate_lane_staging + LaneSupervisor in parallel_lanes.py.
  • Fugu module: scripts/cobbler_runtime/fugu.py (shim run_fugu.sh).

Optional surfaces (outside normal critical path)

Reports, notifications, provider routes, media generation, legacy bounded execution, and untrusted lanes remain useful but are not the default happy path.

Host parity

Claude Code, Codex, Grok Build, and Oh My Pi (omp) provide the same workflow and prewalk safety contract. Exact-session prewalk preserves the same qualification, trajectory, checkpoint, visibility, fallback, and authority semantics on every host; supervised transport syntax may differ. The v2.24 run tools (redrive, learnings, usage, salvage, continuity) share one CLI surface and one honesty boundary on every host — see v2.24 run tools (host-neutral) above and references/host-parity.md. Codex Goals are optional continuation plumbing — distinct from Grok Build goal mode.

Compatibility notes

  • Missing optional provider access never blocks a native run.
  • Record implementation_lane: fast | untrusted when using external work drivers.
  • Supported main drivers are Claude Code, Codex, Grok Build, and Oh My Pi (omp). Required prewalk qualifies the installed transport automatically; experimental prewalk is explicit and still fail-closed during the real trajectory. Grok as an optional worker under Claude/Codex remains consent-gated.
  • Compatibility: $elves setup-council remains supported.