Skip to content

feat(effects): rule and rule action changes - #612

Open
ccf-lisa[bot] wants to merge 1 commit into
effectors/16-effect-backfill-prunefrom
effectors/16b-rule-lifecycle
Open

ccf-lisa[bot] wants to merge 1 commit into
effectors/16-effect-backfill-prunefrom
effectors/16b-rule-lifecycle

Conversation

@ccf-lisa

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

Copy link
Copy Markdown
Contributor

What

rules.Lifecycle is how a rule or rule action change reaches its effects, inside the transaction that saves it (user interface, rule actions are resources; API LLD, effect state machine). effects.Engine.Apply implements it:

Change Effects
Rule created, enabled, trigger changed Backfill the rule
Rule disabled / deleted Delivered effects cleared as disabled / removed; pending ones go inactive silently; matches and watches dropped
Action created or changed Backfill that action; a params change also redelivers its active and finished effects (redelivered) so plugins re-render
Action params only Redeliver only
Action repointed (agent or effector action) Its effects on the old one removed; backfilled from scratch
Action deleted Its effects removed

The jobs a change decides are written to the outbox with it (backfills join ticks and deliveries) and enqueued after commit (AfterCommit). Machine.Redeliver bumps an active or finished effect's generation with the same content.

Raising max_repeats does not resume a finished effect: that is an open question in the plan, deliberately not implemented.

Nothing calls Apply until the rule routes (stack 3).

Why

Plan: stack 2, split out of the plan's PR 15/16 to keep each under 1000 lines.

Test evidence

lifecycle_integration_test.go (Postgres): disable (pending effects aren't delivered), enable (backfill, generations keep increasing), delete (removed, the document still builds); repoint (removed on the old agent, fresh on the new one, an old tick is a no-op) and delete an action; params changes redeliver active and finished effects only, with the new params in the document; an evaluation and a backfill wait for a disable and then write nothing; a rule change's backfill is written to the outbox; Redeliver (not redeliverable, not found, ok). jobs_integration_test.go covers backfill payloads.

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/effects/ ./internal/service/rules/ pass.

Size

Counted: 558 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: 9e50122b-87c3-482c-ba63-6e6f79864ca9

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

rules.Lifecycle is how a rule or rule action change reaches its effects,
inside the transaction that saves it; effects.Engine implements it:

- rule created, enabled or its trigger changed: backfill the rule;
- rule disabled or deleted: every delivered effect is cleared as
  disabled or removed, pending ones go inactive silently, and the rule's
  matches and watches are dropped;
- action created or changed: backfill that action; a params change also
  redelivers its active and finished effects (transition redelivered)
  so plugins re-render them;
- action repointed to another agent or effector action: its effects on
  the old one are removed, and it is backfilled from scratch;
- action deleted: its effects are removed.

The jobs a change decides are written to the outbox with it (backfills
join ticks and deliveries) and enqueued after commit. Redeliver bumps an
active or finished effect's generation with the same content. A raised
max_repeats does not resume a finished effect (an open question).

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