Adding a wire
This page lists every place a wire protocol is registered, in the order you would touch them when adding one. It is derived from how the existing wires are wired in at main 8a689c5c (2026-11-30). The Confluent Schema Registry wire is used as the worked example because it is one of the most recent additions and touches every layer. Paths in source pointers are relative to the repository root.
There is no generator or registry file: a wire is a module, a config key, a block in Server::start, and entries in the tests, the Docker files and the proof pack.
Checklist
| Step | File | Symbol or key | Schema Registry example |
|---|---|---|---|
| Module | src/protocol/mod.rs |
pub mod <wire>; |
pub mod schema_registry; |
| Handler | src/protocol/<wire>/mod.rs |
impl ProtocolHandler for <Wire>Handler |
SchemaRegistryHandler |
| Port key | src/config.rs |
ServerConfig.<wire>_port, ServerConfig::default
|
schema_registry_port, default Some(8081)
|
| Start | src/server/mod.rs |
Server::start block, then start_handler
|
if let Some(port) = server_config.schema_registry_port |
| Docker |
docker/synergydb.toml, docker/synergydb.allwires.toml, Dockerfile
|
<wire>_port, EXPOSE
|
schema_registry_port = 8081; EXPOSE ... 8081
|
| Pre-auth test | tests/wire_preauth_gate.rs |
one #[tokio::test]
|
schema_registry_rejects_unauthenticated_requests |
| Handler tests | tests/protocol_<wire>.rs |
tests/protocol_schema_registry.rs |
|
| Differential suite | test-scripts/diff-<wire>/ |
three phases | diff-schema-registry/diff_schema_registry.py |
| Proof pack |
prove/wires.py, prove/refs.py, prove/bench.py, prove/ci-baseline.json
|
WIRES, REFS, probe, BENCH, wires
|
Wire("schema_registry", ...), "ref-sr", probe("sr"), no BENCH entry |
| Docs |
README.md, this book's src/wires/, docs/status/
|
scorecard row, wire page, one entry | src/wires/schema-registry.md |
(source: src/protocol/mod.rs; src/protocol/schema_registry/mod.rs, SchemaRegistryHandler; src/config.rs, ServerConfig; src/server/mod.rs, Server::start; docker/synergydb.toml; Dockerfile; tests/wire_preauth_gate.rs; prove/wires.py, WIRES; prove/refs.py, REFS; prove/ci-baseline.json)
1. Module
Create src/protocol/<wire>/mod.rs (existing wires are all directories) and declare it in src/protocol/mod.rs with pub mod <wire>;. The module is compiled into every build: see step 5 on Cargo features (source: src/protocol/mod.rs; listing of src/protocol/).
src/protocol/ also holds shared pieces a new wire can use: tls.rs (MaybeTlsStream, accept_auto), buffer_limits.rs (message and query size limits, used by 10 wires), timeout.rs and rate_limiter.rs (source: listing of src/protocol/; src/protocol/buffer_limits.rs, BufferLimits).
2. The ProtocolHandler implementation
Every wire implements this trait (source: src/protocol/mod.rs, ProtocolHandler):
#[async_trait]
pub trait ProtocolHandler: Send + Sync {
fn name(&self) -> &'static str;
fn default_port(&self) -> u16;
async fn start(&self, addr: SocketAddr, shutdown: mpsc::Receiver<()>) -> Result<()>;
}
name() is what the server prints at startup and in errors ("Schema Registry"). start owns the listener until shutdown (source: src/server/mod.rs, Server::start_handler).
Constructors
The server builds a handler with one of two constructors: with_storage(storage) when TLS is off and with_tls(storage, tls) when it is on. with_tls returns a Result, so a bad certificate fails startup (source: src/server/mod.rs, Server::start; src/protocol/schema_registry/mod.rs, SchemaRegistryHandler::with_tls). Building the handler is also where a wire reloads any in-memory state from storage: start_handler records a startup-memory checkpoint right after construction for that reason (source: src/server/mod.rs, start_handler, startup_memory::checkpoint).
The accept loop
The existing handlers share one shape. From SchemaRegistryHandler::start (source: src/protocol/schema_registry/mod.rs, impl ProtocolHandler for SchemaRegistryHandler):
-
TcpListener::bind(addr). -
loop { tokio::select! { ... } }overlistener.accept()andshutdown.recv(). The shutdown branch breaks the loop. - On
Ok((stream, peer)):set_nodelay(true), build a per-connection handler (here withrequire_auth: auth.requires(&peer)), andtokio::spawnthe connection. - Inside the task: if TLS is configured,
tls.accept_auto(stream); otherwise wrap the socket inMaybeTlsStream::Plain. A failed TLS handshake drops the connection with a debug log. - Run the connection inside
crate::auth::audit::in_connection("<wire>", Some(peer), handler.handle_connection(stream)). This sets a task-local audit context naming the wire and peer (source:src/auth/audit.rs,in_connection). - On
Err(e)fromaccept:crate::protocol::accept_error("<wire>", &e).await.
accept_error sleeps before the next accept (100 ms when the process is out of descriptors, buffers or memory, 5 ms otherwise) and logs at most once per 10 s per wire with a count of what it suppressed. Without it, a wire that runs out of file descriptors spins and floods the log. A search finds 25 call sites, matching the status entry's "all 25 accept loops" (source: src/protocol/mod.rs, accept_error; docs/status/2026-11-30-open-files-and-accept-backoff.md). A new wire should call it too.
Optional instrumentation
| Helper | What it does | Who uses it | Source |
|---|---|---|---|
ConnectionTracker::new("<wire>") |
Increments the active and total connection metrics for the wire; decrements on drop | Most wires. Kafka, Schema Registry, S3, Gremlin and Arrow Flight do not |
src/observability/metrics.rs, ConnectionTracker
|
crate::heap::track("<wire> connection", fut) |
Attributes a connection task's allocations to a named tracker in the memory log | MySQL, Redis, Elasticsearch, ClickHouse, Cassandra, Bolt, CouchDB, S3, Kafka, InfluxDB, HTTP and SQL Server |
src/heap.rs, track; docs/status/2026-11-30-wire-task-memory.md
|
storage_close_hooks |
Lets a wire flush state when storage closes. Push handler.shutdown_hook() before start_handler
|
Memcached |
src/server/mod.rs, Server::start
|
PROTOCOL_SCHEMAS |
Reserves a catalog namespace and display OID for tables the wire creates | mongo, dynamo, graph, redis, memcached, es |
src/catalog/system_tables.rs, PROTOCOL_SCHEMAS
|
Not verified: whether a new wire that stores rows needs a PROTOCOL_SCHEMAS entry, or only gains a nicer pg_class.relnamespace. Several wires that store data (Kafka, CouchDB, Schema Registry) have none.
3. Authentication
Decide what an unauthenticated client may do before writing any command handling. tests/wire_preauth_gate.rs holds the rule the existing wires follow: a request sent before the handshake or login must be refused and must not leak data (source: tests/wire_preauth_gate.rs).
Wires without a SQL session (Redis, MongoDB, Elasticsearch, CouchDB, Kafka, InfluxDB, Prometheus, Memcached, Gremlin, Schema Registry) do not check table privileges, so a login reaches all of that wire's data. For those, check credentials with crate::auth::wire_auth::verify_wire_credential(wire, storage, legacy, user, password), or authorize_http_basic_for(wire, storage, header) for HTTP Basic. Both accept a superuser, or a role that is a member of synergy_wire_<wire> or synergy_wire_all. SYNERGYDB_WIRE_ACCESS=open turns the membership check off (source: src/auth/wire_auth.rs, wire_access_allowed, verify_wire_credential, authorize_http_basic_for). The wire string you pass becomes the role name suffix, so pick it once and use it consistently with the audit label.
Patterns the existing wires use for the default policy:
| Pattern | Example | Source |
|---|---|---|
| Loopback open, remote must authenticate, configurable by env | Schema Registry: SrAuth::LocalOnly by default; SYNERGYDB_SCHEMA_REGISTRY_AUTH=users or open
|
src/protocol/schema_registry/mod.rs, SrAuth, auth_from_env
|
| Fail closed unless configured or in dev mode | Kafka requires SASL unless kafka_require_sasl says otherwise or dev-insecure auth is on |
src/server/mod.rs, Server::start (Kafka block) |
| Off by default | SQLite: sqlite_port defaults to None because the wire has no auth handshake and no TLS |
src/config.rs, ServerConfig::default
|
SYNERGYDB_DEV_INSECURE_AUTH relaxes several of these checks for tests. Read it through crate::auth::wire_auth::dev_insecure_auth_enabled() rather than the environment directly. main.rs refuses to start with auth-disabling variables on a non-loopback bind (source: src/auth/wire_auth.rs, dev_insecure_auth_enabled; src/main.rs). See Security for the operator view.
4. The port key in ServerConfig
Add one field to ServerConfig and one line to its Default (source: src/config.rs, ServerConfig, ServerConfig::default):
/// Confluent Schema Registry REST port (Avro/Protobuf/JSON schema store)
#[serde(default)]
pub schema_registry_port: Option<u16>,
// in Default:
schema_registry_port: Some(8081),
How the value is chosen at run time:
-
No config file:
ServerConfig::defaultapplies, so the wire starts on its default port if the default isSome(source:src/config.rs,ServerConfig::default;README.md, "From source"). -
A config file without the key: the field deserialises to
Noneand the wire is off.docker/synergydb.tomlandREADME.mdboth state this (source:docker/synergydb.toml, header comment;README.md, "From source"). -
Environment:
SYNERGYDB_SERVER_<KEY>overrides any key, soSYNERGYDB_SERVER_SCHEMA_REGISTRY_PORT=18081works with no extra code (source:src/config.rs,Config::apply_env_overrides; testenv_overrides_reach_every_section_and_type).
README.md says that with no config file "every wire starts on its default port". The SQLite wire is the exception, since its default is None (source: README.md, "From source"; src/config.rs, ServerConfig::default).
Choose the default with security in mind. bind_address defaults to the loopback address, but the Docker config binds all interfaces (source: src/config.rs, ServerConfig::default; docker/synergydb.toml). Document the key in Configuration reference.
5. Registration in Server::start
Add a block to Server::start, next to the other wires (source: src/server/mod.rs, Server::start):
if let Some(port) = server_config.schema_registry_port {
let handler = if let Some(ref tls) = tls_config {
SchemaRegistryHandler::with_tls(storage.clone(), tls.clone())?
} else {
SchemaRegistryHandler::with_storage(storage.clone())
};
self.start_handler(handler, &server_config, port).await?;
}
tls_config is resolved once for all wires through crate::protocol::tls::resolve_tls_config earlier in Server::start (source: src/server/mod.rs, Server::start; src/protocol/tls.rs, resolve_tls_config).
start_handler then (source: src/server/mod.rs, Server::start_handler):
- Binds a
std::net::TcpListeneronbind_address:portand drops it, so a port clash fails startup with "<name>protocol cannot listen on …" instead of the server reporting ready while the wire serves nothing. Test:start_handler_fails_when_port_is_taken. - Creates the shutdown channel and keeps its sender in
shutdown_txs. - Prints "Starting
<name>protocol on<addr>" and records the startup-memory checkpoint. - Spawns
handler.start(addr, rx). An error there is printed, not propagated.
Cargo features are not needed
Cargo.toml has wire-named features (mysql-wire, mongodb-wire, bolt-protocol, s3-api, arrow-flight and others), but none of them gates code. Only grpc and rest-api change what is compiled, and every module under src/protocol/ is built regardless (source: Cargo.toml, [features]; Building). A new wire does not need a feature. Whether it runs is decided by its port key alone.
6. Docker config and EXPOSE
| File | What to add | Source |
|---|---|---|
docker/synergydb.toml |
<wire>_port = <port> if the wire passes its differential suite. Wires without a reference suite stay out of this file (Prometheus and Arrow Flight today) |
docker/synergydb.toml, header comment |
docker/synergydb.allwires.toml |
<wire>_port = <port> in every case |
docker/synergydb.allwires.toml |
Dockerfile |
The port on an EXPOSE line, and its name in the comment above it |
Dockerfile |
The Dockerfile comment above the second EXPOSE line names five wires but the line has six ports. 8081 (Schema Registry) is not named. The Prometheus (9091) and Arrow Flight (8815) default ports are not exposed (source: Dockerfile).
7. Proof pack entries
A wire is reported in the proof pack once it has a differential suite and these entries:
The differential suite
Put it under test-scripts/diff-<wire>/. It runs each check against SynergyDB and the reference in three phases: same connection, second connection, and after a restart (SynergyDB killed with kill -9, the reference restarted). It takes --sdb-restart and --ref-restart commands and prints a total line and one count per phase (source: prove/wires.py, wirediff). The five newer suites share test-scripts/wire_diff_common.py. Not verified: that module and most diff-* directories are not in the snapshot. See Testing.
prove/wires.py
Add a Wire to WIRES. Its fields (source: prove/wires.py, Wire, Step):
| Field | Meaning | Schema Registry value |
|---|---|---|
key |
Wire id used by --wires, BENCH and the baseline |
"schema_registry" |
name |
Display name | "Schema Registry" |
reference |
The real database and version | "Confluent Schema Registry 7.7" |
refs |
REFS names to start, in order |
["ref-kafka", "ref-sr"] |
steps |
Step list: name, kind (diff, matrix, durability), cmd, total regex, phases regexes, timeout
|
One diff step, 2,400 s timeout |
profile |
SynergyDB login setup in prove/sdb.sh
|
"wirediff" |
ports |
SynergyDB listeners to wait for | [8081] |
gaps |
Known differences printed in the report | two entries |
cmd can use {py}, {ts}, {sdb_restart} and {ref_restart:<ref>}, which prove.py expands (source: prove/prove.py, fill). For a suite built on wire_diff_common.py, the helper wirediff(suite, ref, label) builds the step with the right regexes (source: prove/wires.py, wirediff).
The gaps list is maintained by hand and can go stale. The Schema Registry entry says JSON Schema and Protobuf compatibility "is not checked (every change is accepted)", but the code has compatibility checkers for both and README.md reports 59/59 on them (source: prove/wires.py, WIRES; src/protocol/schema_registry/jsonschema.rs; src/protocol/schema_registry/protobuf.rs, incompatibilities; README.md, "Wire scorecard").
prove/refs.py
Add a REFS entry, name -> (image, docker run args, probe kind, start timeout), and a branch for the probe kind in probe(kind). The probe must speak the protocol, not just open a port (source: prove/refs.py, REFS, probe, module docstring). Run the reference on a port that does not clash with SynergyDB's default (the Schema Registry reference listens on 18081). Keep credentials for the reference in the existing pattern; do not reuse production values.
prove/bench.py
Add a function to BENCH keyed by the wire's key. prove.py calls bench.py <key> for every wire unless --skip-bench is given, and bench.py rejects keys it does not know, so a wire without an entry gets a bench log holding only an argument error. Schema Registry is in that state today (source: prove/bench.py, BENCH, main; prove/prove.py, run_bench). See Benchmark harnesses.
prove/ci-baseline.json
Add "<key>": {"<step name>": {"min": N, "total": M}}. gate.py fails a run when a step scores below min, produces no score, or is missing. A step that has no baseline entry is shown as new and passes (source: prove/gate.py, main; prove/ci-baseline.json). Set min from a clean run.
Run it with make prove-quick ARGS='--wires <key>', then python3 prove/gate.py prove/out/latest/results.json (source: Makefile; prove/gate.py, module docstring).
8. Rust tests
| Test | What to cover | Example |
|---|---|---|
tests/wire_preauth_gate.rs |
A request before login is refused and a seeded secret never appears in the reply. The file removes SYNERGYDB_DEV_INSECURE_AUTH first |
schema_registry_rejects_unauthenticated_requests |
tests/protocol_<wire>.rs |
Handler behaviour against a started handler and a client. 27 protocol_*.rs files exist |
tests/protocol_schema_registry.rs |
| Unit tests in the module | Parsers, auth policy, encoders |
src/protocol/schema_registry/mod.rs, auth_policy_tests
|
(source: tests/wire_preauth_gate.rs; listing of tests/; src/protocol/schema_registry/mod.rs) See Testing for the shared helpers.
9. Docs and status
- Add a row to the scorecard in
README.mdwith the reference, the score and the port (source:README.md, "Wire scorecard"). - Add a page under
src/wires/in this book and link it from the wire guides. - Add one
docs/status/YYYY-MM-DD-<topic>.mdentry with the gates you ran. See Contributing.