Skip to main content

sanning-anchor

Produce verifiable evidence from your Python agents: hash locally, anchor a signed commitment, and hand an auditor a pack they verify offline. Nothing in this package needs a wallet, a chain identity, or a Sanning account to check.

Node is not required at any point. The bundle command that assembles a hand-over pack is a Python console script, and so is everything before it.

  • The path from a first conversation with Sanning to a verified event is at docs.sanning.io.
  • The wire format, the envelope profile and the pack body type are specified in documents that ship inside sanning-proof, beside the kernel that implements them.

Install

pip install sanning-anchor

Access to the console comes through a conversation with Sanning; there is no self-service sign-up. Once your organization has a console login, create an API key at console.sanning.io. Give the key agent:enroll and anchor:write to anchor, and anchor:read as well if the same key will later build a hand-over pack. The console pre-checks the first two. A key holding only anchor:write anchors nothing, because the plane refuses an envelope whose signing key the organization has not enrolled; a key holding no anchor:read anchors correctly and then fails at hand-over.

Anchor an event

import json
import os

from sanning_anchor import Anchorer, FsLogStore, LocalEd25519Signer

anchorer = Anchorer(
    # Writes to a permanent public record. Use "dev" until you mean it.
    environment="production",
    # Your Ed25519 identity key. Keep the seed: a different seed is a different agent.
    signer=LocalEd25519Signer.from_seed_hex(os.environ["SANNING_SIGNING_SEED"]),
    subject={"type": "agent", "agent_id": "claims-triage"},
    api_key=os.environ["SANNING_API_KEY"],
    log_store=FsLogStore("./logstore"),
)

decision = {"claim_id": "c-1", "outcome": "approved"}  # your own data

result = anchorer.anchor(
    # Hashed in this process. These bytes are never sent to Sanning.
    content=json.dumps(decision).encode(),
    metadata={"reviewer": "queue-3"},
)

anchorer.close()

result.event_id  # the id this process minted
result.event_bytes  # retain these: the bytes payload_hash commits to

Replace the following:

  • SANNING_SIGNING_SEED with a 32-byte Ed25519 seed, 64 hex characters, that your service keeps across restarts. An agent's identity is this key, not its name. bytes.fromhex accepts either case; the TypeScript SDK's fromSeedHex takes lowercase only.
  • SANNING_API_KEY with the key from the console.
  • claims-triage with the identity you want the evidence attributed to.

@sanning/anchor takes the same arguments under TypeScript naming and writes the same bytes, so a mixed fleet hands over one pack.

Start in the sandbox

Start with a Sandbox API key, which begins sanning_test_, and set no environment. The SDK signs "dev", stamps are simulated, and nothing reaches the public record. A pack built from those records reads verified with the sandbox label: sanning-proof verify prints the Sandbox: line and exits 3. When you are ready for evidence, switch SANNING_API_KEY to a Live API key, which begins sanning_prod_, and use a new signing seed. See Sandbox and live and Go live.

The environment and your API key

With an API key, environment is optional: the SDK reads it from the key's prefix. sanning_test_ signs "dev" and sanning_prod_ signs "production", at the same host. A sanning_test_ key with environment="production" raises ValueError at construction, and so does a sanning_prod_ key with environment="dev" (the Live plane refuses a dev record): dev records need a Sandbox key, or drop environment to sign "production". Any other explicit value is used as given. With a key that has neither prefix, or with your own client and no key, environment is required and its absence raises TypeError. An api_key that is not a str raises TypeError.

A Live plane refuses a Sandbox API key, and a Sandbox refuses a Live API key. Only the prefix is read, and the value is sealed into every record. base_url still points the SDK at another origin, such as staging.

From CI, persist one seed. Calling LocalEd25519Signer.generate() in every run enrolls a new key under the same agent_id, which the plane refuses as an unauthorized rotation. Generate a seed once (openssl rand -hex 32), store it as a CI secret beside a Sandbox API key, and pass it as the signer:

anchorer = Anchorer(
    signer=LocalEd25519Signer.from_seed_hex(os.environ["SANNING_SIGNING_SEED"]),
    subject={"type": "agent", "agent_id": "claims-triage"},
    api_key=os.environ["SANNING_API_KEY"],
    log_store=FsLogStore("./logstore"),
)

Chains need a durable store

anchor(chain="orders") links each record to the one before it under that chain key, and keeps the head in the anchorer's store. The default MemoryStore loses its heads on a restart, so the next record on the same chain key starts again at GENESIS: one chain with two roots, a fork whose links all verify. sanning-proof reports it as the chain-second-root finding, which does not change the verdict.

Use a durable store with one writer for any chain key that outlives one process. A durable store does not make two writers safe, because the store has no compare-and-set: two instances on one chain key fork the same way. In production, anchor(chain=...) on the default store warns once per anchorer. If every chain key lives only as long as the process (the LangChain handler's per-run key, for example), pass store=MemoryStore() to say so and the warning stays quiet.

Enrollment is automatic

The example writes no enrollment step, and that is the whole of it: on the first anchor(), the SDK proves possession of your signing key to the control plane, and your agent appears on Fleet under agent_id. One organization key covers the whole fleet: no per-agent credential, no enroll script. It is not optional politeness, because the plane refuses an envelope signed by a key your organization has not enrolled (SIGNING_KEY_NOT_ENROLLED, HTTP 403).

Three properties are load-bearing:

  • The challenge is shape-checked before it is signed. Enrollment is the one moment your identity key signs bytes the server chose, and that key also seals your envelopes, so the SDK refuses anything that is not a nonce rather than trusting Sanning not to send an envelope pre-image. Sanning is never in the trust path, including here.
  • A different key for an agent_id your organization has enrolled is a rotation, and it needs the retiring key's counter-signature (previous_signer=). It is never inferred from a refusal: that is what stops a leaked organization key silently taking over an identity that is already producing evidence.
  • Verification never depends on the roster. Enrollment is the plane's door policy, not the trust path. Every signed record verifies offline against sanning-proof, enrolled or not.

Enrolling out of band at deploy time instead? auto_enroll=False turns the call off, and enroll() is exported for you to drive:

from sanning_anchor import enroll

enroll(
    api_key=os.environ["SANNING_API_KEY"],
    agent_id="claims-triage",
    signer=signer,
)

Behaviour is identical to the TypeScript SDK, pinned by a shared conformance oracle that calls neither of them.

What never leaves your process

Your content does not. It is hashed locally and only the hash goes into the signed envelope. The control plane is content-blind by construction rather than by policy: it never receives the bytes, so it cannot disclose them.

event_bytes is your retention obligation. It is what payload_hash commits to. Sanning never holds it, so losing it leaves you holding a commitment to something you can no longer produce.

Beside the envelope goes a projection of the signed record, for indexing. It holds ids and fixed formats: never a name, a content length, a hash of content, a locator or a file path. Ids are sent in clear, the case id included. It is unsigned, never placed and never evidence.

No Arweave wallet, no chain identity, no data item. Placement is Sanning's act, which is why this package holds no blockchain code at all, and why it is a few hundred lines rather than a chain client.

Retain what you anchored

Pass log_store= and the SDK writes both halves an auditor needs before the event is anchored: the content you handed it, and the canonical event record the envelope commits to. If the store write fails, nothing is anchored. There is deliberately no best-effort mode, because under this write path nothing else holds those bytes.

Beside each record it also writes the signed envelope over it, at envelopes/<payload_hash>, so a record read back from your own store carries its signature and its signed_at. That time is the one your agent declared when it signed: it is never trusted for ordering and never used as proof. A store written before this change holds no envelopes and reads exactly as it did.

FsLogStore is the development destination. For production, sanning_anchor.s3 (from sanning_anchor.s3 import S3ObjectStore, with pip install "sanning-anchor[s3]") supplies an S3-compatible object store behind the same seam, the same shape as TypeScript's @sanning/anchor/s3, and the on-disk shape is a versioned contract, specs/log-store.md in the sanning-proof package, so an auditor holding nothing but the directory can resolve it without a connector and without Sanning.

--logs takes a local store root or an s3:// URL. Reading a bucket needs SANNING_S3_ENDPOINT, SANNING_S3_ACCESS_KEY_ID and SANNING_S3_SECRET_ACCESS_KEY in the environment, and a missing one is named individually. SANNING_S3_REGION is optional and defaults to us-east-1. There is no flag for them: a credential in argv lands in shell history. The reader credential is enough, s3:GetObject and s3:ListBucket.

Trace a LangChain agent

pip install "sanning-anchor[langchain]"
from sanning_anchor import AnchorCallbackHandler

with AnchorCallbackHandler(anchorer) as handler:
    agent.invoke(inputs, config={"callbacks": [handler]})

Every chain, model, tool and retriever step is anchored as an agent.* record of the sanning.agent/1 vocabulary, with LangChain's run_id and parent_run_id tree committed alongside a per-invocation seq and prev_event_id. A missing record leaves a hole in seq and a moved one breaks the chain, so the trail is deletion-evident and reorder-evident. An invocation opens with agent.run_opened (which lists in capture.not_captured what this adapter cannot write), runs as a root step, and closes with agent.run_closed. Every start has an end that names it in run.started_event_id, and a tool call carries gen_ai.tool.call.id on both: the model's id, or one this adapter assigns from the run id.

A moment LangChain reports as one event is one agent.step.occurred, with no start, no end and no outcome, inside the run LangChain names: an agent action (run.source_type langchain.agent_action), an agent finish (langchain.agent_finish), and a retry between two attempts (langchain.retry, inside the model call it retries). It commits the event as LangChain handed it. A customer's own event from dispatch_custom_event is not recorded.

Four things decide whether your integration is correct, so they sit here rather than in a guide:

  • The with block raises on a gap. Leaving it out anchors what it can and walks past what it cannot, and you find out when an auditor asks. Use raise_on_gaps=True to stop the agent instead: the lost record's error raises out of invoke or ainvoke at the step whose record was lost, so a tool whose start record is lost does not run. A lost record is any record of this handler's that is not in the trail: one the plane refused, one the handler could not build (the chain key function raised, the payload would not serialise), one a chain-store failure cost, and a step whose callback raised before its record was attempted, which is recorded as unbuilt. A lost file record (a file a tool returned) raises at the end of that tool's step, once every file it returned is recorded, so the next tool call does not run. When several are lost, the first one's error is raised. Any other error inside the handler (one after the step's record was attempted) is logged and the agent continues. An anchorer built with fail_closed=True stops the agent the same way on any lost record, without raise_on_gaps, and the handler then stays stopped: every later step raises the same error, and a new run on it raises an error that says to construct a new handler. With a buffer, a record is lost only once a later drain is refused for good, so the agent stops at the step after it.

  • A handler answers for its own records. One Anchorer can serve a handler per request: handler.gaps, chain_gaps, is_complete and close() count only the records that handler wrote, so one request's lost record never makes another request's trail incomplete. The handler never closes the anchorer; close it yourself when the process is done with it.

  • The object the framework handed each callback is committed: a chain's inputs or outputs, a model call's messages or prompts, a tool's input or output. It stays with you. on_event watches each record's outcome and cannot change it.

  • A file a tool returns gets its own record, committed to the file's own bytes, with no setup: its event.content_hash is the file's SHA-256, and the bytes go to the log store as the record's content, like any other content. metadata.artifact names the file and carries no hash. A file the SDK cannot read becomes a agent.file record with outcome.status failed and artifact.reason, because silence is how files go unrecorded on a run that reports success.

  • A LangGraph pause and resume. When a node calls interrupt(), LangGraph ends the run and reports the root as completed. The handler reads it as it is: the node's agent.step.ended and the root's carry outcome.status interrupted, and the closing record observes interrupted. interrupt() does not say who decides, and a resume value is any JSON, so the approval records need two things from you:

    from sanning_anchor import AnchorCallbackHandler, ApprovalOptions
    
    handler = AnchorCallbackHandler(
        anchorer,
        approvals=ApprovalOptions(
            actor="human",
            # Read the resume value as an answer; raise for a value that is no verdict.
            verdict=lambda resume: "approved" if resume == "yes" else "rejected",
        ),
    )
    

    The handler writes agent.approval.requested before the interrupted node ends and keeps that record's event_id with the conversation (LangGraph's thread_id, never generated). The invocation that resumes the thread writes agent.approval.resolved, naming the request in run.started_event_id; the two are in different runs and are tied by gen_ai.conversation.id. Pending approvals are kept in this process by default; pass ApprovalOptions(pending=...), an object with put(conversation_id, pending) and take(conversation_id), when the resume can arrive in another process. A resume with no pending approval writes no answer and names both approval types as not captured. Only a LangGraph Command(resume=...) answers; a state dict with a resume key does not. A verdict or reviewer that raises, or a pending store that raises, costs the resolution: it is an unbuilt hole (is_complete is false), the approval stays pending, and the run's other records are written.

    A thread_id is an id: 1 to 128 characters of A-Z a-z 0-9 _ . : -. One outside that grammar, such as an email address, is never rewritten or left out, so every record of the run is refused and reported in gaps, and the agent still runs. Use an opaque thread_id.

    When interrupt() is called inside a tool, the tool call ends interrupted in the invocation that started it, not failed. On resume LangGraph runs the tool again as a new tool call, with its own start and end, and the answer writes no end for the old one.

    The approval's subject, approval.subject_event_id, is the agent.step.started of the node that paused for the answer, not the start of a tool call. A verifier warns ran_after_refusal when a tool call ran after its approval refused it, and that check does not cover these runs: the re-run after a resume is a new operation that nothing links to the refusal. The records still show both.

    What Sanning can see after an answer depends on how you built the agent. In private it does not receive the verdict, so it can only look at what follows the answer (section 7 of the vocabulary):

    • When an approval node routes on the answer, an approved run shows a tool call and a decision (where you name a decision tool) after the answer, and a rejected run shows neither.
    • When interrupt() is called inside the tool, the tool runs again on both answers, so the records look the same whichever way the answer went (unless the tool raises on a rejection, which ends the call failed).
  • Decisions from a named tool. State each decision in a tool call, and name the tool and the decision:

    from sanning_anchor import AnchorCallbackHandler, DecisionTool
    
    handler = AnchorCallbackHandler(
        anchorer, decisions=[DecisionTool(record_conclusion, "credit_verdict")]
    )
    

    When record_conclusion ends completed, the handler writes an agent.decision named credit_verdict, whose value is what the tool returned. Pass the tool object: a tool that does not exist, a tool named twice, or a name that is no label is refused when the handler is constructed. The tool is matched by name: a tool with the same name triggers it. A call that ends failed, including a ToolMessage with status error (what handle_tool_error and handle_validation_error produce), writes no decision. Name the decision for what was decided, and put the outcome in the value: credit_verdict with the value declined is right, credit_declined is not.

  • An id that fails the grammar is refused. An id is 1 to 128 characters of A-Z a-z 0-9 _ . : - (a tool call id, 1 to 256). The handler checks each id it writes and refuses a record whose id fails, naming the field and never the value. With fail_closed=True on the anchorer, or raise_on_gaps=True, the callback raises and the agent stops before its work. By default the agent keeps running: the record is an unbuilt hole (is_complete is false) and handler.recording_status() lists it under refused beside the anchorer's own status.

  • Transient failures are retried; a 4xx is not. The plane has said the envelope is wrong, and repeating it is a slower failure rather than a recovery.

  • Show which policy a step applied. Have the tool that reads or applies the policy return the file as its artifact, and the handler writes a agent.file record committing to the file's bytes, on that tool's run. The trail then shows which policy a step actually read, rather than which one was configured at startup. An auditor holding the policy runs sha256sum and compares it with that record's event.content_hash:

    @tool(response_format="content_and_artifact")
    def read_underwriting_policy() -> tuple[str, dict]:
        """Read the underwriting policy in force."""
        return "Loaded underwriting policy v3.", {"path": "policies/underwriting-v3.md"}
    

    Hashing documents named at startup would record a declaration, not what any step read, so there is no option for it.

  • The closing record. An agent.run_closed record is written once per root run, automatically, when close() runs -- no option gates it. It states how many records that root run anchored (the anchorer accepted them) and their ids, even 0: a root run that anchored nothing still gets one stating the zero. Its outcome is completed, failed, interrupted (a LangGraph node interrupted the run) or unknown, with a reason code (error or interrupted) when it did not complete, and close(outcome=..., reason=...) states how you say it ended, with the reason one of error, timeout, cancelled, interrupted or policy: free text is refused. Once the handler is closed, every later record is refused, so nothing lands after a root's closing record. A close() that returns before the closing records are written raises ClosingNotDeliveredError (an AnchorError, from sanning_anchor), whatever raise_on_gaps says: the second of two concurrent calls waits at most 120 s for the first, and one called from inside an on_event hook does not wait at all. That includes one called from inside a closing anchor call (a hook on a closing record, a custom anchorer writing one): the closing that call is part of cannot be confirmed from inside it, so it raises every time, and retrying in a loop there only holds up the claiming close() and never succeeds. The hook guard logs it from a hook. From a custom anchorer the error leaves anchor(), and that root's run_closed comes back unbuilt (complete=False) unless the anchorer catches it.

  • The file role. A tool's returned object can name role ("input" or "output"), source and/or destination alongside its path or bytes, and all three land on the artifact record unchanged. Absent unless the tool names them.

  • A file above artifacts["max_bytes"] is recorded unreadable, never truncated. The default is 25 MiB (DEFAULT_ARTIFACT_MAX_BYTES).

  • The promoted fields name the model, the tool and the step. Beside the run linkage (run.run_id, run.parent_run_id, run.root_run_id, run.seq, run.prev_event_id), each record carries, where LangChain hands it over: run.name (the step, by LangChain's own naming rule), run.client (the client class, such as ChatOpenAI), and under gen_ai the OpenTelemetry GenAI names, pinned to v1.41.0: gen_ai.request.model, .temperature, .max_tokens, .seed, .top_p; gen_ai.provider.name (the service that served the call, in OTel's well-known values plus openrouter; see below); gen_ai.response.model, .id, .finish_reasons; gen_ai.usage.input_tokens, .output_tokens, .reasoning.output_tokens; gen_ai.tool.name (the serialized tool's own name, never the run name a caller sets) and gen_ai.tool.call.id; gen_ai.prompt.name; and gen_ai.agent.version. openai.response.system_fingerprint sits in OpenAI's own namespace. Every record carries otel.scope: sanning-anchor, its version, and https://opentelemetry.io/schemas/1.41.0. v1.41.0 is the last core OTel release where these names are current; from v1.42.0 core marks them moved to open-telemetry/semantic-conventions-genai, which has no release yet, and Sanning moves the pin deliberately once it does. A field LangChain does not hand over is absent, never empty: no response id when the provider put none on the message (LangChain's own lc_run-… id is never written as the provider's), no token counts when neither usage_metadata nor llm_output has them, no fingerprint from a non-OpenAI-compatible provider. Records anchored before this change keep the old names (model.id, model.id_returned, model.provider, run.tool_call_id); this SDK writes only the new ones.

    handler = AnchorCallbackHandler(
        anchorer,
        record_names=False,          # keep run.name and gen_ai.tool.name out
        agent_version="2026.10.1",   # gen_ai.agent.version on every record
    )
    agent.invoke(
        inputs,
        config={"callbacks": [handler], "metadata": {"gen_ai.prompt.name": "underwrite-v3"}},
    )
    

    record_names=False exists because a record's metadata is visible whenever the record is, even in a pack whose content is withheld, and a tool's name can say more than you meant (lookup_customer_ssn). It omits both names and nothing else; they stay in the committed content, hashed and withheld like the rest.

For the event vocabulary and worked examples, see Trace a LangChain agent.

Hand over a pack

When a compliance person asks for one agent's evidence over one period, the SDK assembles it in one command, with no Node installed:

export SANNING_API_KEY=ANCHOR_READ_KEY   # the key needs the `anchor:read` scope

sanning-anchor bundle \
  --agent claims-triage \
  --from 2026-06-01 --to 2026-06-30 \
  --logs ./logstore \
  --out claims-triage-2026-06.zip

Replace ANCHOR_READ_KEY with a key from the console carrying anchor:read. There is no flag for it: a credential in argv lands in shell history, and this is a command people paste into tickets. A key missing the scope is reported as a scope to widen, never as an absence of evidence.

Flag What it names
--agent The agent's agent_id, as committed in each event's subject.
--from Period start, inclusive: a whole UTC day written YYYY-MM-DD. A time is refused with a usage error. Required for a period pack. A case pack takes no dates: --case with --from is refused with a usage error.
--to Period end: a whole UTC day written YYYY-MM-DD, and that day is included. A time is refused with a usage error. When it is today (the UTC date), the period ends at the end of the last sealed stamp interval instead, and a day after today is refused. Required unless --case is given.
--logs Your sanning.logstore/v1 store root: the local directory holding content/ and records/, or s3://bucket or s3://bucket/prefix.
--out Where to write the pack. A .zip suffix is appended when absent.
--base-url The control plane. Defaults to https://api.sanning.io, or $SANNING_BASE_URL.
--allow-unstamped Assemble even when records in the period are anchored but not yet stamped. Without it the verb refuses. Takes no value.
--case Select a case's records and declare the pack about it. The records are those the plane returns for the case id (case_id, in clear), each kept only when its own signed context.case_id is the case; no window is derived, and --from and --to are refused with it; see One case, no window.
--handoffs-only With --case, pack only the case's hand-off records: the minimum-disclosure selection for handing another organization your side of a case.
--report-file Case file only: a file to put under report/. Takes a path, and may be given more than once.

sanning-anchor --help prints that reference, the exit codes, and the offline command that checks what the verb produced.

The window is the plane's clock, not yours. --from and --to are whole UTC days, matched against each record's received_at (Sanning's receipt time), which the plane sets when it accepts the envelope. That instant can be earlier than the local one you captured just before calling anchor(): 433 ms earlier on a measured production run. A record anchored within a moment of 00:00 UTC can then belong to the neighbouring day, and the pack for the day you expected is short by that record while the command exits 0 and warns about nothing, which is the one outcome a pack's reader cannot detect. Compare the pack's event count against what you anchored, and build the neighbouring day too when they differ.

A period that runs to today ends at the last sealed stamp interval. With --to set to today's UTC date, the pack ends at the end of the last sealed stamp interval before the build, not at midnight: every record in it has a stamp, and two builds in the same interval hold the same records and state the same period. The pack states that end as a time, and the signed text keeps ISO 8601 (2026-10-14 → 2026-10-20T15:00:00.000Z). "Today" is the UTC date the control plane reports, which at 00:30 in London in summer is still the day before: a --to after it is refused. This needs a control plane that answers GET /api/v1/user/records/sealed-through.

Pass prefix to one of S3ObjectStore and the ObjectLogStore wrapper, never both. Each of them prepends it, so the same value on both writes ts/ts/content/... while every reader looks under ts/content/..., and the writes and the reads disagree. bundle refuses correctly, with no record object in your log store, and that message does not name the cause.

That writes one zip: a signed sanning.stamp.evidence/v2 bundle.json beside logs/<event id>.json. Proofs come from the Sanning index; the raw bytes come from your log store and never left it. The verb reads the whole pack offline before it writes anything, the way the kernel's verify reads it, and exits with the code verify gives that pack. A pack that would read failed at the auditor is never produced (exit 1, no file).

A stamp settles after it seals. For the first minutes of its life an interval stamp has not reached the public record. A pack built then is written and reads incomplete, as verify reads it, and the verb exits 2 and prints the kernel's lines. Running it again once the stamp settles writes a new pack in its place. Your records are anchored, retained and stamped throughout, and nothing about them is wrong.

It also refuses to assemble a short pack, in two cases, because a recipient cannot tell a short pack from a complete one:

  • Records whose record object is missing from your store make subject.agent_id unknowable, and one of them may be this agent's.
  • Records that are anchored but not yet stamped have no inclusion proof, so a pack built now omits them and says so nowhere inside itself. The stamper seals on an interval, and running again once it has is usually the whole fix. --allow-unstamped assembles anyway, and then the summary tells you the pack is short so you can say so in the cover note.

No signing key is required. Without one, the container is sealed with a one-time assembly key, and every event inside already carries its agent's own signature. With SANNING_SIGNING_SEED, the pack carries a signed declaration of what it holds.

One case, no window

--case selects a case's records, and takes no --from or --to:

sanning-anchor bundle --case case-4b19de \
  --agent assessor \
  --logs ./logstore --out case-4b19de.zip
  • The pack's records are the ones the plane returns for the case id, kept on their own signed context.case_id. The SDK sends the case id, in clear, in the projection beside every record of a type the plane indexes (index). --case asks the plane for the records filed under the case id (case_id, in clear, 1 to 256 characters), pages to the end, and keeps each one whose own signed context.case_id is the case. It reads nothing else and derives no window. A case pack takes no dates: it holds every record of the case, however long the case runs.
  • The case id only finds candidates. It is the producer's own word and is not signed, so it selects nothing on its own: a row filed under it whose signed record names another case is left out and counted on the summary.
  • Records sent without a projection are not found. A custom one-argument submitter would send none. A custom client must accept the index keyword argument that carries the projection (submit(envelope, index=None)): the Anchorer reads the signature of submit at construction and raises TypeError unless it has a parameter named index or takes **kwargs, rather than drop the projection in silence.
  • A record in the window that names no case refuses a declared pack (the signing seed is set), and an undeclared pack leaves it out and says how many. Pass the case id when you anchor.
  • The pack's period is the span of the records it holds: the earliest to the latest signed_at among them, read from each signed envelope. The pack's records run oldest first by that signed time, never by a time the plane's list sends. It is not a window, so there is nothing to pad. The declaration's period.end is the exclusive bound, one millisecond after the latest record.
  • A case pack holds every record of the case, however long the case runs. --from or --to with --case is a usage error: a case pack takes no dates. The control plane reads the whole case, and a plane that does not say how much of the case fell outside what it read, or says some did (a record dated after its clock, or a plane that predates the whole-case read), is refused: the verb exits 4 rather than build a short pack. An empty selection exits 4 and writes nothing.
  • A case file (several --agent) selects the same way: each pack states its own records' span, and the case file's period line is the span of all of them.

Several agents, one case: the case file

Give --agent more than once, with --case, and the verb writes a case file (evidence-bundle.md §5.6): one pack per agent, each built, declared and verified exactly as a single pack is and sealed by that agent's own key, unpacked under packs/<agent>/ in one zip beside contents.json (an unsigned index of every file and its SHA-256) and HOW-TO-VERIFY.txt. Nobody signs the case file itself.

export SANNING_API_KEY=…
export SANNING_SIGNING_SEEDS=assessor=SEED_A,checker=SEED_B
sanning-anchor bundle --case case-4b19de \
  --agent assessor --agent checker \
  --logs ./logstore --out case-4b19de.zip

Replace SEED_A and SEED_B with each agent's 64-hex signing seed. SANNING_SIGNING_SEEDS holds one <agent>=<seed> entry per --agent, and SANNING_SIGNING_SEED is refused beside it. --logs is given once for every agent, or once per --agent in the same order. A case file exits with the code the kernel's case gives the file it wrote, and writes nothing when that case would read failed; a case reads its worst pack. Every agent named gets a pack in the file, or nothing is written:

Agents' packs Exit Written?
All verified 0 Yes. Each agent's declaration is anchored.
All verified, sandbox 3 Yes. Each agent's declaration is anchored.
Any incomplete (a stamp not confirmed yet included), none failed 2 Yes, with the incomplete packs inside and no declaration anchored. Running it again later writes a new case file in its place.
Any pack failed 1 No. The output names the agent and prints the kernel's lines.
No pack fails alone, and the case fails (through a hand-off) 1 No. The output says the case file would read failed and prints the kernel's lines.
Records not stamped yet, or the record index could not be reached 2 No.
Any agent's run could not run, or the file cannot be assembled or written 4 No.

contents.json's absent[] is written empty. --report-file <path>, given any number of times, adds files under report/ beside a report/README.txt saying no record commits to them.

Every declared pack (SANNING_SIGNING_SEED set), single or in a case file, declares sanning.declaration/v2: each record is signed handoff (a record envelope-spec.md §4.1 governs, claimed in handoffs[]) or step. Each hand-off record's message travels as logs/<event id>.json, exactly JCS(message), the bytes its message_hash commits to. So a full pack reads cleanly as a case, and --handoffs-only is the minimum-disclosure selection for handing another organization your hand-off records alone.

Hand-offs between agents

create_handoff(anchorer=..., case_id=...) records a message that passes between two agents, over any transport: the sender's send writes agent.handoff.sent, the receiver's receive verifies what arrived and writes agent.handoff.received. Both are sanning.agent/1 records, built by build_agent_record and refused before signing unless they read verified: each carries the message's part counts, and the receiver's carries the sender's event_id. A receiver that holds the bytes of a file part names its position in held_parts, which the record lists as held and not checked. Two additions, both offline:

  • How gen_ai.provider.name is decided. It is a signed claim about which service served the call, so it is written only from an endpoint this adapter positively observed, in the client library's own precedence. First, the base-URL field in the client's dumpd() kwargs: openai_api_base (ChatOpenAI), anthropic_api_url (ChatAnthropic), groq_api_base (ChatGroq), xai_api_base (ChatXAI), endpoint (ChatMistralAI). These clients resolve their own LangChain-level variables and the LangSmith gateway into that field at init (OPENAI_API_BASE, ANTHROPIC_API_URL/ANTHROPIC_BASE_URL, GROQ_API_BASE, XAI_API_BASE, MISTRAL_BASE_URL), so the field is what the client will call. When the field is unset, the variable the underlying SDK reads decides (OPENAI_BASE_URL, GROQ_BASE_URL), then the SDK's documented default. The provider is that endpoint's host: a ChatOpenAI pointed at OpenRouter says openrouter. In every other case the field is absent: a client class not listed (ChatDeepSeek serializes as not_implemented, with no kwargs), a host this package does not know (a local server, a proxy, the LangSmith gateway). run.client still records the class. The table is pinned by captures from the published clients in tools/langchain-callback-conformance/provider-captures.json. An endpoint chosen in code, such as a pre-built client=, is not in the serialized form; set the endpoint with the client's base_url instead.
  • receive(expected_sender=...) refuses a message whose signed sender key is not the one you name, with HandoffUnexpectedSenderError, before anything is recorded. Either case of a key is the same key.
  • handoff.verify(attachment=..., wire_bytes=..., expected_sender=None) reads a message before you decide: it runs the checks receive runs and returns a HandoffVerifyResult (message, message_hash, message_bytes_hash, sequence, content_type, sender_public_key, sender_record, sender_run_records), and records nothing. A message that is not the one the sender committed to raises HandoffAlteredError; call receive with the same input to record the tamper. Then receive records your decision.
  • handoff.confirm(sent=..., received_record=...) lets the sender check the receiver's own signed record (received.received_record, sent back over your transport) with the kernel's verify_envelope and read_handoffs. It returns a HandoffConfirmation with confirmed, reasons, outcome, receiver_public_key and readings, and reasons names every check that failed. A receipt is untrusted, so nothing about it raises.

outcome is a required keyword argument of receive: the agent decides, accepted, rejected or failed, then receive records that decision, before your agent acts on the message. There is no default: this SDK never signs a decision on your behalf. Omitting outcome is a TypeError from Python itself, since it is a required keyword argument; passing it anyway with None or a value outside those three words raises HandoffOutcomeRequiredError before anything verifies or is written. The spec has no word for "received, not yet decided", which is a real limitation Hand off between agents states in full, along with the refusal table. Both SDKs return the same reason names, graded against one recorded cross-language run.

Agent records (sanning.agent/1)

An agent.* record follows the sanning.agent/1 vocabulary. Build one with build_agent_record: it reads the record against the vocabulary's schemas, offline, and raises InvalidRecordError for a record that does not read verified, with the spec's reason code in reason and a JSON Pointer in at. build_envelope runs the same check, so a record that breaks the schema is never signed. Every record the SDK builds, of any type, carries a fresh random context.salt, which the builder writes and no builder argument sets. Below full, Sanning does not receive it. A record you build yourself and pass as build_record, or to build_envelope, is signed with whatever well-formed salt it carries, and the spec makes no finding on a weak one. sanning_anchor.salt.fresh_salt is internal and not public API. build_event_record, and so Anchorer.anchor called with an event_type, builds event (the default), checkpoint and declaration. It refuses an agent.* type with event_schema_missing at /extras/event_schema, because only build_agent_record builds one, and any other type, such as claims.decision, with event_type_not_in_set at /event_type, because a verifier reads it failed. build_envelope refuses a hand-built record of such a type the same way. To sign and chain an agent.* record, pass build_record to anchor: it is called (subject, chain_key, previous_hash) under the chain lock and must return a record whose event.content_hash is the hash of the call's content. recording_status().refused lists each refused record by event id, type, reason and at, including a record build_record returned that is not one it may sign.

from sanning_anchor import agent_content, build_agent_record, decision_content

content = agent_content(decision_content(name="quote_issued", value={"rate": "3.50"}))
record = build_agent_record(
    event_type="agent.decision",
    subject={"type": "agent", "agent_id": "claims-triage"},
    content=content,  # content.bytes are the JCS bytes content_hash commits to: retain them
    metadata=metadata,  # run, otel and decision, as the schema names them
)

agent_content(value, scrub_credentials=True) replaces the whole value of every credential-shaped key with "[scrubbed]" before hashing, and the record built from it says so in context.content_scrubbed. read_agent_record(record) returns the reading without raising.

Verify a pack

Verification lives in sanning-proof and needs no account, no key and no network. The case reader reads one pack or a whole case file, and bundle prints it as its next step (the case command reads a v2 pack from sanning-proof 0.13.0):

unzip pack.zip -d pack
sanning-proof case pack

The library call grades one bundle on its own:

import json, pathlib
from sanning_proof import verify_evidence_bundle

pack = pathlib.Path("pack")
verdict = verify_evidence_bundle(
    json.loads((pack / "bundle.json").read_bytes()),
    content={p.stem: p.read_bytes() for p in (pack / "logs").glob("*.json")},
)
verdict.status  # "verified"

Whoever receives your pack does not need this SDK. For what a verdict proves, and the four things it does not claim, see Verify.

Parity with the TypeScript SDK

sanning-anchor and @sanning/anchor produce the same signed bytes for the same event, and the same signed pack body, byte for byte, for the same pack, so a mixed fleet hands over one pack. Both are gated against the same pinned corpus for the envelope, and against an oracle that imports neither SDK for the hand-over pack, so neither language can pass by agreeing with the other.

The LangChain adapters commit JSON.stringify(payload), which json.dumps is not, so this package reimplements it against a cross-language corpus generated from the real JSON.stringify.

One case refuses rather than diverges: an integer outside ±(253−1), a set, a reference cycle. JavaScript would round the first one, and two different 64-bit trace ids can round to the same double, which is a false integrity verdict rather than a formatting difference. So it fails at anchor time, while you can still fix it, rather than at verification, when the record is already sealed. Convert the value before anchoring it.

Development

pip install -e ".[dev]"
black --check src tests
pytest -q

MIT licensed.

Metadata

Release files for sanning-anchor 0.21.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sanning-anchor 0.21.1
File Size Uploaded Provenance Actions
sanning_anchor-0.21.1.tar.gz 334.2 kB With provenance Details for sanning_anchor-0.21.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sanning-anchor 0.21.1
File Interpreter ABI Platform Actions
sanning_anchor-0.21.1-py3-none-any.whl Python 3 none any Details for sanning_anchor-0.21.1-py3-none-any.whl

Total release size: 684.5 kB

Release files / sanning_anchor-0.21.1.tar.gz

Download URL sanning_anchor-0.21.1.tar.gz
Size 334.2 kB
Tags Source
SHA-256 checksum
How to use checksums
60ac15ede0a653ed943a9fde3b88f514f34162c11511db739dd2eca485b38076
BLAKE2b-256 checksum
How to use checksums
45f4d2df6d57e3b8de59ee34b0a33d32aa04688a361b7ba45fd420ca4b819664
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / sanning_anchor-0.21.1-py3-none-any.whl

Download URL sanning_anchor-0.21.1-py3-none-any.whl
Size 350.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
218bb80dbf46c567cf2fdfbce92fde3e12956fd2256f983cbc527d0685346d5c
BLAKE2b-256 checksum
How to use checksums
5ddd5c3aed68ec70fee0f9ddf33680c028c39de04105f7bbe7ac607195f82271
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Security for sanning-anchor 0.21.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for sanning_anchor-0.21.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page