Skip to content

feat: count remote device connection outcomes - #1725

Merged
yansfil merged 4 commits into
mainfrom
feat/device-connect-analytics
Oct 27, 2026
Merged

yansfil merged 4 commits into
mainfrom
feat/device-connect-analytics

Conversation

@yansfil

@yansfil yansfil commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Hide가 시작하는 outbound 원격 기기 bootstrap의 성공 횟수와 실패 단계를 확인할 수 있도록 hide_device_connected 하나를 추가합니다.
기기 콘텐츠와 식별자는 보내지 않고, 기존 설치 통계 설정과 전송 큐를 사용합니다.
이 core로 직접 접속하는 inbound node는 집계하지 않습니다.

Review

  • 판단해 주세요: 저장 프로필 서버를 그대로 둔 성공은 승인된 추가 값 herdr=preserved로 구분합니다.
  • 조심해서 볼 파일: runtime/device_analytics.rs는 완료 토큰 소비와 실패 매핑, runtime/hosts.rs와 runtime/kit.rs는 연결 수명 경계를 담당합니다.
  • 비용 검토: 연결당 최대 1개 완료 토큰, 대기 최대 128개, 기존 Sink 큐 최대 128개입니다. 새 I/O·워커·폴링·알림은 없습니다.
내부 결과 외부 값
SSH/config·신뢰·미지원·설치/업로드·helper 단절·kit 거절/호출 오류 failed, failed_step=install
외부 플랫폼 release kit 취득 오류 (EstablishError::Download) failed, failed_step=download
Herdr pinned/version/program/ping/start 오류, legacy NoServer, 업데이트 결과 누락 failed, failed_step=herdr_start
Herdr Behind(전환 미지원/이전·현재 전환 실패), record/handoff/confirm 오류 failed, failed_step=herdr_handoff
HerdrUpdate Started/HandedOff/Current/Kept ready, herdr=started/handed_off/current/kept
저장된 named session의 서버 보존, HerdrUpdate 없음 ready, herdr=preserved

플랫폼은 허용된 macOS/Linux 아키텍처 조합만 전송하며, 플랫폼 확인 전 오류는 승인된 unknown을 사용합니다.
연결 세대에 묶인 시도 토큰을 첫 Apply 또는 bootstrap 완료가 소비합니다.
소비 후 중복 완료·status·snapshot은 이벤트를 만들 수 없고, 재연결과 Retry는 새 토큰을 받습니다.
이전 세대의 완료는 무시하며, 취소·동의 철회·제거는 미완료 토큰을 폐기합니다.

Evidence

  • 확인한 것: 코어 신규 4개를 포함한 56개 테스트로 성공·실패·재연결·Retry·inbound 제외·중복 완료·조회 무재집계를 확인했습니다.
  • 확인한 것: daemon의 실제 loopback HTTP 2개 테스트로 6개 전송 본문의 정확한 키·속성과 opt-out 큐 폐기를 확인했습니다.
  • 확인한 것: 변경 크레이트 컴파일, 포맷, 코어 기기 접근 금지·off-lock reader·ignore·식별자·귀속·design contract 검사를 통과했습니다.
  • 확인한 것: 전체 Rust, 원격 mailbox, Linux 웹 5샤드, Windows 검사·웹·데스크톱, macOS 데스크톱 2샤드 CI가 통과했습니다.
  • 확인하지 못한 것: 실제 기기 bootstrap에서 PostHog 수신까지의 수동 경로는 미확인입니다. 코어 최초 시도 진입은 fixture로 공급합니다.
Verification record
  • Base: c88c8c470e14 (main). Head: 70483c77806a413c766349c3f392bad145307dcd.
  • Local: scoped compile PASS; core device-kit 56 PASS including 4 analytics regressions; hided product_analytics 2 PASS (6 real HTTP bodies); fmt and boundary checks PASS.
  • Scoped all-target clippy: PASS. Independent code/fidelity reviews: PASS on 70483c77806a413c766349c3f392bad145307dcd, no Fix now defects. Follow-up: production SSH admission fixture coverage; tests currently supply initial admission.
  • Mutation check: removing the outbound-only Retry guard failed the inbound-exclusion regression as predicted; original guard restored.
  • Full CI: verify 40446150036 PASS on the final head. Planned skips are retained; no lane was manually rerun.
  • Synthetic merge: cc0c99d6b78f50c9b8e21f5aa27bfbd85968797f against main c88c8c470e14a712245fa6e3cc27c2faedc7aada.

@yansfil
yansfil merged commit 0732fa4 into main Oct 27, 2026
65 checks passed
@yansfil
yansfil deleted the feat/device-connect-analytics branch October 27, 2026 04:23
yansfil added a commit that referenced this pull request Oct 27, 2026
Related: #1722, #1725

## Summary

main의 `verify`가 #1722 머지(e21d4bb) 뒤로 `rust workspace`의 기기 통계 테스트 하나에서
계속 실패합니다.
두 PR이 따로 초록인 채 머지되며 생긴 충돌입니다: #1722는 Herdr 시작 실패 뒤 Retry를 kit 재적용에서 기기
재연결로 바꿨고, #1725의 테스트는 옛 kit 경로로 Retry를 흉내 냈습니다.
제품 동작은 맞습니다: 재연결이 새 연결 시도를 열고, 그 연결의 kit 보고(`Started`)가 성공 한 번으로 기록됩니다.
그래서 코드는 그대로 두고, 테스트가 Retry 뒤 재연결의 결과를 공급하도록 고쳤고, `docs/ARCHITECTURE.md`의
통계 계약에 이 Retry가 재연결의 시도로 세어진다는 문장을 더했습니다.

## Review

- **판단해 주세요**: 되돌리기(revert #1722) 대신 테스트 수정을 택했습니다. Retry 성공이 연결 한 번으로
세어진다는 계약은 재연결 경로(`spawn_host_start`의 `begin_device_connect` ->
`ingest_host_established`의 claim/complete)에서 그대로 지켜집니다.
- **조심해서 볼 파일**: `herdr-core/src/runtime/tests/device_kit.rs` - fixture에
SSH transport가 없어, 바깥 worker가 하는 시도 등록과 연결 결과를 테스트가 직접 넣습니다(바로 위 통계 테스트와
같은 방식).

## Evidence

- **확인한 것**: 수정 전 main(e22c924)에서 CI와 같은 단언(device_kit.rs:2897, 두 번째
`Ready(Started)` 없음)으로 로컬 실패를 재현했습니다.
- **확인한 것**: 수정 뒤 `verify-cargo.sh nextest -p herdr-core -E
'test(/device_kit|device_analytics|device_connect/)'` 56개 통과,
`fmt-check` 통과.
- **확인한 것**: 테스트는 Retry가 기존 연결을 닫는지, Retry 자체는 통계를 늘리지 않는지, 재연결 성공이 한 번만
기록되는지를 봅니다.
- **확인하지 못한 것**: 디스크 여유가 4GB 아래라 로컬 clippy와 다른 crate는 돌리지 않았습니다. CI
`verify`에 맡깁니다.
- **확인하지 못한 것**: 실제 기기로 Retry 뒤 PostHog 이벤트가 오는지는 보지 않았습니다.

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

Base: `e22c924b67a630e04e4c907d9d28bb021ef22c07`.
Failing main runs: 40450672875, 40453581851, 40455435250; last green
main a1bed1f (run 40449782460).

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