View Markdown Β· Documentation index (llms.txt)
Learning Guide β TraderX Security Lab (Planned): purpose, walkthrough, and related learning states.
Supervised delivery worker contract
This candidate wraps the existing State 019 delivery adapters. It does not
bootstrap schema, create broker streams or consumers, provision permissions,
or cut over an application consumer. The consumer is only the existing
same-database reference projection described in event-delivery.md.
Configuration and trustβ
Run python scripts/security-lab/delivery_worker.py --config /absolute/private/worker.json.
The JSON file must be a regular, non-symlink file owned by the process user and
inaccessible to group and other users. It contains credentials and must never
be committed. All fields are required; unknown and duplicate fields are
rejected. Paths are absolute. Example structure (replace placeholders locally):
{
"mode": "publisher",
"broker_endpoint": "tls://broker.example:4222",
"broker_user": "publisher",
"broker_password": "replace-locally",
"broker_ca": "/private/broker-ca.pem",
"database_host": "database.example",
"database_port": 5432,
"database_name": "traderx",
"database_user": "publisher",
"database_password": "replace-locally",
"database_transport": "verify-full",
"database_ca": "/private/database-ca.pem",
"batch_size": 8,
"lease_seconds": 30,
"poll_seconds": 1,
"operation_timeout_seconds": 10,
"retry_attempts": 5,
"retry_base_seconds": 1,
"retry_cap_seconds": 30,
"shutdown_seconds": 15
}
For reference-consumer mode additionally provide account_id (positive
integer) and durable (pre-provisioned broker durable name). The worker binds
that existing durable and rejects messages outside the exact trade and position
subjects for the configured account before invoking the adapter. Broker
permissions and the database allowlist remain the authorization boundaries;
the local scope check does not provision or replace either.
For example, prepare a separate private configuration with "mode": "reference-consumer", "account_id": 22214, and "durable": "ACCOUNT_A",
and its own scoped database and broker credentials. Start it with the same
--config command. Configure the durable to filter both account subjects;
the worker cannot inspect its server-side filters with the restricted fixture
permissions. Protect the file with chmod 600 and make its parent directory
accessible only to the intended service user.
The only plaintext SQL mode is fixture-loopback, restricted to literal
127.0.0.1 or ::1, with database_ca set to null. All other SQL connections
require verify-full and an explicit CA file. DNS names such as localhost
are not accepted as proof of loopback. The broker always uses the existing
hostname-verified TLS adapter. Configuration must not contain connection
strings or user-supplied libpq options.
Any inherited PG* environment variable is rejected to prevent libpq
environment defaults from overriding the explicit connection. CA paths must
refer to operator-controlled trust files.