fix(agent): 스레드 조회를 torn read에 견디게 하고 선조회 지침을 복원한다#36
Merged
Conversation
2026-07-15 사건: 호스트는 current_thread_response를 정상 기록했지만
(integrity_check ok), 툴의 250ms 폴러가 호스트 커밋 순간의 torn read로
SQLITE_CORRUPT를 한 번 맞고 재시도 없이 죽어 사용자에게 "database disk
image is malformed"가 노출됐고, 응답 row는 아무도 소비하지 않아 영구
pending으로 남았다.
- isCorruptionError를 db/sqlite-errors.ts로 추출해 poll-loop와 공유
- requestCurrentThread: corruption 계열 읽기 오류를 "아직 안 보임"으로
간주하고 데드라인까지 재시도, 지속되면 재호출 안내를 담아 타임아웃
- 시작 시 2분 이상 지난 stray current_thread_response를 ack해 고아 정리
- #31이 지운 선조회 트리거("위 내용"류 지시어·본문 없는 mention이면
되묻기 전에 먼저 호출)를 안전 제약은 유지한 채 복원
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
문제
2026-07-15, C0BDJA287MW 스레드에서 봇이 (1) "위 주장과 근거를 검증해줘" 멘션에 스레드를 읽지 않고 되물었고, (2) 명시 요청("쓰레드내용") 후의
read_current_thread호출이database disk image is malformed로 실패해 사용자에게 시스템 오류가 노출됐다.세션 DB 확인 결과:
current_thread_response를 inbound.db에 기록했다.PRAGMA integrity_check= ok — 파일 손상이 아니라 호스트 커밋 순간의 크로스마운트 torn read.findResponse)에는 poll-loop와 달리 corruption 내성이 없어 1회 오류로 즉시 실패했고, 응답 row는 두 poll-loop 경로 모두kind='system'을 건너뛰므로 영구 pending으로 남았다.변경
isCorruptionError를db/sqlite-errors.ts로 추출해 poll-loop와 툴이 공유 (두 가지 발생 모드 문서화).requestCurrentThread: corruption 계열 읽기 오류를 "응답이 아직 안 보임"으로 간주하고 데드라인까지 계속 폴링. 지속 실패 시 타임아웃 메시지에 일시 오류임과 재호출 안내를 포함.current_thread_response를 ack해 고아 row 정리 (동시 호출의 살아있는 응답은 age gate로 보호).검증
bun test162 pass (신규 6개: 정상 수신, torn read 재시도, 지속 corruption 타임아웃, 회복 후 무혐의, 비corruption 전파, stray 정리/age gate)tsc -p container/agent-runner/tsconfig.json --noEmit통과,pnpm run format:check통과🤖 Generated with Claude Code