Skip to content
Website ↗

Execution, review, and acceptance ​

Delivering file changes from a task card to a workspace requires a record of who executed it, which files were in scope, which candidate was reviewed and checked, and which publication operations were confirmed. This page follows the UTF‑8 import and export example through Codant's hunt workspace delivery path.

text
Accept and claim → delegate and execute → three-way candidate
                → Soldier review and selected checks
                → approval and publication
                → confirm evidence and close resources → complete

Admission, leases, and write scopes ​

When accepting a task, the daemon retains the original submission plan and creates a root task card. On execution, it claims the card and binds the same agent and lease generation to the task and write scope. The project path and model are confirmed before admission. Work runs in a directory prepared for the task, with the original baseline retained for computing changes. See task leases

A worker declares write targets when proposing a subtask. The runtime uses the actual workspace root, resolved targets, and available file identity to detect conflicts. Scouts are read-only. A worker with an empty file declaration is treated as writing the whole workspace for conflict detection. For example, siblings that write separate import and export implementations can run in parallel. A sibling that needs a helper reserved by a running task queues and has its scope rechecked before dispatch. A proposal that overlaps an active parent or ancestor's write scope is rejected, so it cannot wait for a reservation held by its own ancestor.

See ScoutTaskExecutor.submitHunt and ScoutRootDispatch.run in packages/api/src/scout-task-executor.ts:67 and packages/api/src/scout-root-dispatch.ts:77. See lease binding in packages/api/src/scout-execution.ts:150 and scope checks in packages/core/src/ant/write-domain.ts:230, packages/core/src/ant/write-scope.ts:128, and packages/api/src/scout-subtasks.ts:575.

Delegation and asynchronous result collection ​

The root worker can use the internal spawn_ant tool to request one level of scout or worker subtasks. The host checks the parent's current execution identity and registered lineage before creating a child card. Children share the root task's model token budget. A card can queue if other active requests temporarily hold the capacity it needs. Admission is rejected if the shortfall is permanent. A scout child uses read-only tools and returns an answer without reserving files for writing. A write subtask inherits the parent's selected checks or can request a subset.

spawn_ant returns an ID once the child is dispatched or queued. The parent can continue its work and later use wait_ants to collect the status of its direct children by ID. With timeoutS=0, the tool reads a snapshot. If a positive wait expires, the runtime requests cancellation for children that have yet to reach a terminal state. The result distinguishes task status, cancellation requests, and resource cleanup. A preview of the original answer is available only if the child completed, met its acceptance criteria, and its original resources have settled.

See packages/api/src/scout-worker.ts:115, packages/api/src/scout-subtasks.ts:540, and packages/api/src/scout-subtask-plan.ts:44 for delegation. See packages/core/src/model/token-budget.ts:170 and packages/api/src/scout-subtask-budget.ts:62 for the shared budget, and packages/core/src/ant/delegate.ts:375, packages/api/src/scout-subtask-wait.ts:30, packages/api/src/scout-subtask-wait.ts:65, and packages/api/src/scout-subtask-wait.ts:127 for waiting and cancellation.

The three-way candidate and its evidence ​

The runtime builds a complete candidate from three trees. base is the retained execution baseline, ours is the current merge target, and theirs is the execution result. This accounts for edits a developer may have made to the workspace while the task ran. A conflict or incomplete candidate leaves its artifact information available and stops the handoff or publication. A validated child candidate can be handed into the parent's execution directory before the root task handles delivery to the actual workspace.

A Soldier independently reads the task card and candidate diff. The runtime records the task, agent, generation, and SHA-256 digests of the candidate, diff, and review report. A fail verdict or critical finding records an alarm and blocks delivery. When review clears, the host runs the configured and selected checks against the same candidate, verifies their certificate, and ties it to the candidate as evidence. The candidate's success signal belongs to this validation stage. See caste responsibilities

See the three-way inputs in HuntMergeCandidateProducer at packages/core/src/ant/hunt-merge-candidate.ts:137, completeness and handoff in packages/api/src/scout-execution.ts:734 and packages/api/src/scout-handoff.ts:193, and review and check-plan handling in packages/api/src/scout-review.ts:133, packages/api/src/scout-review.ts:164, and packages/core/src/ant/hunt-check-plan.ts:204.

Approval, publication, and receipts ​

For a candidate that changes the workspace, the host creates a publication plan bound to the original target state, candidate, and check plan. The hunt_publish approval includes the publication preview and action identity. After approval, the host rechecks current execution authority, the target, and the candidate's validation certificate, then installs the approved changes. Each operation's start and confirmation are tied to the original plan. A successful publication receipt requires confirmation of the target and every operation in the plan.

When approval is declined, the candidate and history remain available for inspection. If installation was dispatched and its result is uncertain, the host retains the action and artifact records. The bus marks an unknown action outcome as blocked so the state can be checked using the original task and receipt. These boundaries let a developer distinguish acceptance, candidate creation, candidate validation, and completed workspace delivery.

ScoutPublication is in packages/api/src/scout-publication.ts:46. See approval, per-operation confirmation, and failure recording in packages/api/src/scout-publication.ts:156, packages/api/src/scout-publication.ts:195, and packages/api/src/scout-publication.ts:254. See action receipts in packages/core/src/bus/action-commands.ts:181.

Failure, cancellation, and restart recovery ​

If a required child fails, its parent can use retry_ant to request one replacement attempt with an explanation and a concrete change in method. The runtime checks that the original task and its descendants have settled, action outcomes are known, alarms are resolved, and the original check selection and write scope can be reused. An accepted replacement receives a new ID in the same transaction that updates the parent's dependency. The original failure and its results stay available. Repeating the complete request with the same decision ID looks up the existing decision.

The parent can also use abandon_ant with a reason to request cancellation of the parent task and its original descendants. A permanent determination that replay is unsafe, or failure of the sole replacement attempt, can also trigger cancellation. After acceptance of a cancellation request, use the original task ID to confirm whether execution and resources have settled.

On restart after an interruption, the daemon verifies stored task records, marks nonterminal cards as failed due to the interruption, and revokes old leases. Actions that were still in progress retain their original identity and receive an unknown outcome for investigation. Restart recovery restores the task record without rerunning those actions. Use codant task show <task ID> and codant task evidence <task ID> to inspect the original task.

See packages/api/src/scout-subtask-decisions.ts:138, packages/api/src/scout-subtask-decisions.ts:239, packages/api/src/scout-subtask-decisions.ts:356, packages/api/src/scout-subtask-decisions.ts:377, and packages/core/src/bus/delegation-commands.ts:250 for retry and cancellation. See packages/core/src/bus/task-bootstrap.ts:27 and packages/core/src/bus/task-recovery.ts:59 for restart recovery.

How a task reaches completion ​

The host records delivery evidence tied to the original artifact, candidate, and check plan, confirms that check and artifact resources are closed, and submits acceptance for the current generation. ActionCommands.complete stages acceptance, lease release, and the terminal check in one bus command. stageCompletion checks the acceptance generation, completed dependencies, absence of active actions or a remaining lease, and resolved alarms across the task and its descendants. A failed condition prevents the command from committing completion. An expired alarm still needs to be resolved.

After delivery, run /ants changes <task ID> in the TUI to view the result. codant task show <task ID> and codant task evidence <task ID> expose status and evidence. See packages/api/src/scout-execution.ts:797, packages/core/src/bus/action-commands.ts:135, packages/core/src/bus/lease-commands.ts:164, and packages/cli/src/task.ts:109.

Source references identify symbols and lines in the Codant development version.