Skip to content

STO · Files

Photos, scans and proofs live in private Supabase Storage buckets: documents, inspections, screening, payments and vehicles. A v1 file the migration can't attach to one v2 record is kept as a file from v1, on its driver or its car (D70). A row stores the file's path, and the app shows the file through a short-lived signed URL. Code STO.

These questions are open in #75. Each gets a rule with a new ID once it is answered.

  • STO open 1 · Bucket limits
  • Whether a night is clean while unmatched v1 files are held (R-STO-22, R-STO-20): D70 makes only files not copied a difference to explain, so held files don't block the gate today. Asked on #254; counting them as differences would change D70.
  • Unmatched v1 files hold personal data with no owner (a KTP photo in the bc folder, say): anonymizing a driver (R-STO-19) can't find them, and how long they are kept is OQ18.

R-STO-01 · Every Storage bucket is private

Section titled “R-STO-01 · Every Storage bucket is private”
  • Status: built
  • Example: given the documents bucket, when a file's public URL is opened without a signed token, then nothing is served.
  • Refusal: none: Storage answers not found.
  • Who: every bucket.
  • Source: D9 (P15).

R-STO-02 · A file is stored at organization_id/table/row_id/file, with no pool in the path

Section titled “R-STO-02 · A file is stored at organization_id/table/row_id/file, with no pool in the path”
  • Status: built
  • Example: given a KTP scan for driver 7f3e…, when it is uploaded, then its path is <organization_id>/driver_documents/<row_id>/ktp.jpg.
  • Refusal: none: an upload outside this pattern has no policy that allows it.
  • Who: every upload.
  • Source: D14, which replaces the path in P15.

R-STO-03 · Reading a file needs read access to its row, at the pool the row has now

Section titled “R-STO-03 · Reading a file needs read access to its row, at the pool the row has now”
  • Status: built
  • Example: given a driver moved from PML to SBY, when an admin_driver scoped to SBY opens the driver's KTP scan, then it is served; the PML admin_driver who uploaded it can no longer open it.
  • Refusal: none: Storage answers not found.
  • Who: whoever may read the row; each table's read permissions are on its domain's page.
  • Source: D14; [Ref] Roles, policy matrix (storage objects).

R-STO-04 · Uploading a file needs write access to its row

Section titled “R-STO-04 · Uploading a file needs write access to its row”
  • Status: built
  • Example: given a satpam, when they upload an inspection photo, then it is refused; a checker at the inspection's pool may upload it.
  • Refusal: none: insufficient_privilege (42501).
  • Who: whoever may write the row; each table's write permissions are on its domain's page.
  • Source: [Ref] Roles, policy matrix (storage objects).

R-STO-05 · A row stores a file's path, never the file's content

Section titled “R-STO-05 · A row stores a file's path, never the file's content”
  • Status: built
  • Example: given a payment, when proof_path is saved as data:image/jpeg;base64,…, then it is refused; a path in the payments bucket is accepted.
  • Refusal: none: check_violation (23514).
  • Who: every writer.
  • Source: D9 (P15); [Ref] Database rules and conventions, Personal data and files (no base64 in rows).
Section titled “R-STO-10 · A file migrated from v1 is copied to its D14 path in a private bucket, and its row stores that path, never v1's link”
  • Status: built
  • Example: given a v1 driver whose KTP photo is a link to v1's Storage, when the photo copy runs, then the file is read from that link's bucket and path, copied to its driver document's path, organization_id/driver_documents/row_id/file (R-STO-02), in v2's private documents bucket, and the driver document stores that path; no v2 column holds a URL.
  • Refusal: none.
  • Who: the migration's photo copy (data phase).
  • Source: D60 (OQ16); D14 (paths follow the owning row).
Section titled “R-STO-11 · A v1 file link that doesn't resolve is an unmatched row in the reconcile, never a silent skip”
  • Status: planned
  • Example: given a v1 row whose file link returns nothing, when the photo copy runs, then that row is listed as unmatched in the reconcile report, and counts until it is signed as an accepted difference (D18).
  • Refusal: none.
  • Who: the migration's photo copy and its reconcile check.
  • Source: D60.

R-STO-12 · An app user can't overwrite or delete a stored file

Section titled “R-STO-12 · An app user can't overwrite or delete a stored file”
  • Status: planned
  • Example: given a KTP scan stored for driver Budi, when an admin_driver uploads a new scan to the same path, or deletes the stored one, then it is refused and the stored file stays as it was; uploading the new scan at a new path and saving that path on the document row goes through (R-STO-04).
  • Refusal: none: Storage refuses it, as storage.objects has policies for select and insert only (insufficient_privilege (42501) on an overwrite; no effect on a delete).
  • Who: every app user, super_admin included. Removing a file is never an app action (D65): only a database function does it, as anonymizing a driver does (R-DRV-26).
  • Source: #59 (item 4: built, as storage.objects has select and insert policies only); #189; D14; D65 (erasing is never an app action). It is planned until a test cites it; the generated Storage page will list the Storage policies (BE, #59).

R-STO-13 · The photo copy attaches a v1 file to a v2 record only when it can tell which one: by the v1 row that names the file, then by its owner and a one-of-a-kind label, then by its owner and day when exactly one record fits

Section titled “R-STO-13 · The photo copy attaches a v1 file to a v2 record only when it can tell which one: by the v1 row that names the file, then by its owner and a one-of-a-kind label, then by its owner and day when exactly one record fits”
  • Status: built
  • Example: given a checkpoint photo named in v1's checkpoints row 4120, then it goes on that checkpoint's v2 inspection; a car's STNK photo, one per car, goes on that car's STNK document by its label; a bc photo named by no row goes on the driver's background check from that day when the driver has exactly one check that day. When two v1 rows name the same file, the one whose owner matches the file's folder wins.
  • Refusal: none.
  • Who: the migration's photo copy (data phase row 6). The file's type comes from Storage, not from its name.
  • Source: D70; the CTO's approval on #184 (2026-10-21: the order, and each folder's labels).

R-STO-14 · A v1 file whose owner is certain but which no v2 record can hold is kept as a file from v1, on its driver or its car, with its v1 folder and label, the time it was taken, its type and size, and its D14 path

Section titled “R-STO-14 · A v1 file whose owner is certain but which no v2 record can hold is kept as a file from v1, on its driver or its car, with its v1 folder and label, the time it was taken, its type and size, and its D14 path”
  • Status: built
  • Example: given a bc photo whose driver had two checks on its day, then it is a file from v1 on that driver, with folder bc and its label, never on either check; a migrated car's front photo (v1's vehicle folder, label depan), which v2 would take in a first preparation inspection the car never had, is a file from v1 on the car with label depan.
  • Refusal: none.
  • Who: the migration's photo copy. A file whose owner itself can't be told is copied too, to the place for unmatched v1 files (R-STO-22).
  • Source: D70 (the record is uncertain, or v2 has no record of that kind); D14; #184.

R-STO-15 · Only the migration writes a file from v1; no app user adds, changes or deletes one or its file

Section titled “R-STO-15 · Only the migration writes a file from v1; no app user adds, changes or deletes one or its file”
  • Status: built
  • Example: given a file from v1 on driver Budi, when a super_admin edits its label, deletes it, or uploads a new one to the table, then nothing changes; its file can't be overwritten or deleted either (R-STO-12).
  • Refusal: none: no policy lets an app user insert, update or delete; Storage refuses the overwrite.
  • Who: every app user, super_admin included. Removing one is never an app action (D65), except anonymizing (R-STO-19).
  • Source: D70 (files from v1 are read-only in v2; only the migration writes the table).

R-STO-16 · A file from v1 out of v1's bc or driver folder is readable by whoever may read its driver's documents

Section titled “R-STO-16 · A file from v1 out of v1's bc or driver folder is readable by whoever may read its driver's documents”
  • Status: built
  • Example: given a file from v1 in folder bc on a PML driver, then an admin_driver or a satpam at PML (who reads that driver's documents) sees it on the driver's page, and a satpam at SBY doesn't; a contract PDF from the driver folder is read the same way.
  • Refusal: none: hidden.
  • Who: holders of driver:read, screening:read, onboarding:read, booking:read, payment:read, inspection:read, gate:read or debt_letter:read at the driver's pool, as for reading the driver (R-DRV-15); a member without the flag sees none, as for the driver's documents (R-ACC-46). Those who read a driver see the driver's NIK and phone in full (D31), so a KTP photo here is within D31.
  • Source: D70 (a background-check or contract file needs what the driver's documents need); D99 (a member with an empty list now sees none, where one with no list had no limit).

R-STO-17 · A file from v1 out of v1's payment or rebate folder is readable by whoever may read payments, at its driver's pool

Section titled “R-STO-17 · A file from v1 out of v1's payment or rebate folder is readable by whoever may read payments, at its driver's pool”
  • Status: built
  • Example: given a payment proof kept as a file from v1 on a PML driver, then a finance user at PML sees it, and an admin_driver at PML, who holds no payment:read, doesn't.
  • Refusal: none: hidden.
  • Who: holders of payment:read at the driver's pool (R-MON-29). A proof shows no margin or company amount, so payment:margin isn't needed (D31).
  • Source: D70 (a payment or rebate file needs what payments need).

R-STO-18 · A file from v1 out of v1's vehicle, checkpoint, asuransi or etle folder is readable by whoever may read its car

Section titled “R-STO-18 · A file from v1 out of v1's vehicle, checkpoint, asuransi or etle folder is readable by whoever may read its car”
  • Status: built
  • Example: given a migrated car's fuel-gauge photo kept as a file from v1 (label bbm), then a checker or a satpam at the car's home pool sees it on the car's page, and the label reads bbm; a user scoped to another pool doesn't.
  • Refusal: none: hidden.
  • Who: holders of vehicle:read, gate:read, fleet_monitor:read, inspection:read, work_order:read or insurance:read at the car's home pool, as for reading the car (R-VEH-14 to R-VEH-17); a member without the flag sees only the files of their rental companies' cars (R-ACC-43, R-ACC-44).
  • Source: D70 (a car, checkpoint, insurance or ETLE file needs what the car needs); D99 (a member with an empty list now sees none, where one with no list had no limit).

R-STO-19 · Anonymizing a driver deletes their files from v1

Section titled “R-STO-19 · Anonymizing a driver deletes their files from v1”
  • Status: planned
  • Example: given driver Budi with three files from v1 in folder bc and one in payment, when app.anonymize_driver() runs for them, then those files are gone from Storage and their file-from-v1 rows hold no path; a car's files from v1 stay.
  • Refusal: none.
  • Who: app.anonymize_driver(), as for their documents (R-DRV-26).
  • Source: D70 (files from v1 are a driver's files under D15); R-DRV-26.

R-STO-20 · The photo copy's reconcile counts, per v1 folder, the files attached to a record, the files kept as files from v1, the unmatched files held, and the files not copied; only the last is a difference to explain

Section titled “R-STO-20 · The photo copy's reconcile counts, per v1 folder, the files attached to a record, the files kept as files from v1, the unmatched files held, and the files not copied; only the last is a difference to explain”
  • Status: built
  • Example: given v1's checkpoint folder with 31,483 files, when a rehearsal's reconcile runs, then it reports for that folder how many went on an inspection, how many became files from v1, how many are held as unmatched (R-STO-22), how many are waiting for their step (R-STO-23), and how many weren't copied because they couldn't be read; the night is clean only when every file not copied is signed as an accepted difference (D18). The report lists the held files per folder, so they can be reconciled later.
  • Refusal: none.
  • Who: the photo copy's reconcile (data phase row 6).
  • Source: D70; D18; R-STO-11; zuki on #254 (2026-10-22: unmatched files are copied and reconciled later).

R-STO-21 · A record from before 2026-08-24 is expected to have no v1 photos, and the reconcile doesn't count it as missing

Section titled “R-STO-21 · A record from before 2026-08-24 is expected to have no v1 photos, and the reconcile doesn't count it as missing”
  • Status: planned
  • Example: given a v1 checkpoint from 2025-03-10, when the reconcile runs, then the checkpoint's missing photos are not reported as files not copied; they are covered by one accepted difference, whose reason says v1 kept no photos before 2026-08-24.
  • Refusal: none.
  • Who: the photo copy's reconcile.
  • Source: zuki on #184 (2026-10-22: v1's data starts in August 2024, but its photos were not kept anywhere before 2026-08-24); D18.

R-STO-22 · A v1 file whose owner can't be told is still copied, to a place for unmatched v1 files that no app user can read, with its v1 folder, name, time, type and size

Section titled “R-STO-22 · A v1 file whose owner can't be told is still copied, to a place for unmatched v1 files that no app user can read, with its v1 folder, name, time, type and size”
  • Status: built
  • Example: given a file in v1's payment folder under a driver name that matches no v2 driver, when the photo copy runs, then the file is copied and held as an unmatched v1 file, with folder payment, its v1 name and the time it was taken; it shows on no driver's or car's page, and the reconcile lists it (R-STO-20). When a later run can tell its owner, it is attached or kept as a file from v1 (R-STO-13, R-STO-14) and leaves the unmatched place.
  • Refusal: none.
  • Who: the migration's photo copy writes it; no app user reads, changes or deletes one (R-STO-12, D65). Whether it is a table, a folder or both is BE's choice in the table pack before row 6.
  • Source: zuki on #254 (2026-10-22: "the non-matched data still need to be copied but under dedicated table or folder, which later can be reconcile"); D60 (every v1 file moves); D70 covers files whose owner is certain.

R-STO-23 · A v1 file whose owner or record is loaded by a step that hasn't run that night is counted as waiting for its step, never kept as a file from v1

Section titled “R-STO-23 · A v1 file whose owner or record is loaded by a step that hasn't run that night is counted as waiting for its step, never kept as a file from v1”
  • Status: built
  • Example: given v1's checkpoint photos on a night when the vehicles step has run but the operations step hasn't, when the photo copy runs, then each is counted as waiting for the operations step, not kept as a file from v1 on its car (R-STO-14); the next night the operations step runs, they attach to their inspections (R-STO-13). A waiting file's bytes are already held (R-STO-24), and it isn't a difference to explain (R-STO-20).
  • Refusal: none.
  • Who: the photo copy (data phase row 6), which runs after row 5's steps in a night.
  • Source: the CTO on #262 (2026-10-22: copy every file now, attach only to records already loaded); D70 (a file is kept as a file from v1 only when no v2 record can hold it); #287.

R-STO-24 · Every v1 file's bytes are copied to v1-hold, a private bucket no app user can read, under its v1 object id, before the photo copy places it

Section titled “R-STO-24 · Every v1 file's bytes are copied to v1-hold, a private bucket no app user can read, under its v1 object id, before the photo copy places it”
  • Status: built
  • Example: given a v1 file payment/budi/transfer 12 okt.jpg, when the photo copy runs, then its bytes are first held in v1-hold under its v1 object id; when it is attached or kept as a file from v1, it is copied from there to its D14 path as <object id>.<extension>, so no v2 path carries v1's file name. A later night skips a file already held at the same size, and a file already at its D14 path, as Storage lists it, isn't read from v1-hold again and is never overwritten.
  • Refusal: none.
  • Who: the photo copy, reading v1 as its read-only login (D68). No Storage policy names v1-hold, so no app user reads or writes it (R-STO-12).
  • Source: D60 (every v1 file moves; v2 is private); D68; the CTO on #262 (2026-10-22: copy every file's bytes now); #287; D65 (erasing is only a named function, and an overwrite would erase the placed file); #591 (the place step's skip).

R-STO-25 · The vehicles bucket accepts only JPEG and PNG images (image/jpeg, image/png), up to 10 MB a file

Section titled “R-STO-25 · The vehicles bucket accepts only JPEG and PNG images (image/jpeg, image/png), up to 10 MB a file”
  • Status: built
  • Example: given a car photo upload, when the file is a HEIC image, a PDF or a 12 MB JPEG, then Storage refuses it; a JPEG or PNG of 10 MB or smaller is accepted. The bucket is private (R-STO-01).
  • Refusal: none: Storage refuses the upload because the type or the size isn't allowed.
  • Who: every upload to the vehicles bucket, which holds car photos (R-VEH-55).
  • Source: #745; zuki, 2026-11-24; D110; D14; R-STO-06 for the documents bucket.