Files
Martin Vogel 1c73f8676c fix(daemon): hash a verified peer image copy once, not on every HELLO (#1955)
A client whose binary is a different file with identical bytes (a second
install path, a package-manager copy) misses the daemon's metadata-only
active-image check, so the HELLO proves the build by SHA-256 over the peer's
whole image. The release binary is ~300 MB: that hash takes ~1.2 s on an
M5 Pro with a warm cache and longer under indexing load or on slower x64,
while the client grants connect+HELLO only 1000 ms. The client abandoned the
HELLO, re-probed, and every re-probe started the same hash again on a fresh
worker, so such a client waited out the whole 30 s startup deadline against a
healthy daemon that kept serving its existing sessions.

The daemon now retains the reference of each peer image whose full
fingerprint matched its own build (bounded to 8 distinct files) and admits
later peers mapping that same unchanged file by metadata, exactly like the
active image. The retained reference pins the inode, so its stat identity
cannot be reused by another file. The accepted set of images is unchanged:
mismatched and unverifiable peers take the same paths as before.

Before, same daemon, identical copy B of the running binary A:
  B cli --json index_status -> 34.9 s, "answered no rendezvous within 30000 ms"
After:
  B first call 4.9 s (one hash), then 1.4 s, 1.4 s (same as A)

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-09-25 18:37:16 +02:00
..