HF-13: signed site-to-cloud link (heartbeat, referral outbox, cloud status) #8

Merged
gmackie merged 1 commit from feat/HF-13-site-link into main 2026-11-04 11:23:55 +00:00
Owner

HF-13 Phase R "Site-to-cloud link" (docs/plans/2026-11-04-level2-hospital-it.html).

What

  • Signed heartbeat: the site cron posts site id, deployed commit, unfinished deliveries and referral-queue depth to SITE_LINK_URL every minute. Requests carry x-hf-link-timestamp, x-hf-link-nonce, x-hf-link-signature = HMAC-SHA256(SITE_LINK_SECRET, timestamp.nonce.body). The cloud rejects bad signatures, skew over 5 min, and replayed nonces (stored, pruned after 10 min).
  • Synthetic referrals through an outbox: POST /v1/site-link/referrals (operator token) enqueues into site_link_referrals; the cron drains it with the dispatcher's lease + fencing discipline. The cloud stores each idempotency key once (site_link_inbound_referrals primary key), so a lost ACK + retry is harmless; a different payload under the same key is a 409 and the row is blocked.
  • Cloud status: public GET /site-link/v1/status JSON and GET /site-link page: online if the last verified heartbeat is under 3 minutes old, last heartbeat, reported queue depth, referrals received. Synthetic only; no secrets or internal errors.
  • Gating: new profile flags siteLinkSend (site, local) and siteLinkReceive (cloud, local). Every endpoint returns 404 unless SITE_LINK_SECRET (≥32 bytes) is configured. Config, not hostname.
  • Migration 0007_site_link.sql (bootstrap list, embed-migrations, check-sql updated). labnuc install.sh generates SITE_LINK_SECRET into site-secrets.env if missing; deploy.sh merges it and HF_COMMIT into the celld vars.

Tests

npm run check: 61 pass. New integration tests: signature/skew/replay rejection, exactly-once delivery across a WAN cut and a lost ACK (plus expired-lease reclaim and key conflict), status online→offline with no secret leakage, and per-profile/secret gating.

🤖 Generated with Claude Code

HF-13 Phase R "Site-to-cloud link" (docs/plans/2026-11-04-level2-hospital-it.html). ## What - **Signed heartbeat**: the `site` cron posts site id, deployed commit, unfinished deliveries and referral-queue depth to `SITE_LINK_URL` every minute. Requests carry `x-hf-link-timestamp`, `x-hf-link-nonce`, `x-hf-link-signature` = HMAC-SHA256(`SITE_LINK_SECRET`, `timestamp.nonce.body`). The cloud rejects bad signatures, skew over 5 min, and replayed nonces (stored, pruned after 10 min). - **Synthetic referrals through an outbox**: `POST /v1/site-link/referrals` (operator token) enqueues into `site_link_referrals`; the cron drains it with the dispatcher's lease + fencing discipline. The cloud stores each idempotency key once (`site_link_inbound_referrals` primary key), so a lost ACK + retry is harmless; a different payload under the same key is a 409 and the row is blocked. - **Cloud status**: public `GET /site-link/v1/status` JSON and `GET /site-link` page: online if the last verified heartbeat is under 3 minutes old, last heartbeat, reported queue depth, referrals received. Synthetic only; no secrets or internal errors. - **Gating**: new profile flags `siteLinkSend` (site, local) and `siteLinkReceive` (cloud, local). Every endpoint returns 404 unless `SITE_LINK_SECRET` (≥32 bytes) is configured. Config, not hostname. - Migration `0007_site_link.sql` (bootstrap list, embed-migrations, check-sql updated). labnuc `install.sh` generates `SITE_LINK_SECRET` into site-secrets.env if missing; `deploy.sh` merges it and `HF_COMMIT` into the celld vars. ## Tests `npm run check`: 61 pass. New integration tests: signature/skew/replay rejection, exactly-once delivery across a WAN cut and a lost ACK (plus expired-lease reclaim and key conflict), status online→offline with no secret leakage, and per-profile/secret gating. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
HF-13: signed site-to-cloud link with heartbeat, referral outbox and cloud status
All checks were successful
Scaffold conformance / test (pull_request) Successful in 1m43s
forgegraph/ci CI passed
Scaffold conformance / forgegraph-report (pull_request) Successful in 13s
adcf921412
The site cron drains a durable synthetic-referral outbox to the cloud and
posts a heartbeat, both signed with HMAC-SHA256 over timestamp, nonce and
body. The cloud rejects bad signatures, skew over 5 minutes and replayed
nonces, stores each referral idempotency key once, and serves a public
read-only status (JSON and page) with online/offline from heartbeat age.
Only site sends and only cloud receives; local may do both. Everything is
disabled until SITE_LINK_SECRET (>=32 bytes) is configured.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
gmackie/hospital-fabric!8
No description provided.