feat: add support to wire webhooks from orchestrator to emitter workflows#70
Draft
feat: add support to wire webhooks from orchestrator to emitter workflows#70
Conversation
…ectable via SNAPSHOT_STORE=memory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and Why ?
Adds the detector → emitter webhook so the OrchestratorWorkflow can
notify the downstream emitter as soon as a snapshot is persisted,
instead of waiting for the emitter's own cron.
No breaking changes. No schema changes.
This work is purely additive at every layer that other systems can observe.
Auth model: this PR is wire-only. Network isolation between detector
and emitter could be enforced as required ranging from options like no-auth to
network policies in k8s all the way till the app layer authn and authz.
What's new (production code):
{"snapshot_id": ...} to /trigger-act with an
injectable HTTPDoer so tests can swap in a fake (no live HTTP).
Default client uses a 10s timeout.
Stage 3 (NotifyEmitter), invoked only when EmitterWebhookURL is
non-empty. Failures are non-fatal: the snapshot is already durable
in S3, so a transient emitter outage just delays emission and
Temporal's retry policy handles the rest.
Activities for test injection.
emitterWebhookURL plus a WithEmitterWebhookURL functional-option
helper. WorkflowInput.EmitterWebhookURL is forwarded into the
orchestrator workflow input.
scheduled workflow input.
NotifyEmitter activity, threads the URL through the schedule and
the admin /scan trigger.
Local testability (also production-safe; defaults preserve current
behavior):
laptop dev / CI smoke tests. Selectable via SNAPSHOT_STORE=memory
(default remains s3). Lets the orchestrator's Stage 2 succeed
without AWS credentials.
branch now falls back to pkg/inventory/mock.InventorySource (one
synthetic resource per config) instead of skipping every resource
and crashing with "no resources configured". Production paths set
the Wiz secrets and remain unaffected — the misleading "using mock
inventory" log line that already existed now actually does what it
says.
(all run the Temporal CLI / curl via Docker — no
brew install temporalneeded).make devno longer hard-requiresentr;auto-reload is used when entr is on $PATH, otherwise it falls back
to plain
go run ./cmd/server.Backwards compatibility:
arg. The package is internal to this private repo and all in-repo
callers (cmd/server, cmd/cli) are updated.
zero-values reproduce the prior behavior.
defaults: empty webhook URL = Stage 3 skipped (legacy behavior);
SNAPSHOT_STORE defaults to "s3".
workflow ID changes.
Tests: full unit suite green (pkg/scan, pkg/schedule, pkg/snapshot,
pkg/workflow/orchestrator, pkg/workflow/detection). NotifyEmitter has
7 tests covering success, 4xx, 5xx, network error, missing URL,
malformed body, and successful-but-empty body.
Local e2e workflow test confirmation