UC5: notify removed PP backend on provider removal#51
Merged
Conversation
When the council contract emits ProviderRemoved, the watcher now sends a fire-and-forget POST to the removed PP's backend (/api/v1/council/removed) so it can react immediately instead of waiting for its own next poll. The notice is a low-trust live signal — body is a hint, not an authority; the PP converges by re-querying the council's authoritative membership-status endpoint, so no shared secret is needed. - Only the ACTIVE→REMOVED transition fires the notify, so event re-delivery and boot replay (a removal seen during downtime) ping the PP exactly once. - Dormant when the provider row has no provider_url. - Never awaited, so it cannot stall or roll back the poll's atomic commit. - Extract applyEvent into apply-event.ts (env-free) so the transition logic is unit-testable without loading DATABASE_URL. Bumps 0.6.2 -> 0.6.3.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Part of the UC5 PP removal & continuity slice (council + provider stacks honour a PP removal end-to-end). This is the council-platform piece.
When the council channel-auth contract emits
ProviderRemoved, the event-watcher already marks the providerREMOVED. This adds the outbound notify to the removed PP's backend so it reacts immediately rather than waiting for its own next poll.How
notify-provider-removed.ts: fire-and-forgetPOST {providerUrl}/api/v1/council/removedwith{ councilId, publicKey, ledger }.provider_removedbranch ofapplyEvent, guarded by the ACTIVE→REMOVED transition + presence ofprovider_url./public/provider/membership-statusendpoint, so no shared secret is required and a spurious/replayed POST can only make a PP re-confirm its own status.notifyDiscord).applyEventinto env-freeapply-event.tsso the transition logic is unit-testable without loadingDATABASE_URL.Tests
src/core/service/event-watcher/notify-on-removal.test.ts: active removal notifies once; already-REMOVED re-delivery/boot-replay does not re-notify; noprovider_url→ dormant; unknown provider → no-op.Full PR pipeline run locally on the pinned deno 2.8.2:
fmt --check,lint,check src/main.ts,test:unit(58),test:integration(185) — all green.Version: 0.6.2 → 0.6.3.
Coordination
Lands together with the provider-platform inbound notify endpoint and the provider-stack (Rust standin) removal-honouring PRs. The contract needs no change —
remove_provideralready emitsProviderRemoved.