Skip to content

Read a project's pull requests again when an agent prints a new one - #522

Merged
yansfil merged 4 commits into
mainfrom
fix/pr-sighting-reread
Oct 5, 2026
Merged

yansfil merged 4 commits into
mainfrom
fix/pr-sighting-reread

Conversation

@yansfil

@yansfil yansfil commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Related: #390 (PR 상태와 worktree 정리), #407, #411

Summary

agent가 연 PR이 사이드바 체크아웃 행에 붙기까지 최대 5분이 걸렸습니다. 프로젝트의 GitHub 재조회가 직전 응답 5분 뒤에야 다시 돌기 때문입니다.
이제 label worker가 agent 대화 기록에서 이미 추출하던 PR 주소를 신호로 씁니다. core의 GitHub 응답에 없는 주소가 보이면, 그 PR을 소유한 프로젝트를 기존 reader의 generation bump로 곧바로 다시 읽습니다.
push 시점은 트리거로 쓰지 않았습니다. push가 gh pr create보다 먼저라서 그때 읽으면 PR이 아직 없습니다.
대화 기록은 agent 상태가 바뀔 때 읽히므로, 늦어도 그 agent의 턴이 끝날 때 반영됩니다.

화면 구성은 바뀌지 않습니다. 기존 PR 글리프가 더 일찍 붙을 뿐이고, 이 조회 동안에는 loading을 띄우지 않습니다.

Review

  • 판단해 주세요: 프로젝트는 같은 owner/name의 PR을 가진 프로젝트로 고릅니다. 그런 프로젝트가 없으면 주소를 출력한 pane의 프로젝트(다른 저장소의 PR이 없을 때만)를 씁니다. fork 체크아웃에서 upstream으로 연 PR은 다시 읽지 않습니다.
  • 판단해 주세요: 주소 하나당 추가 조회는 출력 후 15분 안에 한 번만 합니다. 200개 목록 밖의 PR이나 다른 저장소의 PR 때문에 같은 조회가 반복되지 않게 하려는 것입니다.
  • 조심해서 볼 파일: herdr-core/src/runtime/projects.rs - failure path. 응답을 아직 받지 못한 조회(5분 주기, 새로고침, request view, 앞선 sighting)가 있으면 앞질러 읽지 않습니다. 그 응답이 PR을 담고 있지 않을 때만 한 번 더 읽고, 연속 실패 중인 프로젝트는 읽지 않습니다. 앞질러 읽으면 publish_github가 진행 중이던 응답을 통째로 버립니다.
  • 조심해서 볼 파일: herdr-core/src/session_sync/coordinator.rs - runtime mutex. exchange_pull_requests는 lock 구간 하나로 sighting을 넘기고 PR 시각을 받아 옵니다. 시각은 lock 밖에서 읽고, sighting이 없으면 하는 일이 새로 생기지 않습니다.
  • 비용 검토: sighting이 있을 때만 lock 안에서 메모리 작업이 늘어납니다(주소당 맵 조회와 프로젝트 1회 스캔). 상한은 worker 대기 32개(초과 시 read.sighted_capped)와 기억 주소 64개(초과 시 read.sighted_over_limit)입니다. 소유자가 없는 주소는 자리를 차지하지 않습니다(read.sighted_unowned). docs/PERFORMANCE_TESTING.md GitHub 행을 갱신했습니다.
  • 질문: 메뉴 PR 새로고침과 request view의 check 재조회도 진행 중인 조회를 앞지를 수 있습니다(같은 응답 폐기). 이번 범위 밖이라 그대로 뒀는데, 이슈로 남길까요?

Evidence

  • 확인한 것: runtime 테스트로 다음을 확인했습니다.
    • 소유 프로젝트 매핑과 첫 PR 매핑.
    • 응답을 기다리는 조회가 있으면 앞지르지 않음(첫 조회, 새로고침, 처리 전 응답, 앞선 sighting 조회).
    • 응답 후 PR이 없을 때만 1회 조회.
    • 실패 backoff 중이면 조회하지 않음.
    • 15분이 지났거나 시계가 앞선 기록은 아무것도 일으키지 않음.
    • 64개 상한과 소유자 없는 주소 70개.
  • 확인한 것: label worker 테스트로 실제 transcript 읽기를 통한 추출, 최신 32개 유지, device worker는 sighting을 보관하지 않음을 확인했습니다.
  • 확인한 것: 핵심 테스트마다 해당 코드를 빼서 실패하는 것을 확인했습니다(mutation 확인). 대상은 앞지르기 방지, 응답 후 재조회, 신선도 정리, 시계 앞섬 상한, device 차단입니다.
  • 확인한 것: verify-cargo.sh lint 통과, nextest -p herdr-core 1428/1428 통과. 별도 리뷰 3회의 Fix-now를 모두 반영했습니다.
  • 확인하지 못한 것: worker에서 exchange_pull_requests를 거쳐 runtime까지 한 번에 지나가는 테스트는 없습니다. coordinator 테스트 fixture로는 로컬 Git 프로젝트를 만들 수 없어서, 이 연결부(약 10줄)는 코드 리뷰로만 확인했습니다.
  • 확인하지 못한 것: 실제 gh로 agent가 PR을 여는 라이브 확인은 하지 않았습니다. CI e2e도 이 경로를 지나지 않습니다.

A pull request an agent opened reached its checkout row only at the
project's next five-minute GitHub re-read. The label worker already finds
the pull request addresses a session's tools print; each one the core's
last GitHub answer does not hold is now handed to the runtime, which moves
that project's generation so the existing reader reads it on the next wake.

The project is the one whose pull requests are in that repository, else the
printing pane's project while none of its pull requests names another
repository. An address sets off one read while its sighting is under
fifteen minutes old, and at most 64 such addresses are remembered at once.
A sighting moved a project's generation even while that project's read was
in flight or its first read had not answered, so the in-flight answer no
longer matched the request, was dropped for every project, and the project
was read twice. A sighting now asks at once only for a project whose last
read worked, and its clock then waits for that answer as the stale re-read
does. A project with an unanswered ask is read once more after that answer
lands, only if the answer does not hold the pull request, and a project in
failure backoff is left to its own retry.

An address no read project owns is no longer remembered, so it cannot take
one of the 64 places a project's own first pull request needs. The worker
keeps no sightings for a device and none older than fifteen minutes, and
the freshness rule lives in one function both sides use. The project list
is built once per hand-off, and the clock is read before the lock.

Tests cover the deferral, the 64 limit and its diagnostic, an unowned
address taking no place, the worker's 32 newest, and a device worker
keeping nothing; core diagnostics can now be captured in a test. The
status model, architecture and performance ledger describe the rule, its
bounds and its diagnostics.
A sighting read a project at once whenever its clock showed a worked
answer, even while a refresh or the request view's re-read was in flight,
or an answer had landed that the clock had not taken yet; the sighted ask
then overtook it. An ask is now outstanding while the generation asked for
is not the one last answered or an answer waits for the clock, whoever
asked, and a sighting waits for that answer.

A sighting waiting for an answer that came long after it (no window, so no
read) set off a read when the answer landed. Freshness is now kept as an
instant on the re-read's clock, and the clock comparison drops what grew
old before an answer can owe it a read. An address an answer holds frees
its place, and a waiting project that is no longer read is forgotten.
A transcript written while the clock ran ahead kept its address remembered,
and its slot taken, for as long as the clock was wrong.
@yansfil
yansfil added this pull request to the merge queue Oct 5, 2026
@yansfil
yansfil merged commit f2b7af1 into main Oct 5, 2026
28 checks passed
@yansfil
yansfil deleted the fix/pr-sighting-reread branch October 5, 2026 16:47
HyunjunJeon pushed a commit to HyunjunJeon/hide that referenced this pull request Nov 9, 2026
…n test (with-hide#2132)

Related: with-hide/hide-private#516, with-hide/hide-private#522,
with-hide/hide-private#588

## Summary

에이전트 시작 e2e 하나가 시작을 네 번(픽스처 부모, 부모가 띄운 자식, spawn 시작, 친 명령 시작) 연달아 하면서
30초 한 번의 예산을 나눠 썼습니다.
부하 걸린 Windows 러너에서 패널 하나 띄우는 데 0.5-2.4초씩 걸리면 마지막 단계 전에 시간이 바닥나 가끔
실패했습니다(경쟁이 아니라 단계 수 문제).
이제 spawn 시작과 친 명령 시작을 에이전트마다 따로 된 시험으로 나누고, 둘 다 자식 없이 부모 에이전트 하나만 띄우는
픽스처(`startCaller`)에서 돌립니다. 시험 하나가 시작 두 번만 합니다.
대기 시간은 늘리지 않았고, 각 대기는 지금처럼 스냅숏의 상태(에이전트 종류, idle)를 기다립니다.

스크린샷 없음: 화면을 바꾸지 않는 e2e 시험과 픽스처 변경입니다.

## Review

- **판단해 주세요**: 시험이 11개에서 22개(Windows npm 8개 포함)가 되어 스택 시작이 늘어납니다. 대신 시험
하나의 시작 수가 4에서 2로 줄어 한 경로의 흔들림이 다른 경로를 가리지 않습니다(docs/TESTING.md, Keep the
size of a test bounded).
- **조심해서 볼 파일**: `web/e2e/engine-fixture.ts` - family/agents 픽스처의 첫 에이전트
시작과 휴식 대기를 함수로 뺐습니다. 기존 픽스처의 동작은 그대로여야 합니다.
- **조심해서 볼 파일**: `web/e2e/agent-start-platform.spec.ts` - Windows npm 시험
4개도 같은 방식으로 spawn/친 명령 두 시험씩(8개)으로 나눴습니다. 이 8개는 20회 반복 run에 들어가지 않았습니다.

## Evidence

- **확인한 것**: 실패한 시도의 hided 로그(CI 아티팩트): with-hide#522 둘째(run 42089610679)는 친 명령
탭이 시도 21.7초째에 요청되고 그 홀더가 2.4초 걸림, 통과한 재시도는 9.3초째. with-hide#516(run 41820931121)은
마지막 단계(친 omp의 idle 대기)에서 30초.
- **확인한 것**: 바뀐 e2e 파일 tsc 타입 검사, eslint, e2e 크기 검사 통과.
- **확인한 것**: 시작 시험 14개를 시험마다 20회, 재시도 없이(임시 커밋 e6c7a0d, 그 뒤 되돌림):
https://github.com/with-hide/hide/actions/runs/42118688419
  - Linux 280/280 통과.
- Windows 278/280: grok 친 명령, pi spawn이 연달아 한 번씩 30초 초과. 그 2분 동안 러너 전체가
느렸음(탭 생성 5초, 패널 닫기 4.7초, 직전 시험 22초, 실패 뒤 PowerShell 호출도 ETIMEDOUT). 둘 다
픽스처 부모가 뜨는 중이었음.
  - 그 샤드만 한 번 다시 돌림(attempt 2): 두 시험 20회씩 40/40 통과.
- **확인하지 못한 것**: 이 Mac에서 Playwright는 아직 돌리지 않았습니다(릴리스 저니 진행 중, macOS
20회는 그 뒤).
- **확인하지 못한 것**: 러너가 통째로 멈추는 동안의 실패는 시험 쪽에서 막을 수 없습니다. 홀더 시작이 부하에서 느린
문제는 with-hide/hide-private#614로 따로 엽니다.

<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