Skip to content

pm-stack notifications Phase 2: Cloudflare edge relay + Durable Object dead-man's switch — push that survives the stack being down #8569

Open

Description

@dezren39

Phase 2 — Cloudflare edge relay: push that survives the stack

Design: pm-stack-notifications-design-2026-11-11.md (goal keep-the-four-repos-healthy, files/). Depends on Phase 1: #8568. Context: #1254 / #3676 (the laptop-side throat + Web Push this mirrors).

The decision (go / no-go on the Cloudflare move)

  • NO-GO: moving the board / aggregator itself to Workers. Every primary data source is laptop-local and tailnet-only (OpenCode :13420, queue broker :4801, Kaneo Postgres, projector DB, ~/.local/state/pm-aggregator/*). An edge board would be a cache of a dead source at exactly the moment it matters, and the board's job is live local state.
  • GO: a small edge notification relay — one Worker + one Durable Object (pm-notify). The notification path is the one piece that must survive the laptop being down, and it is tiny: events in, subscriptions, push sends, answers in. The fleet already operates Workers (webhook-gateway on workers.dev, infra/github-backup/worker, pkgs/github-ci/worker, pkgs/id/hosted-worker), wrangler is packaged in-repo, and a day-to-day CF API token already lives in Bitwarden by name.

Shape

  • The aggregator throat mirrors every push-worthy event (incident raised/escalated, needs-drew raised, quota wall) to the Worker via authenticated POST (shared secret, same pattern as the throat intake token). The DO stores the mirror log + a subscription mirror.
  • The laptop stack sends a heartbeat POST every ~60s. The DO sets an alarm on each heartbeat; a missed heartbeat window (~2 missed beats) fires stack.silent: the DO itself sends a Web Push ("the PM stack is down", with since-when) using the mirrored subscriptions and a VAPID keypair whose private key lives as a Worker secret. This is the dead-man's switch — no cron, no laptop, no Muse in the path.
  • Edge answer intake: notification action taps and answer pages are served by the Worker from DO state (question + full option list), so Drew can answer while the laptop is down. Answers are stored in the DO and flushed to the aggregator's answers outbox (Phase 1 path) on the next heartbeat/event contact; if the laptop is up, the Worker can also forward immediately through the existing tunnel ingress pattern.
  • Dual-send discipline during transition: for classes the edge owns (stack.silent only, at first) the laptop never sends; for mirrored classes the laptop remains the sender and the edge is a silent mirror until a later, separately-reviewed cutover.

Acceptance (Drew's terms)

  • Stop the whole laptop stack (or kill the tunnel) → a "stack down" push reaches Drew's phone in under 2 minutes with zero cron and zero Muse involvement.
  • Answer a needs-drew question from the push while the laptop is down → when the stack returns, the ledger shows it answered and the blocked task unblocks; nothing is lost or double-applied.
  • Stack recovers → one "recovered" push naming the downtime length; no duplicate down pushes for the same episode.
  • The page-health-push cron narrows the day this ships: its page checks retire (the DO owns them) and it becomes a daily canary only — is the DO itself alive and did it receive yesterday's heartbeats.

Activity

  1. added
    kind/featureNew feature or capability request
    priority/normalOrdinary priority (the default)
    app/pm-stackpm-stack (Pad/Grist) in developing-today/code
    on Nov 11, 2026
  2. developing-today commented on Nov 11, 2026

    @developing-today
    Contributor
  3. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    Direction — Drew, main chat, 2026-11-11 01:25 CST: move the data sources to Cloudflare too.

    On the design's no-go for moving the board to Workers (deciding constraint: every data source is laptop-local, so an edge board would be a cache of a dead source), Drew's ruling: "you would move the data sources to CF too, possibly sync with Turso and/or laptop."

    So this phase's scope grows from relay-only to: the board's data sources get Cloudflare-resident homes, kept current by sync with Turso and/or the laptop — the sync topology (what lives in Workers/Durable Objects/D1, what syncs from Turso, what syncs from the laptop, and which side wins on conflict) is this phase's design work. The deciding constraint from the design is answered by moving the sources, not by abandoning the move.

  4. added
    design/pm-notificationsDesign: pm-notifications - all issues of this effort carry it
    epic/pm-stackReprioritization program epic (2026-11-12)
    on Nov 12, 2026
  5. added this to the PM stack coherence milestone on Nov 12, 2026
  6. added
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    effort/lLarge: multi-day or open-ended; expect staged check-ins
    on Nov 17, 2026
  7. dezren39 commented on Nov 17, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · triaged (inline triage — dependency met, Drew's ruling stands; design record routed to task 20170)

    • Agent: queue worker (repo-worker-code), lane any-c
    • Session / ID: task 18689
    • Found via: queue claim (bulk-intake triage packet, 2026-11-16)

    Triage verdict (fresh, 2026-11-17, via gh):

    Routing: design-record packet queued as task 20170 (small_fix, 45 min, docs-only); implementation chains from it under the same dedupe key. Task 18689 completes as triaged naming it. Issue #8569 stays open for Phase 2.

  8. dezren39 commented on Nov 17, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done — Phase-2 design record opened as PR #11241; build split below

    • Agent: repo-worker-code (Muse lane code-a)
    • Session / ID: queue task 20170
    • Found via: atomic claim from the one fleet queue (stream repo-health-code-pilot), filter repo = code

    Design record: PR #11241 adds doc/2026-11-17_design_pm8569_notifications_phase2.md, deciding the five items the parent design's ruling left open: (1) sync topology — per-event idempotent mirror POSTs, full-snapshot subscription sync under a monotonic seq, bidirectional heartbeat that drains edge answers by pull/ack, per-start stackEpoch as the recovery signal; (2) relay/DO shape — singleton pm-notify DO, alarm at last-beat + 150s as the only scheduler, a closed Worker route list; (3) board read path — none at the edge (board stays laptop-only; edge serves answer pages + a status stub only), with episode semantics (exactly one down push, exactly one recovered push) made mechanical; (4) secrets by name only — shared throat↔Worker secret, the existing VAPID keypair with custody moved to a Worker secret, hashed per-question answer tokens, deploy-time-only CF token; (5) the ordered split below.

    Follow-on build split (in order; each step independently shippable):

    1. Relay skeleton + dead-man's switch (heartbeat, alarm, subscription snapshot sync, stack.silent + recovered sends; edge owns stack.silent from here).
    2. Event mirror (silent mirror; soak-check against the throat store, dedupe verified by forced retries).
    3. Edge answer intake (answer pages/POST from DO state; drain on heartbeat contact; catcher application unchanged).
    4. Cron narrowing to the daily DO canary (page-health-push retires its page checks).

    This issue stays open as the Phase-2 tracker; the four steps above are its implementation children when filed.

  9. added a commit that references this issue on Nov 18, 2026
  10. removed their assignment
    on Nov 20, 2026
  11. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    Merged work, still open. Every pull request that references this issue has merged (#11241) and none is open, but the issue kept status:in-review. Tasks that name it as a blocker have been waiting on it.

    status:in-review is removed. Whoever takes this next: run the issue's done check against main. Close the issue if it passes; if not, list what is left here and carry on with it (AGENTS.md, "Finishing work").

    By: Claude, 2026-11-22 flow review.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/pm-stackpm-stack (Pad/Grist) in developing-today/codedesign/pm-notificationsDesign: pm-notifications - all issues of this effort carry iteffort/lLarge: multi-day or open-ended; expect staged check-insepic/pm-stackReprioritization program epic (2026-11-12)kind/featureNew feature or capability requestpriority/normalOrdinary priority (the default)task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions