Skip to content

fix(agent): 스레드 조회를 torn read에 견디게 하고 선조회 지침을 복원한다#36

Merged
lbox-limit merged 1 commit into
mainfrom
fix/current-thread-torn-read
Jul 15, 2026
Merged

fix(agent): 스레드 조회를 torn read에 견디게 하고 선조회 지침을 복원한다#36
lbox-limit merged 1 commit into
mainfrom
fix/current-thread-torn-read

Conversation

@lbox-limit

Copy link
Copy Markdown
Collaborator

문제

2026-07-15, C0BDJA287MW 스레드에서 봇이 (1) "위 주장과 근거를 검증해줘" 멘션에 스레드를 읽지 않고 되물었고, (2) 명시 요청("쓰레드내용") 후의 read_current_thread 호출이 database disk image is malformed로 실패해 사용자에게 시스템 오류가 노출됐다.

세션 DB 확인 결과:

  • 호스트는 스레드를 정상 조회해 1.3초 만에 current_thread_response를 inbound.db에 기록했다. PRAGMA integrity_check = ok — 파일 손상이 아니라 호스트 커밋 순간의 크로스마운트 torn read.
  • 툴의 250ms 폴러(findResponse)에는 poll-loop와 달리 corruption 내성이 없어 1회 오류로 즉시 실패했고, 응답 row는 두 poll-loop 경로 모두 kind='system'을 건너뛰므로 영구 pending으로 남았다.
  • 되묻기 회귀는 #31이 툴 설명에서 "'위 내용'류 지시어 → 답하거나 되묻기 전에 반드시 호출"을 제거한 결과.

변경

  • isCorruptionErrordb/sqlite-errors.ts로 추출해 poll-loop와 툴이 공유 (두 가지 발생 모드 문서화).
  • requestCurrentThread: corruption 계열 읽기 오류를 "응답이 아직 안 보임"으로 간주하고 데드라인까지 계속 폴링. 지속 실패 시 타임아웃 메시지에 일시 오류임과 재호출 안내를 포함.
  • 호출 시작 시 2분 넘게 방치된 stray current_thread_response를 ack해 고아 row 정리 (동시 호출의 살아있는 응답은 age gate로 보호).
  • 툴 설명에 선조회 트리거 복원 — #31의 안전 제약(타인 요청·기답변·민감 작업 추측 금지)은 유지.

검증

  • bun test 162 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

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>
@lbox-limit
lbox-limit merged commit 5d16a37 into main Jul 15, 2026
2 checks passed
@lbox-limit
lbox-limit deleted the fix/current-thread-torn-read branch July 15, 2026 02:51
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