Overview
apps/drive is the canonical Tuturuuu Drive application. Production Drive
traffic should use https://drive.tuturuuu.com/{wsId} instead of rendering the
Drive explorer inside apps/web.
apps/driveowns the workspace shell, Drive explorer UI, local/verify-tokenhandoff, and local app-session logout.apps/web /{wsId}/driveremains a compatibility route. It checksmanage_drive, preserves the query string, and redirects to the Drive app.- Drive uses local port
7817and Portless hostdrive.tuturuuu.localhost.
Native mobile directory behavior
The mobile Drive screen uses the shared floating dock for search, view, sort, and permission-gated actions. Search temporarily occupies the shared search surface rather than adding a second search field to the directory body. Closing search clears its query and reloads the current directory. Drive opens in a compact list. Use the view action to switch to a grid. Inside a folder, the navbar shows the folder name and the folder-path action opens a picker with each ancestor. The floating Back control goes up one folder. Long-press a file or folder to start selection, then tap other entries to add them. Done clears the selection. Workspace members withmanage_drive can
delete selected entries and open Storage usage to see workspace file count,
used space, and the limit when one is available.
Directories retain their visible entries during refresh. Additional pages load
when the viewport is within 400 logical pixels of the end, including directories
that initially do not fill the viewport; the explicit load-more action remains
available. Appended entries are deduplicated by name within the current directory.
Workspace or account changes clear search, selection, and the previous directory.
Late responses and signed-file actions cannot restore or open content from the
previous account, workspace, or request generation. Definitive authorization
failures clear displayed files; verification challenges and temporary failures
retain the current view. This includes MFA_REQUIRED responses identified by
the API error code even when the typed verification flag is absent; the challenge
message remains visible, and a subsequent definitive denial still clears entries.
Regression coverage: apps/mobile/test/features/drive/drive_page_test.dart.
Move entries between folders
On mobile, choose Move to folder from an entry menu or start selection with a long press and move several entries together. The folder picker runs within the selected workspace. It omits selected folders so their descendants cannot be destinations. Moves requiremanage_drive.
The protected move API accepts up to 20 entries, 64 stored objects (including
empty-folder markers), and 2 GiB per request. Preflight verifies object sizes and
checks for destination conflicts before any write. The move also checks each
destination folder before starting it and each destination key before moving
the corresponding object. Supabase rejects concurrent writes to the same key.
Unrelated files added after a folder move starts can remain alongside the moved
files.
If a move fails after execution begins, the response identifies completed,
stopped, and skipped entries. The mobile result shows the number of visible
files confirmed moved and the reason the move stopped. If the outcome is unknown,
inspect both folders before trying again.
The move endpoint supports Supabase workspaces. R2 workspaces receive an error
before mutation because an R2 copy followed by a delete cannot condition that
delete on the source version. The API rejects cross-workspace moves and
destinations in private application storage. Route and widget tests cover the
authorization boundaries, collisions, partial results, and picker behavior.
API Ownership
Protected storage APIs remain centralized inapps/web:
apps/driveforwards/api/*traffic toapps/web.- Client Drive data flows must use
@tuturuuu/internal-apihelpers with TanStack Query. - Do not create direct Supabase browser reads or storage mutations in
apps/drive. apps/webstorage routes authenticate normal web sessions and Drive app-session cookies through the shared storage route auth helper, then enforcemanage_driveor the route-specific permission fallback.
apps/web, expose it
from packages/internal-api, and consume it from apps/drive.
Export link lifetime and revocation
Folder export links are bearer credentials: anyone holding one can read ordinary Drive files under that exact folder, including files added after issuance. This applies to exports created through Web and the Drive satellite, with either Supabase or R2 as the file provider. Private application roots remain excluded. New exports expire seven days after issuance.DRIVE_EXPORT_LINK_TTL_SECONDS
can select a lifetime of at least one second, capped at 30 days. Unset, zero,
negative, non-finite, and invalid values use seven days; zero never means
unlimited. The signed token fixes the expiration at issuance, so increasing the
environment value cannot extend existing links. Legacy version-one tokens are
refused; regenerate existing exports after deploying this change.
A current workspace folder manager (manage_drive, including owners with that
permission) can revoke all existing exports for one folder with authenticated
DELETE /api/v1/workspaces/{wsId}/storage/export-links, JSON body
{"path":"exports/site"}. The Drive export dialog offers Revoke and replace
links, which revokes the old links and requests a new export. New exports
created after revocation work normally.
Revocation covers that exact folder, not independently exported parent or child
folders. Removing a member does not automatically revoke their exports; a manager
must revoke the affected folders. Copies already downloaded cannot be withdrawn.
Each folder has a random revocation version stored in the existing private
workspaces Supabase bucket at
{wsId}/.tuturuuu/drive-export-revocations/{sha256(folderPath)}. The control
registry uses Supabase even when exported assets use R2. Issuance creates a missing
marker with insert-only semantics. Revocation replaces the marker. Every
issuance and asset fetch reads the marker without caching. Missing markers at fetch time and all other
read failures fail closed. Marker writes are service-only, behind the
authenticated permission check. Retain these small control objects during storage cleanup and provider
migration: deleting a marker invalidates existing links; subsequent exports
initialize a different version.
The existing private-root Storage RLS migration
20261026170000_least_privilege_workspace_storage_rls.sql must be applied before
release so direct member Storage access cannot modify these markers. No new
schema migration or signing-secret rotation is required for folder revocation.
Expired or revoked links return HTTP 410 with no asset URL or file data. Invalid
or legacy tokens return 404. Asset redirects and rejection responses are not
cached. Each underlying signed read lasts at most 15 minutes. A signed read
issued before revocation remains usable until its own deadline; revocation prevents subsequent signed reads.
Regression coverage: storage-core workspace-storage-export-links.test.ts and
Web’s active storage/export-links/route.test.ts and
storage/export/[token]/[...assetPath]/route.test.ts. Tests exercise the real HMAC
and clock rules, with isolated Storage adapters; hosted Storage/RLS and browser
acceptance remain release checks.
Private attachment boundaries
Drive permissions apply to ordinary Drive files. They do not grant access to application-owned chat attachments. In every workspace, Drive share, download, list, export, upload, rename, and delete boundaries reserve the root nameschat,
chats, external-apps, AI Agent Imports, recordings, .tuturuuu, and
topic-announcements for their owning applications. Root matching is
case-insensitive, including both segments of mira/images, in every workspace.
The Drive and signing policies share workspace-storage-roots.ts, matching
RLS’s lowercase segment comparison without trimming segment whitespace or
matching name prefixes. Drive keeps its existing relative-path sanitization
(leading slashes, backslashes, and repeated separators); the signing mirror and
RLS validate exact full object names and reject empty slash-delimited segments.
Only the two-segment prefix mira/images is reserved for Mira image results; mira itself and ordinary files such as mira/notes.txt remain available.
Root/directory listings and Drive analytics omit private objects; quota accounting
continues to count their bytes. Exports omit private descendants. Recursive Drive
renames/deletes validate every enumerated object before any mutation, so a parent
operation cannot expose or remove mira/images. A mira folder containing only
ordinary files can be renamed or deleted normally.
This applies to Web, the Drive satellite, mobile Drive, and API-key storage APIs.
Even an attachment’s owner must use the owning application API for these paths.
Chat and Mind APIs retain their own ownership and content checks, including
quarantine; Drive cannot mint an alternate URL for a rejected attachment.
Normal Drive files and the existing finance/task-specific permission rules stay
available. Meet files intentionally saved into the owner’s personal Drive retain
that behavior.
Regression coverage: the Web workspace storage share/list route tests,
legacy-api-routes/v1/storage/reserved-paths.test.ts, and storage-core
drive-path-policy.test.ts / storage-analytics.test.ts.
Private upload census
Paths below are relative to<wsId>/ in the workspaces bucket. The owning
application must authorize reads; Drive permissions do not replace that check.
These source locations are the upload contracts for the separate Storage RLS lane.
Mobile voice attachments use the same AI/native upload flow through
apps/mobile/lib/features/assistant/data/assistant_repository.dart:536 (uploadAttachment, delegating to assistant_attachment_upload.dart);
there is no additional voice-only workspace storage root. Notes voice analysis
accepts request audio without a workspaces object upload.
Intentional Drive outputs remain accessible: drive/mira/qr/ is explicitly saved
to Drive (packages/ai/src/tools/executors/qr.ts:114), and Meet room files and
recordings use the creator’s personal Drive (packages/meet-core/src/routes/api/meet-call/[meetingId]/files/route.ts:38
and sibling recording/route.ts:43). See the Meet call recording decision.
Profile/report buckets and workspace-wide branding/template/whiteboard assets,
task-images, project-updates, and forms are outside this private chat/media
namespace policy.
Mira generated image reads
mira/images/ stays service-only in the bucket RLS. Neither Drive nor workspace
members can sign it directly. Chat history signs each generated image on read:
- Client. The Web chat UI asks
POST /api/ai/chat/signed-read-urlto sign the tool output’sstoragePath. The query refreshes every 50 minutes, within the URL’s 1-hour lifetime. - Server check. The route signs a direct
<wsId>/mira/images/<file>object only for a current workspace MEMBER who generated it. The generator is theuser_idon the image’simage_generationAI credit transaction, matched onmetadata.storagePath. - Denials. Every other member, any non-member, nested or encoded paths, and
drive/mira/qr/are rejected. - Fallback. The stored
imageUrlis used only while signing is pending or for outputs that have nostoragePath.
mira/images
re-key run.
Regression coverage:
- storage-core
mira-image-access.test.ts. - Web
app/api/ai/chat/mira-image-read-access.test.ts. - The chat
use-generated-image-url.test.ts. - internal-api
ai.test.ts.
Reserved-name collision check
A user-createdrecordings root folder could plausibly collide with the reserved
meeting prefix: older generic folder/upload APIs allowed arbitrary root names,
and objects beneath a user-selected recordings folder use the same namespace.
This is source reasoning only; no production inventory was read and no collision
is confirmed. Keep recordings reserved. A later approved operator check should
inventory that prefix, distinguish meeting/session objects from user-created
files, and plan reference-preserving relocation for any collisions. Do not infer
ownership from the folder name or automatically move/delete matching objects.
Signed URL lifetime decision
-
Rule: new signed read URLs for workspace storage default to one hour
(3,600 seconds) and never exceed seven days (604,800 seconds).
clampSignedUrlTtlin@tuturuuu/storage-core/signed-url-policyenforces this. Requests above the cap (up to the previous one-year maximum) are clamped, not rejected. -
Where the clamp runs:
- The workspace share route (POST and the GET redirect). Its default changed from one year to one hour.
createGuardedSupabaseStorageReadUrl, which signs every Supabase read URL fromcreateWorkspaceStorageSignedReadUrl, the SDK share and share-batch routes, and the download route. The SDK routes also validate at most seven days, with a one-hour default.- Mira tool outputs: generated images (
mira/images/) and QR codes (drive/mira/qr/). These were 30 days and are now seven days. The output includesstoragePathso callers can re-sign.
-
Fixed short lifetimes: every other app-side
createSignedUrlorcreateSignedUrlscall on theworkspacesbucket passes a constant of one hour or less and is not clamped further. That covers:- the managed-contact avatar read route (one hour, or the public URL);
- AI chat attachment routes;
- task/project-update attachments (15 minutes);
- workspace branding and logos (15 minutes);
- whiteboards, forms media and templates;
- meeting recordings and time-tracking images.
createSignedUrlandcreateSignedUrlsfound no app-side signer above seven days after this change. -
Not clamped by this helper: R2 presigned URLs from
createWorkspaceStorageSignedReadUrl. They default to 15 minutes, and SigV4 presigning rejects lifetimes above seven days. Client-side defaults (the mobile Drive repository, the SDK and internal API helpers) are only requests; the server applies the cap. -
Redirect caching: the share GET redirect sends
Cache-Control: private, no-store, so its short-lived Location is not cached. -
No stored bearer URLs: anything that must stay readable longer stores the
object path and signs on read.
- Embedded images use the share route’s GET redirect
(
/api/v1/workspaces/<wsId>/storage/share?path=…), which re-checks access and issues a fresh one-hour URL. Task media and document images both work this way. - Task/project-update attachments store
file_pathand return a 15-minute URL. - Managed-contact avatars return the stable public URL of the
avatarsbucket (no token). Legacy avatars in the private bucket get a one-hour URL and must not be stored.
- Embedded images use the share route’s GET redirect
(
-
Existing stored URLs: documents rewrite stored signed
workspacesimage URLs to the share redirect when they load, so images stay readable after the old token expires.- Stored avatar URLs and other copies stay valid until their original expiry.
- Nothing is revoked or re-keyed by this change.
- Affected surfaces: Drive share links, SDK share APIs, Web documents, Tasks attachments and media, Contacts and mobile CRM avatars, and Mira image and QR results.
-
Regression coverage:
packages/storage-core/src/lib/signed-url-policy.test.tspackages/storage-core/src/lib/storage-download-sign.test.tsapps/web/src/app/api/v1/workspaces/[wsId]/storage/share/route.test.tspackages/users-core/src/routes/users/avatar.test.tspackages/ai/src/tools/executors/image.test.tsandqr.test.tsapps/web/src/app/[locale]/(dashboard)/[wsId]/documents/[documentId]/document-image-sources.test.ts
Previously issued signed URLs
The workspace share route used to default to 31,536,000 seconds (one year), so some issued URLs may stay valid for up to a year. A shorter default does not revoke them. Denying new requests does not revoke bearer URLs already issued for private objects, and direct Supabase Storage access is governed by the workspace storage RLS. Remediation is an approval-required operator action: inventory exposed object keys and references, copy/re-key or move each object to a new unpredictable key, verify the replacement and update owning-application references, then retire the old key only after the replacement is durably confirmed. Account for provider/CDN caches and verify that each previously issued URL no longer serves bytes before claiming revocation. Preserve ownership, consent, retention, and deletion rules. No object move, removal, key rotation, or production write is authorized or run by this implementation PR. Obtain explicit per-case approval before execution.CI/CD
Production runs on the Drive Cloudflare Worker; Vercel receives no deploys.Validation
Use these focused checks when changing Drive deployment wiring:bun validate or app builds on the shared machine.
Storage access decision
- Scope: every object in the
workspacesStorage bucket, reached directly through the Supabase Storage API with a user token. Server APIs that use the service role are unaffected. - Default: direct access follows the app layer. A Drive object is readable
with
view_driveormanage_drive. Writes and deletes requiremanage_drive. Plain membership no longer grants Drive access. - Private roots:
chat/**andchats/ai/resources/**are private to the chat creator (or, fortemp/<userId>/**, the uploader). Owners can read and delete their own objects, but nobody writes them directly. Otherchats/**,external-apps/**,AI Agent Imports/**,mira/images/**,recordings/**,topic-announcements/**and.tuturuuu/**objects have no direct client access. - Affected surfaces: Web, Rewise and Mind AI chat attachments now upload
through
POST /api/ai/chat/upload-url. It enforces chat ownership and issues a signed upload URL. Meeting recording routes use the service role after their checks. The Drive app and SDK keep their server-side checks. - Intentional exceptions:
project-updates/**stays member-wide, matching its request-scoped route.template-backgrounds/**is member-readable for template pickers.drive/mira/qr/**is an intentional Drive output. - Evidence: the matrix, rollback and verification steps are in Workspace storage RLS.
Start candidate staging cookies and authentication
The unprovisioned Start candidate remains restricted to the exact Drive staging host. Candidate response cookies stay host-only, including__Host- rotations and deletions. The response policy and Worker exit reject
every outgoing Domain cookie rather than rewriting it to a parent domain.
Production cookie behavior is unchanged. Global Supabase and shared-cookie
configuration remains deferred to the issuer migration.
Unauthenticated pages redirect to central staging login through a Drive
verify-token return URL that retains the original destination. Unauthenticated API requests return 401 before Start or upstream
forwarding. src/start-candidate/worker-auth.test.ts runs the real Drive proxy,
shared auth and bridge with fixture Start/RSC and provider adapters;
staging-policy.test.ts and Supabase’s staging-cookie-domain.test.ts cover
cookie rotations, deletions, Domain rejection and production parity. Hosted login and provider
sessions still require staging acceptance before publication.
Mobile offline directory preparation
Mobile preparation is opt-in behindmobile_offline and
offline_read_drive_list, both default OFF. It retains the default root page
for the current account/workspace without downloading files. Other cached
directories, searches and pages survive preparation. Workspace permission and
access-denial fences still apply; this does not grant new access. Regression:
drive_offline_preparation_test.dart opens the real cold page offline and
checks preservation of a directory outside the prepared page.