Skip to content
Like what we’re building? Star on GitHub

DSL errors, persistence and resume ​

Read it when a run fails, resumes or rewinds, or a checkpoint looks torn (docs/resume.md carries the operator view).

Error Handling ​

  • RuntimeError (pkg/runtime/errors.go) — structured error with Code (type ErrorCode), Message, NodeID, Hint, Cause
    • Codes: NODE_NOT_FOUND, NO_OUTGOING_EDGE, LOOP_EXHAUSTED, BUDGET_EXCEEDED, EXECUTION_FAILED, WORKSPACE_SAFETY, TIMEOUT, CANCELLED, JOIN_FAILED, RESUME_INVALID
  • Diagnostics (pkg/dsl/ir/compile.go, pkg/dsl/ir/validate.go) — compile-time warnings/errors with sparse codes C001–C199 plus the C2xx async/bundle families (unknown refs, routing issues, unreachable nodes, undeclared cycles, attachments, presets, capability checks (C080–C082), cursor declarations (C083–C086), etc.; the codes live in pkg/dsl/ir (diagnostics_codes.go and the per-feature files beside it))
  • Sentinel errors: ErrRunPaused (resumable), ErrRunCancelled (resumable with checkpoint), ErrBudgetExceeded
  • Resumable failures: Most runtime failures produce failed_resumable status with a checkpoint. See docs/resume.md for the exhaustive matrix.

Refusals before the engine ​

pkg/runner/pre_engine_refusal.go records the runner's refusals before Engine.Run/ResumeWithHostInputs: workflow/IR loading, budget overrides, credentials, repository pin/workspace, MCP, executor, bundle, engine requirement, usage admission and launch inputs. It returns the original error; delivery classification, retry scheduling and refused-resume release keep their owners. The AST inventory follows each launch/resume branch; executable pipeline cases in pkg/runner cover these sites; engine success, pause and failure do not enter this recorder.

The optional store.PreEngineRefusalRecorder has filesystem and Mongo twins. One atomic write checks both eligible status and publication time, including an already-running run: an older delivery cannot overwrite a newer attempt. An unmarked legacy delivery writes only an unmarked run. Generic queued retries keep their checkpoint, answered interaction, inputs and outcome unchanged; Run.PreEngineRefusal and Run.Error explain why the delivery is pending. Usage parking still creates the failed-resumable state its retry scheduler requires. IR and engine-version refusals retain their typed final verdicts, except when the existing queued-resume releaser owns the transition.

The diagnostic belongs to the store: SaveRun preserves it for the same status/publication, ignores caller-authored copies and clears it on a changed attempt. A changed message or failure code clears the old cause even on the same status; rearming the same cause preserves it. Claim, new publication, pause, cancellation and completion clear it. Snapshots clone the diagnostic. The filesystem store rejects a mismatched persisted run ID or tenant; historical local runs without a tenant keep their existing local-store semantics.

Only a successful write emits an event: run_pre_engine_refused for a still queued delivery, run_failed for a written failure. Document and event writes are not transactional. Missing capability, stale attempt, malformed publication, store failure or event failure is logged; none replaces the original error or falls back to an unfenced status write. Recording uses a bounded context that survives cancellation of the execution context.

Store & Persistence ​

<store-dir>/runs/<run_id>/
  run.json              # Run metadata (status, inputs, checkpoint)
  attempts/<sha256>.json     # Immutable source/resources and effective budget per attempt
  events.jsonl          # Timestamped events (one per line, monotonic seq)
  artifacts/<node>/<v>.json   # Versioned node outputs
  interactions/<id>.json      # Human interaction records (questions/answers)
  report.md             # Generated by `iterion report` — chronological run report

The checkpoint embedded in run.json is the authoritative source for resume — events are observational only. See docs/persisted-formats.md for field semantics.

Run statuses: queued (cloud mode only — submitted to the NATS queue, not yet claimed by a runner pod) → running → paused_waiting_human or paused_operator → finished | failed | failed_resumable | cancelled

Key event types: run_started, node_started, llm_request, llm_retry, tool_called, artifact_written, human_input_requested, run_paused, run_resumed, join_ready, edge_selected, budget_warning, budget_exceeded, budget_exit_grace, run_finished, run_failed

Resume from Failed/Cancelled Runs ​

The engine saves a checkpoint after every successful node execution. When a run fails or is cancelled, the checkpoint is preserved, enabling iterion resume to restart from the failing node without re-executing upstream nodes.

Resumable statuses: paused_waiting_human (needs answers), failed_resumable (automatic retry), cancelled (user-interrupted, checkpoint preserved)

Execution failures routed through the checkpoint-aware path are resumable, including a failure on the first node (resume starts from the workflow entry when no older checkpoint exists). Reaching FailNode is intentional workflow termination and produces non-resumable failed; bootstrap/persistence failures that cannot save resumable state can also end as plain failed.

Common resumable failures: transient LLM errors (rate limit, timeout), budget exceeded (increase budget + resume), schema validation errors (fix workflow + --force), context timeout/cancellation, fan-out branch failures, router failures.

--force flag: allows resume even when the .bot source has changed (e.g., bug fix). Without --force, a hash mismatch produces an error. It never accepts the loss of the run's scratch (SCRATCH_NOT_PORTABLE): --accept-scratch-loss does (ADR-106).

See docs/resume.md for the current status, checkpoint, and override semantics. The console selects an immutable attempt snapshot; a resume with edited source never replaces the previous attempt's graph.

A tool command that fails the same way again ​

handleNodeFailure (pkg/runtime/recovery_dispatch.go) is the one place a trunk node's failure is counted, dispatcher wired or not. For a command: / script: tool node classified EXECUTION_FAILED it keeps a salted digest of the failure (exit status + error text) and its streak in Checkpoint.NodeFailureStreaks; at ITERION_NODE_MAX_IDENTICAL_FAILURES (default: the ONE constant DefaultNodeMaxIdenticalFailures; 0 off; runner-wide) the run fails TOOL_FAILED_PERMANENT with *runtime.IdenticalToolFailure as cause (identical_failure.go). The limit counts EXECUTIONS across deliveries — two in a run's first delivery, one per redelivery. Counted (countedToolFailure): the command ran to an exit status its failure carries, and its text carries no wording of transient_outage.go, the ONE table of known outage wordings (a list, judged on the corpus in transient_outage_test.go; it changes no classification; a 4xx on a tool's own line and a proxy's 403/407 are refusals, counted — git's RPC-stage refusal trails its hang-up line and is not). Success, an uncounted or different failure and a rewind end the streak; a resume does not. Never counted: agent/judge nodes, registry and action: recipes, policy: recover, a postcondition unmet after a zero exit, sandbox.ErrExecStatusUnknown, NETWORK_TRANSIENT, a tool node inside a fan-out branch (branches never cross handleNodeFailure). The board dispatcher gives up at once on the code (pkg/dispatcher/commands.go). Operator view: docs/resume.md.

Concurrency ​

  • Fan-out/convergence: Router fan_out_all spawns parallel branches; downstream nodes aggregate via await: wait_all or await: best_effort
  • Semaphore: buffered channel enforces max_parallel_branches budget
  • Workspace safety: only one mutating branch allowed (agents/humans with tools); multiple read-only branches OK
  • Shared budget: mutex-protected token/cost/duration tracking across all branches

Admission, correction bounds and the rollout mode ​

The reliability invariants of #1006 have owning layers, mapped in ADR-152; the published ledger is docs/workflow-reliability-1006.md, where a criterion reads met only when a NAMED test refuses its violation — three guards in pkg/reliability pin the row count, the existence of every witness and every owner link.

  • Admission (admitRun, pkg/runtime/admission.go) runs after the run document exists and before attachments, workspace setup or the first executor call, at launch AND at resume. It compares the normalisation error, the workflow revision against the run hash, the lineage, and the runner-expected revision/parent/policy; it does NOT compare the declared stores (RunStore, BusinessStores) — that half is owed a store-identity seam first. Every outcome is a durable AdmissionDecision: legacy records it unvalidated, report records and surfaces without refusing a run, enforce denies with FailureLaunchFailed.

  • Correction is bounded at the producer, on two shipped paths. A tool node's unmet postcondition goes through ADR-044's ladder (pkg/backend/model/executor_verified_action.go) under the author's declared max_repair_attempts / max_agent_attempts, with the postcondition as the only success oracle and a durable node_verified_action event — one bound answering to no test, the self-repair rung's attempt COUNT, which is why criterion 4 reads partial; the self-repair rung runs only for a command or a script recipe (ir.ToolRecipeSelfRepairable: a registry recipe has no corrected command to re-run, and C179 warns when that leaves no rung reachable).

  • Schema correction keeps the caller's durable allowance when the executor and store participate in the owned protocol. An agent or judge's feedback re-ask and optional structured extraction are distinct operations: each needs its own reservation and usage receipt. The extraction's bill is additive and keeps its actual credential route. An LLM router retains its local correction path. The allowance is configurable; see ITERION_OUTPUT_CORRECTION_BUDGET and the runtime options. Invalid parse feedback retains the raw parse diagnosis. Typed invocation stops are preserved; an auxiliary provider's credential error does not become the business node's authentication failure.

  • Correction restart limit: the pending extraction phase lives on the invocation's opaque handle. Cancellation between re-ask and extraction preserves the durable allowance but does not reconstruct that phase: a new engine resumes through a fresh business invocation/re-ask using the remaining correction allowance. This is also the legacy path's behavior, not exact continuation. TestOwnedExtractionRestartPreservesAllowance witnesses the limit; TestOwnedExtractionAllowanceAndControl proves separate reservations and stop handling. Owned recovery events describe persisted transitions, so an unchanged answer can follow attempt directly.

  • The rollout mode (ITERION_RELIABILITY_MODE, pkg/reliability/rollout.go) is the operator's FLOOR and its emergency cap: an explicit legacy is a cap no level overrules, a level may raise the gate and never lower it, and the database level above it is ADR-132 / #2699 territory. It is operator-grade refused to bots and to .env files (internal/envtrust), so no repo-provided environment sets it.