Skip to content

feat: Email through KyPost alert channel - #90

Merged
Yoshiofthewire merged 4 commits into
masterfrom
feat/kypost-alert-mail
Nov 16, 2026
Merged

Yoshiofthewire merged 4 commits into
masterfrom
feat/kypost-alert-mail

Conversation

@Yoshiofthewire

Copy link
Copy Markdown
Member

In one line: Administrators can add a second alert channel, "Email through KyPost", which sends each alert as plain-text mail from a KyPost member's mailbox to recipients that member allowed.

What changed

  • Settings › Server has a new "Email through KyPost" card after the webhook (administrators only). It shows the same-host warning, the pairing state, the last answer from KyPost (a code only), an owner picker, recipients (1 to 11), Save, Send test and Remove.
  • Every alert that goes to the webhook also goes to KyPost, retried on the webhook's backoff. The event ID stays the same across retries, so a retry never sends a second mail.
  • The channel needs KyIdentity sign-in: KyPulse pairs with KyPost only through KyIdentity's suite directory (pair from KyIdentity #244). Without that, the card shows a note and nothing else.
  • Recipients are sealed at rest (alert_kypost_enc). They are never logged or audited and never shown to viewers. Audits record the owner ID and a recipient count.
  • The wire contract docs/KYPOST.md is byte-identical with KyPost docs/KYPULSE.md. The design is in docs/superpowers/specs/2026-11-15-kypost-email-alerts-design.md.

Review this

Checked: make ci (tidy, gofmt, vet, race tests, frontend tests, smoke) with GOTOOLCHAIN=auto and Node 26: passed (tidy, gofmt, vet, go test -race all packages, frontend tests, smoke: "Local CI checks passed"). The dist rebuild is byte-identical to the committed web/dist. Not checked: a live KyPulse→KyPost send between two running servers. That needs the KyPost PR deployed with a KyIdentity pair, so it is unproven here; both sides are covered by contract tests against a signed fake.

Decided for you

  • The mailbox owner is picked from KyPulse accounts that sign in through KyIdentity, since they carry a subject KyPulse knows. There is no suite-wide member picker.
  • A refusal from KyPost shows beside the channel but does not raise the alert bar's "alerts not delivered".
  • There is no environment-variable pairing; only KyIdentity pairs the two.

You need to: nothing. Merge order: KyIdentity #244 (merged), then this PR and the KyPost PR in either order.

Detail

Routes (admin only)

Method Path Notes
GET /api/alerts/kypost availability, pairing, eligible owners, config, last outcome
PUT /api/alerts/kypost {owner_id, recipients}; audited admin.kypost_mail_set
DELETE /api/alerts/kypost audited
POST /api/alerts/kypost/test one attempt; 502 {error: code} on refusal

Negative tests

internal/kypost: the exact body is signed; refusal codes are kept to [a-z0-9_]{1,64}; a refused signature asks for a fresh pairing and is retried; an unpaired send fails; no_peer, unauthorized and a peer URL with a path or userinfo all unpair, while an outage keeps the pairing. internal/monitor: an alert reaches the webhook and KyPost; a refusal is recorded without addresses; an outage is retried and then sent; an owner without KyIdentity is refused; config bounds. internal/api: the channel is hidden without KyIdentity; the routes are set, test and refuse; recipients never reach settings; viewers get 403 on all four routes (authz_test.go). The outbound guard is the shared internal/egress client and its own tests.

Screenshots

Settings › Server: before, after (without KyIdentity: note only) and after (KyIdentity configured but unpaired). Each at desktop and phone width, light and dark.

before after (no KyIdentity) after (KyIdentity, unpaired)
light-desktop
dark-desktop
light-phone
dark-phone

Captured with docs/ui-kypost-mail-2026-11-15/capture.mjs against a disposable server; KyIdentity points at an .invalid name.

🤖 Generated with Claude Code

Yoshiofthewire and others added 4 commits November 15, 2026 14:02
A second alert channel beside the webhook: KyPulse asks a paired KyPost
to send one plain-text alert from a KyIdentity member's mailbox to the
recipients the administrator chose (docs/KYPOST.md, byte-identical with
KyPost's docs/KYPULSE.md). Pairs through KyIdentity's suite directory
only; the channel is sealed at rest and only reason codes are stored,
shown or audited.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Yoshiofthewire

Copy link
Copy Markdown
Member Author

Failed to review PR


Advisory only: this comment never gates the pull request.
claude-sonnet-5-5 using pr-agent on behalf of Yoshi

@Yoshiofthewire

Copy link
Copy Markdown
Member Author

Security review - cleared

Detail withheld: this repository is public, and posting an unfixed finding here would be public disclosure. The full report was posted to the hand-off board at https://myslop.urlxl.us/f/pr-reviewer-busnes-app-kypulse-server-90, where it is readable by the operator and expires seven days after the last post.

Review input was truncated; omitted changes were not reviewed.


gpt-6.1-sol using security-audit on behalf of Yoshi

@Yoshiofthewire

Copy link
Copy Markdown
Member Author

Autonomous review - 1/1 personas cleared

  • security: cleared

Merging remains a human decision; this bot never approves.


gpt-6.1-sol using security-audit on behalf of Yoshi

@Yoshiofthewire
Yoshiofthewire merged commit 87e784d into master Nov 16, 2026
22 checks passed
@Yoshiofthewire
Yoshiofthewire deleted the feat/kypost-alert-mail branch November 16, 2026 00:57
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