Skip to content

feat(sigild): DB + atomic consume + revocation/audit MVP (CTX-0023) - #31

Merged
Xuepoo merged 1 commit into
mainfrom
ctx-0023/feat-sigild-mvp
Aug 31, 2026
Merged

feat(sigild): DB + atomic consume + revocation/audit MVP (CTX-0023)#31
Xuepoo merged 1 commit into
mainfrom
ctx-0023/feat-sigild-mvp

Conversation

@Xuepoo

@Xuepoo Xuepoo commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Summary

Implements CTX-0023 — Sigild server MVP: DB + atomic consume + revocation/audit per docs/research/media-credential/usage/credential-design.md §4.

  • DB schema covers / credentials / credential_consumptions / audit_events (Postgres normative, SQLite WAL with rusqlite bundled, migrations/001_initial.sql, SCHEMA_SQL in db.rs)
  • Atomic consume via UPDATE ... RETURNING inside BEGIN IMMEDIATE + Idempotency-Key (UNIQUE credential_id, idempotency_key), verify is read-only, revoke + audit trail
  • Carrier integration via capglyph_core::{framing,ecc}encode_credential_token / decode_credential_token (CBOR seal + Repetition8, soft-bit LLR path, KMS K_mac/K_embed HMAC split)
  • HTTP axum: POST /v1/credentials (issue), /verify, /consume, GET /v1/credentials/{id}, POST /v1/credentials/{id}/revoke (header Idempotency-Key)
  • Binary capglyphd (crates/capglyph-server/src/bin/capglyphd.rs)
  • Docs crates/capglyph-server/README.md + docs/sigild-mvp.md

Tests

  • cargo test -p capglyph-server --test concurrent_consume — 8 tests including concurrent no double-spend (10 threads max_uses=1 → 1 success, max_uses=3 → 3, idempotent replay, verify readonly, revoked/expired fail-closed, audit)
  • cargo test --workspace / cargo clippy --workspace --all-targets -- -D warnings / cargo fmt / cargo check --lib --target wasm32-unknown-unknown --no-default-features all pass
  • WASM clean: capglyph-server is a separate crate not in capglyph lib graph

How to test

cargo test -p capglyph-server
cargo run -p capglyph-server --bin capglyphd -- --db /tmp/capglyphd.db --listen 127.0.0.1:3000
curl -X POST http://127.0.0.1:3000/v1/credentials -H 'content-type: application/json' -d '{"cover_id":"...","scope":["download:asset:42"],"max_uses":1}'

Closes CTX-0023

Implements credential-design.md §4: covers/credentials/credential_consumptions/audit_events (SQLite/WAL, rusqlite bundled)
- atomic consume via UPDATE ... RETURNING in BEGIN IMMEDIATE, with
  Idempotency-Key handling (UNIQUE credential_id, idempotency_key)
- verify read-only, revoke, audit trail
- carrier integration via capglyph_core::{framing,ecc} (CBOR seal + Repetition8, K_mac/K_embed HMAC split, soft-bit path)
- axum HTTP: POST /v1/credentials/{verify,consume,revoke}, GET /v1/credentials/{id}
- bin capglyphd (capglyph-server crate) + migrations/001_initial.sql
- concurrent consume no-double-spend tests (max_uses=1/3, idempotent replay, verify readonly, revoked/expired fail-closed)
- cargo fmt/clippy/test/wasm check pass

Closes CTX-0023
@Xuepoo
Xuepoo force-pushed the ctx-0023/feat-sigild-mvp branch from 46bc36b to 7fd2c47 Compare August 31, 2026 14:15
@Xuepoo
Xuepoo merged commit 5fefc51 into main Aug 31, 2026
8 checks passed
@Xuepoo
Xuepoo deleted the ctx-0023/feat-sigild-mvp branch August 31, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant