Skip to main content

rawctx

Tamper-proof receipts for your AI's answers.

When an AI answer is challenged, rawctx records what it said, which sources it used, and a verifiable receipt. It keeps answer evidence and proof review separate from the agent and observability stack you already run.

Install

pip install rawctx
rawctx login

You can also mint a no-signup, hash-only browser receipt from the rawctx Hub. The browser path sends cryptographic fingerprints instead of the question and answer text.

Log an answer

import rawctx

receipt = rawctx.log_answer(
    "What is the refund policy?",
    "Customers can request a refund within 30 days.",
    project_key="support-assistant",
)

print(receipt)

Hash-centered storage is the default. Workspace settings can enable raw question and answer text storage, while hashes remain available when text storage is off.

Select a project and environment

Projects separate applications or services inside one workspace. Environments belong to a project and are used for filtering and deployment-specific credentials.

rawctx projects list
rawctx projects create support-assistant \
  --display-name "Support assistant" \
  --default-environment production
rawctx environments create staging --project support-assistant
rawctx projects use support-assistant --environment production
rawctx credential create production-writer \
  --project support-assistant \
  --scope answer_audit:create

credential create prints the plaintext project token once. Store it in a secret manager. Use rawctx credential revoke CREDENTIAL_ID --project PROJECT to revoke it.

Applications can select context explicitly or through environment variables:

with rawctx.RawctxClient(
    project="support-assistant",
    environment="production",
) as client:
    client.create_answer_log(question_text="Question", answer_text="Answer")
RAWCTX_PROJECT=support-assistant
RAWCTX_ENVIRONMENT=production

Use project_key in new code. application_key is deprecated but remains available for older integrations. Existing flat answer and reconciliation API endpoints still send it. If a project_key call omits the environment, the server uses the Project's default.

Queue EZKL verification

Install the optional prover runtime and prepare rawctx.ezkl.json once with the ONNX model, compiled circuit, settings, PK, VK, and workspace-compatible SRS paths:

pip install 'rawctx[ezkl]'
{
  "schema": "rawctx.ezkl.project.v1",
  "model_path": "ezkl/model.onnx",
  "compiled_circuit_path": "ezkl/network.compiled",
  "settings_path": "ezkl/settings.json",
  "proving_key_path": "ezkl/pk.key",
  "verification_key_path": "ezkl/vk.key",
  "srs_path": "ezkl/kzg.srs",
  "srs_ref": "kzg_srs_v1"
}

Paths are relative to rawctx.ezkl.json. Set RAWCTX_EZKL_CONFIG when the file is stored elsewhere.

Set the workspace endpoint and a Project credential in the process environment. Use a workspace login token only for Project and credential administration:

RAWCTX_REGISTRY=https://<workspace-api-host>
RAWCTX_TOKEN=<project-credential>
RAWCTX_PROJECT=ezkl-test

At runtime, no artifact path is passed. The SDK generates and locally verifies the proof, creates the answer log, and queues server verification:

import rawctx

with rawctx.RawctxClient() as client:
    result = client.run_ezkl_and_log(
        project_key="ezkl-test",
        input_data=[[2.0]],
        idempotency_key="ezkl:identity:run-001",
    )

print(result["log_id"])
print(result["job_id"], result["proof_job"]["status"])

The helper supports a single public rescaled numeric input and output. Local verification is followed by an asynchronous server job, so queued is not the final result; wait for adapter_verified. The SRS must match the workspace's pinned kzg_srs_v1 bundle and must not be regenerated with EZKL. Use a stable idempotency_key because answer-log and job creation are separate writes.

What rawctx records

  • Answer record: application, environment, question and answer text or hashes, idempotency key, policy flags, and status.
  • Source evidence: source_refs for documents, registered audio or video evidence, answer segments, and purpose-bound retrieval events.
  • Model-run lineage: model metadata, input and output hashes, configuration hashes, trace IDs, and inference commitments.
  • Lifecycle and proof: correction, void, and redaction events plus Merkle inclusion, signed tree-head binding, external anchors, witness receipts, and explicit proof status.

rawctx does not orchestrate model or agent inference and does not replace LangSmith, Langfuse, or another OpenTelemetry runtime. Its optional EZKL helper only runs the proof lifecycle for an already prepared ONNX circuit. rawctx records the evidence object that connects an answer to the sources and trace information needed for review.

Connect OpenTelemetry evidence

rawctx.ingest_otel_trace_bundle() wraps public-safe fields from an existing OpenTelemetry trace into an answer-audit record. Keep trace ownership in your current observability system and submit only the identifiers, hashes, and references needed for answer review.

Do not send observability API keys, private trace URLs, raw tool outputs, or other secrets to rawctx.

Check answer-log completeness

Independent reconciliation compares a short-period external reference set with rawctx answer-audit logs. It detects missing, unexpected, late, duplicate, and unanchored records without becoming an inline decision gate.

rawctx reconcile run reconciliation.json --json
rawctx reconcile findings RUN_ID --json
rawctx reconcile proof RUN_ID --output reconciliation-proof.json
rawctx trust verify reconciliation-proof.json --online

The JSON command keeps the complete API payload in one file. For a CSV export, provide the run envelope and map the source columns locally:

moderation_id,occurred_at,result,source_row_id
mod-123,2026-08-12T09:13:00Z,blocked,row-987
rawctx reconcile run moderation.csv --format csv \
  --source-key moderation-daily-export \
  --period-start 2026-08-12T00:00:00Z \
  --period-end 2026-08-13T00:00:00Z \
  --project-key moderation-agent \
  --environment production \
  --id-column moderation_id \
  --time-column occurred_at \
  --outcome-column result \
  --external-record-id-column source_row_id \
  --json

CSV input is a local adapter for the same reconciliation API. It accepts UTF-8, including a UTF-8 BOM, preserves duplicate rows for duplicate findings, and rejects files over 10,000 records instead of splitting them automatically. The Project and Environment can come from the active CLI profile when their flags are omitted. A .csv suffix is detected automatically; --format can be used to select json or csv explicitly.

Use an export from a business system, provider, or auditor that answer-log operators cannot edit at the same time. Findings and proofs store commitments; do not place secrets, raw customer exports, personal data, or private system URLs in payload metadata.

Review proof state

Proof status distinguishes externally anchored records from pending or local-only evidence. It describes the receipt's verification state; it does not claim that the submitted answer or upstream trace content is true.

rawctx trust proof answer ANSWER_LOG_ID --output proof.json
rawctx trust verify proof.json --online --json

Public documentation

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rawctx-0.3.47.tar.gz (205.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rawctx-0.3.47-py3-none-any.whl (164.4 kB view details)

Uploaded Python 3

File details

Details for the file rawctx-0.3.47.tar.gz.

File metadata

  • Download URL: rawctx-0.3.47.tar.gz
  • Upload date:
  • Size: 205.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for rawctx-0.3.47.tar.gz
Algorithm Hash digest
SHA256 12d9973d2721705ca112f93f23c3273b3a43841c9369ee15790fce2bf79d514a
MD5 85f0ec83bbbcd7b2f44eebda0f09d32f
BLAKE2b-256 3e1d1cbd27cbc64560d4ec0540e0e74cd8e66f811331901236b02b5822cbe765

See more details on using hashes here.

File details

Details for the file rawctx-0.3.47-py3-none-any.whl.

File metadata

  • Download URL: rawctx-0.3.47-py3-none-any.whl
  • Upload date:
  • Size: 164.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for rawctx-0.3.47-py3-none-any.whl
Algorithm Hash digest
SHA256 d082d8fb34e0fc90806de710d31eb85883239e4f88a989c2b5751a75c9a6bae0
MD5 cfd317f5c96f830d54c5d4f317981591
BLAKE2b-256 3ec56602c150e8112a31014787742dc96c8acaa2b7b6b485549e507dee3d135d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page