Repository navigation
Memory: read past a session line over the line cap - #991
Merged
Merged
Conversation
Memory's analysis and receipt walk read JSONL sessions through a line reader that refused a whole read when one line passed 256 KiB, so a session holding a screenshot tool result was never analyzed, its receipts were never read, and every pass logged the same failure. Both now read through the conversation reader the label read and search use (`Call::SessionConversation`), which reads past such a record without holding it and counts it; the pass logs that count once. A cursor saved by the old reader resumes at its offset. A session that still cannot be read is logged once per version of its file instead of on every pass. The line reader (`SessionCursor::read`, `Call::SessionChunk`) had no other caller and is removed.
Memory now reads through `Call::SessionConversation`, which came with protocol 26, and the line read a protocol-24 node answered for it is gone. A node advertises the Memory reader for a runtime only beside its conversation reader, protocol 24 advertises none, and the walk reads a session only when the node holding it advertises both, so an older node's sessions are left unread as for a runtime with no Memory reader instead of failing every read.
…lines # Conflicts: # docs/ARCHITECTURE.md
yansfil
added a commit
that referenced
this pull request
Oct 12, 2026
…ory (#1000) ## Summary - 지금 추출 프롬프트는 30 KB 그룹당 카드 약 4.7장을 만들고 절반이 "한 작업의 설계"라서, 운영자가 지운 카드의 39%를 같은 출처에서 다시 만들었습니다. - 추출 프롬프트를 교체하고(세션당 새 카드 2장, 운영자 발언 3회 미만 세션은 카드 없음, 에이전트가 시작시킨 세션의 사람 이벤트는 `parent_agent`), 카드가 의존하는 파일·경로·명령을 증거로 저장합니다. - 증거가 바뀐 카드는 `확인 중`으로 에이전트 인덱스와 프롬프트 매칭에서 빠지고, 하루 한 번 provider가 다시 확인해 유효(복귀)·수정(새 revision, Undo 가능)·삭제(Undo 가능) 중 하나로 정합니다. - 규칙·교훈을 제안하기 전에 저장소 AGENTS.md/CLAUDE.md와 링크 문서, 운영자의 전역 지침 파일을 한 번 대조해, 이미 적힌 카드는 포인터 카드로 바꾸거나 제안하지 않습니다. - 에이전트가 `hide memory outdated <card> <reason>`으로 승격 중 낡은 카드를 알릴 수 있고, 탭은 `확인 중` 표시 한 가지만 더 그립니다(4개 언어). - **공개 변경**: 공개 문구(disclosure)가 버전 3으로 올라 저장소 파일과 지침 파일 전송을 명시하므로, 기존에 켠 모든 Project는 한 번 꺼지고 다시 동의를 묻습니다. 저장된 Memory는 그대로입니다. 화면 변경은 카드 상태 슬롯의 `확인 중` 한 줄과 disclosure 문구입니다. 캡처는 로컬(`agents/runs/`)에만 있어 이 본문에는 올리지 못했습니다. ## Review - **판단해 주세요**: 추출 프롬프트 `newb`(운영자 선택)가 `new`보다 지운 카드를 3장 더 닮습니다(5 vs 2). 수치는 아래 Evidence입니다. - **판단해 주세요**: 전역 지침 파일 매칭이 `in_docs`이면 포인터 대신 카드를 forget합니다(Undo 가능). 포인터는 저장소 경로가 있어야 하기 때문입니다. - **판단해 주세요**: 점검 호출은 일일 상한의 절반(`MAINTENANCE_CALL_LIMIT` 500)까지만 씁니다. PRD D-08보다 엄격합니다. - **조심해서 볼 파일**: `herdr-core/src/runtime/memory_analysis.rs` - #961(다중 노드 pass)·#991(긴 줄)과 겹쳐 main을 두 번 병합했고, `analyze_session`이 `delegated`와 `stat`를 모두 받습니다. - **조심해서 볼 파일**: `herdr-core/src/runtime/memory_verify.rs`, `memory_evidence.rs` - 분석 worker 위의 provider 호출·노드 읽기. runtime mutex 안에서는 아무것도 하지 않습니다. - **조심해서 볼 파일**: `hide-memory/src/store.rs` - 스키마 9(`VACUUM INTO` 백업 후 마이그레이션, 기존 카드는 모두 `확인 중`으로 시작), 판정은 읽은 revision과 claim에만 적용(`confirm_card`, `revise_card`, `forget_checked`). - **조심해서 볼 파일**: `hide-memory/src/verify.rs` - provider로 가는 발췌. 긴 파일은 카드와 단어가 겹치는 섹션을 고르고, 자격 증명 이름의 파일은 읽지 않습니다. - **비용 검토**: 점검은 pass당 재확인 4장, 제안 전 점검 3장, 증거 비교 200장, 지문 읽기 300+200회로 상한이 있고, 카드당 하루 한 번(답이 온 경우) 물으며 hook은 노드도 모델도 부르지 않고 SQL 조건 하나로 `확인 중`을 거릅니다. - **알려진 한계(코드 수정 안 함)**: 노드 링크가 끊긴 사이에 쓴 카드는 증거 없이 검증되어 이후 비교되지 않습니다. - **알려진 한계(코드 수정 안 함)**: 운영자 발언 3회 미만이어서 건너뛴 세션의 앞부분은 이후에 다시 읽지 않습니다(닫힌 세션이 영원히 미정으로 남는 것을 피하려는 선택). - **알려진 한계(코드 수정 안 함)**: 지침 파일 속 지시문이 provider의 수정 판정 텍스트에 영향을 줄 수 있습니다. 수정은 새 revision이며 Undo가 가능하고, 비밀·credential 검사는 거칩니다. - **알려진 한계(코드 수정 안 함)**: 이 변경 전에 만든 카드는 위임 세션에서 온 사람 횟수를 그대로 가집니다. 이전 hook 도우미는 스키마 9 저장소를 읽을 때 kit이 갱신될 때까지 닫힌 채 실패합니다(fail closed). - **알려진 한계(코드 수정 안 함)**: 260px 폭의 한 줄 맞춤은 갤러리에서 수동 확인했고 자동 테스트는 없습니다. Pen 라이브러리는 갱신하지 않았습니다. - **질문**: 운영자의 herdr-ide 저장소는 기존 카드 895장을 가집니다. 설치 후 비우고 새 규칙으로 다시 추출할지는 운영자 결정입니다. ## Evidence - **확인한 것**: `scripts/verify-cargo.sh clippy` 경고 없음, `scripts/verify-cargo.sh test -p hide-memory` 워크스페이스 46개 테스트 바이너리 모두 통과(herdr-core 라이브러리 테스트 2천여 개 포함), `verify-web.sh` 통과, `check-design-contract`, `check-core-touches-no-machine`, 워크스테이션 신원 검사 통과. - **확인한 것**: 프롬프트 비교(30개 실제 세션 + 지운 카드의 근거 68개 그룹). 현재 4.70장/세션, `new` 0.27, `newb` 0.40. 지운 67장 중 같은 내용을 다시 만든 수는 현재 26, `new` 2, `newb` 5. 보존 가치가 있는 비율은 현재 34%, `new` 85%, `newb` 92%. - **확인한 것**: 실제 저장소 복사본(895장 규모)으로 스키마 8 -> 9 마이그레이션과 백업 파일 생성, 증거 추출기 정밀도(지운 카드 67장 중 7장이 이동한 이름을 가짐, 유지 카드 89장 중 0장). - **확인한 것**: 네이티브 리뷰 3종(Fidelity, Code, Security)을 돌려 지적을 고쳤습니다. 마지막 리뷰 head는 병합 전이고, 이후 변경(자격 증명 이름 파일 제외, 답이 온 점검만 실패 표시 해제, 발췌 단어에 alias 포함)은 테스트로만 확인했습니다. - **확인하지 못한 것**: 운영자의 설치된 앱과 실제 provider로 하는 라이브 점검. 격리 HOME의 합성 저장소 테스트와 스크립트된 provider 응답까지만 확인했습니다. - **확인하지 못한 것**: `parent_agent` 이벤트 종류가 포함된 프롬프트의 실제 모델 동작. 위임 세션은 운영자 발언 0회로 계산되어 모델까지 가지 않습니다. - **확인하지 못한 것**: 프로젝트의 필수 suite가 sasu에 설정돼 있지 않아 `sasu implement verify`는 필수 suite 0개로 통과했습니다. 위 lane은 제가 직접 돌린 결과입니다. 스크린샷은 업로드하지 않았습니다. ## Breaking change - 공개 문구 버전 3: 기존에 켠 모든 Project가 한 번 꺼지고 Settings에서 다시 켜야 합니다(저장된 Memory 유지). - 스키마 9로 올라가면 이전 빌드는 이 저장소를 열 수 없고, 마이그레이션 직전 상태는 `project-memory.sqlite3.v8-backup`에 남습니다. <details><summary>Verification record</summary> - Base: origin/main 04721d3 병합 후 head는 PR 상단 참조. 로컬 PRD `memory-card-quality`(사람 승인 완료). - `sasu implement verify`: PASS(필수 suite 없음), 프로젝트 lane은 위 Evidence에 직접 기재. - 리뷰: Fidelity P1-P2 수정, P3-P7 Review 노트로 수용. Code 16건 중 한계로 남긴 항목(링크 끊김, 첫 청크, 전역 파일 전송 등)을 제외하고 수정. 후속 Code 리뷰에서 N1-N3 수정. Security: 자격 증명 이름 파일 제외로 수정, 나머지 낮은 위험은 한계로 기재. </details>
yansfil
added a commit
that referenced
this pull request
Oct 15, 2026
Related: #1149 ## Summary 충돌을 풀려고 main을 합쳐 push하면, 바뀐 것이 문서뿐이어도 PR이 계획한 레인이 처음부터 다시 돕니다. 이제 그런 push는 이 PR의 마지막 초록 `verify`를 재사용하고 `policy`만 돌립니다. plan 요약에 재사용한 실행 ID가 남습니다. 재사용은 두 조건이 모두 참일 때만입니다. - **A. PR이 더하는 것이 그대로**: 그 실행의 head를 지금 main에 합친 결과와 이번 merge가 `policy`만 읽는 경로(문서, `design/`, `POLICY_ONLY`)에서만 다릅니다. 코드, 테스트가 읽는 가이드, 계약이 다르면 다시 돕니다. - **B. main이 PR 파일을 건드리지 않음**: 그 실행이 본 main 이후 main이 바꾼 파일 중, PR이 바꾼 파일이면서 레인이 읽는 것이 없습니다. #1133처럼 겹치면 다시 돕니다. - **실패는 일반 plan**: 실행이나 기록이 없거나, 기록의 head가 다르거나, API·다운로드·fetch·비교가 실패하면 지금처럼 계획하고, 요약에 이유를 씁니다. 각 PR 실행은 레인이 실제로 확인한 main과 head를 `ci-plan` 아티팩트로 남깁니다. 재사용한 실행은 원래 실행을 가리켜, 비교는 항상 레인이 돈 실행과 합니다. 머지 직전 `premerge-check.py`는 지금처럼 merge 결과에서 돕니다. ## Review - **판단해 주세요**: 재사용해도 `policy`(리눅스 잡 1개, 약 70초)는 돕니다. 스크립트 테스트와 불변식이 바뀐 문서를 읽기 때문입니다. brief의 "레인을 다시 돌리지 않고"보다 하나 더 돕니다. - **판단해 주세요**: B는 브리프대로 파일 겹침만 봅니다. main이 PR이 고친 함수를 쓰는 새 파일을 더한 경우는 지금의 "뒤처진 초록 PR 머지" 정책과 같이 premerge-check와 main push 런에 맡깁니다. - **조심해서 볼 파일**: `scripts/ci-plan.py` `plan` - 재사용 분기는 `NotReused`, git 실패, `OSError`, `ValueError`를 모두 일반 plan으로 돌립니다. 통과로 가는 길은 두 조건이 참일 때 하나뿐입니다. - **조심해서 볼 파일**: `scripts/ci-plan.py` `still_stands` - 충돌이 난 merge-tree 결과는 충돌 표시가 남은 채 비교되어, 코드 충돌을 다르게 푼 push는 A에서 걸립니다. - **조심해서 볼 파일**: `.github/workflows/pr.yml` plan 잡 - `actions: read` 권한, `GH_TOKEN`, 기록 업로드(`continue-on-error`: 업로드 실패는 다음 실행이 일반 plan이 될 뿐). - **비용 검토**: 재사용을 시도할 때만 commit과 tree를 받습니다(blob 없이, main 전체 이력 약 9 MB). GitHub에서 받은 depth 2 체크아웃 기준 첫 판정 11.6초(로컬 망). ## Evidence - **확인한 것**: `python3 -m unittest discover -s scripts/tests -p 'test_*.py'` 360개 통과. - **확인한 것**: 실제 git 저장소로 만든 테스트 7개: 문서 충돌만 푼 재push는 재사용, main과 겹친 코드(#1133 모양), 코드로 푼 충돌, PR 코드 변경, 테스트가 읽는 가이드 변경은 재실행, 실행 없음·조회 실패·받을 수 없는 커밋은 일반 plan. - **확인한 것**: 조건 B 제거, 조건 A 제거, READERS를 문서로 취급, 실패를 재사용으로, 다른 fork 실행 포함, 기록 head 미확인의 변조 6개가 각각 테스트를 실패시킵니다. - **확인한 것**: 실제 이력 재생. PR 39개에서 초록 실행 뒤에 온 실행 52개를 판정했습니다. 재사용 3, PR이 레인 경로를 바꿔 재실행 45, main 겹침으로 재실행 4. 표는 아래. - **확인한 것**: #1133(브리프의 반드시 재실행 사례)은 재실행입니다. 재병합에서 `persistence.rs` 충돌을 풀어 A가 걸리고, B만 따로 봐도 main과 겹친 레인 경로 6개로 걸립니다. - **확인한 것**: GitHub에서 depth 2로 받은 #1143 merge 체크아웃에서 fetch, merge-tree, 판정이 끝까지 돌았습니다(재실행 판정, 같은 head 재판정은 재사용). 실제 API 조회는 초록 실행을 찾고 기록이 없어 일반 plan으로 갑니다. - **확인하지 못한 것**: 머지 전 실행은 기록을 남기지 않았으므로 재사용은 이 PR 머지 뒤의 초록 실행부터 됩니다. - **확인하지 못한 것**: 이 PR의 첫 실행은 `ci-plan.py`를 바꿔 전체 레인입니다. 문서만 다시 push해 재사용이 실제로 일어나는지는 이 PR에서 따로 확인합니다. <details><summary>재생 결과 (재사용과 main 겹침 사례)</summary> 재생: 각 실행의 merge commit 첫 부모를 그 실행의 main으로 보고, head를 그 main에 합쳐 다시 만든 merge로 이 PR의 판정을 돌렸습니다. | PR | 실행 | 그 전 초록 실행 이후 바뀐 것 | 판정 | | --- | --- | --- | --- | | #967 | 38137531799 | `docs/VERIFICATION.md` 한 줄 | 재사용 (원래 전체 레인) | | #966 | 38173834278 | 베이스 브랜치 병합, 베이스가 바꾼 3개 파일은 PR과 안 겹침 | 재사용 | | #1010 | 38274906653 | 같은 head, 같은 main에서 다시 돈 실행 | 재사용 | | #1133 | 38689861115 | main 병합, `persistence.rs` 충돌을 코드로 해결 | 재실행 (A, B 모두) | | #1114 | 38668610949 | main이 PR도 바꾼 `hided/tests/it/core_move.rs`를 바꿈 | 재실행 (B) | | #991 | 38214789905 | main이 PR도 바꾼 `memory.rs` 등 4개를 바꿈 | 재실행 (B) | | #969 | 38142050470 | main이 PR도 바꾼 `pr.yml`을 바꿈 | 재실행 (B) | | #1143 | 38699835291 | main이 PR도 바꾼 `design/tokens.json` 등 10개를 바꿈 | 재실행 (B) | 나머지 44개는 PR이 레인이 읽는 경로를 바꿔 재실행입니다. </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
Memory's analysis and receipt walk refused a whole session read when one JSONL line passed 256 KiB (
session_capacity:line_bytes:262144).On the installed 0.1.0-main.b70d00a3 build, 134 of 310 recent herdr-ide Claude Code sessions hold such a line, mostly a screenshot tool result: none of them was analyzed, their receipts were never read, and each pass logged the failure again (about 5 per 90 s).
Call::SessionConversation). It reads past an oversized record without holding it and counts it; the pass logs that count once (receipts.records_skipped,analysis.records_skipped).CursorCheckpointconverts intoConversationCheckpoint).SessionCursor::read,Call::SessionChunk,hide_host::sessions::chunk) had no other caller and is removed with its tests.SessionConversation(protocol 26) and now advertises none, and the walk reads a session only when the node holding it advertises both. An older node's sessions are left unread, as for a runtime with no Memory reader, never logged aswalk_failed.Review
herdr-core/src/runtime/memory_analysis.rs- failure path:read_throughrecords the file size when a read reached the end it saw, so a torn last line is not reread every pass (the old reader recorded its read position the same way).hide-node-link/src/protocol.rs- aCallvariant is removed; Memory only asks the core's own node, which ships in the same build.MemoryWork.hide-node-link/src/sessions.rs- the protocol-24 reader contract shrinks (Memory removed for Claude Code and Codex CLI), since this PR removes the call such a node answered for Memory.docs/ARCHITECTURE.md(the one on receipts and the 1 MiB read). Whichever lands second resolves that one conflict; the Rust files merge cleanly.Evidence
a_session_holding_an_oversized_tool_result_is_analyzed_and_its_receipts_read_past_itwrites a Claude Code session with the operator's rule, a 300 KiB tool_result, an assistant reply and a signed receipt, and runs real passes throughhide_node::Local. The provider input holds both turns and no tool bytes, the receipt is recorded, the skip is logged once with{"non_conversation_capacity": 1}, and a second pass logs nothing.analyzedwith no card instead oflearned one.a_session_that_cannot_be_read_is_logged_once_per_change_of_its_file: an unreadable saved cursor logs both failures on the first pass, nothing on the second, and both again after the file changes.verify-cargo.sh lint(fmt + workspace clippy) clean; nextest over every crate the change reaches (herdr-core, hide-factory, hide-host, hide-node, hide-node-link, hide-session, hided): 3284 passed, 38 skipped.check-core-touches-no-machine.py,check-no-workstation-identity.sh,check-capability-readers-off-lock.shpass.an_older_nodes_sessions_are_not_read_for_memory_and_log_no_failed_read: a node built from a protocol-24 Hello that refusessession_conversationgets no read, no provider call and no Memory log line. The test fails withreceipts.walk_failedif protocol 24 still advertises Memory./tmp, removed after), with a private pinned Herdr 0.9.3 andHIDE_MACHINE_ID=live-check-node. It walked a scratch git Project with Memory on (seeded with card m1) and a Claude Code session: a rule, a screenshottool_use, a 300 KiB imagetool_result, an assistant reply and a signed receipt.core.jsonlloggedreceipts.records_skippedandanalysis.records_skippedonce each (non_conversation_capacity: 1) and neverwalk_failed,session_failedorline_bytes. The receipt was recorded atevent:308911(after the image line), card m2 was learned, and both cursors reached 309473 (the file size). Over 150 s of later passes, no new Memory line.claudeon the login PATH was the repository'shide-ai/tests/fixtures/fake-claude.pywithFAKE_REPLYset. The prompt it received (463 chars) held both turns and no image bytes. The first pass deferred analysis until the weekly usage was read (analysis.deferred: weekly_usage_unread), as designed.