Skip to content

feat(effectors): config and domain event outbox - #603

Open
ccf-lisa[bot] wants to merge 1 commit into
effectors/10-modelsfrom
effectors/11-config-outbox
Open

ccf-lisa[bot] wants to merge 1 commit into
effectors/10-modelsfrom
effectors/11-config-outbox

Conversation

@ccf-lisa

@ccf-lisa ccf-lisa Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

What

Config (API LLD, configuration): internal/config/effector.go reads

Variable Default
CCF_EFFECTOR_SIGNING_KEY none: effectors are off without it
CCF_EFFECTOR_SIGNING_KEY_NEXT none
CCF_EFFECTOR_ALLOW_INSECURE_WEBHOOKS false
CCF_EFFECTOR_CEL_COST_LIMIT 100000
CCF_EFFECTOR_DELIVERY_TIMEOUT 10s

into Config.Effector, with Enabled() and EffectorDomainEvents() (effectors on and the worker running). The variables are bound in cmd/root.go (PoC follow-up 5 (follow-ups): unbound, they were silently ignored and effectors stayed off) and listed in .env.example.

Outbox (API LLD, producer and dispatcher): internal/service/outbox

  • SubjectChanged / Write record a domain event in the producer's transaction; WriteJob records an engine job with its payload; MarkProcessed marks rows whose jobs were enqueued directly.
  • Dispatch claims up to 500 unprocessed rows FOR UPDATE SKIP LOCKED, folds them into one evaluation per (source, subject) (newest row id kept), passes engine job rows through, skips sources without enabled rules, and marks everything processed except the rows the enqueue callback asks to keep, all in the caller's transaction.
  • Prune deletes processed rows older than a cutoff (Retention = 24h).

Producers: evidence.WithDomainEvents() makes EvidenceService.Create write a subject-changed event in the evidence's transaction; EvidenceIntegration.WithDomainEvents(true) does the same for workflow evidence, which now writes each evidence row and its labels in one transaction.

Nothing turns the producers on or runs the dispatcher yet: cmd/run.go is unchanged. That wiring lands with the River workers (stack 2), so no rows pile up before something consumes them.

Why

Plan: stack 1, PR 11. Last PR of stack 1.

Test evidence

  • internal/service/outbox/outbox_integration_test.go (new; the PoC only tested dispatch through the worker): empty dispatch, folding per subject and newest id, sources without enabled rules, engine job payloads, kept rows, the limit, rollback on enqueue error, SKIP LOCKED under a concurrent dispatcher, rollback of a producer transaction, MarkProcessed and Prune. 85.9% coverage.
  • domain_events_integration_test.go: Create writes one row per evidence with the option, none without, none when the transaction rolls back. internal/workflow: workflow evidence writes the stream's event only when enabled.
  • internal/config/effector_test.go (defaults, overrides, quotes, nil config) and cmd/root_test.go (the environment reaches the loader).

Gate on this branch: go build ./... pass; go vet -tags integration ./... pass; make lint 0 new issues (6 pre-existing on main, untouched files); make test pass; make swag no diff; go mod tidy no diff; go test -tags integration -p 1 on ./internal/service/outbox/ ./internal/service/relational/evidence/ ./internal/workflow/ ./cmd/ ./internal/config/ pass.

Size

Counted: 810 lines.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 914d19f7-bb56-4bcc-9249-cd5f84464183

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

internal/config: the CCF_EFFECTOR_* settings (signing keys, insecure
webhooks, CEL cost limit, delivery timeout), bound in cmd so the
environment reaches them (PoC follow-up 5), and listed in .env.example.

internal/service/outbox: writes domain events in the producer's
transaction and dispatches them (claim with SKIP LOCKED, one evaluation
per subject, engine job rows, rows kept for the next dispatch, prune).
EvidenceService and the workflow evidence integration can record a
subject-changed event with every evidence write (WithDomainEvents);
nothing enables it yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@gusfcarvalho gusfcarvalho 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.

ccf-review: APPROVE

no findings.

Stack (gh stack 604): #592 → #593 → #594 → #595 → #596 → #597 → #598 → #599 → #600 → #601 → #602 → #603 → #605 → #606 → #607 → #608 → #609 → #610 → #611 → #612 → #613 → #614 → #615 → #616 → #617 → #618 → #619 → #620 → #621 → #622 → #623 → #624 → #625 → #626 → #627 → #628 → #629 → #630

This branch has not been deployed

No deployments
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.

1 participant