Skip to content

feat: add durable webhook idempotency - #56

Merged
Lakes41 merged 2 commits into
Adamantine-guild:mainfrom
rohitmulani63-ops:durable-webhook-idempotency
Jun 25, 2026
Merged

Lakes41 merged 2 commits into
Adamantine-guild:mainfrom
rohitmulani63-ops:durable-webhook-idempotency

Conversation

@rohitmulani63-ops

Copy link
Copy Markdown
Contributor

Description

Adds durable webhook idempotency for dashboard activity ingestion. Webhook event IDs are now recorded through one storage boundary so duplicate retries are handled during the write instead of by a separate pre-check.

Linked Issue

Closes #45

Type of Change

  • Bug fix
  • New feature / enhancement
  • Documentation update
  • Chore / refactor
  • Tests only

Changes Made

  • Added a storage-level record-or-duplicate flow for processed webhook IDs.
  • Added a file-backed local durable adapter that uses atomic marker creation for duplicate protection.
  • Updated the webhook route to call the idempotent activity write path directly.
  • Added coverage for restart-safe duplicate detection and concurrent duplicate submissions.
  • Documented durable webhook storage settings in deployment notes.
  • Cleaned activity typing so the dashboard typecheck passes cleanly.

Test Evidence

  • node_modules\.bin\tsc.cmd --noEmit -p apps/dashboard/tsconfig.json passed.
  • node_modules\.bin\eslint.cmd apps/dashboard/lib/activity/storage.ts apps/dashboard/app/api/webhooks/route.ts apps/dashboard/test/webhook.test.ts apps/dashboard/lib/env.ts apps/dashboard/lib/activity/types.ts apps/dashboard/lib/hooks/useActivityFeed.ts passed.
  • git diff --check passed for touched files.
  • Hidden/bidi control character scan passed for touched files.

Not run: package test scripts. In this checkout, pnpm stops before package scripts because dependency build scripts require explicit approval.

Checklist

  • I have read CONTRIBUTING.md
  • This PR is linked to an open issue
  • npm run typecheck passes with no errors
  • npm run lint passes
  • The Discord bot still starts and responds to commands (if bot code changed)
  • Docs site renders correctly (if docs changed): npm run dev:docs
  • No secrets, tokens, or API keys are included in this PR
  • Environment variable changes are reflected in .env.example
  • I have updated documentation if new behaviour was introduced

Screenshots / Recordings

Not applicable for this backend/storage change.

Additional Notes

I ran the focused dashboard typecheck and ESLint commands listed above. The package scripts were not marked complete because the local pnpm install blocks package script execution until dependency build-script approval is handled.

The file-backed adapter is meant for local durable mode and as a concrete implementation of the idempotency boundary. Hosted production can use the same interface with a database-backed adapter and a unique constraint on webhook event ID.

@rohitmulani63-ops

Copy link
Copy Markdown
Contributor Author

Hi @Lakes41, this PR is ready for review. I linked it to #45 and kept the scope focused on durable webhook idempotency across restarts/redeployments, with tests for duplicate and concurrent duplicate submissions. Happy to adjust the approach if you prefer a narrower storage boundary.

@Lakes41 Lakes41 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats fine, Good job. Please do resolve conflicts @rohitmulani63-ops

@rohitmulani63-ops

Copy link
Copy Markdown
Contributor Author

Hi @Lakes41, thanks for checking this.

I resolved the conflicts against the latest main branch and kept the durable webhook idempotency changes alongside the newer dashboard mock/live updates. GitHub is showing the branch as cleanly mergeable now.

@Lakes41
Lakes41 merged commit 4f0344b into Adamantine-guild:main Jun 25, 2026
@rohitmulani63-ops

Copy link
Copy Markdown
Contributor Author

thanks @Lakes41 glad this got merged

if anything small comes up around the webhook flow docs or tests I can help

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.

Make webhook idempotency durable across deployments

2 participants