Detailed design and innovations
Codant has its own agent harness, built from the ground up. This local runtime connects model calls, tool execution, task state, approvals, and acceptance. The first iteration is a minimal implementation of swarm coordination. A coding task can be split, agents can hand off work through a shared task tree, recorded feedback can guide later dispatch, and a user can verify delivery by task ID. The assembly entry point is createDefaultSwarm in packages/api/src/default-swarm.ts. Source paths in this guide are relative to the product repository root. Swarm intelligence and design · Codant source guide
Task card
↓ Check signals, threshold, capacity, budget, and write scope
Dispatch → Claim lease → Run → Result
├→ Signals → Later dispatch
└→ Candidate → Review and checks → ReceiptDecentralized work with local task authority
Decentralization applies to how agents coordinate the work. A Worker with delegation can propose a subtask and give the daemon its goal, acceptance requirements, and file scope. The child card records its parent and root task IDs, so later collaborators can find results and feedback along the task tree. One local daemon holds the runtime lock for each data directory. The pheromone bus uses its shared task store, and the daemon confirms claims and state transitions. See spawnSubtask in packages/api/src/scout-subtasks.ts and PheromoneBus in packages/core/src/bus/bus.ts.
A lease carries an agent identity, generation, and expiration time. The daemon checks the active lease when accepting progress, so a late result from a previous generation cannot count as work by the current claimant. Terminal and VS Code clients connected to the same runtime can observe the same tasks. Use the live snapshot for the current working set and the task ID for the full history. See the runtime lock in packages/api/src/daemon.ts, leases in packages/core/src/bus/lease-commands.ts, and snapshots in packages/api/src/swarm-hub.ts. Trace a task
Signal-guided dispatch with separate acceptance criteria
Ant colony optimization (ACO) inspired Codant to use signals in a shared environment so earlier results can influence later work. A finished subtask can leave a signal on its parent card. At dispatch, evaluateAndDispatch reads active signals. A trail can increase stimulus, doubt can lower it, and time in the queue can also increase it. The scheduler checks that value against a threshold for the caste and task type. A strong alarm tightens the parallelism limit on new dispatches. packages/api/src/scout-subtasks.ts · packages/core/src/ant/scheduler.ts
The runtime checks subtask model budget and considers caste slots, total capacity, delegation depth, file write conflicts, turn limits, and the stimulus threshold before it dispatches, queues, or rejects the subtask. It records the reason so collaborators can see which constraint applied. When the task is claimed, claim checks that it is eligible and that its dependencies have completed, then issues a new lease generation. From signals to a dispatch decision · Admission, leases, and write scopes
Dispatch reads active signals. Acceptance also checks the task and its descendants for unresolved alarms. When an alarm expires, for example, scheduling can reassess capacity using current signals while stageCompletion continues to block completion until the alarm is resolved. Short-lived feedback can expire while the outstanding delivery issue stays visible. packages/core/src/bus/views.ts · packages/core/src/bus/lease-commands.ts
File scope and budget bound parallel work
Suppose a change adds a new state to an interface. Separate Workers can handle protocol validation and rendering when their write scopes can be separated and capacity is available. If both subtasks need to edit the shared type file, one can queue until the scope becomes available. If an active ancestor already owns that file's write scope, spawnSubtask rejects the overlapping delegation so the parent can handle it directly. See packages/api/src/scout-subtasks.ts.
The root task and its subtasks share a model budget, and the hunt executor also limits delegation depth. A useful split therefore needs both a clear file boundary and enough budget to finish the work. Shared edits or a tight budget can reduce the number of agents that run. packages/api/src/scout-subtask-budget.ts · packages/api/src/scout-worker.ts · Delegation and asynchronous result collection
Review, checks, and write-back use the same candidate
A user can keep editing the workspace while a hunt runs. The candidate producer reads the retained starting baseline, the current target, and the isolated execution result to attempt a three-way merge. When it cannot produce a complete candidate, the workflow stops at that stage and retains the available results and history for inspection. packages/core/src/ant/hunt-merge-candidate.ts · The three-way candidate and its evidence
ScoutReview.review records hashes for the candidate, diff, and review report, then records the check certificate hash after checks complete. Write-back requires approval for the specific action and rechecks the candidate and target. For example, a change to either one while approval is pending stops that write-back. packages/api/src/scout-review.ts · packages/api/src/scout-publication.ts · Configure a reproducible check
The runtime also decides when to mark the shared task card complete. stageCompletion requires acceptance for the current lease generation, completed dependencies, cleared leases and active actions, and no cancellation, block, or unresolved alarm. The terminal and connected clients can use the task record to verify the candidate, checks, write-back, and completion state. packages/core/src/bus/lease-commands.ts · How a task reaches completion
Failure recovery preserves known facts
When the daemon restarts, planTaskRecovery marks interrupted tasks as failed and revokes their old leases. If an action started without a final receipt, recovery preserves its original identity and records its outcome as unknown. A write might already be on disk, for example. The retained action record, candidate, and current workspace can help determine what happened before further work. packages/core/src/bus/task-recovery.ts · Inspect task history and evidence
For a settled, required subtask that qualifies for retry, the parent can use retry_ant to explain the changed approach and request a replacement. The replacement gets its own record, and the original failure and evidence stay available. An unknown side effect calls for investigation first. Recovery can take longer, and each attempt remains traceable by its scope, evidence, and result. packages/api/src/scout-subtask-decisions.ts · Failure, cancellation, and recovery
