Skip to content

feat(notify): forge-notify, optional email and Web Push notifications - #387

Merged
PastaPastaPasta merged 18 commits into
masterfrom
feat/forge-notify
Oct 5, 2026
Merged

PastaPastaPasta merged 18 commits into
masterfrom
feat/forge-notify

Conversation

@PastaPastaPasta

Copy link
Copy Markdown
Owner

What

forge-notify: an optional, multi-tenant service that sends Dash Forge notifications by email and browser push (owner decision D1, "host more"). Forge works the same without it. The in-browser inbox still reads the chain, and every notice links back to forge-web, which reads the chain again with proofs.

Stacked on #370 (relay sinks): the service embeds forge-relay's ingest, notice renderer and SMTP transport.

The service (services/forge-notify)

  • No account, no password. Subscribers send signed requests (docs/design/service-auth.md). The signature is a domain-separated secp256k1 signature by an AUTHENTICATION HIGH/CRITICAL key, read from Platform with proofs. Each request carries a single-use nonce, a time within ±300 s, and the operator's name. This is an off-chain convention, not a protocol feature. A test vector is shared with the web app.
  • Email has double opt-in. The confirmation page needs a button press, so link scanners don't confirm. Every mail carries RFC 8058 one-click List-Unsubscribe and Auto-Submitted. An address is paused after 3 hard bounces.
  • Web Push (RFC 8291 + VAPID). Endpoints must be on a known push host, which guards against SSRF. Gone subscriptions are deleted.
  • Preferences: participating, review requested, assigned, mentioned, watched repos, own/member repos, releases, private activity; email and/or push; instant or a daily digest.
  • Sources (proved reads through forge-core):
    • watched, owned and member repos, polled through the relay's ingest;
    • review requests and assignments from the addressee index, in any repo, using the same rules as forge-web's inbox;
    • @mentions (DPNS label or identity id) in public content.
  • Private repos: only "new activity in ", from public metadata, for members who opt in. Never a title or text.
  • Privacy: addresses and push endpoints are sealed with AES-256-GCM under HKDF-derived keys, with a keyed blind index. Never on chain. data.export and data.delete are supported. Logs contain no addresses, tokens or endpoints.
  • Abuse controls: per-IP limits (FORGE_NOTIFY_TRUST_PROXY = none | cloudflare | forwarded, the last XFF entry), per-identity and per-address confirmation quotas, subscriber and repo caps, a per-user daily cap and a global daily send budget.
  • Ops: /healthz, /readyz, aggregate /metrics; a Dockerfile (non-root, healthcheck), docker-compose.yml with Docker secrets, and forge-notify keys.

Web

Settings → Notifications (/settings/notifications/) links to the inbox. Its Email and push section shows only when the build sets NEXT_PUBLIC_NOTIFY_URL. It has privacy copy, email confirm and remove, push on and off in this browser (public/notify-sw.js), topics, digest, test, export and delete. Requests are signed with the browser's limited key (controller.serviceKey()), and only for the host the build calls. Settings links to it.

Docs

docs/hosting/forge-notify.md covers what you need, run, every env var, DNS/TLS, SPF/DKIM/DMARC, Web Push, routes, rate limits, monitoring, logs, backups, the web build flag, local testing, billing (designed, later), a privacy notice draft, and a checklist for dashhq.

Survivability

"notify down" is now part of the browse drill (components/notify-panel.test.tsx): an unreachable service shows one line and nothing else changes. No read-path crate can link forge-notify, because it depends on forge-relay, which the drill already keeps off the read path.

Review

An independent review (security focus) found 10 issues. All are fixed in fix(notify): address review …:

  • addressed events now follow the inbox rules;
  • a full page holds the cursor back;
  • a watch doc no longer follows a private repo;
  • proxy header modes;
  • key-cache eviction;
  • a bounded, deduplicated reindex queue;
  • old unsubscribe links are voided on an address change or a re-created subscriber;
  • delete no longer resets quotas;
  • the privacy link must be https;
  • the web app signs only for the host it calls.

Test evidence

  • cargo test -p forge-notify: 18 unit tests plus 2 integration tests. The integration tests run subscribe → confirm → route (watch, participant, mention, private) → one-click unsubscribe → export → delete, and check CORS/CSP and metrics, all with a stub chain, mailer and push service. Clippy is clean with -D warnings.
  • forge-web: typecheck, lint and vitest (the shared vector, URL handling, the panel: down, signed out, operator mismatch, signed request verified with secp256k1).
  • Live on sakura with Mailpit and a local Web Push receiver that decrypts RFC 8291, using QA identities svcn-alice-7 / svcn-bob-7:
    • signed sign-up and mail confirmation;
    • push test;
    • mention mail;
    • watched-repo mail and push;
    • assignment from the addressee index ("svcn-bob-7 assigned you to issue fix: page every read that feeds a deterministic fold #2");
    • a private repo svc-notify-priv, where bob's sealed issue produced "New activity in a private repository you belong to" with no title or text (checked with a SHOULD-NOT-LEAK marker).
  • Browser: a static build with NEXT_PUBLIC_NOTIFY_URL was signed in by importing alice. The browser's contract-bound limited key signed account.get, prefs.set and test.send, and the service accepted them.
  • Docker: the image was built; docker compose up ran against sakura; /readyz and /v1/info answered; a signed sign-up was confirmed; test.send mail carried List-Unsubscribe + List-Unsubscribe-Post; one-click unsubscribe, export and delete worked.
  • Evidence: dash-forge-qa/evidence/svc-notify/forge-notify/ (Mailpit messages with tokens redacted, decrypted pushes, service and container logs, web screenshots).

Owner actions to host it

A hostname (e.g. notify.forge.dashhq.org) on the Cloudflare tunnel, and a transactional SMTP provider with the SPF, DKIM, DMARC and bounce records for the sending domain. Run forge-notify keys once and store the data key and VAPID key. Publish the privacy notice. Build forge.dashhq.org with NEXT_PUBLIC_NOTIFY_URL. The checklist is in the hosting guide.

Not in this PR

  • Billing: designed in the guide, not built.
  • Notices for comments and reviews in private repos: there is no per-repo index for them.
  • Repo activity written while the service is down is not sent after a restart. Addressed-event cursors are kept.

🤖 Generated with Claude Code

PastaPastaPasta and others added 5 commits October 4, 2026 14:20
… for Forge identities

services/forge-notify is a multi-tenant notification service. A subscriber proves control of a Forge identity with a signed request (docs/design/service-auth.md: a domain-separated secp256k1 signature by an AUTHENTICATION key read from Platform with proofs; no account, no password), confirms an address by mail (double opt-in, a button page so link scanners do not confirm), and picks topics (participating, review requested, assigned, mentioned, watched, own repos, releases, private activity), channels and instant or daily digest delivery.

It follows each subscriber's watched, owned and member repositories with proved reads, polls the public ones through forge-relay's ingest and renderer, reads review requests and assignments from the addressee index in any repository, and scans @mentions in public content. For private repositories it reads public metadata only and says new activity, never a title. Addresses and push endpoints are sealed with AES-256-GCM under an HKDF-derived key with a keyed blind index; mails carry RFC 8058 one-click unsubscribe; Web Push is RFC 8291 with VAPID; export and delete endpoints; per-IP, per-identity, per-address and global quotas; /healthz, /readyz and an aggregate /metrics.

forge-web gets Settings > Notifications with an optional Email and push section shown only when NEXT_PUBLIC_NOTIFY_URL is set, signing with the browser key (controller.serviceKey), a push service worker, and the shared test vector. Dockerfile, docker-compose and docs/hosting/forge-notify.md (env vars, DNS, TLS, SPF/DKIM/DMARC, backups, monitoring, log hygiene, rate limits, privacy notice draft). The survivability drill gains a notify-down case. The relay and runner Dockerfiles copy services/ since it now holds a workspace member.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…roxy modes, link and token hardening

Review requests and assignments follow forge-web's inbox rules (an assignment is a member's event, a review request asks only on a pull request, and the thread must belong to the event's repository); two capped pages merge without skipping past a full one; a watch document never follows a private repository; FORGE_NOTIFY_TRUST_PROXY is none, cloudflare or forwarded (the last X-Forwarded-For entry); the key cache evicts expired entries and misses before clearing; the reindex queue is bounded and deduplicated; a confirmed new address and a re-created subscriber void old unsubscribe links; deleting keeps the day's quota counters; the privacy link must be https on both sides, and the web app signs only for the host it calls.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…pose, operator includes the port

Addressed and private-activity notices name the author and owner by DPNS label like the relay's notices. The compose file takes settings from .env with env_file, so an unset setting keeps its default instead of arriving empty. The default operator is the public URL's host and port, as a browser's URL.host names it. The hosting guide says which private-repo activity is seen.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 18 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a31aff2a-430f-4f55-8717-8609ab8c0c93
📥 Commits

Reviewing files that changed from the base of the PR and between 08815bc and 6c8257d.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (45)
  • .github/workflows/survivability.yml
  • Cargo.toml
  • crates/forge-core/src/keyring.rs
  • crates/forge-core/src/network.rs
  • crates/forge-core/src/platform/identity_keys.rs
  • crates/forge-core/src/platform/mod.rs
  • crates/forge-core/src/webhooks.rs
  • crates/forge-relay/Dockerfile
  • crates/forge-runner/Dockerfile
  • docs/design/service-auth.md
  • docs/hosting/forge-notify.md
  • forge-web/app/settings/notifications/page.tsx
  • forge-web/app/settings/page.tsx
  • forge-web/components/notify-panel.test.tsx
  • forge-web/components/notify-panel.tsx
  • forge-web/lib/auth/controller.ts
  • forge-web/lib/notify/client.test.ts
  • forge-web/lib/notify/client.ts
  • forge-web/lib/notify/config.ts
  • forge-web/lib/short-url.ts
  • forge-web/public/notify-sw.js
  • services/forge-notify/Cargo.toml
  • services/forge-notify/Dockerfile
  • services/forge-notify/README.md
  • services/forge-notify/docker-compose.yml
  • services/forge-notify/examples/request.rs
  • services/forge-notify/src/api.rs
  • services/forge-notify/src/auth.rs
  • services/forge-notify/src/chain.rs
  • services/forge-notify/src/config.rs
  • services/forge-notify/src/crypto.rs
  • services/forge-notify/src/dispatch.rs
  • services/forge-notify/src/error.rs
  • services/forge-notify/src/index.rs
  • services/forge-notify/src/lib.rs
  • services/forge-notify/src/limits.rs
  • services/forge-notify/src/mail.rs
  • services/forge-notify/src/main.rs
  • services/forge-notify/src/push.rs
  • services/forge-notify/src/route.rs
  • services/forge-notify/src/server.rs
  • services/forge-notify/src/store.rs
  • services/forge-notify/testdata/vector-digest.txt
  • services/forge-notify/testdata/vector-signature.txt
  • services/forge-notify/tests/notify.rs
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

PastaPastaPasta and others added 12 commits October 5, 2026 00:02
…roup

usable_signing_key never looked at a key's bounds, so a HIGH AUTHENTICATION key that a
third-party dapp holds, bound to its own contract, could export a user's email, take over the
address or delete their data.

forge-core's IdentityKeyInfo gains bounds (KeyBounds: the contract and document type, or the
contract group id; bound_to is unchanged for existing callers) and ForgeIds::allows_key_bounds.
forge-notify now accepts only unbound keys or keys bound to a Forge contract or the Forge
contract group.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…t one mailbox

A confirmation mail did not count against the service's global daily send budget, and the
per-address limit was keyed on the lowercased address as given, so +tags and Gmail's dotted
spellings each got a fresh limit. email.set now charges the global budget, and the per-address
limit counts a normalised mailbox (no +tag; no dots for gmail.com/googlemail.com). The stored
index is unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…subscribers

send_digests deleted an identity's items before the send could fail (budget spent, mail
paused, a temporary SMTP failure), so those digests were lost silently. Items are now read,
and deleted up to the newest one sent only after a successful send; the 7-day purge still
bounds what never goes.

A subscriber with no working address and daily delivery, or past the per-user daily cap, got
nothing: the notices went to a digest that is never mailed. Such notices now go as pushes when
they happen, within the global budget. test.send reports whether the test mail really went.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… skips the cap

push.add upserted on endpoint_hash alone and set identity on conflict, so registering an
endpoint took it from whichever identity had it. Rows are now unique per (identity,
endpoint_hash) and a conflict refreshes only that identity's row; one browser may serve several
identities. A store with the old table is rebuilt in place, keeping its rows.

The 10-browser cap counted rows before the upsert, so re-adding a browser already registered
failed at 10. It is skipped when the endpoint is already among the identity's rows.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The forms posted to root-relative /v1/verify and /u/{token}, which miss the service when
PUBLIC_URL has a path prefix. Their actions are now built from public_url.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…n windows

poll_private saved its cursor before delivering, so a failed delivery lost the window, and it
excluded a subscriber when the newest write was theirs, hiding other writers' earlier activity
in the same window.

Chain::latest_activity becomes activity_since: the writes after the cursor (a page per kind of
document; a full page ends the window so nothing is skipped), with the window's newest time and
its writers. The cursor is saved after delivery, and a subscriber is left out only when every
write in the window is theirs.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Sending push-only subscribers their over-cap notices skipped the user: quota altogether, so one
identity watching a busy repo could draw down the shared daily budget. The cap applies again:
a push-only subscriber on daily delivery gets pushes as notices happen, up to the cap, and
past it a notice is skipped since there is no digest to hold it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts:
#	forge-web/app/settings/page.tsx
#	forge-web/lib/short-url.ts
Split the 63-word privacy paragraph in two and say "written to Dash
Platform" instead of the banned "on chain".

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@PastaPastaPasta
PastaPastaPasta merged commit 9ab3980 into master Oct 5, 2026
30 checks passed
@PastaPastaPasta
PastaPastaPasta deleted the feat/forge-notify branch October 5, 2026 09:00
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