Skip to content

Close a request's answer wait when a party ends or after 24 hours - #791

Merged
yansfil merged 5 commits into
mainfrom
gen-prd/request-answer-wait-ends
Oct 8, 2026
Merged

yansfil merged 5 commits into
mainfrom
gen-prd/request-answer-wait-ends

Conversation

@yansfil

@yansfil yansfil commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Closes #764
Related: PRD agents/prd/request-answer-wait-ends/prd.md · 이어서 #755 (같은 delivery/worker.rs를 건드려 이 PR 뒤에 시작)

Summary

  • 답이 오지 않은 request/block 편지가 답이나 취소가 올 때까지 열린 채 남아, 열린 편지가 1024개에 닿으면 모든 hide request send가 capacity로 거절됐습니다.
  • 보낸 쪽이나 받는 쪽 등록이 끝나면(hide agent end, pane 사라짐) 받아 간 편지의 답 기다리기가 그 전이에서 같이 끝납니다.
  • 보낸 지 24시간이 지난 답 기다리기는 store worker의 기존 유지 보수 처리에서 닫힙니다. 새 thread와 timer는 없습니다.
  • 닫힌 편지는 상태 값을 그대로 두고 waiting_answer: false, finished_at, 새 필드 answer_wait_ended(party_ended 또는 deadline)를 남기며 hide request show로 보입니다.
  • 한도 1024와 5000, hide inbox, 화면은 바뀌지 않습니다. ledger 버전 1과 새 State 값 없음을 지켜 옛 build도 파일을 읽습니다.

Review

  • 판단해 주세요: 아직 받아 가지 않은(Pending) 편지는 등록이 끝나도 닫지 않고 기존 60분 undelivered 기한에 맡겼습니다. PRD B1의 "받아 간" 문구를 따른 해석입니다.
  • 조심해서 볼 파일: herdr-core/src/coordination/mod.rs - end_record가 pane+device+session 일치로 actor를 고르고 이미 끝난 등록의 반복 end는 건드리지 않음 (live 가드). 틀리면 살아 있는 대기가 닫힘.
  • 조심해서 볼 파일: herdr-core/src/delivery/{ledger,worker}.rs - 기한 판정 now - created >= 24h, 유지 보수 idle 조건에 answer_overdue 추가, 진단은 저장 성공 뒤에만 한 줄씩(본문 없음).
  • 비용 검토: 입력당 추가 일은 등록 종료 때 편지 목록 한 번 훑기뿐이고, 기한 판정은 기존 유지 보수 처리 안입니다. 알림 fan-out 변화 없음. 업데이트 직후 24시간 넘은 대기가 한 번에 닫히며 진단이 그만큼 남습니다.
  • 질문: 받아 간 뒤 이미 끝난 쪽의 request는 최대 24시간 대기로 남습니다(아래 Follow-up). 이 PR에서 막을지 후속으로 둘지 정해 주세요.

Evidence

  • 확인한 것: 단위 테스트 - 두 종료 경로, 기한 경계(23시간 59분 열림, 24시간 닫힘), 이미 답/취소/undelivered 불변, 이중 닫힘 없음, 이유 필드, 필드 없는 옛 ledger 로딩과 50시간 대기 첫 유지 보수 닫힘, 1024 가득 찬 mailbox가 닫힌 뒤 send 재수락.
  • 확인한 것: 실제 hided + 핀된 Herdr 0.9.3 위 통합 테스트(ignored 2개) - 받는 쪽이 hide agent end하면 보낸 쪽 hide request show가 waiting_answer:false, party_ended, 상태 delivered를 보이고 로그에 이유만 있고 본문은 없음.
  • 확인한 것: nextest --profile ci --workspace 3320개 통과, lint와 fmt 통과, 심은 결함(유지 보수 조건 제거, live 가드 제거) 두 가지가 테스트를 실패시킴. sasu implement verify PASS (S1 test, S2 lint).
  • 확인하지 못한 것: B9(watch 경고의 open requests 수)와 B8(화면에 아무것도 안 뜸)은 전용 테스트가 없고 코드 구조(watch.rs가 waiting_answer를 셈)로만 성립합니다.
  • 확인하지 못한 것: operator의 ledger와 앱은 건드리지 않았습니다. 업데이트 뒤 실제 ledger 효과는 설치 후 읽기로만 확인할 수 있습니다.
  • 확인하지 못한 것: 이 머신의 부하로 로컬 verify가 서로 다른 무관한 시간 의존 테스트에서 여러 번 실패했고(단독 실행은 통과), origin/main을 합친 뒤 헤드에서 PASS했습니다. CI가 최종 증거입니다.

Review notes (advisory)

  • Fidelity와 Code 리뷰는 683892179에서 PASS (노트 있음), Fidelity+Code+Security는 550ced2fa까지 PASS (Fix now 없음). 이후 변경은 origin/main merge뿐입니다.
  • 반영한 지적: 반복 end가 새 등록의 대기를 닫지 않게 live 가드, Pending 편지 제외, actor 매칭 표 테스트, 보관 기간 문서 보강.
  • Follow-up: 이미 끝난 쪽의 request가 받아 간 뒤에도 최대 24시간 대기(record_intake가 등록을 보지 않음). 늦은 reply/cancel 뒤에도 answer_wait_ended가 남아 show에 "답 없이 닫힘"으로 보임. 둘 다 24시간 상한 안이라 이 PR 밖으로 둡니다.
  • 기존 문제: resolve_actor가 parent를 id 또는 name/pane으로 맞춤. 이 변경과 별개라 따로 이슈로 둡니다.
Verification record
  • PRD: agents/prd/request-answer-wait-ends/prd.md (sha256 711af4228dd6a5c608077d339c8bf5290707f7b31d10bc374750fc29e51b83d0)
  • Base 0a257a8 → head 5fa8397, verified 2026-10-08T08:29:20.926Z: PASS
  • Verification report: agents/runs/request-answer-wait-ends/verification-report.json and agents/runs/request-answer-wait-ends/verification-report.md; source fingerprint 22130f4d05a8e0615987bcca155e53014dab58bbd72aa3e82414a1d0873cc5d6
  • Suites:
    • S1: GREEN bash scripts/verify-cargo.sh test (exit 0)
    • S2: GREEN bash scripts/verify-cargo.sh lint (exit 0)
  • Reviews: Fidelity PASS with notes and Code PASS with notes on 6838921; Fidelity, Code and Security PASS with notes on 6838921; follow-up review on 550ced2 found no Fix now items. Head 5fa8397 adds only the merge of main after that review.
  • Evidence: none registered separately.
  • Changed paths: 10 (see Files changed)
  • Delivery: mode pr, branch gen-prd/request-answer-wait-ends, base main

A request or block letter waited for its answer until the recipient replied
or the sender cancelled, so letters nobody answers filled the 1024 open-letter
cap and every new send was refused with capacity.

The wait now ends when the sender's or the recipient's registration ends, in
the same transition that ends its watches, or 24 hours after the letter was
sent, judged in the store's existing maintenance pass. The letter keeps its
state, waiting_answer turns false, finished_at is set, and a new optional
answer_wait_ended field (party_ended or deadline) tells the sender why through
hide request show. The ledger stays at version 1 and an older ledger loads
unchanged. Each closed wait logs one structured answer_wait.ended diagnostic
without the body. The open and retained limits, hide inbox and the screen are
unchanged. The CLI contract and docs/delivery.md follow the new field.
…ided

The external delivery lane registers the local recipient, has a remote pane send it a request the recipient takes in, ends the recipient's registration, and reads from the sender's pane through hide request show that the wait ended as party_ended with the state unchanged. The core log carries one answer_wait.ended line with the reason and no body.
…end rule

A registration ending now ends the answer wait only of letters the recipient took in, so a request still awaiting intake follows its 60-minute delivery deadline as before. Repeating hide agent end on a registration that already ended no longer ends the waits of the live registration that took the same pane and session. Tests pin the exact pane, device and session match, and the guide states the retention of finished waits.
@yansfil
yansfil merged commit 044d016 into main Oct 8, 2026
20 checks passed
@yansfil
yansfil deleted the gen-prd/request-answer-wait-ends branch October 8, 2026 08:50
yansfil added a commit that referenced this pull request Oct 8, 2026
…that cannot deliver (#793)

Closes #755
Related: PRD `agents/prd/held-letter-notice-channels/prd.md` · 앞선 #791
(같은 `delivery/worker.rs`)

## Summary

- 60분 안에 받는 agent에게 들어가지 못한 편지의 운영자 알림이 휴대폰 push와 Herdr 둘 다 닿지 않았는데,
로그에는 `human.channels_failed`와 편지 id만 남아 이유를 알 수 없었습니다.
- 휴대폰 push는 보내기 전에 닿을 수 있는지 판정합니다. 닿을 수 없으면 시도하지 않고 이유(`no_vapid`,
`mode_off`, `app_open`, `mobile_off`, `no_subscription`)를 적습니다.
- Herdr 알림은 이 Mac에 socket이 없을 때만 건너뜁니다(`no_socket`). 나머지는 시도하고, 답의
이유(`disabled`, `rate_limited`, `no_foreground_client`, `busy`)나 호출 오류를
적습니다.
- 어느 경로로도 닿지 않으면 로그 한 줄에 알림 종류, 편지 id, 경로별 이유가 남습니다. 편지 내용, endpoint, 키는
남지 않습니다.
- 새 알림 경로, claim 규칙, 60분 기준, push 다음 Herdr 순서, ledger, 계약, 화면은 그대로입니다.

## Review

- **판단해 주세요**: push 모드와 Mobile 스위치가 둘 다 꺼져 있을 때 이유는 먼저 맞는 `mode_off`로
적습니다(운영자가 알림을 받으려면 바꾸는 설정이 모드이기 때문). 순서가 맞는지 봐 주세요.
- **조심해서 볼 파일**: `hided/src/mobile/push.rs` `notice_route` - 틀리면 닿을 수 있던
push를 건너뜀. `mode_allows`를 그대로 쓰고 조건마다 단위 테스트가 있음.
- **조심해서 볼 파일**: `hided/src/mobile/mod.rs` - 경로 판정은 Mobile mutex 안에서만 하고
`Mutex<Runtime>` 아래에서는 하지 않음. 휴대폰 최대 4대로 보내는 것은 그대로.
- **조심해서 볼 파일**: `herdr-core/src/delivery/worker.rs` `notify_herdr` - 이제
`Result<(), 이유>`를 돌려줌.
- **비용 검토**: 상시 작업 변화 없음. 알림 한 번당 판정이 한 번 늘 뿐이고, 새 thread/timer/호출은
없습니다.

## Evidence

- **확인한 것**: 경로 판정 단위 테스트 - 조건별과 경계(`app_closed`에서 앱 창 0개/1개), 여러 원인이 겹칠
때의 순서, Herdr 답 이유 매핑(FakeHerdr).
- **확인한 것**: 실제 hided를 자식 프로세스로 띄우는 통합 테스트
`hided/tests/it/held_letter_notice` (진단 sink가 프로세스당 하나라서, 한 binary 안의 다른
daemon이 로그를 가로채지 않게 함) - 시드한 ledger의 배달되지 않은 편지로 (1) Herdr socket 없음: 두
경로 이유가 로그에 남음, (2) 닿는 휴대폰: loopback 가짜 push 서비스에 201 뒤 500을 주고 편지가 처리된
것을 확인한 뒤 실패 로그가 없음(B9), (3) 고정 Herdr 0.9.3 위 ignored 테스트:
`push=mode_off`와 Herdr 이유가 로그에 남음. 심은 결함(mode와 mobile 검사 순서 뒤바꿈, mobile
검사 반전)이 테스트를 실패시킴.
- **확인한 것**: `sasu implement verify`는 main을 합치기 전 헤드 19a3a23에서 PASS (S1
test, S2 lint). 마지막 헤드는 아래 '확인하지 못한 것' 참고. `real_herdr`의 pinned-Herdr
도우미를 `tests/it/support/private_herdr.rs`로 옮겼고(순수 이동) 기존 테스트도 통과.
- **확인하지 못한 것**: operator의 휴대폰, 앱, Herdr, ledger는 건드리지 않아 실제 push 도착은 보지
못했습니다. 격리된 daemon과 비공개 Herdr만 썼습니다.
- **확인하지 못한 것**: 마지막 헤드(`d96282169`)의 `sasu implement verify`는 PASS하지
못했습니다. 이 변경 밖의 `hide-platform`
`process::repeated_guarded_work_releases_children_and_capture_resources`(descendants
4 != 5)가, main이 crate별 `tests/it` 한 binary로 합쳐진 뒤 `cargo test` 전체에서만
실패했습니다. 단독 실행과, main(3766d99)에서 `scripts/verify-cargo.sh test -p
hide-platform --test it`를 두 번 돌린 결과도 통과했으므로 부하나 순서에 따라 달라지는 실패로 보입니다. 이
PR의 diff에 hide-platform은 없습니다. main 합친 뒤 변경(875ed8a, d962821)은 집중 테스트만
했고 재리뷰는 하지 않았습니다. CI가 증거입니다.
- **확인하지 못한 것**: 이 머신 부하로 로컬 verify가 `letter_origin`(첫 exec 데드라인) 시간 의존
테스트에서 한 번 실패했고 단독 실행과 재실행은 통과했습니다. 마지막 커밋(테스트만 변경)은 재검토 없이 재검증만 했습니다.
CI가 최종 증거입니다.

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

- PRD: `agents/prd/held-letter-notice-channels/prd.md` (sha256
6b64ba9b28bc7f7aaeaf40194269d5d5bd19751a83153330266b2f950dc1b7c6)
- Last verified head 19a3a23 (base 044d016), 2026-10-08T09:59:08.933Z:
PASS. Pushed head d962821 (main merged, test moved to the `it` binary,
daemon as child process): verify FAIL on an unrelated hide-platform
test, see Evidence
- Verification report:
`agents/runs/held-letter-notice-channels/verification-report.json` and
`agents/runs/held-letter-notice-channels/verification-report.md`; source
fingerprint
7aaf71af1522cb2df6d5695589c1955db295e82ecea8d6f936dfbc34fabbede9
- Suites:
  - S1: GREEN `bash scripts/verify-cargo.sh test` (exit 0)
  - S2: GREEN `bash scripts/verify-cargo.sh lint` (exit 0)
- Reviews: Fidelity on d5701be and 83167bf: B1-B11 and D-01..D-11 all
covered, no gaps. Code on d5701be: nothing blocking, stale
`scripts/ci-plan.py` comment fixed. Code on 83167bf: one test defect
(the reachable-phone test read the log before the daemon could write
it), fixed in 19a3a23 which was re-verified only. Follow-up
improvements: none.
- Evidence: none registered separately.
- Changed paths: 12 (see Files changed)
- Delivery: mode pr, branch `gen-prd/held-letter-notice-channels`, base
`main`

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

Requests awaiting a reply stay open forever and fill the 1024 open-letter cap

1 participant