Repository navigation
refactor: let letter delivery read the turn the row is drawn from - #1954
Merged
Merged
Conversation
A pass observes Herdr's list under the lock and lays the hook's and the session read's facts after it, so a turn an earlier pass laid stood for a question read while Herdr's state stayed the same. Each observation now carries its pass's number and only that pass's laid turn is read; between the two steps a letter holds as turn_unprojected. The bell's episode is the core's turn and when it last moved instead of Herdr's status, so a turn the hook alone runs takes the next letter once the last is taken, and a letter skipped within a turn is held as announced.
The observation hands back its pass's token, and only the ingest that carries it, with the payload and label overlay that pass observed, lays turns; any other ingest, such as an editor's close status read with the overlay the runtime held before, certifies nothing.
yansfil
added a commit
that referenced
this pull request
Nov 1, 2026
…w status (#1967) ## Summary Hide checks a brief or letter it typed against the agent's own record. If the agent never records it, Hide tells the parent and types it again once someone answers the screen. That check decided "the agent is working" from Herdr's raw status. The row, the doorbell and sleep all read the core's one turn instead (hook first, then session file, then Herdr, #1954). When the two disagreed, the typed-input decision disagreed with the row: - **hook says working, Herdr says idle**: the parent got a false "has not confirmed" notice, and once the screen was answered the brief could be typed into a working agent a second time. - **hook says the turn ended, Herdr still says working**: the record wait never started, so the notice and the retype never came. Now the confirmation, the composer read before a retype, and omp's "a turn after the typing is its record" all read the same projected turn. The composer read goes through the same gate a bell is typed through, now shared with the doorbell (`doorbell::unheld_turn`, `doorbell::takes_keys`). One more rule for the same decision: a brief also counts as taken when the agent's own hook reports a turn that started after the typing, and no other input or bell could have started it. It is confirmed `by: turn`, as omp's already is: the parent is not told, the row asks nothing, and it is never typed again, even if the prompt digest never matches. Today a long brief to Claude Code reads unconfirmed though it was taken (its digest is being fixed separately), and nothing may type a brief twice (principle 11). ## Review - **Judgement call**: when the core has no turn for the pane (a stale read, or the moment between a pass's observation and the turn it lays), nothing moves, and the row and `hide agent show` keep the last verdict for that typing (`plans.input_verdicts`). A state ends this, never a timer: the next agent list (asked every second) lays a fresh turn; a stale read ends with the list that confirms the agents again, and until then the row also shows activity unknown; a pane Herdr no longer lists drops its input. Without this, the doorbell's 250 ms pass falls into that moment on every session pass. It would drop the asked reread (so the verdict starts over) and make the row's ask blink. A stale read used to drop the row's ask; it now keeps it. - **Behavior change for tool-letter agents** (OpenCode, Pi, omp, Antigravity, Grok): when their hook says idle and Herdr still says working, they are now judged at rest, so after the record wait the parent gets the "has not confirmed" notice. Hide still does not retype or read the composer while Herdr reads them working (`takes_keys`, the same rule the bell follows). - **Judgement call**: the turn rule counts only a turn the hook reports (`TurnProjection::reported`), never Herdr's reading alone. It misses a turn shorter than one pass, input during the turn, a core restart (the latch is memory until the store confirms), and agents whose hook reports no turn. Those keep the record-only rule. - **Files to watch**: - `herdr-core/src/delivery/doorbell.rs`: `judge` is split into two helpers with the same holds in the same order; the bell's behavior must not change. - `herdr-core/src/delivery/typed.rs`: `composer_readable` is now the doorbell's gate, so for a kind without tool letters, a turn at rest that Herdr still reads as `working` gets its composer read. The off-lock `readiness.accepts_input()` check still holds before any key is sent. - **Cost**: no new work per input. Each doorbell pass rebuilds `plans.input_verdicts`, one entry per unconfirmed input (bounded by open inputs), under the lock it already holds, with no I/O. - **Left on purpose**: `delivery/watch.rs` reads Herdr status changes as an inactivity clock for quiet-child warnings, and `worker.rs` `same_target` compares samples. Neither decides whether the agent works now, so neither is changed. ## Evidence - **Checked**: two runtime tests cross the hook and Herdr and assert what the doorbell receives (`typed_input_work` notice and retype, `input_asks` row). Both fail against the old raw-status read and pass now. - **Checked**: `a_stale_read_keeps_the_briefs_verdict_until_a_fresh_turn_is_laid` drives `telemetry_stale` through Unsettled and back: across a 10-minute stale read the row's ask and `agent show`'s `unconfirmed` stay, nothing is sent, and the reread is not asked again. A fresh turn continues the verdict, an unlaid pass holds it the same way, and the pane leaving drops it. It fails when a stale read falls back to Waiting, as before this PR. - **Checked**: `a_brief_whose_hook_reports_a_turn_after_the_typing_is_confirmed_by_that_turn`: during the turn and after it ends (record still unmatched, screen answered), the doorbell gets only `recorded: turn`, with no notice, reread or resubmit; the row has no ask and `agent show` lists no pending brief. - **Checked**: `a_turn_herdr_alone_reads_or_other_input_started_is_no_record_of_the_brief`: Herdr-only working, a key after the typing, and a letter bell after the typing each still end in the parent's notice. - **Checked**: omp's turn record now follows the core's turn (an omp hook turn while Herdr reads idle confirms the brief). The existing typed, doorbell and turn_authority tests pass unchanged except fixtures that now lay a turn. - **Checked locally**: full `herdr-core` nextest, clippy `-p herdr-core --all-targets`, `cargo fmt`, `check-engine-boundary.py`, `check-core-touches-no-machine.py`, `check-capability-readers-off-lock.sh`. - **Not checked**: no live run with a real agent at a hooks-review or trust screen. The change is a pure decision over facts the core already holds, so it was proven at the runtime layer. Linux and Windows run on PR CI only. <details><summary>Verification record</summary> </details>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
화면의 상태(멈춤/작업 중/승인 대기)와 편지 초인종이 같은 사실을 따로 계산해서, 둘이 어긋나면 화면은 멈췄다고 하는데 편지는 "작업 중"으로 붙잡히는 일이 생겼습니다.
이제 에이전트의 차례(작업 중인지, 승인 프롬프트가 떠 있는지, 에이전트 자신의 질문·계획 승인이 기다리는지)는
agent_state::turn_projection한 곳이 정하고, 화면 행·초인종·도구 편지 전달이 모두 그 답을 읽습니다.입력해도 되는지(Herdr의 blocked 프롬프트와 준비 상태, 초안·조용한 시간, 컴포저 읽기)는 차례와 따로 남은 별도 관문입니다. "멈춤으로 보임"을 "입력해도 됨"으로 읽지 않습니다.
화면 변경 없음 (core와 문서만).
어긋남과 고른 답:
blocked로 보류 → 계속 보류하되not_ready(Herdr가 거기서agent.prompt를 거부함)로 이름 붙임.awaiting_operator→ 차례를 따름.리뷰에서 나온 두 가지도 고쳤습니다.
--now·--force포함)turn_unprojected로 기다립니다.announced로 이름이 남습니다.Review
herdr-core/src/delivery/doorbell.rsjudge- 보류 순서와 관문 분리(failure path).herdr-core/src/runtime/delivery.rsobserve_delivery·lay_delivery_turns·projected_turn- 관측이ObservedPass토큰을 돌려주고, 그 토큰을 든 깔기만 같은 번호의 관측을 인증.herdr-core/src/runtime/session.rsingest_observed_session- 토큰·overlay·payload를 한 번에 받는 유일한 local 깔기 경로, 나머지 ingest(ingest_session*, 에디터 닫기 상태)는 깔지 않음.herdr-core/src/session_sync/coordinator.rs- 기기 패인은 coordinator가 훅·세션 사실을 깐 뒤 다시 잡은 잠금에서 깜.herdr-core/src/delivery/doorbell.rsEpisode- 다시 울릴지의 기준이 Herdr 상태 대신 코어 차례와 그 변경 시각.hided/tests/it/remote_delivery.rs여정은 Claude Code의 프롬프트 훅만 돌리고 턴을 끝내는 Stop 훅은 돌리지 않아, 훅 기준으로 턴이 영원히 working이었습니다(어긋남 2의 규칙대로 재연결 편지가 5분 대기). 실제 에이전트처럼 각 턴 뒤에 Stop 훅을 돌리게 했습니다. Claude Code의 Stop 훅은 편지를 가져가지 않으므로 여정이 확인하는 전달 경로는 그대로입니다.turn_projection한 번(메모리만, 행 projection이 이미 하는 계산)과 관측 맵 갱신. I/O·알림·새 타이머 없음, 런타임 잠금 안의 일은 기존 ingest 안의 메모리 작업뿐.turn_unprojected가 영구 보류가 되지 않는 이유: 관측과 깔기는 같은 sync pass에서 이어지며 그 사이 출구는 죽은 런타임(로컬)이나 교체된 기기 coordinator(후임이 다시 관측하고 깜)뿐. 길어질 수 있는 유일한 경우는 이 기기의 패인 이동 중이며, 그동안 화면도 이동 전 패인을 그리고 이동의 publication barrier가 풀리면 끝남.Evidence
a_question_read_under_an_unchanged_herdr_state_never_rings_on_the_last_turn: 같은 Herdr 순번에서 관측과 ingest 사이를 멈추고, 보통·--now·--force편지 모두turn_unprojected. 그 틈에 이전 overlay로 같은 payload를 다른 ingest가 먹어도 그대로turn_unprojected, 그 pass의 ingest가 커밋한 뒤에야 행은 question이고 편지는awaiting_operator. 깔기를 소비 시점 번호로 찍던 이전 방식으로 되돌리면Ok(())(입력됨)로 실패함을 확인.a_turn_the_hook_alone_moves_decides_the_next_bell_while_herdr_stays_idle:Doorbell::pass로 Herdr idle·순번 2 고정, 같은 턴announced, 훅만의 턴 시작·끝 뒤 울림, 훅 턴 중 앞 편지 수신 뒤 다음 편지 울림. 옛 상태 기준 Episode로 되돌리면 실패함을 확인.runtime::tests::turn_authority10개 - 훅·Herdr·세션 읽기를 교차시켜 실제 경로(훅 보고 → 관측 → 세션 ingest)로 행의 activity/demand/blocked와 초인종 보류 이름을 함께 단언(어긋남 1~4, 무훅 blocked, 훅 승인 대기, 비동기 질문, 초안·조용한 시간·Grok working 관문, 다음 상태가 같은 pass ingest에서 깔림).scripts/verify-cargo.sh nextest -p herdr-core3726개 통과,nextest -p hided전달 관련 11개 통과,clippy -p herdr-core -p hided --all-targets -D warnings통과,cargo fmt.agent_sleep.rs); 끝내기 직전agent.get재확인은 native fence로 유지. typed-input·unreadable 보류는 그대로.remote_delivery·held_letter_notice5개(--run-ignored only, 고정 Herdr 0.9.5, 격리 픽스처)를 로컬 macOS에서 통과 - 기기 패인 초인종이 coordinator가 깐 차례로 울림. Stop 훅 추가 전에는 재연결 편지가working으로 보류되어 실패함을 확인.Verification record