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.

Contents

1. The Invisible Work Problem 2. Scenario: Insurance Claims Triage 3. Procedure Definition 4. Evidence Structure 5. Merkle Binding 6. Cost Reconciliation 7. Clearing Level Behavior 8. Trust Boundaries 9. Auditor Verification Procedure 10. SDK Integration: Python 11. SDK Integration: TypeScript 12. Failure Handling 13. Regulatory Mapping 14. References

1. The Invisible Work Problem

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.

2. Scenario: Insurance Claims Triage

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:

Step 1 -- Document Classification

Classify Attached Documents

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.

Step 2 -- Severity Assessment

Assess Claim Severity

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.

Step 3 -- Routing Decision

Route to Adjuster or Fast-Track

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.

3. Procedure Definition

AI-TASK.1

Task Outcome Attestation

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 Semantics

FactorLabelEncoding
factor_aStep countNumber of sub-inference anchors in the task. Must be ≥ 1 for PASS.
factor_bCost reconciliation ratiowitnessed_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_cOutcome status0 = completed, 1 = partial, 2 = failed, 3 = timeout, 4 = abandoned

Verdict Logic

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.

Task Type Codes

CodeTypeDescription
0inferenceSingle-turn or multi-turn conversation
1workflowMulti-step pipeline (RAG, chain-of-thought)
2agent_loopAutonomous agent with tool use
3code_generationCode writing, review, or debugging
4researchInformation gathering and synthesis
5assessmentEvaluation, grading, or classification
6transformationData transformation or format conversion
7orchestrationMulti-agent coordination
8customApplication-defined task type

4. Evidence Structure

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.

FieldDescription
task_idDeterministic identifier: TASK-{SHA256("TASK:{tenant}:{chain_id}:{timestamp}")[:16]}
task_typeCode from task type table (e.g., "workflow")
lifecycle_chain_idLinks to all constituent step anchors in the lifecycle chain
outcome_statusTerminal status code (0-4)
outcome_hashSHA-256 of the caller's declared outcome description
step_countNumber of sub-inference anchors (must match Merkle leaf count)
merkle_rootSHA-256 Merkle root computed from all step fingerprints
step_proceduresDistinct procedure IDs witnessed (e.g., ["AI-INF.1", "AI-TOOL.1"])
cost_declaredProvider's stated cost in USD microcents
cost_witnessedSum of token-based cost estimates from individual steps
cost_ratiowitnessed / declared × 1000
cost_sourceTrust level: 0 = manual, 1 = SDK estimated, 2 = provider API, 3 = invoice verified
duration_msWall clock time from task start to finalization
agent_idsDistinct agent identifiers involved (hashed at clearing level 1+)
tool_call_countTotal 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.

5. Merkle Binding

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
        ...
Three-tier Merkle tree: daily rollup > session > task > step fingerprints

This creates two independent verification paths:

  1. Task completeness proof: Recompute the Merkle root from the step fingerprints retrieved via the lifecycle chain query. If the recomputed root matches the merkle_root in the AI-TASK.1 anchor, the step set is complete and unmodified.
  2. Task inclusion proof: Standard Merkle inclusion proof that the AI-TASK.1 anchor's fingerprint appears in the daily rollup. This confirms the task attestation itself was not retroactively inserted.

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.

6. Cost Reconciliation

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.

RatioInterpretationImplication
1000Exact matchWitnessed token costs equal the declared task cost
> 1000OverchargedDeclared cost exceeds witnessed token costs
< 1000UnderchargedWitnessed token costs exceed the declared cost
0UnavailableNo cost data was provided or computed

Cost Source Trust Levels

Not all cost data is equal. The cost_source field records where the cost figure originated:

CodeSourceTrust LevelAuditor Guidance
0ManualLowestCaller entered a number. Zero inherent trust. Flag for corroboration.
1SDK estimatedMediumSDK computed cost from token counts using model pricing tables. Pricing tables may be stale.
2Provider APIHighCost retrieved from the provider's billing or usage API. Subject to API accuracy.
3Invoice verifiedHighestReconciled 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.

7. Clearing Level Behavior

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.

LevelNameRetained FieldsRemoved Fields
0AnalyticsAll fields, including cleartext declared_outcomeNone
1StandardAll fields except cleartext outcome. outcome_hash replaces declared_outcome. Agent IDs are hashed.declared_outcome (replaced by hash)
2Sensitivetask_id, outcome_status, outcome_hash, step_count, merkle_root, step_procedures, duration_ms, timing fields, tool_call_counttask_type, all cost fields, agent_ids, lifecycle_chain_id
3ClassifiedFactors 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.

8. Trust Boundaries

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.

FieldVerification LevelWhat It ProvesWhat It Does Not Prove
merkle_rootCryptographicThe 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_countCryptographicMatches the leaf count of the Merkle tree.That each step corresponds to a real inference (requires ledger cross-check).
outcome_hashSelf-attestedThe 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_declaredSelf-attestedThe 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_ratioDerivedRatio 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_msSDK-measuredWall 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.

9. Auditor Verification Procedure

An auditor verifying a task attestation follows this sequence:

Step 1. Retrieve the lifecycle chain for the task.
GET /api/v1/witness/chain?chain_id={lifecycle_chain_id}

Step 2. Extract all step fingerprints from the chain response. Every anchor except the terminal AI-TASK.1 is a step.

Step 3. Confirm each step fingerprint exists in the ledger and belongs to the same tenant. This rejects cross-tenant fingerprint injection.

Step 4. Recompute the Merkle root from confirmed step fingerprints.
Sort fingerprints lexicographically. Apply SHA256("SWT3:LEAF:" + fingerprint) to each. Build the binary tree using SHA256("SWT3:NODE:" + left + ":" + right).

Step 5. Compare the recomputed root to observations.merkle_root in the AI-TASK.1 anchor.
MATCH = step set is complete and unmodified.
MISMATCH = steps were added, removed, or altered after minting.

Step 6. Verify step_count == number of confirmed fingerprints.
MATCH = no phantom or missing steps.
MISMATCH = step inflation or omission detected.

Step 7. (Optional) Reconcile 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.

10. SDK Integration: Python

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()

11. SDK Integration: TypeScript

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

12. Failure Handling

Not every task completes successfully. The protocol distinguishes between AI failures and infrastructure failures using the mark_steps_complete() checkpoint.

ScenarioOutcome StatusExplanation
All steps succeed, task completes normally0 (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() call2 (failed)Caller determined the task cannot produce a valid outcome. Reason recorded in outcome description.
Task exceeds time budget3 (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.

13. Regulatory Mapping

FrameworkReferenceRelevance to AI-TASK.1
EU AI ActArt. 12(1)Automatic recording of events enabling traceability. The task envelope satisfies the recording requirement for composite AI operations.
EU AI ActArt. 13(3)(b)(ii)Transparency regarding system capabilities and expected level of accuracy. The outcome status and cost ratio provide operational transparency.
EU AI ActArt. 9(2)(b)Continuous risk estimation during operation. Task-level monitoring enables risk tracking at the work-unit level.
NIST AI RMFMEASURE 2.3AI system performance assessment and monitoring. The task envelope provides per-task performance evidence.
NIST AI RMFGOVERN 1.4Organizational accountability mechanisms. The Merkle-bound evidence chain establishes a verifiable accountability trail.
SR 11-7Model Risk ManagementOngoing monitoring of model outputs and costs. Cost reconciliation enables billing audit at the task level.
OCC 2026-13Operational RiskAI operational cost governance. The cost source trust levels enable graduated assurance over cost claims.
ISO 42001Clause 9.1Monitoring, measurement, analysis, and evaluation. The task attestation provides structured measurement data for each AI work unit.
GPAI Code of PracticeArt. 5.2Record-keeping for general-purpose AI outputs. Task attestations satisfy output record-keeping for GPAI providers.
NIST 800-53SA-4(10)Use of verified software for critical functions. The Merkle binding verifies task integrity without requiring access to the AI model.
CMMC v2.0AU.L2-3.3.1System-level audit of events. AI-TASK.1 anchors constitute audit events for composite AI operations.
SOC 2CC7.2Monitoring system components for anomalies. Cost ratio deviations and outcome status patterns are anomaly indicators.

14. References