Skip to content

Contributing

Source files: 131 · checked against Etemenanki 46c12e4 · katana v6.1.0 · shinku-quic v0.1.0
  • Etemenanki/Cargo.toml
  • Etemenanki/Cargo.lock
  • Etemenanki/.cargo/config.toml
  • Etemenanki/.github/workflows/build.yml
  • Etemenanki/README.md
  • Etemenanki/concepts/Cargo.toml
  • Etemenanki/environment/Cargo.toml
  • Etemenanki/reality/Cargo.toml
  • Etemenanki/reality/src/lib.rs
  • Etemenanki/reality/src/keys.rs
  • Etemenanki/protocols/Cargo.toml
  • Etemenanki/supervisor/Cargo.toml
  • Etemenanki/app/Cargo.toml
  • Etemenanki/subscribe/Cargo.toml
  • Etemenanki/webclient/Cargo.toml
  • Etemenanki/ffi/Cargo.toml
  • Etemenanki/concepts/src/buffer.rs
  • Etemenanki/concepts/src/runtime.rs
  • Etemenanki/environment/src/dial/udp.rs
  • Etemenanki/environment/src/routing.rs
  • Etemenanki/protocols/src/socks/udp_link.rs
  • Etemenanki/protocols/src/socks/server.rs
  • Etemenanki/protocols/src/socks/protocol.rs
  • Etemenanki/protocols/src/socks/handshake.rs
  • Etemenanki/protocols/src/helpers/address_family.rs
  • Etemenanki/protocols/src/mux/demux.rs
  • Etemenanki/protocols/src/anytls/core.rs
  • Etemenanki/protocols/src/anytls/users.rs
  • Etemenanki/protocols/src/transports/accept.rs
  • Etemenanki/protocols/src/transports/connect.rs
  • Etemenanki/protocols/src/transports/stream.rs
  • Etemenanki/protocols/src/vless/protocol.rs
  • Etemenanki/protocols/src/vless/codec.rs
  • Etemenanki/protocols/src/transports/reality.rs
  • Etemenanki/protocols/src/transports/camouflage.rs
  • Etemenanki/protocols/src/wireguard/device.rs
  • Etemenanki/protocols/src/hysteria/config.rs
  • Etemenanki/protocols/src/hysteria/server/config.rs
  • Etemenanki/protocols/src/hysteria/server/inbound.rs
  • Etemenanki/protocols/src/hysteria/server/datagrams.rs
  • Etemenanki/protocols/src/vmess/accounts.rs
  • Etemenanki/supervisor/src/lib.rs
  • Etemenanki/supervisor/src/serve.rs
  • Etemenanki/supervisor/src/supervisor.rs
  • Etemenanki/supervisor/src/system/listener.rs
  • Etemenanki/supervisor/src/policy.rs
  • Etemenanki/supervisor/src/build/validate.rs
  • Etemenanki/supervisor/src/topology/spec_plan/mod.rs
  • Etemenanki/supervisor/src/topology/spec_plan/inbound.rs
  • Etemenanki/supervisor/src/topology/spec_plan/transport.rs
  • Etemenanki/supervisor/src/topology/spec_plan/outbound.rs
  • Etemenanki/supervisor/src/topology/inbound/mod.rs
  • Etemenanki/supervisor/src/topology/outbound/mod.rs
  • Etemenanki/subscribe/src/proxy_servers.rs
  • Etemenanki/supervisor/src/entity/usage.rs
  • Etemenanki/supervisor/src/track/mod.rs
  • Etemenanki/supervisor/src/track/pace.rs
  • Etemenanki/app/src/transport.rs
  • Etemenanki/app/src/config.rs
  • Etemenanki/app/src/lower.rs
  • Etemenanki/app/src/instance.rs
  • Etemenanki/app/src/main.rs
  • Etemenanki/concepts/tests/runtime.rs
  • Etemenanki/concepts/tests/client.rs
  • Etemenanki/protocols/tests/pipeline/socks.rs
  • Etemenanki/protocols/tests/unit/socks/server.rs
  • Etemenanki/protocols/tests/unit/socks/protocol.rs
  • Etemenanki/protocols/tests/pipeline/wireguard.rs
  • Etemenanki/protocols/tests/unit/wireguard/device.rs
  • Etemenanki/environment/tests/integration/udp.rs
  • Etemenanki/environment/tests/unit/routing.rs
  • Etemenanki/protocols/tests/unit/helpers/address_family.rs
  • Etemenanki/protocols/tests/unit/vless/protocol.rs
  • Etemenanki/protocols/tests/unit/vless/addons.rs
  • Etemenanki/protocols/tests/unit/anytls/frame.rs
  • Etemenanki/protocols/tests/unit/sss/protocol.rs
  • Etemenanki/protocols/tests/unit/sss/varint.rs
  • Etemenanki/reality/tests/unit/tls13/messages.rs
  • Etemenanki/reality/tests/unit/keys.rs
  • Etemenanki/protocols/tests/pipeline/reality.rs
  • Etemenanki/protocols/tests/unit/vmess/protocol.rs
  • Etemenanki/protocols/tests/unit/vmess/accounts.rs
  • Etemenanki/protocols/tests/unit/anytls/users.rs
  • Etemenanki/protocols/tests/unit/trojan/protocol.rs
  • Etemenanki/protocols/tests/unit/mux/frame.rs
  • Etemenanki/protocols/tests/unit/transports/grpc_framing.rs
  • Etemenanki/protocols/tests/unit/dns/message.rs
  • Etemenanki/protocols/tests/unit/hysteria/protocol.rs
  • Etemenanki/protocols/tests/unit/hysteria/auth.rs
  • Etemenanki/protocols/tests/unit/hysteria/server/datagrams.rs
  • Etemenanki/supervisor/tests/hot_swap.rs
  • Etemenanki/supervisor/tests/tracking.rs
  • Etemenanki/supervisor/tests/sss.rs
  • Etemenanki/supervisor/tests/anytls.rs
  • Etemenanki/supervisor/tests/unit/usage.rs
  • Etemenanki/supervisor/tests/unit/track.rs
  • Etemenanki/supervisor/tests/unit/supervisor.rs
  • Etemenanki/supervisor/tests/unit/serve.rs
  • Etemenanki/supervisor/tests/unit/validate.rs
  • Etemenanki/app/tests/unit/config.rs
  • Etemenanki/app/tests/unit/lower.rs
  • Etemenanki/app/tests/unit/transport.rs
  • Etemenanki/app/tests/integration/e2e_hysteria_inbound.rs
  • Etemenanki/app/tests/integration/e2e_reload.rs
  • Etemenanki/app/tests/support/mod.rs
  • katana/Cargo.toml
  • katana/Cargo.lock
  • katana/.cargo/config.toml
  • katana/.github/workflows/release.yml
  • katana/src/config.rs
  • katana/src/manager/node.rs
  • katana/src/runtime.rs
  • katana/src/api/mod.rs
  • katana/src/api/newv2board.rs
  • katana/src/api/helium.rs
  • katana/src/manager/mod.rs
  • katana/src/lower/mod.rs
  • katana/src/lower/inbound.rs
  • katana/src/lower/outbound.rs
  • katana/tests/unit/lower/inbound.rs
  • katana/tests/unit/lower/outbound.rs
  • katana/tests/unit/lower/spec.rs
  • katana/tests/unit/e2e.rs
  • katana/tests/unit/runtime.rs
  • katana/tests/unit/manager/node.rs
  • katana/tests/unit/api/newv2board.rs
  • katana/tests/unit/api/helium.rs
  • katana/tests/support/mod.rs
  • shinku-quic/Cargo.toml
  • shinku-quic/AGENTS.md
  • shinku-quic/scripts/check-vendor.sh

This page is the working agreement for anyone who changes the kernel or katana. It says which repository a change belongs in, which commands must pass before it lands, what every reviewer checks regardless of the change, how versions are chosen, in which order crates are released, which git operations are off limits, and how these documentation pages are kept in step with the code.

The rules are stable; the numbers are not. Versions, branches, tags and dependency resolutions change with every release, so every step below starts by reading them from the repository rather than from this page. Where this page and a repository disagree, the repository is right and this page is due for an update (see Keeping these docs current).

The code lives in separate git repositories. None of them is a parent of the others, and there is no Cargo workspace spanning them: run every git, Cargo, test and release command inside the repository you are changing.

You are changing Repository Path Package
The sans-I/O core contract, the per-connection runtimes, links, connectors, shared net types Etemenanki concepts/ etemenanki-concepts
Host dialers (TCP, UDP, QUIC), the shared socket policy, the route model Etemenanki environment/ etemenanki-environment
REALITY: its TLS 1.3 subset, the session_id authentication, the server and client handshakes, RealityStream, the camouflage relay to the cover site Etemenanki reality/ etemenanki-reality
A protocol, a transport, mux, sniffing, DNS Etemenanki protocols/ etemenanki-protocols
Accept loops, sessions, the connector, the plane, routing and balancers, outbounds, the Spec and its validation, plan and apply, flow tracking, per-user usage and speed limits, the host socket policy on outbound sockets Etemenanki supervisor/ etemenanki-supervisor
The subscribe-file format Etemenanki subscribe/ etemenanki-subscribe
The client REST API’s HTTP layer Etemenanki webclient/ etemenanki-webclient
The mobile library and its bindings Etemenanki ffi/, ffi/bindgen/ etemenanki-ffi
The TOML schema, merging a subscribe file, lowering a config into a Spec, reloading, route switching and the REST API’s config side of the standalone proxy Etemenanki app/ etemenanki-app
Panel clients, node lifecycle, lowering a node into a Spec, audit routes, traffic reporting, katana’s own configuration and reload katana src/ katana
The QUIC stack under Hysteria 2: the patched quinn, Brutal, the congestion switch after the handshake, client port hopping, Bandwidth shinku-quic vendor/, shinku-quic/ shinku-quinn-proto, shinku-quinn, shinku-h3-quinn, shinku-quic

Hysteria 2’s own rules (authentication, obfuscation, whose rate wins) stay in etemenanki-protocols; shinku-quic knows QUIC, not Hysteria, and its vendor/ tree changes only by re-vendoring an upstream release or through patches/quinn-proto.patch. shinku-quic overview describes its boundaries.

Five boundaries catch people out:

  • REALITY lives in a crate of its own, below the others. etemenanki-reality depends on no other etemenanki crate, so a REALITY fix ships as a release of that crate alone. etemenanki-protocols reaches it only through its reality feature, off by default like hysteria and tun, and behind wrapper types of its own (transports::reality, and Camouflage in transports::camouflage): no type of the reality crate shows in protocols’ public API, which is why a compatible reality release reaches downstreams through a lockfile update without a protocols release. The supervisor and the app turn the feature on. REALITY overview describes the crate.
  • Routing semantics belong in environment/src/routing.rs. The route model was vendored unchanged from the standalone routing crate (harranu) as etemenanki_environment::routing, and the supervisor routes with that copy for every front end. A change made only in harranu reaches none of them. When harranu itself needs a change, it is released on its own, never as part of a kernel release; weigh whether the same change also belongs in environment/.
  • Semantic validation has one owner. The supervisor knows no configuration format: a front end lowers its own format faithfully into a Spec, and supervisor/src/build/validate.rs owns every rule about what a spec means, for every front end. A rule that depends on the meaning of a spec goes there, once; a front end refuses only what its own format gets wrong.
  • katana has one node model. Whatever the panel, a node reaches lowering as the helium-node-api crate’s node config (src/api/mod.rs → Node), the contract katana shares with Helium, whose types cannot write what the kernel cannot serve and whose validate checks the rules they cannot express. helium’s answer is one already. A UniProxy answer is converted into one by parse_node_config in src/api/newv2board.rs, which refuses by name, as the answer is read, what it asks for and katana cannot serve. Lowering (src/lower/) then judges only this host’s part: the certificate settings, the listen address, the real-IP and handoff keys, the VMess clock check, Hysteria 2’s credential kind and congestion control. A new node feature therefore goes into the contract first, then into the UniProxy conversion where a UniProxy panel describes it, and only the host’s side of it into lowering.
  • Reference trees are not implementations. Xray-core/, hysteria/ and sing-box/ in Etemenanki are upstream sources (git submodules) kept for protocol reference and built by the interop tests (Xray and Hysteria by both repositories, sing-box by the app’s AnyTLS tests); Xboard/, V2bX/ and XrayR/ in katana are kept for panel reference. A bug that shows up against them is fixed in the Rust code, never by editing the reference tree.
  • katana sees only published kernels. katana depends on etemenanki-concepts, etemenanki-environment, etemenanki-protocols and etemenanki-supervisor by version from a private Cargo registry, takes etemenanki-reality through protocols’ reality feature, and the kernel takes shinku-quic’s packages from the same registry. The helium-node-api crate, the types of Helium’s node API v2 that katana and Helium both compile, comes from that registry too. A kernel fix reaches katana only after the affected crates are published and katana’s lockfile is moved to them. Workspace and crates has the details, including which features katana enables (vendored-openssl, hysteria and reality on etemenanki-protocols; it gets tun through the supervisor).

Files ignored by .gitignore (scratch copies, build output) are never authoritative. Review and change only tracked sources.

  1. Read the live state of the repository. Every later decision depends on it.

    Terminal window
    git status --short --branch
    git branch --show-current
    git remote -v
    git log --oneline --decorate --max-count=12
    git tag --sort=-v:refname | head -20
  2. Read the manifests. Cargo.toml, Cargo.lock and .cargo/config.toml say which versions exist, which registry a crate publishes to and how the registry authenticates. For the package graph, use cargo metadata --no-deps --format-version 1. The version a dependency actually resolves to is in Cargo.lock or cargo metadata, not in the requirement in Cargo.toml.

  3. Read the call chain, not just the function. For a change to a public item in concepts, environment, protocols or supervisor, search katana and every dependent in the workspace (the supervisor, the app, the webclient and the ffi) for every use of it: a signature change there is a breaking release (see Versioning). The one dependent of reality is protocols, through transports::reality and transports::camouflage.

  4. Walk the failure paths. For configuration, protocol, network or lifecycle code, ask what happens on malformed input, on a peer that stops reading, on cancellation, and when a dependency (DNS, a port, the panel) is not there. The review checklist lists what has gone wrong before.

Fix the cause, not the test. Keep the change as small as it can be while still complete, leave unrelated code alone, and do not add a dependency the change does not need.

A change lands only when its repository’s gates pass. The release gates are run in addition, immediately before publishing or tagging.

Terminal window
cargo fmt --all -- --check
cargo test --workspace
cargo clippy --workspace --all-targets --all-features -- -D warnings
# before a release, additionally:
cargo check --workspace --locked

In shinku-quic, scripts/check-vendor.sh checks vendor/ against the upstream releases it claims to be (quinn and h3-quinn byte for byte, quinn-proto plus patches/quinn-proto.patch), and fmt and clippy cover only the shinku-quic crate: upstream code is not reformatted or linted.

Gate What it protects
cargo fmt … --check One formatting, so diffs show only real changes
cargo test Behaviour, including the tests named in the checklist below
cargo clippy … -D warnings Every warning is an error. In etemenanki-environment, etemenanki-reality and etemenanki-protocols this is also what enforces the crate-wide denies on unwrap_used, expect_used, indexing_slicing and arithmetic_side_effects, which keep untrusted bytes from panicking the process; cargo build and cargo test do not check them
--all-features Lints the code behind features no workspace member turns on: quic on etemenanki-environment, and vendored-openssl on etemenanki-protocols, etemenanki-app and etemenanki-ffi. (hysteria, tun and reality are compiled anyway, because the supervisor enables them.)
--all-targets Also compiles and lints the test crates, the ffi/bindgen binary and the criterion benches
--locked Fails instead of silently changing Cargo.lock, so what is tested is what is released

Neither repository’s CI runs these gates. Etemenanki’s build.yml runs on pull requests and on manual dispatch, and only builds the etemenanki-app release binary; katana has no workflow for branches or pull requests: its one workflow, release.yml, builds the release binaries when a tag is pushed (see katana release). A green CI run says nothing about tests or clippy. Run the gates locally.

The kernel crates build for Linux, macOS (AArch64) and Windows (x86-64, AArch64), but CI builds only the Linux binary; the other targets are built by the apps that embed the crates. Code that only another platform compiles (the Wintun device, TUN routes on macOS and Windows, the TLS clients’ CA store on Windows and macOS, the refusal of a Unix-socket listen off Unix) is therefore compiled by no gate run on Linux unless you build for that target.

A green cargo test can still have skipped things. The Xray, Hysteria and sing-box interop tests build the upstream binaries with go from the reference trees. When go is missing or the build fails, the support code prints a SKIP: line and each test that needs the binary returns early and passes, some after printing skipping: hysteria binary unavailable (app/tests/support/mod.rs, and katana’s tests/support/mod.rs, which looks for the Xray and Hysteria trees in the sibling ../Etemenanki checkout). Changes to a protocol (the Vision flow included), a transport (REALITY included), TLS, SOCKS or WireGuard should be checked with those interop tests actually running. Testing lists what each suite needs.

Before asking for review, check the diff itself:

Terminal window
git diff --check
git diff --stat
git diff

Look for unrelated files, leftover debug output, temporary or generated files, a lockfile that moved more than the change explains, and anything that looks like a credential, token or private key.

These invariants come from the architecture and from past reviews. They are not a list of open bugs. Each one describes a property the code must have and must not lose. Where the verified revision does not fully meet an item yet, the item says so, and a change in that area should move towards the rule, not away from it. Apply every item that touches the code under review, and add a test for any mechanism a change introduces or moves.

UDP datagrams come from the association’s peer

Section titled “UDP datagrams come from the association’s peer”

A UDP relay must only accept datagrams from the peer it is serving, and a client must only accept replies from the relay it associated with. A packet from any other address is dropped, never relayed or delivered.

  • Server: the SOCKS server’s UDP association loop in protocols/src/socks/server.rs hears one client (RFC 1928 §7), described by an ExpectedSender that is built before the relay socket is bound. Over TCP the client is the control connection’s peer: admits requires every datagram’s IP to be that peer’s, and a datagram from any other IP is dropped unread. The first datagram that parses and carries a payload pins the port (pin; the first pin holds), so a neighbour on the same address cannot claim the association by sending junk first. A UDP ASSOCIATE whose DST.ADDR names the peer’s own IP with a non-zero port pins that port up front. A request that names anything else (another address, an unspecified address, a domain) is set aside rather than trusted or refused, because it is not where the datagrams come from: a client behind NAT names its LAN address, and sing-box names a loopback address whenever its first target is private. Replies go only to the pinned client, in the form the relay socket saw it. Over a Unix socket there is no peer, so the request must name its exact IP and a non-zero port. When there is no client the relay could hold to, the server answers 0x02 (STATUS_NOT_ALLOWED, “connection not allowed by ruleset”) and closes the control connection. That happens for a Unix-socket request that names a domain or leaves the address or the port at zero, and for a relay (udp_bind) in an address family the client’s IP is not in: hears lets an IPv4 or IPv4-mapped relay hear only IPv4, the unspecified IPv6 relay :: hear both families, and any other IPv6 relay hear only IPv6. An association never outlives its control connection: EOF or an error on the TCP stream ends it, and so does RELAY_IDLE_TIMEOUT without traffic. Datagrams with a non-zero FRAG byte are discarded by parse_udp_packet in protocols/src/socks/protocol.rs. A SOCKS inbound over anything but plain TCP (SOCKS5 inside TLS) serves no association: validation in supervisor/src/build/validate.rs refuses udp = true there, because the relay’s datagrams would go to a UDP socket beside the transport, in the clear (socks_relays_udp_over_plain_tcp_only, supervisor/tests/unit/validate.rs).

    struct ExpectedSender {
    ip: IpAddr, // canonical; every datagram must come from it
    port: Option<u16>, // when the request named it alongside `ip`
    client: Option<SocketAddr>, // the first sender forwarded for; replies go here
    }
    impl ExpectedSender {
    fn new(peer: Option<IpAddr>, declared: Option<&Destination>, hub: IpAddr) -> Result<Self, &'static str>;
    fn admits(&self, from: SocketAddr) -> bool;
    fn pin(&mut self, from: SocketAddr);
    fn client(&self) -> Option<SocketAddr>;
    }
    fn hears(hub: IpAddr, ip: IpAddr) -> bool;
  • Comparison: both sides compare senders with endpoint in protocols/src/socks/protocol.rs: the IP in canonical form, so an IPv4-mapped IPv6 address from a dual-stack socket is the IPv4 one, and the port. IPv6 flow info and scope are left out.

    pub(crate) fn endpoint(addr: SocketAddr) -> (IpAddr, u16);
  • Client: SocksUdpLink in protocols/src/socks/udp_link.rs skips any datagram whose source is not the relay address the server named, tested as endpoint(from) != endpoint(self.relay), so a dual-stack client socket still hears an IPv4 relay. Its own UDP ASSOCIATE names no source (all zeros, as RFC 1928 has a client do when it does not know), so a server that checks sources holds it to the control connection’s address and the port of its first datagram:

    impl<S> DatagramLink for SocksUdpLink<S>
    where
    S: AsyncRead + AsyncWrite + Unpin,
    {
    type Addr = Destination;
    fn poll_recv_from(
    &mut self,
    cx: &mut Context<'_>,
    buf: &mut ReadBuf<'_>,
    ) -> Poll<io::Result<Destination>>;
    }

A change to either side needs a negative test that sends from a third address and asserts nothing is delivered. The existing ones are udp_association_ignores_another_ip, udp_association_ignores_another_port_once_pinned, udp_association_is_not_widened_by_the_request and udp_link_ignores_datagrams_not_from_the_relay in protocols/tests/pipeline/socks.rs (the two that send from 127.0.0.2 run on Linux only). The same file pins the refusals with udp_association_over_a_unix_socket_needs_its_exact_source and udp_association_refuses_a_relay_that_cannot_hear_the_client, and the positive round trip is new_server_vs_new_client_udp. The unit tests in protocols/tests/unit/socks/server.rs pin ExpectedSender directly, the hears rules included through ExpectedSender::new, and endpoint_sees_through_ipv4_mapping_and_ignores_flow_info (protocols/tests/unit/socks/protocol.rs) pins the comparison. SOCKS describes the association in full.

Queues are bounded and backpressure reaches the producer

Section titled “Queues are bounded and backpressure reaches the producer”

Every per-connection buffer or queue has a fixed upper bound. Moving items from a bounded channel into an unbounded collection to keep a producer running defeats the bound: when the consumer stalls, the stall must travel back to whoever is producing.

  • Mechanism: ProxyServerRuntime keeps three buffers per connection, each capped at BUF_SIZE bytes: the transport read buffer (ReadBuffer<const N: usize>), the transport staging buffer (WriteBuffer<const N: usize>), both in concepts/src/buffer.rs, and an outbound scratch array. BUF_SIZE is a cap, not an allocation. The read buffer starts at INITIAL (2048 bytes, or N if smaller); make_room moves the unparsed tail to the front and doubles the storage up to N each time reading uses up the free region, and grow_to makes room for a whole datagram before a datagram read. The staging buffer holds nothing until the first stage, and Staging::reserve grows it to the larger of what the stage needs, twice its size and 2 KiB, never past N. The scratch array (Option<Box<[u8; BUF_SIZE]>>) is allocated at the first outbound read. Backpressure is measured against the cap, not the allocation: WriteBuffer::room counts against N, and a read buffer whose unparsed bytes fill all N (is_saturated) is a frame too large. The contract in concepts/src/runtime.rs is that a forward that cannot complete holds every effect behind it, and while a forward of transport bytes waits the transport is not read; an outbound is not read while the staging buffer lacks STAGING_RESERVE plus one byte (plus a whole datagram for a datagram outbound). A client that stops reading therefore stops the downlink at the outbound socket.

  • WireGuard driver: the driver task in protocols/src/wireguard/device.rs moves every connection’s bytes between bounded channels and smoltcp sockets, so besides the runtime’s buffers it keeps per-connection state of its own. Each connection’s way up is an Uplink: the application’s channel, bounded at CHANNEL_CAP = 256 items, and a slot for at most one item the socket has not accepted yet. The driver reads the channel only while that slot is empty (poll_refill stays Pending while an item is held), so a remote or tunnel that stops draining one connection fills that connection’s socket (a TCP socket buffers TCP_BUFFER = 64 * 1024 bytes each way), then its channel, and then blocks the application’s sender, while the other connections keep moving. It hands one socket at most CHANNEL_CAP items per pass, so no producer keeps the driver to itself. On the way down, a socket is read only while its channel has room; a channel found full is waited on through RoomWaits, which wakes the driver once that channel has room, so a slow reader does not keep the driver running passes over every socket. Each pass also takes up to RECV_BATCH = 64 datagrams that have arrived from the peer, rather than one pass per datagram. A UDP datagram that finds its association’s send ring full is held in the same slot until the next poll empties the ring; one that can never be sent (larger than the whole ring, or to an unaddressable endpoint) is dropped rather than retried.

    struct Uplink<T> {
    rx: Option<mpsc::Receiver<T>>,
    held: Option<T>,
    }
    impl<T> Uplink<T> {
    fn take(&mut self) -> Option<T>;
    fn hold(&mut self, item: T);
    fn poll_refill(&mut self, cx: &mut Context<'_>) -> Poll<()>;
    }
  • Tests: stalled_outbound_holds_uplink_but_not_other_downlink, frame_larger_than_the_buffer_is_an_error, a_frame_past_the_grown_buffer_is_still_an_error and datagram_outbound_is_never_truncated_by_staging_backpressure (concepts/tests/runtime.rs); the unit tests in concepts/src/buffer.rs, among them read_buffer_starts_small_and_doubles_up_to_n, make_room_moves_the_tail_and_grows_below_n, write_buffer_holds_nothing_until_a_stage and staging_grows_to_n_and_no_further; backpressure_from_the_wire_reaches_the_writer (concepts/tests/client.rs); a_stalled_tcp_flow_blocks_its_writer (protocols/tests/pipeline/wireguard.rs), which checks that a flow whose remote reads nothing blocks its writer once the buffers above are full and does not hold up another flow on the same tunnel; a_held_item_keeps_the_channel_unread and a_stalled_reader_does_not_keep_the_driver_busy (protocols/tests/unit/wireguard/device.rs).

Session tables that grow with peer input carry an explicit cap too, for example MAX_SESSIONS = 256 per connection for Hysteria 2 UDP sessions (protocols/src/hysteria/server/datagrams.rs) and for mux sub-flows (protocols/src/mux/demux.rs), and MAX_STREAMS = 256 streams per AnyTLS session (protocols/src/anytls/core.rs). Observers get the same treatment: the flow tracker’s lifecycle events go out on a broadcast channel of EVENT_CAPACITY = 1024 (supervisor/src/track/mod.rs) that lets a slow subscriber lag and lose events rather than hold the data plane back.

A semaphore that claims to bound active connections must hold its permit until the relay has finished. A permit that covers only the handshake, the decode or the transport stage bounds that stage, not active connections. At every spawn, check that the permit moves into the spawned task.

Where Constant Held by
Stream inbounds of every front end (supervisor/src/serve.rs) MAX_LIVE_CONNECTIONS_PER_INBOUND = 4_194_304 An Arc<OwnedSemaphorePermit> taken in run_stream_inbound from the inbound’s InboundCaps, which every listener of the inbound shares (its TCP bind and its handoff socket), cloned into every stream a transport yields, and bound as _live for the whole of serve_connection
Hysteria 2 circuits (protocols/src/hysteria/server/inbound.rs, datagrams.rs) circuit_permits: the inbound’s max_circuits, default DEFAULT_MAX_CIRCUITS = 4_194_304 in both etemenanki-app and katana A permit per proxy stream, bound as _permit inside the task that awaits the runtime, and one per UDP session, held by the session entry

The stage limit next to them, MAX_HANDSHAKES_PER_INBOUND = 204_800, is deliberately separate and covers the handshake stage; it is not a connection limit. Both semaphores belong to the inbound, not to a listener: caps_for in supervisor/src/supervisor.rs gives a listener added beside a kept one the kept one’s InboundCaps, so a second listener is no second pool, and an_inbounds_listeners_share_one_set_of_caps (supervisor/tests/unit/supervisor.rs) pins it. the_circuit_limit_refuses_new_sessions (protocols/tests/unit/hysteria/server/datagrams.rs) pins the circuit cap for UDP sessions.

Two kinds of connection hold permits without ever reaching a protocol core. A REALITY connection that is not a client of the server comes back from the transport’s accept as Disposition::Camouflage: Connection::serve_tcp drops its handshake permit, keeps its live one for the whole relay to the cover site, ends the relay with the session, and tells the ban guard nothing (a_camouflaged_connection_gives_its_handshake_permit_back, supervisor/tests/unit/serve.rs). An sss stream refused before authentication (serve_sss) keeps its handshake permit while it is drained, as a stream still waiting for its header would, and gives it back when it is handed to the fallback; either way the live permit stays until it ends.

When a name resolves to several addresses, the caller must pick one its local sockets can actually reach, and keep the others as fallbacks, rather than taking the first answer and dropping the packet when that family is unavailable.

  • Mechanism: select_candidate_ips in protocols/src/helpers/address_family.rs filters the resolver’s answer by the outbound’s AddressFamilyStrategy and by FamilySupport (which families the outbound can source traffic from: FamilySupport::both() for a dialer that leaves source selection to the kernel, FamilySupport::from_addrs for a userspace netstack with its own interface addresses), and orders it with a stable sort so the other family stays as a fallback. DualStackUdp in environment/src/dial/udp.rs binds one socket per requested family, leaves out a family whose bind fails, and sends each datagram from the socket of the peer’s family.

    pub fn select_candidate_ips(
    resolved: Vec<IpAddr>,
    strategy: AddressFamilyStrategy,
    support: FamilySupport,
    ) -> Vec<IpAddr>;
    impl DualStackUdp {
    pub fn socket_for(&self, peer: &SocketAddr) -> io::Result<&UdpSocket>;
    }
  • Tests: auto_skips_families_without_a_local_address, prefer_ipv4_keeps_ipv6_as_fallback and ipv4_only_filters_to_ipv4 (protocols/tests/unit/helpers/address_family.rs); v6_socket_is_v6_only_and_dual_stack_picks_by_family (environment/tests/integration/udp.rs).

A parser checks every fixed field (version, reserved bytes, lengths, command and type codes) and refuses a value it does not know. Never assume the peer is a correct implementation, and never let a declared length allocate or read beyond a bound before it is checked. In environment, reality and protocols the clippy denies above make unchecked indexing and unchecked arithmetic a lint error, so the code has to handle an out-of-range index or an overflowing length instead of panicking on it.

Parser Tests that pin the strictness
VLESS rejects_bad_version, rejects_an_unknown_or_malformed_flow_header, response_header_rejects_version (protocols/tests/unit/vless/protocol.rs); the request addons, read as Xray’s protobuf: an_unknown_flow_is_refused, an_unknown_field_is_refused, malformed_protobuf_is_refused_not_panicked (protocols/tests/unit/vless/addons.rs)
AnyTLS every_command_byte_round_trips_and_the_rest_are_refused, a_split_header_waits_and_an_unknown_command_fails (protocols/tests/unit/anytls/frame.rs)
sss bad_fields_are_errors_as_soon_as_they_arrive (protocols/tests/unit/sss/protocol.rs), non_minimal_and_overlong_varints_are_refused (protocols/tests/unit/sss/varint.rs)
REALITY’s TLS 1.3 messages malformed_hellos_are_refused, server_hellos_outside_the_subset_are_refused, and every_truncation_and_mutation_is_handled_without_panicking over 20,000 mutated ClientHellos (reality/tests/unit/tls13/messages.rs). On the server, anything that does not parse goes to the cover site
VMess rejects_unknown_version, rejects_unknown_command, rejects_unknown_security, rejects_invalid_option_relationship (protocols/tests/unit/vmess/protocol.rs)
Trojan rejects_missing_crlf, rejects_oversize_udp_packet (protocols/tests/unit/trojan/protocol.rs)
mux.cool rejects_unknown_status_and_network, rejects_truncated_metadata (protocols/tests/unit/mux/frame.rs)
gRPC framing decoder_rejects_unexpected_field, decoder_rejects_an_oversized_length_before_buffering_the_body (protocols/tests/unit/transports/grpc_framing.rs)
DNS truncated_and_malformed_input_never_panics, rejects_an_over_long_name_and_label (protocols/tests/unit/dns/message.rs)
Hysteria 2 varint_above_62_bits_is_refused_not_panicked, tcp_response_rejects_an_undefined_status_byte (protocols/tests/unit/hysteria/protocol.rs)

A typo must stop the program, not fall back to a default that changes what the configuration means. Stable configuration structs reject unknown fields, and a value that is not recognised is an error, not “anything else”.

  • Mechanism: the configuration structs carry #[serde(deny_unknown_fields)] (43 of them in app/src/config.rs, 12 in katana’s src/config.rs, and those of the subscribe file). tls_layer in app/src/transport.rs validates security against the network instead of comparing it with "tls", so an unknown value is refused rather than becoming plaintext. security = "reality" is a security of its own: resolve_stream takes it before tls_layer and only over network = "tcp", and the supervisor’s validation refuses REALITY under any protocol but VLESS, on an inbound or an outbound:

    pub fn tls_layer(network: &str, security: Option<&str>, ctx: &str) -> io::Result<bool>;
    pub fn resolve_stream(stream: &StreamConfig, ctx: &str) -> io::Result<StreamShape>;
  • Tests: a_mistyped_key_is_rejected_rather_than_ignored (app/tests/unit/config.rs); an_unknown_security_is_rejected_on_every_network, tcp_with_tls_is_rejected_and_names_the_fix and reality_is_refused_on_any_network_but_tcp (app/tests/unit/transport.rs); reality_settings_fail_closed, reality_is_vless_only and a_reality_outbound_is_vless_only (supervisor/tests/unit/validate.rs); in katana, reject_unknown_sni_is_refused_rather_than_ignored, acme_cert_mode_rejected, hysteria_refuses_an_unknown_obfs_rather_than_disabling_it and hysteria_refuses_an_unknown_congestion_control (tests/unit/lower/inbound.rs), a_transport_katana_cannot_serve_is_refused and a_tcp_header_other_than_none_is_refused (tests/unit/api/newv2board.rs), and an_invalid_address_family_is_rejected_for_every_protocol (tests/unit/lower/outbound.rs).

The binaries show it directly. A misspelled key under [inbound.stream] stops etemenanki-app --test with configuration invalid: TOML parse error at line 7, column 1, followed by the unknown field and the keys the table accepts. The process exits with status 1 and binds nothing.

Pay particular attention to keys that decide exposure or security: listen address, port, protocol, network, security, TLS settings, outbounds and routes.

A reload must not tear down the running configuration and then discover that the new one cannot start. Validate and build first; switch only when that succeeded; keep the old state when it did not.

flowchart LR
  read["read config and subscribe files"] --> lower["effective config, lower into a Spec"]
  lower -->|error| keep["log, keep the running spec"]
  lower --> apply["Supervisor::apply: plan, prepare, commit"]
  apply -->|refused| keep
  apply --> report["log config reloaded: <report>"]
  • App mechanism: Core::reload_with in app/src/instance.rs reads the config and subscribe files, lowers them into a spec and calls Supervisor::apply. The supervisor prepares everything that can fail, binding new listeners beside the running ones, before it commits, so a refused apply leaves every running listener, connection and user as it was. A spec that does not lower, or that the supervisor refuses, is logged as reload: <error>; keeping the running config; a change that would end live connections (a TUN or Hysteria 2 obfuscation change) is refused with reload refused, keeping the running config: inbound <tag>: <reason>, which would end its live connections; restart to apply it. A committed apply is logged as config reloaded: <report>.

    pub enum Reload {
    Applied(ApplyReport),
    Unchanged { failed: Option<String> },
    }
    impl Core {
    pub async fn reload_with(&self, read: impl FnOnce() -> Read) -> Result<Reload, LoadError>;
    }
    impl<U: UserId> Supervisor<U> {
    pub async fn apply(&self, spec: Spec<U>) -> Result<ApplyReport, ApplyError>;
    }
  • katana mechanism: a file that does not load is refused first, in the watcher loop, with config reload failed, keeping current: <error>. apply_reload in src/runtime.rs then checks every node the reload adds or changes against what it would run (lower::test_spec and etemenanki_supervisor::check, with a new panel client for a changed entry) before touching any running node. If one fails, it applies nothing and logs reload: node <display_id>: <error>; keeping current config. Only then are node changes applied, node by node: a removed or re-identified node is stopped, a new one is spawned, a changed one is sent the edit, and a change to [[outbound]] or [dns] reaches every node as StaticUpdate::Globals. A node the reload adds or respawns that fails to come up, for example on a port that is still taken, keeps retrying as described under Node tasks are supervised.

  • Tests: a_refused_spec_changes_nothing (supervisor/tests/hot_swap.rs) checks that a bind failure on one new inbound releases another bound in the same prepare and changes nothing; an_open_connection_keeps_transferring_across_a_reload and a_reload_that_removes_a_user_closes_only_their_connections (app/tests/integration/e2e_reload.rs) and a_reload_keeps_the_inbound_serving_on_its_udp_port (app/tests/integration/e2e_hysteria_inbound.rs) check what an applied reload keeps; a_reload_with_a_node_that_does_not_build_changes_nothing (katana tests/unit/runtime.rs) checks that an entry with a mistyped node_type leaves the running node, its live connection and the route edit made alongside untouched, and the other tests in that file pin which edits respawn a node and which reach it in place; route_change_drops_connections and repeated_user_refreshes_never_disturb_a_live_connection (katana tests/unit/e2e.rs) pin what a katana reload and a panel refresh keep. Planning and applying a change, etemenanki-app: run, reload and shutdown and Runtime and config reload describe these paths in full.

A transient failure of the first panel request, of DNS, of a bind or of bring-up must not end a node’s task for good with nothing to restart it. A long-lived node task needs retry with backoff under a supervisor, and must still stop promptly on cancellation.

  • Bootstrap: NodeManager::bootstrap in src/manager/node.rs calls try_bootstrap until the node is up or its CancellationToken is cancelled. An attempt first asks the panel afresh (forget_etags), then fails when node_info fails or returns nothing (a newV2board answer that asks for what katana cannot serve fails here, with the reason in its message: node <id>: node_info failed: parse UniProxy config response: <reason>; retrying in <n>s), when user_list fails or returns nothing (a node up without its users would serve nobody), or when lowering the node or Supervisor::start fails (initial start failed: <error>), for example on a port that is still taken. It also reads the audit rules unless disable_get_rule is set. After a failure the node logs node <id>: <reason>; retrying in <n>s and waits BOOTSTRAP_RETRY_MIN (1 s), doubling with each failure up to BOOTSTRAP_RETRY_MAX (60 s), or up to the poll period (controller.update_periodic) when that is shorter. While it waits it applies static updates as they arrive, which keeps the runtime’s bounded channel to it from filling, and a config edit ends the wait at once, since the edit may be the fix. Cancellation is honoured both during an attempt and during the wait.

    const BOOTSTRAP_RETRY_MIN: Duration = Duration::from_secs(1);
    const BOOTSTRAP_RETRY_MAX: Duration = Duration::from_secs(60);
    impl NodeManager {
    pub async fn run(self: Arc<Self>, shutdown: CancellationToken, static_rx: mpsc::Receiver<StaticUpdate>);
    async fn bootstrap(&self, shutdown: &CancellationToken, static_rx: &mut mpsc::Receiver<StaticUpdate>) -> bool;
    async fn try_bootstrap(&self) -> Result<(), String>;
    }
  • Steady state: NodeManager::poll_cycle falls back to the last answer when a panel request fails or returns nothing, a refused UniProxy answer included (node <id>: node_info: parse UniProxy config response: <reason>), and tries again on the next tick. The loop exits only when its CancellationToken is cancelled. Whether the node stopped in the steady state or while still bootstrapping, run then shuts its supervisor down with Duration::ZERO and calls report() once more, for what arrived since the last poll.

  • Tests: a_node_comes_up_once_the_panel_answers, a_node_whose_port_is_taken_comes_up_once_it_is_free and a_node_that_never_bootstraps_still_stops (tests/unit/e2e.rs). The node manager describes the whole loop.

Reload rebuilds whatever caches configuration

Section titled “Reload rebuilds whatever caches configuration”

If an object caches configuration fields when it is built, a reload that changes those fields must rebuild or update that object. Updating the manager’s copy of the config while the client keeps the old one is the failure this rule exists for.

  • Identity: a node’s identity in src/runtime.rs is the tuple of fields that decide which panel node it serves. A reload that changes the identity removes the node and spawns a new one, with a new PanelClient and a fresh traffic registry, so one panel node’s counters are never billed to another; a reload that keeps it sends StaticUpdate::Config to the running node.

    type NodeId = (String, String, u32, String, String);
    fn identity(cfg: &NodeConfig) -> NodeId;
    pub fn panel_node_type(cfg: &NodeConfig) -> String;

    The tuple is (panel_type, api.host, api.node_id, api.key, panel node type), with panel_type lowercased. The panel node type comes from panel_node_type in src/api/mod.rs: newV2board finds a node by its id and the node_type it is asked for, so there it is "vless" for a V2ray-family node (node_type V2ray, Vmess or Vless) with enable_vless, else the lowercased api.node_type; helium finds a node by id alone, so there it is empty. display_id shows the node type after the id when it is not empty.

  • Cached fields: Client::new in src/api/newv2board.rs and src/api/helium.rs copies every field it needs from panel_type, enable_mtls, [node.api] and [node.hysteria] into the client, including the timeout, api.speed_limit, api.rule_list_path and whether it presents the client certificate, and on newV2board api.node_type, api.enable_vless and the [node.hysteria] block it completes a Hysteria 2 node with (the helium client refuses those, [node.hysteria] congestion aside, as it refuses every local key the panel describes). NodeManager::apply_static in src/manager/node.rs therefore builds a new PanelClient whenever panel_type, enable_mtls, anything in [node.api] or anything in [node.hysteria] changed, before it stores the edit, and refuses an edit whose client does not build (node <id>: config edit refused, keeping the running one: <error>). The new client takes over the routes the old one read from a newV2board node config (PanelClient::inherit_routes), so audit rules derived from them keep applying until it reads the config itself. It holds no ETags, so the node then runs one full panel poll with it. An edit to a local setting the listener or its routes are built from ([node.route], controller.listen_ip, controller.cert, controller.disable_sniffing or [node.hysteria]) marks the node for a rebuild: with the next applied change, every connection is closed (Supervisor::close(Selector::All)). The listener’s socket is kept unless its bind changes. An edit to controller.disable_vmess_clock_check, real_ip_header, real_ip_from, enable_device_limit, ban_max_failures, ban_window_secs, ban_secs or carrier_max_failures, which only the inbound’s handler, the users’ limits and the policies are built from, also runs one panel poll at once, without marking a rebuild. So does an edit to handoff_dir or handoff_group: the handoff socket is a listener beside the node’s own, and that poll binds, moves or drops it while every connection, a handed-over one included, runs on.

  • What to check: a new field a client caches is covered only if it is inside [node.api], [node.hysteria], panel_type or enable_mtls; otherwise it must join that comparison in apply_static, or be pushed to the client on reload. A field that decides which panel node is served belongs in the identity.

  • Tests: a_newv2board_node_is_also_the_type_it_asks_for, a_node_is_logged_by_its_panel_node_not_its_key, a_newv2board_type_edit_respawns_the_node, a_client_edit_takes_effect_without_dropping_connections and enable_mtls_is_on_unless_turned_off (tests/unit/runtime.rs); a_rebuilt_client_keeps_the_routes_it_has_not_read (tests/unit/api/newv2board.rs); a_reload_of_the_real_ip_keys_alone_applies_at_once, a_reload_of_the_handoff_keys_alone_applies_at_once and a_reload_of_enable_mtls_alone_rebuilds_the_client (tests/unit/manager/node.rs).

A token bucket charges the actual number of bytes and produces a wait or a debt in proportion. A chunk larger than the bucket’s capacity must not pass after a single refill period, and the achieved rate must not depend on the relay’s buffer or chunk size.

  • Mechanism: Pacer in supervisor/src/track/pace.rs is one bucket per user, shared by every flow of that user in both directions. It refills at rate bytes per second and banks at most one second of it. charge always takes the full amount after a transfer moves, letting the balance go negative, and poll_ready, called by the Metered wrapper before each read and write, holds every flow of that user back until the debt is repaid. The rate comes from the spec’s UserSpec::speed_limit, published at commit and at each user edit as a change set: Actor::publish_limits in supervisor/src/supervisor.rs hands Tracker::change_speed_limits only the users whose limit changed. katana sets it to each user’s own limit (lower_users in src/lower/mod.rs), which the panel clients have already replaced with [node.api] speed_limit for every user when that is set.

    impl Pacer {
    pub(crate) fn set_rate(&self, rate: Option<NonZeroU64>);
    pub(crate) fn charge(&self, n: usize);
    pub(crate) fn poll_ready(&self, cx: &mut Context<'_>, pause: &mut Option<Pin<Box<Sleep>>>) -> Poll<()>;
    }
  • Tests: a_limited_users_flow_moves_at_its_limit, a_users_flows_share_one_limit and a_raised_or_removed_limit_is_felt_within_a_second (supervisor/tests/unit/track.rs), on a paused tokio clock, so their timings are exact; a_user_is_held_to_their_speed_limit (katana tests/unit/lower/spec.rs); a_users_speed_limit_paces_their_traffic (katana tests/unit/e2e.rs) end to end.

A limit on active authenticated connections, per node or per user, would need admission control that covers the whole relay in the same way as the connection limits above; the handshake limit covers only the handshake stage. See Listeners and the serve loop.

Never log a credential, UUID, token, key, panel secret, or a URL whose query carries one. When a credential is malformed, log a safe identifier and the kind of error, never the value.

  • Mechanism: error_for_status in katana’s src/api/mod.rs replaces reqwest’s own status check and strips the URL, because the newV2board client sends the panel key in the query string (the helium client sends it as a bearer token, never in a URL); both use it. display_id in src/runtime.rs renders a node as panel type, host, node id and, on newV2board, the panel node type, never api.key. NodeManager::try_bootstrap renders a failed panel request by its outermost error message only, because the cause beneath carries the request URL and its query carries the key. Lowering a node’s users logs a user it skips by uid (skipping user <uid>: <reason>), never by credential, and katana’s outbound lowering refuses a malformed UUID without quoting it. In Etemenanki, a spec holds passwords, pre-shared keys and private keys as Secret<T>, whose Debug prints Secret(..), and the Debug of VMess’s UserHint, which names a user to try first, prints UserHint(<redacted>) rather than the UUID it holds. The AnyTLS user table’s Debug names no password. REALITY’s private keys and shortIds are redacted in Debug in etemenanki-reality, and no error repeats them; In katana’s node, the helium-node-api crate’s types, a Shadowsocks 2022 key, a REALITY private key and shortId and a Salamander password print as Ss2022Key(..), RealityPrivateKey(..), ShortId(..) and SalamanderPassword(..); the newV2board client decodes a UniProxy node’s REALITY key and shortId with the kernel’s decoders, none of its refusals repeats them, and a value of the wrong type in a UniProxy body is reported by its line and column, never quoted (a value of the wrong type at line <l>, column <c>).

    pub fn error_for_status(resp: reqwest::Response) -> Result<reqwest::Response>;
    fn display_id(id: &NodeId) -> String;
  • Tests: a_malformed_uuid_is_refused_without_echoing_it (katana tests/unit/lower/outbound.rs); a_node_is_logged_by_its_panel_node_not_its_key (katana tests/unit/runtime.rs); a_spec_never_prints_a_credential (Etemenanki app/tests/unit/lower.rs); an_unencodable_password_is_refused_without_quoting_it (Etemenanki protocols/tests/unit/hysteria/auth.rs); a_user_hint_never_shows_its_uuid (Etemenanki protocols/tests/unit/vmess/accounts.rs); debug_output_never_shows_a_password (Etemenanki protocols/tests/unit/anytls/users.rs); keys_never_show_in_debug_output and an_invalid_short_id_error_does_not_repeat_it (Etemenanki reality/tests/unit/keys.rs); a_bad_setting_is_refused_without_naming_a_key (Etemenanki protocols/tests/pipeline/reality.rs); a_reality_node_with_bad_settings_is_refused_without_repeating_them, parse_v2ray_reality_takes_its_tls_settings and a_malformed_body_is_refused_without_quoting_it (katana tests/unit/api/newv2board.rs); the_node_config_is_the_contracts_as_helium_wrote_it (katana tests/unit/api/helium.rs).

A change to HTTP error handling in a panel client must keep URLs and tokens out of every error it can return.

Per-user usage must keep these properties through every change: every byte is taken exactly once, a removed user’s bytes are still reported, and bytes that arrive while a report is in flight are not taken by it.

  • Mechanism: the supervisor counts each session’s wire bytes and binds them to the session’s user (supervisor/src/entity/usage.rs); an sss session’s bytes are counted after its transform chains are undone. Ledger::reconcile, run once per sampler tick, moves what each live session moved since its watermark into its user’s pending total; a closing session folds the rest in. Supervisor::take_usage drains the pending totals, and SupervisorBuilder::usage_sink pushes them on an interval instead. Its module documentation states the rule the code keeps: “Every byte lands in exactly one take_usage result, whichever of polling and a sink took it.” katana’s NodeManager::report takes the usage and reports the totals per uid to its panel.

    impl<U: UserId> Supervisor<U> {
    pub fn take_usage(&self) -> Vec<UsageDelta<U>>;
    }
    impl<U: UserId> SupervisorBuilder<U> {
    pub fn usage_sink(self, sink: impl UsageSink<U>, interval: Duration) -> Self;
    }
  • Tests: every_byte_is_taken_exactly_once (a proptest property) and takes_racing_live_sessions_report_every_byte_once (supervisor/tests/unit/usage.rs); a_usage_sink_gets_a_batch_per_interval_and_the_last_at_shutdown (supervisor/tests/tracking.rs); the_user_is_charged_sss_bytes_not_what_the_transforms_send (supervisor/tests/sss.rs) and streams_of_one_session_count_exactly_toward_its_user (supervisor/tests/anytls.rs); vmess_traffic_is_metered_and_reported (katana tests/unit/e2e.rs) end to end. Per-user usage accounting and Traffic accounting and reporting describe both sides.

The route model in environment/src/routing.rs keeps first-match semantics: the first rule that matches wins, and a target no rule matches goes to the default outbound. Changes to matchers or geodata loading are reviewed for case normalisation, regex validation, CIDR prefix validation, malformed protobuf input and rule order. A port range whose lower bound exceeds its upper bound is refused by parse_port_match rather than compiled into a rule that never matches:

pub fn parse_port_match(s: &str) -> io::Result<RouteMatch>;

port_parser_rejects_an_inverted_range and port_ranges_are_inclusive (environment/tests/unit/routing.rs) pin it. Domain regexes are compiled into DomainRegexSets (parse_domain_regexes), sets matched in one pass rather than one search per pattern; a set too big to compile is split in halves. The same review applies to harranu, which carries the same model up to that change.

Every published crate follows SemVer as Cargo interprets it. Cargo reads a bare requirement such as version = "2.0.0" as a caret requirement, and what “compatible” means depends on whether the version is below 1.0:

Version series Requirement ^X.Y.Z accepts Breaking change Compatible addition Compatible fix
0.y.z with y >= 1 (before 1.0) >=0.y.z, <0.(y+1).0 Bump y Bump z Bump z
x.y.z with x >= 1 >=x.y.z, <(x+1).0.0 Bump x Bump y Bump z

At the verified revision the manifests record concepts 2.1.2, environment 3.2.1, reality 0.1.1, protocols 6.2.1, supervisor 1.1.0, app 2.8.0, subscribe 1.0.0 and webclient 2.0.0; etemenanki-ffi (0.4.1) and etemenanki-ffi-bindgen (0.1.0) are publish = false. The workspace crates’ requirements on each other name a series in two parts, such as version = "1.1" on the supervisor or "6.2" on protocols, not a patch release. The one exception is the supervisor’s requirement on concepts, "2.1.2", the release it needs at least. The release commits since 2.0.2 are listed on Workspace and crates.

katana is at 6.1.0. It took a major version when it moved onto the supervisor (katana 4.0.0), when its helium client moved to Helium’s node API v2 (katana 5.0.0) and when it dropped SSPanel (katana 6.0.0), and 4.1.0 added the WireGuard key endpoint_address_family. Each minor release of 4.x since added a feature or a set of node kinds, and the patch releases of 4.8 and 4.10 fixed what it added or took in kernel patch releases:

katana Added
4.2.0 [node.controller] disable_vmess_clock_check, which admits VMess clients whose clocks are wrong
4.3.0 A client certificate, presented when a panel asks for one
4.4.0 enable_device_limit: the panel’s per-user device limit and an IP ban for failed authentication; carrier_max_failures, a failure count that closes a gRPC connection
4.5.0 The helium panel type
4.6.0 A panel’s Hysteria 2 rates (up_mbps, down_mbps, ignore_client_bandwidth), each overridable in [node.hysteria]
4.7.0 [node.controller] real_ip_header and real_ip_from: a WebSocket node behind a reverse proxy takes its client from the proxy’s header
4.8.0 [node.controller] handoff_dir and handoff_group: a stream node also takes the connections a relay on the same host hands over on a Unix socket of its own; a reload that changes only real_ip_header or real_ip_from applies at once
4.8.1 A stream node on one address names its handoff socket <listen_ip>-<port>.sock, so nodes on one port and different addresses get different sockets, and handoff_dir’s length check counts the node’s own name; supervisor 0.11.1, under which the TCP port and the handoff socket count against one set of connection caps
4.8.2 supervisor 0.11.2: a refused reload leaves a running handoff socket’s file untouched
4.8.3 supervisor 0.11.3: each bind stages its handoff socket under a random name of its own beside the path, and preparing a reload removes no file
4.8.4 environment 3.2.1 and protocols 5.2.1: a route’s geoip and geosite files are read as a stream instead of decoded whole
4.8.5 supervisor 0.11.4: the IP ban counts and bans an IPv6 client by its /64
4.9.0 Node kinds: AnyTLS; SOCKS and HTTP over TLS; Shadowsocks over the transport the panel names; VLESS over REALITY, with the Vision flow, from a helium node’s tls_settings. A helium node whose protocol tag names another family is refused
4.10.0 sss nodes
4.10.1 protocols 6.2.0 and supervisor 1.0.1: a VLESS request with an unknown user id is refused as such whatever flow it asks for, so it counts toward the IP ban, and a Vision inbound sends its own direct command after an inner TLS 1.3 handshake, as Xray does
5.0.0 helium nodes on Helium’s node API v2 alone (/api/node/v2/{node_id}/…), whose bodies are the helium-node-api crate’s types: the panel describes the whole inbound, Hysteria 2’s UDP relay and masquerade included, so a helium node that sets [node.api] node_type, enable_vless or vless_flow, or any [node.hysteria] key but congestion, is refused; each users answer says its limits once, for every user. A newV2board node of type sss is refused
5.1.0 protocols 7.0.0 and supervisor 2.0.0: sss nodes’ transform chains in the notation of the sss whitepaper; a route’s geoip and geosite files are stamped when the route is lowered, so a file replaced at the same path rebuilds the route on the next apply
6.0.0 enable_mtls under [[node]]: false presents no client certificate, even to a panel that asks for one. SSPanel is gone: panel_type = "SSpanel" is refused by name, [node.api] vless_flow and disable_custom_config are unknown keys, and nothing reports audit hits to a panel. A TCP node whose panel asks for header obfuscation other than none is refused. protocols 7.1.1 and supervisor 2.1.0
6.0.1 Every panel request asks for a gzip-compressed answer, and a compressed answer is read as it decompresses
6.1.0 One node model from every panel, the helium-node-api crate’s node config: a UniProxy answer is converted into it, and what it asks for and katana cannot serve is refused by name as it is read, with the reason in the logged line, and the contract’s own rules hold for it too; a server_port outside 1 to 65535 is refused rather than truncated; a helium node may be legacy Shadowsocks (helium-node-api 0.2.0); a [node.hysteria] edit gives a newV2board node a new panel client. concepts 2.2.0, environment 3.2.2 and protocols 7.2.1

katana 4.8.1, 4.8.2, 4.8.3 and 4.8.5 moved onto supervisor 0.11.1, 0.11.2, 0.11.3 and 0.11.4, 4.8.4 onto environment 3.2.1 and protocols 5.2.1, and 4.10.1 onto protocols 6.2.0 and supervisor 1.0.1, as patch releases; 4.10.0 moved onto concepts 2.1.2, protocols 6.1.0 and supervisor 1.0.0, 4.9.0 onto protocols 6.0.0 and supervisor 0.12.0 with the reality feature on, 4.8.0 onto protocols 5.2.0 and supervisor 0.11.0, 4.7.0 onto protocols 5.1.0 and supervisor 0.10.0, and 4.6.0 onto protocols 5.0.0 and supervisor 0.9.0, each as a minor release; a patch release (4.1.4) had moved it onto supervisor 0.4. katana is a binary, so its version follows its configuration and behaviour: a kernel major that changes neither is a minor or patch release for katana. 5.0.0 took no kernel major at all and is a major release for its configuration and its panel: a helium node config that sets any of the keys above no longer builds, katana calls Helium’s node API v2 only where 4.5.0 to 4.10.1 called v1, and a UniProxy node of type sss no longer builds. 5.1.0 moved onto protocols 7.0.0 and supervisor 2.0.0 as a minor release. 6.0.0, on protocols 7.1.1 and supervisor 2.1.0, is a major release for its configuration: a node that names SSPanel no longer builds, a file that sets vless_flow or disable_custom_config no longer loads, and a TCP node with header obfuscation is refused. 6.0.1 asked for gzip-compressed panel answers as a patch release, and 6.1.0, on concepts 2.2.0, environment 3.2.2, protocols 7.2.1 and helium-node-api 0.2.0, is a minor release: every config file that loaded before still loads, and what changed is which UniProxy answers are served, now held to the contract’s rules, which refuse a WebSocket path with a query other than ?ed=N, say, or an empty gRPC service name, with a server_port outside 1 to 65535 refused rather than truncated.

The supervisor was below 1.0 until 1.0.0, so each 0.y bump was breaking:

Supervisor Breaking change
0.2.0 Per-user speed limits and Hysteria 2 password users in its public specs
0.3.0 Its public specs carry protocols types, the socket policy and the TUN descriptor source
0.4.0 Guarded is gone and AppConnector::Stream is Metered<OutboundStream>: a drain closes a version’s flows through the tracker
0.5.0 InboundProtocolSpec::Vmess gained clock_check
0.6.0 TunSpec and TunHandler gained fields (TunSpec::ipv6, TunHandler::own_addresses)
0.7.0 It builds on Windows: TunSource::Fd and SuppliedTun are Unix only, and a Unix-socket listen is refused off Unix
0.8.0 UserSpec::device_limit, Policies::ip_ban, Policies::carrier_max_failures and InboundSpec::proxy_protocol
0.9.0 The Hysteria 2 inbound and outbound specs carry bandwidth, congestion control and QUIC settings, and the outbound a port-hopping set
0.10.0 InboundSpec and StreamInbound gained a public real_ip field (RealIpSpec), which breaks a caller’s struct literal
0.11.0 InboundSpec gained a public handoff field (HandoffSpec) and BindSpec a Handoff variant, which break a caller’s struct literal and an exhaustive match on BindSpec
0.12.0 InboundProtocolSpec, OutboundProtocolSpec and StreamShape became #[non_exhaustive], the two protocol specs gained Anytls and StreamShape gained Reality; InboundTransportSpec and OutboundTransportSpec gained a public reality field; the SOCKS, Shadowsocks and Shadowsocks 2022 inbounds gained a transport, and VLESS on both sides a flow
1.0.0 sss inbounds and outbounds; the exhaustive public enums StreamProtocol and Outbound gained a variant. Released as 1.0.0, leaving 0.x, instead of 0.13.0

Its 0.11 patch releases change no API. 0.11.1 gives a stream inbound one set of handshake and live-connection caps across its listeners, and reads one byte more than the longest PROXY protocol v2 header on a handoff, so a byte after a full-length header is refused like any other trailing byte. 0.11.2 binds a Unix or handoff socket under a staging name beside its path and moves it over the path at commit, so a refused apply removes only the staged file. 0.11.3 draws that name afresh for each bind, a dot and random letters, and passes over a name that some file already has, so preparing removes and replaces nothing. 0.11.4 counts failed authentications, bans and the success that clears a count by the client’s /64 for IPv6 and by its address for IPv4, so an IPv6 client that moves to another address in its prefix stays counted and banned.

Since 1.0.0 the supervisor follows the x.y.z rules. 1.0.1 is a patch release: a Vision VLESS outbound builds its datagram codec with its flow, and the requirement on protocols moves to 6.2. 1.1.0 is a minor release: it adds Supervisor::close_rerouted, Supervisor::http_ping and the public ping module, and changes nothing that existed.

etemenanki-webclient passes supervisor types through its API, so since supervisor 0.5.0 it has taken a breaking bump with each of them (webclient 0.2.0 to 0.9.0, then 1.0.0 with supervisor 1.0.0). webclient 2.0.0 is breaking on its own account, beside the minor supervisor 1.1.0: router takes the Supervisor where it took its Tracker, so every caller changes. The app follows its configuration and command line: 2.7.3 only carries protocols 6.2.0 and supervisor 1.0.1 in its lock, and 2.8.0, a minor release, adds the REST API’s close on a route switch and its delay endpoint. etemenanki-protocols 4.0.0 is a major release because the socket policy added public fields to WgConfig, HysteriaConfig and the DNS resolver options, and a tunnelled TCP connection’s downlink now ends with an empty chunk for the remote’s FIN. 5.0.0 is a major release because Hy2Config (protocols/src/hysteria/config.rs) and ServerConfig (protocols/src/hysteria/server/config.rs) became #[non_exhaustive], built with Hy2Config::new and ServerConfig::new, when they gained the rate, congestion, QUIC and port-hopping settings: a caller’s struct literal no longer compiles. 5.1.0 is a minor release: it only adds public items, among them UserHint, AccountValidator::verify_from and the hot-tier calls, VMessCore::with_hint, RealIpHeader and WsRoute::real_ip_header. 5.2.0 is a minor release too: it adds decode_v2, Header and MAX_V2_LEN to transports::proxy_protocol, and holds every fixed field of a PROXY protocol v2 header to the protocol. 5.2.1 is a patch release: on iOS the TLS clients and the Hysteria 2 client trust Mozilla’s roots, and no API changes. etemenanki-environment 3.2.1 is one as well: build_geo_data keeps its signature and streams the .dat files. protocols 6.0.0 is a major release: InboundTransport::accept returns a Disposition (Done, or Camouflage for a REALITY connection relayed to its cover site), InboundTransport, TransportKind and TransportStream became #[non_exhaustive], and VLESS’s encode_request_header and VlessStream::new take the flow. 6.1.0 is a minor release that adds the sss module; the SOCKS driver’s flush of the sniffed prefix it forwards came with it. 6.2.0 is a minor release because it adds VlessDatagram::with_flow; the Vision writer’s own direct command, the refusal of an unknown VLESS user id whatever its flow, and the room the VLESS client codecs reserve for the Vision addons came with it. 6.2.1 is a patch release: on Windows and macOS the TLS clients trust the platform’s CA store, and no API changes. concepts 2.1.2 is a patch release: a proxy client’s runtime flushes the wire after each datagram. etemenanki-reality 0.1.0 is the crate’s first release; etemenanki-subscribe took 0.3.0 for its AnyTLS and REALITY nodes, its enums becoming #[non_exhaustive], and 1.0.0 for sss nodes.

What counts as breaking:

  • Library crates: removing or renaming a public item, changing a public signature, a trait’s required items or a public type’s fields, or changing a feature’s meaning. Adding a public item or an optional feature is a compatible addition, except that a public struct gaining a public field breaks any caller that builds it with a struct literal, as protocols 4.0.0 records. A #[non_exhaustive] struct with a constructor, as Hy2Config and ServerConfig are since protocols 5.0.0, can gain fields compatibly, and a #[non_exhaustive] enum can gain variants compatibly, which is why the spec enums (since supervisor 0.12.0), the transport enums (since protocols 6.0.0) and subscribe’s Protocol and Stream (since 0.3.0) carry the attribute. An exhaustive public enum gaining a variant is breaking.
  • Behaviour: a change in what existing configuration means, what goes on the wire, or what a caller can observe is judged like an API change, even when every signature stays the same. For etemenanki-app and katana, removing a configuration key or changing its meaning is breaking.

etemenanki-protocols 2.0.1 is one recorded exception. It replaced Demux::feed_whole with feed_chunks; etemenanki_protocols::mux and Demux are public, so by the rule above that removal is breaking. The release shipped as a patch because nothing outside the crate called the method, and the release commit’s body says so. That judgement does not change the rule: a patch that removes a public item needs the same check (search katana and every other dependent for uses) and the same written justification, and when any dependent might use the item, the release is breaking.

If you cannot tell whether a change is compatible, say so in review and settle it before anything is published. Bump only the crates that changed; a crate whose code and dependency requirements did not change keeps its version.

A release is a deliberate act with outside effects (a registry upload, pushed commits, a tag and the binaries built from it), so it happens only when a release has actually been decided, never as a side effect of landing a change.

Crates are published in dependency order, and katana moves only after the kernel crates it needs are visible in the registry:

flowchart LR
  q["shinku-quic: its four packages"] --> e
  q --> p
  c["etemenanki-concepts"] --> e["etemenanki-environment"]
  e --> p["etemenanki-protocols"]
  r["etemenanki-reality"] --> p
  p --> s["etemenanki-supervisor"]
  s --> w["etemenanki-webclient"]
  s --> a["etemenanki-app"]
  w --> a
  sub["etemenanki-subscribe"] --> a
  s --> k["katana: update lockfile, bump, tag vX.Y.Z"]
  p --> k
  e --> k
  c --> k
  r --> k

etemenanki-reality depends on no other workspace crate, so it goes before etemenanki-protocols, which depends on it through the reality feature, so the lower crates go concepts, environment, reality, protocols, supervisor, then the crates above them. katana does not name the reality crate in its Cargo.toml, but its lockfile resolves it. etemenanki-ffi and ffi/bindgen are publish = false and are never published. Skip every crate that was not bumped. When a lower crate changes, check each crate above it:

Changed Check the manifests of Also check
etemenanki-concepts environment, protocols, supervisor, webclient, app, ffi Source changes needed in each
etemenanki-environment protocols, supervisor, app, ffi Source changes needed in each
etemenanki-reality protocols (its optional dependency) Only protocols’ transports::reality and transports::camouflage use it. A release within protocols’ "0.1" requirement needs no protocols release: katana takes it with cargo update -p etemenanki-reality --precise <version>. A new 0.y is outside that requirement, so protocols raises it and is released
etemenanki-protocols supervisor, app, ffi, and webclient (a dev-dependency) Source changes needed in each
etemenanki-supervisor webclient, app, ffi Source changes needed in each
etemenanki-subscribe app, ffi Source changes needed in each
etemenanki-webclient app, ffi Source changes needed in each
etemenanki-app ffi Source changes needed in the ffi
shinku-quic The workspace Cargo.toml (quinn, h3-quinn and shinku-quic, used by environment, protocols and supervisor) Source changes needed in each

The inter-crate dependencies are written as path dependencies with a version (two parts, but for the supervisor’s "2.1.2" on concepts) and a registry, so the published manifest points at the registry series. If a crate needs something only a newer lower crate provides, raise its requirement to that series (for example from "3.0" to "3.2"). Either way, confirm in Cargo.lock that the workspace resolves to the version you are about to publish.

shinku-quic is released before the kernel when it changed, and the kernel then moves to the new version: a crate published to a registry cannot depend on a git source, so Etemenanki takes shinku-quic’s packages from the registry. The four packages share one version ([workspace.package] version and the literal version in each vendored manifest) and pin each other with =, so they are bumped together and published in dependency order, shinku-quinn-proto, shinku-quinn, shinku-h3-quinn, shinku-quic, each confirmed with cargo info before the next. The release commit carries an annotated tag v<version>.

  1. Preflight. Read the live state of Etemenanki (and katana, if it will follow) as in Before you start, and read .cargo/config.toml for the registry and its credential provider. The registry token is never in the repository; it comes from the environment or Cargo’s credential store. If the branch must be synced first, use a fast-forward only pull (see Git rules) and stop if it cannot fast-forward.

  2. Decide the scope. List what actually changed with git status --short, git diff --name-only and git diff --cached --name-only, and map paths to packages: concepts/**, environment/**, reality/**, protocols/**, supervisor/**, subscribe/**, webclient/**, app/** (ffi/** is never published). Root manifest, feature and lockfile changes are judged by which crates they affect.

  3. Choose the versions by the rules in Versioning, and edit only the bumped crates’ version, plus the version requirement other workspace crates declare on them where it must rise. The workspace members’ own entries in Cargo.lock follow on the next Cargo command run without --locked (the gate cargo test --workspace is one); cargo check --workspace --locked fails until they have. Check that Cargo.lock changed only in those crates’ entries.

  4. Run every Etemenanki gate, including cargo check --workspace --locked. A failure stops the release.

  5. Commit. The message names what is released: release etemenanki-protocols X.Y.Z for one crate, or release etemenanki-protocols X.Y.Z, etemenanki-supervisor X.Y.Z for several. The body says why the bump has the size it has. Check git status and git show --stat afterwards.

  6. Publish in order, one bumped crate at a time, and confirm each exact version is visible before the next:

    Terminal window
    cargo publish -p <package> --registry <registry>
    cargo info --registry <registry> <package>@<version>

    Each crate’s manifest has publish = [...] naming the one registry it may go to. The index can lag for a moment, so retrying cargo info is reasonable.

  7. Push the branch with git push origin <branch>. Etemenanki has no release tags; its release commits carry the versions. Do not start a tag scheme.

  1. Update the kernel dependencies that the release needs (etemenanki-concepts, etemenanki-environment, etemenanki-reality, etemenanki-protocols and etemenanki-supervisor), once they are visible in the registry, one package at a time:

    Terminal window
    cargo update -p <package> --precise <version>

    Raise the requirement in Cargo.toml too if katana needs the new version’s API or behaviour. katana names the kernel crates it depends on directly by a two-part series (version = "2.1" on the supervisor), except protocols, which it names by the release it needs at least ("7.1.1"). A new major, or a new 0.y below 1.0, is outside either kind of requirement and always needs it raised, as katana 4.9.0 raised the supervisor’s 0.11 to 0.12 and 4.10.0 raised it to 1.0. Then check Cargo.lock: each updated crate resolves to the version just published, its source line is the private registry’s index and it carries a checksum, and nothing else moved.

  2. Bump katana’s own version in Cargo.toml, read from the file rather than remembered. A compatible fix is a patch and a new feature a minor release; a kernel major alone does not make a katana major (see Versioning), but removing a configuration key or changing its meaning does. Update the katana entry in Cargo.lock too, with any Cargo command run without --locked such as cargo check: the --locked gates refuse a lockfile that no longer matches Cargo.toml. Check that nothing else in the lockfile moved.

  3. Run every katana gate, including cargo metadata --locked --no-deps --format-version 1 and cargo check --locked.

  4. Commit and tag. The history uses a commit titled release vX.Y.Z and an annotated tag vX.Y.Z with the same message:

    Terminal window
    git commit -m "release vX.Y.Z"
    git tag -a vX.Y.Z -m "release vX.Y.Z"
    git rev-parse HEAD
    git rev-parse 'vX.Y.Z^{commit}'

    The tags are annotated, so compare HEAD with the tag’s peeled commit vX.Y.Z^{commit}; a plain git rev-parse vX.Y.Z prints the tag object instead.

  5. Push the branch, then the tag:

    Terminal window
    git push origin <branch>
    git push origin vX.Y.Z

    The tag push starts release.yml, which builds x86_64-unknown-linux-gnu and x86_64-unknown-linux-musl binaries with --locked, fails if either links OpenSSL dynamically or if the musl binary is not fully static, and publishes katana-vX.Y.Z-linux-x86_64-gnu, katana-vX.Y.Z-linux-x86_64-musl and a .sha256 for each as the release’s assets.

If the tag already exists and points at another commit, do not move or force-update it.

In every repository you changed, confirm that local and remote agree:

Terminal window
git status --short --branch
git rev-parse HEAD
git ls-remote origin refs/heads/<branch>
git ls-remote origin 'refs/tags/vX.Y.Z*' # katana: the peeled ^{} line is the release commit
cargo info --registry <registry> <package>@<version> # every crate published

Finally, check that katana’s Cargo.lock resolves every etemenanki-* crate to the version this release published, and bring these pages up to the new release as described in Keeping these docs current.

Stop, and report the actual error, when any of these happens. Do not work around it.

Situation Not acceptable as a workaround
The branch cannot fast-forward, or has diverged from the remote Merging or rebasing and carrying on
Registry authentication fails, or the registry configuration is missing Publishing somewhere else
A publish reports the version exists Overwriting it, or bumping until it goes through
A dependency does not resolve, or the lockfile moves far more than expected Deleting Cargo.lock or running a blanket cargo update
Any gate fails Skipping the test or lowering the clippy level
The new version does not appear in the registry Moving katana to it anyway
A tag exists and points at another commit Moving the tag
SemVer compatibility or the tag convention is unclear Guessing

Uncommitted work belongs to whoever made it and outranks automation.

  • Never run git reset --hard, git checkout -- <file> or other destructive restores, and do not run git clean casually.
  • Never delete, overwrite or hide someone else’s uncommitted changes to make a command or a test pass.
  • Never force-push a branch, and never rewrite history that has been pushed.
  • Check git status before syncing with the remote. When local changes exist, sync with git pull --ff-only --autostash. If the pull cannot fast-forward, stop: merging or rebasing is a decision for a person, not a release step.
  • Tags are never moved once pushed.

Every developer page lists, in its frontmatter, the repository files it describes and the revision it was last checked against:

sources:
Etemenanki: [concepts/src/core.rs, concepts/src/runtime.rs]
katana: [src/manager/node.rs]
verified:
Etemenanki: '46c12e4'
katana: v6.0.0

Quote a commit that YAML would read as a number: unquoted, a commit such as 8e51843 is a number in exponent notation, and a commit made only of digits is an integer.

In the docs repository, pnpm check:drift (scripts/check-drift.mjs) reads that frontmatter from every page and reports a problem when:

  • a repository listed under sources has no verified entry, or the revision does not exist in the sibling checkout;
  • a listed file does not exist at the verified revision;
  • any listed file has commits between the verified revision and the released revision recorded for that repository in the docs repository’s docs-versions.json (it prints them). The comparison deliberately stops at the release rather than the checkout’s HEAD, which may hold unreleased work; a repository missing from that file is compared up to HEAD;
  • a translated page’s sources or verified differ from its English page.

It ends with check-drift: N tracked page(s), M problem(s) and exits with status 1 when there is any problem. After each release, move that repository’s ref in docs-versions.json to the release commit or tag and run the check. For every page it reports, re-read the code, update the prose, move verified to the new revision and update the Chinese page’s frontmatter in the same commit. A change to configuration keys also means updating the field tables under src/data/reference/ and the examples under examples/, which pnpm check:examples runs through the real binaries with --test; pnpm build then fails on any broken link or anchor. pnpm check:coverage (scripts/check-coverage.mjs) lists every .rs file under a crate’s src/ that no English developer page names in its sources, read at the same released revisions, so a new source file is noticed too.

The site is public and the code repositories are private. Pages name code by repository-relative path and symbol, never by line number or link, and they never contain real secrets, registry names or URLs, or anything about a particular deployment.