Skip to content

fix(core): draw 64-bit session ids so a pruned id is not reused - #445

Merged
ElbertePlinio merged 4 commits into
mainfrom
fix/413-session-id-bits
Oct 29, 2026
Merged

ElbertePlinio merged 4 commits into
mainfrom
fix/413-session-id-bits

Conversation

@ElbertePlinio

Copy link
Copy Markdown
Member

Closes #413
Closes #376

New session ids carry 8 random bytes (16 hex characters) instead of 4. A new session drawing one specific id freed by session prune now has a chance of 2^-64 per creation, so a stalled caller cannot act on a new session through its old id. Records with 8-hex ids from before this change still read, update and destroy.

The generation binding the issue first proposed was dropped. The council found that every check-then-mutate path (update, destroy, stop input) still raced a reuse, so it narrowed the window without closing it.

The longer id makes viewer/host.sock 8 bytes longer. Clients now connect to the native viewer host through /proc/self/fd/<fd>/host.sock on a verified handle to its directory, so the path length no longer matters. This also fixes #376. Every #404 identity check on the socket is unchanged and now runs on that same descriptor path. Requests, subscriptions and pulses all connect this way.

Traceability

Requirement Verification Scenario and edge cases Result Evidence
#413: a reused id cannot reach a stale caller New ids from randomBytes(8); unit test on all four session types desktop, android, duo and browser ids match <prefix>-[0-9a-f]{16} Pass; fails on the old source ~/.pickforge/investigations/413/ids/before-old-source.log, vitest-core.log
#413: old sessions keep working Unit test with a hand-written desk-1a2b3c4d record get, update and destroy an 8-hex record next to new ids Pass ~/.pickforge/investigations/413/ids/vitest-core.log
#413: ids display correctly Native viewer on a private Xvfb thumbnail label and window title with a 16-hex id, short and long project names Pass ~/.pickforge/investigations/413/ids/qa-short-label.png, qa-long-label.png, titles.txt
#413: socket path lengths Table of every socket and length-limited path that contains an id default home, 32-character user name, legacy home, test homes Only host.sock is connected by Pickforge, fixed below; app-made sockets unchanged in kind ~/.pickforge/investigations/413/ids/path-table.md
#376: the host is reachable for any home native-viewer-host.test.ts "serves a request, a subscription and a pulse when the socket path passes the limit" host.sock over 107 bytes: takeover request, subscription to ready and cancel, pulse Pass; times out on 2349129 ~/.pickforge/investigations/413/socket/before-long-home.log, after-long-home.log
#376: watch opens the native viewer QA on a private Xvfb with a 76-byte PICKFORGE_HOME 124-byte host.sock, watch with no browser fallback Pass ~/.pickforge/investigations/413/socket/qa/qa-root.png, sessions.txt, watch-longhome.log
#404 checks still hold Existing replaced, legacy and dead-readiness socket tests; reviewer probes replaced socket, symlinked or unsafe directory, stale identity, missing ctime, timeout, refused connection, 153-byte path Pass ~/.pickforge/investigations/413/socket/vitest-focused.log
Session create with a long home session create --no-viewer and session destroy with an 84-byte home create and destroy succeed Pass ~/.pickforge/investigations/413/socket/long-home-create.log
Full suite full-suite.sh at 0ea478a build, lint, typecheck, viewer build, vitest, cargo 3448 passed, 4 skipped; cargo 328 passed ~/.pickforge/investigations/413/full3/
PickCheck and secret scan pickcheck check --base origin/main --fail-on new,worsened,unmatched; gitleaks on the branch commits 22 files checked 0 violations; no leaks ~/.pickforge/investigations/413/full3/pickcheck.json

Review

Council, three seats per round.

Round Revision Sol Fable Kimi
1 generation binding (dropped) 4 8 3
2 2349129 7 9 not run (usage limit)
3 0ea478a 9 9 not run (usage limit)

Round 2 found the host.sock connect limit and a stale 32-bit comment; both are fixed in 45efb80 and 0ea478a. Round 3 left three nits, accepted without a repair round: a missing or symlinked viewer directory reports the run storage wording from DirHandle, a refused connect names the /proc/self/fd path, and the long-home test covers success, while the shared refusal checks run under a short home.

A socket swapped at host.sock between the identity check and connect is still reached, as before this change. Requests and subscriptions refuse it when the reply does not match the recorded host.

Session ids now carry 8 random bytes. After prune frees an id, a new session practically never draws it again, so a stalled caller cannot act on a new session by its old id. Records with 8-hex ids still read, update and destroy. Refs #413.
…descriptor

Clients checked and connected to host.sock by its full path. With 16-hex session ids, a session home of 60 bytes or more pushed that path past the 107-byte socket path limit, so requests failed with EINVAL. Clients now check the socket identity and connect through one verified viewer directory descriptor, as the host binds it. Refs #413.
@ElbertePlinio
ElbertePlinio merged commit 9997172 into main Oct 29, 2026
10 checks passed
@ElbertePlinio
ElbertePlinio deleted the fix/413-session-id-bits branch October 29, 2026 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant