---
name: execute-dag-node
description: Execute or resume one DAGrail task, gate, decision, or effect node. Use when a work package names a stable Role and Node, when replacing a prior worker session, or when checkpointing and finishing an assigned attempt.
---

# Execute one DAGrail node

Operate only the stable Role and Node named by the work package. If neither is named,
do not guess a Role or acquire a lease; ask the DAG controller for an assignment.

1. Bind that Role to this harness session. Never reuse a session bound to another
   formal Role. Use takeover only after the former lease expires.
2. Call `dag_context` with `view: worker`, `role_id`, and `node_id`. Treat its cursor,
   checkpoint, resource refs, and `allowedActions` as authority. Follow an opaque ref
   with `dag_inspect` only when the bounded package is insufficient.
3. Apply only the current `allowedActions[].ref` with a stable idempotency key. Never
   construct a transition, outcome envelope, hash, or resource ID yourself.
4. Start with `node.start` or continue the current Attempt. After material progress and
   before yielding, apply `attempt.checkpoint` with a replacement-ready summary and
   digest-only evidence refs. Exclude prompts, secrets, transcripts, and artifact bodies.
5. Publish material execution through `evidence.publish`. Bind the candidate,
   prospective tree, command graph, protected inputs, observations, artifact digests,
   and provenance; keep large objects in their external store.
6. Close every active resource with its returned `resource.close` action. A failed or
   unknown receipt keeps capacity leased: use the later `resource.reconcile` action and
   do not complete the Attempt until closure is confirmed.
7. Use the NodeKind-specific terminal action:
   - task: `attempt.submit`, then `task.complete` for a success outcome;
   - decision: `decision.record` with one declared outcome and bounded evidence;
   - gate: `gate.evaluate` with the declared provider input—never invent its outcome;
   - effect: `effect.prepare`, reconcile `unknown`, then `effect.complete` only when the
     receipt state supports the chosen outcome;
   - custom kind: the exact terminal action returned by DAGrail.
8. Call `dag_pre_wait` before becoming passive. Address work owned by this Role; report
   other ready, submitted, incident, lease, or effect items to the controller.

A native harness resume restores transport only. DAGrail's Role lease, Attempt,
checkpoint, Decision records, and receipts remain the recoverable authority.
