Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.
Single VM Deployment
This is the first deployment target for DBBASIC Object Server: one small VM, one ASGI process, one object source directory, and one data directory.
The goal is not to claim the public runtime is production-ready. The goal is to keep a clean staging server running so install, restart, logs, object storage, and the edit/run/inspect loop are tested on a real machine.
This shape should stay cheap and understandable: one small VM can run the server, objects, TSV-backed state, logs, versions, HTTPS proxy, and monitoring without requiring a separate database tier for the first useful app.
Deployment Goal
The first deployment path should stay closer to a simple Unix/PHP-style upload than a large multi-service app stack:
- one VM is enough for the first useful business app
- no container runtime is required for the base deployment
- no separate database server is required before the app proves itself
- server code, live object source, runtime data, and secrets live in separate
Unix paths
- normal upgrades are
git pull, package install, service restart, checks - object edits do not require a full server redeploy
- every manual step should become scriptable after it stays boring
This does not mean skipping safety. The simple path still uses a service user, systemd, a reverse proxy, HTTPS, private config, filesystem checks, backups, and explicit public route allowlists.
Verified Baseline
The first staging install was verified on:
- Ubuntu 24.04.4 LTS
- Python 3.12.3
- Git 2.43.0
- Caddy 2.11.4
- systemd with the DBBASIC service and Caddy running as separate units
Record the baseline on each new VM. Run the Caddy commands after Caddy is installed, if the VM does not already have it.
lsb_release -a
python3 --version
git --version
caddy version
systemctl is-active dbbasic-object-server caddy
cd /opt/dbbasic-object-server
sudo -u dbbasic git rev-parse --short HEAD
Do not commit the VM's real IP address, hostname, or provider-specific details to this repository.
System Updates
Before using a new VM for staging, apply normal OS updates and reboot if Ubuntu requests it:
sudo apt update
apt list --upgradable
sudo DEBIAN_FRONTEND=noninteractive apt-get upgrade -y
sudo DEBIAN_FRONTEND=noninteractive apt-get autoremove -y
test -f /var/run/reboot-required && cat /var/run/reboot-required || true
If packages are kept back because they need new dependencies, install them explicitly when they are normal platform packages:
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y fwupd
After a reboot, verify the services and endpoint again:
sudo systemctl is-active dbbasic-object-server caddy
curl https://dbbasic.example.com/
Provider Monitoring
For DigitalOcean Droplets, the metrics agent is useful on staging VMs because it adds CPU, memory, disk, and network graphs plus alerting while the server is under active development. DigitalOcean describes this as a free opt-in service. It sends system telemetry for monitoring, not customer content.
Install it after normal OS updates:
curl -fsSL https://repos.insights.digitalocean.com/install.sh -o /tmp/do-agent-install.sh
sudo bash /tmp/do-agent-install.sh
Verify it:
systemctl is-active do-agent
systemctl is-enabled do-agent
dpkg-query -W do-agent
systemctl --no-pager --full status do-agent
Metrics usually appear in the Droplet's Insights tab after a few minutes. This is provider-specific VM monitoring; it does not replace DBBASIC's own object logs, state, versions, or future application/runtime metrics.
Layout
Use separate paths for server code, object source, and runtime data:
/opt/dbbasic-object-server
/var/lib/dbbasic-object-server/objects
/var/lib/dbbasic-object-server/data
/opt/dbbasic-object-serveris the git checkout./var/lib/dbbasic-object-server/objectscontains live object source files./var/lib/dbbasic-object-server/datacontains state, logs, and versions.
objects and data are mode 0700, owned by dbbasic: user objects run as a second user, dbbasic-sandbox, which must not be able to traverse, stat or chmod anything in them (see "Kernel Requirements for User Code").
Keeping objects and data outside the checkout lets the server be upgraded without mixing application data into git history.
Install
On a fresh Debian or Ubuntu VM:
sudo apt update
sudo apt install -y python3 python3-venv python3-pip git
sudo useradd --system --home /var/lib/dbbasic-object-server --shell /usr/sbin/nologin dbbasic
sudo mkdir -p /opt/dbbasic-object-server
sudo mkdir -p /var/lib/dbbasic-object-server/objects
sudo mkdir -p /var/lib/dbbasic-object-server/data
sudo chown -R dbbasic:dbbasic /opt/dbbasic-object-server /var/lib/dbbasic-object-server
sudo chmod 755 /opt/dbbasic-object-server
sudo chmod 750 /var/lib/dbbasic-object-server
sudo chmod 750 /var/lib/dbbasic-object-server/objects
sudo chmod 750 /var/lib/dbbasic-object-server/data
Clone and install the server:
sudo -u dbbasic git clone https://github.com/askrobots/dbbasic-object-server.git /opt/dbbasic-object-server
cd /opt/dbbasic-object-server
sudo -u dbbasic python3 -m venv .venv
sudo -u dbbasic .venv/bin/python -m pip install -e '.[server,scheduler]'
Environment
Create /etc/dbbasic-object-server.env:
DBBASIC_OBJECTS_DIR=/var/lib/dbbasic-object-server/objects
DBBASIC_DATA_DIR=/var/lib/dbbasic-object-server/data
DBBASIC_BACKUPS_DIR=/var/lib/dbbasic-object-server/data/backups
DBBASIC_PACKAGES_DIR=/opt/dbbasic-object-server/packages
DBBASIC_ENABLE_SOURCE_WRITES=false
# Non-admin users writing their own u_<id>_ objects. Keep false until user
# objects run sandboxed -- see "User objects and external identity" below.
DBBASIC_ENABLE_USER_SOURCE_WRITES=false
# An external token verifier (e.g. a DRF app's /api/auth/verify/). Unset = off.
# Must be a trusted internal service: every caller's token is sent to it.
# https:// is required unless the host is loopback (127.0.0.0/8, ::1, localhost).
# DBBASIC_IDENTITY_VERIFY_URL=http://127.0.0.1:8000/api/auth/verify/
# This server's name; the verifier must echo it as "audience" (required).
# DBBASIC_IDENTITY_AUDIENCE=box-a.example.com
# Shared secret sent as X-DBBASIC-Verify-Secret (required for a non-loopback URL).
# DBBASIC_IDENTITY_VERIFY_SECRET=<random, 16+ visible characters>
# Roles the verifier may confer (default: none; admin names never).
# DBBASIC_IDENTITY_VERIFY_ALLOWED_ROLES=viewer,editor
# Seconds a verified token is trusted before re-asking (default 30, at most 60). The app
# can also POST /admin/identity/sources/forget (admin token) on revocation.
# DBBASIC_IDENTITY_CACHE_TTL_SECONDS=30
DBBASIC_ENABLE_FILE_WRITES=false
DBBASIC_ENABLE_PACKAGE_INSTALLS=false
DBBASIC_ENABLE_PACKAGE_RESTORE=false
# AI chat, voice, and reader -- each is its own flag; enabling AI chat does
# NOT enable TTS/STT/reader. Each also needs a per-user provider key stored
# via PUT /identity/users/{id}/service-keys before it does anything -- see
# docs/shell-and-ai.md and docs/secrets-and-credentials.md.
DBBASIC_ENABLE_AI_CHAT=false
DBBASIC_AI_TIMEOUT_SECONDS=60
DBBASIC_AI_DEFAULT_MODEL=anthropic:claude-haiku-5-5
# Effort for conversation tool subsets and for builder mode
# (low|medium|high|xhigh|max); sent only to Claude 4.6+ models.
DBBASIC_AI_EFFORT=low
DBBASIC_AI_BUILDER_EFFORT=high
DBBASIC_ENABLE_TTS=false
DBBASIC_TTS_CLOUD_TIMEOUT_SECONDS=30
# STT costs real money on every utterance (not just occasional replies
# like TTS) -- leave this off even where TTS is on unless you mean it.
DBBASIC_ENABLE_STT=false
DBBASIC_STT_TIMEOUT_SECONDS=30
DBBASIC_ENABLE_READER=false
DBBASIC_ADMIN_TOKEN=replace-with-a-generated-token
DBBASIC_MAX_REQUEST_BYTES=1048576
DBBASIC_MAX_OBJECT_FILE_BYTES=1048576
DBBASIC_MAX_CONCURRENT_REQUESTS=64
DBBASIC_MAX_CONCURRENT_EXECUTIONS=8
# One customer's user objects may run this many at once (0 = no per-user cap).
# Over it, that customer alone gets 429; others are unaffected.
DBBASIC_MAX_CONCURRENT_EXECUTIONS_PER_USER=3
# Per-customer storage quotas for u_<id>_ objects (0 = unlimited each):
# objects owned, bytes of one object's state, bytes of all _files storage.
DBBASIC_USER_MAX_OBJECTS=100
DBBASIC_USER_MAX_STATE_BYTES=5242880
DBBASIC_USER_MAX_FILES_BYTES=104857600
DBBASIC_OBJECT_TIMEOUT_SECONDS=5
DBBASIC_WORKER_POOL_SIZE=2
DBBASIC_TRUSTED_IN_PROCESS_OBJECTS=site_home
DBBASIC_RATE_LIMIT_REQUESTS=1000
DBBASIC_RATE_LIMIT_WINDOW_SECONDS=60
DBBASIC_RATE_LIMIT_TRUST_PROXY_HEADERS=true
DBBASIC_ENABLE_PERMISSION_AUDIT=false
DBBASIC_ENABLE_PERMISSION_ENFORCEMENT=false
DBBASIC_PERMISSION_TRUST_HEADERS=false
# true = a stored allow rule whose narrowing key was dropped (a misspelt or
# null row_filter, collection, ...) grants nothing instead of applying more
# widely than written. Deny rules are untouched. Off by default; the default
# may turn on in a later release (docs/permissions-model.md).
DBBASIC_POLICY_FAIL_CLOSED_WIDENED_ALLOWS=false
DBBASIC_ENABLE_SESSION_LOGIN=false
DBBASIC_SESSION_LOGIN_TOKEN=
DBBASIC_ENABLE_PASSWORD_LOGIN=false
DBBASIC_COOKIE_SECURE=true
DBBASIC_LOGIN_LOCKOUT_ATTEMPTS=5
DBBASIC_LOGIN_LOCKOUT_WINDOW_SECONDS=900
DBBASIC_ENABLE_RECORD_EVENTS=true
DBBASIC_EVENT_KEEP_COUNT=1000
DBBASIC_EVENT_KEEP_SECONDS=604800
DBBASIC_LOG_MAX_BYTES=10485760
DBBASIC_LOG_COMPRESS_ROTATED=true
DBBASIC_LOG_KEEP_ROTATED=32
# Other feature gates worth knowing exist -- off by default, turn on what
# you actually use rather than everything at once.
DBBASIC_ENABLE_USER_FILES=false
DBBASIC_ENABLE_REALTIME=false
DBBASIC_ENABLE_SITE_ROUTES=false
DBBASIC_ENABLE_FEED=false
DBBASIC_ENABLE_FILTERING=false
DBBASIC_ENABLE_CONCURRENCY=false
DBBASIC_ENABLE_SESSION_ADMIN_GATES=false
# off | shadow | on. Makes a permission-filtered list cost what the user can
# see instead of the whole collection (docs/permissions-model.md#row-filter-index).
# Run `shadow` first: it serves the old result and logs any disagreement.
DBBASIC_ROW_FILTER_INDEX=off
# Copy new mail from members' own IMAP mailboxes into their inbox
# (app-mail-sync; see docs/http-api-contract.md#mail-sync-imap-inbound).
# The second line lets it reach mail servers on private addresses.
DBBASIC_ENABLE_MAIL_SYNC=false
DBBASIC_MAIL_SYNC_ALLOW_PRIVATE_HOSTS=false
Generate a local token on the VM:
python3 -c "import secrets; print(secrets.token_urlsafe(32))"
Use that generated value for DBBASIC_ADMIN_TOKEN. Do not reuse test tokens, README placeholders, or tokens from another server. It is required for local or admin object listing and introspection requests such as source, state, logs, metadata, and versions.
Bootstrap Browser Login
To enable browser login on a fresh VM, create the first admin user from the shell and turn on password login:
cd /opt/dbbasic-object-server
sudo -u dbbasic DBBASIC_DATA_DIR=/var/lib/dbbasic-object-server/data \
.venv/bin/python object_identity_cli.py create-superuser \
--user-id operator --email you@example.com
The password is prompted twice without echo and stored only as a scrypt hash under data/identity/credentials.tsv (owner-only permissions, inside the runtime data directory that never enters source control). Then set DBBASIC_ENABLE_PASSWORD_LOGIN=true in the environment file, restart the service, and allow /login and /logout through the reverse proxy. Keep DBBASIC_COOKIE_SECURE=true behind HTTPS; set it to false only for plain-HTTP local development. Additional users can be managed with the same CLI (create-user, set-password, list-users) or through the admin HTTP surface from Scroll.
For the first VM boot, leave source writes disabled. After health checks, backups, and proxy access are working, a staging server can enable source writes:
DBBASIC_ENABLE_SOURCE_WRITES=true
User objects and external identity
To let another app's users call this server with their own tokens, set DBBASIC_IDENTITY_VERIFY_URL to that app's verify endpoint on an internal address (https://, or http:// to a loopback host only), DBBASIC_IDENTITY_AUDIENCE to this server's name, and -- for a host that is not loopback -- DBBASIC_IDENTITY_VERIFY_SECRET. Those users can then run their own u_<id>_ objects and list theirs plus the system objects marked LISTED = True; they are never admin. Their code may call only system objects marked USER_CALLABLE = True, and each user is held to the concurrency and storage limits above (runtime-contract.md "Fairness and quotas"). See permissions-model.md.
Letting them write code is a separate switch, DBBASIC_ENABLE_USER_SOURCE_WRITES=true. The server refuses user writes (403) unless user objects can run sandboxed on this host (the sandbox launcher running, Landlock ABI >= 4, not root; python object_sandbox.py --status), because without that wall a user write would be arbitrary Python running with the server's privileges. DBBASIC_ENABLE_SOURCE_WRITES does not imply it and it does not imply DBBASIC_ENABLE_SOURCE_WRITES.
Leave file writes disabled on public staging until quotas, permissions, and content policy are ready for the use case. A controlled operator VM can enable them separately:
DBBASIC_ENABLE_FILE_WRITES=true
Permission audit and enforcement should also stay closed on first boot. Turn on audit mode first to watch route decisions without blocking users:
DBBASIC_ENABLE_PERMISSION_AUDIT=true
Request blocking only after the persisted policy and auth gateway are confirmed:
DBBASIC_ENABLE_PERMISSION_ENFORCEMENT=true
Once set, enforcement is always effective: every request is decided by the policy, and permissions.mode in /permissions/status reads enforced. The readiness checks in /permissions/status are advisory. A problem while enforced never opens the box; it shows in what the affected callers get: a corrupt or unreadable policy answers 503 permission_policy_unavailable to everyone but the admin token (which can repair it with PUT /permissions/policy), an unreadable identity store answers 503 identity_store_unavailable to signed-in callers, and with no sign-in path only the admin token and public grants get in. The server logs a WARNING for each problem at startup, GET /admin/status leads with it under alerts, and a problem that appears later is logged as an ERROR and recorded in GET /admin/ops?kind=permission_readiness. A policy with no grants is enforced as deny-all for everyone but admins, which is how a fresh box starts until it has a policy (see permissions-model.md for the fresh-box order).
The one thing enforcement refuses to start without is DBBASIC_ADMIN_TOKEN, the way in for every other problem. For one release DBBASIC_ALLOW_START_WITH_BLOCKED_ENFORCEMENT=true starts without it, still enforced (it used to start the server unenforced, and no longer does). DBBASIC_ALLOW_UNREADY_PERMISSION_ENFORCEMENT no longer does anything; remove it. To run without enforcement on purpose, leave DBBASIC_ENABLE_PERMISSION_ENFORCEMENT=false and use DBBASIC_ENABLE_PERMISSION_AUDIT=true to watch decisions.
A hosted, multi-user box should also set DBBASIC_REQUIRE_PERMISSION_ENFORCEMENT=true: the server then refuses to start, with a one-line Refusing to start: ... error, unless DBBASIC_ENABLE_PERMISSION_ENFORCEMENT=true (audit alone refuses too), so a lost or mistyped enforcement flag cannot bring the box up open. Unset, it changes nothing.
DBBASIC_POLICY_FAIL_CLOSED_WIDENED_ALLOWS=true stops the engine applying a stored allow rule that /admin/status reports as allowing more than written (a misspelt or null row_filter, collection and the like): the rule grants nothing until it is fixed. Before turning it on, read the alert and GET /permissions/status: every rule named there as an allow that "applies more widely than written" will stop granting, which can lock its users out of that collection until you fix the key. Deny rules are not affected. Unset or false, it changes nothing (docs/permissions-model.md).
DBBASIC_PERMISSION_TRUST_HEADERS=true is only appropriate when a trusted proxy or auth gateway strips client-supplied identity headers and writes fresh X-DBBASIC-* headers itself.
Do not commit real tokens, VM hostnames, private URLs, or deployment-specific paths to this repository.
After creating the file, keep it readable by root and the service group only:
sudo chown root:dbbasic /etc/dbbasic-object-server.env
sudo chmod 640 /etc/dbbasic-object-server.env
Filesystem Check
The public package includes a small single-VM layout checker. Run it after installing the server and after changing ownership or deployment paths:
cd /opt/dbbasic-object-server
set -a
. /etc/dbbasic-object-server.env
set +a
.venv/bin/python -m deployment_checks
The checker validates the normal Unix boundary:
- server code under
/opt/dbbasic-object-server - live object source under
/var/lib/dbbasic-object-server/objects - runtime data under
/var/lib/dbbasic-object-server/data - deployment secrets under
/etc/dbbasic-object-server.env - systemd unit under
/etc/systemd/system/dbbasic-object-server.service
Errors should be fixed before exposing routes publicly. Warnings usually mean a runtime path is visible to other local users. On a single-purpose staging VM that may not break anything, but the safer default is 750 for object and data directories.
Traffic Limits
Keep the public server narrow while it is staging.
DBBASIC_MAX_REQUEST_BYTES limits inbound HTTP request bodies before JSON parsing or object execution. The default is 1 MiB:
DBBASIC_MAX_REQUEST_BYTES=1048576
DBBASIC_MAX_CONCURRENT_REQUESTS=64
DBBASIC_MAX_CONCURRENT_EXECUTIONS=8
Configure the same or smaller request body limit in the reverse proxy so Caddy or nginx can reject oversized traffic before Python handles it. The app-level limit stays in place because proxy configuration can drift.
The concurrency limits are per process. Under overload, the server returns 503 rather than queueing unlimited work on a small VM. Future production hardening still needs CPU/memory isolation. DBBASIC_OBJECT_TIMEOUT_SECONDS runs object methods in a worker process and returns 504 if the wall-clock timeout is exceeded. On its own that means a new Python interpreter for every object call, including every page object and site route. DBBASIC_WORKER_POOL_SIZE (default 0, off) keeps that many warm worker processes instead. Isolation, the 504 timeout and live source edits are unchanged; the interpreter start-up cost is not paid per request. Start with 2 on a small VM; each worker holds roughly 32 MB of RSS after serving a page. Size it near the number of objects you expect to run at once, and keep it at or below DBBASIC_MAX_CONCURRENT_EXECUTIONS. Measured numbers are in traffic-limits.md. DBBASIC_TRUSTED_IN_PROCESS_OBJECTS is a comma-separated allowlist for reviewed server-owned objects that should keep the fast in-process path, such as the public homepage. Do not add user-created objects to this list. The rate limit values above return 429 with Retry-After when one IP or valid admin token exceeds the configured window. DBBASIC_RATE_LIMIT_TRUST_PROXY_HEADERS is appropriate only because uvicorn is bound to 127.0.0.1 behind Caddy.
See traffic-limits.md for the operating model.
Log Maintenance
Object logs are part of the runtime feedback loop, so staging servers should not let them grow forever.
The active log for an object stays plain TSV:
/var/lib/dbbasic-object-server/data/logs/{object_id}/log.tsv
When it reaches DBBASIC_LOG_MAX_BYTES, the server rotates it. New rotated logs are gzip-compressed by default:
/var/lib/dbbasic-object-server/data/logs/{object_id}/log-YYYYMMDD-HHMMSS-ffffff.tsv.gz
Inspect compressed logs without expanding a second copy:
gzip -cd /var/lib/dbbasic-object-server/data/logs/site_home/log-*.tsv.gz
Garbage collection is controlled by DBBASIC_LOG_KEEP_ROTATED. The default keeps the newest 32 rotated files per object and deletes older rotated logs after a successful rotation. Set it to 0 to keep all rotated logs.
This is at-rest compression. For in-motion compression, start with reverse-proxy HTTP compression for large log responses. Later station replication should compress batches, not individual tiny events.
Event rows are a delivery queue, not the durable audit log. The server and daemon prune old data/state/events/state.tsv event rows with:
DBBASIC_EVENT_KEEP_COUNT=1000
DBBASIC_EVENT_KEEP_SECONDS=604800
Set either value to 0 to disable that retention rule. Subscriptions stay in place, and any event referenced by a subscription last_event_id is protected so the daemon keeps its delivery cursor. Failed delivery attempts are protected too, so callback failures stay visible and retryable until delivery succeeds or the subscription is repaired.
Packages
Packages are read from DBBASIC_PACKAGES_DIR. The public server currently supports package listing, dry-run planning, and package installs only when DBBASIC_ENABLE_PACKAGE_INSTALLS=true. Dry-run and install requests append compact audit rows under /var/lib/dbbasic-object-server/data/package_changes/{package_id}/changes.jsonl. Package installs create a runtime restore point before writing source, schema, or seed files. Restore points default to /var/lib/dbbasic-object-server/data/backups/; set DBBASIC_BACKUPS_DIR if they should live on another mounted volume.
Package restore is separate and requires DBBASIC_ENABLE_PACKAGE_RESTORE=true. It restores a recorded install restore point with overwrite and snapshot pruning, so package-created runtime files are removed if they were not in the archive.
Keep DBBASIC_ENABLE_PACKAGE_INSTALLS=false and DBBASIC_ENABLE_PACKAGE_RESTORE=false on public staging unless /packages is reachable only from a private admin surface. The first install path writes objects and schemas, creates seed TSV files only when no data exists, and rejects permissions/migrations until merge/run semantics are explicit.
Reactions and Scheduled Passes
Installing a package does not by itself make its reactions run. Three separate things have to be true, and a stock install has only some of them:
- Event handlers (
HANDLESobjects: an invoice flipping to paid, a
journal composing, a sale moving stock) run only when DBBASIC_ENABLE_EVENT_HANDLERS=true (writes made over HTTP) and/or DBBASIC_ENABLE_CHANGE_DISPATCH=true (the daemon replays the change log, which also reaches writes actions, runners and webhooks make at storage level -- a Stripe payment, a checkout, a shipment). Both default off. Turning them on is a deliberate act: read the open handler findings (tax basis, order totals) before you do. Change dispatch starts from the moment its first pass runs: writes made before then (payments that landed while the flag was off) are NOT dispatched, and the first pass says so -- GET /daemon/status carries change_dispatch_baseline and a change_dispatch_skipped_history warning with the count. To replay them, delete .change_dispatch_cursor in the data dir and start the daemon once with DBBASIC_CHANGE_DISPATCH_FROM=beginning (or an ISO timestamp). Read what your handlers do first: state-based reactions (invoice status, books, stock) are idempotent, but a replay queues an order email per order.
- Scheduled passes (invoice aging, recurring journals, the biller, the
usage rollup, tracking polls, and the methods objects schedule for themselves with _schedule) run only in the daemon, object_daemon.py. install.sh installs and starts it as dbbasic-object-daemon.service (see "systemd" below); a hand-built VM needs that unit added.
- Cron schedules -- every schedule the shipped packages declare --
need croniter, which is an optional extra (scheduler). install.sh installs it (.[server,scheduler]), and so does the one-click install, which runs install.sh. A hand-built VM installs it into the server's virtualenv with pip install -e '.[server,scheduler]'; a box installed before install.sh did so adds it the same way.
None of this is silent any more. The server's startup log prints one [dbbasic] Reactions NOT RUNNING (...) line per gap, naming the handler objects or schedules affected and the setting that fixes it; the daemon's boot banner prints a Reactions: block; and GET /daemon/status reports daemon.reactions with status, the flags, whether a daemon heartbeat (data/.daemon_heartbeat, touched every 30s by a running daemon) is fresh, and a problems list (handlers_inert, storage_writes_unreacted, cron_needs_croniter, daemon_not_running). A cron task that cannot be scheduled also carries the reason in its own error field (GET /daemon/scheduler/tasks) and is logged as an ERROR once per daemon start.
Minimal Object
Create one object so the VM can prove execution, state, and logs:
sudo -u dbbasic mkdir -p /var/lib/dbbasic-object-server/objects/site
sudo -u dbbasic tee /var/lib/dbbasic-object-server/objects/site/home.py >/dev/null <<'PY'
def GET(request):
count = _state_manager.get("count", 0) + 1
_state_manager.set("count", count)
return {
"status": "ok",
"message": "DBBASIC Object Server is running",
"count": count,
}
PY
This object resolves as site_home.
For a public staging page, the same object can return HTML instead of JSON:
def GET(request):
count = int(_state_manager.get("count", 0)) + 1
_state_manager.set("count", count)
_logger.info("site_home served", count=count, response_type="html")
return {
"content_type": "text/html; charset=utf-8",
"body": f"<!doctype html><h1>DBBASIC Object Server</h1><p>Served {count} times.</p>",
}
That keeps the staging page honest: it is a live object with state and logs, not a static file.
Run Manually
Before creating a service, run the server by hand:
cd /opt/dbbasic-object-server
set -a
. /etc/dbbasic-object-server.env
set +a
.venv/bin/uvicorn object_server:app --host 127.0.0.1 --port 8001 --no-access-log
In another shell:
curl http://127.0.0.1:8001/health
curl -H "Authorization: Token $DBBASIC_ADMIN_TOKEN" 'http://127.0.0.1:8001/health?capacity=true'
curl -H "Authorization: Token $DBBASIC_ADMIN_TOKEN" http://127.0.0.1:8001/objects
curl http://127.0.0.1:8001/objects/site_home
curl -H "Authorization: Token $DBBASIC_ADMIN_TOKEN" 'http://127.0.0.1:8001/objects/site_home?state=true'
curl -H "Authorization: Token $DBBASIC_ADMIN_TOKEN" 'http://127.0.0.1:8001/objects/site_home?logs=true'
systemd
Create /etc/systemd/system/dbbasic-object-server.service:
[Unit]
Description=DBBASIC Object Server
After=network-online.target
Wants=network-online.target
[Service]
User=dbbasic
Group=dbbasic
WorkingDirectory=/opt/dbbasic-object-server
EnvironmentFile=/etc/dbbasic-object-server.env
ExecStart=/opt/dbbasic-object-server/.venv/bin/uvicorn object_server:app --host 127.0.0.1 --port 8001 --no-access-log
Restart=on-failure
RestartSec=2
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=full
ReadWritePaths=/var/lib/dbbasic-object-server
[Install]
WantedBy=multi-user.target
Start it:
sudo systemctl daemon-reload
sudo systemctl enable --now dbbasic-object-server
sudo systemctl status dbbasic-object-server
curl http://127.0.0.1:8001/health
curl -H "Authorization: Token $DBBASIC_ADMIN_TOKEN" 'http://127.0.0.1:8001/health?capacity=true'
Watch logs:
sudo journalctl -u dbbasic-object-server -f
The daemon unit
The background daemon (object_daemon.py: scheduled tasks, including the methods objects schedule for themselves with _schedule, the queue, change dispatch, retention and cleanup passes) is a second unit with the same user, code, env file and data directory, and no port. install.sh writes it; on a hand-built VM create /etc/systemd/system/dbbasic-object-daemon.service:
[Unit]
Description=DBBASIC Object Server daemon (scheduler, queue, background passes)
After=network-online.target dbbasic-object-server.service
Wants=network-online.target
[Service]
User=dbbasic
Group=dbbasic
WorkingDirectory=/opt/dbbasic-object-server
EnvironmentFile=/etc/dbbasic-object-server.env
ExecStart=/opt/dbbasic-object-server/.venv/bin/python object_daemon.py
Restart=on-failure
RestartSec=5
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=full
ReadWritePaths=/var/lib/dbbasic-object-server
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now dbbasic-object-daemon
sudo journalctl -u dbbasic-object-daemon -f
Run exactly one daemon per data directory: two would both run every due task. Restart it alongside the server after an upgrade or an env change (sudo systemctl restart dbbasic-object-server dbbasic-object-daemon).
--no-access-log keeps successful request lines out of journald. DBBASIC keeps the useful application trail in object logs and /health?metrics=true, which are the surfaces Scroll should read. If access analytics are needed later, build them as an explicit app/object instead of relying on raw process logs.
Cap journald so process logs cannot consume the VM:
sudo mkdir -p /etc/systemd/journald.conf.d
sudo tee /etc/systemd/journald.conf.d/99-dbbasic.conf >/dev/null <<'EOF'
[Journal]
SystemMaxUse=128M
SystemKeepFree=1G
MaxRetentionSec=7day
Compress=yes
EOF
sudo systemctl restart systemd-journald
sudo journalctl --vacuum-size=128M
sudo journalctl --disk-usage
Upgrade
Two different things live at /opt and two different things get served at /var/lib — know which one you changed before declaring a deploy done.
Core server modules (object_server.py, object_ai.py, and every other .py at the repo root) are imported directly from /opt/dbbasic-object-server — the steps below are complete for these:
cd /opt/dbbasic-object-server
sudo -u dbbasic git pull --ff-only
sudo -u dbbasic .venv/bin/python -m pip install -e '.[server,scheduler]'
sudo systemctl restart dbbasic-object-server dbbasic-object-daemon
Anything under packages/<name>/ (objects, schemas, seed data) is different. The running server reads these from a separately installed copy at /var/lib/dbbasic-object-server/objects/ and /var/lib/dbbasic-object-server/data/schemas/ — git pull alone never syncs into it, no matter how many times you restart. A git pull-only "deploy" of a packages/ change is a silent no-op: the commit lands, the tests pass, the service restarts clean, and the live server keeps running the old code with no error anywhere. After the git pull above, also run:
curl -s -X POST https://dbbasic.example.com/packages/app-shell/install \
-H "Authorization: Token $DBBASIC_ADMIN_TOKEN" -H 'Content-Type: application/json' \
-d '{"allow_replace": true}'
To reinstall many packages (e.g. every one after an upgrade), take one backup and have each install reuse it instead of writing a full archive per package (about 237 MB each on a 3.3 GB data directory):
BACKUP=$(curl -s -X POST https://dbbasic.example.com/admin/backups \
-H "Authorization: Token $DBBASIC_ADMIN_TOKEN" | python3 -c 'import json,sys; print(json.load(sys.stdin)["backup"]["id"])')
for pkg in $(ls packages); do
curl -s -X POST "https://dbbasic.example.com/packages/$pkg/install" \
-H "Authorization: Token $DBBASIC_ADMIN_TOKEN" -H 'Content-Type: application/json' \
-d "{\"allow_replace\": true, \"restore_point\": \"$BACKUP\"}"
done
The loop's order does not matter. A package whose queues or doors are written into another package's collection (app-nav's attention_sources) installs cleanly even when that package is still the old release's, because those rows are held back until app-nav is installed and refreshes its schema; app-nav sorts late in this loop, so read install.warnings of the earlier installs as "waiting for app-nav", not as failures, and expect registered_for_others in the app-nav response. The release gate's upgrade stage (CONTRIBUTING.md) runs exactly this loop from the previous tag.
(swap app-shell for whichever package changed; DBBASIC_ENABLE_PACKAGE_INSTALLS must be true). Check the response's install.objects[].status — "updated" means a real change landed, "unchanged" means nothing to sync. Read install.permission_retractions too: it lists every permission rule the install removed because the package withdrew it, and every rule it left in place for you to decide about (GET /permissions/unshipped shows those for the whole box; see "Package Rules And Upgrades" in permissions-model.md). A package's tightened permission rules do not reach a running box until it is reinstalled. A schema-only change can also go straight to PUT /admin/schemas/{collection} with the updated schema JSON, same admin-token gate. Either way, restart the service afterward — object modules are cached in the running process, so even a correctly-installed file has no effect until the next restart clears that cache:
sudo systemctl restart dbbasic-object-server dbbasic-object-daemon
To confirm a packages/ deploy actually landed rather than trusting the install response alone, diff the live file against the source directly:
diff /var/lib/dbbasic-object-server/objects/site/<name>.py \
/opt/dbbasic-object-server/packages/<pkg>/objects/site/<name>.py
A non-empty diff means the install step (or the restart) didn't happen yet.
Then verify the local service, filesystem layout, public proxy, and deployed commit:
cd /opt/dbbasic-object-server
set -a
. /etc/dbbasic-object-server.env
set +a
.venv/bin/python -m deployment_checks
curl http://127.0.0.1:8001/health
curl https://dbbasic.example.com/
sudo systemctl is-active dbbasic-object-server caddy
sudo -u dbbasic git rev-parse --short HEAD
If the upgrade only changes live objects that were edited directly under /var/lib/dbbasic-object-server/objects (not via a packages/ git change), the server should not need a git deploy at all. That is the object loop: edit one object, run it, inspect state/logs, and keep the version trail. This is a third, separate path from both cases above — it never touches /opt or git at all.
HTTPS Proxy
For a public or staging hostname, put Caddy or nginx in front of uvicorn and keep uvicorn bound to 127.0.0.1.
Install Caddy if the VM does not already have a reverse proxy:
sudo apt install -y caddy
Example Caddyfile using documentation domains:
dbbasic.example.com {
reverse_proxy 127.0.0.1:8001
}
Replace dbbasic.example.com only on the VM. Do not commit real deployment hostnames into this repository.
If Caddy was already installed, inspect what it is serving before taking over the hostname:
sudo systemctl status caddy --no-pager
sudo sed -n '1,220p' /etc/caddy/Caddyfile
sudo find /usr/share/caddy -maxdepth 3 -type f -printf '%p\t%s bytes\n'
Back up the old config before changing it:
sudo cp -a /etc/caddy/Caddyfile /etc/caddy/Caddyfile.before-dbbasic
For the earliest public staging endpoint, expose only the hello object, system dashboard object, admin status and admin inspection routes, health check, and current-session self-service route until auth, permissions, and source visibility are ready. Keep the broad /objects listing blocked:
dbbasic.example.com {
handle / {
rewrite * /objects/site_home
reverse_proxy 127.0.0.1:8001
}
handle /health {
reverse_proxy 127.0.0.1:8001
}
handle /login {
reverse_proxy 127.0.0.1:8001
}
handle /logout {
reverse_proxy 127.0.0.1:8001
}
# only when signup / password reset are turned on
handle /signup {
reverse_proxy 127.0.0.1:8001
}
handle /verify {
reverse_proxy 127.0.0.1:8001
}
handle /reset* {
reverse_proxy 127.0.0.1:8001
}
handle /admin/status {
reverse_proxy 127.0.0.1:8001
}
handle /admin/changes* {
reverse_proxy 127.0.0.1:8001
}
handle /admin/objects* {
reverse_proxy 127.0.0.1:8001
}
handle /admin/files* {
reverse_proxy 127.0.0.1:8001
}
handle /admin/collections* {
reverse_proxy 127.0.0.1:8001
}
handle /admin/schemas* {
reverse_proxy 127.0.0.1:8001
}
handle /admin/identity* {
reverse_proxy 127.0.0.1:8001
}
handle /permissions/status* {
reverse_proxy 127.0.0.1:8001
}
handle /permissions/policy* {
reverse_proxy 127.0.0.1:8001
}
handle /daemon/status {
reverse_proxy 127.0.0.1:8001
}
handle /daemon/scheduler/tasks* {
reverse_proxy 127.0.0.1:8001
}
handle /daemon/queue/messages* {
reverse_proxy 127.0.0.1:8001
}
handle /events* {
reverse_proxy 127.0.0.1:8001
}
handle /packages* {
reverse_proxy 127.0.0.1:8001
}
handle /api/mcp {
reverse_proxy 127.0.0.1:8001
}
handle_path /static/* {
root * /var/lib/dbbasic-static
file_server
header Cache-Control "public, max-age=3600"
}
handle /permissions/audit* {
reverse_proxy 127.0.0.1:8001
}
handle /dashboard {
rewrite * /objects/system_dashboard
reverse_proxy 127.0.0.1:8001
}
handle /admin/write-probe {
rewrite * /objects/system_write_probe
reverse_proxy 127.0.0.1:8001
}
handle /collections/dbbasic_probe/records* {
reverse_proxy 127.0.0.1:8001
}
handle /collections/dbbasic_probe/changes {
reverse_proxy 127.0.0.1:8001
}
handle /schemas/dbbasic_probe {
reverse_proxy 127.0.0.1:8001
}
handle /identity/session {
reverse_proxy 127.0.0.1:8001
}
# This exposes GET/DELETE current-session checks. POST password login works
# when DBBASIC_ENABLE_PASSWORD_LOGIN=true; the gateway session-mint POST
# remains disabled unless DBBASIC_ENABLE_SESSION_LOGIN=true and
# DBBASIC_SESSION_LOGIN_TOKEN are set.
handle /objects/site_home* {
reverse_proxy 127.0.0.1:8001
}
handle {
respond "Not found" 404
}
}
Validate and reload:
sudo caddy fmt --overwrite /etc/caddy/Caddyfile
sudo caddy validate --config /etc/caddy/Caddyfile
sudo systemctl reload caddy
Then test:
curl https://dbbasic.example.com/
curl https://dbbasic.example.com/health
curl -H "Authorization: Token $DBBASIC_ADMIN_TOKEN" https://dbbasic.example.com/admin/status
curl -H "Authorization: Token $DBBASIC_ADMIN_TOKEN" https://dbbasic.example.com/admin/collections
curl -H "Authorization: Token $DBBASIC_ADMIN_TOKEN" https://dbbasic.example.com/admin/schemas
curl -H "Authorization: Token $DBBASIC_ADMIN_TOKEN" https://dbbasic.example.com/admin/identity/users
curl -H "Authorization: Token $DBBASIC_ADMIN_TOKEN" https://dbbasic.example.com/daemon/status
curl https://dbbasic.example.com/objects/site_home
curl https://dbbasic.example.com/admin/write-probe
curl https://dbbasic.example.com/objects
The first six should return responses from the object server. The root and site_home responses may be JSON or HTML depending on the object. The full /objects route should stay blocked by Caddy in this early staging mode.
The admin-write-probe package may also expose the narrow /collections/dbbasic_probe/records*, /collections/dbbasic_probe/changes, and /schemas/dbbasic_probe routes. Those routes are still protected by the server-side admin-token gate. They exist to prove collection create/update/ delete behavior, record changelog reads, and schema reads through the public reverse proxy without exposing every collection or schema route. Do not expose broad /collections*, /schemas*, /objects*, or source write routes on a public staging server. Use /admin/collections* and /admin/schemas* for operator inspection instead. Use /admin/identity* for read-only account, user, and session inspection instead of exposing broad identity management routes.
Public Code Execution Controls
In the early staging deployment, do not expose the full object server API directly to the internet.
Use all of these controls together:
- keep uvicorn bound to
127.0.0.1 - expose only specific routes through Caddy
- keep
DBBASIC_ENABLE_SOURCE_WRITES=false - do not add a public object-create route until permissions are enforced
- keep live object source and data out of the git checkout
With that shape, outside users can only run the explicitly proxied objects. They cannot list every object, read source, write source, roll back source, or create new runnable code through the public hostname.
Kernel Requirements for User Code
User-namespace objects (u_<uid>_*) run as a separate OS user behind a Landlock sandbox (runtime-contract.md "User Object Isolation"). That needs Linux >= 6.7 (Landlock ABI >= 4) with Landlock enabled in the kernel's LSM list -- Ubuntu 24.04's 6.8 kernel qualifies -- a non-root service user, and the sandbox launcher unit below. Without the launcher user objects are refused whatever the kernel: as the server's own uid, user code could chmod and stat other customers' files. On a host that does not qualify, user objects return HTTP 503 and the log says why; admin, system and package objects are unaffected. Check a host with:
cd /opt/dbbasic-object-server
sudo -u dbbasic .venv/bin/python object_sandbox.py --status # exit 0: user objects can run here
The sandbox launcher unit
scripts/install.sh creates the dbbasic-sandbox user (its own group, no home, no shell, owns nothing) and dbbasic-sandbox-launcher.service, which runs a root-owned copy of the launcher with the system interpreter:
[Service]
User=root
ExecStart=/usr/bin/python3 -I -S /usr/local/lib/dbbasic/object_sandbox_launcher.py --socket /run/dbbasic-sandbox/launcher.sock --server-user dbbasic --sandbox-user dbbasic-sandbox --python /opt/dbbasic-object-server/.venv/bin/python --worker /opt/dbbasic-object-server/object_sandbox.py
RuntimeDirectory=dbbasic-sandbox
RuntimeDirectoryMode=0750
CapabilityBoundingSet=CAP_SETUID CAP_SETGID CAP_KILL CAP_CHOWN CAP_SYS_ADMIN
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
ProtectProc=invisible
PrivateTmp=true
PrivateDevices=true
PrivateNetwork=true
IPAddressDeny=any
RestrictAddressFamilies=AF_UNIX
RestrictNamespaces=net
# ... and the usual Protect*/Restrict* hardening; see scripts/install.sh
Workers inherit all of it: a read-only filesystem, no /home, a private /tmp, no other users' processes in /proc, a private network with only loopback, and no IP sockets at all. With CAP_SYS_ADMIN the launcher also gives each worker its own empty network namespace. The server and daemon units list it in Wants=/After= and reach it through /run/dbbasic-sandbox/launcher.sock (directory root:dbbasic 0750); the launcher answers only the dbbasic uid.
The root-owned copy is refreshed each time scripts/install.sh runs, so an upgrade is: re-run the installer (or copy the file and systemctl restart dbbasic-sandbox-launcher). Never point the unit at the checkout's copy: the checkout is owned by dbbasic, and root must not run a file the server can edit.
If a host cannot meet this, do not enable user code on it. Never set DBBASIC_USER_CODE_ISOLATION=unsafe-dev on a server: it runs user code without the wall and exists for development machines (macOS).
Backup
The portable runtime backup set is:
/var/lib/dbbasic-object-server/objects
/var/lib/dbbasic-object-server/data/state
/var/lib/dbbasic-object-server/data/logs
/var/lib/dbbasic-object-server/data/versions
/var/lib/dbbasic-object-server/data/source_changes
/var/lib/dbbasic-object-server/data/schema_versions
/var/lib/dbbasic-object-server/data/record_changes
/var/lib/dbbasic-object-server/data/package_changes
/var/lib/dbbasic-object-server/data/file_changes
/var/lib/dbbasic-object-server/data/files
/var/lib/dbbasic-object-server/data/schemas
/var/lib/dbbasic-object-server/data/collections
Create and verify a portable runtime backup with:
python -m object_backup create \
/var/backups/dbbasic-object-server/runtime-YYYYMMDD-HHMMSS.tar.gz \
--objects-dir /var/lib/dbbasic-object-server/objects \
--data-dir /var/lib/dbbasic-object-server/data
python -m object_backup verify \
/var/backups/dbbasic-object-server/runtime-YYYYMMDD-HHMMSS.tar.gz \
--json
Restore into clean directories first:
python -m object_backup restore \
/var/backups/dbbasic-object-server/runtime-YYYYMMDD-HHMMSS.tar.gz \
--objects-dir /tmp/dbbasic-restore/objects \
--data-dir /tmp/dbbasic-restore/data \
--json
The runtime archive deliberately excludes deployment secrets, environment files, systemd service files, git history, virtualenvs, caches, lock files, temp files, and ephemeral rate-limit files.
The server environment file and systemd unit still need to be backed up by an operator-controlled process:
/etc/dbbasic-object-server.env
/etc/systemd/system/dbbasic-object-server.service
Keep those secret-aware backups separate from portable runtime archives. Before calling this a production deployment, restore runtime backups on a second clean VM and run the health/object checks again.
See backup-restore.md for the runtime archive contract and restore rules.
Current Limits
This deployment shape is for staging and dogfooding.
Known limits:
- the direct Python loader runs admin/system/package objects unsandboxed;
user-namespace objects run sandboxed (see "Kernel Requirements for User Code")
- source writes still use an explicit admin gate and are disabled until
DBBASIC_ENABLE_SOURCE_WRITES=true
- admin-token gates can optionally accept active admin-role DBBASIC sessions
with DBBASIC_ENABLE_SESSION_ADMIN_GATES=true
- route permission enforcement is available, but off until a deployment enables it
- real user/session auth still needs to replace trusted staging headers
- WebSocket/SSE runtime behavior is still design-stage
That is still useful. A clean VM lets DBBASIC prove that install, restart, object lookup, execution, state, logs, and versions work away from a developer machine.