feat(shared-triggers): shared column on triggers (M2.1)
A group-owned trigger marked `shared = true` watches a §11.6 shared collection instead of per-app collections — the namespace boundary that lets a shared-collection write fire a trigger. Mirrors the sealed column; existing rows default false (per-app, unchanged). Match-query split + emission land in M2.2/M2.3. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
21
crates/manager-core/migrations/0061_shared_triggers.sql
Normal file
21
crates/manager-core/migrations/0061_shared_triggers.sql
Normal file
@@ -0,0 +1,21 @@
|
||||
-- §11.6 / §4.5: SHARED-collection triggers.
|
||||
--
|
||||
-- A §11.6 shared collection is group-owned and written by any subtree app via
|
||||
-- the `kv::shared_collection(...)` handles. Until now such writes fired NO
|
||||
-- trigger (the "group trigger has no app to watch" deferral): the per-app
|
||||
-- trigger dispatch keys on the writer app's OWN collections, and a shared
|
||||
-- collection lives in a distinct group-keyed store.
|
||||
--
|
||||
-- A SHARED trigger closes that gap: a group-owned trigger template marked
|
||||
-- `shared = true` watches the group's shared collection (not per-app
|
||||
-- collections). On a shared-collection write the emitter matches these triggers
|
||||
-- by the OWNING GROUP's chain and runs the handler under the WRITER app
|
||||
-- (`cx.app_id`) — the same "group template runs under the firing app" model.
|
||||
--
|
||||
-- The `shared` marker is the namespace boundary: a `shared = false` trigger
|
||||
-- (the default, incl. every existing row) watches per-app collections exactly
|
||||
-- as before; a `shared = true` trigger watches shared collections only. The two
|
||||
-- never cross (the per-app match queries add `AND t.shared = FALSE`, the shared
|
||||
-- match queries `AND t.shared = TRUE`).
|
||||
|
||||
ALTER TABLE triggers ADD COLUMN shared BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
@@ -409,6 +409,7 @@ table: triggers
|
||||
name: text NOT NULL default=(gen_random_uuid())::text
|
||||
group_id: uuid NULL
|
||||
sealed: boolean NOT NULL default=false
|
||||
shared: boolean NOT NULL default=false
|
||||
|
||||
table: vars
|
||||
id: uuid NOT NULL default=gen_random_uuid()
|
||||
@@ -940,3 +941,4 @@ constraints on vars:
|
||||
0058: template suppressions
|
||||
0059: sealed templates
|
||||
0060: group suppressions
|
||||
0061: shared triggers
|
||||
|
||||
Reference in New Issue
Block a user