Agent-readable docs index: /llms.txt. Full docs in one file: /llms-full.txt. Download /docs.zip to grep all markdown files locally.

Stateful agent simulations

Halfspan supports a manual refund world with orders.lookup and payments.refund tools. The server owns the order state, permissions, operation journal and evaluator. Your local process runs the agent code and forwards tool operations through a temporary loopback broker.
Execution and supplied fixture facts are customer-attested. Broker state and evaluation are local broker replay evidence. Local code runs with your operating-system access. This workflow does not provide a hosted sandbox or enforce process egress isolation.

Freeze a regression case

Save a trace event as an evaluation case in the dashboard. Fetch its dataset to obtain the immutable version, case ID and manifest digest:
curl "$HALFSPAN_API_URL/api/v1/observability/eval-datasets/$DATASET_ID" \ -H "Authorization: Bearer $HALFSPAN_API_KEY"
Dataset responses include version, currentVersion, manifestDigest, manifest and cases. Each case includes rowDigest and requiredChecks. Add ?version=N to fetch an older frozen version. Use the digest supplied by the server; dataset and simulation manifests use separate versioned canonical formats.
Snapshots have source-bound retention. Expired or moved sources deny reads and execution. Unsharing, forgetting or deleting a source permanently revokes its snapshots and removes copied simulation specifications, checkpoints and evaluations in the same database transaction. Re-sharing the same source ID does not restore revoked snapshots.

Prepare a manual world

Create refund-world.json using your saved case:
{ "dataset": "YOUR-DATASET-UUID", "datasetVersion": 2, "case": "YOUR-CASE-UUID", "orderId": "order-1", "request": "Please refund 40 units", "paid": 100, "authorizedRefund": 40, "expectedRefund": 40, "faults": [ {"operationId": "refund-1", "stage": "after_commit_response_lost"} ], "qualification": [] }
All amounts are integer units in one fixture currency. The agent sees the request and order ID. It cannot read the authorized refund, expected result or qualification through the tool broker.
Qualification must cover permission, committed_effect, idempotency, prerequisites and artifact_identity. Each entry has factId, status (match, mismatch or unknown) and an evidenceDigest in sha256: format. Supply these from your review of the world against the intended system. An empty inventory produces blocked_unknown. Every critical fact must match for eligibility; one mismatch vetoes qualification. Customer statements are retained as attestations, rather than promoted to independent verification.

Run your code

The source CLI can be run from the monorepo:
node packages/sim/cli.mjs sim trial \ --spec refund-world.json \ --code path/to/agent.mjs \ --target node -- path/to/agent.mjs
Repeat --code to bind the source artifacts your run uses. The CLI hashes those files and the fixture, and the server binds them to the scenario, world, dataset and evaluator identities. This records supplied artifacts; it does not attest the complete executable or dependency environment.
The evaluator commitment hashes the embedded kernel source artifact separately from the private oracle's expected outcome data. A server with a different evaluator artifact rejects restoring an earlier run with a conflict. Retained historical artifact execution is not yet available.
Your target reads one JSON object from standard input. It contains protocol, runId, attempt, entrypoint, knowledge, tools, clock, deadline and broker: {url, token}. Write one JSON object to standard output when finished. The target's output does not determine its grade. The parent CLI requests server finalization after the target exits successfully.
Send operations to broker.url with Content-Type: application/json and Authorization: Bearer <broker.token>:
{ "operationId": "lookup-1", "tool": "orders.lookup", "schemaDigest": "COPY-THE-OFFERED-TOOL-SCHEMA-DIGEST", "orderId": "order-1", "amount": 0, "causalParent": "", "expectedRevision": 0 }
Lookup returns the order's id, paid and refunded fields with a state revision. To refund, use payments.refund, a positive amount, the current revision and the lookup operation ID as causalParent.
Reuse an operation ID and identical input for a retry. Reusing it with different input conflicts. A response-lost fault commits the refund once and withholds its reply; retrying returns the committed result. before_commit faults allow retry without an earlier effect. Unknown tools and schemas produce unsupported evidence and block eligibility.
The parent retains the Halfspan credential. The target receives a short-lived loopback token that can forward only bounded tool operations for its attempt. Environment inheritance defaults to basic process settings. Use --target-env OPENAI_API_KEY to explicitly pass a model credential. Halfspan and CI credential variables are reserved.

Inspect and cancel

The API provides:
MethodPathEffect
POST/api/v1/observability/simulationsCreate an immutable manual run
GET/api/v1/observability/simulations/{id}Read public manifests and evaluation
POST/api/v1/observability/simulations/{id}/operationsCommit an attempt-bound tool operation
POST/api/v1/observability/simulations/{id}/finalizeGrade authoritative state and close the run
POST/api/v1/observability/simulations/{id}/cancelAcknowledge a fence against subsequent operations
Create requires UUID id and executor, manifestDigest, codeDigest, configDigest, and the fixture fields above. Operations, finalization and cancellation bind the returned attempt. Direct API calls require traces:read or traces:write as appropriate. Read-only keys cannot mutate a world. Project selection uses workspaceProject; resolved stored projects are checked again before access.
Each tenant can have eight active runs. A run admits operations for one minute and at most 128 calls. Stored simulation evidence expires after 24 hours or earlier source revocation. Cancellation advances the generation before acknowledgment; subsequent stale operations fail. Local process group termination is best effort and does not establish containment of hostile code.
Expiry purges specification, checkpoint and evaluation payloads while retaining the run's reference tombstone. An expired run ID cannot be reused by a late retry while its dataset/project references remain retained.
CLI exit 0 means eligible and passed, 1 means failed, and 2 means inconclusive or unavailable. Outcome, support and gate are separate fields. A correct refund with missing qualification remains inconclusive.
Use just simulation-replay with migrated disposable Postgres and ClickHouse to replay the kernel corpus and the actual CLI/API/storage workflow. Hosted execution, automatic world construction, repository discovery, counterparty agents, paired statistical reports and GitHub simulation workflows remain separate work.