Skip to content

Integration: rule evaluation ordering & precedence vs hooks (in-transaction) #105

Description

@rrrodzilla

Workstream: Integration · Part of #89

Context

All three rungs of the escalation ladder (#89) participate in a single write, and we must define one coherent ordering across them — not just rules-vs-hooks:

  1. Rules (CEL) — pure, in-transaction, before persistence.
  2. gRPC hooksbefore_* (blocking, pre-persistence) and after_* (detached, post-persistence) (crates/schema-forge-acton/src/hooks/mod.rs).
  3. Webhooks — outbound, fire-and-forget, dispatched on CRUD events alongside after_change; never block the response, retry with backoff (crates/schema-forge-acton/src/webhook.rs; dispatch in routes/entities.rs).

Defining this lets us also leverage that rules fix the documented hook reentrancy/ordering/consistency caveats.

Scope

  • Full write sequence: rule defaults → rule compute → rule validate → before_* hooks → persist → { after_* hooks, webhook dispatch }.
  • All rules evaluate in-transaction before persistence; specify precedence between rules and before_* hooks (rules first — they're pure and cheap, and can short-circuit before a network round-trip).
  • Pin down the post-persistence fan-out: relative ordering (if any) of after_* hooks vs. webhook dispatch, and that both are detached so neither blocks the API response.
  • Guarantee determinism for the in-transaction phase (engine-controlled ordering) and no rule reentrancy.
  • Confirm a rule abort prevents persistence and suppresses the post-persistence fan-out (no webhook/after_* fires for a rejected write).

Acceptance

  • Documented, tested ordering model covering rules, before_*/after_* hooks, and webhooks.
  • Rules evaluate in-transaction ahead of before_* hooks; a rule rejection fires no downstream hook or webhook.

Dependencies: Suggested order: after at least one capability lands (#92). Soft.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions