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>
22 lines
1.2 KiB
SQL
22 lines
1.2 KiB
SQL
-- §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;
|