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
PR #55 introduced ScopeLinkRepo::list_authz_scope_links() to replace the legacy "hydrate full entities then map to scope edges" approach with ID-only queries. The Postgres implementation in crates/oversight-store-pg/src/repo_scope_link.rs currently issues 7 sequential SQL queries (projects, collections, documents, tasks, workflows, cycles, agent_definitions).
This is already a significant improvement over the legacy collector that hydrated Document labels/attrs/version, Task assignees/labels, nested workflow state, etc. But each authz reload still incurs 7 PG round-trips, which adds up under frequent reload (membership/grant churn, hot-reload triggers).
Proposed change
Collapse into one UNION ALL shaped as (child_type, child_id, parent_type, parent_id), then map tuples to Scope variants in Rust:
SELECT'project'AS child_type, id AS child_id, 'workspace'AS parent_type, NULL::textAS parent_id FROM projects
UNION ALLSELECT'collection', id, 'project', project_id FROM collections
UNION ALLSELECT'document', id, 'collection', collection_id FROM documents
UNION ALLSELECT'task', id, 'project', project_id FROM tasks WHERE project_id IS NOT NULLUNION ALLSELECT'workflow', id, 'project', project_id FROM workflows WHERE project_id IS NOT NULLUNION ALLSELECT'cycle', id, 'project', project_id FROM cycles WHERE project_id IS NOT NULLUNION ALLSELECT'agent', agent_id, 'workspace', NULL::textFROM agent_definitions;
Acceptance
Single PG query replaces the 7 sequential ones in crates/oversight-store-pg/src/repo_scope_link.rs.
Existing pg_scope_link_repo testcontainer test in crates/oversight-store-pg/tests/repo_contracts.rs passes unchanged.
Cross-backend parity stays asserted via the same fixture in both sqlite_scope_link_repo and pg_scope_link_repo.
Behavior on empty tables remains identical (returns Vec::new()).
Follow-up from PR #55 review.
Context
PR #55 introduced
ScopeLinkRepo::list_authz_scope_links()to replace the legacy "hydrate full entities then map to scope edges" approach with ID-only queries. The Postgres implementation incrates/oversight-store-pg/src/repo_scope_link.rscurrently issues 7 sequential SQL queries (projects, collections, documents, tasks, workflows, cycles, agent_definitions).This is already a significant improvement over the legacy collector that hydrated
Documentlabels/attrs/version,Taskassignees/labels, nested workflow state, etc. But each authz reload still incurs 7 PG round-trips, which adds up under frequent reload (membership/grant churn, hot-reload triggers).Proposed change
Collapse into one
UNION ALLshaped as(child_type, child_id, parent_type, parent_id), then map tuples toScopevariants in Rust:Acceptance
crates/oversight-store-pg/src/repo_scope_link.rs.pg_scope_link_repotestcontainer test incrates/oversight-store-pg/tests/repo_contracts.rspasses unchanged.sqlite_scope_link_repoandpg_scope_link_repo.Vec::new()).Notes
Refs: PR #55, commits
67b76766+ddb07217.