Skip to content

Have Codex trust the Herdr hook the kit installs - #693

Merged
yansfil merged 5 commits into
mainfrom
prd/codex-herdr-hook-trust
Oct 7, 2026
Merged

yansfil merged 5 commits into
mainfrom
prd/codex-herdr-hook-trust

Conversation

@yansfil

@yansfil yansfil commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Related: PRD agents/prd/codex-herdr-hook-trust/prd.md · 선행: #670 (Codex hook 신뢰), #668 (kit의 Herdr 연동), #688 (spawn guard)

Summary

  • Record Codex's trust for Hide's own hooks so Codex does not ask to review them #670 이후 hide 자기 hook은 Codex에 신뢰로 기록되지만, kit이 같이 설치하는 Herdr의 Codex hook은 남의 것이라 새 기기에서 "Hooks need review"가 뜨고, 승인 전까지 Herdr는 그 pane의 Codex 세션을 모른다.
  • kit이 herdr integration install codex를 부르기 직전과 직후에 ~/.codex/hooks.json을 읽어, 그 호출이 추가한 항목(event, matcher, 종류, command)을 kit 기록(herdr_hooks)에 남긴다. Herdr의 명령은 hide에 적혀 있지 않다.
  • 기록된 항목은 #670의 select_targets가 hide 자기 항목과 같은 글자 단위 일치 규칙으로 함께 고른다. 신뢰 확인은 pass당 한 번이고, 에이전트 부품 설치 뒤로 옮겨 첫 설치에서 한 번의 app-server 세션으로 둘 다 신뢰된다.
  • 운영자가 먼저 설치한 연동, 같은 스크립트 이름을 흉내 낸 명령, 다른 에이전트는 바뀌지 않는다. docs/agent-hooks.md, INSTALL.md, ARCHITECTURE.md에 이 규칙과 2026-10-07 조사 결과를 적었다.

Review

  • 판단해 주세요 (보안): 학습은 설치 호출 전후 diff다. 그 한 번의 호출 구간에 다른 도구가 항목을 순수하게 추가하면 Herdr 것으로 기록되고 신뢰된다.
    상한 4개, 사용자 권한의 쓰기가 필요하고, config.toml을 직접 쓰는 것보다 더 얻는 것은 없다. 호출 구간 밖의 쓰기, 다른 항목의 삭제나 수정은 막았다.
    더 막으려면 integration status의 스크립트 경로를 명령에 요구하는 규칙이 필요한데, 손으로 쓴 Herdr 규칙에 가까워 넣지 않았다. 이 잔여 위험을 받아들이시겠습니까?
  • 판단해 주세요 (기존 기기): herdr:codex만 있고 항목 기록이 없는 기기(Clean up Settings: six tabs, seven agents, a Hide AI tab and Reopen for unheard panes #668 빌드가 설치)는 학습하지 못한다. Herdr가 이미 쓴 항목은 재설치해도 그대로라 kit에 추가로 보이지 않는다.
    그 기기는 검토 화면을 한 번 보고, 승인하면 그 해시가 신뢰된다. Herdr가 옛 항목을 지우지 않고 새 항목만 더할 때만 회복하며, 제자리 교체는 기록에 없는 항목의 제거라 거절된다. 이전은 넣지 않았다.
  • 판단해 주세요 (D-03 해석): 신뢰 확인을 #670의 자리(부품 루프 안)에서 agent_kit::apply 뒤로 옮겼다. Herdr 연동이 그때서야 설치되므로 B1에 필요하다. 프로세스와 확인 경로는 그대로 하나다.
  • 운영자가 확인하지 않은 구현 측 가정: D-02의 학습 방식(설치 시점 기록), D-04, D-05 조사(Cursor 현재 CLI와 Pi 사용자 extension은 문서 추정), D-06, D-07.
  • 조심해서 볼 파일: hide-agent-hooks/src/codex_trust.rs - 신뢰 대상 선택(select_targets, learn_herdr_entries), 가장 먼저 볼 곳.
    hide-kit/src/agent_kit.rs - 설치 전후 읽기, apply/reports 분리. hide-kit/src/lib.rs - 확인 위치와 Codex 부품 실패 전파. hide-kit/src/record.rs - herdr:codex가 있을 때만 항목을 읽는 관문.
  • 비용 검토: 새 프로세스와 새 상태 파일은 없다. codex app-server 확인은 pass당 1회 그대로이고, 설치 호출마다 hooks.json 읽기 2회, 학습 항목 상한 4개다.

Evidence

  • 확인한 것: 고정된 Herdr 0.9.1(sha가 contracts/herdr-bundle.json과 일치)과 codex-cli 0.160.0, 격리된 Herdr 서버, 비공개 HOME에서 실제 kit pass(hide_kit::apply)를 돌려 봤다.
    빈 ~/.codex에서 한 pass로 7개 항목이 신뢰됐고 Codex가 "Hooks need review" 없이 시작했으며, 첫 턴 뒤 herdr agent list에 agent_session(source herdr:codex)과 hide의 hide_hooks 토큰이 있었다(B1, 수정 뒤 코드로 다시 확인).
    반복 pass는 config.toml을 바이트 단위로 그대로 두었다(B6). 운영자가 먼저 설치한 연동은 신뢰되지 않아 Codex가 그 hook 하나만 검토 화면에 올렸다(B2). 같은 이름의 다른 경로 명령도 검토 화면에 올랐다(B3).
    워크스페이스 전체 cargo test와 lint가 통과했다(kit 140개, hide-agent-hooks 통합 22개, 단위 25개 이상 포함). auth.json 사본의 지문은 끝까지 같았고 rm -P로 지웠다.
  • 확인하지 못한 것: B4(Herdr 명령 변경)와 B5(기록 실패)는 stand-in으로만 확인했고 실제 Herdr/Codex로는 보지 않았다. 패키지된 hide.app, 기기(device) 경로, Herdr가 명령을 제자리에서 바꾸는 실제 동작, Herdr 재설치가 config.toml의 hooks.state를 보존하는지, Cursor와 Pi의 실제 동작은 확인하지 못했다.
Verification record
  • PRD: agents/prd/codex-herdr-hook-trust/prd.md (sha256 5efb1726de39a3c658cbe20a3d78b38b17f3e111d72cdce00b2e58ca7ed1a5ae)
  • Base 7852aef → head f4ec34a, verified 2026-10-07T02:49:37.198Z: PASS
  • Verification report: agents/runs/codex-herdr-hook-trust/verification-report.json and agents/runs/codex-herdr-hook-trust/verification-report.md; source fingerprint 303af8c81f58d9b78dfe504150308ce977849713bc2efe752613539d398fa624
  • Suites:
    • S1: GREEN bash scripts/verify-cargo.sh test (exit 0)
    • S2: GREEN bash scripts/verify-cargo.sh lint (exit 0)
  • Reviews (조언용, 병합 권한 아님):
    • 아래 SHA는 origin/main(9e9e6a9)으로 충돌 없이 리베이스하기 전 값이다. 이 PR의 diff는 같고, 리베이스한 head에서 verify가 다시 통과했다.
    • Fidelity: a586392a, 4d199851, e27da3be, 0ff0c5f6 검토. Fix now 없음. 사람 결정으로 넘긴 것: 기존 기록 기기 미학습(위 Review 2번), 신뢰 확인 위치 이동. 문서 문구 두 건은 0ff0c5f6에서 반영.
    • Code: a586392a에서 Fix now 3건(시험이 주장을 확인하지 못함, 오류 경로 시험 부족, 설치 전후 읽기 간격) 모두 4d199851에서 수정; 4d199851에서 1건(거절된 학습이 기록을 지움)을 e27da3be에서 수정; e27da3be는 Fix now 없음. 0ff0c5f6(문서와 주석만 바뀜)은 Code와 Security가 다시 보지 않았고 Fidelity가 확인함.
    • Security: a586392a에서 Fix now 1건(전후 읽기 창이 넓음)을 4d199851에서 좁힘; 4d199851과 e27da3be는 Fix now 없음.
    • 받아들이지 않은 제안: 학습 집합 길이 상한, 기록에서 사라진 항목의 매 pass 정리, integration status 경로로 명령 교차 확인, 기록 로드 시 상한 검사(이유는 Review에).
    • Follow-up improvements: a_refused_learn_keeps_what_was_recorded_before에 설치 호출 발생 단언 추가, handler_type 검사가 세 곳에 겹침.
  • Evidence: 3 registered (2 file, 1 log); paths are local to the run directory
    • agents/runs/codex-herdr-hook-trust/live/evidence.md
    • agents/runs/codex-herdr-hook-trust/live/b1/screen-after-prompt.txt
    • agents/runs/codex-herdr-hook-trust/live/evidence-rerun.md
  • Changed paths: 22 (see Files changed)

The kit records the hook entries Herdr's Codex integration adds to hooks.json
when the kit runs the install, read from the file before and after the call.
The Codex trust check lists those recorded entries with Hide's own and
selects them through the same exact-match rule, so a Codex first start on a
kit-installed machine shows no review screen for Herdr's hook either.
An integration the operator installed first has no record and a look-alike
command is not byte-equal to one, so neither is trusted.

The trust check now runs once after the agents' pieces, because Herdr's
integration is only in place then; the Codex hook part still carries its
failure.
The agent-hooks guide, the install guide and the architecture guide now say
the entry Herdr's integration wrote when the kit installed it is recorded and
trusted exactly, that an integration the operator installed first is not, and
which agents ask for a hook review (a survey dated 2026-10-07, with Pi and
Cursor inferred from documentation).
The hook file is read right after the integration install returns, so the
window another writer could land an entry in is that one call. An install
that removed or edited anyone else's entry, or added more than four, teaches
nothing and forgets what was recorded; an unreadable file leaves the record
alone. Recorded entries are handed to the trust check only while Herdr
reports the integration current. A new entry and recorded entries still in
the file are both kept.

Tests cover a foreign entry added after the install, an install that also
removed another entry, a pile of entries, an unreadable record, the record's
ownership gate, and compare the hash Codex holds with the entry's current
one.
A refused learn no longer clears the entries recorded from an earlier
install: they were seen when Herdr wrote them and are only ever matched
against a byte-equal entry in the file. Recorded entries of a handler type
other than command are never expected. The guide now says a machine whose
record predates the entries does not heal when Herdr reinstalls.
…hook

Only a Herdr that adds a new entry without removing the old one lets such a
machine learn it; a refused learn leaves the record as it was.
@yansfil

yansfil commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

Merge check before merge: origin/main 9e9e6a9 is already an ancestor of head f4ec34a, so git merge-tree gives the head's own tree (a62a9bd6); the Rust lanes this diff touches (scripts/verify-cargo.sh lint and test) passed on exactly that tree in the run's verification report, and CI is green (17 pass, 5 skipped).

@yansfil
yansfil merged commit 4bb2f68 into main Oct 7, 2026
22 checks passed
@yansfil
yansfil deleted the prd/codex-herdr-hook-trust branch October 7, 2026 03:20
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