Skip to content

feat(notifications, github): WS-N + WS-G - channels, event bus, GitHub App webhooks, auto-deploy - #381

Closed
vsilent wants to merge 9 commits into
devfrom
feature/notifications
Closed

vsilent wants to merge 9 commits into
devfrom
feature/notifications

Conversation

@vsilent

@vsilent vsilent commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

Two workstreams from config/PLAN-notifications.md and config/PLAN-github-webhooks.md (2026-11-24).

WS-N Notifications (N1-N4)

  • notification_channel / notification_dispatch schema + casbin rules; secrets only in Vault (targetHint masked, errors redacted recursively)
  • REST /api/v1/notifications/*: channels CRUD, test send, dispatch log; global channels are root/group_admin-only and receive organization-level events only (code-review B1)
  • Adapters: Slack / Discord / Telegram / webhook (HMAC X-Stacker-Signature); email through RabbitMQ -> notify (notify.start.email.notification.all)
  • Event bus: edge-triggered deploy transitions from the MQ listener and force-complete; container.down edge-detected in the agent report path
  • CLI stacker notify {add,test,list}

WS-G GitHub integration (G1-G5)

  • Schema github_installation / github_repo / github_webhook_delivery + casbin
  • POST /api/v1/github/webhook: X-Hub-Signature-256 HMAC (constant-time), replay guard on X-GitHub-Delivery, webhook secret only in Vault
  • Watch-path matching (globs with ! exclusions); Repo Connect API /api/v1/github/repos
  • Auto-deploy on matched pushes via redeploy_saved_project: rebuilds the Deploy form from the project's saved state and pins server.server_id — redeploys onto the existing server, never provisions a new VM

Crates (fast-compile strategy)

Pure logic lives in leaf crates: crates/notification-core (payloads, masking, redaction, retry) and crates/github-events (signature, normalization, watch paths). Their unit tests (10 + 7) run in ~10ms without building the service.

Tests

  • cargo nextest run -p notification-core 10 passed
  • cargo nextest run -p github-events 7 passed
  • cargo nextest run -E 'binary(notification_channels)' 9 passed
  • cargo nextest run -E 'binary(github_webhook)' 9 passed
  • cargo nextest run --lib 2382 passed, 6 skipped (pre-existing #[ignore])
  • Regressions: binary(remote_secrets) 15 passed (vault_service touched)

Reviewed by code-reviewer + migration-checker before the WS-N merge point (B1/M1/M2 fixed, M3 accepted as a convention deviation matching db/remote_secret.rs).

Contracts and BDD fixtures live in the config repo: shared-fixtures/api-contracts/notifications-*.json, github-webhooks.json, shared-fixtures/features/notifications.feature, github-autodeploy.feature.

- schema: notification_channel + notification_dispatch (migration
  20261124111150); casbin rules for /api/v1/notifications/*
  (migration 20261124111654)
- REST: create/list/update/delete/test channels, list dispatches
- adapters: slack, discord, telegram, webhook (HMAC X-Stacker-Signature);
  email delivery deferred to N4 via the notify service
- secrets live only in Vault (notification_secret_path); responses carry a
  masked targetHint; errors are redacted recursively before storing
- delivery is at-least-once: retry x3 with backoff on 429/5xx, shared
  reqwest client with a 10s timeout
- project events go to that project's channels only; global channels
  require root/group_admin (code-review B1) and are reserved for
  organization-level events
- unauthorized channel access answers 404 (no existence leak)
- tests: 8 integration (tests/notification_channels.rs) + unit tests for
  masking/redaction; reviewed by code-reviewer + migration-checker
  2026-11-24 (B1/M1/M2 fixed, M3 accepted as convention deviation)
- contracts and BDD fixtures live in config/shared-fixtures (notifications-*)
… N3)

- deploy status transitions notify project channels (edge-triggered:
  completed->deploy.succeeded, failed/error->deploy.failed) from the MQ
  listener and force-complete; best-effort, never breaks the deploy flow
- pure logic moved to the leaf crate crates/notification-core (events,
  channel payloads, masking, redaction, retry/backoff, HTTP delivery);
  its 10 unit tests run in ~10ms without building the service - the
  agreed crate/module strategy for fast compilation going forward
- services/notification.rs keeps orchestration only (Vault, dispatch rows,
  project fan-out with per-channel events filter)
- tests: notification-core 10/10, notification_channels 9/9 (new fan-out
  and dispatch-log cases), lib 2382 passed / 6 skipped (pre-existing)
…S-N N4)

- email channels deliver through RabbitMQ -> notify (routing key
  notify.start.email.notification.all, NotifyEmailMessage shape), recorded
  in notification_dispatch like every other channel
- container.down: edge-detect running->exited/dead between aggregate health
  reports in the agent report path and fan out the contract event to the
  project's channels (best-effort, never fails the report)
- CLI: stacker notify add/test/list over /api/v1/notifications/*
  (secrets are write-only and never echoed back)
- crates/TODO.md: Slack/Telegram/Discord targets shipped, Teams stays open
- tests: notification-core 10/10, notification_channels 9/9, lib
  2382 passed / 6 skipped (pre-existing)

Closes WS-N (N1-N4).
…h paths (WS-G G1-G3)

- schema: github_installation, github_repo (branch, watch_paths, autodeploy,
  project binding), github_webhook_delivery replay guard
  (migration 20261124131026); casbin-anonymous webhook rule
  (migration 20261124131027, precedent: payout webhook)
- POST /api/v1/github/webhook: X-Hub-Signature-256 HMAC (constant-time),
  one processing per X-GitHub-Delivery, webhook secret only in Vault
- pure logic in the leaf crate crates/github-events: signature verify,
  push/pull_request/installation normalization, watch-path matching
  (globs with ! exclusions); tests run in ~10ms standalone
- push handling answers the matched repos seam for the G5 deploy trigger
- tests: github-events 7/7, github_webhook 4/4, notification_channels 9/9
  (regression), lib 2382 passed / 6 skipped (pre-existing)
- /api/v1/github/repos CRUD (create/list/update/delete), owner-gated:
  touching another user's project answers 404, duplicate repo+branch 409
- casbin rules for the new endpoints (migration 20261124135149)
- installation / installation_repositories webhooks are recorded in
  github_installation
- auto-deploy switch lives on github_repo.autodeploy; the stale catalog
  form field autodeploy is marked as superseded (forms/project/app.rs)
- tests: github_webhook 7/7 (CRUD roundtrip, ownership, installation
  recording), github-events 7/7, notification_channels 9/9, lib
  2382 passed / 6 skipped (pre-existing)

G5 (redeploy_saved_project primitive) is designed in the plan and follows.
- src/services/redeploy.rs: redeploy_saved_project rebuilds the Deploy form
  from the project's recorded request plus its saved server/cloud rows and
  pins server.server_id, so a push redeploys onto the existing server and
  never provisions a new VM (deploy.rs:1720 reuse path)
- webhook response grows 'triggered': per-repo outcome
  (queued|skipped|failed) with the reason (e.g. no saved server yet)
- acting user for webhook deploys is the connected repo's owner
- tests: github_webhook 9/9 including the G5 seam (skip without a saved
  server, deployment row created with one), github-events 7/7,
  notification_channels 9/9, lib 2382 passed / 6 skipped

Closes WS-G (G1-G5).
- schema: backup_destination, backup_job (source postgres/mysql/mongo/volume,
  cron schedule, retention 7 daily + 4 weekly), backup_run lifecycle
  (migration 20261124142356)
- crates/backup-core: dump/restore command building for the agent exec queue
  (single shell commands, per-run token via $BACKUP_TOKEN, never embedded)
  and the retention policy (B2); 9 unit tests in ~10ms
- docs/BACKUPS_SYNCOPIA.md: decisions B1-B3, architecture

Contracts and fixtures: config/shared-fixtures (backups-syncopia.json,
backups.feature).
Header names for the backup upload/download leg are now passed in
(BackupSpec.extra_headers) and rendered generically - nothing
vendor-specific is hardcoded in the crate. The service layer will supply
them from configuration per destination. Tests updated (10/10).
@vsilent

vsilent commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Closing: rework needed (documentation language and quality issues).

@vsilent vsilent closed this Nov 24, 2026
@vsilent
vsilent deleted the feature/notifications branch November 24, 2026 15:04
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.

2 participants