Skip to content

feat(effectors): models and migrations - #602

Open
ccf-lisa[bot] wants to merge 2 commits into
effectors/09-sdkfrom
effectors/10-models
Open

ccf-lisa[bot] wants to merge 2 commits into
effectors/09-sdkfrom
effectors/10-models

Conversation

@ccf-lisa

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

Copy link
Copy Markdown
Contributor

What

New package internal/service/relational/effectors: the GORM models of the API LLD's data model, all ccf_-prefixed.

Model Table Role
DomainEvent ccf_domain_events The outbox: subject changes and the engine's own jobs
Rule, RuleAction ccf_rules, ccf_rule_actions Rules (soft-deleted) and their actions (target, timing, status, params)
RuleSubjectMatch, RuleSubjectWatch ccf_rule_subject_matches, …_watches Per-subject for timing and now-dependent subjects
Effect, EffectSubject ccf_effects, ccf_effect_subjects Desired state per (rule action, agent, action, target)
EffectHistory, EffectDelivery ccf_effect_history, ccf_effect_deliveries Generations and delivery attempts (24h retention later)
RuleError ccf_rule_errors Evaluation errors per (rule, action, subject)
AgentEffector, AgentEffectorInstance, EffectorAction ccf_agent_effectors, … Agent base URLs, registrations and registered actions (with params schema, defaults and locks)

EnsureIndexes adds what GORM tags can't express (the outbox's partial indexes, the rule-error upsert key with a nil action as one key). Models() is added to both AutoMigrate lists (internal/service/migrator.go, internal/tests/migrate.go), and ModelsReversed() to both MigrateDowns. Small helpers encode and decode stored params.

Ported from the PoC. The tables are created but nothing reads or writes them yet: the outbox writer comes in the next PR, the engine in stack 2.

Why

Plan: stack 1, PR 10.

Test evidence

  • models_integration_test.go (Postgres): a rule with an action and an effect, the effect key's uniqueness, the rule-error key treating a nil action as one key, the JSON columns of an effector action.
  • models_test.go (new, unit): Models/ModelsReversed order, DecodeParams/EncodeParams (null, empty, round trip, errors), the params accessors.

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 ./internal/service/relational/effectors/ ./internal/service/ pass (includes the migrator's integration tests).

Notes for reviewers

  • Deferred from self-review (should-fix, ported as is): `EffectorAction.Locked()` ignores a decode error of the stored `params_locked` column and returns no locks. The column is only written by the API from a validated registration; making it return an error changes the stack 2 call sites.

Size

Counted: 600 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: c9d27a0c-ffc6-4a62-9d17-f1b0de502b89

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

@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: REQUEST_CHANGES

1 Must-fix.

Stack (gh stack 604): #592 → #593 → #594 → #595 → #596 → #597 → #598 → #599 → #600 → #601 → #602 → #603

ccf-lisa Bot and others added 2 commits December 2, 2026 08:35
internal/service/relational/effectors: the GORM models of the effector
design (docs/effectors/lld/api.md, Data model): the domain event outbox,
rules and rule actions (with params), per-subject matches and watches,
effects with their subjects, history and deliveries, rule errors, and
agent effector registrations and actions, with the indexes GORM tags
can't express. Added to both AutoMigrate lists and to MigrateDown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
EffectorAction.Locked dropped the decode error and returned no locks, so
a corrupt stored list would let rule params through that the operator
locked. It now returns ([]string, error), like DecodeParams, and callers
fail closed.

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