Skip to content

Comments

feat: EscrowSet + KeriRuntime for serverless composition#71

Open
seriouscoderone wants to merge 3 commits intoTHCLab:masterfrom
seriouscoderone:feat/serverless-composition
Open

feat: EscrowSet + KeriRuntime for serverless composition#71
seriouscoderone wants to merge 3 commits intoTHCLab:masterfrom
seriouscoderone:feat/serverless-composition

Conversation

@seriouscoderone
Copy link

Summary

  • EscrowSet<D> replaces the anonymous 5-tuple from default_escrow_bus with a named struct — callers access escrows by name (escrows.partially_witnessed) instead of positional destructuring
  • default_escrow_bus now accepts Option<NotificationBus> — Lambda handlers can inject an SQS-backed bus for async dispatch while None preserves existing in-process behavior
  • KeriRuntime<D> extracts the shared KERI processing stack (processor, storage, escrows, notification_bus) from Controller into a standalone public struct so serverless handlers can compose without pulling in TEL or fighting private fields
  • Controller<D,T> refactored to compose over KeriRuntime<D> via a public kel field

All 13 callers of default_escrow_bus updated across keri-core, keri-sdk, controller, and watcher components.

Test plan

  • cargo check --all-features compiles
  • cargo check --package keri-core --no-default-features --features query (no-redb) compiles
  • cargo test --all-features — all 113 tests pass (3 ignored, unchanged)
  • KeriRuntime::new(db) works (validated implicitly by existing Controller test)
  • KeriRuntime::with_config(db, config, Some(bus)) accepts a custom bus

🤖 Generated with Claude Code

seriouscoderone and others added 3 commits February 18, 2026 17:47
…tecture

Gate redb behind `storage-redb` feature flag (default ON) in keri-core and
teliox so the core protocol logic can compile and run without redb. This
enables future alternative storage backends (e.g., DynamoDB for serverless).

Key changes:
- Split EventStorage constructors: generic `new()` (no mailbox) vs
  `new_redb()` (RedbDatabase with mailbox) vs `new_with_mailbox()` (inject)
- Make mailbox_data an Option<MailboxData> to support non-redb backends
- Remove Any bound from EventValidator
- Gate TelLogDatabase, teliox EscrowDatabase, and escrow module behind
  storage-redb feature
- Genericize teliox escrow structs over K: EventDatabase for KEL storage
- Add in-memory MemoryDatabase implementing all database traits for
  validation and testing
- Move rkyv_adapter to database::rkyv_adapter (not under database::redb)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace the concrete HashMap-based NotificationBus with a trait-based
dispatch architecture. NotificationBus is now a Clone-able wrapper around
Arc<dyn NotificationDispatch>, enabling alternative notification backends
(e.g. SQS for serverless) without adding generic type parameters anywhere
in the codebase.

- Add NotificationDispatch trait with dispatch() and register_observer()
- Extract current HashMap logic into InProcessDispatch (RwLock + OnceLock)
- Add NotificationBus::from_dispatch() for custom implementations
- Change register_observer from &mut self to &self across all processors
- Add RwLockingError variant to keri-core Error enum

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace the anonymous 5-tuple return from default_escrow_bus with a named
EscrowSet<D> struct, accept an optional NotificationBus parameter, and
introduce KeriRuntime<D> in keri-sdk as a shared composition layer.

These changes address three problems that block serverless (Lambda) use:

- Anonymous tuple was fragile: callers positionally destructured five
  Arc'd escrows and adding a sixth would break every call site. EscrowSet
  gives named fields so callers pick what they need.

- Bus couldn't be injected: default_escrow_bus always created an
  in-process NotificationBus internally. Lambda handlers need SQS-backed
  dispatch so notifications fan out to queues instead of running inline.
  Accepting Option<NotificationBus> lets callers pass a custom bus while
  None preserves existing default behavior.

- Controller buried its internals: the SDK Controller created processor,
  storage, bus, and escrows in new(), discarded escrows, and kept fields
  private. KeriRuntime<D> extracts the shared KERI processing stack
  (processor, storage, escrows, notification_bus) into a standalone
  public struct so Lambda handlers can be thin shells — deserialize
  request, call runtime, serialize response.

All 13 callers of default_escrow_bus updated. Controller<D,T> now
composes over KeriRuntime<D> via a public `kel` field.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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