Skip to content

feat(worker): effector job workers - #617

Open
ccf-lisa[bot] wants to merge 2 commits into
effectors/19-effector-statusfrom
effectors/20a-effector-workers
Open

ccf-lisa[bot] wants to merge 2 commits into
effectors/19-effector-statusfrom
effectors/20a-effector-workers

Conversation

@ccf-lisa

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

Copy link
Copy Markdown
Contributor

What

The River workers of the effector rule engine (API LLD, dispatcher, timers, delivery), not registered yet:

Job Worker
domain-events.dispatch Claims outbox batches (up to 20 per run) and inserts their jobs in the same transaction: one rules.evaluate-subject per subject (unique while queued or running; a change to a subject whose evaluation is running stays in the outbox for the next dispatch), and the engine's ticks, deliveries and backfills
rules.evaluate-subject, rules.backfill The engine (20 attempts / 30 min timeout)
effects.tick The machine at its time; snoozes when it runs early instead of re-scheduling an identical tick
effects.deliver One attempt; snoozes while the agent isn't ready; retries with 2^n s backoff, ±10% jitter, capped at 1h
effector.verify Verification, backing off up to 5 min
effects.prune 24h retention (including processed outbox rows)
rules.sweep The now sweep, skipping rules with a backfill queued or running

riverEffectScheduler enqueues the engine's jobs (one tick per effect and time, one delivery per generation) and registration's verifications (one per agent per minute); it implements effects.Scheduler and effector.Jobs. rules.EvaluateSubjectArgs and rules.BackfillArgs are the jobs' args.

No domain-events.prune worker: effects.prune already prunes processed outbox rows.

Why

Plan: stack 2, PR 20, split: the workers here, tested directly; registering them and turning the producers on in 20b, so no job is enqueued before its worker exists.

Test evidence

  • effectors_test.go: tick wait and early snooze, delivery backoff bounds, verify retry, bad engine job rows.
  • effectors_dispatch_integration_test.go (Postgres, River): folding per subject, sources without enabled rules, engine job rows to jobs (tick scheduled at its time), changes kept while an evaluation runs, active backfills; the scheduler's uniqueness; every worker run against the engine (evaluation, backfill, tick, delivery snoozing until the verify worker makes the agent ready, then delivered, retry on 502, prune, sweep).

Gate on this branch: go build ./... pass; go vet -tags integration ./... pass; make lint (golangci-lint v2.15.0, CI config) 0 new issues; make test pass; make swag no diff; go mod tidy no diff; go test -tags integration -p 1 on ./internal/service/worker/ ./internal/service/rules/ pass.

Size

Counted: 961 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: 881d1d75-b277-4294-978d-5e5b5a3b9465

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

ccf-lisa Bot and others added 2 commits December 2, 2026 11:04
internal/service/worker: the River workers of the effector rule engine
(LLD Dispatcher, Timers and backfill, Delivery), not registered yet:

- domain-events.dispatch claims outbox batches in a transaction and
  inserts their jobs in it: one rules.evaluate-subject per subject
  (unique while queued or running; a change to a subject whose
  evaluation is running stays in the outbox for the next dispatch), and
  the engine's own ticks, deliveries and backfills;
- rules.evaluate-subject, rules.backfill, effects.tick (snoozes when it
  runs early), effects.deliver (snoozes while the agent isn't ready,
  retries 429/5xx/timeouts with capped exponential backoff and jitter),
  effector.verify, effects.prune (24h retention, including the outbox)
  and rules.sweep (skipping rules with a backfill queued or running);
- the scheduler the engine and registration enqueue through: one tick
  per (effect, time), one delivery per (effect, generation), at most one
  verification per agent per minute.

The next PR registers them and turns the producers on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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