feat(modules): group-docs schema + kind-generalized registry (§11.6 docs C1)

Data layer for extending shared group collections from KV to docs. KV behavior
unchanged (callers pass kind="kv").

- 0054_group_docs.sql: widen the group_collections kind CHECK to ('kv','docs')
  and add the group-keyed group_docs store (clone of docs/0013, keyed by
  group_id, CASCADE on group delete) + its (group_id,collection) and data GIN
  indexes.
- group_collection_repo: thread a `kind` parameter through list_for_owner,
  resolve_owning_group, insert/delete_collection_tx; add list_all_for_owner ->
  (name,kind) for the kind-aware diff (D4). Relocate the injectable
  GroupCollectionResolver trait + Postgres impl here (now shared by kv+docs;
  resolve takes kind) — was in group_kv_service.
- group_docs_repo: a near-clone of docs_repo keyed by group_id; find reuses the
  generalized build_find_query.
- docs_repo: generalize build_find_query(table, owner_col, owner_id, …) — both
  are compile-time literals (no injection); app docs passes ("docs","app_id"),
  group docs ("group_docs","group_id"). row_to_doc/build_find_query are now
  pub(crate) for reuse.

Schema snapshot re-blessed (55 migrations).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
MechaCat02
2026-06-30 07:33:39 +02:00
parent af525e71bd
commit 5d1d4b3ff6
8 changed files with 479 additions and 87 deletions

View File

@@ -850,6 +850,7 @@ impl ApplyService {
&mut *tx,
owner.as_script_owner(),
&ch.key,
"kv",
)
.await
.map_err(|e| ApplyError::Backend(e.to_string()))?;
@@ -956,6 +957,7 @@ impl ApplyService {
&mut *tx,
owner.as_script_owner(),
&ch.key,
"kv",
)
.await
.map_err(|e| ApplyError::Backend(e.to_string()))?;
@@ -1800,7 +1802,7 @@ impl ApplyService {
owner: ApplyOwner,
) -> Result<Vec<CollectionInfo>, ApplyError> {
let names =
crate::group_collection_repo::list_for_owner(&self.pool, owner.as_script_owner())
crate::group_collection_repo::list_for_owner(&self.pool, owner.as_script_owner(), "kv")
.await
.map_err(|e| ApplyError::Backend(e.to_string()))?;
Ok(names
@@ -2076,7 +2078,7 @@ impl ApplyService {
.map_err(|e| ApplyError::Backend(e.to_string()))?;
// Shared group-collection markers declared directly at this node (§11.6).
let collection_names =
crate::group_collection_repo::list_for_owner(&self.pool, owner.as_script_owner())
crate::group_collection_repo::list_for_owner(&self.pool, owner.as_script_owner(), "kv")
.await
.map_err(|e| ApplyError::Backend(e.to_string()))?;
Ok(CurrentState {