Skip to content

feat(discovery): the daemon derives a peer's identity port itself — the by-hand dial, encoded (#1301 caller side) - #1370

Merged
joelteply merged 2 commits into
canaryfrom
feat/discovery-derives-the-identity-port
Sep 4, 2026
Merged

joelteply merged 2 commits into
canaryfrom
feat/discovery-derives-the-identity-port

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

The by-hand dial this replaces

Measured live today, BigMama → M5: peer enrolled, its Mac answering mDNS, its daemon listening on its identity-derived stable port — and every stored endpoint for it carrying a stale ephemeral port from the pre-#1369 churn. Discovery dialed corpses and reported 0 routes, 96 enrolled peers.

What finally connected was a human doing the derivation manually:

arp/mDNS             -> the IP    (192.168.1.249)
stable_lan_port(id)  -> the port  (57958, from peer 2f0aed7f)
airc dial --expected-peer ...     -> CONNECTED, authenticated

A user without a terminal cannot do any of that — Joel's standing rule: "There is no one to manually do shit... all of this must work automatically for users." So the sequence becomes a dial rung.

The rung

identity_port_candidates pairs every IP already known for a peer with the one port knowable without any advertisement: stable_lan_port of the peer's transport host (the dial pin, not the record peer — the listener binds the wire-owning scope's identity; machine-vs-scope, same rule as the TLS pin).

Appended last, not prepended: post-#1369 the advertised port is the stable port, so stored endpoints normally win and this rung costs nothing. It pays exactly when the stored set is stale — churn-era records, or a peer whose bind fell back — and failure-counted eviction retires the corpses so the rung stops paying their timeouts. A stored endpoint already at the derived port adds no candidate (pinned by test).

The pair this completes

Between them, the churn class that kept two current, healthy, firewalled-open nodes mutually unreachable for two days stops being representable.

Verification

cargo test -p airc-lib --lib — 336 passed, 0 failed, including the new candidate test (derives from record peer when self-hosted, from the declared host when hosted, adds nothing when the stored endpoint is already correct).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc

@joelteply
joelteply enabled auto-merge (squash) September 4, 2026 16:07
joelteply and others added 2 commits September 4, 2026 13:05
…he by-hand dial, encoded (#1301 caller side)

Measured live 2026-08-15, BigMama -> M5: the peer was enrolled, its Mac
answered mDNS, its daemon was LISTENING on its identity-derived stable port
— and every STORED endpoint for it carried a stale ephemeral port from the
pre-#1369 churn. Discovery dialed corpses and reported "0 routes, 96
enrolled peers". The connection that finally worked was a human doing the
derivation by hand:

    arp/mDNS            -> the IP     (192.168.1.249)
    stable_lan_port(id) -> the port   (57958, from peer 2f0aed7f)
    airc dial --expected-peer ...     -> CONNECTED, authenticated

A user without a terminal cannot do any of that. Joel: "There is no one to
manually do shit... all of this must work automatically for users." So the
sequence becomes a dial rung.

`identity_port_candidates` pairs every IP already known for a peer (stored
endpoints; learned IPs ride in via the existing #9 rung) with the ONE port
knowable WITHOUT any advertisement: stable_lan_port of the peer's transport
host. Derived from the dial PIN, not the record peer — the listener binds
the wire-owning scope's identity, so a record answered by a declared host
must derive from that host (machine-vs-scope, same rule as the TLS pin).

Appended LAST, not prepended: post-#1369 the advertised port IS the stable
port, so stored endpoints normally win and this rung costs nothing. It pays
exactly when the stored set is stale — churn-era records, or a peer whose
bind fell back — and failure-counted eviction retires the corpses so the
rung stops paying their timeouts. When a stored endpoint already carries the
derived port, no candidate is added (pinned by test).

With #1369 (bind keeps the stable port across restarts) this closes the loop
from both ends: the listener stays where identity says it should be, and the
dialer can now find it there with nothing but the trust store.

Verified: cargo test -p airc-lib --lib — 336 passed, 0 failed.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc
… candidate

CI caught what my local run did not: five assertions in
stored_endpoint_dial pin exact `peer_dial_failures` / `peer_dial_skips`
counts, and the identity-port rung appends one candidate per peer, so each
count went 1 -> 2 (and N_TARPITS -> 2 * N_TARPITS).

These are CORRECT failures, not noise — the counts are the contract, and
they changed. Each site now says why: post-#1369 a peer advertises its
stable port, so the derived candidate dedups away and costs nothing; these
fixtures use synthetic/churn-era endpoints, which is exactly the case the
rung exists for, so they pay one extra fast local dial.

The concurrency bound in `peers_are_dialed_concurrently_not_serially` is
untouched and still load-bearing: the slow dial per peer is the single 3s
tarpit; the derived dial is an instant local refuse adding milliseconds to
each peer's serial walk, well inside the 9s ceiling. It passed at 20.4s
wall for the whole suite.

Verified: cargo test -p airc-lib --test stored_endpoint_dial — 13 passed,
0 failed (was 12/1).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc
@joelteply
joelteply force-pushed the feat/discovery-derives-the-identity-port branch from b4f940d to 728faeb Compare September 4, 2026 18:05
@joelteply
joelteply merged commit d5b7436 into canary Sep 4, 2026
11 of 12 checks passed
@joelteply
joelteply deleted the feat/discovery-derives-the-identity-port branch September 4, 2026 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant