testing/cross_backend/rust_spine_stub_backend_config.ts

Cross-process BackendConfig preset for the non-domain spine consumer, testing_spine_stub — a Rust binary that mounts only the spine surface (auth / account / admin / audit / role-grant offers) with no domain layer. fuz_app drives it from src/test/cross_backend/*.cross.test.ts to verify its TS spec against the Rust spine end-to-end with no domain implementation in the loop — drift becomes a fuz_app failure rather than a downstream consumer's failure with mixed signals.

Binary discovery — env-supplied, never hardcoded. The binary lives in a sibling Rust workspace, not in fuz_app, so the preset never bakes a path in. FUZ_TESTING_RUST_SPINE_STUB_BIN (or the binary_path option) must point at a prebuilt binary; the preset throws a clear error when neither is set rather than guessing. Build once with cargo build -p testing_spine_stub --profile cross-test (the workspace's non-LTO test profile; --release works too, slower to rebuild) and point the env var at the resulting target/cross-test/testing_spine_stub; operators / CI cache the binary across runs for fast spawns.

Operator setup — the target Postgres database must exist before the stub boots. The harness creates it only when a setup asks (ensure_database_for_url, or create_cross_backend_global_setup's ensure_databases), so a test role needs no CREATEDB grant otherwise.

FUZ_TESTING_RUST_SPINE_STUB_DATABASE_URL points the stub at another server (e.g. a scratch cluster on a spare port).

The binary self-wipes the auth-namespace schema on every boot (FUZ_TESTING_RESET_DB_ON_STARTUP=true, set by the Rust-family builder), so no manual DROP TABLE between sessions is needed; per-test reset is the orthogonal _testing_reset RPC action default_cross_process_setup fires.

view source

Declarations
#

8 declarations

rust_spine_stub_backend_config
#

testing/cross_backend/rust_spine_stub_backend_config.ts view source

(options?: SpineStubBackendConfigOptions): BackendConfig import {rust_spine_stub_backend_config} from '@fuzdev/fuz_app/testing/cross_backend/rust_spine_stub_backend_config.js';

Build the BackendConfig for testing_spine_stub. Resolves the binary from options.binary_path or FUZ_TESTING_RUST_SPINE_STUB_BIN; throws when neither is set so a missing build surfaces as a clear error rather than a confusing spawn failure. Reconciles the binary's env contract: port via --port (and FUZ_RUST_SPINE_STUB_PORT), daemon-token dir via FUZ_RUST_SPINE_STUB_DIR (anchored to paths.root so the written {dir}/run/daemon_token matches the path spawn_backend reads).

options?

optional default {}

returns

BackendConfig

throws

  • Error - when no binary path is available.

RUST_SPINE_STUB_BIN_ENV
#

RUST_SPINE_STUB_DATABASE_URL_ENV
#

testing/cross_backend/rust_spine_stub_backend_config.ts view source

"FUZ_TESTING_RUST_SPINE_STUB_DATABASE_URL" import {RUST_SPINE_STUB_DATABASE_URL_ENV} from '@fuzdev/fuz_app/testing/cross_backend/rust_spine_stub_backend_config.js';

Env var overriding the stub's Postgres URL when database_url is omitted — e.g. a scratch cluster on a spare port, keeping the run off the machine's default server. A runner that creates the stub's database before the spawn must create the one this URL names, on the server it names.

RUST_SPINE_STUB_DEFAULT_DATABASE_URL
#

testing/cross_backend/rust_spine_stub_backend_config.ts view source

"postgres://localhost/fuz_app_test_rust_spine_stub" import {RUST_SPINE_STUB_DEFAULT_DATABASE_URL} from '@fuzdev/fuz_app/testing/cross_backend/rust_spine_stub_backend_config.js';

Default Postgres database — real PG (PGlite isn't reachable from tokio-postgres).

RUST_SPINE_STUB_DEFAULT_NAME
#

RUST_SPINE_STUB_DEFAULT_PORT
#

RUST_SPINE_STUB_EXPECTED_SCHEMA_PATH_ENV
#

testing/cross_backend/rust_spine_stub_backend_config.ts view source

"FUZ_RUST_SPINE_STUB_EXPECTED_SCHEMA_PATH" import {RUST_SPINE_STUB_EXPECTED_SCHEMA_PATH_ENV} from '@fuzdev/fuz_app/testing/cross_backend/rust_spine_stub_backend_config.js';

Env var the stub reads for the absolute path of the committed expected_schema.json its /ready gate introspects against. Pointed at the same fixture the TS spine reads (SPINE_EXPECTED_SCHEMA_URL) — column-presence is engine-portable, so one file is the cross-impl contract.

SpineStubBackendConfigOptions
#

testing/cross_backend/rust_spine_stub_backend_config.ts view source

SpineStubBackendConfigOptions import type {SpineStubBackendConfigOptions} from '@fuzdev/fuz_app/testing/cross_backend/rust_spine_stub_backend_config.js';

port?

Listening port. Default RUST_SPINE_STUB_DEFAULT_PORT.

type number

readonly

database_url?

Postgres connection URL. Default $FUZ_TESTING_RUST_SPINE_STUB_DATABASE_URL, then RUST_SPINE_STUB_DEFAULT_DATABASE_URL.

type string

readonly

name?

Backend name — labels the spawn in errors and logs, and names its directory under os.tmpdir() (default_test_backend_paths, namespaced by the running repo), which holds the bootstrap token, the daemon token and the fact store. Default RUST_SPINE_STUB_DEFAULT_NAME. Give each stub spawned alongside another its own name, so those files don't collide.

type string

readonly

binary_path?

Prebuilt binary path. Overrides the FUZ_TESTING_RUST_SPINE_STUB_BIN env var. When neither is set the preset throws.

type string

readonly

enable_login_rate_limit?

Enable the per-IP + per-account login rate limiters on the stub (FUZ_LOGIN_RATE_LIMIT_ENABLED=true). Off by default — the standard cross suites fire many loopback logins a live limiter would 429. Set true only for the dedicated login-security cross project (global_setup_login_security.ts). Pair with trusted_proxies so the limiter keys on the resolved X-Forwarded-For client IP. Mirrors TsSpineBackendConfigOptions.enable_login_rate_limit.

type boolean

readonly

trusted_proxies?

Comma-separated trusted-proxy allowlist passed as FUZ_TRUSTED_PROXIES (e.g. '127.0.0.1,::1'). Unset, the stub trusts the loopback set (127.0.0.1, ::1), as the TS spine binary does unconditionally, so a loopback caller's X-Forwarded-For names the client; ',' trusts none. The login-security project passes the loopback set explicitly.

type string

readonly

enable_action_rate_limit?

Enable the action rate limiters (FUZ_ACTION_RATE_LIMIT_ENABLED=true) — one per-IP and one per-account limiter shared by the RPC and WS endpoints. Off by default, like enable_login_rate_limit; set only for the dedicated security cross project, which drives them through ws_action_rate_limit.ts. Mirrors TsSpineBackendConfigOptions.enable_action_rate_limit.

type boolean

readonly

action_rate_limit_max_attempts?

Replace both action limiters' max_attempts (FUZ_ACTION_RATE_LIMIT_MAX_ATTEMPTS) so a suite reaches the cap in a few calls. Requires enable_action_rate_limit — the binary refuses to boot otherwise. Mirrors TsSpineBackendConfigOptions.action_rate_limit_max_attempts.

type number

readonly

audit_sse_keep_alive_ms?

Replace the audit stream's keep-alive interval (FUZ_AUDIT_SSE_KEEP_ALIVE_MS). Mirrors TsSpineBackendConfigOptions.audit_sse_keep_alive_ms.

type number

readonly

ws_receive_timeout_ms?

Replace the WS endpoints' receive timeout (FUZ_WS_RECEIVE_TIMEOUT_MS). Mirrors TsSpineBackendConfigOptions.ws_receive_timeout_ms.

type number

readonly

db_checkout_timeout_ms?

Replace the request pool checkout bound (FUZ_DB_CHECKOUT_TIMEOUT_MS). Mirrors TsSpineBackendConfigOptions.db_checkout_timeout_ms.

type number

readonly

db_audit_checkout_timeout_ms?

Replace the audit write pool checkout bound (FUZ_DB_AUDIT_CHECKOUT_TIMEOUT_MS). Mirrors TsSpineBackendConfigOptions.db_audit_checkout_timeout_ms.

type number

readonly

Depends on
#