// CONTENTS Part 05 · Data and persistence

// PART 05

Drive and Drive compiler

Chapter 23 / 56 3 min read English Part 05 of 14

Drive is the bot file system: an S3-compatible object store (botdrive crate) that the runtime reads bots from; the local filesystem holds only the work copy that the monitors materialize. Nothing in the product addresses a bot through a local path.

Two bucket layouts

Both layouts are real in production, so a bucket cannot be derived from a bot name alone — the organization and the branch decide (botbasic_core/src/utils/mod.rs):

Layout Bucket Key prefix for one bot
Standalone {bot}.gbai {bot}.gbdialog/, {bot}.gbot/, {bot}.gbkb/, {bot}.gbdrive/ at the bucket root
Org workspace {tenant}.gborg {branch}.gbai/{bot}.gbdialog/ and siblings

In the org layout a bucket holds an organization, a .gbai/ prefix holds one workspace (branch), and every bot is a set of sibling directories inside that workspace — there is no per-bot bucket.

What lives in each bot directory

Directory Contents Notes
{bot}.gbdialog/ BASIC scripts and tools, compiled to .ast for git-owned bots this is a materialized copy of the bot’s ALM repository; the Drive copy is archived, never read
{bot}.gbot/ Channel prompts (PROMPT-*.md) and config.csv same repository rule as .gbdialog
{bot}.gbkb/ Knowledge-base source documents the only home of a bot’s knowledge files
{bot}.gbdrive/ User files, media, generated artifacts conventions (conversations/, media/, inbox/, …), not a schema
{bot}.gbdrive/.versions/ file history newest 20 revisions kept, older pruned

The monitors

main_module/drive_monitors/ lists the object store at boot and then on a loop — every 30 s by default, override with DRIVE_SCAN_INTERVAL. Only buckets ending in .gborg are processed by the org scanner; a bot is recognized from a top-level {bot}.gb<marker> directory (.gbdialog, .gbot, .gbkb, .gbdrive). Per-bot monitors recompile scripts and reload configuration on ETag change (~10 s), which is why config.csv edits never need a server restart. git_bot_monitor/ pulls git-owned bots every 15 s.

The Drive UI does not guess the bucket: it asks GET /api/files/bucket for the authoritative bucket and key prefix of the bot it is showing.

The Drive compiler

botserver/src/drive/drive_compiler.rs (DriveCompiler) is the component that turns the materialized bot tree into runtime artifacts: BASIC sources to .ast, tool headers into tool definitions, configuration into per-bot state. It works on the work copy the monitors produce, and keeps a one-hour missing-log registry purely to suppress duplicate warnings — it holds no user-visible state.

Privacy and access

  • Private by default. No public bucket, no direct-to-S3 URL for clients. Bytes reach a browser through botserver, gated by revocable share links (drive_public_links); a revoked or expired link answers exactly like an unknown one, and any write/move/delete of the object revokes its links.
  • Per-user files use two separate scopes. The Drive app’s My Files uses bucket user-{id} with prefix users/{id}/; Paper documents use the instance bucket with users/{owner}/papers/…. Treating them as one folder is the most common integration mistake.
  • Limits. Drive upload body 100 MiB, file name 180 characters, KB import body 50 MiB (botsecurity-core/src/upload_policy.rs). Quota reporting is informational only.

Backends

Backend backend key Notes
OtterIO (self-hosted, default) otterio no egress charge
Backblaze B2 b2 region required for signing
Cloudflare R2 r2 region required for signing
Wasabi wasabi 1 TB floor + 90-day retention; the code logs why it is unsuitable for runtime buckets

Credentials come from Vault secret/gbo/drive (accesskey, secret, bucket, optional endpoint/region/fallback_endpoint); environment equivalents (OTTERIO_ACCESS_KEY, …) are the fallback. A configured fallback_endpoint is used for reads only, after the primary fails — a write is never silently redirected.

REST surface

The Drive families under /api/files/* (list, write, versions, quota, share links) are in the generated API reference; the versions endpoints are POST /api/files/versions/list and POST /api/files/versions/restore.

Found a mistake? Open an issue · All books

// SEARCH ESC
Pagefind · 236 pages · 4 books Enter to open ↑ ↓ to move