When AI providers charge per task instead of per token, the evidence trail disappears inside the task boundary. AI-TASK.1 creates a Merkle-bound record of every constituent step, enabling independent verification of completeness, cost, and outcome.
New in v8.3 • AI-TASK.1 ships in both Python and TypeScript SDKs. Context manager pattern auto-captures inferences as task steps. Merkle-bound outcome attestation with 4 clearing levels and cost reconciliation across 4 trust tiers. pip install swt3-ai or npm install @tenova/swt3-ai
Who this is for: AI auditors and assessors evaluating task-based AI billing, model risk examiners under SR 11-7, EU AI Act conformity assessors verifying Article 12 automatic recording, platform engineers integrating composite AI workflows, and financial controllers reconciling AI operational costs.
Token-based pricing created an observable relationship between work performed and cost incurred. A model consumed 4,000 input tokens and produced 800 output tokens; the cost was deterministic, the evidence was the token count, and reconciliation was arithmetic.
Task-based pricing changes the equation. A provider charges $0.15 for a "research task" or $0.04 for a "code review." The number of inferences inside that task boundary is opaque. Did the provider run one inference or five? Were there failed retries that consumed resources but produced no output? Did a chain-of-thought decomposition spawn sub-tasks that the caller never requested?
The problem is not that task-based pricing is inherently unfair. The problem is that there is no independent evidence of what happened inside the task boundary. The provider declares an outcome and a cost. The consumer accepts or disputes, but has no basis for either beyond trust.
For regulated industries, this gap becomes an audit finding. SR 11-7 requires ongoing monitoring of model outputs and their costs. EU AI Act Article 12 requires automatic recording of events that enable traceability. ISO 42001 Clause 9.1 requires measurement, analysis, and evaluation of AI system performance. When the work product is a "task" and the evidence is a single invoice line, none of these requirements can be satisfied.
Assessor Note
The absence of task-level evidence is not a hypothetical future problem. Organizations that have migrated from token-based to task-based AI pricing often discover during examination that their cost monitoring controls no longer function. The granular token data that previously satisfied SR 11-7 model performance monitoring disappears behind the task boundary. Ask the organization what evidence they retain for each AI task, and how they reconcile declared costs against observed work.
A property and casualty insurer uses an AI workflow to triage incoming claims. The workflow is a single "task" from the provider's perspective, billed at $0.08 per claim. Inside that task boundary, three things happen:
The model reads uploaded images, PDFs, and repair estimates. It classifies each document by type (police report, medical record, repair estimate, witness statement) and extracts structured fields. This is one inference.
Using the extracted data, the model scores the claim on a severity scale (minor, moderate, major, catastrophic) and estimates reserve requirements. The reserve estimate feeds downstream actuarial models. This is a second inference.
Based on severity, policy limits, and historical patterns, the model routes the claim either to a human adjuster or to an automated fast-track settlement path. This is a third inference, and it determines whether a human ever reviews the claim.
The insurer pays $0.08. What they receive is a routing decision. What they do not receive is evidence that all three steps occurred, that the severity assessment informed the routing decision (and not the other way around), or that the document classification was complete before the severity model ran.
When the state insurance commissioner asks how the insurer ensures that AI-routed claims receive equivalent treatment to human-reviewed claims, the insurer has an invoice and an output. No chain of evidence. No proof of completeness. No cost breakdown.
Assessor Note
The critical question is not whether the task produced a correct output. It is whether the organization can demonstrate that the declared process actually occurred. If the provider's documentation states that every claim passes through three stages, the evidence should independently confirm three distinct inference events, in sequence, for each claim. A single task-level record does not establish that.
Task outcome is cryptographically bound to constituent inference evidence. A Merkle root computed from all sub-step anchor fingerprints proves completeness (step count matches leaf count), integrity (no post-hoc modification), and cost reconciliation (witnessed cost vs declared cost).
| Factor | Label | Encoding |
|---|---|---|
factor_a | Step count | Number of sub-inference anchors in the task. Must be ≥ 1 for PASS. |
factor_b | Cost reconciliation ratio | witnessed_cost / declared_cost × 1000. A value of 1000 means exact match. Above 1000 means overcharged. Below 1000 means undercharged. 0 means cost data unavailable. |
factor_c | Outcome status | 0 = completed, 1 = partial, 2 = failed, 3 = timeout, 4 = abandoned |
PASS: outcome_status == completed (0) AND step_count ≥ 1 AND merkle_root present.
FAIL: outcome_status is not completed, OR step_count is 0, OR merkle_root is missing.
| Code | Type | Description |
|---|---|---|
| 0 | inference | Single-turn or multi-turn conversation |
| 1 | workflow | Multi-step pipeline (RAG, chain-of-thought) |
| 2 | agent_loop | Autonomous agent with tool use |
| 3 | code_generation | Code writing, review, or debugging |
| 4 | research | Information gathering and synthesis |
| 5 | assessment | Evaluation, grading, or classification |
| 6 | transformation | Data transformation or format conversion |
| 7 | orchestration | Multi-agent coordination |
| 8 | custom | Application-defined task type |
The terminal AI-TASK.1 anchor contains a task envelope in its observations.ai_context field. The envelope records everything an auditor needs to verify the task without accessing the original inference data.
| Field | Description |
|---|---|
task_id | Deterministic identifier: TASK-{SHA256("TASK:{tenant}:{chain_id}:{timestamp}")[:16]} |
task_type | Code from task type table (e.g., "workflow") |
lifecycle_chain_id | Links to all constituent step anchors in the lifecycle chain |
outcome_status | Terminal status code (0-4) |
outcome_hash | SHA-256 of the caller's declared outcome description |
step_count | Number of sub-inference anchors (must match Merkle leaf count) |
merkle_root | SHA-256 Merkle root computed from all step fingerprints |
step_procedures | Distinct procedure IDs witnessed (e.g., ["AI-INF.1", "AI-TOOL.1"]) |
cost_declared | Provider's stated cost in USD microcents |
cost_witnessed | Sum of token-based cost estimates from individual steps |
cost_ratio | witnessed / declared × 1000 |
cost_source | Trust level: 0 = manual, 1 = SDK estimated, 2 = provider API, 3 = invoice verified |
duration_ms | Wall clock time from task start to finalization |
agent_ids | Distinct agent identifiers involved (hashed at clearing level 1+) |
tool_call_count | Total tool invocations across all steps |
Assessor Note
The step_procedures field reveals what types of work occurred inside the task. If an organization claims their claims triage involves document classification, severity assessment, and routing, but the step_procedures array contains only ["AI-INF.1"] with no AI-TOOL.1 entries, the documented process does not match the observed evidence. This is a verifiable discrepancy that requires no access to the underlying inference data.
Each sub-inference inside a task produces an anchor with a 12-character fingerprint. When the task completes, those fingerprints become leaves in a Merkle tree. The resulting root is stored in the terminal AI-TASK.1 anchor.
Daily Rollup Root (server-side)
|
+-- Session Root (MerkleAccumulator)
| |
| +-- Task Root (AI-TASK.1) <-- stored in observations.merkle_root
| | +-- Step fingerprint (AI-INF.1) <-- document classification
| | +-- Step fingerprint (AI-INF.1) <-- severity assessment
| | +-- Step fingerprint (AI-TOOL.1) <-- routing decision
| |
| +-- Task Root (AI-TASK.1)
| | +-- Step fingerprint (AI-INF.1)
| |
| +-- Standalone anchor (AI-DRIFT.1, no task)
|
+-- Session Root
...
This creates two independent verification paths:
merkle_root in the AI-TASK.1 anchor, the step set is complete and unmodified.The key property: the task Merkle root lives inside the observations of the AI-TASK.1 anchor, while the AI-TASK.1 fingerprint participates in the session and daily Merkle trees. Modifying the step set changes the task root, which changes the AI-TASK.1 anchor's content, which changes its fingerprint, which invalidates every Merkle proof that includes it.
Assessor Note
To verify a task attestation, retrieve the lifecycle chain (GET /api/v1/witness/chain?chain_id={lifecycle_chain_id}), collect the step fingerprints, sort them lexicographically, compute the Merkle root using domain-separated hashing (SWT3:LEAF: prefix for leaves, SWT3:NODE: prefix for internal nodes), and compare to the stored merkle_root. A match proves the step set has not been altered. This verification requires no proprietary tooling. The hashing algorithm is SHA-256; the domain separation prefixes are published in the protocol specification.
The cost reconciliation ratio (factor_b) expresses the relationship between what was witnessed and what was declared. It is a consistency check, not a fairness determination.
| Ratio | Interpretation | Implication |
|---|---|---|
| 1000 | Exact match | Witnessed token costs equal the declared task cost |
| > 1000 | Overcharged | Declared cost exceeds witnessed token costs |
| < 1000 | Undercharged | Witnessed token costs exceed the declared cost |
| 0 | Unavailable | No cost data was provided or computed |
Not all cost data is equal. The cost_source field records where the cost figure originated:
| Code | Source | Trust Level | Auditor Guidance |
|---|---|---|---|
| 0 | Manual | Lowest | Caller entered a number. Zero inherent trust. Flag for corroboration. |
| 1 | SDK estimated | Medium | SDK computed cost from token counts using model pricing tables. Pricing tables may be stale. |
| 2 | Provider API | High | Cost retrieved from the provider's billing or usage API. Subject to API accuracy. |
| 3 | Invoice verified | Highest | Reconciled against a provider invoice or Stripe charge. External corroboration exists. |
Assessor Note
A cost_ratio of exactly 1000 with cost_source of 0 (manual) is a red flag. It means someone typed in a cost figure that happens to match perfectly. This combination warrants inquiry into how the cost was determined. Conversely, a cost_ratio of 1000 with cost_source of 3 (invoice verified) is the strongest evidence available: the numbers match and there is external documentation.
The task envelope respects the same four clearing levels as all SWT3 anchors. Higher clearing levels progressively remove fields from the envelope while preserving the cryptographic factors that enable verification.
| Level | Name | Retained Fields | Removed Fields |
|---|---|---|---|
| 0 | Analytics | All fields, including cleartext declared_outcome | None |
| 1 | Standard | All fields except cleartext outcome. outcome_hash replaces declared_outcome. Agent IDs are hashed. | declared_outcome (replaced by hash) |
| 2 | Sensitive | task_id, outcome_status, outcome_hash, step_count, merkle_root, step_procedures, duration_ms, timing fields, tool_call_count | task_type, all cost fields, agent_ids, lifecycle_chain_id |
| 3 | Classified | Factors only (factor_a, factor_b, factor_c) | Entire envelope including merkle_root |
At clearing level 2, the Merkle root survives but cost and identity data are removed. An auditor can still verify that the declared steps match the Merkle tree, but cannot see who was involved or what was spent. At clearing level 3, only the numeric factors remain: step count, cost ratio, and outcome status. The Merkle root is stripped. This is by design: classified environments require provable existence of a task (via factors) without disclosing its structure.
Assessor Note
When evaluating an organization that uses clearing level 2 or 3, verify that the clearing level selection is documented and justified. Clearing level 3 eliminates the Merkle root, which means task completeness cannot be independently verified from the anchor alone. The organization should maintain a separate, appropriately classified record that preserves the Merkle binding for internal audit purposes, even if the external attestation omits it.
AI-TASK.1 witnesses claims, not truths. This distinction is fundamental. The protocol records what participants declare, and cryptographic verification catches inconsistencies. But the outcome itself is always a claim.
| Field | Verification Level | What It Proves | What It Does Not Prove |
|---|---|---|---|
merkle_root | Cryptographic | The declared steps, and only those steps, produce this root. Any addition, removal, or reordering changes the root. | That these were the only inferences the provider executed. Hidden retries or speculative execution are invisible. |
step_count | Cryptographic | Matches the leaf count of the Merkle tree. | That each step corresponds to a real inference (requires ledger cross-check). |
outcome_hash | Self-attested | The caller declared this exact outcome string at task completion time. | That the outcome is truthful. A caller can hash "approved" for a rejected application. |
cost_declared | Self-attested | The caller input this number. Trust level indicated by cost_source. | That this is the actual cost. Only cost_source=3 (invoice verified) has external backing. |
cost_ratio | Derived | Ratio of two reported/estimated values. Useful as consistency check. | Fair pricing. A ratio of 1000 means the numbers match, not that either is correct. |
duration_ms | SDK-measured | Wall clock time between task start and finalization on the client. | Server-side processing time. Clock skew affects accuracy. |
The design principle: the protocol witnesses what participants claim. Cryptographic verification (Merkle root, fingerprint integrity) catches tampering. Consistency checks (cost ratio, step count vs ledger) catch mistakes and gross fraud. But the outcome is always a claim, not a measurement -- the same standard that applies in financial auditing, where the auditor verifies the books, not the underlying transactions.
This is the core insight. An organization that produces AI-TASK.1 anchors with consistent Merkle roots, verifiable step counts, and reconciled costs has not proven its AI is correct. It has produced independently verifiable evidence that its declared process occurred as described. The evidence chain can be audited by any party with the protocol specification. No proprietary tooling, no vendor dependency, no trust assumption beyond the cryptographic primitives. That is what distinguishes a witness record from a log file.
An auditor verifying a task attestation follows this sequence:
GET /api/v1/witness/chain?chain_id={lifecycle_chain_id}SHA256("SWT3:LEAF:" + fingerprint) to each. Build the binary tree using SHA256("SWT3:NODE:" + left + ":" + right).observations.merkle_root in the AI-TASK.1 anchor.step_count == number of confirmed fingerprints.cost_witnessed against the provider invoice. Deviation exceeding 10% warrants investigation.
Assessor Note
Steps 1-6 can be performed with standard cryptographic tooling (any SHA-256 implementation). No SWT3-specific software is required. The domain separation prefixes (SWT3:LEAF: and SWT3:NODE:) are the only protocol-specific knowledge needed. For bulk verification across many tasks, the SDK provides get_merkle_root() (Python) and getMerkleRoot() (TypeScript), but these are convenience functions implementing the same algorithm.
from swt3_ai import Witness
witness = Witness(
endpoint="https://sovereign.tenova.io",
api_key="axm_live_...",
clearing_level=1,
)
client = witness.wrap(OpenAI())
# Context manager pattern: inferences are auto-captured as steps
async with witness.task("claims-triage", task_type="workflow") as task:
r1 = await client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Classify these documents..."}],
)
r2 = await client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Assess severity..."}],
)
r3 = await client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Route this claim..."}],
)
task.declare_cost(declared=0.08, source="provider_api")
task.mark_steps_complete()
task.declare_outcome("route: fast-track, severity: minor, reserve: $2,400")
# receipt.merkle_root binds all 3 step fingerprints
# receipt.task_id is deterministic and reproducible
# receipt.cost_ratio shows whether $0.08 aligns with token usage
# Manual pattern: for external fingerprints or non-async flows
task = witness.begin_task("fraud-scoring", task_type="agent_loop")
task.add_step(fingerprint="a1b2c3d4e5f6") # from external system
task.add_step(fingerprint="f6e5d4c3b2a1")
task.declare_cost(declared=0.015, source="sdk_estimated")
task.declare_outcome("fraud_score: 0.87, action: flag_for_review")
receipt = task.complete()
import { Witness } from "@tenova/swt3-ai";
import OpenAI from "openai";
const witness = new Witness({
endpoint: "https://sovereign.tenova.io",
apiKey: "axm_live_...",
clearingLevel: 1,
});
const client = witness.wrap(new OpenAI()) as OpenAI;
// Callback pattern: inferences are auto-captured as steps
const receipt = await witness.task(
"claims-triage",
{ taskType: "workflow" },
async (task) => {
const r1 = await client.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "Classify these documents..." }],
});
const r2 = await client.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "Assess severity..." }],
});
const r3 = await client.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "Route this claim..." }],
});
task.declareCost({ declared: 0.08, source: "provider_api" });
task.markStepsComplete();
task.declareOutcome("route: fast-track, severity: minor, reserve: $2,400");
},
);
console.log(receipt.merkleRoot); // Merkle root binding all 3 steps
console.log(receipt.taskId); // Deterministic task identifier
console.log(receipt.costRatio); // Consistency check vs declared cost
Not every task completes successfully. The protocol distinguishes between AI failures and infrastructure failures using the mark_steps_complete() checkpoint.
| Scenario | Outcome Status | Explanation |
|---|---|---|
| All steps succeed, task completes normally | 0 (completed) | Standard case. Merkle root binds all steps. |
Exception after mark_steps_complete() | 1 (partial) | AI work succeeded; post-processing (formatting, storage, notification) failed. The inference evidence is valid; the task delivery is incomplete. |
Explicit fail() call | 2 (failed) | Caller determined the task cannot produce a valid outcome. Reason recorded in outcome description. |
| Task exceeds time budget | 3 (timeout) | The caller's deadline passed before the task could complete. |
Exception without mark_steps_complete() | 4 (abandoned) | Unknown failure point. Cannot distinguish whether AI steps completed before the exception. |
The distinction between partial (status 1) and abandoned (status 4) matters for metrics and billing. A partial task has valid inference evidence; the AI work is usable even if the delivery pipeline failed. An abandoned task may or may not have produced valid inferences. Organizations tracking task completion rates should count partial tasks as "AI-succeeded" and abandoned tasks as "unknown."
Assessor Note
A high ratio of abandoned (4) tasks relative to partial (1) tasks suggests the application is not using the mark_steps_complete() checkpoint. This is not a compliance failure, but it reduces the precision of completion rate reporting. If the organization represents a 95% task success rate and the denominator includes abandoned tasks counted as failures, the actual AI success rate may be higher. Ask whether mark_steps_complete() is called, and if not, how abandoned tasks are classified in reported metrics.
| Framework | Reference | Relevance to AI-TASK.1 |
|---|---|---|
| EU AI Act | Art. 12(1) | Automatic recording of events enabling traceability. The task envelope satisfies the recording requirement for composite AI operations. |
| EU AI Act | Art. 13(3)(b)(ii) | Transparency regarding system capabilities and expected level of accuracy. The outcome status and cost ratio provide operational transparency. |
| EU AI Act | Art. 9(2)(b) | Continuous risk estimation during operation. Task-level monitoring enables risk tracking at the work-unit level. |
| NIST AI RMF | MEASURE 2.3 | AI system performance assessment and monitoring. The task envelope provides per-task performance evidence. |
| NIST AI RMF | GOVERN 1.4 | Organizational accountability mechanisms. The Merkle-bound evidence chain establishes a verifiable accountability trail. |
| SR 11-7 | Model Risk Management | Ongoing monitoring of model outputs and costs. Cost reconciliation enables billing audit at the task level. |
| OCC 2026-13 | Operational Risk | AI operational cost governance. The cost source trust levels enable graduated assurance over cost claims. |
| ISO 42001 | Clause 9.1 | Monitoring, measurement, analysis, and evaluation. The task attestation provides structured measurement data for each AI work unit. |
| GPAI Code of Practice | Art. 5.2 | Record-keeping for general-purpose AI outputs. Task attestations satisfy output record-keeping for GPAI providers. |
| NIST 800-53 | SA-4(10) | Use of verified software for critical functions. The Merkle binding verifies task integrity without requiring access to the AI model. |
| CMMC v2.0 | AU.L2-3.3.1 | System-level audit of events. AI-TASK.1 anchors constitute audit events for composite AI operations. |
| SOC 2 | CC7.2 | Monitoring system components for anomalies. Cost ratio deviations and outcome status patterns are anomaly indicators. |