Skip to content

테스트 stand-in을 빌드마다 한 번만 시작해 부하에서 첫 실행 대기가 제품 기한을 먹지 않는다 - #815

Merged
yansfil merged 3 commits into
mainfrom
fix/first-exec-warmup
Oct 8, 2026
Merged

yansfil merged 3 commits into
mainfrom
fix/first-exec-warmup

Conversation

@yansfil

@yansfil yansfil commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Closes #813

Summary

macOS는 파일을 처음 실행할 때 파일마다 한 번 검사하고, 기기 전체의 그 검사가 한 줄로 기다립니다.
hide-platform, hide-agent-hooks, hide-kit 테스트는 helper를 복사하고 stand-in(hide, launchctl, codex, herdr, login shell)을 테스트마다 새로 써서, 부하가 있으면 그 대기가 hook 예산과 kit의 5초 기한 안에 들어갔습니다.
이제 stand-in은 body마다 빌드당 파일 하나(읽기 전용, test binary 옆 stand-ins/)이고, 프로세스마다 한 번 시작한 뒤 테스트 폴더에 hard link로 놓습니다. helper는 cargo가 만든 파일을 link합니다.
제품 기한과 assertion은 그대로이고, 테스트가 재는 구간에서 준비 비용만 빠졌습니다.

측정 (2026-10-09, load 7):  새 스크립트 첫 실행 ~90 ms, 두 번째 6 ms, 이미 실행한 파일의 hard link 5-8 ms
새 스크립트 20개 동시 실행:  하나씩 차례로 끝나 마지막이 1.8 s

Review

  • 판단해 주세요: 공유 코드는 맨 아래 crate의 hide-platform/tests/it/stand_ins.rs 하나이고, hide-agent-hooks(unit, it)와 hide-kit unit test가 #[path]로 포함합니다. 세 crate에 같은 70줄을 두는 대신 고른 것이며, 이 파일이 바뀌면 hide-platform 변경으로 세 crate의 lane이 모두 계획됩니다.
  • 판단해 주세요: READY_GUARD 60 s는 준비 단계의 hang guard입니다. 이전 5 s와 달리 파일당 빌드마다 한 번만 치르고, 어떤 제품 기한 안에도 있지 않습니다(nextest slow-timeout period와 같은 값).
  • 조심해서 볼 파일: hide-platform/tests/it/stand_ins.rs - store는 동시 test process가 같이 씁니다(persist_noclobber, 내용 대조, 64개 cap). ready는 stand-in을 --help와 임시 HOME으로 한 번 돌리므로 body는 HOME 밖 경로에 쓰면 안 됩니다.
  • 조심해서 볼 파일: spawn_guard.rs, letter_origin.rs, codex_daemon.rs, kit grok_login_shell, platform user_agents.rs - stand-in body에 박혀 있던 테스트 폴더 경로를 $HOME, ${HOME%/*}로 바꿨습니다. 실행 대상 프로그램이 HOME을 넘기는 것에 기댑니다.
  • 질문: hide-host/src/executable_fixture.rs(ETXTBSY 대응)와 install.rs의 helper 스크립트는 같은 부류지만 기한 실패 보고가 없어 바꾸지 않았습니다. 같은 store로 옮길까요?

Evidence

  • 확인한 것: 고치기 전 테스트를 load 17-21에서 돌려 hide-agent-hooks it 63개 중 8개가 warm-up 줄(spawn_guard.rs:34, letter_origin.rs:33)에서 실패하는 것을 재현했습니다. 그때 it binary는 31.6 s / 29.7 s.
  • 확인한 것: 고친 뒤 verify-cargo.sh test-scoped를 load 8-35에서 hooks와 kit 11번, main(보호된 작업 반복 테스트가 프로세스 전체 자손 수 대신 자기 자식만 확인한다 #812 포함) 위로 rebase한 뒤 platform, hooks, kit 함께 3번(load 16-26) 돌려 모두 통과(it 63개 5.5-9.1 s, kit 148개 19-41 s; 고치기 전 kit 58.8 s).
  • 확인한 것: rebase 뒤 verify-cargo.sh nextest -p hide-platform -p hide-agent-hooks -p hide-kit가 load 14-20에서 4번 모두 567개 통과. 고치기 전 load 31 nextest에서 codex_daemon unit test 2개가 같은 이유로 실패해 포함했고, user_agents::fixture_inspection_failure_does_not_attempt_a_bootout도 부하 실패 보고가 있어 포함했습니다.
  • 확인한 것: verify-cargo.sh lint(fmt, workspace clippy -D warnings) 통과. 이 Mac에서 target/, $TMPDIR, /tmp는 같은 장치라 모든 배치가 hard link입니다.
  • 확인하지 못한 것: Linux와 Windows는 CI에 맡깁니다. Linux에서 store와 fixture 폴더가 다른 filesystem이면 copy 후 한 번 시작하는 경로를 타는데, 이 Mac에서는 그 경로가 실행되지 않았습니다.
  • 확인하지 못한 것: nextest 4번 중 1번이 테스트 하나를 "leaky"(통과, 끝난 뒤 handle이 남음)로 표시했고 어느 테스트인지 다시 잡지 못했습니다.
  • 확인하지 못한 것: delivery::tests::diagnostic_claim_precedes_output_and_repeated_cause_is_suppressed가 한 번 실패하고 재실행에서 통과했습니다. 0초 대기 file lock을 다른 thread의 fork가 상속한 descriptor로 잡는 다른 부류로 보이며, 이 PR은 고치지 않았습니다.
  • 확인하지 못한 것: 부하는 다른 작업자의 빌드가 만든 것이고 합성 부하는 걸지 않았습니다. 이슈의 load 62 조건은 다시 만들지 못했습니다.

macOS checks a file the first time it starts, once per file, and the checks
of every process on the machine wait in one line. The hook tests copied the
helper and wrote their stand-in `hide` afresh per test, and the kit tests
wrote `launchctl`, `codex`, `herdr` and login-shell stand-ins per fixture,
so under load the first start queued inside the hook budget or the kit's
5 s deadlines (issue 813).

Each stand-in is now one read-only file per body in the build folder,
started once per process under a hang guard before a test is given it, and
a test's folder holds a hard link to it; the helper is linked from the file
cargo built. The four `warm_first_exec` copies and `version_program` are
gone.
The `codex_daemon` unit tests wrote their stand-in `codex` afresh per test
and ran it under its 5 s deadline, the same queue as issue 813; under
nextest at load 31 two of them failed. The store now lives in
hide-agent-hooks/src/stand_ins.rs, built only into tests: this crate's unit
and integration tests and hide-kit's unit tests include the one file. It
keeps one read-only file per body beside the build's test binaries and puts
a hard link, or a copy started once across filesystems, where a test needs
the program. docs/TESTING.md states the rule.
… test

hide-platform's `fixture_inspection_failure_does_not_attempt_a_bootout`
wrote its `launchctl` stand-in afresh and ran it under the login agent's
5 s deadline, the same queue as issue 813, and failed under load with no
`calls` file. The store's one file now lives in
hide-platform/tests/it/stand_ins.rs, the bottom crate, so a change to it
plans the lanes of every crate that includes it; hide-agent-hooks and
hide-kit include it by `#[path]`.
@yansfil
yansfil force-pushed the fix/first-exec-warmup branch from a4b2788 to aa5aee4 Compare October 8, 2026 18:48
@yansfil
yansfil merged commit 404a09c into main Oct 8, 2026
22 checks passed
@yansfil
yansfil deleted the fix/first-exec-warmup branch October 8, 2026 19:09
yansfil added a commit that referenced this pull request Oct 8, 2026
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 #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).

<details><summary>Follow-up improvements (not needed for this
contract)</summary>

- 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.

</details>

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

- 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:
- Fidelity (full contract, earlier head): Fix now items fixed before the
follow-up rounds; closure confirmed, nothing blocking.
- Code (full contract, then follow-ups through the merge with main): Fix
now items fixed (plugin eviction, report coalescing, root lookup for
question, receipts off the lock); nothing blocking on the merged head.
- Security (on the merged head): Fix now 1, a letter or Memory line
could close the plugin's own reminder tags; fixed with a test that fails
without the fix. Six hardening follow-ups listed above.
- Code follow-up (after merging #815/#816/#817): Fix now 1, the OpenCode
tests copied or wrote the programs they start, against TESTING.md rule
8; converted to the build's stand-ins. Merge resolutions confirmed.
- Evidence: none registered separately.
- Changed paths: 63 (see Files changed)
- Delivery: mode pr, branch `feat/opencode-plugin`, 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.

hide-agent-hooks와 hide-kit 테스트의 첫 실행 준비 5초 기한이 부하에서 실패해 검증을 막는다

1 participant