Skip to content

M0 · Monorepo move

Rewritten on 2026-10-05 for D25. M0 is rebuilt from an empty folder, in the order of the timeline. BE-M0-01 is the timeline's row 1; packs A to F below fill rows 18 to 22 and 32, and BE-M0-32 (row 18a) fixes pack A.

  • D3 · Business rules, multi-step actions and access control live in Postgres; every pack below writes them there.
  • D4 · The Supabase CLI owns the schema; pnpm db:types writes the types into @opleet/db-types, committed.
  • D5 · supabase/ at the repository root; tools/ outside the pnpm workspace.
  • D6 · Conventional Commits; this runbook's commits use the supabase and tools scopes.
  • D9 · Schema V13's business rules and loophole fixes, P15 included (pack D).
  • D10 · Every refusal raises a stable key with a JSON detail, and a pgTAP test asserts it.
  • D11 · Migration files are edited in place until cutover; nothing is pushed to production.
  • D12 · pgTAP on the local Supabase stack, Postgres 17; the CI database job runs on a path filter (supabase/** and tools/db/**).
  • D13 · Publishable and secret keys; the local stack signs tokens with an ES256 key made on each machine (pack A).
  • D14 · Storage paths carry no pool; policies find the pool through the owning row's resolver (pack D).
  • D19 · Every rule and every RPC gets pgTAP tests in the same step.
  • D22 · packages/db-types holds the generated types only.
  • D25 · M0 is rebuilt from an empty folder, in the timeline's order. The delivered M0 and the design canvas are background: read, never copied in whole. Its 44 checks are the acceptance list (pack E). The plain-Postgres stub never enters the repository.
  • D27 · apps/docs holds the rules: every pgTAP description starts with the ID of the rule it proves, and pnpm docs:rules checks the links. Pack B waits for DOC pack A's IDs; pack E adds pnpm docs:reference for the generated pages and maps the 44 checks to rules.
  • D28 · GitHub Team: every pack works on a branch, its pull request needs the checks and pr-title jobs green, and zuki squash-merges it; agents never merge. A run is logged as a comment on the pack's issue. This runbook lives in apps/docs.
  • D29 · name (Indonesian) and name_en (English, optional) on charge_types, lead_sources, inspection_item_types and body_panels (pack B); proper nouns, pricing groups among them, keep one name.
  • OQ2 · Open. Pack A switches self sign-up off on the local stack, following the proposed answer.
  • OQ13 · Open. Realtime stays off on the local stack until it is decided.
  • D30 · The error keys are a Postgres enum, public.error_key, raised through app.refuse() (P0001) and app.deny() (42501); app.error_keys is gone (pack B, BE-M0-12).
  • D31 · Margin and company_amount are read only with the new permission payment:margin (super_admin, admin and finance); NIK and phone stay in full for every role that reads a driver (packs B to D).
  • D33 · A migration's author runs pnpm db:types and commits packages/db-types in the same pull request; CI's database job fails on any difference (closes OQ21).
  • D37 · A change to a person's roles or overrides ends their sessions and stamps their profile; session_is_current() tells proxy.ts whether a token is older (pack G1).
  • D39 · No one deletes a car: inactive is a status, vehicle:delete is gone, plates are unique among cars that aren't inactive, and temporary plates may repeat (pack G1).
  • D38 and D40 · The rental chain (pack G2, the data phase) and document numbers (M4) are not in M0.
  • D48 · A membership suspended or removed, or a change to a role's permissions, also ends sessions, and the super_admin grant at a new pool (R-ACC-47) ends none. Pack G1 is merged as written and pack G1b (#165) makes these changes, with company bank accounts read with payment:read (R-MD-12).
  • D50 to D64 · Not in M0: they shape the data phase and M1 to M6. Pack G1b leaves surat hutang's type code to R-NUM-10 and M4.
  • D41 to D47 and D49 · Not in M0: driver stages, VIN and the rental chain are pack G2; the rest is M3 to M6 and the data phase.

Interface, updated 2026-10-15 for pack G1. Pack B writes everything below unless a later pack is named. None of it has run on the Supabase stack yet, so it stays planned until zuki logs a clean run of the pack that writes it. The names, arguments and columns are fixed, so the Frontend Engineer can build against them.

  • public.my_permissions() · RPC with no arguments, for authenticated users only; anon cannot call it. Returns one row per pool and permission the caller holds after roles, grant overrides and deny overrides: organization_id uuid, pool_id uuid, pool_code text, permission_code text, ordered by pool code, then permission code. Every role and override names its pool (R-ACC-04, pack G1), so each comes back for its own pool only. Call it as rpc('my_permissions'). A suspended membership gives no rows. Written in pack B, BE-M0-13.
  • public.set_my_locale(locale text) · RPC for any signed-in user. It sets profiles.locale for the caller only and returns the stored value. It accepts id and en; anything else raises profile.locale_unsupported with the detail {"locale": …}. profiles.locale defaults to id (D7). Written in pack B, BE-M0-13 (FE-R5). Without a signed-in person it raises profile.not_signed_in.
  • Views v_charge_balance, v_driver_balance, v_checkpoint_due and v_driver_clearance · security_invoker, so RLS applies to whoever reads them. Written in pack B, BE-M0-20. How v_driver_clearance treats an older failed check is OQ7; its states wait for a rule (BC open 1).
  • Status changes · app.set_vehicle_status and app.set_driver_stage stay in the app schema, which the API does not expose, and check the caller's permission at the row's pool. An app user who edits vehicles.status, drivers.stage, rentals.status or charges.status directly gets vehicle.status_locked, driver.stage_locked, rental.status_locked or charge.status_locked. The actions that change a status get public RPCs with their modules (M2 onwards). Written in pack B (BE-M0-15, BE-M0-16, BE-M0-17, BE-M0-19).
  • Master data names (D29) · charge_types, lead_sources, inspection_item_types and body_panels have name (Indonesian, required) and name_en (English, may be null: show name then). The other master data has one name; pricing groups are named after the models they price. Written in pack B (BE-M0-14); the system charge types and lead sources carry both names from pack D (BE-M0-22).
  • Row-level security (pack C, BE-M0-21) · a row is visible to a caller who holds one of its table's read permissions at the row's pool, and written by one who holds its write permission there; the generated Row-level security page lists every policy after BE-M0-31. A read the policies refuse returns no rows. An insert they refuse raises 42501 (“new row violates row-level security policy”), and an update or delete they refuse changes nothing and raises nothing. A table with no policy for an action refuses it to every app user, which holds an open question until its rule exists. Every member reads their own organization's row (R-TEN-17), and the full name and avatar of the members of their organizations through public.member_names(profile_ids uuid[] default null) (R-ACC-39); the rest of a profile still needs user:read, and nobody deletes a profile from the app (R-ACC-38). A member with member_rental_companies rows is limited in that organization to those rental companies: their cars and the rentals, contracts, inspections, work orders, gate passes, ETLE rows and rent charges of those cars, those companies and their payouts (R-ACC-42 to R-ACC-45). Such a member reads no drivers row; public.driver_names(driver_ids uuid[] default null) gives the name of a driver renting one of their cars, and the same function names drivers for anyone who reads them (R-ACC-46). Payouts need payment:read and payment:margin (R-MON-40). A change to memberships, member roles or overrides that would leave the organization with no active member holding user:write is refused with access.last_user_manager (R-ACC-40) and, without user:read, a member reads only the permissions they hold from the catalogue (R-ACC-33, pack G1). A car is read with vehicle:read, gate:read, fleet_monitor:read, inspection:read, work_order:read or insurance:read at its home pool (R-VEH-14 to R-VEH-17); only vehicle:write changes it. Nobody inserts, changes or deletes vehicle_status_history from the app: app.set_vehicle_status writes it (R-VEH-18). An audit row with no pool (a change to settings, legal entities, pools, bank accounts, memberships or roles) is read only with audit_log:read at every pool of the organization; a deny override at one pool hides it (R-AUD-12). Every member reads vehicle_brands (R-MD-01, pack G1), but nobody writes them yet, and apps/web can't read insurer_garages (MD open 1) or maintenance_records (WO open 1). It can't request a pool transfer (TRF open 1), write debt letters, their items or collection calls (COL open 1),. my_permissions() needs none of these.
  • Margin and company amount (D31, pack C) · charges.company_amount and charges.margin are not granted to app users, so a select on charges must list its columns: select=* is refused (42501). public.charge_margins(charge_ids uuid[]) returns charge_id, company_amount and margin for the charges the caller reads, empty where the caller lacks payment:margin at the driver's pool (R-MON-39).
  • Storage (pack D, BE-M0-24) · four private buckets: documents (KTP, SIM, STNK, contracts and BASTK PDFs), inspections (inspection photos and signatures), screening (background check evidence) and payments (proof of payment). A file's path is <organization_id>/<table>/<row_id>/<file name>, where the row is the one that stores the path, with no pool (D14). Uploading needs write access to that row, and reading needs read access to it, at the pool the row has now; the row must exist first. So apps/web makes the row's id itself (crypto.randomUUID()), inserts the row with the path the file will have, then uploads to that path. Upload with upsert off: a file is never replaced or deleted through the API, and a new version is a new path. Show a file through a signed URL. Path columns hold the storage_path type: a bucket path of at most 400 characters, never a URL or a data: URI. A long base64 run in a contract template, a driver note or v1's nota is refused too (23514). Each bucket takes only its file types, up to its size: documents, screening and payments take JPEG, PNG, HEIC and PDF (image/jpeg, image/png, image/heic, application/pdf); inspections takes JPEG, PNG and HEIC. payments takes 5 MB a file, the others 10 MB (R-STO-06 to R-STO-09). Storage refuses any other upload before a policy runs, so check type and size in the browser first.
  • Pack G1 (BE-M0-34 to BE-M0-38, #150) · what changed for apps/web:
    • public.session_is_current() · RPC with no arguments, for authenticated users only. True when the caller's login token (its iat) was issued after their last access change, profiles.access_changed_at; false when it wasn't, or when the caller has no profile. proxy.ts calls it on every request and sends the user to /login when it is false or errors (D37, R-ACC-48; FE pack B2, #151). A change to a person's roles or overrides, their own included, ends their sessions (R-ACC-08).
    • Roles and overrides need a pool; writing one with no pool raises 23502 (R-ACC-04). Granting needs the permissions at that pool (access.grant_not_held). A new pool goes to every super_admin at once (R-ACC-47). As G1 builds it, that grant also ends their sessions; pack G1b exempts it (D48).
    • Every organization has its own copy of the system roles, charge types and lead sources, is_system and locked; look them up by organization and code (R-TEN-03). There is no row with an empty organization except the permission catalogue.
    • Permissions: gate:write records gate passes (super_admin, admin, satpam; R-GATE-04); vehicle:delete is gone, and no one deletes a car (R-VEH-13). contract_templates and pricing_groups need master_data:read; company_bank_accounts (from pack G1b) and rental_companies need master_data:read or payment:read (R-MD-12, R-MD-08).
    • Vehicles: inactive is a vehicle status, set through the status function (D39). vehicles.plate_is_temporary is set by the database. temporary_plates (organization_id, plate_number, note) is read with vehicle:read or master_data:read and written with master_data:write (R-VEH-21).
    • GPS: gps_devices.slot (primary or backup) and gps_devices.is_active; a backup is linked on standby. To switch, set the active device inactive first, then the other active. v_vehicle_position gives each car's latest position from its active device: vehicle_id, organization_id, pool_id, gps_device_id, slot, recorded_at, location, speed_kmh (R-VEH-23).
    • v_checkpoint_due now returns interval_weeks, due_from (a Monday), due_to (its Friday) and is_overdue instead of interval_days and next_due_on (R-INSP-06, R-INSP-10). The setting is checkpoint_interval_weeks.
    • Phones are stored as 62 and the number, with no plus (R-CONV-07); a person's phone starts 628 (R-CONV-16). apps/web normalizes what users type before saving.
    • audit_log has db_user (set when a change is made directly in the database, source system) and transaction_id, shared by the rows of one transaction (R-AUD-05, R-AUD-13).
  • Pack G1b (BE-M0-40 and BE-M0-41, #165) · what changed for apps/web, nothing it calls (D48):
    • Sessions also end, and profiles.access_changed_at is stamped, when a member's membership is set to suspended (R-ACC-52) or deleted (R-ACC-53), and for every holder of a role when a permission is added to it or removed from it (R-ACC-54). Setting a membership back to active ends nothing. session_is_current() and proxy.ts are unchanged.
    • Creating a pool no longer signs out the organization's super_admins: the R-ACC-47 grant ends no session (R-ACC-55). Any other change to their roles still does.
    • A reader with payment:read (finance, viewer) now reads company_bank_accounts, to pick the account a payment came into (R-MD-12).
  • E2E logins (pack E, BE-M0-25) · pnpm db:e2e-users makes one login per system role in the E2E organization, with the role at every pool (E2A and E2B). The address is e2e.<role, with - for _>@e2e.opleet.test. .env.e2e holds E2E_PASSWORD and E2E_<ROLE>_EMAIL for the 11 roles, for example E2E_ADMIN_FLEET_EMAIL.
  • Generated types (pack E, BE-M0-26) · pnpm db:types writes packages/db-types/src/database.ts from the local database's public schema. It exports the types (Database, Tables, TablesInsert, TablesUpdate, Enums) and one value, Constants, which lists every enum's values, the error keys among them (Database["public"]["Enums"]["error_key"]).
  • Error keys (D10, D30) · each refusal raises its key as the error message, with the JSON detail named here; Postgres's code is P0001 for a broken rule (app.refuse) and 42501 for a missing permission (app.deny). The keys are the values of the enum public.error_key, so pnpm db:types gives apps/web the union and Constants the list; a key outside the enum can't be raised (22P02). What a key means is the Refusal line of its rule, and pack E's generated Error keys page lists every key with its code, where it is raised and its rules (BE-M0-31). Written in pack B (the enum in BE-M0-12), by step (key, code, detail fields):
  • BE-M0-13 · access.not_member (42501; organization_id) · profile.not_signed_in (42501; no detail) · profile.not_found (P0001; profile_id) · profile.locale_unsupported (P0001; locale) · settings.pool_not_found (P0001; pool_id) · settings.unknown_key (P0001; key) · document.wrong_organization (P0001; organization_id, legal_entity_id) · document.bad_period (P0001; period).
  • BE-M0-15 · vehicle.not_found (P0001; vehicle_id) · vehicle.status_forbidden (42501; vehicle_id) · vehicle.status_locked (42501; vehicle_id).
  • BE-M0-16 · driver.not_found (P0001; driver_id) · driver.stage_forbidden (42501; driver_id) · driver.stage_locked (42501; driver_id).
  • BE-M0-18 · vehicle.cross_pool_blocked (P0001; vehicle_id, home_pool_id, pool_id): an inspection, work order or gate pass given a pool other than its car's home pool while the organization's allow_cross_pool_operations is off, the default (VEH open 3, answered in #77). With the setting on, the pool given is kept; nothing in the app turns it on yet.
  • BE-M0-17 · rental.cross_pool (P0001; driver_pool_id, vehicle_pool_id) · rental.status_locked (42501; rental_id).
  • BE-M0-19 · allocation.payment_voided (P0001; payment_id) · allocation.exceeds_payment (P0001; payment_id, payment_amount, allocated) · allocation.exceeds_balance (P0001; charge_id, balance, amount) · allocation.cross_entity_blocked (P0001; payment_entity_id, charge_entity_id) · charge.status_locked (42501; charge_id).
  • BE-M0-21 · access.last_user_manager (42501; organization_id).
  • BE-M0-34 · access.grant_not_held (42501; pool_id, permission_codes): a role, grant or deny at a pool where the granter lacks those permissions (R-ACC-50).
  • BE-M0-37 · vehicle.plate_in_use (P0001; vehicle_id, plate_number): bringing back an inactive car whose plate is now on another car that isn't inactive (R-VEH-24).
  • Refusals by a constraint keep Postgres's own code and name the constraint instead of a key: 23505 for a unique (such as rentals_one_live_per_vehicle), 23514 for a check (such as drivers_phone_62), 23503 for a foreign key (such as insurance_claims_partner_garage_fk). The module actions users call (M2 onwards) check first and raise keys; the constraints stay as the backstop.

Requests from FE, 2026-10-02, updated 2026-10-05 for D25:

  • FE-R1 · packages/db-types: the package name and import path for the generated Database type, and whether apps/web needs transpilePackages for it. Needed by FE-M0-06. Status: answered in part; transpilePackages waits for BE-M0-26.
  • FE-R2 · E2E logins on the local stack, one per role in the E2E organization. scripts/create-e2e-users.mjs writes to a database, so under the monorepo spec it belongs in tools/; it uses the secret key and refuses any non-local URL. Needed by FE-M0-08 and FE pack E. Status: planned in BE pack E (BE-M0-25).
  • FE-R3 · List my_permissions() here: its arguments and returned columns. It exists from M0. Needed by FE pack C. Status: answered.
  • FE-R4 · Confirm the local stack signs tokens with asymmetric keys, or set it in config.toml, so getClaims() verifies locally as D13 intends. With a shared secret it calls the Auth server on every request. Needed by FE-M0-08. Status: answered; BE pack A Done 2026-10-06.
  • FE-R6 · The E2E logins script (BE-M0-25) also writes what Playwright reads to the git-ignored .env.e2e at the repository root: E2E_PASSWORD and one E2E_<ROLE>_EMAIL per role, the role code in capitals (E2E_FINANCE_EMAIL). The values stay in that file, never in a runbook. Needed by FE pack E (timeline row 29) and the CI end-to-end job (TL-M0-19). Status: agreed 2026-10-06, planned in BE pack E (BE-M0-25).

BE answers, updated 2026-10-06:

  • FE-R1 · Answered by D25: the package is @opleet/db-types, created by TL-M0-10; import the type with import type { Database } from "@opleet/db-types". Pack E (BE-M0-26) writes the first generated types. The file exports one runtime value, Constants, besides its types, and the package exports its TypeScript source. So apps/web needs transpilePackages: ["@opleet/db-types"] in next.config as soon as it imports Constants (enum labels per D29 will); type-only imports need nothing. Status: answered 2026-10-07; BE-M0-26's run log confirms the export.
  • FE-R2 · Pack E (BE-M0-25): tools/db/create-e2e-users.mjs, one login per role in the E2E organization, using the secret key. It targets the local stack by default; a staging run needs --staging and is zuki's to run (pack F); a production URL is always refused. Run it with pnpm db:e2e-users. Status: written in pack E.
  • FE-R3 · Answered above, under my_permissions(). Status: answered; written in pack B (BE-M0-13).
  • FE-R4 · Pack A (BE-M0-10, BE-M0-11): an ES256 key made on each machine by pnpm db:signing-key and kept out of git, with signing_keys_path in config.toml. The stack then publishes its public key at /auth/v1/.well-known/jwks.json, so getClaims() verifies tokens locally. CI makes its own key in the database job. Status: answered; pack A Done 2026-10-06.
  • FE-R5 · Pack B (BE-M0-13): profiles.locale and public.set_my_locale(), described above. Asked in the M1 tab; D25 moved it into M0's tenancy step. Status: written; runs with pack B.
  • FE-R6 · Agreed, in pack E (BE-M0-25): after making the logins, the script writes E2E_PASSWORD and one E2E_<ROLE>_EMAIL per role, the role code in capitals, to the git-ignored .env.e2e at the repository root, replacing only those lines. It makes a random password on the first run and reuses the one in .env.e2e after that, so the values never appear in a runbook or a chat. Status: written in pack E.

M0 is rebuilt from an empty folder in the order of the timeline (D25). Each pack below fills one timeline row and runs when the rows above it are done. A step is done when zuki has logged a clean run on its pack's issue (D28). Step IDs continue from BE-M0-10, and withdrawn IDs are never reused.

Withdrawn on 2026-10-05 by D25: BE-M0-02 (the baseline of the delivered M0, never run), BE-M0-03, BE-M0-04 and BE-M0-09. BE-M0-05 to BE-M0-08 were planned and never written; their work is now in packs A to E.

Every pack is checked in BE's workspace before it is sent: on plain Postgres 16 with a stand-in for Supabase's auth and storage schemas that never enters the repository. Each step is run from its zip on its own, the generators must write the files the zip holds, and the rule check runs against DOC pack A's draft 1. Then 24 rules across packs B to D are broken on purpose, each one failing its test. The real run is zuki's, on the Supabase stack and Postgres 17.

BE-M0-01 · Preflight: tool versions (timeline row 1)

Section titled “BE-M0-01 · Preflight: tool versions (timeline row 1)”

Pack A · Local stack settings (timeline row 18)

Section titled “Pack A · Local stack settings (timeline row 18)”

Delivers: self sign-up off, the site URL for apps/web, an ES256 signing key on each machine so getClaims() verifies locally (FE-R4), and the services M0 doesn't use switched off: Logflare and Vector, Edge Functions, Realtime and image transformation. Two steps on one branch, merged as one pull request.

Runs after timeline row 17. Status: Done 2026-10-06 (logged by zuki).

Added 2026-10-07: pull request #6 committed supabase/signing_keys.json, the private key, and supabase/.gitignore has no line for it. BE-M0-32 ignores and untracks the file and makes a new key. It can run now, before pack B (#69).

Added 2026-10-19: BE-M0-10 set enable_signup = false under [auth.email] too, which switches off the whole email provider, so password sign-in was refused with email_provider_disabled. BE-M0-42 turns the provider back on and keeps self sign-up off through [auth] (#205).

Pack B · Schema V13, domain by domain (timeline row 19)

Section titled “Pack B · Schema V13, domain by domain (timeline row 19)”

Delivers schema V13 domain by domain in nine steps: 9 migrations with 70 tables, 67 enums (the error keys among them), the rule functions and triggers, 4 views and the audit log, and 205 pgTAP tests in 10 files. Each step copies one folder of be-pack-b.zip into the repository, rebuilds the local database with pnpm supabase db reset, runs every test with pnpm supabase test db and commits. BE-M0-20 marks the rules the pack proves as built and opens the pull request. Written new from the V13 references; the delivered M0 was read as background only (D25). The error keys are listed under Interface.

Changes to the plan of 2026-10-05: settings (P10), pool dates (P11), document numbers (P12) and updated_at (P14) moved into BE-M0-13 beside their tables; each status rule (P9) sits with its table; every table has RLS switched on in the step that creates it, and pack C adds the policies. Changes of 2026-10-07, to follow DOC pack A's rules: a plate change keeps the old plate (R-VEH-09); the audit log writes a row for every update, even one that moves only updated_at, and logs an unmarked change as app (R-AUD-01, R-AUD-05); a charge's status is written only when it changes; the pool time-zone limit and the partner-filter helper are out until rules cover them. Changes for D29, later on 2026-10-07: name_en on the four bilingual lookups (BE-M0-14), and profiles.avatar_url became avatar_path, a Storage path that pack D types (P15). Changes of 2026-10-08, for D30 and the Docs Engineer's answers in #10: the error keys are the enum public.error_key, raised through app.refuse() and app.deny() (D30); a pool's time zone is one of Indonesia's four again (R-TEN-16); profiles.phone, rental_companies.contact_phone, garages.phone and insurers.phone are E.164, and a login's phone is copied to its profile with the + (R-CONV-07); drivers.registered_on, maintenance_records.started_on and debt_letters.issued_on default to the pool's date (R-CONV-10); new tests for R-CONV-15, R-TEN-16, R-SET-06, R-AUD-11, R-MON-38 and R-MD-10, and the charge status test now cites R-MON-37. Changes of 2026-10-09, for D31: the permission action margin joins permission_action (BE-M0-12); organization_settings.allow_cross_pool_operations (default false, BE-M0-13), and while it is off an inspection, work order or gate pass of a car at a pool other than the car's home pool is refused with vehicle.cross_pool_blocked; with it on, the pool given is kept, as pack B did before (VEH open 3, answered in #77, BE-M0-18). Its four tests cite R-SET-07, R-VEH-20 and R-GATE-08 (#121).

Rule IDs (D27): every test description starts with the ID of the rule it proves, from the rule pages DOC pack A merged on 2026-10-08 (247 rules); RULE-IDS.txt in the zip lists the tests for each rule. Every M0 B rule has a test, and no ID is invented. BUILT-IDS.txt lists the 146 rules BE-M0-20 marks built. Two cited rules stay planned: R-ACC-02 until pack C, and R-NUM-01 until a test can run two sessions at once.

Questions for the Docs Engineer, from pack B (2026-10-07), answered in #10 on 2026-10-08; the changes above follow the answers:

  • DOC-Q1 · Proposed rule: every function that runs as its owner (security definer) pins its search_path. All of pack B's do; their test went out until the rule has an ID. Status: answered in #10.
  • DOC-Q2 · Proposed rule: a pool's time zone is WIB, WITA or WIT (Asia/Jakarta, Asia/Pontianak, Asia/Makassar or Asia/Jayapura). Pack B no longer limits it. Status: answered in #10.
  • DOC-Q3 · R-AUD-01 says every update writes an audit row, so pack B now logs an update that moves only updated_at, with no changed field. If such updates should be skipped, a rule saying so brings the skip back. Status: answered in #10.
  • DOC-Q4 · R-AUD-06: pack B masks doc_number on every document, because a KTP's number is the NIK. Should SIM and other document numbers stay in clear? Status: answered in #10.
  • DOC-Q5 · R-CONV-07: V13 checks E.164 only on drivers, emergency contacts and queue tickets. profiles.phone (copied from the login), rental_companies.contact_phone, garages.phone and insurers.phone have no check. Does the rule cover them? Status: answered in #10.
  • DOC-Q6 · R-TEN-01: profiles and permissions are global in V13, with no organization, and the rule's exceptions don't name them. Status: answered in #10.
  • DOC-Q7 · R-CONV-10: drivers.registered_on, maintenance_records.started_on and debt_letters.issued_on default to the server's date (UTC on Supabase), as V13 has them. Are they business dates under the rule? Status: answered in #10.
  • DOC-Q8 · Two argument checks are cited under R-CONV-13, since their tests prove the refusal raises its key: an unknown setting name (settings.unknown_key) and a counter period that isn't yyyy or yyyy-mm (document.bad_period). Should either be a rule of its own? A daily period for NUM open 1 would change the second. Status: answered in #10.
  • DOC-Q9 · Untested until the open question has a rule; pack B's code does what the brackets say: ACC open 1 (no partner filter yet; its helper comes with pack C), VEH open 3 (a pool given on an inspection, work order or gate pass was kept; since #77 it is refused unless it is the car's home pool or the organization allows cross-pool operations), MON open 1 (a charge closed by adjustments alone is refunded if one is a refund, else waived), BC open 1 (the states of v_driver_clearance). Status: answered in #10.
  • DOC-Q10 · Behaviour that answers an open question for now: SET open 1 (the settings row is made with the organization, which R-SET-03's test relies on) and MON open 2, untested (a cash payment, or a charge with no legal entity, is never cross-entity). Status: answered in #10.

be-pack-b.zip, rebuilt for D31 and #77 on 2026-10-09: SHA-256 855d66a0b6c77bed1c4f762962e7647d640f54f624f52b5cef9dd086bdc1c823, with the rule IDs of #121 in step 18. Steps 12 to 14 are the same as in dd1a8c6b…, from which they ran. Every earlier zip (dd1a8c6b…, 4aba89df… and 3a4244da… of today, 5a34bc62… of 2026-10-08, 911b70bb… and abac3694… of 2026-10-07, and the draft of 2026-10-06) is withdrawn. Runs after timeline rows 18 and 14c, both done. Issue: #11.

Pack C · Row-level security (timeline row 20)

Section titled “Pack C · Row-level security (timeline row 20)”

Delivers the policies for all 70 tables in one step. supabase/migrations/20261006001000_access_helpers.sql adds the resolvers the policies need (a pool's, a membership's, a role's and a profile's organization, a GPS device's pool, who may write an inspection of each kind, the partner filter's two lists and the owner of a car, a rental or an inspection), the three name and margin functions above, and the guard that keeps a user manager (R-ACC-40). tools/db/gen_rls.py holds one spec, table by table, naming the rules each entry implements, and writes 20261006001100_rls.sql: 185 policies, all in the = any ((select app.pools_with_any(…))::uuid[]) pattern. It also writes the grants: anon loses every privilege; authenticated loses TRUNCATE, REFERENCES and TRIGGER, every write to the audit log and every access to the document counters; even service_role can't write the audit log. A last block refuses to finish if any public table lacks RLS or is missing from the spec. 21_rls.test.sql adds 92 tests: pool scoping, deny overrides, tenant isolation, anon, the document counters, the audit log's guard, and every M0 C rule.

A table with no policy for an action refuses it to every app user. That is how pack C holds an open question until its rule exists; the Interface above lists what apps/web can't do yet. R-WO-03 and R-WO-04 stay planned until WO open 1 decides which pool a maintenance record belongs to; their work-order half is tested. BE-M0-21 marks 87 rules built: every M0 C rule except those two, plus R-ACC-02, R-ACC-21, R-MD-05 and R-AUD-12. It also marks R-SET-07, R-VEH-20 and R-GATE-08, which pack B tests but main left planned in #123 (their page landed in #121 after pack B's branch was cut). Changes of 2026-10-08, for the Docs Engineer's answers: members read their own organization (R-TEN-17), every signed-in user reads the permission catalogue (R-ACC-33), member rental companies cite R-ACC-34, and gate:read and fleet_monitor:read read cars (R-VEH-15, R-VEH-16). Changes of 2026-10-09, for D31 and the access answers in #72: the partner filter (R-ACC-42 to R-ACC-46), member names (R-ACC-39), no profile deletes (R-ACC-38), the last user manager (R-ACC-40), payouts with payment:margin (R-MON-40) and margin through public.charge_margins() (R-MON-39). Changes of 2026-10-09, for #119: inspection:read, work_order:read and insurance:read read cars (R-VEH-17, #77), status history is closed to app users (R-VEH-18), and audit rows with no pool get app.orgs_with_every_pool() (R-AUD-12, #74). Tests cite R-ACC-37, R-ACC-36 and R-MON-40 instead of R-ACC-18, R-ACC-25, R-ACC-27 and R-MON-34, which the audit retires.

Questions for the Docs Engineer, from pack C (2026-10-07), answered in #10 on 2026-10-08:

  • DOC-Q11 · Who reads an organization's row? No rule says, so organizations has no policy and apps/web can't show the organization's name. A proposal: any member reads their own organizations. Status: answered, R-TEN-17.
  • DOC-Q12 · Who reads the permission catalogue? permissions has no policy, and my_permissions() returns codes without labels. A proposal: every signed-in user reads it, since it holds no tenant data. Status: answered, R-ACC-33.
  • DOC-Q13 · R-ACC-17 and R-ACC-18: pack C reads a member's rental companies with user:read, adds them with user:write and removes them with user:delete, in the membership's organization. Is that the rule's intent? Status: answered, R-ACC-34.
  • DOC-Q14 · A profile is shared by every organization its person works for, so pack C lets a user delete it only with user:delete in each of them. Should that be a rule, or should deleting a profile be refused outright in favour of ending a membership? Status: answered in #72, R-ACC-38.
  • DOC-Q16 · AUD open 1: audit rows with no pool (organization-level changes) are read by no app user until it is answered. Status: answered in #74, R-AUD-12.

be-pack-c.zip, rebuilt for #119 on 2026-10-09: SHA-256 35b79d5e1db4ee90fc5678b04740b27b59e2a269e649ecb36006956a6f90f354. Runs after row 19. Issue: #12.

Pack D · Seed and Storage (timeline row 21)

Section titled “Pack D · Seed and Storage (timeline row 21)”

Delivers the system rows, the sealed E2E organization and Storage in three steps on one branch. tools/db/gen_seed.py writes 20261006001200_seed_system.sql with the 46 permissions, the 11 system roles and their 196 grants (as v1 had them, renamed, with payment:margin for super_admin, admin and finance, D31), the 8 system charge types and the 11 system lead sources, the last two with name and name_en (D29). supabase/seed.sql makes the E2E organization the end-to-end tests sign in to. 20261006001300_storage.sql makes the four private buckets, the file policies that ask the owning row through pack C's generated resolvers (D14), the storage_path type on all 14 path columns and the base64 guards (P15); each bucket has its file types and size limit (R-STO-06 to R-STO-09, #75). Tests: 5 for the system rows and 14 for Storage, 316 in all. BE-M0-24 marks 11 rules built: R-ACC-35, R-ACC-36 and R-STO-01 to R-STO-09.

Questions for the Docs Engineer, from pack D (2026-10-07 and 2026-10-09):

  • DOC-Q17 · D31 names margin and company_amount. vehicles.company_daily_cost and rentals.company_daily_cost give the same figure per day, and every car or rental reader sees them. Should R-MON-39 cover them? Status: open.
  • DOC-Q15 · STO open 1: which MIME types and which size limit for each bucket? Status: answered in #75, R-STO-06 to R-STO-09.

be-pack-d.zip, rebuilt for #119 on 2026-10-09: SHA-256 92359c9b2c3b5c3c027ff33422a734e45316bc4709fa713fc421624dad69f688. Runs after row 20. Issue: #13.

Pack E · Logins, types and the acceptance check (timeline row 22)

Section titled “Pack E · Logins, types and the acceptance check (timeline row 22)”

Delivers four steps on one branch: the E2E logins script (FE-R2, FE-R6), pnpm db:types with the first generated types (FE-R1), the acceptance check, and pnpm docs:reference with the generated reference pages (D27). Each of the delivered M0's 44 checks is proved by the tests of the rule it maps to, as BE-M0-27's table shows; check 7 (satpam reads its pool's car) maps to R-VEH-15 since 2026-10-08. The pack adds no test and marks no rule built.

be-pack-e.zip, rebuilt on 2026-10-09: SHA-256 26849b7cd52fb392448d3285d351bb38a7c49dcfb49eddf8d8cc8f13821acfdf. Runs after row 21. Issue: #14.

For the CTO: what the CI database job must run (timeline row 23, TL-M0-18)

Section titled “For the CTO: what the CI database job must run (timeline row 23, TL-M0-18)”

TL-M0-18 is the CTO's. From the backend side, the job must run these, in this order, on a path filter of supabase/** and tools/db/** (D12):

  • pnpm install --frozen-lockfile, which brings the pinned Supabase CLI.
  • pnpm db:signing-key: the signing key is git-ignored (from BE-M0-32 on), so the job makes its own before the stack starts.
  • pnpm supabase start: config.toml already switches off the services M0 doesn't use, so no -x flags are needed.
  • pnpm supabase db reset: every migration and the seed, from an empty database.
  • pnpm supabase test db: every pgTAP file. Through their rules, they cover all 44 acceptance checks (BE-M0-27).
  • python3 tools/db/gen_rls.py, python3 tools/db/gen_seed.py, then git diff --exit-code supabase/migrations: the generated migrations are current (packs C and D).
  • pnpm db:types, then git diff --exit-code packages/db-types: the committed types are current (pack E, D4).
  • pnpm docs:reference, then git diff --exit-code apps/docs/src/content/docs/reference: the generated reference pages are current (pack E, D27). Add apps/docs/src/content/docs/reference/** to the path filter, so a hand edit there fails too.
  • pnpm supabase stop --no-backup at the end, also after a failure.

The end-to-end job (TL-M0-19) needs pnpm db:e2e-users after the reset; it writes .env.e2e for Playwright inside the job. A fresh clone needs pnpm db:signing-key once before its first pnpm supabase start. The README and AGENTS.md (the CTO's files) could list both with the other commands.

Pack G1 · The review's schema changes (timeline row 22b)

Section titled “Pack G1 · The review's schema changes (timeline row 22b)”

Delivers the built rules the higher-ups' review changed (#144, DOC pack B in #149), edited in place in supabase/migrations (D11), each rule first, then its pgTAP test, then the SQL (D27, D19). Unlike packs A to E, it reaches the repository as the Backend Engineer's pull request (D28): nothing is copied in from a zip.

Run BE-M0-39 first, on the pull request's branch: it runs every test and commits the regenerated types (D33), which the Backend Engineer's workspace can't produce. After the merge, BE-M0-34 to BE-M0-38 prove each part from main. Staging is then rebuilt with BE-M0-33. Issue: #150.

Not in G1: the rental chain and dropping contracts.daily_rate (D38, pack G2), document numbers (D40, M4), the background-check flow (M3), ETLE and a new car's preparation work order (M5, R-ETLE-03, R-VEH-22), and the overdue limit and bulk payments (#148). What else ends sessions, and finance reading company bank accounts (D48, R-MD-12), follow in pack G1b (#165, timeline row 22d).

Pack G1b · Sessions and bank accounts (timeline row 22d)

Section titled “Pack G1b · Sessions and bank accounts (timeline row 22d)”

Delivers what else ends sessions (D48, R-ACC-52 to R-ACC-55) and finance reading company bank accounts (R-MD-12), from DOC's follow-ups (#164). Like pack G1, it reaches the repository as the Backend Engineer's pull request, each rule first, then its pgTAP test, then the migration edited in place (D27, D11); the RLS policy is changed through the generator's spec in tools/db/gen_rls.py, never in the generated file.

Run BE-M0-40 first, on the pull request's branch: every test, then the generated files (D33). After the merge, BE-M0-41 proves it from main. Staging is then rebuilt with BE-M0-33, before the M0 exit check. Issue: #165.

Not in G1b: surat hutang's type code (R-NUM-10, DOC's) and document numbers, built in M4.

Delivers staging with main's schema, the seed and the E2E logins, and a step to rebuild it from main by hand. Every step runs from zuki's Mac, from main with a clean tree, so staging always holds main's migrations (D11). Every step is L0. The pack changes no file in the repository, so it has no branch or pull request: each run is logged on the issue.

Runs right after row 31, TL-M0-20, which makes the project, logs the CLI in and writes .env.staging. Issue: #22.