docs/internal/agenthub-pairing-handshake.md
AgentHub pairing-handshake contract
This page freezes the two-administrator bilateral Hub-pairing ceremony,
its version-1 messages, and the implemented version-1 persisted model.
pairing runs the sessions, store owns durable transactions, and service
composes them through the single public accept owner and local administration. internal/agenthub/pairingwire is the sole
pairing message codec. The invitation package still owns JOIN WORD derivation,
claimant locking, scheduling, and no-oracle claim policy. The records package
still owns Hub authority lineages, records.Ceremony, and
records.PairingApproval. The hoptls package owns the typed first-contact and
exact-pinned pairing TLS boundaries.
Two maintainer clarifications supersede earlier mini-plan shorthand. First,
PairingPrepared is committed after target-authenticated TLS and Challenge,
because the exact authenticated target key and generation assertion needed by
Q do not exist before dialing. It is still committed before any selector or
proof leaves the joining Hub. A dial or TLS failure therefore creates no
durable attempt. Second, the seven-day deadline closes all new approvals and
incomplete exchange. It does not invalidate a target approval that committed
before the deadline. An exact StatusRequest may retrieve that immutable
Completion until the existing RetentionUntil; no other post-deadline pairing
operation is allowed.
Pairing uses TLS 1.3 with ALPN ez-agent-hub-pairing/1 and exporter label
EXPORTER-AgentHub-pairing-v1. It never enters clientAdapter, client gateway
framing, or a device-claimant policy. Pairing TLS carries pairing messages only.
It cannot become a peer, mux, endpoint, directory, route, transit, or ordinary
application connection.
Roles and operator inputs
The initiating Hub is the joining Hub. The target Hub is the inviting Hub. Both
network identities are stable Hub authorities, not devices or operational-leaf
identities. The protocol role bytes are initiator 1 and target 2; these are
pairing roles, not records.StableRole values.
Before the inviting administrator can create JOIN WORDS:
- The joining administrator opens the local, offline Hub identity display. It
shows
Hub authority, four KEY CHECK words, the mandatory check byte, and the full lowercase SHA-256 SPKI fingerprint. - The inviting administrator receives that value independently and records either the complete short check or the exact fingerprint as the claimant lock. If both are supplied, they must resolve to the same canonical SPKI.
- The inviting Hub commits an ordinary Pairing-purpose, claimant-locked invitation. Only then does it display the five secret JOIN WORDS.
A direct card contains the inviting Hub's one public address, its authority KEY CHECK and check byte, full fingerprint, the JOIN WORDS, the claim expiry, and an optional advisory friendly name. The friendly name is presentation only. The joining UI may edit it as a local alias. It is not in a request, ceremony, approval, or synchronized field.
The joining administrator enters the direct address and independently supplied target checks. Candidate target verification must finish before the joining Hub discloses its authority certificate, invitation selector, or claim proof. Four words without the check byte do not suffice. A candidate-provided fingerprint is diagnostic, and there is no accept-anyway path. Sessions and service composition use the typed pairing TLS boundary without weakening this pre-disclosure order.
Initial and recovery pairing TLS
The service composes these closed TLS boundaries without another listener:
hoptls.InitialPairingClientandInitialPairingServeruse TLS 1.3,ez-agent-hub-pairing/1, operational credentials, strict two-certificate authority/operational chains, pairing-only exporters, no resumption, and the existing bounded handshake timeout.- The client verifies the target chain and every independently entered
CandidateCheckvalue before its callback can release the joining Hub's operational certificate. A failed short check or exact fingerprint sends no joining certificate. - The first-contact server accepts a structurally and cryptographically valid authority/operational client chain without a prior exact authority pin. It exposes the authenticated current authority ID and SPKI so pairing can apply the invitation's claimant lock and then require Claim's signed lineage to match.
InitialPairingConnexposesAuthorityIdentityvalues without a generation. An authority certificate proves the key, not its lineage generation. Only a verified signed lineage bundle may assign the generation asserted byQ.- Pairing owns claimant-lock evaluation, exact
Qchecks, and pairing session state. A Prepared row has the exact target authority key but no signed target generation, so StatusRequest and exact-Q Claim retry useInitialPairingClientwith that exact key. A Prepared row that lost Context also lacks the authenticated target-clock deadline: local Cancel remains durable but transmits no application bytes. Once signed Context installs durable target trust and its exact deadline, Approval, later status polling, and Cancel delivery use exact-pinnedPairingClient. For inbound recovery, the target validates the authenticated authority against durableQbefore any operation.PairingServeris the separate closed pinned TLS foundation, not an optional service public-entry composition. - Service connects
InitialPairingServerto the one-addressPublicInitialServer/PublicPeerServeraccept owner. It also owns the generic-pre-TLS to authenticated pairing/session budget transfer. No recovery path reuses first-contact target checks as a substitute for a saved exact pin.
Neither initial nor recovery pairing TLS can return ClientEntryConn, enter
clientAdapter or gateway framing, or become a normal peer connection.
Direct administrator and protocol transcript
The target is T, the initiator is I, and Q is the immutable canonical
pairing request. One initial dedicated pairing TLS connection performs target
verification, mutual authentication, Claim, fresh Context, and the joining
administrator's decision. It is the only normal path for Approval. The wait for
the joining administrator is exactly 300 seconds, bounded earlier by the
approval deadline or caller cancellation. Timeout or transport loss closes the
connection without cancelling either durable row.
| Step | Operator or protocol action | Durable and authorization effect |
|---|---|---|
| D1 | I dials the locally entered address. During the server-authenticated portion of the initial pairing TLS handshake, it checks T against the independently entered KEY CHECK plus check byte or exact fingerprint. I discloses no authority certificate, selector, or proof before that succeeds. | Candidate TLS grants nothing and cannot populate or replace a dial target. Refusal creates no pairing row. |
| D2 | After the exact target check succeeds, I discloses its authority certificate and the same connection completes mutual pairing TLS. T -> I: Challenge. I checks its ID and SPKI against the authenticated target and checks a nonzero nonce. It uses the Challenge generation only to construct Q, pending signed target-lineage verification. | Pairing TLS grants pairing capacity only. The certificate does not prove generation. ValidateInitialChallenge does not compare generation. |
| D3 | Before transmitting a selector or proof, I durably creates PairingPrepared. It stores immutable Q, Direct mode 1, the exact TLS-authenticated authority keys, the locally verified initiator generation, the target's asserted generation, the locally entered address, preparation time, and the exact eight-day unanswered cutoff. | The target generation grants nothing until Context lineage proves it. The address remains local input. No remote field may create or replace it. |
| D4 | On that connection, I -> T: Claim carrying Q, both nonces, the invitation selector, I's complete signed authority lineage, and the root-authenticated claim proof bound to this connection's dedicated exporter. T verifies the lineage head against both Claim Q and the TLS-authenticated joining ID/SPKI before claimant-lock evaluation. | Invalid attempts do not mutate state. A valid outside-lock proof compromises the invitation. A first satisfying authority with a changed request or lineage, or a second satisfying authority, conflicts it. |
| D5 | For the first valid locked claim, T atomically moves the Invitation to pairing-specific PairingClaimed, persists the accepted initiator lineage, and creates PairingAccepted. It fixes one canonical records.Ceremony, claim time, and approval_deadline = claim_time + 604800. T -> I: fresh Context carrying T's complete signed lineage on the same connection. | This commit starts seven-day approval and recovery. It does not extend claim expiry. The ceremony contains Direct mode, exact lineage heads and generations, request ID, initial-connection nonces and exporter, and deadline. |
| D6 | I authenticates Context, verifies the target lineage against TLS, Q, and the ceremony, requires the deadline not to exceed its original eight-day cutoff, and atomically persists that lineage while advancing its prepared row to PairingAccepted. The connection remains open for at most 300 seconds while the joining UI displays the verified inviting authority and exact ceremony digest. | A failed or uncertain local write sends no approval. Closing, timeout, or transport loss is not Cancel and does not extend either cutoff. |
| D7 | If the joining administrator chooses Cancel, I first commits local Cancelled, erases pending approval and invitation material, and sends authenticated Cancel on the initial connection when it is still usable. T commits its matching terminal state when permitted, returns generic Failure, and closes. | Cancel is terminal, not a retry. Another attempt requires a fresh claimant lock, invitation, JOIN WORDS, and request. After connection loss, Cancel may instead use one fresh short pairing connection. |
| D8 | If the joining administrator chooses Approve, I signs the existing records.PairingApproval initiator slot, durably stores it as pending evidence, then sends Approval on the same initial connection with the Claim nonce pair and exporter. | One approval grants no peer or transport privilege. Uncertain local persistence sends no Approval. |
| D9 | T validates the exact request, initial nonce/exporter continuity, ceremony digest, initiator approval, and current lineage, then durably stores the initiator approval. It immediately returns Waiting, or Completion if final target approval raced, and closes. | Only durable initiator evidence enables the inviting administrator's action. The inviting administrator is never awaited on a held remote connection. |
| D10 | The inviting administrator approves. One target-side transaction re-verifies both approvals and current lineages, stores the target-slot approval, activates durable peer eligibility, promotes no reverse address, makes the linked invitation terminal, and erases activation-capable invitation material. | Final target approval is atomic with target activation. There is no separately committed BothApproved phase. Invitation traffic cannot revoke or alter the active relationship. |
| D11 | After Waiting and close, I polls on fresh short pairing TLS connections: Challenge, StatusRequest, then one recovered Context, Waiting, Completion, or generic Failure response and close. Recovered Context repeats the target lineage. Completion also carries the target lineage so a joining process that lost cached Context can rebuild verifier dependencies. On Completion, I verifies both approvals and current lineages and atomically stores the target approval and activates its peer relationship. | Only I promotes its locally entered direct address into its Peer row. Both Hubs then have the same ceremony and approvals, but no normal peer connection. |
| D12 | The normal-peer link may establish a fresh ez-agent-hub-peer/1 TLS connection using the active relationship. | Pairing TLS is closed and never reused. The normal-peer link owns dialing, acceptance, reconnect, and duplicate-link arbitration. |
Before D3 succeeds, the final WAL cut can refuse an unpublished Prepared
candidate because the semantic security second advanced. The joining owner may
rebuild that local candidate once, keeping exact Q, root, selector, address and
the captured store revision. Both evaluations retain the live final-cut check.
Only a definite precommit time-advance refusal without any independent error
permits this rebuild. Ordinary conflicts, cancellation, invalid clocks, rollback,
cleanup failure and uncertain persistence still fail. No TLS connection or Claim
is repeated, and Prepared is published only once. Context and published-request
recovery keep the existing rules below.
The raw socket remains charged to the generic pre-TLS pool through handshake.
After InitialPairingClient or InitialPairingServer returns authenticated
authority identities, service atomically transfers ownership to the dedicated
authenticated pairing/session budget before Challenge or any pairing frame.
The held 300-second decision wait consumes that budget slot. The target starts
its timer after the complete fresh Context write; the joining Hub starts its
timer after the durable Context commit. Each side uses the earlier of its local
start plus 300 seconds and the approval deadline. EOF, deadline, or caller
cancellation releases the slot and leaves recovery available to a later
client-requested check. None schedules a reconnect, emits or commits Cancel.
Five minutes is the frozen phase-one limit. It gives the local administrator a short decision window while keeping the held authenticated slot finite; it is separate from the ten-second default TLS handshake limit and the seven-day durable approval deadline. Presentation may use shorter timers, but cannot keep this connection past 300 seconds.
If the initial connection is interrupted before its final response, the durable
request survives. Fresh StatusRequest polling recovers canonical Context or the
latest later state. Once I has durable canonical Context, a joining Approve
chosen after that interruption signs and stores pending evidence and transmits
it with the recovery-only sequence Challenge, Approval, then Waiting,
Completion, or Failure. The same sequence retransmits an already stored
Approval that did not reach T. This transport-recovery exception does not
repeat Claim, alter its ceremony nonces/exporter, or make fresh-connection
Approval the normal path. If Approval may already have reached T,
StatusRequest is used first.
On either Hub, the transaction that adds the second verified approval also activates the relationship. Joining activation occurs only in the atomic Completion transaction.
Address-free routed target selection
Routed mode uses the same ceremony. The restricted routed carrier owns route setup; the pairing handshake owns every end-to-end message and durable transition below.
- The joining administrator starts from the same offline joining-authority display. The inviting administrator records that lock before creating the invitation and JOIN WORDS.
- The joining administrator selects the target authority using independently
supplied target checks. A route or directory result may offer candidates,
but it is not trust input. No host, port, route, relay, next hop, DNS name, or
carrier attachment enters
Q, the ceremony, either approval, Pairing, or Peer address lists. - The restricted routed carrier establishes a route carrying one initial dedicated end-to-end pairing TLS connection. That connection verifies the target before initiator-certificate, selector, or proof disclosure, then completes mutual pairing TLS; it is not replaced between verification and Claim.
- After mutual TLS and Challenge, but before selector or proof transmission,
the joining Hub commits
PairingPreparedwith Routed mode2, immutableQ, exact TLS-verified target identity, preparation time, the original eight-day cutoff and an empty address list. Prepared has no authenticated target generation or target-clock deadline; signed Context supplies those. - The exact D4 through D11 ordering then runs on the restricted carrier, including the initial connection's Claim, Context, joining decision, and normal-path Approval. Every later poll or recovery operation gets a fresh restricted route and short pairing TLS connection. The target Invitation, both Pairing rows, and both eventual Peer rows have empty dial-address lists.
- Bilateral activation creates eligibility only. A later normal-peer path is a fresh normal-peer connection, possibly using routing. The pairing carrier cannot be promoted into an arbitrary tunnel or peer link.
Direct is byte 1 and Routed is byte 2, exactly
records.PairingDirect and records.PairingRouted. There is no translation
map. Mode is explicit and cannot be inferred from address presence.
Interruption and tokenless recovery
Every retry uses fresh pairing TLS, Challenge nonces, and a current exporter. The accepted ceremony remains byte-identical and retains the first valid claim's nonces and exporter.
| Interruption | Required recovery |
|---|---|
| Before a valid claim commits | Reuse the durable prepared Q, selector, and root while claim expiry and the eight-day cutoff remain open. A retry creates fresh pairing TLS but not a new request. |
| Claim commits but fresh Context is lost | Authenticate both authorities on fresh pairing TLS and send StatusRequest for exact Q. The target returns recovered Context with the already committed ceremony, then closes. No bearer token or repeated JOIN WORD entry is used. |
| Joining persistence fails after Context | Send no approval. Reopen the prepared row, authenticate again, recover the same Context, and retry the atomic local transition. Uncertain persistence is never reported as success and does not imply Cancel. |
| Initial connection times out or is lost during the joining-administrator wait | Close without Cancel. The durable request and Context remain recoverable through short StatusRequest polling. A later local Approve signs/stores pending evidence and uses the recovery-only fresh Approval sequence; a later local Cancel is terminal and uses a fresh short Cancel connection when possible. |
| Durably stored joining Approval was sent or attempted, but delivery or its response is uncertain | Poll first when delivery may have succeeded. Recovered Context proves no initiator approval committed and permits transmission of that same signed Approval on one fresh recovery connection; Waiting proves it committed; Completion proves target activation committed. No new approval or ceremony is created. |
| A later Status response is lost | A fresh StatusRequest for exact Q returns recovered Context if no initiator approval committed, Waiting if the target is awaiting its administrator, or Completion if target activation committed. |
| Target final approval commits but Completion is lost | The target remains active. A later exact StatusRequest returns the same Completion. It does not create another approval or extend a deadline. |
| Either process restarts | Load only durable request, ceremony, approval, and deadline state. TLS secrets, active sockets, current nonces, current exporter, and authenticators never survive as a connection. |
| Deadline or terminal state wins a race | Return generic Failure and close, except for retrieval of an already committed Completion within existing retention. Cached content no longer permitted by durable state must not escape. |
A StatusRequest is tokenless: mutual authority TLS, current request-bound
message authentication, and exact Q authorize the bounded lookup. It carries
no status key, recovery bearer, JOIN WORD, root, or proof. A recovered Context
has disposition byte 2; a first response has disposition byte 1. The
current response authenticator binds the fresh TLS exporter. The ceremony bytes
inside recovered Context remain those from the first valid claim.
Claim expiry and approval deadline
The invitation claim expiry is the administrator-selected 600, 3600, or 86400
seconds. A first claim is valid only while now < claim_expiry; equality is
expired. A successful first claim fixes a separate seven-day deadline. Both
new approvals and all incomplete exchange require now < approval_deadline.
After that deadline, only an exact authenticated StatusRequest to an Active
target may retrieve its already committed Completion while
now < RetentionUntil. No Context, Waiting, Approval retransmission, or Cancel
is permitted after the approval deadline. The joining Hub retains LocalApproved
evidence through that existing cutoff, verifies Completion, and activates
atomically. At retention equality it purges incomplete joining evidence and
fails recovery. Generic remote failure is not an explicit rejection.
Restart, retry, recovered Context, Status, and lost responses move no deadline.
The joining row starts with unanswered_cutoff = prepared_at + 691200, eight
days. It accepts target Context only when the target's seven-day deadline is no
later than that cutoff. The maximum 24-hour claim lifetime plus seven days fits
exactly. It does not copy or invent the target's claim expiry before claiming.
Pairing invitation root context
Pairing uses the existing invitationwire JOIN-index cryptography. It does not
define another invitation codec. NewPairingStaticContext produces canonical
J with this exact encoding:
| 1 | U8 version # 1 |
| 2 | U8 purpose # 3 Pairing |
| 3 | U8 subject_role # 1 Authority |
| 4 | byte[32] target_id # inviting authority current ID at creation |
| 5 | U8 claimant_role # 1 Authority |
| 6 | U16BE profile_length # 0 |
| 7 | U8 mode # 1 Direct, 2 Routed |
Admission and Endpoint J encodings stay byte-identical and require mode zero.
Pairing J cannot enter the client invitation Request or Context codecs. Five
deterministic JOIN indices derive root and selector through the existing
AgentHub/invitation/root/v1 and AgentHub/invitation/selector/v1 domains.
Mode and target ID therefore change both values. The fixture publishes the
indices, words, J, derived root, and selector so Go and Ruby check the same
derivation independently.
Half-paired, terminal, and removal rules
Before bilateral activation, a pairing connection may exchange only Challenge, Claim, Context, Approval, StatusRequest, Status, Cancel, Completion, or Failure. One approval is pending ceremony evidence. It grants no peer TLS, mux channel, directory synchronization, route, endpoint, transit, relay, circuit, or application privilege. Service composition must keep half-paired connections out of peer and mux handlers.
A local administrator may cancel any incomplete pairing. The local cancellation
commits first and erases pending approval and invitation material. A best-effort
Cancel on authenticated exact Q lets the other side do the same; its only
remote terminal response is generic Failure. Cancellation cannot remove an
active peer. After activation, the administrator uses peer removal, which
atomically marks Pairing and Peer history removed and causes the normal-peer link to close
matching normal-peer sessions. Any later pairing attempt requires a fresh
claimant lock, invitation, JOIN WORDS, and canonical request.
A valid root proof from an authority outside the immutable claimant lock makes
the Invitation Compromised. Before a valid claim, it creates no Pairing row.
After PairingAccepted, the target transaction also makes the linked Pairing
Compromised, erases pending approvals and activation-capable material, and
prevents approval. A changed request from the first authority or another
authority satisfying a short lock makes both linked rows Conflicted. The target
dashboard may show those diagnoses. The joining Hub never receives either
label, and neither state is remotely recoverable.
Final approval and every terminal transition serialize under the store writer. If final approval commits first, invitation traffic cannot change the active relationship. If conflict, compromise, cancellation, or expiry commits first, final approval fails. The inviting administrator cannot approve before the joining approval is durably present.
Exact pairingwire v1 encoding
All integers are unsigned big-endian. U8, U16BE, U32BE, and U64BE have
fixed widths. No varints, text integers, implicit defaults, optional fields, or
extension fields exist.
A normal complete frame is:
| 1 | U32BE body_length # 7..49152 |
| 2 | byte[4] "AHPW" |
| 3 | U8 version # 1 |
| 4 | U8 kind # 1..8 |
| 5 | U8 field_count |
| 6 | repeat field_count times: |
| 7 | U8 field_id # strictly increasing |
| 8 | U16BE field_length # 0..40960 |
| 9 | byte[field_length] value |
The complete frame limit is 49156 bytes. The decoder checks the U32 body bound before allocation. Every kind requires exactly the listed fields, IDs, lengths, and order. Missing, duplicate, reordered, unknown, or extra fields fail. A field over 40960 bytes, body over 49152 bytes, truncation, noncanonical nested value, mismatched U32 length, or trailing byte fails. There is no ignore-unknown rule and no multi-frame parsing fallback.
Canonical request Q
Q is a field value with this one positional encoding:
| 1 | byte[4] "AHPR" |
| 2 | U8 version # 1 |
| 3 | U8 mode # 1 Direct, 2 Routed |
| 4 | byte[16] request_id # nonzero |
| 5 | U8 initiator_pairing_role # 1 |
| 6 | byte[32] initiator_id # SHA-256 of canonical SPKI |
| 7 | U16BE initiator_spki_length |
| 8 | byte[...] initiator_spki # canonical Ed25519 or P-384, max 512 |
| 9 | U64BE initiator_generation # 0 for genesis, increments on transition |
| 10 | U8 target_pairing_role # 2 |
| 11 | byte[32] target_id |
| 12 | U16BE target_spki_length |
| 13 | byte[...] target_spki # canonical Ed25519 or P-384, max 512 |
| 14 | U64BE target_generation # 0 for genesis, increments on transition |
The maximum encoded request is 348 bytes. The authorities must be distinct. The request has no selector, proof, expiry, approval deadline, nonce, exporter, address, friendly name, route, profile, or status credential. The Claim carries the invitation selector separately. Pairing and Invitation rows link to the same exact request bytes and request ID.
Message kinds and fields
Each row lists fields in mandatory field-ID order. request always means the
complete canonical Q. Nonces, selectors, proofs, digests, exporters, and
authenticators are exactly 32 bytes. Generations are U64BE and may be zero;
newly bootstrapped Hub authorities are generation zero.
| Kind | Byte | Ordered fields |
|---|---|---|
| Challenge | 1 | 1 target_role=2, 2 target_id, 3 target_spki, 4 target_generation, 5 target_nonce |
| Claim | 2 | 1 request, 2 target_nonce, 3 initiator_nonce, 4 selector, 5 initiator_lineage, 6 claim_proof |
| Context | 3 | 1 request, 2 target_nonce, 3 initiator_nonce, 4 records.Ceremony bytes, 5 disposition, 6 target_lineage, 7 authenticator |
| Approval | 4 | 1 request, 2 target_nonce, 3 initiator_nonce, 4 ceremony_digest, 5 initiator records.PairingApproval frame, 6 authenticator |
| StatusRequest | 5 | 1 request, 2 target_nonce, 3 initiator_nonce, 4 authenticator |
| Status | 6 | 1 request, 2 target_nonce, 3 initiator_nonce, 4 status=1, 5 ceremony_digest, 6 authenticator |
| Cancel | 7 | 1 request, 2 target_nonce, 3 initiator_nonce, 4 authenticator |
| Completion | 8 | 1 request, 2 target_nonce, 3 initiator_nonce, 4 records.Ceremony bytes, 5 initiator approval frame, 6 target approval frame, 7 target_lineage, 8 authenticator |
These eight kinds are sufficient for the settled lifecycle. Multi-message initial ordering is a connection-state rule, not a reason to add an ACK, decision, resume, or peer-upgrade message.
On first contact, ValidateInitialChallenge compares target ID and SPKI with
InitialPairingConn.RemoteAuthority and checks canonical framing and a nonzero
nonce. It deliberately does not compare generation to an independently
authenticated value. The joining Hub copies that assertion into Q; fresh
Context must then prove the same head with signed target lineage before the
generation becomes trusted. On recovery connections,
ValidatePinnedChallenge compares ID, SPKI, and generation with durable Q.
For Prepared recovery the service pins the exact saved target key using the
initial TLS profile, not a short human check. Generation remains an unproven
assertion until signed Context verifies it. Status comes first; if it recovers
no committed claim, retry the same saved Claim on fresh TLS. No new Q or
administrator ceremony is created automatically.
Context disposition 1 means the first response to the committing claim. Byte
2 means the target returned the already committed ceremony during recovery.
Status byte 1 means only waiting-for-target. Active state uses Completion.
No terminal status or local diagnosis has a wire value.
Ceremony bytes are at most records.MaxCeremonyBytes, currently 1233. Each
approval field is at most 2048 and must parse as the existing closed
records.KindPairingApproval. pairingwire checks that approval and ceremony
fields agree. The records verifier remains responsible for signature and
lineage verification. There is no alternate ceremony core, approval core, or
signature domain in pairingwire.
Canonical authority-lineage bundle
initiator_lineage and target_lineage use one pairing envelope around
existing complete signed records frames:
| 1 | byte[4] "AHPL" |
| 2 | U8 version # 1 |
| 3 | U8 record_count # 1..65 |
| 4 | repeat record_count times: |
| 5 | U16BE record_length # 1..32914 |
| 6 | byte[record_length] record # canonical records frame |
The complete bundle is at most 40960 bytes. Record zero must be one signed
HubGenesis. Each later item must be the next signed AuthorityTransition.
The bundle contains no other record kind. records.VerifyAuthorityLineage
enforces signatures, exact predecessor digest, stable genesis ID, consecutive
generations, old-head equality, new-key possession, no key reuse, and at most
64 transitions. Omission, duplication, reordering, a second genesis, trailing
bytes, noncanonical records, an invalid signature, or an unrelated transition
fails the whole pairing message.
The resulting head generation is record_count - 1. Its ID, SPKI, and
generation must exactly equal the corresponding participant in Q, Ceremony,
and each Approval. Its ID and SPKI must also equal the authority certificate
authenticated on that pairing TLS connection. TLS supplies no trusted
generation. Claim transfers the initiator bundle; every fresh or recovered
Context transfers the target bundle; Completion repeats the target bundle so
it is sufficient without a retained Context response. The containing Claim
proof or message authenticator binds every bundle byte.
Before approval verification, the receiver stages both verified bundles and
the exact Ceremony as records.Verifier dependencies. An unseen lineage is
persisted only in the same transaction that accepts Claim or Context. If local
trust already exists, every record through the saved generation must be
byte-identical and any extension must verify from that head. A different
genesis, a fork at an existing generation, a stale head, or a TLS/Q/bundle
mismatch returns generic Failure, preserves existing trust, and records only a
local conflict diagnosis. Wire arrival order never chooses a fork. The store
owns the concrete transactions and storage shape.
Exporter, proof, and message authentication
Let B16(x) = U16BE(len(x)) || x. The 32-byte TLS exporter context is:
| 1 | SHA-256( |
| 2 | "AgentHub/pairing/exporter-context/v1\0" || |
| 3 | B16(Q) || target_nonce || initiator_nonce |
| 4 | ) |
TLS exports exactly 32 bytes with EXPORTER-AgentHub-pairing-v1. Claim proof
is:
| 1 | HMAC-SHA-256( |
| 2 | invitation_root, |
| 3 | "AgentHub/pairing/claim-proof/v1\0" || |
| 4 | pairing_exporter || |
| 5 | canonical Claim AHPW body with claim_proof omitted and field_count = 5 |
| 6 | ) |
Context, Approval, StatusRequest, Status, Cancel, and Completion use:
| 1 | HMAC-SHA-256( |
| 2 | current_pairing_exporter, |
| 3 | "AgentHub/pairing/message-auth/v1\0" || |
| 4 | canonical AHPW body with authenticator omitted and field_count reduced by 1 |
| 5 | ) |
Challenge relies on the authenticated TLS record layer for sender and byte integrity, but first-contact TLS does not prove the semantic truth of its generation field. Its nonce is bound by the next proof or authenticator. Claim uses the root proof. Any changed request, mode, role, identity, generation, nonce, ceremony, deadline, approval, status, or message kind changes the proof or authenticator. A frame from another TLS connection, exporter label, mode, or direction fails.
The target validates a newly received first operation's exact Q and target
Challenge nonce before deriving the exporter context with that operation's
initiator nonce. On the initial connection, fresh Context, Approval or Cancel,
and the final response must all repeat the Claim request and nonce pair and use
the Claim-derived exporter. ValidateContinuation checks that invariant. A
response receiver compares both outer nonces with the locally retained
outstanding operation and verifies with that operation's already derived
exporter; it never derives a new exporter context from response fields. The
fresh Context nonces also equal the nonces embedded in its canonical ceremony.
Recovered Context preserves those ceremony-internal first-Claim values while
its outer request, nonces, and authenticator bind the fresh polling connection.
Exact per-connection sequences
Frames are read one at a time on one TLS stream. Version 1 allows only these complete sequences; braces select exactly one alternative:
| 1 | Challenge, Claim, Failure |
| 2 | Challenge, Claim, Context(fresh), Approval, {Waiting, Completion, Failure} |
| 3 | Challenge, Claim, Context(fresh), Cancel, Failure |
| 4 | Challenge, Claim, Context(fresh), Failure |
| 5 | Challenge, Approval, {Waiting, Completion, Failure} # interrupted initial Approval recovery only |
| 6 | Challenge, StatusRequest, {Context(recovered), Waiting, Completion, Failure} |
| 7 | Challenge, Cancel, Failure # cancellation recovery |
The expanded successful normal sequence is exactly Challenge, Claim, Context(fresh), Approval, Waiting or the Completion race variant, all on one
nonce pair and exporter. The initial Cancel variant likewise keeps that pair.
An interrupted prefix may end only because TLS setup, deadline, finite local
wait, transport, parse, or write failed; EOF is not a Cancel frame. Recovery
Context, Waiting, Completion, generic Failure, and every response to a recovery
Approval or Cancel are terminal for that connection.
No sequence exceeds five valid pairing messages. There is no cycle, second
operation on a status poll, repeated Context, repeated Approval, post-terminal
message, unbounded wait, or pairing-to-peer upgrade. pairingwire exposes a
pure acyclic sequence validator but owns no socket or durable session state;
The pairing engine combines it with deadlines, TLS, and store transactions. A validator
result other than ConnectionTerminal is only an interrupted transport prefix,
never a successful protocol result.
Generic terminal result and close behavior
The one complete terminal frame is exactly:
| 1 | 00 00 00 06 41 48 50 46 01 01 |
| 2 | U32BE(6) "AHPF" v generic-failure |
It has no field count, reason, retry bit, state, identity, request, or deadline. After authenticated pairing TLS exists and a bounded response can be written, malformed, invalid, unavailable, expired, rejected, cancelled, compromised, conflicted, unsupported-terminal, and policy-denied attempts all receive this same frame under the same bounded write policy, followed by TLS close. An unsafe oversized or truncated input may force immediate close, but it never gets a more specific response. A terminal frame is always followed by close and cannot precede another pairing message.
Recovered Context, Waiting, Completion, and every final response to Approval
or Cancel are followed by close. Fresh Context on the initial connection is the
one nonterminal response: it is followed by the bounded joining-administrator
wait and exactly one Approval, Cancel, Failure, or transport close. Failure to
read expected EOF after a terminal response makes that exchange unusable.
Neither side accepts gateway controls, invitationwire messages, client
invitation failure bytes, two frames concatenated into one declared frame, or
trailing data. Multiple allowed frames remain individually length-prefixed on
the same TLS stream.
Implemented version-1 persisted model
AgentHub is unreleased. Pairing extends strict version-1 YAML in place and adds no migration or feature-branch compatibility reader.
The target starts with one ordinary Invitation and no Pairing. For Pairing
purpose, Invitation stores explicit purpose 3, explicit mode 1 or 2, row
ID, immutable claimant lock, owner generation, creation and claim-expiry times,
shared root and selector state, revision, phase, first claimant, exact canonical
request bytes and request ID after claim, claim time, and seven-day approval
deadline. It remains the owner of proof checking, no-oracle retries,
compromise, conflict, and secret erasure. A linked pairing invitation cannot
disagree with Pairing about request, participants, generations, mode, deadline,
or terminal state.
The first valid pairing claim changes the target Invitation from Unclaimed to
the explicit pairing-only phase PairingClaimed. Pairing never enters the
client-purpose Unacked or Acked phases and has no credential recovery ACK,
authority ACK, or circuit DATA ACK. The Pairing row, specifically a present and
verified initiator approval, gates the inviting administrator's action. Final
target approval changes the linked Invitation from PairingClaimed to
Approved in the same transaction that stores the target approval and
activates Pairing. Cancellation, expiry, conflict, and compromise move both
linked rows to their matching terminal states. The target retains only the
root/proof material needed to detect a valid outside-lock proof while
activation remains possible, then erases it on activation or any terminal
transition.
After target verification and mutual TLS, the joining Hub creates Pairing in
Prepared on durable storage before Claim or any selector/proof transmission
on the still-open initial connection. The row stores:
- explicit mode and exact canonical request bytes and ID;
- verified local authority ID and generation, exact authenticated remote ID and SPKI, the target's unproven generation assertion, and the local slot; remote genesis and lineage are installed only with verified Context;
- preparation time and exact eight-day unanswered cutoff;
- exactly one locally entered direct address for Direct, or no addresses for Routed;
- local alias only outside authenticated or synchronized fields.
The first valid target claim creates Accepted; the joining transaction changes
Prepared to Accepted. Accepted state stores claim time, authoritative
seven-day deadline, canonical ceremony bytes and digest, exact remote trust,
the verified canonical lineage records needed by records.Verifier, and empty
approval slots. It removes the unanswered cutoff as an authority but
retains enough original preparation evidence to prove the accepted deadline did
not exceed it. The target stores no reverse address. No remote input can fill a
dial-address list.
The incomplete approval phases are LocalApproved and RemoteApproved, named
from each store's perspective. The initiator normally has LocalApproved; the
target normally has RemoteApproved. BothApproved is not a separately
committed phase: adding the second verified approval and Active eligibility is
one transaction. Terminal pre-activation phases are Cancelled, Expired,
Compromised, and Conflicted. Compromised is target-only diagnosis after an
accepted claim. Removed follows only Active peer removal.
Active stores the same ceremony, both exact signed approval frames, activation time, and linked Peer row. The joining Peer receives its one local direct address only in this activation transaction. The target Peer may have no direct address. Routed Peer rows have none. Pending approval and invitation material that could activate a terminal row is erased. Existing security-time, retention, authority-transition cancellation, failed-write, and uncertain-commit rules continue to apply.
The store exposes narrow transactional operations used by the engine and revision-checked local administration:
| 1 | PreparePairing / PairingRetryView |
| 2 | AcceptPairingClaim / DiagnosePairingClaim |
| 3 | CommitPairingContext |
| 4 | PairingStatus |
| 5 | ApproveJoiningPairing / ReceiveJoiningApproval |
| 6 | FinalizeTargetPairing |
| 7 | CompleteJoiningPairing |
| 8 | CancelPairingContext / CancelPairingCardContext |
| 9 | RemovePeerContext |
AcceptPairingClaim is one target transaction across Invitation, accepted
lineage dependencies, and Pairing. The joining-side Context transaction has the
same atomic lineage-persistence requirement.
FinalizeTargetPairing and CompleteJoiningPairing verify current lineages,
generations, ceremony digest, both signer slots, and the applicable approval or
Completion-retention cutoff before activation. PairingStatus uses authenticated
authority identities and exact Q, not a bearer token. Prepare, target claim,
and joining Context transactions refuse a non-removed Peer for the same remote
authority or genesis. Re-pairing requires removal on both Hubs.
Fixtures and review boundary
Language-neutral literals are in
internal/agenthub/testdata/trust/pairing.json. The
independent Ruby checker parses framing and records, derives Pairing invitation
root and selector, recomputes proofs and tags, verifies Ed25519 genesis,
transition, and approval signatures, and checks the complete allowed sequence
set, lineage links and heads, fresh polling, nonce/exporter continuity,
cancellation, response binding, zero nonces, foreign/malformed formats, replay,
and generic failure. Its invalid-signature and reordered-lineage Claim cases
retain valid outer root/exporter HMACs, which both checkers verify before
rejecting lineage semantics. Direct covers signed generation-zero genesis. Routed
covers real generation-one transitions signed by distinct old and new keys. Go
tests consume the same literal file. Commands are listed in the fixture
README.
Pairing implements sessions, durable transactions, direct service composition, and local administration against these frozen bytes. It adds no listener or EzAgent JSONL message. The normal-peer link owns the mandatory fresh normal-peer connection; the restricted routed carrier owns routed transport. Select terminal checks for affected interactions through the computer-use guide.
Recovery scheduling and bounds
Repeated recovery checks belong to the open local pairing view.
pairing open performs an immediate passive access/status read and exact
requested checks; reopen starts fresh. The client repeats sequential checks
five seconds after each completed pass, and an approval wakes the open view
immediately. pairing close, EOF, input failure, or dashboard exit cancels and
joins the timer and in-flight caller. Close changes no durable state and sends
no protocol Cancel. Add Hub opens this view automatically. Ordinary status
never dials, and idle or restarted Hubs never schedule work from Prepared or
LocalApproved rows. There is no daemon recovery ticker, scan, cursor, or backoff.
The private check_pairing operation names one exact remote authority and
request ID. It checks durable active Peer access first, independently of retained
ceremony evidence, then runs at most one existing status-first recovery sequence
under caller cancellation and a twelve-second operation bound. It returns only
active, waiting, known local terminal, timeout, or temporarily unavailable.
It defers to an already held initial carrier and excludes another exact check.
Accepted rows await local action; terminal rows do not dial. Five-minute carrier
reuse finishes existing work only and its expiry schedules no reconnect.
After the seven-day authorization cutoff, a LocalApproved request can still
retrieve a pre-cutoff Completion before RetentionUntil. A clean exact status
Failure without Completion yields timeout, not a named remote rejection.
Transport failure remains temporarily unavailable and the open view may retry.
Retention equality forbids another recovery check but never revokes active Peer
access. The daemon never polls durable pairing rows.
Local Cancel first blocks new recovery registration for exact Q, cancels and
joins any held decision or in-flight recovery owner, and then commits the local
terminal transition. When signed Context supplied the exact target-clock
deadline, it performs exactly one fresh best-effort Cancel while the barrier
remains held. A Prepared row without Context performs no network operation.
This is not a durable redial loop. Caller cancellation
still closes a held dashboard connection without cancelling Q.
The pairing queue accepts the reviewed 49156-byte complete-frame bound rather than the client invitation payload limit. Its reservation charges the exact retained frame plus 4096 bytes of queue overhead and releases once. Complete 64-transition bundles share one memoized lineage verification operation. The deterministic collision-policy tests supply a true lock-match result for distinct authenticated authorities at the pure policy boundary. They do not claim to generate a real short-check collision or bypass production matching.
Mechanical ownership shared with other ceremonies
Pairing keeps the complete typed transcript, two local actors, approval slots,
held-connection ordering and durable Pairing/Peer rows described above. Target
card creation enters through CreatePairing and CreatePairingInvitation, not a
purpose-inferred client invitation hook. The joining side uses the identity
owner's closed Hub-evidence match before certificate disclosure. TLS generation
is still not signed Context evidence.
Only coincident mechanics converge. Nonce generation uses the existing invitation byte owner, with pairing's additional nonzero check. Exporter contexts retain their separate literal domains and encodings. The shared scheduler owns a dispatched attempt's processing deadline and finish. Pairing joins and retires carrier cancellation before an active worker adopts it, then joins worker cancellation before finishing the attempt. Reply writes and the held-decision continuation regain a separate carrier cancellation owner. The shared TLS lifecycle owner performs each callback join; a connection-local once guard keeps pairing's existing graceful Close action from running twice. A blocked Close remains charged to the scheduler worker and lane until that join finishes, and the connection reservation remains held through joined transport cleanup. Store mutation owns revision fencing, persistence uncertainty and publication after durability. No client ACK, status key, replay cache, client response confirmation, new cutoff or recovery credential is added to pairing.
The public EntryServer detaches and joins its pre-auth transport callback before
initial pairing adopts graceful Close. It retains only the pairing capacity
lease until that handler joins; no raw-abort callback remains active against
the initial pairing transport while Serve runs. Composed shutdown tests
observe close_notify before raw close, hold the raw close to verify callback
joining, and require capacity to remain charged until that join completes.
The typed InitialPairingEntry.Serve callback owns live cancellation and
graceful close and must join its transport work before return. Entry then
retires the typed transport with Abort before releasing capacity,
including callback returns without close. This post-callback retirement neither
competes with live cancellation nor waits for a fallback close_notify write.
There is no optional pinned-pairing service override or parallel public entry.
Prepared recovery uses exact-key InitialPairingClient; recovery after signed
Context uses exact-pinned PairingClient.
JoinInput.Indices is a consumed pointer-owned array. JoinInitial clears the
caller's array before setup validation, including nil-connection and recovery
setup failures, then owns and clears its local copy. A fresh zero-RequestID
request requires a nonnil array before any entropy, Claim disclosure or durable
Prepared row. Nonnil all-zero indices remain valid independently supplied words,
including dictionary index zero. Nil input is allowed only for an exact nonzero
RequestID Prepared retry, which reloads the saved Q, root and selector without
creating a new request, secret or deadlines. The service transfers a
distinct worker holder and clears the service copy before launching the worker.
Cancellation remains transport loss, never protocol Cancel, and does not change
Prepared timing, exact-Q recovery or the held administrator window.
Transient transcript ownership
The connection owner uses pairingwire.ReadOwned and typed pointer message
holders, retiring their nonce, selector, proof and authenticator fields on every
exit. Context and Completion holders own transient ceremony bytes. Outgoing
holders clone those bytes from private store projections before the projection
retires. They never erase an approved durable ceremony or borrowed public
lineage/approval/key bytes. Value-form Read and Parse preserve their existing
API by moving the decoded holder's slices and copying scalars to the successor.
Marshalling reserves the body capacity once, then clears its owned request and scalar fields after copying. Authentication clears its separately marshalled body, exporter-context input and digest temporaries. Receive frames retire on parse failure and partial read as well as success. Writes retain and erase the full original encoded allocation after short-write slicing, including failure. The engine's original queued frame retires independently of the scheduler clone. Local ceremony structures, generated nonces and exporter copies also have explicit retirement. These are source-owned buffer guarantees, not a claim that Go or TLS erases every compiler/runtime-internal copy.
Parsed ceremony retirement includes its independent canonical Bytes copy as
well as nonce and exporter arrays. records.EncodeCeremony retires its scalar
parameter copy and pre-sized encoder backing buffer after copying the result.
Ceremony digest and validation helpers retire their encoded input temporaries.
A successfully parsed ceremony transfers its canonical bytes to the caller;
failed parsing retires its partial scalar holder. These changes preserve the
exact approved ceremony encoding and do not clear caller-owned input bytes.
Validation and signing use records.WithCeremony for scoped parsed holders;
records.Ceremony.Close is the shared retirement operation for canonical bytes,
nonces and exporter arrays. Store validation, installation, claim acceptance,
approval signing, catalog generation selection and dependency admission do not
transfer their temporary holder to durable state. Successful verified-record
results retain their ceremony evidence; failed or duplicate candidates retire.
Dependency lookups transfer an explicit owned candidate holder to the verifier,
which clears every cloned candidate on success and failure. VerifiedPool
retains an independent ceremony copy, retires consumed verifier evidence on
every intern result, shares retained evidence through its existing pool
references, and clears it when the final pool owner closes. Directory validation,
relationship projection, and epoch construction scope or avoid parsed ceremony
holders rather than leaving temporary nonce or exporter copies to garbage
collection.
Every independent store snapshot and runtime pairing projection owns its request,
ceremony, root, and selector copies. Snapshot replacement, rejected candidates,
post-rename uncertainty cleanup, retention purge, service projection exit, and
store shutdown call the same pairing-row retirement operation. Signed approvals
and public trust records remain public evidence and are not treated as secrets.
Growing invitation, pending-client, and pairing slices transfers rows to a new
backing allocation and clears the abandoned structs so inline selectors do not
remain in an unreachable old allocation.
Protocol Cancel uses the caller or worker context while waiting for the writer
and before persistence. Persistence that has started retains the ordinary
post-rename uncertainty rule. For a row with accepted Context, an already
committed Cancel may be delivered or accepted only while
now < approval_deadline. A prepared-origin row whose Context was lost has no
safe delivery cutoff because the two Hubs have independent clocks. It can
commit local cancellation, but it sends no Cancel without the target's signed
Context and exact deadline. The Completion-only exception after the cutoff does
not admit Cancel.
Joining preparation retires root/selector parameter copies and registers its connection-local copies before derivation or preparation can fail. The approval branch has a separate owner for the reloaded private projection. Its request and ceremony allocations retire on success, load/phase/approval failure, write failure and response failure. Retirement does not clear borrowed signed approvals or the store's durable ceremony.
Public recovery retires the initial status projection separately from the independent runtime projection loaded for an exact committed-Cancel retry. The fallback transfers its projection to a scoped validation owner that registers request and ceremony retirement before load, phase or identity rejection. Retained-alias regressions check erasure on success and every rejection while preserving the durable cancelled row. A separate public-TLS regression keeps the joining row Prepared after the target commits Claim, advances its security time past the target's actual deadline, restarts it, and proves that its durable Cancel sends no application bytes without an authenticated target deadline. Pairing wire responses, exact-Context deadlines and durable formats do not change. Independent final review confirmed the scoped owner and retained-alias coverage for that source revision.
The merge correction makes both timing boundaries authoritative after blocking work. Local joining approval, inviting approval, and cancellation refresh the service's injected wall clock after decision and recovery owners have joined. The store samples that live pairing clock again after acquiring its snapshot lock, then applies the persisted security-time floor. Time spent behind a reader or writer therefore cannot preserve an earlier decision instant. A timestamp captured when local control decoded the request, or immediately before a blocked store call, cannot authorize a decision after the approval deadline.
This is a deliberate pairing-only divergence from the client invitation carrier. Admission and endpoint sessions finish within their scheduler and response deadlines and use their existing replay or acknowledgement recovery; they do not commit a claim and then hold the same socket for an out-of-band administrator. Pairing does exactly that after durable Context, so it releases the initial worker and starts a separate, bounded held-decision phase. The seven-day approval deadline governs durable ceremony eligibility and fresh exact-pinned recovery. It does not authorize keeping the initial TLS connection open for seven days.
After durable Context, each initial TLS side transfers its one transport
cancellation owner to the earlier of the fixed five-minute window and approval
deadline. Projection reads, scheduler continuation, and response writes use that
context, and the write deadline cannot extend it. If the cutoff wins after a
joining approval was already durable, no Approval frame is sent and
PairingLocalApproved remains available to exact-pinned recovery. The target
likewise closes instead of writing a late continuation response. This changes no
message, signature, exporter, or durable bytes. Service coverage also proves
that cancelling a Prepared row with no authenticated target deadline commits
locally without opening a TCP connection or reserving pairing-connection
capacity.
Local API boundary
Private administration now uses typed EzHub JSONL over authenticated AF_UNIX.
Local RPC request_id is separate from durable pairing_request_id.
check_pairing and bilateral decisions retain their existing exact-request,
revision, deadline and registration barriers. Transport cancel ACK follows
handler retirement, not durable ceremony cancellation. EOF and shutdown cancel
then join recovery owners. The shared dashboard/view Client preserves passive
status and client-owned check scheduling.
The engine's synchronous Prepared callback now carries the definite commit revision and precedes Claim disclosure. Its separate ContextCommitted callback runs immediately after definite Context persistence, before deadline evaluation or Accepted handoff. Thus local Add Hub can preserve a Prepared checkpoint after carrier failure and Accepted after an abandoned handoff. Neither callback publishes a new durable phase or inter-Hub field. Persistence uncertainty remains inspectable by the local owner, triggers fail-closed service notification and never fabricates either result. Remote responses remain generic Failure.
The config client opens or wakes one view for either durable outcome and starts an immediate exact check. Alias warnings do not erase the checkpoint. See private administration and service integration tests. All bilateral U32BE frames, TLS/exporters, signatures, approvals, deadlines and durable bytes above are unchanged. Routing, relay transport, circuit bootstrap, fixed-attachment sessions, retained recovery, production remote application access and the restricted routed pairing carrier below are implemented; see the circuit status. The approved private contract is frozen in local control. The invitation/pairing ceremony remains unchanged.
Restricted routed acquisition
The restricted carrier
freezes AHRP setup, states, frames, admission, quotas and exact-link settlement.
The contract is implemented through restrictedpairing.Setup and the existing
service pairing owners. AddHub, recovery and cancellation branch on explicit
stored mode before indexing an address. See the service composition
and service pairing tests. Empty routed address lists remain empty through
Prepared, both Pairing rows, both approvals and eventual Peer rows. No API field,
signed record, pairingwire frame, Q or durable row format changes.
For a new routed AddHub, keep validateAddHub's empty Address rule, the expected revision check, JoinWords parsing, HubIdentityLock and every independently supplied identity check. Charge outbound ResourcePairingConnection before any carrier/TLS work, using the existing 16-global/two-per-key limits. Obtain a charged, independently owned bounded candidate set through LearnedDirectory.VerifiedLineages and its existing reserve callback. Verify complete authority lineages with records' existing verifier, group by stable root, and require one maximal nonforked current head satisfying ALL supplied HubIdentityLock/CandidateCheck constraints. Zero matches or multiple roots/heads fail unavailable; a route preference never disambiguates an identity lock. Close the copied candidate-set charge after retaining the single scoped ResolveCircuitAuthority selection/borrow. Recheck that exact selection after carrier OK and TLS verification, then close its proof hold. These are bounded public authority proofs, not a Peer pin, successor consent or target generation for Prepared.
Lookup only that selected genesis root in the RAM routing Table; retain one complete candidate, then establish one fresh AHRP carrier with the selected head. Require both its public OK fields and the dedicated end-to-end InitialPairingClient chain/check callbacks to match. Pass the full CandidateCheck again to InitialPairingClient, not only a fingerprint reconstructed from learned content. Only that client may release the joining certificate. The invitation selector/proof remains withheld until mutual TLS, Challenge and definitely committed Prepared. Origin/relay/carrier checks do not move that commit earlier. Signed Context, not the certificate or learned bundle, installs target generation and target-clock deadline. The existing JoinInitial input uses mode Routed and no addresses; its callbacks still register the exact initial decision owner before Prepared publication and return typed Prepared versus Accepted outcomes.
Target service reserves the restricted raw connection, normal pairing TLS working capacity and a routed scheduler handshake lease before transport OK. It then uses InitialPairingServer with the existing provider and exact pairing ALPN, authenticates the joining authority, transfers authenticated pairing capacity, and invokes the SAME pairing.Engine.ServePublic path as direct entry. Factor that service callback from the public accept composition rather than copying the ceremony. Use the marked ReserveRoutedHandshake lease specified in service composition. Its Entry fairness key is the validated path's first root, not an IP or a claimed remote certificate; it grants no trust. After pairing TLS, TrafficIdentity.Claimant and Subject come from actual remote/local authorities. Claim's signed lineage and claimant lock remain the target's authority checks. Any endpoint/peer ALPN, exporter substitution or arbitrary tunnel attempt fails before entering the engine. No normal peer accept callback is reachable here.
For a saved routed row, select its exact durable target pin and Q, not fresh short checks or new ceremony material. Resolve a current unambiguous lineage and route only as transport evidence for that pin; failure is an interrupted check, not permission to adopt a successor. Prepared without Context uses InitialPairingClient with the saved exact target key and performs status-first RecoverJoining. An exact-Q Claim retry, when existing policy permits it, uses a NEW restricted carrier and TLS connection. Context-bearing rows use the existing request-bound PairingClient provider for status/Approval/Cancel. Target's current ServePublic recovery dispatch and durable exact-Q authorization remain in use; no carrier purpose flag skips them. Prepared without an authenticated target deadline still sends no Cancel bytes.
One private exact check remains owned by the open local view through the existing decisions/recoveries/canceling registry. Hub startup, route publication, refresh, recovery notifications and durable rows schedule no check or reconnect. The view owns retry pacing and polling. Each operation joins its carrier, TLS, engine/completion work and budget before unregistering the exact recovery owner or delivering the typed API terminal result. The five-minute initial carrier, seven-day approval cutoff, eighth-day Prepared boundary and Completion-only retention rules stay under their existing owners. Carrier lifetime/quota loss may interrupt delivery; it never extends those rules or replays an approval.
Required downstream negatives include target-head/root substitution, mismatch of any one supplied check, reversed TLS role, wrong ALPN/exporter, direct/routed Q replay, missing/late Prepared, lost Context status-first recovery, cancellation without Context, active-row timer creation, nonempty address installation, endpoint/normal-peer/arbitrary-tunnel promotion and late settlement against a replacement exact link. Literal transport negatives are already in the carrier corpus; these cryptographic/business cases require real service tests later.
Topology and successor integration evidence
The complete diamond regression now checks passive joining restart and exact-Q recovery over an alternate, then both approvals and Completion. The rotated actual target regression covers neighboring successor approval, the old partner's persisted denial, bilateral local removal and a complete new routed ceremony. No previous consent/denial or dial address is inherited. Stale head and contradictory independent checks fail before a new durable Q.
A changed-key attempt before bilateral removal can reach Prepared because Challenge/Prepared does not yet establish signed genesis. The target refuses Claim, so it issues no Context or approval and does not replace the existing Peer. Do not describe that boundary as a refusal before all durable preparation. Both new regressions retain strict signed/TLS proof and the original engine; rotation is staged while services are stopped, not inside a live ceremony. These regressions live with the pairing and service owners; selection follows the test policy.