Thanks! I knew that there had to be a function somewhere; it hadn't occurred to me that the function was written in Pl/PgSQL, rather than Tcl.
I'm also having fun reading through https://openacs.org/new-file-storage/download/permissions-notes-vadim.html?version_id=229, which is explaining permissions and the data model rather nicely; even if it doesn't directly address this issue, that document will undoubtedly help me to understand the rest of the system.