Skip to content

OpenCode 세션을 DB에서 직접 읽어 제목, 질문 대기, 재우기와 fork를 보인다 - #878

Merged
yansfil merged 15 commits into
mainfrom
feat/session-readers-opencode
Oct 9, 2026
Merged

yansfil merged 15 commits into
mainfrom
feat/session-readers-opencode

Conversation

@yansfil

@yansfil yansfil commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Related: PRD agents/prd/session-readers-opencode/prd.md · 세션 리더 공통 #804, Pi #826, omp #865, Grok #868, Cursor #877 다음의 마지막 child

Summary

  • OpenCode 1.18.30의 세션을 세션 파일이 아니라 OpenCode 자신의 SQLite DB에서 읽기 전용으로 읽습니다.
  • 읽을 때마다 같은 transaction 안에서 id가 root session(parent_id 없음)이고 기록된 directory가 정확히 그 checkout임을 증명합니다.
  • 그 증명 위에서 native 제목, question 도구 대기, 재우기/깨우기(opencode -s <id>), fork(-s <id> --fork)를 켭니다.
  • 프로젝트 아카이브 목록/검색/상세와 폰 대화도 opencode/<id> locator로 같은 증명을 거쳐 읽습니다.
  • lifecycle gate는 requires_native_proof(native-file reader 전부 + OpenCode) 하나로 모았고, 증명 참조는 OpenCode만 id, 나머지는 path입니다.

OpenCode의 native question이 행의 질문 상태와 pane header의 Answer 태그로 보인다

재운 OpenCode 세션이 opencode -s <id>로 새 pane에서 같은 제목으로 깨어난다

Review

  • 판단해 주세요: DB를 열 수 없을 때 OpenCode 행만 빠지고 화면에는 아무것도 띄우지 않으며 core 로그(sessions.store_unreadable)에만 남깁니다(원칙 Move live and remote Herdr parsing to the typed boundary #13).
  • 판단해 주세요: 그 refusal은 기존 ProjectSessions 답의 한 행({"agent","store_refused"})으로 옵니다. 옛 core는 refused row 하나로 셉니다. protocol bump 없이 택한 방식입니다.
  • 조심해서 볼 파일: hide-agent-adapter/src/lib.rs - Herdr/core ownership. requires_native_proof가 Grok/Cursor/Pi/omp gate를 그대로 덮는지.
  • 조심해서 볼 파일: hide-session/src/opencode.rs - failure path. 모든 SQL은 progress handler 작업 상한과 행 크기 가드 아래에서 돕니다.
  • 조심해서 볼 파일: herdr-core/src/runtime/memory.rs - Memory 분석이 Memory reader 있는 agent만 읽도록 바뀌었습니다(OpenCode, Cursor 제외).
  • 비용 검토: 상시 경로 추가 없음. 읽기는 기존 label/activity 요청 때만, 한 번에 1 MiB, message 200개, part 512개, SQL step 상한 안에서 끝납니다.

Evidence

  • 확인한 것: sealed verify PASS(cargo test 249 s, lint 4 s), 최종 head에서 clippy workspace clean, nextest 10 crate 3463 통과.
  • 확인한 것: e2e session-readers.spec.ts 8/8. DB를 쓰는 OpenCode 대역으로 제목, child 제목 제외, question 대기/해제, 재우기, -s <id> 깨우기, DB+WAL 무변경.
  • 확인한 것: 설치된 OpenCode 1.18.30 실물(로그인 없음, private HOME과 격리 Herdr)로 -s <id> 정확 재개, -s <id> --fork가 parent 없는 새 root, 실제 WAL DB 읽기.
  • 확인한 것: web typecheck/lint/test 1312 통과, design contract 통과.
  • 확인하지 못한 것: agent-live-check.py --agents opencode는 도구 sandbox에서 agent 시작이 timeout, 모든 장면 not_tested, verdict unknown.
  • 확인하지 못한 것: windows check의 web/e2e/windows-sockets.unit.ts가 powershell 30 s ETIMEDOUT로 실패(이 PR과 무관, quarantine with-hide/hide-private#295), 실패 잡만 재실행.
  • 확인하지 못한 것: 로그인한 실제 모델 턴의 question 호출, 설치된 OpenCode의 Herdr 세션 자동 보고, 패키지 앱 UI, 실제 폰.
Verification record
  • PRD: agents/prd/session-readers-opencode/prd.md (sha256 25e35a2b30c918aa5a78c796d0be819bd0eb3de537f002e48a40fc220126b479)
  • Base f2ad76a → head 023cd90, verified 2026-10-09T13:20:21.197Z: PASS
  • Verification report: agents/runs/session-readers-opencode/verification-report.json and agents/runs/session-readers-opencode/verification-report.md; source fingerprint 76065e2461def954a490d75420ab1e8fde62f12c7ee7ba0e7ed65a0bdae735b2
  • Suites:
    • S1: GREEN bash scripts/verify-cargo.sh test (exit 0)
    • S2: GREEN bash scripts/verify-cargo.sh lint (exit 0)
  • Reviews (advisory):
    • Fidelity+Code 1차 (1e7ab02): Fix now 8건 모두 수정. catalog가 DB 실패로 전체 이력을 비우던 것, SQL work cap 누적, pending question, Memory 분석 정지, 폰 newest page 누락, 건너뛴 message의 witness, question 크기 admission, 문서.
    • follow-up (fb39ca3): Fix now 3건 수정. DB 단위 실패의 진단 누락(store refusal row + sessions.store_unreadable), json_valid 앞 크기 가드, budget admission 테스트.
    • follow-up (0c82c74): Fix now 1건 수정. NotFound 이외 stat 오류를 missing으로 읽던 것. page cap 초과 refusal row도 함께 수정.
    • follow-up (merge 후 최종 head 023cd90): Fix now 없음. Low 1건(mode 000 테스트가 root runner에서 실패할 수 있음)은 Follow-up.
    • Follow-up: 로그 per-poll 중복, catalog cap에서 refusal 분리, stat 두 번의 race, OpenCode 3 s follow-up poll 없음(설계), Cursor Memory 제외 테스트, Factory guard 테스트에 Grok/Cursor 추가, 다음 protocol bump에서 typed {sessions, refusals} 답.
  • Evidence: none registered separately.
  • Changed paths: 51 (see Files changed)
  • Delivery: mode pr, branch feat/session-readers-opencode, base main

yansfil added 15 commits October 9, 2026 12:53
…leep, wake and fork

OpenCode's reader proves the root session and its checkout from OpenCode's own
row in one read transaction, keeps a witness of the last message so a rewound
session is read again, and folds its question tool into the existing turn
tracker, including the unfinished message a waiting question keeps open.
Sleep, wake, fork and resume take OpenCode's -s <id> and -s <id> --fork once
that proof holds, through the lifecycle gates Pi already uses.
…opencode

# Conflicts:
#	docs/ARCHITECTURE.md
#	docs/UI_BEHAVIOR.md
#	docs/agent-hooks.md
#	docs/status-model.md
#	herdr-core/src/agent_sleep/dormant.rs
#	herdr-core/src/fork.rs
#	herdr-core/src/labels/worker.rs
#	herdr-core/src/live.rs
#	herdr-core/src/recent_closed.rs
#	herdr-core/src/runtime/agent_sleep/dormant.rs
#	herdr-core/src/runtime/projects.rs
#	herdr-core/src/runtime/session.rs
#	herdr-core/src/runtime/tests/agent_sleep.rs
#	herdr-core/src/sidebar.rs
#	herdr-core/src/worktree_control.rs
#	hide-agent-adapter/src/lib.rs
#	hide-host/src/serve.rs
#	hide-kit/src/tests/agent_cases.rs
#	hide-node-link/src/sessions.rs
#	hide-session/src/catalog.rs
#	hide-session/src/lib.rs
#	web/e2e/session-readers.spec.ts
#	web/src/agentAdapters.test.tsx
…opencode

# Conflicts:
#	docs/ARCHITECTURE.md
#	docs/UI_BEHAVIOR.md
#	docs/agent-hooks.md
#	docs/factory.md
#	docs/status-model.md
#	herdr-core/src/agent_sleep/dormant.rs
#	herdr-core/src/fork.rs
#	herdr-core/src/live.rs
#	herdr-core/src/recent_closed.rs
#	herdr-core/src/runtime/memory.rs
#	hide-agent-adapter/src/lib.rs
#	hide-kit/src/tests/agent_cases.rs
#	hide-node-link/src/sessions.rs
#	hided/src/mobile/conversation.rs
#	web/e2e/session-readers.spec.ts
#	web/src/agentAdapters.test.tsx
…opencode

# Conflicts:
#	docs/ARCHITECTURE.md
…opencode

# Conflicts:
#	docs/ARCHITECTURE.md
#	docs/UI_BEHAVIOR.md
#	docs/agent-hooks.md
#	herdr-core/src/agent_sleep/dormant.rs
#	herdr-core/src/recent_closed.rs
#	herdr-core/src/runtime/tests/agent_sleep.rs
#	hide-agent-adapter/src/lib.rs
#	hide-node-link/src/sessions.rs
#	hide-session/src/catalog.rs
#	hide-session/src/lib.rs
#	hide-session/src/turns.rs
#	hided/Cargo.toml
#	web/e2e/session-reader-fixture.ts
#	web/e2e/session-readers.spec.ts
#	web/src/agentAdapters.test.tsx
@yansfil
yansfil merged commit 97be59e into main Oct 9, 2026
41 of 43 checks passed
@yansfil
yansfil deleted the feat/session-readers-opencode branch October 9, 2026 14:02
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