Storage Configuration
Configure where Reflexio stores data, including SQLite (default), Supabase, and PostgreSQL for production deployments.
Storage configuration determines where Reflexio stores data.
Default Storage (Open Source)
The open-source version uses SQLite by default — no storage configuration is needed. Reflexio automatically creates and manages a local SQLite database, so you can start using it immediately without any setup.
# No storage configuration required — SQLite is used automatically
client = ReflexioClient() # see Quickstart for connection options
config = client.get_config()
# config.storage_config is already set to SQLitecurl -X GET "${REFLEXIO_URL:-https://www.reflexio.ai}/api/get_config" \
-H "User-Agent: my-agent-reflexio" \
-H "Authorization: Bearer $REFLEXIO_API_KEY"Supabase Storage
Hosted Enterprise
Hosted Enterprise uses Supabase with automatic provisioning and managed infrastructure. Hosted accounts start with managed storage and can switch to their own Supabase project from Settings.
For production deployments that need managed cloud storage, you can configure Supabase manually:
from reflexio.models.config_schema import StorageConfigSupabase
storage = StorageConfigSupabase(
db_url="postgresql://reflexio_user:replace-me@host:5432/postgres",
)
config.storage_config = storage
client.set_config(config)curl -X POST "${REFLEXIO_URL:-https://www.reflexio.ai}/api/set_config" \
-H "User-Agent: my-agent-reflexio" \
-H "Authorization: Bearer $REFLEXIO_API_KEY" \
-H "Content-Type: application/json" \
--data @- <<'JSON'
{
"...": "updated full config object"
}
JSON| Field | Type | Description |
|---|---|---|
type | str | Serialized backend identity: supabase |
db_url | str | PostgreSQL connection string |
schema | str | Optional. Used by hosted Reflexio for platform-managed per-org schemas. Omit this for bring-your-own Supabase storage. |
Supabase data reads, RPCs and complete table mutations use pooled native SQL
through db_url. Saved configuration retains type: "supabase". Historical
url, key, read_url and read_key inputs are ignored and omitted from saved
configuration; the data backend needs no HTTP credentials. For a native read replica,
use PostgreSQL storage's read_db_url and reader pool settings below.
PostgreSQL Storage
Hosted Enterprise
Reflexio Enterprise can also store data in a customer-owned PostgreSQL database, such as AWS RDS, without running Supabase or PostgREST. Auth/login storage remains separate from data storage.
from reflexio.models.config_schema import StorageConfigPostgres
storage = StorageConfigPostgres(
db_url="postgresql://reflexio_user:replace-me@host:5432/database",
schema="public",
# Optional reader pool for search traffic
read_db_url="postgresql://reflexio_reader:replace-me@reader:5432/database",
read_pool_size=10,
)
config.storage_config = storage
client.set_config(config)curl -X POST "${REFLEXIO_URL:-https://www.reflexio.ai}/api/set_config" \
-H "User-Agent: my-agent-reflexio" \
-H "Authorization: Bearer $REFLEXIO_API_KEY" \
-H "Content-Type: application/json" \
--data @- <<'JSON'
{
"...": "updated full config object"
}
JSON| Field | Type | Description |
|---|---|---|
db_url | str | PostgreSQL connection string |
schema | str | Optional. Target schema for Reflexio data. Defaults to public. |
pool_size | int | Optional. Maximum direct SQL connections per target/policy/process. Defaults to 10. |
read_db_url | str | Optional. Reader PostgreSQL connection string for search. Defaults to db_url. |
read_pool_size | int | Optional. Maximum reader connections per process. Defaults to pool_size. |
PostgreSQL storage requires PostgreSQL 15+ with pgvector available.
Connections are shared across work using the same database credentials and pool
policy in one process. Organizations sharing that target must use compatible pool
settings; conflicting settings are rejected. When concurrency exceeds pool_size,
additional queries wait within the existing whole-borrow deadline. Queueing,
dialing, SQL and cleanup share its remaining time; waiting does not renew it.
Actual request and explicit operation deadlines may shorten it. Reader and
privileged-credential pools have separate capacity. Budget all pools across every
server process, including overlap during deployment, against the database limit.
In self-host deployments, the saved organization storage_config owns the writer and reader
pool sizes. Startup preserves them when updating database bindings. Before the
first publication, SELF_HOST_INITIAL_CONFIG_FILE can select a canonical JSON
snapshot with nondefault settings. Its database target must match the deployment;
existing populated organizations never reload this file. Without an initial
snapshot, the model defaults remain 10 writer connections, a 30-second acquire
wait, and reader settings inherited from the writer.
During the packaged one-time upgrade, the selected existing native organization
adopts the predecessor's pool policy from the upgrade environment. Once that
authority transition completes, the four old REFLEXIO_POSTGRES_*POOL* variables
cannot select capacity or wait times. Matching obsolete assignments are assertions;
conflicting assignments stop startup before changing saved settings. Remove obsolete
exports after verifying the upgrade. The deployment binding
REFLEXIO_POSTGRES_READ_DB_URL remains supported.
REFLEXIO_STORAGE_POOL_SIZE controls the separate Supabase SQL default and does
not change native PostgreSQL capacity, including when the native pool-size setting
is unset.
Supabase data operations now use native SQL; the former data-operation HTTP client and its timeout setting have been removed. Ordinary native PostgreSQL and Supabase SQL statements use their checked-out connection's remaining lease. Authentication and management HTTP clients retain their separate policies.
For enterprise native PostgreSQL and Supabase SQL pools,
REFLEXIO_DB_LEASE_TIMEOUT_SECONDS owns the 120-second total connection
lease limit. It starts after checkout and includes all statements, time between
statements, commit, rollback, and pool cleanup. It interrupts unresponsive database
socket operations even when the peer still acknowledges TCP traffic. It is not an
HTTP request timeout and does not interrupt arbitrary application computation.
The database lease deadline also protects the authentication PostgreSQL pool and background workers' dedicated transactions. Persistent maintenance sessions apply it per database operation or batch, so idle time does not release healthy advisory locks. Daemon coordination uses a fixed 15-second client deadline for its short database interactions. Expiry discards the connection without replaying writes; a commit whose response was lost may already have succeeded. Fleet schema migrations use a separate 30-minute per-operation budget, accommodating existing ten-minute index builds without imposing a time limit on the whole migration sweep.
Remove REFLEXIO_POSTGRES_STATEMENT_TIMEOUT_MS assignments, including blank ones.
Independent early per-statement cancellation is retired: each ordinary statement
now consumes the same remaining borrow budget, capped by its request deadline.
The default can permit one statement longer than its former 30-second cap, while
multiple statements and cleanup share the existing 120-second lease. There is no
lossless conversion from per-statement milliseconds to whole-borrow seconds;
select the existing lease budget deliberately rather than copying the old value.
Pool admission limits and domain-specific explicit lock/operation caps remain.
Set a larger finite positive lease value for intentional long transactions. Unset or empty uses 120 seconds; zero, negative, NaN, and infinity are rejected. Expired connections are discarded. A timeout can leave a write's outcome unknown (the server may have committed before its response was lost), so reconcile the result or use an idempotency key before retrying a write. The pool does not replay it automatically.
Config Encryption
Hosted Enterprise
Enterprise can encrypt stored organization configuration before it is written to
the configuration store. This protects persisted configuration_json rows, such
as stored storage credentials; it does not encrypt the Reflexio data tables
themselves. Configure FERNET_KEYS with a comma-separated key ring. The first
valid key encrypts new writes, and older keys are accepted for reads during
rotation. Leaving FERNET_KEYS empty is valid and stores configuration as
plaintext.
Generate a key with:
uv run python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"Keep Fernet keys in your secret manager or deployment environment; never commit
them. Set FERNET_REQUIRED=true only after valid keys are deployed and existing
configuration rows have been re-encrypted. Required mode fails closed: if no
valid Fernet key is available, Reflexio refuses to store plaintext
configuration. During key rotation, deploy the new key first in the
FERNET_KEYS list, re-encrypt existing rows, then remove retired keys after all
running instances can read the newly encrypted values.
Row Retention
Reflexio applies high-water row limits to data tables. When an eligible table
reaches its limit, the server deletes the oldest 20% of rows for that table by
its target-specific ordering column; not every target uses created_at.
The check runs on the background retention sweep, once per project on the lineage garbage-collection poll interval — not on each publish, which is where it used to run.
# Defaults to 250000 rows per target
REFLEXIO_ROW_LIMIT_INTERACTIONS=500000
REFLEXIO_ROW_LIMIT_PROFILES=250000
# Default ceiling PER operational table; target overrides are independent
REFLEXIO_OPERATIONAL_ROW_LIMIT=250000
# Keep more complete optimizer history; disable only share-link row-cap cleanup
REFLEXIO_ROW_LIMIT_PLAYBOOK_OPTIMIZATION_HISTORY=2000000
REFLEXIO_ROW_LIMIT_SHARE_LINKS=0Set a cap to at least five days of ingest
The sweep deletes 20% of the current row count per tick, so a cap only settles
when limit >= 5 x daily_ingest. Above that the table converges; below it the
table keeps growing past its limit, because each tick removes less than a day
adds.
At the 250,000 default that threshold is 50,000 rows/day, which every target is
comfortably inside. It matters if you lower a cap to bound a hot table: setting
REFLEXIO_ROW_LIMIT_INTERACTIONS=10000 on a project ingesting more than 2,000
interactions a day will not hold that table at 10,000.
Optimizer history reclaims complete graphs in bounded root batches. Its throughput can be limited by that batch or protected work, so the simple physical-table ingest formula is not a guarantee for history cleanup.
Every deletion logs an event=retention_cap_enforced line with rows_before, so a table that
is climbing rather than settling is visible in that series.
Disabling cleanup
For customer-data tables, set that target's REFLEXIO_ROW_LIMIT_* to 0.
For operational tables, set REFLEXIO_OPERATIONAL_ROW_LIMIT=0 to disable
inherited row-cap cleanup. Set a target's REFLEXIO_ROW_LIMIT_* to 0 to disable
only that cap. A nonblank target override is independent of the shared default.
Other deletion policies retain their own gates.
The operational default applies separately to retrieval verdicts, tuner reward labels, share links and retrieval occurrence logs. Optimizer history has one aggregate budget over its job, candidate, evaluation and event rows; its unset default is four times the operational default, keeping the former combined nominal ceiling. Cleanup removes complete eligible job graphs, never independent winner/evaluation fragments. It retains active work, publication effects and attribution anchors. One oversized eligible graph may exceed a deletion batch's row request so cleanup can make progress. The budget is not an aggregate database-size limit. Customer-data limits and the fixed exposure-event limit stay separate. All operational limits accept nonnegative integers; invalid values stop the whole sweep before leases, table probes, archiving or deletion.
Upgrade optimizer-history capacity
Remove the retired REFLEXIO_ROW_LIMIT_PLAYBOOK_OPTIMIZATION_JOBS,
REFLEXIO_ROW_LIMIT_PLAYBOOK_OPTIMIZATION_CANDIDATES,
REFLEXIO_ROW_LIMIT_PLAYBOOK_OPTIMIZATION_EVALUATIONS and
REFLEXIO_ROW_LIMIT_PLAYBOOK_OPTIMIZATION_EVENTS assignments, including blanks.
Select REFLEXIO_ROW_LIMIT_PLAYBOOK_OPTIMIZATION_HISTORY explicitly when
migrating custom caps; zero disables history capacity cleanup. Four independent
caps cannot be converted into one equivalent constraint, so startup and direct
policy reads reject old assignments without copying or printing their values.
Do not replace a disabled legacy policy with a positive aggregate by assumption.
Age-based cleanup retains its own existing policy.
Upgrade from the shared-only operational policy
Independent REFLEXIO_ROW_LIMIT_<TARGET> controls are supported again. Blank or
unset overrides inherit the shared default. There is one ambiguous upgrade:
previous releases ignored an explicit per-target value of 250000 when the
shared cap differed. Such combinations now stop cleanup rather than silently
changing deletion policy. Remove the old per-target assignment to keep the
shared policy. To explicitly choose independent caps including 250000, unset
REFLEXIO_OPERATIONAL_ROW_LIMIT and set each target whose cap differs from the
standard 250000 default. This also preserves a deliberate zero opt-out.
Earlier versions of this page described
REFLEXIO_RETENTION_CLEANUP_INTERVAL_SECONDS=0 as disabling the periodic sweep.
It never did: the code read <= 0 as no throttle, meaning the sweep ran on
every publish rather than not at all. That variable has been removed along
with the publish-path sweep, so no deployment loses a capability it had — the
documented behaviour was the opposite of the implemented one.
Configure interactions with REFLEXIO_ROW_LIMIT_INTERACTIONS. Remove any
INTERACTION_CLEANUP_THRESHOLD assignment before upgrading; it is rejected.
The user_playbook_exposure_events target is fixed at 250,000 rows in code and
does not accept a REFLEXIO_ROW_LIMIT_USER_PLAYBOOK_EXPOSURE_EVENTS override.
Most retention targets are ordered by created_at. The exceptions are:
offline_tuner_reward_label rows use label_created_at (on backends that
still have that table; a target whose table is absent is skipped), and
user_playbook_exposure_events rows use ingested_at. Exposure events also
have a 14-day minimum age floor, so row-count cleanup cannot delete them until
they are at least 14 days old.
Managed cloud: plan-based retention
On the managed cloud, the row limits above work differently for customer data:
- Raw events expire by plan. Interactions, requests, evaluation results, and exposure events older than your plan's retention window are archived and then deleted. The window is 30 days on Free and 90 days on Pro, and during a signup trial the trial plan's window applies. Archived copies are kept for 90 days and then permanently removed.
- Learned knowledge does not expire by age. Active profiles and playbooks are kept. Only retired (archived, merged, superseded or expired) rows are removed, after the lineage grace window.
- Customer-data row limits alert instead of deleting. Profiles, interactions, requests, playbooks, evaluation results and skills have a high safety limit. Reaching it alerts our team and deletes nothing.
Self-hosted deployments keep the row limits described above. Plan-based expiry is a managed-cloud feature.
Enterprise Self-Host Single Database
Hosted Enterprise
Enterprise self-host deployments can run with one customer-owned database for both login metadata and Reflexio data. Set DEPLOYMENT_MODE=self_host, choose REFLEXIO_STORAGE=supabase or REFLEXIO_STORAGE=postgres, and provide SELF_HOST_USERNAME / SELF_HOST_PASSWORD for the only login account.
For either Supabase or vanilla Postgres self-host, configure the native DATA_DB_URL for both auth and tenant storage. HTTP URL/key pairs are retired; verify the intended native database and remove old inputs before adopting the new release. Startup applies auth and data migrations to that same database and stores the generated configuration_json in public.organizations.
Usage-metering WAL volume (self-host)
Hosted Enterprise
REFLEXIO_SELF_HOST_METERING=required|exempt selects the self-host metering composition. Unset or blank defaults to required. Only a trusted deployment owner may deliberately select exempt for an intentionally unmetered installation; paid deployment tooling must not set it accidentally.
In required mode, usage is written to a small encrypted write-ahead log (WAL)
on disk rather than your database. Mount a persistent, writable volume at
REFLEXIO_USAGE_WAL_PATH (default ~/.reflexio/usage_wal) for restart-safe
metering. Boot fails when the resolved directory is not writable; an ephemeral
or default path logs a warning.
If the control plane temporarily cannot complete a usage-ingest cardinality
read, it returns HTTP 503 with Retry-After: 5. The shipper retains the batch
in its WAL and retries without double-counting acknowledged usage. Keep the WAL
volume intact while database availability recovers.
For multi-instance deployments, configure one shared persistent mount root and
let startup create derived per-instance directories at
<root>/<instance-id>. Distinct per-replica persistent volumes are an
alternative when every replica receives a stable, unique path. Reflexio's
generated, file-backed instance id is preferred; set REFLEXIO_INSTANCE_ID
only when the orchestrator guarantees uniqueness. If required-mode WAL files
become unreadable, recover the original preserved files rather than starting
from an empty directory.
In exempt mode, Reflexio does not construct or validate the usage WAL, and no
WAL path, persistence, or mount is required. Early startup may still normalize
or derive a configured path environment value before selecting the exempt
composition.
Activating a Self-Host Data Plane
Hosted Enterprise
When Reflexio provisions your self-host account, the admin console's Onboard self-host customer flow shows a one-time activation key. Configure your data plane with that key — the control-plane URL defaults to Reflexio cloud.
# The activation key shown once in the Reflexio admin portal.
BYOC_DEPLOYMENT_SECRET="rflx-dep-…"
# Optional — the Reflexio control-plane base URL. Defaults to the Reflexio cloud
# control plane (https://www.reflexio.ai); set it only to target a different one.
# CONTROL_PLANE_URL="https://www.reflexio.ai"Use an HTTPS origin in CONTROL_PLANE_URL; plain HTTP is supported only for
literal loopback development endpoints. Activation, usage shipping and lease
polling share this policy. Remove BYOC_ENFORCE_ACTIVATION_HTTPS assignments
before upgrading; there is no insecure-transport bypass. Custom HTTP control
planes must provide working HTTPS first. Keep existing deployment credentials
and signing keys.
Use CONTROL_PLANE_URL. Before upgrading, rename CONTROL_PLANE_INGEST_URL
to this name while preserving its URL; the removed name is rejected even when
blank or accompanied by the canonical setting.
On startup the data plane calls POST /api/billing/byoc/activate with the
activation key in the X-Deployment-Secret header. The control plane confirms
the key→deployment binding and returns your deployment id, org id, and central
public key.
After activation, the data plane ships usage and pulls its entitlement lease
automatically. You do not need to set BYOC_DEPLOYMENT_ID; the activation
handshake supplies it.
Official self-host images already include Reflexio's public verification keys. With the default Reflexio control plane, installing or upgrading the image is sufficient: no public-key setting or enforcement flag is needed. The server verifies both licenses and centrally issued login tokens automatically. The existing staging control-plane URL selects staging keys separately.
If you operate a custom control plane, configure its public key with the advanced
CONTROL_PLANE_PUBLIC_KEY override. This replaces the bundled keys. Never copy
Reflexio's private signing key to a self-host server.
Missing or invalid signatures refuse gated enterprise features; core APIs remain
available. The former ENTERPRISE_REQUIRE_SIGNED_LEASE flag is ignored.
The activation key is your deployment's credential: keep it secret. Every live
BYOC endpoint requires a registered per-deployment key. Registration recovers
that deployment's existing ID or sends its heartbeat; it never creates a deployment.
Usage ingestion additionally requires the registered report-signing key.
The retired legacy /ingest endpoint returns HTTP 410.
BYOC_ENFORCE_REGISTER_CREDENTIAL is retired. A control-plane-wide secret no
longer authorizes registration, heartbeat, activation, ingestion, or lease issuance.
Existing per-deployment keys continue to work without changes.
For an older keyless deployment, a control-plane administrator can call
POST /api/admin/billing/byoc/deployments/{deployment_id}/activation-key using
admin authentication. This issues a key on the existing row, preserving its ID,
report key and replay history. Retrying returns the same key; it does not rotate
an existing key. Set the returned value as BYOC_DEPLOYMENT_SECRET on that data
plane and restart it. This is an explicit adoption step, not an automatic upgrade.
New deployments continue to use admin self-host provisioning.
Explicit PostgreSQL TCP routes
Use the connection string's port and hostaddr parameters for custom TCP
routing. PGPORT and PGHOSTADDR no longer supply Reflexio connection defaults.
An existing explicit parameter keeps working alongside obsolete environment
assignments. Otherwise a nonblank old assignment requires explicit adoption in
the connection string before dialing; no value is copied or silently replaced.
Retain the hostname for TLS/authentication when using a numeric hostaddr.
Service-file selection is no longer supported. A nonempty connection-string
service, PGSERVICE or PGSERVICEFILE is rejected on all shared PostgreSQL
connections, even if other connection parameters are explicit. Before upgrading,
resolve every effective service parameter into the existing connection string,
including TLS verification and authentication, and remove the selectors.
Connection-string parameters override service parameters; service parameters can
override environment defaults. Reflexio never expands the file or copies secrets.
Empty selectors are inert; whitespace selectors are rejected. Ordinary Unix
socket and multi-host connections remain supported.
Source provenance follows parent playbooks
Source links affect source-filtered search, so they are retained while both parent playbooks survive. Parent deletion/retention and explicit source replacement remove them; a separate operational cap no longer truncates live provenance. Existing agent/user playbook limits keep their units, values and zero-disable behavior. This does not impose a total graph row or byte budget.
Remove REFLEXIO_ROW_LIMIT_AGENT_PLAYBOOK_SOURCE_USER_PLAYBOOKS, including
blank/zero assignments, before upgrading. Startup and direct policy reads reject
it. Do not copy its value into a parent cap: independent provenance eviction
has no equivalent safe replacement. This is an explicit external-configuration
upgrade exception; no stored configuration or schema migration is required.
Valid source-link storage can grow until its parent cleanup instead of being
independently truncated.
The former pool_acquire_timeout and read_pool_acquire_timeout fields are
retired. The matching image upgrade validates and removes them before serving,
with old writers stopped and exact encrypted configuration originals retained.
Local SDK files upgrade through the existing pre-launch file owner, preserving
original bytes. Independent early queue-only abort is intentionally removed;
values are not copied into REFLEXIO_DB_LEASE_TIMEOUT_SECONDS. That existing
setting owns the entire borrow, rather than only its wait phase. Explicit
copy conversion remains available for caller-selected historical files.