Prerequisites
Before you start, make sure you have:- The
wattswarmbinary built (cargo build --bin wattswarm) wattswarm-runtimebuilt and running (cargo run --bin wattswarm-runtime -- --listen 127.0.0.1:8787)- A node started with
wattswarm node up - The
rtexecutor registered (wattswarm executors add rt http://127.0.0.1:8787)
Creating a Task Contract
A task contract is the boundary object between your application and the WattSwarm kernel. It is a JSON document that tells the kernel what work to do, what a valid answer looks like, how much compute budget to allocate across execution stages, and when the task expires. Create a file calledtask.json in your working directory:
task.json
Field reference
| Field | Type | Purpose |
|---|---|---|
protocol_version | string | Contract schema version. Use "0.1" for the current kernel. |
task_id | string | Unique identifier for this task. Use any stable string — UUIDs work well. |
task_type | string | Must match one of the executor’s declared task_types from its /capabilities response. |
inputs | object | Key-value pairs forwarded as-is to the runtime /execute endpoint. The prompt key is the standard way to pass a natural-language instruction. |
output_schema | JSON Schema object | The kernel validates every candidate output against this schema before accepting it as a potential decision. |
budget.time_ms | number | Wall-clock budget in milliseconds for the entire task. |
budget.max_steps | number | Maximum number of execution steps allowed before the task is terminated. |
budget.cost_units | number | Total cost budget across all stages combined. |
budget.explore_cost_units | number | Hard cost gate for the explore stage. Execution cannot advance past this stage once the threshold is exceeded. |
budget.verify_cost_units | number | Hard cost gate for the verify stage. |
budget.finalize_cost_units | number | Hard cost gate for the finalize stage. |
budget.reuse_verify_time_ms | number | Time budget allocated for knowledge-reuse verification attempts. |
budget.reuse_verify_cost_units | number | Cost budget for knowledge-reuse verification. |
budget.reuse_max_attempts | number | Maximum number of reuse verification attempts before falling back to fresh execution. |
assignment | object | Claim and concurrency policy controlling how proposers and verifiers are scheduled. |
acceptance | object | Quorum threshold, voting policy, verification policy binding, and settlement configuration. |
expiry_ms | number | Unix epoch in milliseconds when the task expires. Set this far enough in the future that your execution chain can complete. |
evidence_policy.max_inline_evidence_bytes | number | Maximum byte size for inline evidence payloads. |
evidence_policy.max_inline_media_bytes | number | Maximum byte size for inline media evidence payloads. |
evidence_policy.inline_mime_allowlist | string array | MIME types permitted for inline evidence (e.g. text/plain, application/json). |
The
output_schema field is what vp.schema_only.v1 (the default verification policy) validates against. Make sure every required field your executor returns is declared here, or verification will fail.The acceptance.verifier_policy.policy_hash value must be the actual SHA-256 hash of the policy definition. When using task run-real, the kernel resolves this automatically. If you are submitting a raw task contract, run wattswarm executors check <name> to retrieve the correct hash for your runtime’s registered policies.Submit the Task
Submit the task contract to the kernel’s local event log:TASK_CREATED event. At this point the task exists but has not been executed yet.
Run the Task
Trigger the full execution chain using a registered executor:task run-real drives the complete lifecycle sequence internally:
Watch for Completion
If you want to poll the task state separately (for example, when running in compose where the worker drives execution asynchronously), use:Fetch the Decision
Once the task is finalized, retrieve the full decision record:Understanding the decision output
| Field | Meaning |
|---|---|
committed | The candidate ID that won the commit-reveal vote round. |
finalized | The candidate ID that passed finality proof verification. Matches committed when no fork was detected. |
candidate_output | The raw JSON object your executor returned as candidate_output from /execute. This is the actual answer. |
confidence | The confidence value your executor included in candidate_output (if present). |
finalized_at | Timestamp (ms) when DECISION_FINALIZED was emitted. |
evidence_summary | Array of evidence references (inline digests and external ArtifactRef URIs) that supported the winning candidate. |
Using the UI Console
If you prefer a visual interface, all of the above steps are available through the built-in kernel console. Start the UI server:- Node → UP
- Executors → ADD (name
rt, base URLhttp://127.0.0.1:8787) - Executors → CHECK
- Task → SAMPLE (optionally apply a preset)
- Task → SUBMIT
- Task → RUN-REAL
- Task → WATCH / DECISION
TaskContract Minimal Reference snippet and preset helpers for common task shapes (swarm / arbitrage / security).