Skip to content

OpenCode 안에서도 편지, 실행 가드, Memory, 하위 에이전트 수가 동작한다 - #818

Merged
yansfil merged 22 commits into
mainfrom
feat/opencode-plugin
Oct 8, 2026
Merged

yansfil merged 22 commits into
mainfrom
feat/opencode-plugin

Conversation

@yansfil

@yansfil yansfil commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Related: #769 (adapter declarations this builds on), #810 (no agent row draws an in-process subagent count yet)

Summary

OpenCode has no command hook, so inside Hide it got none of Hide's collaboration: no letters on its prompt, no spawn guard, no Memory, no subagent count.
This adds a Hide-owned OpenCode plugin, ~/.config/opencode/plugins/hide.js beside Herdr's, written and removed only by hide-agent-hooks and installed as OpenCode's hook piece in the kit.
Inside a Hide-managed Herdr pane it adds guidance, Project Memory and waiting letters to a root session's prompt as one synthetic part, and confirms the letters only after OpenCode reports that part stored.
It also refuses herdr agent start with the spawn guard's reason, refuses question in a Factory worker pane, and reports subagent counts from child-session events.
OpenCode stays unbelled, since its resume picker reads done. Outside a managed pane the plugin registers nothing.

Settings now name OpenCode's piece Plugin, drop its Basic chip, and say on any agent's row why its hook could not be put in (for example, the agent's config folder does not exist yet).

Review

  • 판단해 주세요: the agent row now shows one quiet line when a hook is Absent with a reason, for every agent (B14). On Windows, Cursor's row says its hook is not written there.
  • 판단해 주세요: the subagent count reaches Herdr's pane tokens and the snapshot (children.subagents), as Claude Code's does. No row draws it yet for any agent: 에이전트 행에 서브에이전트 수 배지가 어느 에이전트에도 그려지지 않는다 #810.
  • 조심해서 볼 파일: hide-agent-hooks/src/opencode/plugin.js - runs inside the operator's OpenCode. Every hook has a budget and fails open except the refusal.
  • 조심해서 볼 파일: herdr-core/src/delivery/mailbox.rs - an unbelled kind with a prompt hook now takes letter bodies on any prompt. The plugin confirms later.
  • 조심해서 볼 파일: herdr-core/src/runtime/memory.rs - receipts from OpenCode's label read are recorded on one owned thread off the lock, with queues capped at 64 and 256.
  • 조심해서 볼 파일: .github/workflows/pr.yml, herdr-update.yml - the rust lane installs Node 22, because hide-agent-hooks runs the plugin under Node in its tests.
  • 비용 검토:
    • Per OpenCode prompt: one helper process, plus one count report after it.
    • Per child status change: at most one running report, with only the newest waiting.
    • Session bookkeeping is capped at 512, evicting finished children first.
    • Nothing is added on hided's high-frequency paths. The lineage pass reads one kit status instead of cloning the kit.

Evidence

  • 확인한 것: sealed suite verify-cargo.sh test and lint PASS on the final head, merged with main at drop한 lock을 descriptor를 닫기 전에 풀어 다른 thread의 child가 lock을 붙잡지 않는다 #821.
  • 확인한 것: Node plugin test, run with OpenCode 1.18.30's hook and event shapes:
    • root and child prompts;
    • deferred confirm and an unstored prompt;
    • budgets, plus slow, failing and garbled helpers;
    • spawn and question refusal, including a subagent's question;
    • background child counts;
    • more than 512 sessions.
  • 확인한 것: web/e2e/opencode-plugin.spec.ts on a private pinned Herdr 0.9.3, where the kit writes the plugin and a stand-in OpenCode in two panes loads it:
    • a letter rides the next prompt and is confirmed only once stored;
    • herdr agent start is refused;
    • Herdr's tokens and the snapshot's children.subagents.working go 1 then 0.
    • 9/9 over 3 repeats, 6/6 over 2 repeats after the last fix; with agent-adapter-layer.spec.ts (OpenCode no longer Basic) 4/4 on the merged head.
  • 확인한 것: unit tests for every file state (current, stale, edited, foreign, config folder absent, Windows); kit apply, Reinstall and switch-off; Memory receipts from synthetic parts; mailbox next-prompt pull.
  • 확인하지 못한 것: the live check with a real OpenCode (PRD D-13) ran but measured nothing (exit 3, every cell UNKNOWN):
    • run: scripts/agent-live-check.py --agents opencode, OpenCode 1.18.30, opencode-go/deepseek-v4.1-flash, private pinned Herdr 0.9.3, this branch's hided;
    • Herdr saw OpenCode idle and ready in every scene, but every screen read came back empty, so all ten scenes timed out at arrival; OpenCode draws a full-screen interface the tool's read does not return;
    • the tool loads Herdr's integration, not Hide's plugin, so the letter cell is UNKNOWN as well;
    • nothing unsafe was seen, cleanup was confirmed, and no login or operator setting was changed;
    • still unproven live: a letter and a refusal reaching the model, B8 after repeated refusals, coexistence with Herdr's plugin, Bun.
    • The event samples in tests/fixtures/opencode/events-1.18.30.json are built from OpenCode's source, not captured.
  • 확인하지 못한 것: a machine whose OpenCode reads $XDG_CONFIG_HOME loads neither Hide's nor Herdr's plugin from ~/.config/opencode (a limitation shared with Herdr).
Follow-up improvements (not needed for this contract)
  • Claude Code's hook is silenced inside OpenCode even where Hide's plugin is not working (Windows, a foreign hide.js).
  • hide inbox offers no ack_command to OpenCode; letters are confirmed by the plugin only.
  • Guidance is read once when OpenCode loads the plugin.
  • A failed confirm can deliver a letter again (at least once); SIGKILL of a helper can orphan its grandchildren; no symlink tests for hide.js.
  • done stops growing once finished children are evicted at 512.
  • No e2e for the question guard (B19) or for an idle pane receiving no input (B5); both are covered below e2e.
  • A bash command over the helper's 256 KiB input, or a call past the 8 running helpers, passes the spawn guard unchecked (it guards accidents, not a sandbox).
  • A subagent's question from a session the plugin never saw created asks about the subagent's own id, which the Factory guard does not know.
  • On a timeout the helper is killed but the hide call it started ends at its own deadline.
  • Letter ids are not checked for a leading - on pull or confirm; they come from Hide's own ledger.
  • herdr-update.yml takes actions/setup-node@v4 by tag, as the rest of the repository does.
Verification record
  • PRD: agents/prd/opencode-plugin/prd.md (sha256 91a061f42e55e18f8f0834a17d9b98c8623e8e8cdf3e8d579208af0e8b9d9448)
  • Base b33fb57 → head bb7bf9d, verified 2026-10-08T20:08:54.127Z: PASS
  • Verification report: agents/runs/opencode-plugin/verification-report.json and agents/runs/opencode-plugin/verification-report.md; source fingerprint 01745cef3e161c615ddbf9ebbd8a6d16fb839f090be81b6040ff408874b81036
  • Suites:
    • S1: GREEN bash scripts/verify-cargo.sh test (exit 0)
    • S2: GREEN bash scripts/verify-cargo.sh lint (exit 0)
  • Reviews:
  • Evidence: none registered separately.
  • Changed paths: 63 (see Files changed)
  • Delivery: mode pr, branch feat/opencode-plugin, base main

yansfil added 22 commits October 9, 2026 02:00
…sal, Memory, counts and the question guard

The adapter row names the hook kind each agent has (hook or plugin), and direct_ask_kind gives the Factory question guard the Herdr kind of every agent whose question tool can be refused. The generated web contract carries hook_kind.
hide-agent-hooks writes ~/.config/opencode/plugins/hide.js with a versioned, hashed marker and this build's helper path, and removes only an unedited file of its own. Inside a Hide-managed Herdr pane the plugin adds guidance, Memory and the pane's letters to a root session's prompt as a synthetic part, confirms the letters once OpenCode reports the part stored, refuses a herdr agent start and a Factory worker's question tool by throwing the reason, and reports subagent counts from child-session events. Each hook has a budget and an unchanged prompt past it; outside a managed pane it registers nothing.

Claude Code's hook run inside OpenCode through a settings bridge now ends silently, so nothing is taken twice. The rust lane installs Node 22 so the plugin test runs it the way OpenCode does.
The piece reads Installed, Outdated (another build, a gone helper, an older version or an edit), Removed or Absent; a pass replaces an unedited stale plugin, Reinstall replaces an edited one, and switching OpenCode off removes only Hide's unedited file. OpenCode is no longer a Basic agent.
OpenCode is never belled, so its plugin's pull takes the letter bodies on any prompt and confirms nothing; the plugin confirms after OpenCode stored the prompt. The Factory question guard accepts every runtime the adapter says can refuse its question tool.
Claude Code and Codex panes keep reading the pane diagnosis; OpenCode has no diagnosis of its own, so its hook status reads the plugin piece on the machine's kit row.
The OpenCode label read reports the receipt lines of the synthetic user parts Hide's plugin added, the label worker hands them up, and the core verifies and records them on one owned thread off the lock, with bounded queues.
agent-hooks.md gains the plugin's section and corrects the OpenCode row, delivery.md explains next-prompt letters and why the bell stays off, and ARCHITECTURE.md names the plugin piece and the receipt path.
A stand-in OpenCode loads the plugin the kit wrote into a private HOME and reports itself as Herdr's OpenCode integration does. The spec checks that a letter from another agent rides the next prompt and is confirmed only once the prompt is stored, that a herdr agent start is refused with the spawn guard's reason, and that child sessions move the counts Herdr holds for the pane.
…erdr has them

Past 512 sessions the plugin forgets the oldest finished child first and keeps the prompted root, so counts keep moving and guidance is given once. A count report Herdr did not take is sent again, and each root prompt and turn end report again. A subagent's question call asks the Factory guard about the root session Herdr knows the pane by. Prompt text is clipped to 32 KiB so a pasted log never costs the prompt its letters, and a prompt whose helper answered nothing is not marked guided. The unused installed_helper_path reader is gone.
…eipts worker restartable

The lineage pass reads the one OpenCode status it needs instead of cloning this Mac's kit snapshot on every agent event. A Memory receipt write failure is logged with its cause, and a panic in one batch no longer leaves the in-flight flag set.
An agent that is on and found, whose hook Hide could not put in because the agent has not made its configuration folder or a file of that name is not Hide's, shows that reason in one quiet line without Reinstall. UI_BEHAVIOR now gives OpenCode no Basic chip and names its piece Plugin.
The count spec now waits for the pane's children.subagents.working in the frames the page receives to go to 1 and back to 0. The stand-in's command and ready files are written whole and renamed, and the Herdr update workflow installs Node for the plugin test.
…count report

At the session limit the plugin keeps the root and every line a running child is counted through. Count reports run one at a time with only the newest waiting, are sent after the prompt's own helper rather than beside it, and a turn's end reports once. Guidance and the session-start Memory are given together only when the helper answers, and prompt text is made well formed before it is sent. The limit test now fires events as OpenCode does and asserts the last report, and the prompt-budget test bounds the wait at 3.5 s again.
Every test in the hide-platform binary shares one process under cargo test,
so the test process's tree also held the children of tests running beside
it and the count moved by one under load.
@yansfil
yansfil merged commit facaaa5 into main Oct 8, 2026
41 of 43 checks passed
@yansfil
yansfil deleted the feat/opencode-plugin branch October 8, 2026 20:49
yansfil added a commit that referenced this pull request Oct 8, 2026
Related: #769 (P3), #810, #818

## Summary

Grok과 Cursor는 지금까지 hide의 기본 단계라 셸에서 `herdr agent start`로 hide의 책임 기록을
우회해도 막히지 않았고, 서브에이전트 수도 보이지 않았습니다.
이 PR은 두 에이전트가 공식 문서로 제공하는 hook에 hide 항목을 설치해 실행 차단(spawn guard)과 서브에이전트
수를 `Claude Code`와 같은 수준으로 줍니다.

- Grok: hide 소유 파일 `~/.grok/hooks/hide.json`을 Herdr, Orca 파일 옆에 둡니다.
이벤트는 `SessionStart`, `PreToolUse`(matcher
`Bash|ask_user_question|exit_plan_mode`), `SubagentStart`,
`SubagentStop`, `Stop`입니다.
- Cursor: 함께 쓰는 `~/.cursor/hooks.json`에 hide 표지(`hide-guidance@2`)가 있는
항목만 더하고 지웁니다. 이벤트는 `sessionStart`, `preToolUse`(`Shell`),
`subagentStart`, `subagentStop`, `stop`입니다.
- 거절은 각 에이전트의 모양으로 합니다. Grok은 `Claude Code`의 envelope을, Cursor는
`{"permission":"deny","agent_message":...}`을 씁니다. Cursor의 권한 hook은 거절하지
않는 모든 경로에서 `{"permission":"allow"}`를 냅니다.
- Grok 안에서는 hide의 `Claude Code` hook과 Cursor 항목이 조용히 끝나므로, 한 사건은 한 번만
셉니다(`GROK_HOOK_EVENT`).
- 코어는 #818의 dialect 기준 설계를 그대로 따라, Grok/Cursor pane의 계측 여부를 OpenCode
플러그인처럼 그 에이전트 행의 hook 조각으로 판정합니다(`kit_hook_status`).
- 운영자가 고친 hide 항목은 "edited" 사유와 함께 Outdated로 보이고 Reinstall 전까지 그대로 둡니다.
#818의 OpenCode 플러그인과 같은 규칙입니다(B8).
- 에이전트 폴더가 없으면 아무것도 만들지 않고, 행이 #818의 대기 줄로 그 이유를 보입니다(B8).
- Factory 질문 가드는 adapter 표가 `direct_ask`를 선언한 에이전트에만 갑니다. hook, CLI,
daemon 소켓이 같은 표(`direct_ask_kind`)를 읽습니다. Grok은 실측 전이라 Unconfirmed로 두고,
그 질문은 그대로 뜹니다.

화면: Settings `기본` 칩 팝오버의 실행 차단과 서브에이전트 수가 Grok/Cursor에서 `✓`로 바뀝니다. 폴더가
없을 때는 Grok/Cursor 행에 "Hook: Grok has not created …/.grok yet; the hook
is put in once it has" 줄이 Reinstall 없이 보입니다(격리 e2e 스크린샷으로 확인, 이미지는 run
디렉터리에 둠).

## Review

- **판단해 주세요**: Grok 파일은 PRD D-01의 이벤트에 `SessionStart`를 하나 더 등록합니다.
서브에이전트에서는 불리지 않는 이벤트라 pane 수를 새로 시작하고 계측 token을 쓰는 자리로 씁니다(lead 승인).
- **판단해 주세요**: 사이드바 수 배지는 어느 에이전트에도 그려지지 않습니다(#810). 이 PR은 `Claude
Code`와 같은 수준, 곧 스냅샷 `children.subagents`까지만 맞춥니다(lead 결정).
- **판단해 주세요 (B8)**: #818 위에서 B8을 맞췄습니다. 폴더가 없을 때의 이유는 Grok/Cursor 행에 대기
줄로 보이고(Reinstall 없음), 고친 항목은 Outdated와 "edited" 사유로 보이며 Reinstall이
되돌립니다. 다음 pass는 고친 항목을 덮어쓰지 않습니다. 둘 다 e2e가 실제 행에서 확인합니다.
- **판단해 주세요 (D-14, B13)**: Grok의 질문 도구가 `PreToolUse`에 오는지 아직 실측하지 못해
`direct_ask`는 Unconfirmed입니다. 그래서 Factory 작업자 pane의 Grok 질문은 지금 그대로 뜹니다.
matcher와 읽기 코드는 남겨 두었으니, 로그인된 Grok으로 실측한 뒤 칸을 Available로 바꿀지
Unavailable로 두고 코드를 지울지 정해 주세요.
- **조심해서 볼 파일**: `hided/src/server.rs` `factory_question_guard` - 소켓 허용
목록을 `direct_ask_kind`로 바꿨습니다. main에서는 `claude-code|codex`만 받아 OpenCode
플러그인의 질문 가드가 `invalid_request`로 떨어져 질문이 그대로 떴습니다. 이 PR에서 OpenCode도 받습니다.
- **조심해서 볼 파일**: `hide-agent-hooks/src/bin/hide-agent-hooks.rs`
`run_basic_hook` - failure path. Cursor가 잘못된 출력을 거절로 읽으므로 allow가 빠지는 경로가
없어야 합니다.
- **조심해서 볼 파일**: `hide-agent-hooks/src/guidance.rs` - 운영자 소유 파일을 쓰는 유일한
코드입니다. 다른 도구의 바이트 보존과 `@1`에서 `@2`로의 교체를 봐 주세요.
- **조심해서 볼 파일**: `hide-kit/src/lib.rs`, `agent_kit.rs` - 새
`Observed::Edited`. `Claude Code`/Codex hook 부품은 Edited를 만들지 않으므로 그 동작은
그대로입니다.
- **조심해서 볼 파일**: `hide-agent-hooks/src/counters.rs` - 모든 count 사건이
`panes.lock` 배타 잠금(1초 대기)을 거치고, 바뀌지 않는 사건은 공유 잠금으로 읽습니다. `Claude Code`와
`Codex`도 같은 경로입니다.
- **조심해서 볼 파일**: `herdr-core/src/runtime/agents.rs`, `runtime/kit.rs` -
`Mutex<Runtime>` 안의 일입니다. Grok/Cursor는 OpenCode와 같이 kit 행의 hook 조각을
pass당 한 번 읽고, 조각이 바뀔 때만 lineage를 다시 맞춥니다.
- **비용 검토**: hook 사건당 잠금 한 번과 기록 쓰기 한 번이 듭니다(fsync 없음). 기록이 보내는 사이 바뀌었으면
보고를 한 번 더 합니다. 상시 작업과 틱 작업은 없습니다.

## Evidence

- **확인한 것**: `hide-agent-hooks/tests/it/grok_cursor_hooks.rs`는 빌드된 도우미를
각 에이전트의 문서 payload, 가짜 `hide`, 가짜 Herdr 소켓과 함께 돌립니다. 확인한 항목은 다음과 같습니다:
  - 거절 모양;
- Cursor allow (pane 밖, 미등록, daemon down/mute/later/slow, 읽을 수 없는
payload, owner handshake 실패);
  - Grok 질문 도구가 가드를 묻지 않고 그대로 뜨는 것;
  - 서브에이전트 수 (Grok 배경 서브에이전트 유지, 서브에이전트 자신의 Stop 무시);
  - Grok 안에서 세 hook이 한 번만 세는 것.
- **확인한 것**: `web/e2e/grok-cursor-hooks.spec.ts`(5개)는 격리 Herdr와 kit를 돌리는
hided, 개인 HOME 위에서 main 병합 후 통과했습니다. 확인한 항목은 다음과 같습니다:
  - 스위치가 hide 항목만 쓰고 지우며, 다른 도구의 바이트가 그대로인 것;
- 지운 hook이 "Hook: Removed"로, 고친 hook이 "edited" 사유로 행에 보이고 Reinstall로
돌아오는 것;
- Grok과 Cursor 폴더가 없으면 아무것도 만들지 않고, 두 행이 "has not created …" 대기 줄을
Reinstall 없이 보이는 것;
  - 설치된 명령 그대로의 거절과 allow;
  - Herdr가 grok/cursor로 분류한 pane의 스냅샷 수;
  - Grok 환경에서 한 번만 세는 것.
- **확인한 것**: Cursor CLI 2026.10.01 번들의 hook 실행 코드를 읽었습니다. 명령은 셸로 돌고,
exit 2와 JSON이 아닌 출력만 막습니다. 다른 exit와 빈 출력은 `failClosed`가 없으면 진행하므로, 도우미가
사라져도 막히지 않습니다.
- **실측 결과 (`scripts/agent-live-check.py --agents grok,cursor`, 격리 Herdr
0.9.3, 이 worktree의 hided, 2026-10-09 06:19-06:33 KST)**: 로그인과 운영자 설정 변경
없이 한 번 돌렸고, exit 3이었습니다. 표는 보고서 그대로입니다.
- grok 1.0.46, 모델 `grok-4.5`: 판정 `unsafe`, 선언된 bell `False`. `grok
models`가 "You are not authenticated."를 답했고, 화면은 "Connection failed |
Retrying"이었습니다. 장면은 startup reached/settings_write, working·model_picker
reached/ambiguous이고, 나머지 7개는 timeout/not_tested입니다.
- cursor 2026.10.01-e373342, 모델 `gpt-5.3-codex-low`: 판정 `unknown`, 선언된
bell `False`, loaded integration
`not_observed`(`global_hooks_not_excluded`). 모든 장면이 "Do you trust the
contents of this directory?" 화면에 머물렀습니다. 장면은
startup·working·model_picker·mcp_approval reached/ambiguous이고, 나머지 6개는
timeout/not_tested입니다.
- 정리: `cleanup.confirmed=true`, 공유 설정 변경 0, 자격 사본 제거. Cursor가 자기 상태 폴더
9개를 `~/.cursor/projects/` 아래에 만들었고(일회용 probe 폴더용), 지우지 않았습니다.
- 두 에이전트 모두 bell은 그대로 꺼 둡니다. 이 도구는 bell 안전성을 재며 hide의 hook을 실제 에이전트에
설치하지 않으므로, 아래 hook 동작은 이 실측으로 확인되지 않았습니다.
- **확인하지 못한 것**: 실제 Grok과 Cursor에서의 hook 동작입니다. 확인할 것은 다음과 같습니다:
  - Grok이 `Claude Code` 호환 hook과 Cursor 항목에도 `GROK_HOOK_EVENT`를 주는지;
  - Grok의 deny envelope과 빈 출력 처리;
  - `ask_user_question`과 `exit_plan_mode`가 `PreToolUse`에 오는지 (D-14);
  - `Stop` 페이로드 모양;
  - 자식 세션의 `SubagentStop`이 부모 pane에 닿는지;
  - Cursor `stop`이 서브에이전트 안에서도 불리는지, 도우미가 없을 때 빈 출력으로 진행하는지.
  Grok은 로그인이 필요하고, Cursor는 trust 화면을 넘길 준비가 필요합니다.
- **확인하지 못한 것**: Windows입니다. 이 hook은 Windows에 쓰지 않습니다(셸 명령, 두 문서 모두
Windows 형태 없음).
- **확인하지 못한 것**: OpenCode 질문 가드가 실제 daemon 소켓을 거치는 경로입니다. 테스트는 `hide`를
대역으로 둡니다.

<details><summary>추가 증거</summary>

- 리뷰: native subagent로 Fidelity, Code/Security, 후속 리뷰 4회를 돌렸습니다. Fix
now는 모두 반영했습니다:
  - 보고 순서;
  - `GROK_SESSION_ID`만으로 `Claude Code` hook이 꺼지던 문제;
  - 잠금 파일 권한;
  - lock 아래 kit 복제;
  - 잘린 기록 경합;
  - CI의 잠금 대기 초과: fsync 제거, 공유 잠금 재읽기;
  - #818 병합 후 daemon 소켓의 질문 가드 허용 목록.
- 마지막 후속 리뷰의 나머지 판단:
- Grok 셸에서 띄운 `Claude Code`의 실행 차단은 main
계약(`inside_another_agents_session_the_guard_stays_out`)대로 꺼진 채 두고, 주석만
바로잡았습니다.
- Follow-up: 이벤트 하나만 지운 항목은 Outdated로 다음 pass가 되돌림. 항목 바이트를 버전에 묶는 테스트.
- 이 브랜치와 무관한 flaky 테스트 하나를 함께 고쳤습니다(`hide-platform` 자손 수 비교).
- Follow-up:
  - `observe_guidance`가 pass당 파일을 세 번 읽음;
  - 잠금 실패 문구가 소켓 실패처럼 읽힘.

</details>
yansfil added a commit that referenced this pull request Oct 9, 2026
Related: P5 OpenCode plugin #818 (이 PR이 그 위에 쌓은 플러그인 설치기와 helper), P6
session readers #804, Pi reader #826 (머지됨, 이 브랜치에 병합)

## Summary

Pi와 omp 안에서 실행된 에이전트는 지금까지 Hide의 편지, 실행 가드, 하위 에이전트 수 없이 기본 지원(스킬과 Herdr
통합)만 받았습니다.
이 PR은 두 에이전트의 사용자 확장 폴더(`~/.pi/agent/extensions/hide.ts`,
`~/.omp/agent/extensions/hide.ts`)에 Hide 확장 하나를 같은 원본으로 설치합니다.
확장은 pane 자신의 TUI 세션에 첫 프롬프트 안내와 대기 편지를 숨은 메시지(`display: false`)로 붙이고,
호스트가 그 메시지와 답을 기록한 뒤에만 편지를 확인합니다.
셸에서 Herdr로 에이전트를 직접 띄우려는 호출은 Claude Code 훅과 같은 사유로 막고, omp에서는 서브에이전트 수를
Herdr에 보고하고 Factory 작업자의 `ask`를 Factory 질문 가드에 넘깁니다.
OpenCode 플러그인의 파일 처리는 세 파일이 함께 쓰는 소유 스크립트
파일(`hide-agent-hooks/src/plugin.rs`)로 일반화했고, 세션 한도는 세션 파일 경로를 담도록 한
규칙(4096바이트)으로 모았습니다.
그래서 설정의 Pi와 omp 행에서 `기본` 칩이 사라지고(PRD D-10, B1), P6의 Pi 세션 읽기와 합쳐진 Pi 행은
켜져 있으면 `Ready` 또는 `N sessions`를 보입니다.
벨은 두 에이전트 모두 꺼 둔 채이고, Memory는 P6의 omp 세션 읽기까지 머지된 뒤 따로 들어갑니다.

## Review

- **판단해 주세요**: 확장은 Herdr pane 환경 변수만 보고 동작합니다(Hide 데몬이 그 Herdr를 소유하는지는
묻지 않음). PRD D-02/B11은 "Hide가 관리하는 pane"이라 쓰지만 Claude Code, Codex CLI 훅과
OpenCode 플러그인이 이미 같은 방식이라 맞췄습니다. 데몬이 없으면 helper가 `{}`를 답합니다.
- **판단해 주세요**: OpenCode 동작 변화 하나. main의 hided는
`factory_question_guard`에서 `claude-code`와 `codex`만 받아 OpenCode의 질문 가드
요청이 wire에서 거절됐고, 그래서 Factory 작업자의 질문이 그대로 보였습니다. 이제 질문 도구를 선언한 모든 런타임을
받으므로 OpenCode 작업자의 질문도 설계대로 막힙니다.
- **판단해 주세요**: 화면 변화. 어댑터 규칙(`basic()` = 프롬프트 받기나 실행 거절 중 하나라도 없음)에 따라
Pi와 omp는 `기본` 칩을 잃습니다. #818에서 OpenCode가 같은 규칙으로 바뀐 것과 같고 PRD가 정한 결과입니다.
main의 설정 e2e 세 개(`agent-adapter-layer`, `agents-follow-herdr`,
`agents-tab`)가 omp 칩을 기대해 CI가 실패했고, 기대를 새 규칙으로 고쳤습니다(이제 `기본`은 Grok과
Cursor뿐).
- **판단해 주세요**: #811 병합 결과. `HookDialect`에 Pi, omp와 Grok, Cursor가 함께 있고,
기능 표는 두 쪽을 합쳤습니다(Grok, Cursor는 실행 가드와 하위 에이전트 수만, 편지는 없음, 그래서 계속 `기본`).
Factory 질문 가드 wire는 이 PR의 4096바이트 세션 한도와 main의 `direct_ask_kind` 판정을 함께
씁니다(`claude-code`, `codex`, `opencode`, `omp`).
- **판단해 주세요**: #826 병합 결과. Pi 선언은 이 PR의 hook, prompt_hook, spawn_guard와
P6의 session, sleep, fork, resume, conversation, titles를 모두 가집니다. Pi 세션은
`reports_turns`가 아니므로 편지가 턴 대기로 묶이지 않고, 확장이 쓰는 숨은 메시지(`role: custom`)는
Pi 리더에서 사람 입력으로 읽히지 않습니다.
- **조심해서 볼 파일**: `hide-agent-hooks/src/pi_extension/extension.js` - 운영자의
Pi와 omp 프로세스 안에서 돕니다. 모든 콜백이 자기 예외를 잡고(omp는 타이머 콜백 예외로 세션이 끝남), 모든
helper 호출이 예산과 개수 상한을 가집니다.
- **조심해서 볼 파일**: `hide-agent-hooks/src/plugin.rs`,
`src/plugin/helper.rs` - 운영자 소유 폴더에 쓰는 코드이고 OpenCode와 공유합니다. OpenCode
파일의 바이트는 고정 테스트가 그대로임을 보입니다.
- **조심해서 볼 파일**: `herdr-core/src/runtime/factory.rs`,
`hided/src/server.rs`, `herdr-core/src/runtime/delivery.rs` - 세션 한도 256
-> 4096바이트(failure path). 해시 전에 길이를 검사합니다.
- **비용 검토**: 셸 호출마다 `herdr` 문자열 검사 한 번, 그 문자열이 있을 때만 helper 1회(2.5초 예산).
프롬프트마다 helper 1회(1.85초), 확인 1회(2초). 동시 helper 8개, 출력 64KiB, 대기 항목
16개(10분), 하위 에이전트 64개 상한. 세션 종료 때 진행 중인 prompt, tool, start helper를
끊습니다.

## Evidence

- **확인한 것**: sealed `verify-cargo.sh test`와 `lint` PASS(head a8996db).
herdr-core, hided, hide-agent-hooks, hide-kit, hide-agent-adapter 전체
nextest 3585개 통과(#826, #811 병합 뒤).
- **확인한 것**: Node 22+에서 생성된 확장을 실제 Pi 1.0.4, omp 18.7.0에서 잡은 사건 표본으로 재생:
밖에서는 등록 안 함, 숨은 메시지 모양, 답 뒤 한 번만 확인, 실패한 확인의 재시도, omp 재진입에서도 안내 유지, 예산,
omp 수와 `ask`, 어떤 입력에도 예외 없음.
- **확인한 것**: Playwright e2e(고정 Herdr 0.9.3, 격리 서버)에서 kit이 두 파일을 쓰고 Pi와
omp 대역 host가 이를 읽음: 양방향 편지와 기록 후 확인, 두 에이전트의 실행 거절 사유, omp 서브에이전트
수(Herdr 토큰과 snapshot), 서브에이전트 프롬프트에는 편지 없음. 확인 호출을 지운 결함을 심으면 실패함을 확인.
- **확인한 것**: 실제 Pi 1.0.4와 omp 18.7.0 TUI를 pty로 띄워(비공개 HOME, 가짜 provider,
대역 helper) 확장 파일 그대로 실측: start, prompt, confirm 순서, 숨은 메시지가 세션 파일에
`display:false`와 `details.hide`로 남고 화면에는 그려지지 않으며 모델에는 닿음, omp TUI의
`ctx.mode`는 `tui`, Pi RPC 모드에서는 helper 호출 0.
- **확인하지 못한 것**: 로그인된 에이전트로 한 실측. `scripts/agent-live-check.py --agents
pi,omp`를 격리 Herdr에서 돌렸지만 두 에이전트 모두 `not_authenticated`였습니다. Pi는 startup
장면만 닿아 판정 `unsafe`(벨 뒤 비공개 설정 쓰기), rest는 시간 초과, 나머지는 건너뜀. omp는 모든 장면
건너뜀. 로그인은 하지 않았고 벨은 꺼 둡니다.
- **확인하지 못한 것**: 실제 omp의 재진입과 실제 서브에이전트 수(합성 사건으로만), 사이드바 배지 표시(issue
810), 기기에서 도는 Pi와 omp, Windows(확장을 쓰지 않음), Memory(P6 뒤 별도 PR).
- **확인한 것**: 고친 설정 e2e 세 개, `pi-omp-extension`, `opencode-plugin`, P6의
`session-readers`와 `link-graph`를 병합한 트리에서 로컬 통과. `pi-omp-extension`은 20회
중 1회 `native_identity_required`(코어가 pane의 세션을 아직 못 들음)로 실패해, 두 pane에서
`hide inbox`가 답할 때까지 기다리도록 고친 뒤 24회 모두 통과.
- **확인하지 못한 것**: sealed 실행에서
`spawn_guard::a_pane_run_or_send_text_launch_leaves_the_name_and_intent_for_the_agent`가
한 번 빈 stdout으로 실패했고 단독 3회, 전체 binary 2회는 통과했습니다(이 PR이 건드리지 않은 테스트,
`bell_intake`와 같은 부하 기한 부류).
- **확인하지 못한 것**: sealed 실행 한 번에서
`bell_intake::a_prompt_that_only_starts_like_the_bell_is_an_operator_prompt`가
0.5초 payload 읽기 기한을 넘겨 실패했고, 단독과 이후 네 번은 통과했습니다. 같은 binary에서 두 Node 테스트가
동시에 돌던 것을 순서대로 돌게 바꿨습니다.

<details><summary>Verification record</summary>

- PRD: `agents/prd/pi-omp-extension/prd.md` (sha256
676a51347370bcc57965ce68ef407ee2585d2fdab6d3c30b64a5ce9ff7113f7d)
- Base ba980fa → head a8996db, verified 2026-10-09T00:08:11.704Z: PASS
- Verification report:
`agents/runs/pi-omp-extension/verification-report.json` and
`agents/runs/pi-omp-extension/verification-report.md`; source
fingerprint
af86a6093a02254b19bcf251c29d027666767d7cd5d857f3bd2d85198399727a
- 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, Security on 274e824: Fix now = Factory 질문 가드의 256바이트
세션 한도(세 리뷰 모두), 확인 전 confirmed 기록(세 리뷰 모두), 준비 시점에 안내를 준 것으로
기록(Fidelity, Code), omp RPC를 pane의 루트로 셈(Security), 문서의 범위 과장(Fidelity).
모두 3236fdd, 95e9876, a301065, 4e5808444에서 고침.
- Follow-up on 4e58084: 고친 8건 모두 닫힘, 새 코드 결함 없음; head에서 omp TUI 재실측,
치환 순서 테스트, 문서 한 문장 요청 -> 2ed0090f4에서 처리.
  - Follow-up on 2ed0090: 새 테스트의 rustfmt 위반 -> d5fbf81. 
- Follow-up on 37b60ff: fmt 닫힘, 두 Node 테스트를 순서대로 돈 변경은 결함을 가리지 않는 부분
완화, main 병합(#832)은 상호작용 없음; Fix now 없음. bell_intake는 `cargo test` 레인에서
재발할 때 issue로(그때는 부하에 기대지 않는 payload 기한으로 고침).
- Follow-up on 1337720 (CI 설정 spec 수정): Fix now 없음; UI_BEHAVIOR 세션 수
문장과 AgentsTab 단위 테스트의 omp 모델링 -> da63cfd.
- Follow-up on 27c8409 (#826 병합): Fix now = UI_BEHAVIOR의 Pi `Basic
popover` 문장 -> 고침. 낡은 주석 둘, factory.md 작업자 문단, 단위 테스트 fixture도 함께 고침. 잠든
Pi 부모의 계보(경로 digest vs native id)는 P6 영역의 Follow-up.
- Follow-up on 30d351f: Fix now = factory.md 작업자 문단이 Pi의 sleep과
OpenCode, Pi, omp의 다음 프롬프트 편지를 뭉갬 -> 54af6dc14에서 기능별로 나눠 고침, model.rs
주석도 실제 이유로.
  - Closure on 54af6dc: 두 항목 닫힘, Fix now 없음.
- Follow-up on 428ac77 (#811 Grok, Cursor hooks 병합): Fix now 없음; 안 쓰는
`HookDialect::plugin()` 삭제, kit hook status와 질문 가드 parse 테스트에 Pi, omp
추가, 문서와 테스트 이름 정리 -> 32f9e2c.
- Closure on 32f9e2c (+ main #842, #844 병합 a8996db): 닫힘, Fix now 없음.
- Follow-up improvements: 잠든 Pi 부모 아래 자식의 계보가 깨어날 때까지 끊김(`SleepRecord`에
살아 있던 행의 계보 digest 보관), Herdr pane이면 Hide 데몬 여부와 무관하게 동작(OpenCode 플러그인과
같음), 다음 프롬프트 편지 pull이 pane 자신의 세션인지 코어에서 확인, 256KiB를 넘는 herdr 셸 명령,
symlink로 된 hide.ts, Memory 전 프롬프트 본문 전달, 확장 미동작 에이전트의 편지 대기, CI 부하에서
Node 기동과 제품 예산의 경쟁.
- Evidence: 13 registered (9 log, 4 file); paths are local to the run
directory
  - agents/runs/pi-omp-extension/evidence/host-smoke/README.md
- agents/runs/pi-omp-extension/evidence/host-smoke/pi-helper-calls.jsonl
-
agents/runs/pi-omp-extension/evidence/host-smoke/pi-session-hidden-entry.jsonl
-
agents/runs/pi-omp-extension/evidence/host-smoke/omp-helper-calls.jsonl
-
agents/runs/pi-omp-extension/evidence/host-smoke/omp-session-hidden-entry.jsonl
  - agents/runs/pi-omp-extension/evidence/host-smoke-tui/README.md
-
agents/runs/pi-omp-extension/evidence/host-smoke-tui/pi-helper-calls.jsonl
-
agents/runs/pi-omp-extension/evidence/host-smoke-tui/pi-session-hidden-entry.jsonl
-
agents/runs/pi-omp-extension/evidence/host-smoke-tui/omp-helper-calls.jsonl
-
agents/runs/pi-omp-extension/evidence/host-smoke-tui/omp-session-hidden-entry.jsonl
  - agents/runs/pi-omp-extension/live-check-1/report.md
  - agents/runs/pi-omp-extension/evidence/host-smoke-tui-head/README.md
-
agents/runs/pi-omp-extension/evidence/host-smoke-tui-head/omp-ctx-mode.txt
- Changed paths: 64 (see Files changed)
- Delivery: mode pr, branch `feat/pi-omp-extension`, base `main`

</details>
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