You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Verifiable Event Sync (VES) v1.0 service for deterministic event ordering, state projection, cryptographic commitments, and zero-knowledge compliance proofs.
Overview
The StateSet Sequencer is the central truth clock for distributed commerce systems, bridging AI agents with cryptographically verifiable infrastructure. It implements the complete VES v1.0 protocol specification.
Key Features
Deterministic Event Ordering: Monotonic sequence numbers per (tenant, store) pair
Exactly-Once Delivery: Idempotent event ingestion with event_id and command_id deduplication
Cryptographic Commitments: Merkle trees with domain-separated hashing for audit trails
Agent Signatures: Ed25519 signature verification for event authenticity
STARK Compliance Proofs: Zero-knowledge proofs for regulatory compliance
On-Chain Anchoring: Ethereum L2 commitment anchoring for trustless verification
Offline-First: SQLite outbox pattern for local CLI agents
Payload Encryption: AES-GCM encryption at rest with key rotation support
Schema Validation: JSON Schema validation for event payloads
# Start the sequencer and PostgreSQL
docker-compose up -d
# Check health
curl http://localhost:8080/health
# Check readiness (verifies database connectivity)
curl http://localhost:8080/ready
# Example: Get head sequence (with bootstrap admin key)
curl -H "Authorization: ApiKey dev_admin_key" \
"http://localhost:8080/api/v1/head?tenant_id=<uuid>&store_id=<uuid>"
Local Development
# Build the project
cargo build
# Set required environment variablesexport DATABASE_URL="postgres://sequencer:sequencer@localhost:5433/stateset_sequencer"export BOOTSTRAP_ADMIN_API_KEY="dev_admin_key"export ALLOW_INSECURE_LOCAL_DB=true
# Run the server (migrations run automatically)
cargo run
# Or run migrations manually
cargo run --bin stateset-sequencer-admin -- migrate
# Backfill VES state roots (if upgrading from older versions)
cargo run --bin stateset-sequencer-admin -- backfill-ves-state-roots
Cargo features
The default build enables full. Notable feature flags:
Feature
Enables
pqc
Post-quantum crypto (ML-DSA-65, ML-KEM-768)
stark
STARK validity/compliance proof verification
integration
Test-only modules that need a live database
gRPC, OpenTelemetry, L2 anchoring, JSON Schema validation and the SQLite outbox
are always compiled in and are not behind feature flags. They were once
listed as flags, but each was an empty feature that gated no code, so turning
one "off" changed nothing about the resulting binary. They were removed rather
than left as no-ops.
The stark feature depends on the ves-stark-* crates in the separate
stateset-stark workspace, expected
at ../stateset-stark. They are path dependencies that cargo must resolve even
when the feature is off, so that checkout must be present to build at all.
To build/test the core sequencer without the STARK proof endpoints (e.g. if
you don't have stateset-stark checked out alongside this repo, the proof
endpoints are simply not mounted):
cargo build --no-default-features --features pqc
Upgrading the STARK dependency
stateset-stark is a path dependency on a separate repository, so its
commits are not captured by this repo's Cargo.lock on their own. CI pins it to
an exact commit via the STARK_REF variable in .github/workflows/ci.yml.
Tracking its default branch instead meant every upstream commit silently
invalidated Cargo.lock and turned every --locked CI job red, with no change
in this repository. Upgrade deliberately, in a single commit:
# 1. Move the local checkout to the commit you want
git -C ../stateset-stark checkout <new-sha># 2. Re-resolve the ves-stark-* crates
cargo update -p ves-stark-prover -p ves-stark-verifier \
-p ves-stark-primitives -p ves-stark-batch
# 3. Verify, then commit Cargo.lock and the new STARK_REF together
cargo test --locked --all-targets
CI note: because the ves-stark-* crates live in a private repo, CI fetches
stateset-stark using a STARK_REPO_TOKEN repository secret (a token with read
access to stateset/stateset-stark). Add it under Settings → Secrets and
variables → Actions. The lint/test/coverage jobs build with the core feature
set (no stark) so they don't compile the private crates.
# List commitments
GET /api/v1/ves/commitments?tenant_id=<uuid>&store_id=<uuid># Create commitment for sequence range
POST /api/v1/ves/commitments
{
"tenant_id": "uuid",
"store_id": "uuid",
"sequence_start": 1,
"sequence_end": 100
}
# Anchor commitment on-chain
POST /api/v1/ves/commitments/{batch_id}/anchor
VES Proofs
# Submit validity proof (batch ZK proof)
POST /api/v1/ves/validity-proofs
{
"batch_id": "uuid",
"proof_type": "stark",
"proof_data": "base64-encoded-proof",
"public_inputs": { ... }
}
# Submit compliance proof (per-event encrypted proof)
POST /api/v1/ves/compliance-proofs
{
"event_id": "uuid",
"proof_type": "stark",
"encrypted_payload": "base64-encoded",
"public_inputs": { ... }
}
# Get inclusion proof for an event
GET /api/v1/ves/inclusion-proofs/{event_id}
Agent Key Management
# Register agent public key
POST /api/v1/agent-keys
{
"tenant_id": "uuid",
"agent_id": "uuid",
"public_key": "base64-encoded-ed25519-public-key",
"valid_from": "2025-01-01T00:00:00Z",
"valid_until": "2026-01-01T00:00:00Z"
}
# List agent keys
GET /api/v1/agent-keys?tenant_id=<uuid>&agent_id=<uuid># Revoke agent key
DELETE /api/v1/agent-keys/{key_id}
Legacy Endpoints
# Get events (legacy format)
GET /api/v1/events?tenant_id=<uuid>&store_id=<uuid>&from=0&limit=100
# Get head sequence
GET /api/v1/head?tenant_id=<uuid>&store_id=<uuid># Get entity history
GET /api/v1/entities/{entity_type}/{entity_id}?tenant_id=<uuid>&store_id=<uuid>
Health & Metrics
GET /health # Basic health check
GET /ready # Readiness check (database connectivity)
GET /metrics # Prometheus metrics
Gap-Free Sequences: No missing sequence numbers within a stream
Linearizable Ordering: Total ordering via PostgreSQL SELECT FOR UPDATE
Verifiable History: Merkle proofs for event inclusion verification
Domain Separation: All hashes include domain separators per VES spec
Immutable Log: Append-only event storage with no mutations
Testing
# Run all tests
cargo test# Run ignored integration tests (requires PostgreSQL and DATABASE_URL)
cargo test --workspace --tests -- --ignored
# Run with output
cargo test -- --nocapture
# Run benchmarks
cargo bench
Admin CLI
# Run migrations
cargo run --bin stateset-sequencer-admin -- migrate
# Backfill VES state roots
cargo run --bin stateset-sequencer-admin -- backfill-ves-state-roots
# Dry run (preview changes)
cargo run --bin stateset-sequencer-admin -- backfill-ves-state-roots --dry-run