Implement recursive CTE in compute_visible_party_ids

Table of Contents

This page is a capture in the next bucket of the product backlog — a pre-sprint idea, not yet pulled into a sprint as a story.

What

(One paragraph: the idea.)

Why

(Motivation, problem being solved, related context.)

References

See also

The current implementation of compute_visible_party_ids (used by PostgreSQL RLS to decide which party rows a session may see) returns only {party_id} with no descendants:

-- stub: just {party_id}
RETURN QUERY SELECT party_id;

Replace with a recursive CTE over ores_refdata_parties_tbl.parent_party_id so the visible set includes the logged-in party and all its descendants. This is the mechanism for HBAC (hierarchy-based access control) on books, portfolios, and other party-scoped entities.

Emacs 29.1 (Org mode 9.6.6)