Skip to content

feat(rules): evaluation, targets and errors - #606

Open
ccf-lisa[bot] wants to merge 1 commit into
effectors/12-rules-celfrom
effectors/13-rules-evaluate
Open

ccf-lisa[bot] wants to merge 1 commit into
effectors/12-rules-celfrom
effectors/13-rules-evaluate

Conversation

@ccf-lisa

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

Copy link
Copy Markdown
Contributor

What

internal/service/rules (API LLD, evidence source and rules.evaluate-subject):

  • EvidenceSubjects / EvidenceSubjectFor: each stream's subject document from its latest evidence (greatest end), in a fixed number of queries: labels, subjects with props and links, components (system components with their defined component's identity labels, and subjects that are defined components). EvidenceStreamPage pages through streams by keyset.
  • EvaluateSubject(when, plans, doc, now): when, then each action's targets (fixed identity or CEL), deduplicated and sorted; identities the registered effector action can't accept are left out with a reason. A failing when is no match, a failing target no target.
  • CheckTarget: the checks the agent does: the scheme:value grammar, a declared scheme, its value pattern, the action's include/exclude patterns.
  • RecordError: upserts an evaluation error per (rule, action, subject) with a count and first/last seen; messages are cut on a UTF-8 boundary.
  • LookupEffectorAction: the freshest instance's registration of an action, and whether it is fresh.

Not here, on purpose: the preview (next PR) and what only the rule routes use (ResolveAgent, ClearErrors, durations, rule action params checks), which stack 3 ports with the routes.

Why

Plan: stack 2, PR 13, split into this PR and the preview (13b) to stay under 1000 lines.

Test evidence

  • evaluate_test.go: CheckTarget (every rejection, no registered action, a broken value pattern), EvaluateSubject (fixed and CEL targets, duplicates, invalid identities with reasons, failing target and when, no match, now), UTF-8 truncation.
  • rules_integration_test.go (Postgres): subject documents from the latest evidence, defined components as subjects, system components with and without a definition, a missing stream, paging; LookupEffectorAction (none, stale, freshest wins); RecordError (one row per key with a nil action as one key, count, truncation, first/last seen).

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

Size

Counted: 742 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: 19ad29a2-0a48-4b6e-a5d1-261e73d8a87d

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/service/rules: evidence subject documents built from each
stream's latest evidence in a fixed number of queries (labels, subjects
with props and links, components with their identity labels), keyset
paging over streams, EvaluateSubject (when, then each action's targets:
fixed or CEL, deduplicated, sorted, and checked against the registered
effector action's schemes, value patterns and target allowlist the way
the agent checks them), RecordError (upserted per rule, action and
subject; long messages cut on a UTF-8 boundary) and
LookupEffectorAction (the freshest instance's registration, and whether
it is fresh).

Nothing calls them 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