Skip to content

feat: let pull request facts and flow changes settle stale session record states - #1565

Merged
yansfil merged 10 commits into
mainfrom
gen-prd/session-record-fact-status
Oct 22, 2026
Merged

yansfil merged 10 commits into
mainfrom
gen-prd/session-record-fact-status

Conversation

@yansfil

@yansfil yansfil commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Related: #1548

Summary

After #1548 the session record still showed what the agent last said, even when Hide already knew better: a flow whose pull request had merged still read "CI 기다림", a flow the operator moved on from still read as a question, and a past flow's questions stayed in 나를 기다리는 것.
Now Hide's own facts win where they are newer:

  • a flow whose pull requests all merged or closed after its last line reads 머지됨 #n / 닫힘 with the time, and the top state does the same for its own flow (a question, block or limit stays);
  • a flow the operator moved on from shows the one line the label gave as it closed (context_label.v21, closed_result), else 넘어감 with its last line;
  • moving to the next flow answers the questions before it;
  • the record is named after the flow the operator asked most in, while the pane keeps the current flow's name.

Before (left) and after (right), gallery SessionWork facts case: the first flow reads 머지됨 #1541 instead of a wait, the second 넘어감, the third shows its closing line, and the top state reads merged.

Session record before-light, gallery facts case
Session record after-light, gallery facts case

Review

  • 판단해 주세요: the closing line is an AI line; it replaces the flow's last turn line even when that turn ended 끝 (eval: 3 of the 18 wrong items in this PR's view are closing lines). Keep it, or show it only for flows that ended on a question or wait?
  • 판단해 주세요: the record title is now the largest flow's name everywhere record.title is read (record header, backlog origin, search), while the sidebar keeps the current flow's.
  • 조심해서 볼 파일: herdr-core/src/links/ledger_store.rs (settle, place_flows, the ask repeat check) - the record read runs on the link worker, not under the runtime mutex; the outputs query adds one indexed prs lookup per output row.
  • 조심해서 볼 파일: herdr-core/src/links/store.rs - link store schema 7 -> 8 (ledger_chapters.closed_result); an older build refuses the newer file, as with 7.
  • 조심해서 볼 파일: herdr-core/src/labels/context_label.rs - label contract v21: closed_result required in both schemas, kept only on replace, a control character drops the line alone.

Evidence

  • 확인한 것: same 21 real sessions as feat: show the session record as goal flows #1548, each scored by fresh independent scorers with the three views (old record, feat: show the session record as goal flows #1548, this PR) unlabeled in one pass, 7 scorers, rubric unchanged:

    누락 틀림 읽기 편함 경계 맞음/틀림
    옛 기록 78 40 2.19 -
    feat: show the session record as goal flows #1548 42 25 3.62 32/16
    이 PR 39 18 3.86 34/14
    • Targets: 틀림 <= 20 met; 운영자 요청 누락 0 met; 경계와 읽기 편함 not worse met.
    • 누락 <= 35 missed (39). 옛 기록보다 틀린 세션 0 missed (3): flow boundaries, one translated product name, and backlog lines outside the record; none comes from the result, status or ask rules here.
    • A first turn of a new flow re-listed a past flow's question word for word in 4 of 56 cases; none was scored wrong.
  • 확인한 것: cargo test -p herdr-core links and labels suites (new tests for settled flows, the top state's own-flow scope including a child's PR and a turn spanning two flows, closing lines, moved-on, asks closed by the next flow and kept dismissed, the title); SessionRecord.test.tsx 25 tests; tsc; node scripts/check-design-contract.mjs; CI rust workspace green on the final head.

  • 확인하지 못한 것:

    • The record e2e (session-work-ledger.spec.ts) was not run locally (its fixture setup stalled on this machine); it passes in CI on Linux, macOS and Windows. Its fixture now merges the pull requests 3 s after creation and waits for the stored merge times, so the merged result no longer races the flow's line.
    • Local sasu implement verify did not pass for machine reasons, so CI stands in: the test suite hit the 600 s cap at load average ~29, then one run failed hide-session usage_opencode_refuses_oversized_identifiers_before_materializing_them (a crate this PR does not touch; it passed 5 of 5 alone and passes in CI). Lint passed every time.
    • No native app check; nothing installed.
    • A continuation turn with no new request keeps the ledger's first judgment, so a status can stay stale until the next request; this is outside the contract and is a follow-up.
추가 증거

Dark theme, same case:

Session record before-dark, gallery facts case
Session record after-dark, gallery facts case

Review rounds: Fidelity (B2 scope, B6 guard) and Code review (e2e expectation, v20 references, dismissed-ask test, child rows, indexed lookup, closing-line refusal, Japanese wording) fixed in 1acbad8; follow-up review found no fix-now defects, and its follow-ups (turn placement, count-free example) are fixed in 4cae0a8 and aab9e6e.

Breaking change

  • Link store schema 8: a Hide build from before this PR refuses the link store this one writes, so going back needs the matching state folder.
  • Label contract context_label.v21: answers from v20 are not read as v21.
Verification record

A flow's result and the record's top state now follow what happened after
the label's line: merged or closed pull requests read as merged or closed,
a question or wait the operator moved on from reads as moved on, the label
that opens a new flow says how the last one ended (context_label.v21,
ledger v8 closed_result), questions of past flows stop waiting, and the
record is named after its largest flow.
The top state now reads only the pull requests printed in the flow its turn belongs to, so a past flow's pull request neither settles nor holds it. A child row reads merged or closed the same way. The ledger no longer refuses a past flow's ask by its words; the label is told, and the record counts asks from the current flow's start. A closing line with a control character is dropped alone. The e2e expectation and fixtures follow the v21 label contract.
The label is told that the operator moved on, so the line a replace gives for the flow it closes names what that flow made or decided by its latest events, never an approval or answer it waits for.
The e2e emulates a version 2 store by dropping every later table and column; it kept version 8's ledger_chapters.closed_result, so the migration's ADD COLUMN met a duplicate and the store never opened.
… e2e

The first flow's pull requests merge within 200 ms of its line, so whether Hide's merged fact or the line stands depends on the runner's timing; the Windows lane read the line. The store tests prove which result wins.
The fixture's pull requests merged within 200 ms of the first flow's line, so whether the merged fact or the line stood depended on the runner. They now merge 3 s after creation, past the line the transcript ends on, and the spec waits for the link store to hold both merge times before it expects the merged result, the one value it asserts.
@yansfil
yansfil merged commit c952950 into main Oct 22, 2026
49 checks passed
@yansfil
yansfil deleted the gen-prd/session-record-fact-status branch October 22, 2026 19:05
yansfil added a commit that referenced this pull request Oct 22, 2026
## Summary

에이전트가 자기 일의 계획을 `hide plan`으로 올리면, Hide가 그 단계를 pane 옆 지도로 그리고 매 프롬프트에 지금
단계를 알려 줍니다.
`--ask`로 올린 계획은 운영자의 검토를 기다리는 질문이 되어 pane 띠, 사이드바 둘째 줄, 벨, 폰에 같은 길로
뜨고(core는 문구 없이 `ask_subject` `{cause: plan_review, steps}`만 보내고 각 화면이 자기
언어로 씁니다), 에이전트가 `hide plan approve`할 때까지 파일 쓰기와 `git commit`/`git push`가
막힙니다.
pane 머리의 옛 작업 칩 자리에 계획 칩(`n/m`, 검토 중이면 `Review`)이 생기고, 팝오버는 작은 지도, `크게
›`는 보기 칸의 큰 지도입니다.
계획은 세션 기록과 같은 저장소에 남아 재시작 뒤에도 읽히고, 세션이 지워지면 함께 지워집니다.

![English UI: chip Review, band and sidebar say Plan review · 5
steps](https://github.com/yansfil/pr-assets/blob/main/hide/gen-prd-hide-plan/e6e898d/plan-review-window.png?raw=true)
검토로 올린 계획(영어 UI): 칩 `Review`, pane 띠와 사이드바 둘째 줄이 `Plan review · 5
steps`로 묻습니다. 한국어 UI에서는 `계획 검토 · 5단계`입니다.

## Review

- **판단해 주세요**: B20의 "같은 자리에서 끈다"를 Settings › Agents의 에이전트 스위치로 읽었습니다. 스킬
줄은 읽기 전용이고 스킬마다 끄는 스위치는 없습니다(kit에 그 상태가 없음). 스킬별 스위치가 필요하면 후속으로 나눕니다.
- **판단해 주세요**: 재계획에서 빠진 `done` 단계는 `done`인 채 "바뀜"으로 남깁니다(빠진 나머지는
`dropped`). `n/m`이 뒤로 가지 않게 하려는 선택입니다.
- **판단해 주세요**: 새 토큰 `--size-plan-node-compact: 144`(팝오버 작은 지도의 카드 폭).
- **조심해서 볼 파일**: `herdr-core/src/runtime/plans.rs` - runtime mutex 안의 일.
`refresh_plan_reviews`가 snapshot 경로에서 계획 책이 바뀐 때만 보이는 행에 검토 질문을 다시 얹고,
얹었던 것만 걷어 냅니다.
- **조심해서 볼 파일**: `herdr-core/src/agent_state/turn.rs`, `header.rs`,
`tally.rs` - snapshot wire. 행의 `ask_subject`가 `state.line.subject`,
`state.ask.subject`, 띠 `subject`, 벨과 폰 알림의 `subject`로 그대로
갑니다(`ask_subject_cause`를 `snapshot-wire-enums.json`에 등록). 이 행은 `detail`이
비고 상태 단어만 남습니다.
- **조심해서 볼 파일**: `web/public/m/sw.js`, `web/src/mobile/push.ts` - 폰이 닫혀
있어도 알림을 쓰도록 페이지가 `{{count}}`를 남긴 문구를 서비스 워커에 넘기고, 워커가 단계 수를 채웁니다.
- **조심해서 볼 파일**: `herdr-core/src/runtime/snapshot_delta.rs` - snapshot
wire. 위 호출이 `refresh_missions` 앞에 들어갑니다.
- **조심해서 볼 파일**: `herdr-core/src/links/` - 링크 worker가 유일한 SQLite writer,
스키마 9에 `ledger_plans` 표(#1565의 8 다음).
- **조심해서 볼 파일**: `hide-agent-hooks/src/plan_record.rs`,
`hide-agent-hooks/src/delivery.rs` - failure path. PreToolUse는 core를 부르지
않고 pane 기록 파일만 읽습니다. 읽지 못한 계획 요약은 요약만 버리고 편지는 그대로 전합니다.
- **조심해서 볼 파일**: `herdr-core/src/dag.rs` - 미션 그래프 코드를 옮긴 것(동작 그대로, 미션
테스트 77개 통과).
- **비용 검토**: 고빈도 경로 추가는 snapshot마다 `plans.edit` 비교 한 번입니다. 계획이 바뀐
publish에서만 행 복사, lineage, 읽음 축을 다시 돕니다. 계획은 128개(`PLAN_LIMIT`), 단계는
64개(`plan_too_large`)로 막히고, `laid`는 보이는 pane으로 잘립니다.

## Evidence

- **확인한 것**: 격리된 Herdr와 hided 위의 Playwright e2e
`web/e2e/plan-review.spec.ts`. `--ask` → 칩 Review, 띠와 사이드바 `Plan review
· 4 steps`(영어 UI), approve → 띠와 사이드바가 비고 1/4, 일하는 단계가 둘째 줄, 순서 거절
`plan_order_refused`, 2/4, 팝오버 4단계, `크게 ›` → 보기 칸 큰 지도(아래로 흐름), drop → 칩
사라짐.
- **확인한 것**: 격리된 후보 Electron 창(Playwright renderer capture, 사설
HOME/state/Herdr)에서 아래 화면 네 장. 운영자 앱과 서버는 쓰지 않았습니다.
- **확인한 것**: 핵심 회귀 - 다른 Herdr 이벤트 없이 approve만 해도 검토 질문이 행에서 걷힘(첫 캡처에서 남아
있던 것을 고침, core 테스트로 고정).
- **확인한 것**: core plan/mission 테스트, delivery-envelope 계약 테스트(계획 요약과 힌트
예시), hide-agent-hooks 전체(훅이 `hide`를 부르지 않고 거절), hided CLI 계약, hide-kit,
web 전체(`scripts/verify-web.sh`), design contract, cargo lint(clippy,
fmt).
- **확인하지 못한 것**: OpenCode와 Pi 플러그인 helper의 계획 거절 경로는 테스트가 없습니다(Claude
Code CLI 경로만 픽스처로 증명).
- **확인하지 못한 것**: 연결된 기기의 pane(B22), 폰 줄(B24)은 실행해 보지 않았습니다. 같은 질문 행을
읽는다는 것은 코드로만 확인했습니다.
- **확인하지 못한 것**: 실제 macOS 창 크롬과 네이티브 입력(renderer capture만 했습니다).
- **확인하지 못한 것**: 한 번 OpenCode plugin2 테스트 "a terminal that misses an
answer…"가 부하 중 실패했고 재실행에서 통과했습니다. 이 변경과 무관해 보입니다.

<details><summary>추가 증거</summary>

![approve 뒤 묻기가 사라지고 칩 1/5, pane 둘째 줄이 지금 단계와
line](https://github.com/yansfil/pr-assets/blob/main/hide/gen-prd-hide-plan/3c96a83/plan-running-window.png?raw=true)
approve 뒤: 묻기가 사라지고 칩 `1/5`, pane 둘째 줄이 `core 이벤트 · 이벤트 쓰는 중`.

![칩 팝오버: 작은
지도](https://github.com/yansfil/pr-assets/blob/main/hide/gen-prd-hide-plan/3c96a83/plan-chip-popover.png?raw=true)
칩 팝오버: 끝난 단계 채움, 지금 단계 진행색과 `Now`, 기다리는 단계 점선, `PR` 꼬리.

![크게 ›가 보기 칸에 큰 지도를
연다](https://github.com/yansfil/pr-assets/blob/main/hide/gen-prd-hide-plan/3c96a83/plan-map-slot-window.png?raw=true)
`크게 ›`가 보기 칸에 큰 지도를 엽니다.

</details>

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

- PRD: `hide-plan` (D-01..D-30, B1..B24), head `e52d7f7b7` (main merged
four times: `02f9043c0`, `d55a5218e` with #1564, `68e6fcba4` with #1565,
`8a6ca61af` with #1567; the last keeps both sides' 보기 items, Plan beside
Worktrees and Cost, and 55 shortcut rows).
- Review band wording moved out of the core (`e6e898dc3`): the row
carries `ask_subject`, and web, bell and phone word it with
`plan.askReview`; core test compares the wire structure, web tests cover
en/ko line, bell and service worker; e2e `plan-review.spec.ts` passes
with the English text; isolated capture replaced.
- Reviews of `e6e898dc3`: Code review found a raised ask (a blocked
delegated child carrying the subject) would word the label line on its
root; `22e41901a` carries `subject` on `RaisedAsk` to the root's ask,
band, turn card and tree popover, with a core test. A plain laid review
does not raise on its own (`ChildBlocked` needs the child's own block),
so this was a latent path. Fidelity review: the same popover sites,
fixed by the same commit; no other Fix now. Follow-ups:
`overviewTasks.cardLine` reads only `ask.what` (its one consumer falls
back to the subject).
- `sasu implement verify`: PASS on `e52d7f7b7` (and on `22e41901a`,
`8a6ca61af`); CI `verify` green on `e52d7f7b7` (run 39855795741). The
phone's cached words now include the plan review template
(`mobile.spec.ts` expectation, `e52d7f7b7`). Code review of the
`8a6ca61af` merge: no Fix now.
- Earlier: `sasu implement verify` PASS on `68e6fcba4` (S1
`verify-cargo.sh test`, S2 `verify-cargo.sh lint`), and earlier on
`02f9043c0` and `7582bce1e`.
- Before the merge, two runs on `3c96a8381` each failed one unrelated
timing test under machine load (load average 20 to 28):
`memory_analysis::...a_linked_node_s_closed_session...` and
`memory_hook::...short_continuations...` (`Deadline` for `Empty`). Each
passed alone, neither file is in this diff.
- Link store schema: #1565 merged first and took version 8
(`closed_result`); `ledger_plans` is version 9, applied after it in the
same migration. Code review of the move: no Fix now (a store a pre-merge
build of this branch stamped 8 would miss `closed_result`; only
throwaway candidate stores).
- Fidelity review on `6195d35af`: 6 Fix now, 5 fixed (done steps on
replan, `--json` revise route, record 지금 line, waypoints icon,
`plan_not_yours` test), 1 left to the reviewer (B20 per-skill off).
Follow-up on `3c96a8381`: no Fix now.
- Code review on `6195d35af`: 4 Fix now, all fixed (`plan_too_large` and
`--json` errors as JSON, review question lifted from shown rows,
`--json` revise route, unreadable plan summary keeps the letters).
Follow-up on `3c96a8381`: no Fix now.
- After the merge, Fidelity found that a deleted session's plan item
closed the viewing column instead of showing the documents (main's
lane-two-columns B13); `drop_detail_items` fixes it for plans and
missions (`2b4b5ad79`). Both reviews of `02f9043c0..7582bce`: no Fix
now.
- CI web e2e linux 5/6 (`s2.spec.ts` shortcut count 53 vs 54 with Show
plan) fixed in `7582bce1e`.
- Follow-ups carried: plan context before the restore finishes, skip the
row copy when no plan is proposed, remote rows' read mark after a
re-lay, bell on a review laid at pull time, ghost steps toward the 64
cap, session precedence after `/clear`, device clock skew, pane record
cleanup, eviction note, OpenCode and Pi helper test, `git rebase
--continue`, a documents-return assertion on the plan delete path,
re-reading a record under a dropped plan.
- Evidence: 5 isolated renderer captures registered (B5, B7, B11, B12,
B14); e2e `web/e2e/plan-review.spec.ts`.

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