Skip to content

feat(webhook): make health-sweep thresholds config-controlled - #1029

Open
AmirF194 wants to merge 1 commit into
tokencanopy:mainfrom
AmirF194:fix/863-webhook-health-thresholds-config
Open

AmirF194 wants to merge 1 commit into
tokencanopy:mainfrom
AmirF194:fix/863-webhook-health-thresholds-config

Conversation

@AmirF194

Copy link
Copy Markdown
Contributor

WarnThreshold, WarnSweepMaxPerTick, and DisableSweepMaxPerTick were compiled constants, so a deployment whose traffic can't accumulate the compiled default's failures could never warn, and turning either per-tick cap down during a real outage meant shipping a release. Scoped this to the two items you flagged as worth having first: WarnThreshold and the per-tick caps. AutoDisableThreshold/AutoDisableWindow stay compiled, as you suggested.

New webhook.warn_threshold and webhook.sweep_max_per_tick (env: E2A_WEBHOOK_WARN_THRESHOLD, E2A_WEBHOOK_SWEEP_MAX_PER_TICK), both defaulting to today's compiled values so an unconfigured deployment doesn't change. One knob covers both WarnSweepMaxPerTick and DisableSweepMaxPerTick rather than two, since your own example only had one sweep_max_per_tick key and they're both 100 today for the same incident-response reason. Validate rejects anything below 1, matching your validation note.

Went under the existing webhook: block (internal_sink_url's home) rather than a new webhooks: block: its own doc comment already says "webhook-delivery settings other than the fan-out engine choice," which is exactly this. Store.SetWebhookHealthLimits carries the override the same optional-setter way the rest of Store's config does, so NewStore(pool) and every existing test are unchanged.

Added TestSetWebhookHealthLimits_OverridesWarnThreshold and TestSetWebhookHealthLimits_OverridesSweepMaxPerTick (the latter also proves the cap drains across ticks rather than dropping), plus TestWarnFailingWebhooks_DefaultWarnThresholdUnaffectedWithoutSetter for the no-override case, and a config load/env/validate test mirroring the existing trash.retention_days one. Full go test ./internal/identity/... and ./internal/config/... pass, gofmt and go vet clean.

Not done: the config.example.yaml documentation block, since the existing webhook: key isn't documented there either (it looks deliberately internal-facing). Happy to add one if you want it there for these two operator-facing fields specifically.

Fixes #863

WarnThreshold, WarnSweepMaxPerTick, and DisableSweepMaxPerTick were
compiled constants. A self-hosted deployment's traffic volume can make
WarnThreshold unreachable in either direction, and the two per-tick
caps are the only incident-response lever for a real e2a-side outage;
turning either down used to need a release.

Adds webhook.warn_threshold and webhook.sweep_max_per_tick (env:
E2A_WEBHOOK_WARN_THRESHOLD, E2A_WEBHOOK_SWEEP_MAX_PER_TICK), both
defaulting to the current compiled values so an unconfigured self-host
is unchanged. Config.Validate rejects anything below 1: a threshold or
cap of 0 would silently break the feature rather than disable it.
Store.SetWebhookHealthLimits carries the override the same optional-setter
way SetDKIMCipher and friends do, so NewStore(pool) and every existing
test are untouched.

AutoDisableThreshold/AutoDisableWindow stay compiled, per the issue's
own scope: they interact with the GA-frozen retry envelope and want
more thought before being exposed.

Fixes tokencanopy#863
@AmirF194
AmirF194 requested a review from jiashuoz as a code owner September 14, 2026 05:13
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 health thresholds config-controlled instead of compile-time constants

1 participant