Add Heimdall patron support intake

This commit is contained in:
Meta Vens 2026-06-09 17:16:27 +01:00
commit bb1b1056be
21 changed files with 625 additions and 13 deletions

View file

@ -73,5 +73,7 @@ After bootstrap, the next session should start implementing the first vertical s
- a formal proposal that affects either project work or GameCult policy/structure
- `Ledger Entry`
- an immutable record of patron points, contributor points, nominal compensation, or adjustments
- `Patron Support Event`
- an auditable support fact recorded manually or through a Heimdall-verified external provider event; Bifrost derives patron points and voting tier snapshots from these events
- `Payout Proposal Batch`
- an admin-reviewed grouping of payout recommendations derived from approved ledger data

View file

@ -97,7 +97,10 @@ Implementation requirements:
- calculate patron points from current recurring support plus historical donations: implemented by `PatronageService`
- apply the concept-doc rule that historical donations are halved after one month and then continue decaying: implemented for effective patron point calculation
- expose both raw support history and current effective patron points: implemented on the ledger surface
- ingest Patreon/Heimdall provider events into the same service path: pending
- ingest Patreon/Heimdall provider events into the same service path: implemented through `/heimdall/patron-support/events`
- ingest PayPal/Heimdall checkout, subscription, refund, reversal, and chargeback facts into the same service path: implemented as provider metadata plus support adjustments
External provider support facts are not payment webhooks in Bifrost. Heimdall owns provider webhook verification and account linking. Bifrost accepts only Heimdall-signed support facts, resolves the linked `HeimdallAccountId`, deduplicates by provider event id, records support through `PatronageService`, and refreshes the derived patron tier.
### Contributor Points

View file

@ -85,6 +85,7 @@ This keeps Reddit useful without making subreddit mechanics the secret constitut
- canonical feature-request and governance topic threads
- topic comments, support, objections, questions, Persona approvals, dispatch promotion, and topic receipts
- user, patron, member, contributor, and agent transport events when they affect work, priority, reward, votes, claims, or receipts
- patron support meaning: support events, effective patron points, derived tier snapshots, voting weight, and audit trail
- mapping from internal request to public target surface
- GitHub proposal/comment/PR transport for agent and member work
- Discord-native Bifrost commands/interactions, dispatch receipts, and persona announcements for work crossings and swarm I/O
@ -96,6 +97,7 @@ This keeps Reddit useful without making subreddit mechanics the secret constitut
### Heimdall Owns
- OAuth provider flows
- PayPal and Patreon webhook receipt, provider signature verification, payment-status normalization, and account-link evidence
- account linking
- credential custody
- signed identity and capability claims
@ -103,6 +105,14 @@ This keeps Reddit useful without making subreddit mechanics the secret constitut
Bifrost consumes Heimdall claims. It does not become the key vault. The split is bridge versus gate: Heimdall decides who may cross under which grant; Bifrost moves authorized work across public protocols and records where it landed.
### Patron Collection Crossing
PayPal and Patreon money movement enters Bifrost only as Heimdall-verified support facts. Heimdall receives provider webhooks, verifies provider signatures, links the provider account to a Heimdall account, normalizes payment status, and POSTs a signed support fact to `/heimdall/patron-support/events`.
Bifrost verifies Heimdall's intake HMAC and resolves the linked `HeimdallAccountId` to a Bifrost account. Only then does `PatronageService` record a `PatronSupportEvent`, point transaction, tier refresh, and audit event. Duplicate provider events are idempotent by `(Provider, ProviderEventId)`.
PayPal one-time donation completions should arrive as `Provider = PayPal`, `Kind = OneTimeDonation`, and a positive amount after completed capture. PayPal subscription current-support snapshots should arrive as `Kind = RecurringSupportSnapshot` with `IsCurrentRecurringSupport = true` after Heimdall has verified active paid support. Refunds, reversals, and chargebacks should arrive as `Kind = SupportAdjustment` with a negative amount. Bifrost does not delete old support history to hide provider churn.
### VoidBot Owns
- Discord observation and room context

57
docs/paypal-patronage.md Normal file
View file

@ -0,0 +1,57 @@
# PayPal Patronage Intake
PayPal collection is a Heimdall-to-Bifrost crossing, not a Bifrost payment stack.
## Authority
- PayPal owns money movement, captures, subscription status, refunds, reversals, and chargebacks.
- Heimdall owns PayPal app credentials, webhook receipt, PayPal signature verification, provider account linking, and provider-event normalization.
- Bifrost owns patronage meaning: support events, point derivation, tier snapshots, voting weight, and audit records.
## Intake Endpoint
Heimdall POSTs verified support facts to:
`POST /heimdall/patron-support/events`
The raw request body must be signed with `HMACSHA256(Heimdall:PatronSupportIntakeSecret, body)` and sent as:
`X-Heimdall-Signature-256: sha256=<hex>`
Payload:
```json
{
"heimdallAccountId": "heimdall-account-id",
"provider": "PayPal",
"providerEventId": "paypal-webhook-event-id",
"kind": "OneTimeDonation",
"amount": 125.00,
"currencyCode": "USD",
"externalSupportId": "PAYMENT.CAPTURE.COMPLETED:CAPTURE-ID",
"supportedAtUtc": "2026-06-09T15:00:00Z",
"isCurrentRecurringSupport": false,
"providerPayerId": "PAYPAL-PAYER-ID",
"providerSubscriptionId": "",
"notes": "Verified PayPal checkout capture from Heimdall."
}
```
Valid `provider` values are `PayPal` and `Patreon`. `Manual` is rejected for this endpoint.
Valid `kind` values:
- `OneTimeDonation`: positive completed one-time support.
- `RecurringSupportSnapshot`: positive current recurring support; set `isCurrentRecurringSupport` to `true` when it is the current support amount.
- `SupportAdjustment`: negative refund, reversal, chargeback, or correction.
`providerEventId` is the idempotency key inside a provider. Bifrost stores one support event per `(provider, providerEventId)`.
## PayPal Event Mapping
- Checkout/order donations: Heimdall records `OneTimeDonation` only after PayPal reports a completed capture.
- Subscription activation/current paid support: Heimdall records `RecurringSupportSnapshot` after verified active paid support.
- Subscription cancellation, suspension, expiration, or failed payment: Heimdall should send a new recurring snapshot that clears or reduces current support when paid support is no longer current.
- Refunds, reversals, and chargebacks: Heimdall records `SupportAdjustment` with a negative amount.
Unlinked PayPal support must stay pending in Heimdall. Bifrost will not create voting power from a PayPal payer id alone.