You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 30d2941
Browse filesBrowse the repository at this point in the historyBrowse files
perf(workflow): cache enabled-workflow lookups per channel with sync invalidation
E3 (correctness ruling §4.10): every ingested channel event ran a
list_enabled_channel_workflows SELECT to find trigger candidates, and
most channels have no workflows at all. Add a moka look-aside cache in
WorkflowEngine keyed (community_id, channel_id) so the trigger path hits
the DB once per channel per TTL instead of once per event.
§4.10 fences:
- Key is community-scoped (community_id, channel_id) — channel UUIDs
collide across communities (Inv_LabelPropagation).
- TTL is 10s (ruling allows ≤30s), matching the relay's other moka
caches.
- Negative results are cached: an empty list is inserted like any other,
which is where most of the win is.
- Synchronous invalidation at every live mutation site. Audit (per
Wren's broad definition — ingest upsert/delete, HTTP/API toggles,
admin/test helpers, soft-delete/reactivation): the only paths that
write trigger eligibility or channel binding are the kind:30620
command upsert and NIP-09 a-tag deletion; both invalidate immediately
after the DB write. delete_workflow_for_owner now RETURNING channel_id
so the deletion path invalidates without a second lookup. The unused
buzz-db mutators (create_workflow, update_workflow,
update_workflow_status, set_workflow_enabled, delete_workflow) have no
callers anywhere in the workspace — CLI and desktop route through
event submission, webhook and approval-resume only write
workflow_runs — and each carries a doc note requiring shared
invalidation from any future caller.
Consistency: no cross-pod invalidation, deliberately. Workflow
triggering is not an access-control fence; the worst case on another
pod is a just-deleted workflow firing (or a just-created one missing
events) for up to 10s. The same TTL bounds the look-aside fill race.
Co-authored-by: Tyler Longwell <[email protected]>
Signed-off-by: Tyler Longwell <[email protected]>
0 commit comments