BE-M0-41 · Sessions end on suspension, removal and role changes, not at a new pool; finance reads bank accounts
ID BE-M0-41 · Level L0 · Pack Pack G1b · Sessions and bank accounts · Run order row 22d, after pack G1b's pull request is merged · Issue #165
Besides a change to a member's roles or overrides (R-ACC-08), a member's sessions end and their profile records when if their membership is suspended (R-ACC-52) or removed (R-ACC-53), and every holder's do when a permission is added to or removed from a role they hold, at any pool (R-ACC-54). The super_admin grant at a new pool (R-ACC-47) ends no session (R-ACC-55). Company bank accounts are read with master_data:read or payment:read, so finance can pick the account a payment came into; pricing groups and contract templates still need master_data:read (R-MD-12). It all follows D48; proxy.ts and session_is_current() don't change.
This step changes no file: the code arrived with pack G1b's pull request. It proves the change from main on your Mac's local stack.
Before
Section titled “Before”- Pack G1b's pull request is merged into main, after BE-M0-40.
- You are in ~/opleet-v2/opleet, the local stack is running (
pnpm supabase start), andgit status --shortprints nothing.
1 · Main, rebuilt from nothing
Section titled “1 · Main, rebuilt from nothing”The migration files were edited in place (D11), so the local database is rebuilt, never migrated.
git switch main && git pullpnpm supabase db reset2 · Every test
Section titled “2 · Every test”pnpm supabase test dbExpect
Section titled “Expect”- Block 1: "Finished supabase db reset".
- Block 2:
All tests successful.,Files=14, Tests=366andResult: PASS. Pack G1b's tests are the 18 in41_access_changes.test.sql, whose descriptions startR-ACC-52toR-ACC-55andR-MD-12, and theR-MD-12line in21_rls.test.sql.
pnpm supabase db query --local "select tgrelid::regclass as on_table, tgname from pg_trigger where tgname like 'end_sessions%' order by 1, 2"Five rows: member_permission_overrides and member_roles with end_sessions (R-ACC-08), memberships with end_sessions_on_remove and end_sessions_on_suspend, and role_permissions with end_sessions.
If it fails
Section titled “If it fails”supabase db resetstops on a migration: paste the file name and the error into #165. Don't edit the file.- A test fails: paste the
not okline and the lines under it that start with#. The test's description starts with the rule it proves. - "permission denied" or "must be owner" on auth.sessions: stop and paste it. The triggers run as their owner so they can end sessions; BE says so on the issue before changing anything.
Nothing to undo: the step changes no file. pnpm supabase db reset rebuilds the local database from main at any time. Never run any part of it against staging or production.
Afterwards: staging
Section titled “Afterwards: staging”Staging still holds the schema from before pack G1b. Once this step's run is logged clean, rebuild staging from main with BE-M0-33 and log that run on #22. BE-M0-33 wipes staging and is zuki's alone; the M0 exit check waits for it (TL-M0-24, row 36).
Log each run as a comment on #165: the date, the last lines of block 2, and the check's output. #165 closes when this run is clean.