Skip to content

feat: ask what ssh asks for the core link and core move on the screen that started them - #1846

Merged
yansfil merged 8 commits into
mainfrom
feat/core-link-sign-in
Oct 29, 2026
Merged

yansfil merged 8 commits into
mainfrom
feat/core-link-sign-in

Conversation

@yansfil

@yansfil yansfil commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

다른 기기의 core에 붙는 연결과 core 이동은 지금까지 ssh가 비밀번호나 처음 보는 서버 확인을 물으면 아무에게도 묻지 못하고 "로그인 필요"로 멈췄습니다.
이제 운영자가 창에서 직접 누른 시도(띠의 로그인·다시 시도, 이동 점검)에서는 장비 줄과 같은 입력칸, 서버 지문 확인, 브라우저 링크, 보안 키 터치 안내가 그 시도를 시작한 화면에 나옵니다: core 연결은 창 위 띠, core 이동은 이동 대화상자.
질문은 누른 창에만 보이고 그 창만 답합니다.
취소하거나, 질문·브라우저 확인·보안 키 터치를 5분 안에 끝내지 않거나, 누른 창을 닫으면 질문이 뜨기 전이든 두 질문 사이든 시도가 끝나고, 입력한 값은 어디에도 남지 않습니다.
Hide가 스스로 하는 재연결과 창 없이 한 연결(hide connect)은 여전히 아무것도 묻지 않고 로그인 필요로 멈춥니다.
실패는 장비 줄과 같은 세 가지(로그인, 바뀐 서버 키를 터미널에서 확인, 다시 시도)로 보이고, 바뀐 서버 키에는 다시 시도가 없습니다.
누른 한 번은 로그인 한 번만 묻습니다.

window-asks-ko
창 위 띠: 다시 시도가 시작한 연결이 비밀번호를 물으면 띠 아래에 장비 줄과 같은 입력칸이 펼쳐집니다.

checks-sign-in-ko
이동 대화상자: 점검이 키 암호를 물으면 입력칸과 ssh-add 안내가 점검 중 문구 아래에 나옵니다.

Review

  • 판단해 주세요: 띠가 질문을 보여 줄 때 띠 아래로 입력칸이 펼쳐지는 모양(위 첫 이미지)이 받아들일 만한지.
  • 판단해 주세요: 로그인 실패 뒤 이동 대화상자의 다시 점검이 로그인으로 바뀝니다. 장비 줄의 다시 시도와 같은 규칙입니다.
  • 조심해서 볼 파일: hided/src/screen_sign_in.rs - 누름 하나가 Lease 하나: 누른 화면 연결이 주인이고, 보이기·묻기·답·취소·5분 기한이 모두 한 잠금 아래에서 처리됩니다. 현재 lease가 아니면 다이얼이 1초 안에 ssh를 끝내고 거둡니다(failure path, 원칙 14).
  • 조심해서 볼 파일: hide-node/src/ssh/upstream.rs - 다이얼이 lease를 가져가며(may_ask(Option<lease>)), lease가 없으면 NoSignIn이라 화면에 아무것도 뜨지 않습니다(D-06, B14).
  • 조심해서 볼 파일: hided/src/node_role.rs, hided/src/node_daemon/screen.rs - 띠의 다시 시도가 그 창의 lease를 잡고(connect_again(Some(screen))), 창 연결이 끝나면 Press 가드가 lease를 끝냅니다. 붙기가 다이얼 없이 열린 세션을 쓰면 남은 lease는 그 자리에서 버립니다. 업데이트 다이얼이 로그인에서 멈추면 다음 누름이 업데이트를 먼저 한 뒤 같은 세션으로 붙습니다(update_owed).
  • 조심해서 볼 파일: hided/src/core_move/control.rs - 점검 요청이 요청한 화면의 lease를 잡고, MoveScreen::frame이 질문을 그 화면에만 보냅니다. 대화상자를 닫으면 질문 번호 없는 취소가 시도를 끝냅니다.
  • 판단해 주세요: 창 없이 한 연결(hide connect, 앱 실행)은 묻지 않고 로그인 필요로 멈춥니다. 비밀번호 서버라면 앱을 연 뒤 띠의 로그인을 한 번 더 눌러야 합니다.
  • 조심해서 볼 파일: contracts/hided-ws.schema.json - core_link·core_move 프레임의 sign_in, ssh_problem과 action: sign_in 이벤트. problem이 이제 장비 줄의 묶음(DeviceProblem) 코드입니다.

Evidence

  • 확인한 것: 실제 sshd로 (system_ssh::unix::a_core_link_asks_on_its_screen_only_for_the_operator_s_own_dial): 누르지 않은 다이얼은 아무것도 띄우지 않고 sign_in_needed; A가 누른 다이얼은 지문을 A에게만 보이고 B의 답은 NotOwner, A의 취소는 sign_in_needed; 같은 연결의 다음 다이얼은 묻지 않음; A가 질문 중에 닫으면 다이얼이 기한 전에 바로 끝남; A가 질문 전에 닫으면 아무것도 뜨지 않고 sign_in_needed; 신뢰 후 연결되고, known_hosts를 지운 뒤 같은 연결의 다음 다이얼은 묻지 않고 열린 세션으로 실행됨.
  • 확인한 것: lease 단위 테스트 10개 (screen_sign_in::tests): 주인만 답함, 질문 전·두 질문 사이 닫기, 질문 번호 없는 취소, 보안 키 터치와 브라우저 확인이 기한에 시도를 끝냄, q1 취소가 나중에 온 q2를 건드리지 않음, 새 누름이 이전 lease를 끝내고 이전 lease의 끝은 새 것을 건드리지 않음.
  • 확인한 것: 이동 점검의 A/B (core_move::control::the_checks_sign_in_belongs_to_the_screen_that_asked_for_them): 질문은 A의 프레임에만, B의 답은 move_not_asker, B가 닫아도 그대로, A가 질문 중·질문 전에 닫으면 끝남, 대화상자 닫기의 번호 없는 취소, 화면 없이 요청한 점검은 lease 없음.
  • 확인한 것: node_role::tests::an_update_stopped_on_a_sign_in_runs_first_on_the_next_press - 로그인에서 멈춘 업데이트는 깨우기로 대기가 끝나지 않고, 누름 없는 시도는 lease도 업데이트도 가져가지 않으며, 누름이 업데이트를 먼저 가져가고 그 뒤 붙기는 누름 없이 다이얼합니다. 보안 키 터치는 askpass 데스크에서도 5분에 끝납니다(askpass::tests::a_touch_that_never_comes_ends_the_attempt_at_its_bound).
  • 확인한 것: 운영자 대기 중 ssh가 다시 시작되지 않음은 기존 remote_core::a_core_link_that_needs_the_operator_dials_again_only_when_they_connect가 서버 연결 수로 확인합니다.
  • 확인한 것: 띠·대화상자 컴포넌트 테스트 7개: 바뀐 서버 키에 다시 시도 없음; 대화상자가 보낸 요청이 도는 동안 닫으면 번호 없는 취소가 그 요청 뒤에 같은 소켓으로 나감(core의 첫 프레임 전에 Move 후 닫기, 다시 점검 후 닫기 포함; 고치기 전 조건에서는 실패); 결과가 온 뒤나 포기용으로 연 대화상자는 보내지 않음. 띠 문구 테스트 포함. 전체 게이트(cargo test, lint, verify-web) 결과는 Verification record에.
  • 확인하지 못한 것 (NOT PROVED): node 창의 실제 소켓 경로, 곧 인증된 websocket 두 개에서 질문 프레임이 A에게만 가고, B의 답이 막히고, A가 닫히면 잡고 있던 ssh가 끝나는 것은 코드 읽기로만 확인했습니다. remote_core 하네스는 화면 websocket을 다루지만, node 데몬의 core 별칭이 질문을 하게 만들려면(처음 보는 서버 키나 비밀번호를 가진 별칭으로 node를 띄우기) 새 하네스가 필요합니다. sshd 테스트는 ScreenSignIn과 Upstream을 직접 이어 소유권과 닫기 시점을 증명하고, 이동 쪽은 MoveScreen 단위 테스트가 필터와 닫기를 증명합니다.
  • 확인하지 못한 것: 실제 두 기기 사이의 core 연결·이동과 core 업데이트를 설치된 앱으로 확인하지 않았습니다(갤러리와 sshd 테스트로 대신). 실제 보안 키 터치는 sshd 테스트로 재현하지 않았습니다(데스크와 lease 단위 테스트로 대신).
추가 증거

window-host-key-ko
띠: 처음 보는 서버의 지문, 어느 쪽도 미리 고르지 않은 두 버튼.

window-sign-in-ko
띠: 로그인 필요로 멈춘 연결은 로그인을 둡니다.

window-host-key-changed-ko
띠: 서버 키가 바뀌면 ssh mini 복사만 두고 다시 시도는 없습니다(#1840의 장비 줄과 같음).

checks-host-key-ko
대화상자: 점검이 처음 보는 서버를 만났을 때.

checks-ssh-failed-ko
대화상자: 연결 점검이 바뀐 서버 키로 멈추면 장비 줄의 문구와 명령, 다시 점검은 없습니다.

window-asks-en
checks-ssh-failed-en
영어.

Verification record
  • head: 58134d7 (lease 2966014, format 1d00673, dialog close before the core answers 5eb5767, a closed window's check still signs in with its key 58134d7)
  • CI verify run 40969696061 on 58134d7: completed success, every job green (remote mailbox core_move included).
  • local core_move suite against the local sshd (-j 4, pinned Herdr 0.9.5): 44/44 on 58134d7.
  • local bash scripts/verify-cargo.sh lint: exit 0.
  • local bash scripts/verify-cargo.sh test: exit 101, only hide-memory store tests that share one process in parallel (a different one each run) at load average 127-235; cargo test -p hide-memory --lib -- --test-threads=1 205/205, nextest passes; this branch does not touch hide-memory (with-hide/hide-private#338).
  • local bash scripts/verify-web.sh with pnpm 10: 2277 passed, 2 failed, both src/OverviewGraph.test.tsx (5 s timeout under load, then its cascade); the file alone passes 17/17. With the shell's pnpm 12 the install refuses (ERR_PNPM_IGNORED_BUILDS).
  • targeted: screen_sign_in::tests (10), core_move::control::tests::the_checks_sign_in_belongs_to_the_screen_that_asked_for_them, node_role::tests::an_update_stopped_on_a_sign_in_runs_first_on_the_next_press, askpass::tests::a_touch_that_never_comes_ends_the_attempt_at_its_bound, system_ssh::unix::a_core_link_asks_on_its_screen_only_for_the_operator_s_own_dial (real sshd): 14/14 pass; web coreLinkSignIn.test.tsx 5/5, coreMove.test.ts 10/10.

…se, ask once per press and offer no retry for a changed key
…ed it

The core link and the core move's checks now take one lease per press, owned by
the screen connection that pressed: only it is shown and answers what ssh asks,
and its end, a cancel, or the five-minute bound of a question, browser check or
key touch ends the attempt before the first question, between questions or on
one. Show, ask, answer, cancel and the deadline go through one lock, so a stale
Cancel cannot end a later question. The last-held-window rule is gone; a
connect no screen made asks nobody. An update stopped on a sign-in runs first on
the next press.
A released lease asks nobody: a question waiting is refused and a browser check
or key touch waiting ends, but a sign-in that needs nobody, keys, the agent or
Tailscale SSH, goes on as one nobody pressed for, so a core move whose window
closed after its request still runs its checks.
@yansfil
yansfil merged commit 0c754da into main Oct 29, 2026
51 checks passed
@yansfil
yansfil deleted the feat/core-link-sign-in branch October 29, 2026 23:18
yansfil added a commit that referenced this pull request Oct 30, 2026
…four hided flakes (#1860)

Closes with-hide/hide-private#351
Closes with-hide/hide-private#321
Closes with-hide/hide-private#347
Closes with-hide/hide-private#330
Related: with-hide/hide-private#339 (diagnostics only; the issue stays
open)

## Summary

Five flaky hided tests, one cause each:

- #351 (`link_mux` connection end): on macOS a `recv` blocked on a local
socket sometimes misses its peer's shutdown, and after that misses its
own end's shutdown too. Then a core-side mux never saw its node end and
kept its streams. Every macOS `LocalStream` read now waits in `poll`
first, which hears both. The test's own `SO_RCVTIMEO` (EINVAL on macOS
after the end) is replaced by a reading thread with a hang guard.
- #321 (`device_bootstrap`): five tests each copied and stripped the 140
MB debug `hided` at once, past the fixture's 10 s command bound. A
shared helper now strips and signs each build version once under a lock,
and `remote_delivery` and `core_move` use it too.
- #347: its one flaky run was the CI merge commit 15f05b4 of a #1846
head that was later rewritten, where 43 of 44 `core_move` tests failed
together. It has passed first try on main since. The cause of that run
is not proven; the issue is closed on the later main passes (evidence in
the issue comment).
- #330: the test was deleted with the SFTP upload in 14b6b68.
- #339 (WSL, Windows only): the cause is not found. The journey keeps
its steps and the Hide AI progress in a bounded in-memory record (256
lines) and prints it only when it fails. At its own 105 s guard, before
the lane's 120 s one, it prints the record and the distribution's
processes, read by an owned `ps` bounded to 10 s, and ends the test. A
passing run prints nothing.

## Review

- **판단해 주세요**: a macOS-only `poll` before every local-socket read,
against the kernel's lost wakeup, instead of changing each caller that
waits for a peer's end.
- **조심해서 볼 파일**: `hide-platform/src/ipc.rs` - high-frequency path: every
`LocalStream` read on macOS (Herdr socket, mux, pane service).
- **조심해서 볼 파일**: `hided/tests/it/support/shipped.rs` - shared state
across test processes: lock, half-made copy cleanup, eviction of an
older build.
- **질문**: `link_mux`'s end tells the link's user by shutting down its
end of an in-process pair, which a Windows peer does not hear until the
handle closes, and no `link_mux` test runs on Windows. Should that
become its own issue?
- **비용 검토**: one `poll(2)` per macOS read, with no new thread, timer,
queue or notification. Linux and Windows read paths are unchanged
(`cfg!(target_vendor = "apple")`). The mux frame reader sits behind a
`BufReader`, so a frame is not one read per field.

## Evidence

- **확인한 것**: #351 reproduced before the fix:
`the_connection_ending_frees_every_stream` failed in 1 of 13, 1 of 81
and 1 of 141 stress iterations (both signatures). A stack sample showed
the core's demux thread asleep in `recvfrom` after its peer ended.
- **확인한 것**: the kernel behaviour, in C at load ~30 on macOS 15.1:
`recv` after the peer's `shutdown(SHUT_WR)` hung for over 60 s, about
once in 4,500 rounds. A `poll` wait hung 0 times in 48,000 rounds, and
`close()` 0 times in 18,000.
- **확인한 것**: the new contract test
`a_shutdown_ends_the_peers_blocked_read_every_time` hung in recvfrom on
its first iteration before the fix. Its rounds now run in an owned
exact-test subprocess bounded to 60 s. With the macOS `poll` removed
again, it failed at stress iteration 12 (round 3,724) in 10 s, with the
subprocess reaped. With the fix: 75 runs × 5,000 rounds passed, and the
`link_mux` tests passed 300 of 300 stress iterations (before the drain's
failure-path change, which only touches a timeout).
- **확인한 것**: `device_bootstrap` passed 6 of 6 twice locally at 8 threads
(macOS, private sshd and pinned Herdr 0.9.5). The store held one
stripped copy, rebuilt once when the build changed.
- **확인한 것**: `hide-platform` + `hided` (lib and `it`) 971 tests and
`herdr-core` + `hide-herdr-client` 3,496 tests passed on macOS with the
change. Clippy `-D warnings` and fmt are clean.
- **확인한 것**: the new contract is Unix only: on the first CI run, `os
contract (windows)` showed that a Windows shutdown never reaches the
peer (`CancelIoEx` ends this end's own I/O; the peer hears the end when
the handle closes).
- **확인하지 못한 것**: #339's cause (no WSL here). `wsl_device.rs` is
Windows-only; a cross-check from macOS could not build its C
dependencies, so the `windows wsl` lane is its first compile.
- **확인한 것 (비용, 미시)**: a C microbenchmark of plain `recv` vs
`poll`+`recv` on one socketpair (macOS 15.1, load 18-48), not a product
build. 64 B messages × 300,000: `recv` 1.14-5.87 µs per read over 5
completed trials, `poll`+`recv` 1.61-6.71 µs over 9. The difference
within a matched pair was 0.3-1 µs; 2 more `recv` trials hung on the
lost wakeup. 16 KiB × 20,000, 6 trials each: 5.7-17.8 µs vs 6.4-16.4 µs,
with the pairs disagreeing in sign (noise).
- **확인하지 못한 것 (비용, 실사용)**: `docs/PERFORMANCE_TESTING.md`'s matched
idle/driven terminal measurement (`scripts/web-shell-measure`,
`MEASURE_SCENARIO=keys`: key echo p50/p95, hided CPU and RSS, base
a891332 vs this head). It was not run: two release builds do not fit
on this Mac's disk now, and its load is 20-60. The microbenchmark does
not prove the product's end-to-end cost.
- **확인하지 못한 것**: `core_move` and `remote_delivery` with the shared
helper (left to the remote mailbox lane).

<details><summary>Verification record</summary>

</details>
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