M1 · Access and master data
Conforms to the decisions through D104.
Applies
Section titled “Applies”-
D3 · Who may invite, what they may grant and acceptance are decided in Postgres; apps/web only sends Auth's email.
-
D4 · The invitations schema comes in through supabase/migrations.
-
D7 · The invite email is Indonesian only: the invitee has no locale yet (D98).
-
D10 and D30 · Every refusal raises a key of
public.error_key; theinvitation.*keys are below. -
D11 · Migration files are edited in place until cutover; M1-01's functions are in
20261006002100_invitations.sql. -
D13 · The secret key stays server side: apps/web's one server-only module calls Auth's admin invite (D98).
-
D19 and D27 ·
62_invitations.test.sqlproves each rule, every description starting with its ID. -
D33 ·
pnpm db:typesis run and committed with the migration. -
D37 and D48 · Every access change ends sessions, except accepting an invitation (R-ACC-98), like the R-ACC-47 grant.
-
D50 and D51 · No sign-up: a login is made only by an invitation; passwords and links as D51 sets them.
-
D52 · Acceptance is one transaction, so the activity log shows it as one entry (R-AUD-14).
-
D77 and D81 · Built in the team session on #454, through a pull request into integration.
-
D98 (proposed) · Postgres decides an invitation; one server-only module sends it; the link lasts 24 hours.
-
D3 and D4 (M1-02) · Roles change only through grant_role() and revoke_role(); authenticated holds no insert, update or delete on member_roles (R-ACC-107), through tools/db/gen_rls.py. The functions are in
20261006002200_member_roles.sql;63_member_roles.test.sqlproves them. -
D37 and D48 (M1-02) · Each grant or revoke ends the member's sessions, the caller's own included (R-ACC-08).
-
D52 (M1-02) · Each call is one transaction and one audit row, the member_roles insert or delete (R-ACC-117).
-
D63 · The functions return no other organization's rows: a membership the caller can't read is access.member_not_found (R-ACC-116).
-
D3 and D4 (M1-03) · Overrides change only through set_override() and clear_override(), and rental companies only through set_company_scope(); authenticated holds no insert, update or delete on member_permission_overrides or member_rental_companies (R-ACC-124, R-ACC-134), through tools/db/gen_rls.py. The functions are in
20261006002300_member_overrides_scope.sql;64_member_overrides_scope.test.sqlproves them. -
D37 and D48 (M1-03) · Each override change ends the member's sessions, the caller's own included (R-ACC-08); a change of rental companies ends none (R-ACC-140).
-
D52 (M1-03) · Each call is one transaction; set_company_scope() writes only the links that change, so a call that changes nothing writes no audit row.
-
D3 (#616) · A caller with rental companies of their own is held to them in Postgres: set_company_scope() refuses an empty set, a company outside their set and a member linked outside it or with no rental companies (R-ACC-149, R-ACC-150, R-ACC-152); scope_companies(), caller_company_scoped() and pool_members().can_set_scope tell apps/web what to offer, so it computes nothing.
-
D10 and D30 (#616) · Two new keys,
access.scope_limit_requiredandaccess.rental_company_not_held, both 42501. -
D11 (#616) ·
20261006002300_member_overrides_scope.sqlis edited in place;64_member_overrides_scope.test.sqlproves the rules (D19, D27). -
D63 (#616) ·
access.rental_company_not_heldnames only companies of the member's organization: it is checked after R-ACC-137. -
D3 and D4 (#616 round 2) · A scoped inviter is held to their own rental companies in Postgres: invite_member() takes the set and refuses it in order, resend_invitation() and acceptance recheck it against whoever last sent it (R-ACC-154 to R-ACC-162); grant_role(), revoke_role(), set_override() and clear_override() refuse a scoped caller a member outside their set (R-ACC-165, R-ACC-166). invitable_roles() and pool_members() say what to offer (R-ACC-163, R-ACC-167, R-ACC-168).
invitation_rental_companiesis new in20261006000300_master_data.sql; apps can only read it (R-ACC-164), through tools/db/gen_rls.py. -
D10 and D30 (#616 round 2) · Two new keys:
invitation.rental_companies_not_allowed(P0001) andaccess.member_outside_scope(42501);invitations.void_reasongainsscope_not_held. -
D11 and D19 (#616 round 2) ·
20261006000200,0300,1000_access_helpers,1100_rls,2100_invitations,2200_member_rolesand2300_member_overrides_scopeare edited in place;62_invitations.test.sql,63_member_roles.test.sqland64_member_overrides_scope.test.sqlprove the rules. -
D52 (#616 round 2) · Acceptance stays one transaction: the membership, role and rental-company links, or the void, in one entry.
-
D11 (M1-03) · The migration's access step (
20261006001600_migration_access.sql) is edited in place: a v1 code both granted and denied gives only the deny override (R-ACC-71, R-ACC-23). -
D99 (#621) ·
memberships.all_rental_companiesdecides the partner filter in Postgres: with the flag no limit, the operator's own cars included; without it only the list's cars, none with an empty list (R-ACC-42, R-ACC-43, R-ACC-169; R-ACC-170 was retired in #748, D108: the operator's own cars belong to TOP, which a list may name), the files from v1 too (R-STO-16, R-STO-18). set_all_rental_companies() is new; set_company_scope(), invite_member(), resend_invitation(), acceptance and pool_members() carry the flag (R-ACC-135 to R-ACC-183). -
D10 and D30 (#621) · One new key,
access.rental_companies_with_flag(P0001), raised by the trigger that keeps the flag and a list apart (R-ACC-172). -
D11 and D19 (#621) ·
0200,1000_access_helpers,1100_rls,1600_migration_access,2100_invitationsand2300_member_overrides_scopeare edited in place;21_rls,47_claim_photos_v1_files,51_migration_access,62_invitations,63_member_rolesand64_member_overrides_scopeprove the rules. -
D3 and D4 (M1-04) · A membership's status and its removal change only through suspend_member(), reinstate_member() and remove_member(); authenticated holds no insert, update or delete on memberships (R-ACC-174), through tools/db/gen_rls.py. Invitations are revoked and restored only through revoke_invitation() and restore_invitation().
-
D10 and D30 (M1-04) · Four new keys:
access.cannot_change_self,access.member_already_active,invitation.not_voided,invitation.already_member;invitations.void_reasonbecomes the enuminvitation_void_reason(D29: labels per language). -
D11 and D19 (M1-04) ·
0100_foundation,0200,1100_rls,2100_invitationsand2300_member_overrides_scopeare edited in place; the new20261006002400_member_management.sqlholds the five calls and, after their helpers, pool_members() (moved there from2300), member_detail() and pool_invitations().21_rls,41_access_changes,62_invitations,64_member_overrides_scope,65_member_management,66_invitation_revoke_restoreand67_member_readsprove the rules, every description starting with its ID. -
D31 and D33 (M1-04) ·
pnpm db:typesruns and is committed with the migration. -
D37 and D48 (M1-04) · suspend_member() and remove_member() end the member's sessions (R-ACC-52, R-ACC-53) through the existing memberships trigger; reinstate_member() and restore_invitation() end none (R-ACC-188, R-ACC-215).
-
D52 (M1-04) · Each of the five calls is one transaction, so one entry in the activity log (R-ACC-205, R-ACC-221).
-
D98 (M1-04) · A restore to pending is sent by apps/web's server-only module, as a resend.
-
D99 and D100 (M1-04) · A caller without the flag is held to their own set on all five calls (R-ACC-192, R-ACC-210).
-
D100 (#621, cited by the rules; no page yet) · A moved v1 login whose allowed_partners are absent, empty or all dropped gets the flag (R-ACC-76).
-
D3 and D4 (M1-05) · Brands, models, pricing groups, charge types and lead sources change only through the security-definer functions below; authenticated holds select only on those five tables (tools/db/gen_rls.py).
-
D10 and D30 (M1-05) · Nine new keys,
master_data.*, listed under Interface. -
D11 and D19 (M1-05) ·
0100_foundation,0300_master_data,0900_views_audit,1100_rlsand1500_migration_master_vehiclesare edited in place; the functions are in20261006002600_master_data_core.sql, proven by70_master_data_core.test.sql, with20,21,46,50,55,58and61updated. -
D27 (M1-05) · Every description in
70_master_data_core.test.sqlstarts with its R-MD ID. -
D29 and D52 (M1-05) · Each call is one transaction and writes one audit row on the row it changes; vehicle_brands, vehicle_models and lead_sources are now watched (R-MD-33). A retire or restore that changes nothing writes none.
-
D57 (M1-05) ·
charge_types.default_due_dayschanges only through set_charge_type_due_days(), with payment:approve, system rows included (R-MD-16, R-MD-23). -
D65 and D76 (M1-05) · The v1 copy maps each of v1's 23 types to a service type through value_map; transmisi manual is manual and matic automatic (zuki, 2026-11-17; R-MD-19).
-
D103 (draft, M1-05) ·
public.service_typeis regular, comfort, luxe, prestige; vehicle_models.default_service_type takes it (R-MD-20). -
D3 and D4 (M1-06) · Legal entities, pools, company bank accounts, contract templates, organization settings and pool settings change only through the security-definer functions below; authenticated holds select only on those six tables (tools/db/gen_rls.py).
-
D10 and D30 (M1-06) · Eight new keys, five
master_data.*and threesettings.*, listed under Interface. -
D11 and D19 (M1-06) ·
0100_foundation,0200_tenancy_access,0900_views_auditand1100_rlsare edited in place; the functions are in20261006002700_master_data_entities.sql, proven by71_master_data_entities.test.sql, with20,21and69updated. -
D27 (M1-06) · Every description in
71_master_data_entities.test.sqlstarts with its R-TEN, R-MD or R-SET ID. -
D33 (M1-06) ·
pnpm db:typesis run and committed with the migration. -
D52 (M1-06) · Each call is one transaction and writes one audit row on the row it changes; a call that changes nothing writes none. contract_templates is now watched (R-AUD-01).
-
D40 (M1-06) · A legal entity's and a pool's code is set once, as numbers already issued carry it: no function takes a new code, and a pool keeps its timezone (R-TEN-19, R-TEN-21).
-
D65 (M1-06) · No app user deletes these rows; a legal entity, pool, bank account or template is retired and restored (R-TEN-23, R-TEN-24, R-MD-43, R-MD-44).
-
D67 (M1-06) · A pool is not retired while a rental of it is live, pending to returned (R-TEN-25).
-
D43, D66, D71 and D95 (M1-06) · set_organization_settings() and set_pool_settings() write the settings these decisions name: max_queue_miss (D43), max_repossessions (D66), cp_skip_weeks_limit (D71) and notification_escalation_hours (D95).
-
D3 and D4 (M1-07) · Garages, insurers, partner garages, rental companies, checklist items and body panels change only through the security-definer functions below; authenticated holds select only on those six tables (R-MD-52, tools/db/gen_rls.py). A partner garage's insurer and garage are its own organization's, by composite foreign keys (R-MD-63).
-
D10 and D30 (M1-07) · Two new keys,
master_data.pair_takenandmaster_data.phone_invalid; the others are M1-05's. All are listed under Interface. -
D11 and D19 (M1-07) ·
0100_foundation,0300_master_data,0900_views_audit,1100_rlsand2600_master_data_coreare edited in place; the functions are in20261006002800_master_data_operational.sql, proven by72_master_data_operational.test.sql, with20,21and46updated. -
D27 (M1-07) · Every description in
72_master_data_operational.test.sqlstarts with its R-MD ID. -
D29 (M1-07) · Checklist items and body panels keep an optional
name_en; garages, insurers and rental companies have one name (R-MD-72). apps/web labels the enums (R-MD-79). -
D33 (M1-07) ·
pnpm db:typesis run and committed with the migration. -
D52 (M1-07) · Each call is one transaction and writes one audit row on the row it changes; a call that changes nothing writes none. The six tables are now watched (R-MD-74).
-
D65 (M1-07) · No app user deletes these rows; they are retired and restored (R-MD-53, R-MD-57, R-MD-58), and retiring never cascades (R-MD-59).
-
D99 and D100 (M1-07) · A rental company is written only by a holder of payment:approve with the all-companies flag (R-MD-55, R-MD-56); a member without the flag reads only their own (R-MD-75). caller_all_rental_companies() tells apps/web whether the caller has the flag (R-MD-76).
-
D77 and D81 (M1-07) · Built in the team session on #460, through a pull request into integration.
-
D97 (M1-10) · A leader delegates a delegable approval they hold at a pool through a role to a member with a role there, and revokes it, only through delegate_permission() and revoke_delegation() (R-ACC-234 to R-ACC-242, R-ACC-247 to R-ACC-253). set_override() refuses a live delegation and replaces one past its end (R-ACC-260, R-ACC-261). pool_delegations(), delegable_permissions() and delegation_candidates() tell apps/web what to show and offer, so it computes nothing.
-
D3 (M1-10) · Who may delegate, to whom, until when and who may revoke are decided in Postgres; the last day of cover is turned into an end in the pool's time zone there (R-ACC-258).
-
D10 and D30 (M1-10) · Five new keys:
access.cannot_delegate_self,access.not_held_by_role(42501),access.member_no_role_at_pool,access.reason_requiredandaccess.ends_at_past; the others are M1-03's. All are listed under Interface. -
D11 and D19 (M1-10) ·
2300_member_overrides_scopeand2400_member_managementare edited in place; the functions are in the new20261006002900_delegations.sql, proven by68_delegation.test.sql. -
D27 (M1-10) · Every description in
68_delegation.test.sqlstarts with its R-ACC ID. -
D33 (M1-10) ·
pnpm db:typesis run and committed with the migration. -
D37 and D48 (M1-10) · delegate_permission() and revoke_delegation() end the member's sessions, not the caller's; a delegation reaching its end ends none.
-
D52 (M1-10) · Each call is one transaction and one audit row on member_permission_overrides.
-
D99 (M1-10) · A caller limited to rental companies delegates to, revokes from and is offered only members within their set, through app.check_member_in_scope() and app.member_outside() (R-ACC-165, R-ACC-166). The member keeps their own scope: a delegation widens no rental company.
-
D77 and D81 (M1-10) · Built in the team session on #638, through a pull request into integration.
-
D101 and D104 (M1-11) · An email whose login holds no membership in any organization is invited again (R-ACC-92, R-ACC-265); invite_member() and resend_invitation() return the delivery, decided in Postgres by app.invitation_delivery() (R-ACC-287), and accept_invitation() makes the new membership (R-ACC-266 to R-ACC-270).
-
D3 (M1-11) · apps/web only sends Auth's invite or sign-in link as the delivery says; acceptance and its recheck (app.settle_invitation(), shared with the trigger app.accept_invitation_on_confirm()) are Postgres's.
-
D4 and D11 (M1-11) ·
2100_invitations,0200_tenancy_access,2600_master_data_core,2700_master_data_entitiesand2800_master_data_operationalare edited in place; the sign-in email issupabase/templates/magic_link.html, set in config.toml. -
D10 and D30 (M1-11) · New keys:
invitation.expiredandmaster_data.field_required(P0001), andinvitation.grant_not_heldandinvitation.scope_not_held, which accept_invitation() returns invoid_reasonand never raises. -
D19 and D27 (M1-11) ·
73_reinvite.test.sqlproves the re-invite rules, and13_tenancy_access,62_invitationsand70to72the carry-overs, every description starting with its rule's ID. -
D33 (M1-11) ·
pnpm db:typesis run and committed with the migrations. -
D37 and D48 (M1-11) · Accepting a re-invitation ends no session (R-ACC-98).
-
D50 and D51 (M1-11) · No login is made for a re-invited email: Auth's sign-in link, with
shouldCreateUser: false, lasts 24 hours as the invite does (R-ACC-273). -
D52 (M1-11) · Acceptance is one transaction: the membership, role and rental-company links, or the void.
-
D98 and D99 (M1-11) · Acceptance rechecks the sender's grants and rental companies as before; a failed recheck voids with
grant_not_heldorscope_not_held. -
D77 and D81 (M1-11) · Built in the team session on #650, through a pull request into integration.
-
D101 and D104 (#693) · accept_invitation() and restore_invitation() refuse with
invitation.login_existsa login that holds a membership in another organization; the invitation stays pending (R-ACC-275 to R-ACC-277). Only a confirmed email accepts (R-ACC-278). -
D3 and D10 (#693) · A person sets their own name only through set_my_full_name(), refused with
profile.not_signed_in,profile.name_requiredorprofile.name_too_long(R-ACC-284, R-ACC-285); my_delegations() lists the caller's own delegations and raises nothing (R-ACC-281). -
D97 (#693) · my_delegations() shows a delegation's giver, reason and last day in the pool's time zone, live and ended, as pool_delegations() does.
-
D11, D19 and D27 (#693) ·
0100_foundation,0200_tenancy_access,2100_invitations,2400_member_managementand2900_delegationsare edited in place, proven by13_tenancy_access,66_invitation_revoke_restore,68_delegationand73_reinvite, every description starting with its rule's ID. -
D33 (#693) ·
pnpm db:typesis run and committed with the migrations. -
D77 and D81 (#693) · Built in the team session on #693, through a pull request into integration.
-
D101 and D104 (#694) · Pulihkan never makes a membership: restore_invitation() puts a voided invitation back to pending for 24 hours with the caller as inviter, for a confirmed login too, and accept_invitation() makes the membership (R-ACC-286, R-ACC-277). It returns the delivery, decided by app.invitation_delivery() (R-ACC-287).
-
D3 and D10 (#694) · The refusals and their order are in Postgres:
invitation.not_voided,invitation.already_member,invitation.login_exists,invitation.already_pending, theninvitation.login_existsfor another organization's pending invitation (R-ACC-286, R-ACC-220). -
D37 and D48 (#694) · Restoring ends no session (R-ACC-215).
-
D52 (#694) · A restore is one transaction and one activity-log entry, and the audit log keeps that it was voided (R-ACC-221).
-
D98 (#694) · Acceptance rechecks the one who restored, who is now
invited_by, andgranted_byis theirs. -
D11, D19 and D27 (#694) ·
2100_invitationsand2400_member_managementare edited in place, proven by66_invitation_revoke_restoreand73_reinvite;51_migration_accesstest 30 counts only the target organization, so it passes after create-e2e-users.mjs (R-ACC-232). Every description starts with its rule's ID. -
D33 (#694) ·
pnpm db:typesis run and committed with the migrations (the return type changed). -
D77 and D81 (#694) · Built in the team session on #694, through a pull request into integration.
Interface
Section titled “Interface”M1-01 (#454), answered to FE in the team session on 2026-11-10. Status: built and tested on the local stack (pgTAP); not yet run by zuki.
public.invite_member(email text, pool_id uuid, role_id uuid)· RPC for authenticated users. Records a pending invitation and returns itsinvitationsrow (id,organization_id,email,pool_id,role_id,invited_by,status,void_reason,expires_at,accepted_at,created_at,updated_at). The email is stored trimmed and in lower case. It makes no login, membership or role (R-ACC-93). Checks in order, each with its key:invitation.not_allowed(42501; pool_id),invitation.role_not_at_pool(P0001; role_id, pool_id: a role of another organization or an inactive pool),access.grant_not_held(42501; pool_id, permission_codes),invitation.email_invalid(P0001; email),invitation.already_pending(P0001; invitation_id, of the pending one in the inviter's organization, for Kirim ulang),invitation.login_exists(P0001; email: a login, or a pending invitation in another organization, whose id is never returned; R-ACC-102). No session:profile.not_signed_in(42501). One email has at most one pending invitation across all organizations.public.resend_invitation(invitation_id uuid)· RPC. Moves a pending invitation's expiry to 24 hours from now, makes the caller its inviter and returns the row (itsemailis what Auth needs). Keys, in order:invitation.not_found(P0001; invitation_id: not readable with user:read at its pool),invitation.not_allowed(42501; pool_id),access.grant_not_held(42501; pool_id, permission_codes),invitation.not_pending(P0001; invitation_id, status: accepted or voided). An expired invitation is still pending.public.invitable_roles()· RPC with no arguments. Returnspool_id,pool_code,pool_name,role_id,role_code,role_name: every active pool where the caller holds user:write, with each role of its organization whose permissions the caller all holds there (R-ACC-90, R-ACC-91). The dialog filters it by pool.public.invitations· read with user:read at the invitation's pool (R-ACC-99); nobody writes it from the API: only the two RPCs and the acceptance trigger do. An expired invitation ispendingwithexpires_atpast.- Sending (D98) · after either RPC succeeds, apps/web's server-only module calls
auth.admin.inviteUserByEmail(email, { redirectTo })for a new invitation and for a resend alike. Auth refuses withemail_existsonly when the login is confirmed; for an invited login that hasn't opened its link it sends the invite again (read in Auth's source; fresh-token check pending, see below). No metadata is needed: the database matches the invitation by email. A failed send needs no call: the invitation stays pending and Kirim ulang sends it again. - Accepting (R-ACC-96 to R-ACC-98) · when the link is verified (
verifyOtp({ type: 'invite', token_hash })on /auth/confirm), Auth sets the login'semail_confirmed_at; a trigger then makes the membership and the role, or voids the invitation (void_reasongrant_not_held). It never raises and ends no session. A voided invitee has no membership, so lands on /no-access. - First password (R-ACC-100) · FE's option (b): apps/web sets
data: { invited: true }at invite time andupdateUser({ password, data: { password_set: true } })on /welcome, and proxy.ts reads both from the session's user metadata. Nothing in the database; a v1 login (R-ACC-59) has noinvitedflag, so it is never caught. - Email template ·
supabase/templates/invite.html(Indonesian only), linking to{{ .SiteURL }}/auth/confirm?token_hash={{ .TokenHash }}&type=invite; resends use the same template./auth/confirmand/welcomeare inadditional_redirect_urlslocally; each hosted project needs the same template, subject, URLs andotp_expiryset by hand: BE-M1-01 (L0). - E2E · the E2E super_admin holds every permission at E2A and E2B, so every role is invitable there. Mail is read from the local mail catcher (Mailpit, port 54324).
- R-ACC-93 in a journey · an invitee's login with no membership isn't visible to the inviter:
profileshas no email column, and its policy shows a profile only to the profile itself or to someone with user:read in one of its organizations, which it doesn't have yet.membershipsreturns nothing for it. pgTAP proves R-ACC-93; a journey can check that the inviter'sinvitationsrow is pending and Mailpit has the email. Answered to FE 2026-11-10. - Email rate limit · local Auth doesn't apply
[auth.rate_limit] email_sentto admin invites: config.toml says it needsauth.email.smtp, which is off, and 9 admin invites plus a repeat to the same unconfirmed login all returned 200 and reached Mailpit (BE, 2026-11-10). Hosted projects send through Supabase's mail unless SMTP is set, which has its own hourly limit; that is for the L0 run, not the journeys. - Types ·
pnpm db:typeshas run:invitation_statusand the seveninvitation.*keys are inConstants, and the three RPCs inDatabase["public"]["Functions"]. - Open · that a second admin invite to an unconfirmed login issues a fresh token (so the first link fails) is not yet proved locally; FE's journey that resends and opens both links proves it.
M1-02 (#455), answered to FE in the team session on 2026-11-12. Status: built and tested on the local stack (pgTAP); not yet run by zuki.
public.grant_role(membership_id uuid, pool_id uuid, role_id uuid)· RPC for authenticated users. Gives the member the role at the pool and returns the newmember_rolesrow (id,organization_id,membership_id,role_id,pool_id,granted_by= the caller,granted_at,created_at,updated_at). Keys in check order (R-ACC-108):access.member_not_found(P0001; membership_id: none, or in an organization where the caller holds no user:read),access.not_allowed(42501; pool_id: no user:write there),access.role_not_at_pool(P0001; role_id, pool_id: role or pool not of the member's organization, or the pool inactive),access.member_not_active(P0001; membership_id: suspended),access.role_already_held(P0001; membership_id, role_id, pool_id),access.grant_not_held(42501; pool_id, permission_codes). No session:profile.not_signed_in(42501). The duplicate-grant key isaccess.role_already_held, notmember_role.already_held.public.revoke_role(membership_id uuid, pool_id uuid, role_id uuid)· RPC; returns nothing (void). Keys in check order (R-ACC-109):access.member_not_found,access.not_allowed,access.member_not_active,access.role_not_held(P0001; membership_id, role_id, pool_id; also for a role of another organization),access.grant_not_held(42501; pool_id, permission_codes; R-ACC-111), thenaccess.last_user_manager(42501; organization_id; R-ACC-40). A role at an inactive pool can be revoked.- Both end the member's sessions (R-ACC-08), the caller's own included, so after a change to your own roles the next request lands on /login (R-ACC-48). A refused call changes nothing, ends no session and writes no audit row.
public.pool_members(pool_id uuid)· RPC; rows ofmembership_id uuid,profile_id uuid,full_name text,email text(the login's, R-ACC-122),status membership_status(activeorsuspended),roles jsonb. One row for every membership of the pool's organization (R-ACC-118), ordered by full_name, then email.rolesis an array, ordered by role_name, of{member_role_id, role_id, role_code, role_name, can_revoke}for the roles held at that pool only;[]when none.can_revokeis true when the member is active and the caller holds user:write and every permission of the role at the pool (R-ACC-110, R-ACC-111, R-ACC-115); the last user manager (R-ACC-40) is left to the call. Without user:read at the pool it returns no rows and raises nothing.- Grants offered (R-ACC-121) · unchanged:
public.invitable_roles(), no arguments, returnspool_id,pool_code,pool_name,role_id,role_code,role_name; filter it bypool_idand drop the role_ids the member holds there. - The caller's own row (R-ACC-123) · the row whose
profile_idis the signed-in user's id (auth.uid(), the session user'sid). No extra column. member_roles· read under user:read as before (R-ACC-16); insert, update and delete from the API are refused with 42501 (R-ACC-107). The secret key (service_role) still writes it, sotools/db/create-e2e-users.mjsis unchanged. Memberships are unchanged: a super_admin'supdate memberships set statusthrough the API still works (R-ACC-17) and ends that member's sessions (R-ACC-52).- E2E · the E2E viewer holds no
gate:approve; the system role checker holds it, and the E2E super_admin may give checker at E2A (it holds every permission there, so checker is ininvitable_roles()). Granting the viewer checker at E2A ends the viewer's sessions. A suspended viewer givesaccess.member_not_active. - Types ·
pnpm db:typeshas run: the three functions are inDatabase["public"]["Functions"]and the six newaccess.*keys inConstants.
M1-03 (#456), answered to FE in the team session on 2026-11-12. Status: built and tested on the local stack (pgTAP); not yet run by zuki. P0001 is a refusal, 42501 a denial.
public.set_override(membership_id uuid, pool_id uuid, permission_code text, effect override_effect, reason text default null)· RPC for authenticated users. Gives an active member a grant or a deny of one permission at one pool, or switches the effect of the override they have there, and returns themember_permission_overridesrow (granted_by= the caller). The reason is trimmed; a blank one is saved as null. Keys in check order:access.member_not_found(P0001; membership_id),access.not_allowed(42501; pool_id: no user:write there),access.permission_not_found(P0001; permission_code),access.pool_not_available(P0001; pool_id: inactive or of another organization),access.member_not_active(P0001; membership_id),access.override_already_set(P0001; membership_id, permission_code, pool_id: the same effect is already there),access.grant_not_held(42501; pool_id, permission_codes: a grant or a deny of a permission the caller lacks at the pool, R-ACC-50), thenaccess.last_user_manager(42501; organization_id; R-ACC-40). No session:profile.not_signed_in(42501).public.clear_override(membership_id uuid, pool_id uuid, permission_code text)· RPC; returns nothing (void). Removes the override, whichever its effect. Keys in check order:access.member_not_found,access.not_allowed,access.member_not_active,access.override_not_held(P0001; membership_id, permission_code, pool_id),access.grant_not_held, thenaccess.last_user_manager. An override at an inactive pool can be cleared.- Both end the member's sessions (R-ACC-08), the caller's own included. A refused call changes nothing and ends no session.
public.set_company_scope(membership_id uuid, rental_company_ids uuid[])· RPC; returns nothing (void). Replaces the member's rental companies with the set given;{}lifts the limit; an id given twice counts once. Keys in check order:access.rental_companies_required(P0001; membership_id: a null set, checked first),access.member_not_found(P0001),access.not_allowed(42501; organization_id, pool_ids: the active pools where the caller lacks user:write,[]when the organization has no active pool),access.member_not_active(P0001),access.scope_limit_required(42501; membership_id:{}from a caller with rental companies of their own, R-ACC-150),access.rental_company_not_found(P0001; rental_company_id: not of the member's organization),access.rental_company_not_held(42501; organization_id, rental_company_ids: for a caller with rental companies of their own, first the member's links outside the caller's set, by name, R-ACC-152; else the ids in the set outside it, in the order given, R-ACC-149),access.rental_company_not_active(P0001; rental_company_id: a new link to an inactive company; a link already held stays). A caller's own set is their links through their active membership in the member's organization, inactive companies included; it applies to their own membership too. A caller with none is not held to anything more. Ends no session (R-ACC-140). (#616, 2026-11-12)public.pool_members(pool_id uuid)· as in M1-02, plus two columns:overrides jsonb, by permission_code, of{override_id, permission_code, effect, reason, can_clear}for the overrides held at that pool, andrental_companies jsonb, by name, of{rental_company_id, name, status}for every company the member is linked to, inactive ones included;[]when none; andcan_set_scope boolean: true when the member is active, the caller has user:write at every active pool of the organization, and, for a caller with rental companies of their own, the member has at least one rental company and none outside them (R-ACC-153; #616).can_clearis true when the member is active and the caller holds user:write and the permission at the pool; the last user manager is left to the call.public.overridable_permissions(pool_id uuid)· RPC; rows ofpermission_code text, by code: the codes the caller holds at the pool, after denies, which are what set_override() accepts there. No rows without user:write at the pool.public.scope_companies(pool_id uuid)· RPC; rows ofrental_company_id uuid,name text, by name: the active rental companies of the pool's organization, or, for a caller with rental companies of their own there, only their own active ones (R-ACC-143; #616). No rows without user:read at the pool.public.caller_company_scoped(pool_id uuid)· RPC; boolean: whether the caller has rental companies of their own in the pool's organization, inactive ones included, so the tab offers no empty set (R-ACC-151); false without user:read at the pool. can_set_company_scope() is unchanged and stays true for such a caller. (#616)public.can_set_company_scope(pool_id uuid)· RPC; boolean: whether set_company_scope() would pass its user:write check in the pool's organization; false when it has no active pool.member_permission_overridesandmember_rental_companies· read under user:read as before; insert, update and delete from the API are refused with 42501 (R-ACC-124, R-ACC-134). The secret key still writes them.- Types ·
pnpm db:typeshas run: the seven functions and the newpool_memberscolumns are inDatabase["public"]["Functions"], the nine newaccess.*keys inConstants(#616 added caller_company_scoped, can_set_scope and two keys).
#616 round 2 (scoped inviter and hands-off, #456), accepted by FE in the team session on 2026-11-12. Status: built and tested on the local stack (pgTAP); not yet run by zuki. A caller's own set is as for set_company_scope(): their links through their active membership in the organization, inactive companies included; a caller with none is unscoped.
public.invitable_roles()· as in M1-01, pluscompany_scoped boolean(the caller has rental companies of their own in the pool's organization) andrental_companies jsonb, by name, of{rental_company_id, name}: the caller's own active companies there;[]when unscoped (R-ACC-163). Read here rather than from scope_companies(), since an inviter may hold user:write without user:read.public.invite_member(email text, pool_id uuid, role_id uuid, rental_company_ids uuid[] default '{}')· as in M1-01, plus the set the invitee will be limited to; an id given twice counts once. Keys in check order (R-ACC-154):profile.not_signed_in,invitation.not_allowed,invitation.role_not_at_pool,access.grant_not_held, thenaccess.rental_companies_required(P0001; pool_id: a null set),access.scope_limit_required(42501; pool_id:{}from a scoped inviter, R-ACC-156),invitation.rental_companies_not_allowed(P0001; pool_id: a non-empty set from an unscoped inviter, R-ACC-160),access.rental_company_not_found(P0001; rental_company_id: the first not of the pool's organization, R-ACC-157),access.rental_company_not_held(42501; organization_id, rental_company_ids: those outside the inviter's set, in the order given, R-ACC-158),access.rental_company_not_active(P0001; rental_company_id, R-ACC-159), theninvitation.email_invalid,invitation.already_pendingandinvitation.login_existsas before.public.invitation_rental_companies·invitation_id,rental_company_id,organization_id,created_at; composite foreign keys keep both in the invitation's organization; deleting the invitation deletes its rows, and a company named by one can't be deleted. Read with user:read at the invitation's pool (R-ACC-164); written only by invite_member().public.resend_invitation(invitation_id uuid)· takes no set and keeps the stored one. Afteraccess.grant_not_heldand beforeinvitation.not_pending, a scoped resender is refusedaccess.scope_limit_required(42501; pool_id) for an invitation with no companies, oraccess.rental_company_not_held(42501; organization_id, rental_company_ids: the stored ones outside their set, by name); an unscoped resender passes (R-ACC-161).- Accepting (R-ACC-155, R-ACC-162) · after the grant check, the invitation is voided with
void_reasonscope_not_heldwhen whoever last sent it is now scoped and their set doesn't cover its companies (or it has none); otherwise the new member is linked to every stored company, inactive ones included. It still never raises. public.pool_members(pool_id uuid)· as in M1-03, plusoutside_scope booleanandcan_grant boolean(R-ACC-167, R-ACC-168).outside_scopeis true when the caller is scoped and the member is not within their set: a link outside it, or no rental companies at all.can_grant, for adding a role or an override, is true when the member is active, the caller holds user:write at the pool andoutside_scopeis false.can_revokeandcan_clearare false whenoutside_scopeis true;can_set_scopeis false too (zuki, 2026-11-13: set_company_scope() refuses a scoped caller a member with no rental companies withaccess.rental_company_not_heldandrental_company_ids[], R-ACC-152). Status: built.- Hands-off (R-ACC-165, R-ACC-166) ·
access.member_outside_scope(42501; membership_id, rental_company_ids: the member's links outside the caller's set, by name;[]when the member has no rental companies) is raised right afteraccess.member_not_activein grant_role(), revoke_role(), set_override() and clear_override(). set_company_scope() keeps its own keys. - Types ·
pnpm db:typeshas run: the new columns and therental_company_idsargument are inDatabase["public"]["Functions"],invitation_rental_companiesinTables, and the two new keys inConstants.
D99 and D100 (all rental companies by flag, #621), answered to FE in the team session on 2026-11-13. Status: built and tested on the local stack (pgTAP); not yet run by zuki. Scoped now means the caller's active membership in the organization has no flag, with a list or an empty one; a caller with the flag is unscoped.
memberships.all_rental_companies boolean· true for a new membership. A member with the flag has nomember_rental_companiesrows (a trigger refuses one); a member without it sees only their list's cars, none with an empty list, and the operator's own company TOP only when TOP is on their list.public.pool_members(pool_id uuid)· as in #616 round 2, plusall_rental_companies boolean;rental_companiesis[]for a member with the flag. For a scoped caller, a member with the flag is outside (outside_scopetrue;can_set_scope,can_grant, everycan_revokeandcan_clearfalse) and a member with an empty list is within.public.set_all_rental_companies(membership_id uuid)· RPC; returns nothing (void). Sets the flag and removes the member's list, in one transaction; on a member with the flag already it changes nothing. Keys in check order:profile.not_signed_in,access.member_not_found(P0001),access.not_allowed(42501; organization_id, pool_ids),access.member_not_active(P0001),access.scope_limit_required(42501; membership_id: a scoped caller, before the no-op). Ends no session.public.set_company_scope(membership_id uuid, rental_company_ids uuid[])· as in #616, but saving clears the flag,{}saves an empty list (no cars) for every caller, andaccess.scope_limit_requiredis no longer raised here. A scoped caller on a member with the flag getsaccess.rental_company_not_heldwithrental_company_ids[].public.scope_companies(pool_id uuid)· unchanged in shape; a scoped caller with an empty list gets no rows.public.caller_company_scoped(pool_id uuid)· true when the caller has no flag, an empty list included.public.invite_member(...)· unchanged in shape. An unscoped inviter sends{}and the invitation gives the flag; a scoped inviter may send{}(D100).invitationsgainsall_rental_companies boolean.invitable_roles().company_scopedmeans no flag. A scoped resender of an invitation with the flag getsaccess.scope_limit_required; acceptance voids it (scope_not_held) when its last sender is now scoped.- E2E · fixtures give the viewer and the checker the flag with
set_all_rental_companies()as the super_admin, in place ofset_company_scope('{}'). membershipsfrom the API · no insert, and update only ofstatus(R-ACC-17, R-ACC-52); delete unchanged (R-ACC-37). A refused write is Postgres's insufficient_privilege (42501), no key: apps/web never writes memberships directly (D3).- A link to a membership with the flag is refused by a trigger with
access.rental_companies_with_flag(P0001; membership_id), a new key no screen reaches: only the functions and the secret key write links. - R-ACC-156 · invite_member() takes no flag argument: an invitation from an inviter without the flag, an empty list included, has
all_rental_companiesfalse.
M1-04 (suspend, reinstate and remove a member; revoke and restore an invitation, #457, #599), accepted by the lead in the team session on 2026-11-13. Status: built and tested on the local stack (pgTAP), tasks #8, #9 and #10 on 2026-11-13; not yet run by zuki. P0001 is a refusal, 42501 a denial. "Every active pool" is as for set_company_scope(): an organization with no active pool refuses every call, with pool_ids [].
public.suspend_member(membership_id uuid)· RPC for authenticated users; returns nothing (void). Sets an active member to suspended and ends their sessions (R-ACC-52); roles, overrides and rental companies stay. Keys in check order (R-ACC-187):profile.not_signed_in(42501),access.member_not_found(P0001; membership_id: none, or in an organization where the caller holds no user:read, R-ACC-202),access.not_allowed(42501; organization_id, pool_ids: the active pools where the caller lacks user:write, R-ACC-190),access.cannot_change_self(P0001; membership_id, R-ACC-193),access.member_not_active(P0001; membership_id: already suspended, R-ACC-194),access.member_outside_scope(42501; membership_id, rental_company_ids, R-ACC-192),access.grant_not_held(42501; pool_id, permission_codes: the first active pool by name where the member holds a permission the caller lacks, R-ACC-191).public.reinstate_member(membership_id uuid)· RPC; returns nothing (void). Sets a suspended member back to active and ends no session (R-ACC-188). Keys as suspend_member(), in the same order, withaccess.member_already_active(P0001; membership_id, R-ACC-200) in place ofaccess.member_not_active.public.remove_member(membership_id uuid)· RPC; returns nothing (void). Deletes the membership with its roles, overrides and rental-company links; the profile stays (R-ACC-189, R-ACC-38); the person's sessions end (R-ACC-53). Active or suspended alike. Keys in check order:profile.not_signed_in,access.member_not_found,access.not_allowed(42501; organization_id, pool_ids: the active pools where the caller lacks user:delete, R-ACC-37),access.cannot_change_self,access.member_outside_scope,access.grant_not_held.- For the three · R-ACC-191 compares the member's permissions at each active pool (roles, plus grant overrides, minus denies, counted as if the membership were active) with the caller's there; a permission held only at a closed pool doesn't count. Each call is one transaction and one entry in the activity log (R-ACC-205).
access.last_user_managercan't be reached through them (R-ACC-40); its trigger stays for the operator's writes. membershipsfrom the API · no insert, update or delete for authenticated (R-ACC-174): Postgres's insufficient_privilege (42501), no key. This replaces M1-03's "update only of status". The secret key and acceptance still write it.public.pool_members(pool_id uuid)· as in D99 and D100, plusjoined_at timestamptz(the membership's created_at; for a v1 login its v1 account's creation date, as loaded, R-ACC-201),can_suspend,can_reinstateandcan_remove boolean(R-ACC-198): each true only when the member's status fits (active for suspend, suspended for reinstate, either for remove) and R-ACC-190 (user:write) or R-ACC-37 (user:delete), R-ACC-192 and R-ACC-191 pass; all three false on the caller's own row (R-ACC-199). The four columns come aftercan_grant, in this order. The filters (R-ACC-195 to R-ACC-197) are apps/web's, over these rows.- Roles for the filter (R-ACC-195) · no RPC: read
public.rolesthrough PostgREST (user:read, R-ACC-16), filtered by the pool'sorganization_id; itsidmatchespool_members().roles[].role_id. public.member_detail(membership_id uuid)· RPC; one row or none (missing, or in an organization where the caller holds no user:read: apps/web shows the not-found page, R-ACC-201). Columns:membership_id,profile_id,full_name,email,status,joined_at,all_rental_companies,rental_companies jsonb(by name,{rental_company_id, name, status};[]with the flag),roles jsonb: by pool name,{pool_id, pool_code, pool_name, roles: [{role_id, role_code, role_name}]}by role name, only at pools where the caller holds user:read and the member holds a role;[]when none it can see.public.invitation_void_reason· a new enum,grant_not_held,scope_not_held,revoked, replacing the text check oninvitations.void_reason. apps/web labels it per language (D29, R-ACC-204).public.pool_invitations(pool_id uuid)· RPC; the pool's pending and voided invitations, bylast_sent_atdescending (R-ACC-204). Columns:invitation_id,email,role_id,role_name,invited_by,invited_by_name,last_sent_at(=expires_at− 24 hours),expires_at,status,void_reason,all_rental_companies,rental_companies jsonb(by name,{rental_company_id, name, status}),can_resend,can_revoke,can_restore(R-ACC-216).can_resend: pending and resend_invitation()'s checks pass.can_revoke: pending, user:write at the pool, the role's grants and the scope checks pass.can_restore: voided, user:write, the role and pool still valid, the grants and the scope checks pass; the state checks (already a member, already pending) are left to the call. No rows without user:read at the pool.emailis text; a pending invitation pastexpires_atstayspending(apps/web shows Kedaluwarsa); rows with the samelast_sent_atfollow by email.public.revoke_invitation(invitation_id uuid)· RPC; returns nothing (void). Voids a pending invitation, expired or not, withvoid_reasonrevoked; sends nothing and ends no session (R-ACC-207). Keys in check order:profile.not_signed_in,invitation.not_found(P0001; invitation_id, R-ACC-99),invitation.not_allowed(42501; pool_id, R-ACC-208),access.grant_not_held(42501; pool_id, permission_codes, R-ACC-219),access.scope_limit_required(42501; pool_id: an invitation with the flag, from a caller without it),access.rental_company_not_held(42501; organization_id, rental_company_ids by name, R-ACC-210),invitation.not_pending(P0001; invitation_id, status, R-ACC-209).public.restore_invitation(invitation_id uuid)· replaced in #694: see FE-694-1 below (R-ACC-286, R-ACC-287). The M1-04 at-once restore for a confirmed login is gone.- Both invitation calls are one transaction and one entry in the activity log (R-ACC-221).
- New keys ·
access.cannot_change_self,access.member_already_active,invitation.not_voided,invitation.already_member(invitation.already_pendingexists). - E2E · the E2E super_admin holds user:write and user:delete at E2A and E2B, the E2E organization's only pools, so every row action is offered there;
67_member_reads.test.sqlproves it on seed.sql, through pool_members(). - Types ·
pnpm db:typesruns with the build.
Requests from FE, 2026-10-02:
- FE-R5 ·
profiles.locale(D7), and a way for any signed-in user to set their own locale, such as an RPC that sets the caller's locale. Profile updates needuser:writetoday, which most roles lack. Needed by FE pack D (timeline row 28). Status: answered 2026-10-05; see M0.
BE answer, 2026-10-05:
- FE-R5 · Moved into M0 by D25: pack B's BE-M0-13 builds
profiles.localeandpublic.set_my_locale(); M0's Interface describes both. Status: written; runs with pack B.
M1 carry-overs (#637), answered to FE in the team session on 2026-11-16. Status: assert_first_password() and the fixture built and tested on the local stack (pgTAP, 2026-11-16); #600's config not yet built; not yet run by zuki.
public.assert_first_password()· RPC for authenticated users, no arguments, returns nothing. /welcome calls it right before Auth's updateUser({ password }) (R-ACC-245, #603). Keys, in order:profile.not_signed_in(42501),auth.password_already_set(P0001, no detail) when the signed-in login already has a password (auth.users.encrypted_passwordnot empty). There is no sign-up (D50), so a login without a password is always an invitee, and a voided one passes (R-ACC-106).- Expired invitation fixture (#634) ·
pnpm db:e2e-users(tools/db/create-e2e-users.mjs) keeps a pending invitation in the E2E organization at E2A forexpired@example.test, role checker, sent by the E2E super_admin, withexpires_atin the past. pool_invitations() lists it as expired with can_resend and can_revoke true for that super_admin (R-ACC-204, R-ACC-216). Journeys never press its actions. It carries the flag, as its sender has it, andexpires_atis set to a day before each run. The secret key now holds insert and update oninvitationsfor it (tools/db/gen_rls.py); authenticated still holds select only. - Invite link (#600) · supabase/templates/invite.html builds the link from
{{ .RedirectTo }}, so apps/web passes the bare origin as redirectTo; Auth falls back to the site URL for an origin it doesn't allow.
M1-05 master data core (#458), answered to FE in the team session on 2026-11-17 (request: .team/458/fe-interface-request.md). Status: built and tested on the local stack (pgTAP, 2026-11-17); pnpm db:types run; the transmisi mapping built (R-MD-19); not yet run by zuki.
- Reads · plain selects under the user's session, as requested; no views. vehicle_brands (
id,name,country,is_active), vehicle_models (id,brand_id,pricing_group_id,name,vehicle_class,body_type,powertrain,tyre_size,transmission,default_service_type,is_active; embed the brand and pricing group through the FKs), pricing_groups (id,name,driver_daily_rate,admin_fee,is_active; master_data:read only, R-MD-12), charge_types (id,code,name,name_en,is_system,default_amount,default_due_days,needs_rental,sort_order,is_active), lead_sources (id,code,name,name_en,channel,needs_note,is_system,sort_order,is_active). Pickers filteris_active = truethemselves (R-MD-30). authenticated has no insert, update or delete on these tables. - Writes · RPCs for authenticated users, security definer,
search_path = '', revoked from public and anon. Each add takes the organization explicitly (a model takes it from its brand) and returns the new row's id; each change is a full replace and returns nothing. Names are trimmed; a blankname_enis stored as null.public.add_vehicle_brand(organization_id uuid, name text, country text default null) returns uuid·public.change_vehicle_brand(brand_id uuid, name text, country text).public.add_vehicle_model(brand_id uuid, name text, pricing_group_id uuid default null, vehicle_class public.vehicle_class default 'car', body_type text default null, powertrain public.powertrain default 'ice', tyre_size text default null, transmission public.transmission default null, default_service_type public.service_type default null) returns uuid·public.change_vehicle_model(model_id uuid, brand_id uuid, name text, pricing_group_id uuid, vehicle_class public.vehicle_class, body_type text, powertrain public.powertrain, tyre_size text, transmission public.transmission, default_service_type public.service_type). The brand can change (R-MD-29); every field is editable, vehicle_class included.public.add_pricing_group(organization_id uuid, name text, driver_daily_rate bigint, admin_fee bigint) returns uuid·public.change_pricing_group(pricing_group_id uuid, name text, driver_daily_rate bigint, admin_fee bigint).public.add_charge_type(organization_id uuid, code text, name text, name_en text default null, default_amount bigint default null, needs_rental bool default false) returns uuid·public.change_charge_type(charge_type_id uuid, name text, name_en text, default_amount bigint, needs_rental bool). No code on change (R-MD-32), no default_due_days, and no sort_order on either: a new row takes the column default, and the order isn't edited in this slice. A negative default_amount is the column check (23514), not a key.public.set_charge_type_due_days(charge_type_id uuid, days int)· needs payment:approve, not master_data:write; works on system copies and retired rows (R-MD-16).public.add_lead_source(organization_id uuid, code text, name text, channel public.lead_channel, name_en text default null, needs_note bool default false) returns uuid·public.change_lead_source(lead_source_id uuid, name text, name_en text, channel public.lead_channel, needs_note bool).public.retire_master_data(kind public.master_data_kind, row_id uuid)·public.restore_master_data(kind public.master_data_kind, row_id uuid). One pair, not one per table:public.master_data_kindisvehicle_brand,vehicle_model,pricing_group,charge_type,lead_source, so the argument stays typed. Retiring a retired row or restoring an active one goes through, changes nothing and writes no audit row (R-MD-26, R-MD-27).
- Keys, checked in this order; detail keys exactly as raised:
master_data.not_found(P0001) ·{id}when the row isn't in the caller's organizations;{field: 'brand_id' | 'pricing_group_id', id}for a model's brand or pricing group from another organization.master_data.not_allowed(42501) ·{organization_id}. master_data:write, or payment:approve for set_charge_type_due_days.master_data.system_row_locked(P0001) ·{id}. A change, retire or restore of an is_system row.master_data.name_required(P0001) ·{field}(R-MD-36), after trimming.master_data.code_invalid(P0001) ·{field: 'code'}; the code must match^[a-z_]+$(R-MD-38).master_data.code_taken(P0001) ·{field: 'code', id, retired}(R-MD-37).master_data.name_taken(P0001) ·{field: 'name', id, retired}(R-MD-31): exact match, the row itself excluded; models are unique by brand and name.master_data.out_of_range(P0001) ·{field, min: 0}for driver_daily_rate, admin_fee and days (R-MD-39).master_data.retired(P0001) ·{field: 'brand_id' | 'pricing_group_id', id}, only when that value is set or changed (R-MD-29).
- Enums to label ·
public.vehicle_class,public.powertrain,public.lead_channel,public.transmission(manual,automatic) andpublic.service_type(regular,comfort,luxe,prestige, D103). - Types ·
pnpm db:typeswas run on 2026-11-17; packages/db-types has the functions and enums.
M1-06 master data entities (#459), answered to FE in the team session on 2026-11-18. Status: built and tested on the local stack (pgTAP, 2026-11-18); pnpm db:types run; not yet run by zuki.
- Reads · plain selects under the user's session; no views. authenticated has no insert, update or delete on these tables.
- legal_entities (
id,organization_id,code,legal_name,address,is_active) and pools (id,organization_id,code,name,city,timezone,address,capacity,opened_on,is_active) · any member of the organization. - company_bank_accounts (
id,organization_id,legal_entity_id,label,bank,account_number,account_name,is_active) · master_data:read or payment:read, so finance and viewer read them through payment:read. - contract_templates (
id,organization_id,legal_entity_id,platform,name,body,version,is_active) · master_data:read. Every version is returned, retired ones included; the editor and pickers filteris_active = truethemselves. At most one version per legal entity and platform is active (unique indexcontract_templates_one_active).public.ride_platformisgrab,gojek. - organization_settings (one row per organization) · any member. pool_settings (one row per pool that has an override; a null column means "use the organization's") · any member of the pool's organization.
- A retired pool stays in my_permissions() and in the pool switcher: neither filters on
is_active. The switcher may mark it frompools.is_active; hiding it is a carry-over, not this slice.
- legal_entities (
- Writes · RPCs for authenticated users, security definer,
search_path = '', revoked from public and anon. Text is trimmed; a blank address is stored as null. Each needs master_data:write in the row's organization.public.add_legal_entity(organization_id uuid, code text, legal_name text, address text default null) returns uuid·public.change_legal_entity(legal_entity_id uuid, legal_name text, address text). No code on change (R-TEN-19).public.add_pool(organization_id uuid, code text, name text, city text, address text default null, capacity int default null, opened_on date default null, timezone text default null) returns uuid·public.change_pool(pool_id uuid, name text, city text, address text, capacity int, opened_on date). A null timezone isAsia/Jakarta; the others allowed areAsia/Pontianak,Asia/Makassar,Asia/Jayapura. No code or timezone on change (R-TEN-21).public.add_company_bank_account(organization_id uuid, legal_entity_id uuid, label text, bank text, account_number text, account_name text) returns uuid·public.change_company_bank_account(account_id uuid, legal_entity_id uuid, label text, bank text, account_number text, account_name text). The legal entity can change; a retired one is refused only when it changes (R-MD-45).public.add_contract_template(organization_id uuid, legal_entity_id uuid, platform public.ride_platform, name text, body text) returns uuid· the new template takes the next version over every version of that legal entity and platform.public.change_contract_template(template_id uuid, name text, body text) returns uuid· retires the version it names and returns the new version's id (R-MD-46); the page moves to that id. An unchanged name and body returns the same id, adds no version and writes no audit row. Only the active version can be changed.public.retire_master_data(kind, row_id)·public.restore_master_data(kind, row_id)take the new kindslegal_entity,pool,company_bank_accountandcontract_template. Retiring a retired row or restoring an active one changes nothing.public.set_organization_settings(organization_id uuid, checkpoint_interval_weeks int, cp_warning_days int, cp_critical_days int, service_interval_km bigint, queue_open bool, queue_opens_at time, queue_closes_at time, max_tickets_per_phone int, max_queue_miss int, overdue_limit_days int, panel_fee bigint, repo_fine bigint, allow_cross_entity_payments bool, allow_cross_pool_operations bool, default_contract_months int, visit_due_days int, require_visit_before_booking bool, notification_escalation_hours jsonb, notification_digest_at time, max_repossessions int, cp_skip_weeks_limit int)· takes the full row: send every setting, the unchanged ones included. A null for a not-null setting is the column's 23502, not a key. An unchanged row writes nothing. notification_escalation_hours is checked by the R-SET-14/R-SET-15 trigger:settings.not_escalating_type/settings.escalation_hours_invalid{type_code}.public.set_pool_settings(pool_id uuid, queue_open bool, queue_opens_at time, queue_closes_at time, max_tickets_per_phone int, checkpoint_interval_weeks int, max_queue_miss int)· takes the full override: a null clears that override, so the pool uses the organization's (R-SET-21). All null on a pool with no row writes nothing.
- Keys, checked in this order for each RPC; detail keys exactly as raised. All are P0001 except not_allowed (42501).
- add_legal_entity ·
master_data.not_allowed{organization_id};master_data.name_required{field: 'legal_name'}, then{field: 'code'};master_data.code_invalid{field: 'code'}(upper-case letters only,^[A-Z]+$, R-TEN-20);master_data.code_taken{field: 'code', id, retired}, retired rows included (R-TEN-22). - change_legal_entity ·
master_data.not_found{id};master_data.not_allowed{organization_id};master_data.name_required{field: 'legal_name'}. - add_pool ·
not_allowed;name_requiredforname,city, thencode;code_invalid;code_taken;master_data.timezone_invalid{field: 'timezone'};master_data.out_of_range{field: 'capacity', min: 0}. - change_pool ·
not_found{id};not_allowed;name_requiredforname, thencity;out_of_rangefor capacity. - add_company_bank_account ·
not_allowed;not_found{field: 'legal_entity_id', id};name_requiredforlabel,bank,account_number, thenaccount_name;master_data.account_taken{id, retired}when another row of the organization holds that bank and number, retired included (R-MD-42);master_data.retired{field: 'legal_entity_id', id}. - change_company_bank_account ·
not_found{id};not_allowed;not_found{field: 'legal_entity_id', id};name_requiredas on add;account_taken;retired{field: 'legal_entity_id', id}, only when the legal entity changes. - add_contract_template ·
not_allowed;not_found{field: 'legal_entity_id', id};name_requiredforname, thenbody;retired{field: 'legal_entity_id', id};master_data.template_active{id}of the active template for that legal entity and platform (R-MD-47). - change_contract_template ·
not_found{id};not_allowed;retired{field: 'id', id}when the version named isn't the active one;name_requiredforname, thenbody. - retire_master_data on a legal entity or pool ·
not_found{id};not_allowed;master_data.last_active{field: 'legal_entities' | 'pools'}when no other active one is left (R-TEN-27);master_data.in_use{reason, count}: a pool withreasonvehicles(home pool, not inactive), thenrentals(pending to returned); a legal entity withcompany_bank_accounts, thencontract_templates, active ones only (R-TEN-25, R-TEN-26). - restore_master_data on an account or template ·
not_found;not_allowed;retired{field: 'legal_entity_id', id}under a retired legal entity (R-MD-45); for a template,template_active{id}when another version is active (R-MD-47). - set_organization_settings ·
master_data.not_allowed{organization_id}, the organization not the caller's or no master_data:write;settings.out_of_range{field, min, max}per setting in parameter order (R-SET-18);settings.warning_after_critical{cp_warning_days, cp_critical_days}when the warning isn't before the critical;settings.queue_hours_invalid{pool_id: null, pool_code: null, queue_opens_at, queue_closes_at}when the organization's own hours open at or after they close, then the same key with the first pool'spool_idandpool_code(by code, retired pools included) whose hours, its override over the new organization's, do; then the trigger keys above. - set_pool_settings ·
settings.pool_not_found{pool_id};master_data.not_allowed{organization_id};settings.out_of_rangefor max_tickets_per_phone, checkpoint_interval_weeks, max_queue_miss (a null skips it);settings.queue_hours_invalid{pool_id, pool_code, queue_opens_at, queue_closes_at}on the pool's effective hours.
- add_legal_entity ·
- Ranges ·
settings.out_of_rangecarriesminandmax. min is 1, except 0 for overdue_limit_days, panel_fee, repo_fine and visit_due_days. max is what the column holds: 32767 for the int2 settings, 2147483647 for service_interval_km, 9223372036854775807 for panel_fee and repo_fine. - Numbers beyond the parameter type · a number above what the parameter's type holds (int 2147483647, bigint 9223372036854775807) is refused by the cast with 22003 before any check, with no key. The form caps every number input at its column's maximum (int2 32767, int 2147483647), so a user never meets 22003.
- Types ·
pnpm db:typeswas run on 2026-11-18; packages/db-types has the functions and the newmaster_data_kindvalues.
M1-07 master data operational (#460), answered to FE in the team session on 2026-11-18. Status: built and tested on the local stack (pgTAP, 2026-11-18); pnpm db:types run; not yet run by zuki.
- Reads · plain selects under the user's session; no views. authenticated has no insert, update or delete on these tables: a direct write is 42501 with no key (R-MD-52).
- garages (
id,organization_id,code,name,kind,address,phone,is_active), insurers (id,organization_id,name,phone,website,is_active) and insurer_garages (id,organization_id,insurer_id,garage_id,partner_since,is_active; embed the insurer and garage through the FKs) · any member of the organization (R-MD-01, R-MD-14), so an admin_fleet user with garage:write and no master_data:read reads the insurers Bengkel rekanan offers. - inspection_item_types (
id,organization_id,code,name,name_en,section,answer,applies_to,vehicle_class,is_system,sort_order,is_active) and body_panels (id,organization_id,code,name,name_en,area,vehicle_class,is_system,sort_order,is_active) · any member. A checklist item's nullvehicle_classmeans both classes. No system rows are seeded in this slice (R-MD-78), sois_systemis false on every row for now. - rental_companies (
id,organization_id,name,legal_name,contact_phone,bank_account_ref,status) · master_data:read or payment:read; a member without the all-companies flag reads only their own (R-MD-75). A rental company has nois_active: retired isstatus = 'inactive'(public.company_status:active,inactive). - Every list returns retired rows too; the tabs filter and mark them, and pickers filter
is_active = true(R-MD-73).
- garages (
public.caller_all_rental_companies(organization_id uuid) returns boolean· RPC for authenticated users (R-MD-76). True when the caller holds master_data:read, payment:read or payment:approve in the organization and has the all-companies flag there; false without such a permission, when limited to their own companies, or for another organization. It says nothing about payment:approve: the Perusahaan rental tab offers add, change, retire and restore only when this is true and my_permissions() holds payment:approve in the organization. finance reads no membership row, so the tab asks here rather than readingmemberships.all_rental_companies.- Writes · RPCs for authenticated users, security definer,
search_path = '', revoked from public and anon. Each add takes the organization explicitly (a partner garage takes it from its insurer) and returns the new row's id; each change is a full replace, returns nothing and writes nothing when nothing changes (R-MD-74). Text is trimmed; a blank optional text (address, phone, website, legal_name, contact_phone, bank_account_ref, name_en) is stored as null (R-MD-68).- Permissions · garage:write for garages and partner garages (R-MD-80); master_data:write for insurers, checklist items and body panels (R-MD-54); payment:approve, in the organization and with no company scope (the all-companies flag), for rental companies (R-MD-55, R-MD-56).
public.add_garage(organization_id uuid, code text, name text, kind public.garage_kind default 'general', address text default null, phone text default null) returns uuid·public.change_garage(garage_id uuid, name text, kind public.garage_kind, address text, phone text). No code on change (R-MD-66); a garage code has no pattern (BK-001 and Bengkel01 are both accepted), and garage names may repeat (R-MD-64). A null kind isgeneral.public.add_insurer(organization_id uuid, name text, phone text default null, website text default null) returns uuid·public.change_insurer(insurer_id uuid, name text, phone text, website text).public.add_insurer_garage(insurer_id uuid, garage_id uuid, partner_since date default null) returns uuid·public.change_insurer_garage(insurer_garage_id uuid, partner_since date). The pair never moves (R-MD-62): a new garage is a new row and the old one is retired. A null partner_since is allowed.public.add_rental_company(organization_id uuid, name text, legal_name text default null, contact_phone text default null, bank_account_ref text default null) returns uuid·public.change_rental_company(rental_company_id uuid, name text, legal_name text, contact_phone text, bank_account_ref text). A new company isactive.public.add_inspection_item_type(organization_id uuid, code text, name text, section public.item_section, answer public.item_answer, name_en text default null, applies_to public.item_applies_to default 'all', vehicle_class public.vehicle_class default null, sort_order int default 100) returns uuid·public.change_inspection_item_type(item_type_id uuid, name text, name_en text, section public.item_section, applies_to public.item_applies_to, vehicle_class public.vehicle_class, sort_order int). No code and no answer on change (R-MD-66, R-MD-70). A null applies_to isall, a null sort_order 100; a null section or answer is the column's 23502, not a key, so the form requires both.public.add_body_panel(organization_id uuid, code text, name text, area public.panel_area, name_en text default null, vehicle_class public.vehicle_class default 'car', sort_order int default 100) returns uuid·public.change_body_panel(body_panel_id uuid, name text, name_en text, area public.panel_area, vehicle_class public.vehicle_class, sort_order int). No code on change (R-MD-66). A null vehicle_class iscar, a null sort_order 100; a null area is 23502, so the form requires it.public.retire_master_data(kind, row_id)·public.restore_master_data(kind, row_id)take the new kindsgarage,insurer,insurer_garage,rental_company,inspection_item_typeandbody_panel. Ending a partnership is retiring its insurer_garages row. For a rental company they setstatus. Retiring a retired row or restoring an active one changes nothing and writes no audit row (R-MD-57, R-MD-58); retiring never touches the rows that use it (R-MD-59).
- Keys, checked in this order for each RPC; detail keys exactly as raised. All are P0001 except not_allowed (42501).
- add_garage ·
master_data.not_allowed{organization_id};master_data.name_required{field: 'code'}, then{field: 'name'};master_data.code_taken{field: 'code', id, retired}, retired rows included (R-MD-65);master_data.phone_invalid{field: 'phone'}. - change_garage ·
master_data.not_found{id};not_allowed;name_required{field: 'name'};phone_invalid{field: 'phone'}. - add_insurer ·
not_allowed;name_required{field: 'name'};master_data.name_taken{field: 'name', id, retired}, retired rows included (R-MD-64);phone_invalid{field: 'phone'}. - change_insurer ·
not_found{id};not_allowed;name_required;name_taken, the row itself excluded;phone_invalid. - add_insurer_garage ·
not_found{field: 'insurer_id', id}, then{field: 'garage_id', id}for a garage outside the insurer's organization (R-MD-63);not_allowed{organization_id}of the insurer;master_data.pair_taken{id, retired}when the insurer already pairs that garage, on an active or a retired row (R-MD-61): withretiredtrue the dialog offers restore on that id;master_data.retired{field: 'insurer_id', id}, then{field: 'garage_id', id}(R-MD-60). - change_insurer_garage ·
not_found{id};not_allowed. - add_rental_company ·
not_allowed{organization_id}, without payment:approve or without the flag (the same key for both, R-MD-56);name_required{field: 'name'};name_taken{field: 'name', id, retired}(retired is status inactive);phone_invalid{field: 'contact_phone'}. - change_rental_company ·
not_found{id};not_allowed(no payment:approve, or no flag: a scoped caller's change to their own company is refused the same way, R-MD-56);name_required;name_taken;phone_invalid{field: 'contact_phone'}. - add_inspection_item_type and add_body_panel ·
not_allowed;name_required{field: 'code'}, then{field: 'name'};master_data.code_invalid{field: 'code'}, the code not matching^[a-z0-9_]+$(R-MD-67);code_taken{field: 'code', id, retired}, a system copy's code included;name_taken{field: 'name', id, retired};master_data.out_of_range{field: 'sort_order', min: -32768, max: 32767}(R-MD-71). - change_inspection_item_type and change_body_panel ·
not_found{id};not_allowed;master_data.system_row_locked{id}on a system copy (R-MD-05);name_required{field: 'name'};name_taken, the row itself excluded;out_of_rangefor sort_order. - retire_master_data and restore_master_data on the six kinds ·
not_found{id};not_allowed{organization_id}(the kind's permission, and for a rental company the flag too);system_row_locked{id}on a checklist item's or body panel's system copy; then, only when the row's state changes, on restoring a partner garageretired{field: 'insurer_id' | 'garage_id', id}(R-MD-60). Nothing else refuses a retirement (R-MD-59).
- add_garage ·
- Phones ·
phone_invalidis raised for anything but62followed by 7 to 13 digits, the first not 0 (^62[1-9][0-9]{6,12}$, R-MD-69, R-CONV-07). Postgres doesn't rewrite08…or+62…: the form sends the 62 form. - Numbers beyond the parameter type · sort_order is an int parameter, so a value between int2 and int reaches
out_of_range; one above 2147483647 is the cast's 22003 with no key. The form caps sort_order at -32768 to 32767. - Enums to label (R-MD-79) ·
public.garage_kind(authorized,general,body_paint,internal),public.item_section(body,interior,engine,equipment,tyres),public.item_answer(grade,present,value),public.item_applies_to(all,ice,ev),public.panel_area(front,left,right,rear,top,wheel),public.vehicle_classandpublic.company_statusas the app already labels them. - E2E · the finance E2E login holds the all-companies flag: tools/db/create-e2e-users.mjs inserts its membership without
all_rental_companies, whose default is true, socaller_all_rental_companies()is true for it. The seed has two rental companies, E2E Mitra Kendaraan and TOP, the marked one (#748, D108); the R-MD-76 journey creates its own company through the E2E fixture. - E2E helper that breaks · apps/web/e2e/support.ts
companies()inserts and updates rental_companies directly as the super_admin; after R-MD-52 that is 42501. It switches toadd_rental_company(organization_id, name)for a missing company, andretire_master_data('rental_company', id)orrestore_master_data('rental_company', id)for the status asked; both are no-ops when the status already matches. The super_admin holds payment:approve and the flag. - Types ·
pnpm db:typeswas run on 2026-11-18; packages/db-types has the functions,caller_all_rental_companiesand the newmaster_data_kindvalues.
M1-10 delegated approvals (#638), answered to FE in the team session on 2026-11-18. Status: built and tested on the local stack (pgTAP, 104 tests in 68_delegation.test.sql, the caller's rental-company limit, R-ACC-264, included; the suite 1802 tests in 45 files, run by zuki on 2026-11-18); pnpm db:types run; not yet run by zuki. P0001 is a refusal, 42501 a denial; every key's message is the key and its detail is JSON.
public.delegable_permissions(pool_id uuid)· RPC for authenticated users; rows ofpermission_code text,pool_today date,timezone text: the delegable codes the caller holds at the pool through a role, with no deny there, for an active pool only.pool_todayis today in the pool's time zone, the earliest last day the date picker offers;timezoneis the pool's. No rows means the caller can't delegate there: hide Delegasikan. R-ACC-254's tab shows when this has rows or the caller holds user:read at the pool.public.delegation_candidates(pool_id uuid)· RPC; rows ofmembership_id uuid,name text: active members holding a role at the pool, the caller excluded, and, for a caller limited to rental companies, only members within their set (one with the flag or a rental company outside it is left out). No rows unless delegable_permissions() has rows for the caller there.public.pool_delegations(pool_id uuid)· RPC; rows ofoverride_id uuid,membership_id uuid,member_name text,permission_code text,granted_by uuid,granted_by_name text,reason text,ends_at timestamptz,ends_on date(the last day of cover in the pool's time zone; null for no end),is_live boolean,can_revoke boolean,given_at timestamptz,timezone text. Ordered bygiven_atdesc (when it was given, or when an ended one was replaced), then id. With user:read at the pool, every delegation there; otherwise only those of codes the caller holds there through a role with no deny.can_revokeis true when the caller holds the code there through a role with no deny, or holds user:write there, and the member is within a scoped caller's set (R-ACC-264); the row comes back either way. Names are the full name, else the email (R-APP-17).public.delegate_permission(membership_id uuid, pool_id uuid, permission_code text, reason text, last_day date default null)· RPC; returns themember_permission_overridesrow (delegatedtrue,effectgrant,granted_bythe caller,ends_at00:00 in the pool's time zone on the day afterlast_day, null for no end). The reason is trimmed; a blank one isaccess.reason_required, so the form needs no check of its own. A delegation past its end is replaced. Ends the member's sessions, not the caller's. Keys in check order:profile.not_signed_in(42501){};access.member_not_found{membership_id};access.cannot_delegate_self{membership_id};access.permission_not_found{permission_code};access.not_delegable{permission_code};access.pool_not_available{pool_id};access.not_held_by_role(42501){permission_code, pool_id};access.member_not_active{membership_id};access.member_outside_scope(42501){membership_id, rental_company_ids};access.member_no_role_at_pool{membership_id, pool_id};access.reason_required{membership_id};access.ends_at_past{ends_at, last_day};access.override_already_set{membership_id, permission_code, pool_id}.public.revoke_delegation(membership_id uuid, pool_id uuid, permission_code text)· RPC; returns nothing (void). Removes the delegation, live or ended. Ends the member's sessions, not the caller's. It checks neither the member's status nor whether the pool is active. Keys in check order:profile.not_signed_in;access.member_not_found;access.not_allowed(42501){pool_id, permission_code};access.member_outside_scope(42501){membership_id, rental_company_ids};access.override_not_held{membership_id, permission_code, pool_id}.public.set_override()· as in M1-03, but a live delegation of that code at the pool, for either effect, isaccess.override_already_set; one past its end is replaced by the plain override (delegatedfalse,ends_atnull) (R-ACC-260, R-ACC-261).public.pool_members(pool_id uuid)· as before; eachoverridesentry gainsends_on date,is_live booleanandgranted_by_name text, set only for a delegated one and null otherwise:{override_id, permission_code, effect, reason, delegated, ends_at, ends_on, is_live, granted_by_name, can_clear}.can_clearis unchanged.- Settled · a giver who loses the role or is suspended or removed leaves the delegation in place (R-ACC-249); a suspended receiver keeps it but it gives nothing until reinstated, and a removed one loses it (R-ACC-250). A caller limited to rental companies is held to members within their set, as in every other member change; the member's own scope is unchanged (D99).
- Types ·
pnpm db:typeswas run on 2026-11-18; packages/db-types has the five functions, thelast_dayargument and the five new keys;pnpm docs:referenceregenerated reference/, again after R-ACC-264 (no signature changed, so no new types).
M1-11 a removed member invited again, and the M1 carry-overs (#650, #666, #667, #674), accepted by FE in the team session on 2026-11-19. Status: built and tested on the local stack (pgTAP, 1851 tests in 46 files, 2026-11-19); pnpm db:types run; the magic_link template live locally; not yet run by zuki. P0001 is a refusal, 42501 a denial.
public.invite_member(email, pool_id, role_id, rental_company_ids)andpublic.resend_invitation(invitation_id)· as before, butinvitation.login_existsnow means the email's login has a membership in any organization (D101, D104); a login with none anywhere is invited. Both return theinvitationscolumns plusdelivery text:'invite'(no login, or one not yet confirmed: apps/web callsauth.admin.inviteUserByEmailas before) or'sign_in'(a confirmed login: apps/web sends the sign-in link,signInWithOtp({ email, options: { shouldCreateUser: false, emailRedirectTo: <SITE_URL> } })).restore_invitation()now returns the same shape (FE-694-1, R-ACC-287).public.accept_invitation()· RPC for authenticated users, no arguments; apps/web calls it once /auth/confirm has verified atype=magiclinktoken. Any session of the invited login counts while the invitation hasn't expired (zuki). Returns one row:invitation_id uuid,organization_id uuid,pool_id uuid,status invitation_status(acceptedorvoided),void_reason text(a D10 key,invitation.grant_not_heldorinvitation.scope_not_held; null when accepted),membership_id uuid(null when voided). A failed D98 recheck voids the invitation and the void stays; nothing raises for it. Keys in check order:profile.not_signed_in(42501),invitation.not_found(P0001; no pending invitation for the caller's email),invitation.expired(P0001, new;invitation_id,expires_at; it stays pending, to be resent). Accepting ends no session, and the login keeps its password, so no /welcome. The trigger on Auth's confirmation is renamedapp.accept_invitation_on_confirm()and works as before; both share one recheck.- Sign-in email ·
supabase/templates/magic_link.html, Indonesian, worded as an invitation, linking to{{ .RedirectTo }}/auth/confirm?token_hash={{ .TokenHash }}&type=magiclink; it lasts 24 hours, asotp_expiryis shared. Locallymax_frequencyis 1s, so an immediate Kirim ulang works; on hosted projects Auth limits sign-in links per email bymax_frequencyandemail_sent, set in the L0 step under BE-M1-01. apps/web maps Auth'sover_email_send_rate_limit. public.set_organization_settings()·service_interval_kmis replaced byservice_interval_km_evandservice_interval_km_ice, in that place and order, each 1 to 2147483647, refused withsettings.out_of_range(field,min,max) (R-SET-12, R-SET-18).organization_settingshas the two columns, ev 20000 and ice 10000 for a new organization; the old column is gone (D11).public.my_permissions()· gains a fifth column,pool_is_active boolean. apps/web hides a retired pool in the switcher (zuki); its access stays, asapp.pools_with_any()is unchanged.master_data.field_required(P0001, new;field) · a required argument passed null:vehicle_classandpowertrainof add_vehicle_model() and change_vehicle_model(),driver_daily_rateandadmin_feeof add_pricing_group() and change_pricing_group(),channelof add_lead_source() and change_lead_source(),platformof add_contract_template(),sectionandanswerof add_inspection_item_type(),sectionof change_inspection_item_type(), andareaof add_body_panel() and change_body_panel().
M1 carry-overs (#693, #686), sent to FE in the team session on 2026-11-19. Status: built and tested on the local stack (pgTAP, 2026-11-19); pnpm db:types and pnpm docs:reference run; not yet run by zuki. P0001 is a refusal, 42501 a denial.
- FE-693-1 ·
public.my_delegations()· RPC for authenticated users, no arguments, security definer. Rows ofoverride_id uuid,pool_id uuid,pool_code text,pool_name text,permission_code text,granted_by_name text,reason text,ends_at timestamptz,ends_on date(the last day of cover in the pool's time zone; null with no end),is_live boolean,given_at timestamptz,timezone text, orderedgiven_atdesc, thenoverride_id. The caller's own delegations at every pool, live and ended, a suspended member's too. It never raises: with no one signed in it returns no rows, as pool_delegations() does (R-ACC-281). Status: built, sent to FE. - FE-693-2 · The E2E fixture ·
tools/db/create-e2e-users.mjskeeps one ended delegation:gate_service:approveat E2B, from the E2E admin_fleet to the E2E checker, reasonE2E ended,ends_on2026-01-01. Journeys find it by its reason, and their cleanups leave it. On staging it comes with BE-M1-02. Status: built locally, sent to FE. - FE-693-3 ·
public.accept_invitation()· its row is unchanged, andprofile.not_signed_in(42501),invitation.not_foundandinvitation.expired(P0001) come as before. New: afterexpiredit raisesinvitation.login_exists(P0001,{email}) when the login already holds a membership in another organization, and the invitation stays pending (R-ACC-276, R-ACC-277). A login whose email isn't confirmed getsinvitation.not_found(R-ACC-278). Status: built, sent to FE. - FE-693-4 ·
public.set_my_full_name(full_name text) returns text· RPC for authenticated users; returns the saved name, trimmed (R-ACC-284). Keys in check order:profile.not_signed_in(42501),profile.name_required(P0001, blank after trimming),profile.name_too_long(P0001,{max: 100}) (R-ACC-285). Saving the same name writes nothing, and no session ends. Status: built, sent to FE. - FE-693-5 ·
public.restore_invitation(invitation_id uuid)· superseded by FE-694-1; it added one refusal right afterinvitation.already_member:invitation.login_exists(P0001,{email}) when the email's login holds a membership in any organization (R-ACC-275). Status: built, sent to FE. - Types ·
pnpm db:typeswas run on 2026-11-19; packages/db-types hasmy_delegations,set_my_full_nameand the two newprofile.*keys.
M1 carry-overs (#694), answered to FE in the team session on 2026-11-20. Status: built and tested on the local stack (pgTAP, 1879 tests in 46 files, 2026-11-20, again after create-e2e-users.mjs); pnpm db:types and pnpm docs:reference run; not yet run by zuki. P0001 is a refusal, 42501 a denial.
- FE-694-1 ·
public.restore_invitation(invitation_id uuid)· RPC; returnspublic.sent_invitation, as invite_member() and resend_invitation() do: theinvitationscolumns plusdelivery text. The row comes backpending,void_reasonnull, the caller asinvited_by,expires_at24 hours from now, for a confirmed login as for any other (R-ACC-286).deliveryis judged now (R-ACC-287):'sign_in'for a confirmed login (apps/web sendssignInWithOtp({ email, options: { shouldCreateUser: false, emailRedirectTo: <SITE_URL> } })),'invite'otherwise (auth.admin.inviteUserByEmail), as for a resend; a failed send leaves it pending for Kirim ulang. No membership, role or link is made until accept_invitation() (R-ACC-277). Keys in check order:profile.not_signed_in(42501),invitation.not_found,invitation.not_allowed(42501),invitation.role_not_at_pool,access.grant_not_held,access.scope_limit_required,access.rental_company_not_held(42501),invitation.not_voided({invitation_id, status}),invitation.already_member({invitation_id}),invitation.login_exists({email}: a membership in another organization),invitation.already_pending({invitation_id}of the other pending one in this organization),invitation.login_exists({email}: another organization's pending invitation). No session ends (R-ACC-215); one transaction and one activity-log entry (R-ACC-221). Status: built, sent to FE.
A step is done when zuki has logged a clean run on its issue (D28).
- BE-M1-01 · Invite and sign-in emails, redirect URLs and link expiry on a hosted project · L0, on staging before its first invitation and on production at cutover.
- BE-M1-02 · The ended E2E delegation on staging · L0, on staging once #693 is merged and staging holds its migrations.