fix(controlplane): exclude deleted workflows from referrer visibility

PE
2d ago
+104-1

Private discovery can expose a shared referrer to a project-scoped caller when a deleted workflow supplies its only granted project. Deleted workflows now stop contributing to referrer visibility, for both root lookups and first-level references.

Consider digest D linked to a live workflow in hidden project B and a deleted workflow in granted project A. The organization-level SQL check finds the live workflow, while hydration currently includes both projects; the grant for A then admits D. Hydration now skips the deleted workflow, so only B participates and the caller cannot retrieve D. A live workflow in A still grants access.

The guard lives in hydrateWorkflowsInfo, which both discovery paths use. This keeps query ordering and cursor construction unchanged rather than duplicating the rule in the eager-loading queries. Deleted workflows also stop contributing workflow IDs, and project or organization IDs contributed solely by those workflows, to the internal discovery result. There is no API or schema change.

AI assistance: Perfloop.

cc @migmartri @javirln

Case and evidence


Made by Perfloop.