Environment and Secrets Management
May 3, 2026 ยท View on GitHub
OneQuery now has two distinct config owners:
workspace-devforbun devself-hostforonequery gateway
The repo does not use a generated env-shaped local config file anymore, and startup does not round-trip config through committed env-shaped files.
The rewrite removed the old env-shaped local sync workflow. Repo-local development now starts from authored config files and derived projections only.
Profile Ownership
Workspace Dev
Workspace development is split across a pure config core and an explicit Node shell:
- fixed browser/API defaults in
@onequery/config .onequery/dev/secrets.toml: untracked local secretspackages/config/src/workspace-dev.ts: schema, validation, and normalizationpackages/config/src/projections/*: Vite, runtime launch, and Drizzle projectionspackages/config-node/src/workspace-dev.ts: filesystem-backed loaderpackages/config-node/src/workspace-dev-init.ts: local secrets bootstrap
bun dev uses this profile only.
Default local ports:
- browser origin:
http://localhost:4545 - Bun API listener:
http://127.0.0.1:4555 - local PGlite data directory:
.onequery/dev/pglite/onequery
Flow:
repo .onequery/dev/secrets.toml
|
v
packages/config-node loadWorkspaceDev()
|
+--> Vite projection
+--> Drizzle projection
|
v
scripts/run-self-host-runtime.ts writes launch contract
|
v
bun dev runtime startup
Self Host
Self-host is owned by the Rust CLI, not by the repo-local dev resolver:
self-host/config.toml: authored operator configself-host/secrets.toml: generated/operator secretsrun/launch.json: resolved startup contract written by the CLIapps/cli/.../config/self_host.rs: defaults, validation, and path rules
onequery gateway uses this profile only.
Overlapping secret keys stay aligned with workspace-dev while values stay independent:
auth.secretcrypto.master_encryption_keyconnectors.enrollment_token
Default self-host port:
- bundled public origin:
http://127.0.0.1:5656
Flow:
self-host/config.toml + self-host/secrets.toml
|
v
Rust resolve_self_host_config()
|
v
run/launch.json
|
v
packages/self-host-runtime startup reads it once
Practical Rules
bun run dev:setupcreates.onequery/dev/secrets.tomlwhen it is missing and prepares the local PGlite data directory. It does not apply the application schema.bun devreads repo-local workspace config and keeps browser/API listeners split on purpose. Its packaged runtime applies the application schema on startup.onequery gatewayignores repo-local.onequery/devand starts from the resolved self-host launch contract.publicOriginis the canonical public URL. Do not introduce separate public URL aliases alongside it.DATABASE_URLis a projection for consumers that need it. It is not the authored source of truth for workspace dev.onequery gatewaydoes not support ambientDATABASE_URL; self-host storage is currently the bundled PGlite runtime only.- Optional secrets for integrations can stay unset until you need them locally.
Commands
# Seed local workspace secrets and validate the workspace-dev config
bun run dev:setup
# Run the split browser/API workspace-dev flow
bun dev
# Start the packaged self-host runtime from the Rust-owned config roots
onequery gateway
For direct CLI development without a global install:
cargo run --manifest-path apps/cli/Cargo.toml --bin onequery -- gateway