create_task() asserts config.active_tasks_count == 0, meaning a user can only ever have one active task at a time. The active_tasks_count field already supports values greater than 1 — the restriction is a single assert, not a structural limit.
This is unnecessarily restrictive. An orchestrator serving a user with multiple parallel steps (already supported in executor.ts) must currently serialize all tasks sequentially at the contract level.
Change in create_task():
Remove:
assert!(config.active_tasks_count == 0, "User already has an active task");
Replace with a balance check only — if the user has sufficient available balance for the new task's plan_cost, the task should be allowed regardless of how many tasks are already active:
// `available` is already computed below; the assert on it is sufficient
The existing available >= plan_cost assert already prevents over-commitment. No other guard is needed.
Test updates:
test_create_task_already_active_fails should be renamed and updated to verify that a second task succeeds when balance is sufficient, and fails only when available balance is insufficient.
- Add a test for two concurrent tasks completing independently.
Acceptance criteria
Relevant files
contracts/agent-vault/src/lib.rs (only the create_task function)
contracts/agent-vault/src/tests.rs
Notes for contributors
If you'd like to work on this, comment below so we can assign it to you.
Questions welcome — see CONTRIBUTING.md for setup
and workflow.
create_task()assertsconfig.active_tasks_count == 0, meaning a user can only ever have one active task at a time. Theactive_tasks_countfield already supports values greater than 1 — the restriction is a single assert, not a structural limit.This is unnecessarily restrictive. An orchestrator serving a user with multiple parallel steps (already supported in
executor.ts) must currently serialize all tasks sequentially at the contract level.Change in
create_task():Remove:
Replace with a balance check only — if the user has sufficient available balance for the new task's
plan_cost, the task should be allowed regardless of how many tasks are already active:// `available` is already computed below; the assert on it is sufficientThe existing
available >= plan_costassert already prevents over-commitment. No other guard is needed.Test updates:
test_create_task_already_active_failsshould be renamed and updated to verify that a second task succeeds when balance is sufficient, and fails only when available balance is insufficient.Acceptance criteria
create_task()no longer panics whenactive_tasks_count > 0active_tasks_countis correctly incremented/decremented through the full lifecycle of two concurrent taskscargo testandcargo clippy -- -D warningspassRelevant files
contracts/agent-vault/src/lib.rs(only thecreate_taskfunction)contracts/agent-vault/src/tests.rsNotes for contributors
If you'd like to work on this, comment below so we can assign it to you.
Questions welcome — see CONTRIBUTING.md for setup
and workflow.