How the Python and SQLite W1 participant works

For implementers. Follow verification into the database transaction that records the charge, then compare its outcome with the Node.js participant.

On this page
  1. Reproduce the exchange
  2. Run the Python participant on its own
  3. Implementation and observation
  4. Scope

This is a second, locally runnable implementation of the public http6-w1-00 credit-charge profile. It can produce and consume the full fixture catalog, execute the eleven-case exchange with the Node.js participant, and retain the resource records for inspection. The human approval is a public test authenticator input. The agent use case is a planner delegating two competing six-credit tool calls against one ten-credit account.

Read the measured results or open the W1 specification and public vector guide.

Reproduce the exchange

Use Python 3.10 or later, the jsonschema package with draft 2020-12 support, a loadable libsodium shared library with Ed25519, and Node.js 22 or later for the released participant. Python supplies the SQLite driver. If required, install the Python dependency in your selected environment with python3 -m pip install -r requirements.txt and install libsodium using your operating system's package manager.

Run from this directory with a fresh output path.

python3 -B run_exchange.py --vectors ../w1-public-vectors-00 --out w1-exchange-new

The coordinator runs both producers and both consumers as separate processes. The Python participant receives a temporary directory with exactly the 13 manifest-listed JSON files and their manifest. The coordinator invokes the released Node executable through its public command-line interface. Both comparators test the actual reports and the five published comparison controls. The process writes REPORT.md, both bundles, both reports, the step and concurrency evidence, the SQLite archive and a checksum record. A nonzero exit identifies a failed run. Either worker may win in the overlapping race. Timestamps, SQLite file hashes, and the observed overlap duration can vary between runs.

Run the Python participant on its own

python3 -B w1.py --vectors ../w1-public-vectors-00 identify
python3 -B w1.py --vectors ../w1-public-vectors-00 emit from-python.json
python3 -B w1.py --vectors ../w1-public-vectors-00 consume from-node.json node-to-python.json observations.json state
python3 -B w1.py --vectors ../w1-public-vectors-00 compare node-to-python.json python-to-node.json

Supply the other participant's generated bundle to consume and its reciprocal report to compare. Give the consumer new report, observation, and state paths. A build ID is the SHA-256 digest of a reproducible list of source file digests. The recorded provenance also gives the runtime and library versions.

Implementation and observation

Component Function
wire.py Constructs and verifies compact JWS and HTTP message signatures with libsodium. Checks canonical JSON, the public schema, issuer roles, freshness, covered fields and the request association.
domain.py Evaluates human admission, grant restriction, runtime keys, provider policy, shared spending, revocation and resource commitment. For the deterministic producer challenge the public input fixes the opaque permit ID. The authority derives the permit terms from the authorized request. The provider derives and signs the corresponding receipt in the transaction that posts the row or terminal closure.
storage.py Uses separate SQLite files for the authority, provider and keeper. A unique operation key and a write transaction serialize competing effects. The provider has its own gate, accepted permits, account rows and disclosure log. The keeper records acknowledged authority state and validates recovery against a signed checkpoint.
corpus.py Verifies the public manifest, builds packets from unsigned inputs, loads the peer's bytes and compares observations to the public results.
w1.py Runs the producer and consumer interfaces. Two workers meet at a barrier before contending on separate SQLite connections. The consumer records each interval and reopens the provider journal to observe the winner.
run_exchange.py Exchanges bundles in both directions, exercises both comparators and the five controls, checks the Python producer and consumer with the published answers removed, and archives the measured evidence.

Each reset run gets a fresh database directory. The SQL operation key is scoped to the configured compute.example service and lab account. The recovered provider row has a unique row identifier, amount, operation, time and signed receipt. During the partition case the provider can finish an eligible pre-issued permit using its local database. While an authority restore is on hold it cannot post a new charge.

For a second observation of case 05, extract the SQLite files into an empty directory. Run the following from that directory with the SQLite command-line client.

sqlite3 -readonly 05/post-once/provider.sqlite "SELECT rowID, op, units FROM terminal WHERE kind='outcome';"
sqlite3 -readonly 05/post-once/authority.sqlite "SELECT op, units, status FROM operations;"

The expected provider row is row-op-41 | op-41 | 6. The authority reports op-41 | 6 | settled. The observer report gives the corresponding read-only results for all scenarios.

Scope

The input contract is the public W1 profile, vector instructions, schema and JSON cases. The Python implementation uses its own policy engine, cryptographic binding and storage code. The same assistant previously worked on the reference kit. This trial used one host, one operator and separately invoked runtimes. It establishes local file interchange and measured agreement. Separate organizational administration, live TLS between parties, production identity assurance and deployment durability require additional evidence. Every key in these runs is a published test key.