Skip to content

fix: remove the causes of the connected-node runtime test flakes - #1824

Merged
yansfil merged 5 commits into
mainfrom
fix/flaky-node-runtime-tests
Oct 29, 2026
Merged

yansfil merged 5 commits into
mainfrom
fix/flaky-node-runtime-tests

Conversation

@yansfil

@yansfil yansfil commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Closes with-hide/hide-private#153
Closes with-hide/hide-private#152
Closes with-hide/hide-private#148
Closes with-hide/hide-private#218
Closes with-hide/hide-private#213
Closes with-hide/hide-private#227
Closes with-hide/hide-private#319
Closes with-hide/hide-private#159
Closes with-hide/hide-private#246
Closes with-hide/hide-private#186
Closes with-hide/hide-private#126

Summary

herdr-core의 연결 노드 runtime 테스트 11개가 가끔 실패하던 원인을 고쳤습니다.
대부분은 테스트가 순서를 직접 정하지 않아 백그라운드 작업이 끼어든 경우였고, 그중 둘은 제품 쪽 문제였습니다.

  • 정리(cleanup) 검토 결과가 화면에 나온 바로 그 순간 누른 "정리" 확인이 조용히 버려졌습니다. 이제 검토 결과와 다음 작업 허용이 같은 순간에 일어나서 확인이 항상 받아들여집니다.
  • 새 pane의 셸 대기에서, 마감이 읽기 도중에 끼어들면 앞서 실패한 이유가 지워져 진단 기록이 "unreadable" 대신 "timeout"이 되거나 엉뚱한 이유를 남겼습니다. 이제 마감에 잘린 읽기는 결과로 치지 않습니다.

대기 시간을 늘리거나 재시도를 더하지 않았습니다.
with-hide/hide-private#274(doorbell 두 테스트)는 재현되지 않아 범위에서 뺐고, 원인 후보와 증거를 이슈에 남겼습니다.

스크린샷 없음: 화면을 바꾸지 않는 core와 테스트 변경입니다.

Review

제품 동작이 바뀌는 곳 (둘 다 수정 없이 실패하는 테스트로 증명, Evidence 참고):

  1. herdr-core/src/worktree_cleanup.rs WorkerGuard, worker_ended - 정리 worker가 마지막 snapshot 전달과 lane 해제를 한 lock 안에서 합니다(전에는 lock 두 번). runtime/projects.rs confirm_cleanup은 lane이 잡혀 있으면 확인을 거절하는데, 검토 답과 lane 해제 사이에 온 확인이 여기서 버려졌습니다(#152의 CI 로그: 10초 동안 제거 진단이 하나도 없음).
    • Mutex<Runtime> 아래 일: 늘지 않았습니다. 같은 ingest_cleanup과 cleanup_worker_finished(필드 하나를 None으로)를 두 번의 lock 대신 한 번의 lock에서 합니다. 새 I/O, subprocess, 직렬화는 없고 notify는 전처럼 lock 밖입니다. scripts/check-capability-readers-off-lock.sh 통과.
    • 판단해 주세요: lane 해제가 마지막 답과 묶였으므로 confirm_cleanup의 cleanup_worker.is_some() 거절은 이제 "검토가 아직 loading 중"일 때만 걸립니다. 그 주석을 고쳤습니다.
  2. herdr-core/src/runtime/terminal_input.rs wait_with - 셸 대기의 반복이 시계와 한 번의 읽기를 받아 돌고, 마감에 걸쳐 끝난 읽기(결과가 무엇이든)는 결과로 치지 않아 마지막으로 끝난 읽기의 결과가 남습니다. shell_reads_keys는 main과 같습니다. 결과는 terminal.input_shell_wait 진단의 outcome/reason에만 쓰이고, 키는 어느 경우든 그대로 써집니다.

다음 둘은 지시서에 제품 변경 후보로 적혔지만 테스트 fixture만 바뀝니다: #218/#213의 held link(runtime/tests/inbound.rs), #227/#319의 연결 전환(runtime/tests/links.rs).

조심해서 볼 파일:

  • runtime/tests/inbound.rs - held link의 Herdr가 link가 풀릴 때까지 connect에서 기다립니다(전에는 없는 socket이라 즉시 거절). 그 거절을 node session sync가 받아 테스트가 연결해 둔 node를 끊긴 상태로 덮었습니다. link를 쓰는 모든 테스트(inbound, hide_ai_devices)가 통과하지만, 끝까지 release를 쥔 테스트가 있으면 멈출 수 있는 구조라 봐 주세요. 이전의 10초 자동 종료(recv_timeout)는 없앴습니다.
  • runtime/tests/node_issues.rs - 확인을 검토 답의 announcement 안에서 누릅니다(ChangeNotifier::announcing). 콜백 안의 panic은 삼켜지므로 값을 모아 밖에서 assert합니다.
  • suggestions/worker.rs handled - 실행 중인 run이 없는 pen 명령의 거절 답을 barrier로 씁니다. 상태를 바꾸지 않는 명령이라 골랐습니다.
  • docs/TESTING.md - The test decides the order와 Wait for state에 규칙 네 줄을 더했습니다.
이슈별 원인과 처리 (main 8a865d8 기준)
이슈 테스트 원인 처리
#153, #148 runtime::delivery::tests::moved_terminal_keeps_…, remote_observation_without_a_local_socket_… Worker::spawn이 doorbell/watch producer를 띄워 자기 시계로 pass를 돌림. watch tick이 fixture의 옮겨진 child를 못 읽고 폴더가 없다고 보면 watch를 끝냄(watches.len() 0, watches[0] index), store가 쓰는 중에 테스트가 파일을 읽음(ledger_unavailable, 로컬 재현) #1812와 같은 규칙: 이 파일의 테스트 12개를 Worker::store로, 파일을 읽기 전에 store를 멈춤
#152 node_issues::a_node_s_merged_worktree_is_removed_… 제품: 위 1번 worker 마지막 답과 lane 해제를 한 lock에서. 테스트는 가장 이른 순간에 확인
#218 inbound::a_node_pane_s_hide_memory_reads_for_the_node_s_session node session sync의 socket_missing 답이 테스트가 넣은 session 뒤에 도착해 node를 끊김으로 바꿈(pane_not_connected, 실패 0.04초) held link의 Herdr가 link 동안 답하지 않음
#213 inbound::a_moved_core_reads_its_own_kit_… 같은 원인 + kit 작업이 대기열에 남은 채 dispatch하면 node는 checking이 되지 않음, dispatch 뒤 lock을 놓은 사이 답이 끝날 수 있음 대기열까지 비기를 기다리고, dispatch와 확인을 한 lock에서
#227, #319 links::a_native_fork_keeps_state_changes_… (#227의 새 이름이 #319) "다음 connect에 전환" arm을 fork worker 옆의 control lane(focus)이 가져가면, 전환이 fork worker의 확인 뒤에 적용되어 pane.get이 옛 서버로 감 전환을 fork worker 자신의 thread connect에서만(같은 fixture의 archive 테스트도)
#246 ssh_hosts_list::the_host_list_names_each_alias_… dispatch 뒤 lock을 놓은 사이 fake 답이 끝나 loading을 못 봄 dispatch와 확인을 한 lock에서
#126 suggestions::worker::tests::a_weak_line_waits_fourteen_quiet_days_… fixture의 barrier read가 전날의 남은 read일 수 있음. 그러면 clock이 Wake 처리 전에 움직여 run이 실제 3분 뒤로 밀리고 10초 대기가 끝남(로컬 재현) 응답 채널이 있는 명령으로 barrier(handled)
#159 memory_analysis::tests::a_linked_node_s_closed_session_… 테스트가 Memory hook의 1초 제품 예산 안에서 읽음, 부하에서 답이 비었음(로컬 37%) hook 답 대신 scope가 가리키는 Project를 직접 확인. hook 답은 memory_hook 테스트의 몫이고 뒤의 receipt 확인은 hook과 무관해 그대로
#186 terminal_input::tests::a_terminal_that_is_never_read_… 제품: 위 2번 잘린 읽기는 결과가 아님. 두 테스트(기존 것과 잘림 규칙 새 것)는 테스트가 움직이는 시계와 정해 둔 읽기로 돌아 socket과 벽시계에 기대지 않음, bound 150ms 그대로
#274 doorbell 두 테스트 재현 안 됨(fixture는 10-09부터 store만 띄움, 실패 둘 다 store의 5초 답 기한) 범위 제외, 이슈에 증거 코멘트

Evidence

Verification record

…answer

A confirmation pressed the moment a review's answer appeared was refused,
because the worker freed its lane by a second lock after the answer. The
node cleanup test now confirms from the announcement of the answer.
A read the deadline cut said nothing about the shell, yet it erased the
failure before it, so a terminal that was never readable could end the wait
as a timeout or with the cut request's own error.
The doorbell and watch producers passed on their own clocks beside the
tests' own passes and could end a watch the test then read from the file.
The cut rule moves into the wait's loop, which takes its clock and its read,
so the tests decide when each read ends against the bound instead of a real
socket and the wall clock; the 150 ms bound is back.
@yansfil
yansfil merged commit ed4d421 into main Oct 29, 2026
68 checks passed
@yansfil
yansfil deleted the fix/flaky-node-runtime-tests branch October 29, 2026 06:19
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