EnvelopeFlow.Stores.Postgres
0.1.0-alpha.3.1
dotnet add package EnvelopeFlow.Stores.Postgres --version 0.1.0-alpha.3.1
NuGet\Install-Package EnvelopeFlow.Stores.Postgres -Version 0.1.0-alpha.3.1
<PackageReference Include="EnvelopeFlow.Stores.Postgres" Version="0.1.0-alpha.3.1" />
<PackageVersion Include="EnvelopeFlow.Stores.Postgres" Version="0.1.0-alpha.3.1" />
<PackageReference Include="EnvelopeFlow.Stores.Postgres" />
paket add EnvelopeFlow.Stores.Postgres --version 0.1.0-alpha.3.1
#r "nuget: EnvelopeFlow.Stores.Postgres, 0.1.0-alpha.3.1"
#:package EnvelopeFlow.Stores.Postgres@0.1.0-alpha.3.1
#addin nuget:?package=EnvelopeFlow.Stores.Postgres&version=0.1.0-alpha.3.1&prerelease
#tool nuget:?package=EnvelopeFlow.Stores.Postgres&version=0.1.0-alpha.3.1&prerelease
PostgreSQL operational delivery and device stores
PostgresDeliveryMigrations.Catalog and PostgresPushInstallationMigrations.Catalog provide feature-owned histories for explicit inspection/planning/adoption through optional PostgresMigrationRunner. See upgrade operations. Initializers remain explicit; workers and construction never migrate. Delivery version-one envelope writes are opt-in through PostgresDeliveryPayloadOptions.WriteVersionedPayloads after every reader is upgraded. Legacy JSON remains readable. Unreadable/future target or outbox content is retained in scoped fenced quarantine without a new provider/hook invocation. Optional IOperationalPayloadInspectionStore exposes bounded safe metadata and explicit version-CAS quarantine, independently from uncertainty and without implicit repair/replay.
Create PostgresDeliveryStore with an application-owned NpgsqlDataSource and explicitly call InitializeAsync during your migration/deployment process. Schema upgrades and admission are transactional, claims use FOR UPDATE SKIP LOCKED, and leases compare database time. Message/target payloads are stored as operational data; configure database encryption/access controls and retention independently from conversation history. No connection is opened by Core or DI implicitly.
Duplicate admission pins the retained message while reading its request fingerprint and ordered delivery IDs. Concurrent identity retention skips the pinned parent until that admission transaction finishes, so both Existing and Conflict results preserve a coherent original target list. Payload retention can still progress; a later pass removes the unpinned identity. Cancellation rolls back the read transaction and releases the pin without changing admission state.
Both ordinary and participating-transaction submission begin lock the exact scoped/fenced Pending row before sampling database time. A row-lock wait cannot carry an earlier eligibility check past the lease or delivery expiry and authorize a provider call. A materialized ownership row feeds a dependent clock sample within one SQL statement; cancelled waits and caller-owned rollback publish no begin or attempt.
Payload retention rechecks pending application events after acquiring work ownership, so a newer evidence event cannot be missed by the earlier selection snapshot. Identity retention also owns and rechecks every work and event row beneath each selected parent before deletion. A concurrent replay, evidence update or event quarantine cannot be erased by an earlier terminal-state snapshot. Busy children skip that whole parent while other eligible parents can progress; the purge result counts only payloads and parents actually removed. Ownership uses the existing parent/work/event indexes and adds no schema or public API.
Delivery payload text must be well-formed Unicode within the 262,144-byte UTF-8 bound. The public payload writer rejects malformed text before serialization, and the reader refuses it, preserving the same exact text/fingerprint contract as request admission. Central scope/identity validation also rejects malformed UTF-16 before serialization can alias another identifier; valid Unicode remains unnormalized.
Optional IDeliveryOperationalHealthStore returns a coherent bounded sample per delivery state and unfinished outbox, with truncation/lower-bound semantics and oldest observed eligible times. It reads indexed metadata without decoding target/event bodies. Applications authorize scope and select readiness thresholds; retained terminal history does not hide the Pending sample.
Delivery schema six adds permanent repair audit records and nullable original-event proof anchors. IOperationalPayloadRepairStore restores only the exact original admitted target or anchored original event, under current revision/fence and a stable operation ID. Target mutation/outbox/audit commit together; retries preserve identity, attempts, provider evidence and uncertainty. Enable PostgresDeliveryPayloadOptions.WriteRepairProofs to anchor new events after upgrading schema/readers; unanchored historical events, purged targets and ambiguous legacy target ordinals cannot be restored. Audit capacity is 100,000 operations globally. Custom repair stores must preserve these proof, atomicity, scope, fencing and idempotency guarantees. See the repair runbook.
Delivery migration 4 adds ordered indexes on work (message_id, target_ordinal, id) and events (delivery_id, occurred_at, id). They bound repeated-admission and per-delivery history lookups and support the child side of foreign-key checks during retention. Explicit initialization creates the same indexes. Existing migration checksums are preserved. Apply this transactional index migration during the application's schema deployment window; index construction on retained data can block writers. The indexes add ordinary write/storage cost and do not change claim priority, fencing or delivery semantics.
The store implements optional IDeliveryDeferralStore; pass DeliveryDeferralOptions to configure policy waits separately from provider retry attempts. A full-scope, Pending claim with the exact revision/fence and active database-time lease can atomically persist its next due time, count and fixed-reason outbox evidence while releasing ownership. Eligibility floors and minimum progress are rounded up to PostgreSQL microseconds, so 100-nanosecond input precision never makes a send eligible earlier. The database clock is sampled after acquiring the row lock and checked again at the atomic transition. Original expiry is preserved; expiry and count/horizon/malformed refusals terminalize owned work with evidence. Accepted, Unknown and Submitting rows remain ineligible.
This addition uses ef_delivery_work.deferrals integer NOT NULL DEFAULT 0 for legacy rows. Explicit InitializeAsync now validates/adopts known unversioned baselines and applies the checksummed delivery catalog atomically. Delivery schema 5 replaces raw composite scope/idempotency indexes with bounded generated SHA256 keys, retaining exact raw scope/idempotency comparisons. Original request hashes, IDs, targets and operational state remain unchanged. Stop old binaries for the table/index rewrite; old conflict targets are incompatible. See bounded-key deployment. Existing due-time indexes serve deferred Pending work without another polling queue or hosted endpoint.
PostgresPushInstallationStore implements the optional IPushInstallationStore and IInstallationStore contracts for Web Push, APNs and Firebase. Create it with the same application-owned data source and explicitly initialize its schema. Register it under both interfaces when the application uses both Web Push registration helpers and native/lifecycle operations; the package does not register endpoints or authentication for you.
The device-store initializer performs transactional DDL without scanning or rewriting registrations. There are no existing deployments requiring an endpoint migration. Every Web Push registration canonicalizes endpoint identity before checking ownership, including host case, default port, dot segments, Unicode/punycode aliases and percent-triplet hex case. Encoded delimiters and meaningful query differences remain distinct. Repeated initialization preserves existing rows and binding revisions; ordinary DDL can still acquire schema locks.
Use InstallationRegistrationService for untrusted browser subscription validation before persistence, including canonical unpadded base64url and P-256 coordinate/curve checks. The native registration method validates provider/token shape and well-formed Unicode before destination hashing or database I/O, and normalizes APNs hexadecimal casing. Opaque Firebase values are preserved without inventing an ASCII format. Full scope, recipient, identity namespace and identity subject are checked on reads and compare-and-swap mutations. Installation IDs and provider destinations are unique within the full messaging scope; competing owners receive a conflict with no existing registration data. Refresh increments the revision, transfer requires the exact expected owner/revision and stays within the same scope, and removal prevents stale logout/provider invalidation from deleting a newer binding.
Registration creation/refresh uses a transaction and a per-installation PostgreSQL advisory lock; independent installation writes remain concurrent. Destination uniqueness is also enforced by database constraints. SHA-256 keys keep composite indexes bounded even for maximum-length Unicode identifiers and 4096-character destinations. Exact values are retained for scope/owner checks, and digest collisions conservatively prevent a conflicting registration. Hashing is an indexing strategy, not protection of credentials: subscriptions, Web Push keys and native tokens are persisted as sensitive operational data.
Registration create/refresh/transfer observations round upward to PostgreSQL microseconds, and immediate/reopened results retain the same value. This prevents precision conversion from making an older APNs invalidation cover a newer registration. IsCurrentAsync independently rounds its current-time upper bound down and maximum-age lower bound up, preserving both freshness limits, including before the PostgreSQL epoch. Unrepresentable upper observations fail before mutation; no stored-row rewrite is performed.
ListAsync/ListNativeAsync return kind-specific registration-ID pages of 1–1000 records. IsCurrentAsync checks exact owner/revision, refresh age, future timestamps and Web Push expiration against the caller's trusted current time. Check immediately before queued submission. This is a database revision guard, not an atomic transaction with an external push provider.
Focused durable contracts use an actual PostgreSQL instance:
ENVELOPEFLOW_TEST_POSTGRES='Host=localhost;Database=envelopeflow_tests;Username=envelopeflow;Password=local-only' \
dotnet test tests/Recipients/EnvelopeFlow.Recipients.Tests --configuration Release
The application-owned messaging sample exercises registration, stale queued-work rejection, a local provider, correlated callbacks and hooks without requiring conversation storage.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- EnvelopeFlow.Delivery.Abstractions (>= 0.1.0-alpha.3.1)
- EnvelopeFlow.Recipients.Abstractions (>= 0.1.0-alpha.3.1)
- EnvelopeFlow.Stores.Migrations.Postgres (>= 0.1.0-alpha.3.1)
- Npgsql (>= 10.0.3)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on EnvelopeFlow.Stores.Postgres:
| Package | Downloads |
|---|---|
|
EnvelopeFlow.Routing.Stores.Postgres
Explicit PostgreSQL routing intents and atomic audited fallback persistence. |
|
|
EnvelopeFlow.Integrations.Feedback.Stores.Postgres
Atomic durable provider feedback correlation, recipient policy effects and replay retention. |
|
|
EnvelopeFlow.Throttling.Stores.Postgres
Optional PostgreSQL provider budgets and atomic provider/policy/delivery submission admission. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0-alpha.3.1 | 51 | 11/22/2026 |
| 0.1.0-alpha.2.1 | 81 | 11/9/2026 |