Skip to content

OS 경계 5: Windows 파이프 리스너가 연결 후 떠난 클라이언트에 막히지 않게 하고, hided를 Windows에서 시작합니다 - #331

Merged
yansfil merged 12 commits into
mainfrom
platform/win-start
Oct 3, 2026
Merged

yansfil merged 12 commits into
mainfrom
platform/win-start

Conversation

@yansfil

@yansfil yansfil commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Refs with-hide/hide-private#103
Closes #315

Summary

OS 경계 5번째 조각입니다. Windows 파이프 리스너가 연결했다 떠난 클라이언트에 막히던 문제(#315)를 고치고, hided를 Windows에서 시작합니다.
리스너는 파이프 인스턴스 4개를 각자 overlapped ConnectNamedPipe로 대기시키고, 전용 스레드가 떠난 연결을 치우며 연결된 것은 최대 64개까지 큐에 쌓습니다.
pane bootstrap 리스너를 hide_platform::ipc 위로 옮겨 Windows 거부를 없앴고, main에서 깨져 있던 Windows 컴파일(state_move.rs, hide-kit 테스트)도 고쳤습니다.
Windows CI가 고정 Herdr v0.9.1로 증명합니다. hided가 뜨고 /health에 답하며, /ws로 연 pane에 친 줄이 터미널 스트림으로 돌아옵니다.
화면 변경은 없습니다.

GET /health -> {"pid":4776,"schema_version":2,...}
create_workspace -> pane w1:p1 -> terminal.session_ready "terminal control session ready in 17 ms"
key "echo hide-proof-\"ok\"\r" -> screen: echohide-proof-"ok"hide-proof-ok   (PowerShell)

Review

  • 판단해 주세요: Windows 스트림 양 끝을 interprocess 대신 자체 Pipe로 바꿨습니다. interprocess는 handle을 ReOpenFile로만 감싸고, 그 재열기가 인스턴스 여럿일 때 두 번째 연결이 됩니다.
  • 판단해 주세요: 쓴 끝은 닫기 전에 별도 스레드에서 FlushFileBuffers합니다(interprocess와 같은 방식). 읽지 않는 상대가 있으면 그 스레드가 상대가 떠날 때까지 남습니다.
  • 판단해 주세요: 옛 Mac 상태 폴더 이동(state_move.rs)은 Unix 전용으로 두었습니다. Windows 빌드는 그 폴더를 쓴 적이 없습니다.
  • 판단해 주세요: windows check는 여전히 verify의 needs 밖입니다. 컴파일은 이제 통과하니, desktop 단위 테스트 20개가 고쳐지면 승격할 수 있습니다.
  • 조심해서 볼 파일: hide-platform/src/ipc.rs Windows sys - failure path. unsafe Win32(overlapped connect, CancelIoEx 후 대기, 이벤트 재설정)입니다.
  • 조심해서 볼 파일: hided/src/pane_auth.rs serve - 블로킹 accept를 전용 스레드에서 돌려 tokio로 넘깁니다. 종료 시 guard가 닫습니다. runtime lock 밖입니다.
  • 조심해서 볼 파일: hided/src/workspace_cli.rs - Windows 파이프의 Unsupported 쓰기 타임아웃을 "타임아웃 없음"으로 읽습니다. 전에는 hide_unavailable이었습니다.

Evidence

  • 확인한 것: 최종 실행 37104455723(08eef17)에서 verify와 windows check가 첫 시도에 모두 통과했습니다. 재실행은 없습니다.
  • 확인한 것: Windows os contract가 전부 통과했습니다. ipc 24개(Windows에서 LocalListener가 연결 후 즉시 끊는 클라이언트 반복에 막힙니다 #315 테스트 3개, 연결 하나는 연결 하나, 드롭 직전 답 전체 도착 포함)입니다.
  • 확인한 것: Windows windows check에서 pane_auth 6개, handshake 21개, hided real_herdr 1개가 통과했습니다. bootstrap 왕복 테스트도 포함입니다.
  • 확인한 것: herdr terminal session control은 Windows에서 동작합니다(attempt 1, 17 ms). 업스트림에 보고할 것이 없습니다.
  • 확인한 것: macOS에서 ipc 25개, handshake 26개, pane_auth 8개, real_herdr 1개(zsh)와 verify-cargo.sh lint, check 스크립트 2개(workstation identity, capability readers off lock), scripts/tests 32개가 통과했습니다.
  • 확인한 것: 첫 Windows 실행에서 재열기 문제(쓰기 시 os error 232/109, 계약 테스트 멈춤)를 찾았고, 같은 테스트로 수정 후 통과를 확인했습니다.
  • 확인하지 못한 것: Windows에서 에디터로 파일 열기가 실패합니다. herdr-core/src/files.rs relative_under가 /를 기대해 file.open_failed가 납니다.
  • 확인하지 못한 것: file index는 Windows에서 src\main.rs로 답합니다. 와이어 구분자는 다음 조각의 경로 모델에서 정합니다. 두 단계는 Unix 전용으로 두었습니다.
  • 확인하지 못한 것: pane 밖 호출자의 checkout 바인딩은 Windows에서 cwd를 읽을 수 없어 caller_unavailable입니다. 실제 pane 안 호출자의 바인딩은 돌려 보지 않았습니다.
  • 확인하지 못한 것: Windows 패키지 앱, hide connect로 띄우기, desktop 창은 확인하지 않았습니다. 증명은 테스트 바이너리 안의 hided입니다.
추가 증거
  • 첫 실행(37101693352): handshake 3개 실패와 계약 테스트 멈춤. 원인은 서버 쪽 PipeStream::try_from(OwnedHandle)의 ReOpenFile로, 원래 끝이 닫혀 상대 쓰기가 "The pipe is being closed"가 됐습니다.
  • 이후 실행: 긴 상태 폴더(260자 초과)에서 bootstrap 기록을 못 만듦(os error 3) -> 테스트 폴더를 MAX_PATH 아래로 줄였습니다. fs::private의 MAX_PATH 한계는 다음 과제입니다.
  • Explorer 열기 실패는 실패 시에만 남기는 증거(코어의 마지막 editor/status)로 원인을 찾았습니다.
  • 한 번의 실행에서 slice 4의 Windows watch 계약 테스트가 생성 이벤트를 놓쳤습니다(#288에 없어 재실행하지 않음). watch가 첫 ReadDirectoryChangesW 전에 반환하던 경쟁이라, 첫 읽기 뒤에 반환하게 고쳤습니다.
  • 독립 리뷰 Fix now 1건(위 workspace_cli.rs)을 고쳤고, 후속 11건 중 9건을 반영했습니다(종료 guard, 닫힘 구분, poison, clear 실패, 문서, CI fetch, 단계 타임아웃).
  • 다음 Windows 과제(작은 것부터): opener(HIDE_OPEN_COMMAND), 원격 bootstrap 클라이언트, desktop 단위 테스트 20개, 기기 workspace bridge. 경로 모델이 실사용에는 더 급합니다.

yansfil added 12 commits October 3, 2026 14:40
… never blocks the next connect

A named pipe instance stays taken by a client that connected and left until
the server clears it, and interprocess's listener keeps one instance and
clears it only inside accept, so quick connect-and-drop clients timed out on
Windows (#315). The Windows listener now keeps four instances listening with
an overlapped ConnectNamedPipe each, served by its own thread that clears an
instance a client left and queues connected ones for accept (at most 64, like
a socket backlog).

ListenerCloser frees a blocked accept on every system (a wake socket polled
beside the listener on Unix, an event on Windows), which a daemon that
listens on a thread needs to stop.

The contract tests connect and leave 40 times with nobody accepting, 200
times against a running accept loop (each also shut down before its first
read, which replaces the pair-based stand-in), and close a waiting accept.
The one-time move of the old state folder is a Mac's history and calls
flock and Unix modes, so it is compiled on Unix only and Env names no old
folder on Windows. The kit test that runs a shell-script Node is gated
like its neighbours. Both broke the Windows check on main.
The bootstrap listener was a Unix socket and refused on Windows, so hided
could not start there. It now binds a LocalListener in a random private
folder under the temporary folder, accepts on a thread of its own that
hands each connection to the async runtime, and closes through its
ListenerCloser on shutdown. The handshake tests run on Windows, except
the ones that reach a checkout through a folder link or need a caller's
working directory, which Windows cannot read.
The handshake tests called /usr/bin/curl, which a Windows runner does not
have. They now send each request through the hyper client the crate
already lists for its tests, with the path sent as written so the
traversal case still climbs.
… in the Windows check

hided/tests/real_herdr.rs starts a private pinned Herdr, starts hided
against it, reads /health, opens a Workspace through the shell's /ws
events, sizes its pane as the shell's terminal does, and waits for a
typed line to come back on the terminal stream. When it does not, the
test runs the same `herdr terminal session control` by hand and reports
the command, its exit and its output. The Windows check now runs hided's
end-to-end tests and this test against the pinned Windows Herdr.
interprocess wraps a pipe handle only by reopening it, and a reopen
relative to a pipe handle is a new client connect. Against one listening
instance it failed and the original was kept; against the listener's four
it took another instance and closed the original end, so the peer's next
write failed with "the pipe is being closed" and the contract tests hung
in Windows CI. Both ends are now the crate's own Pipe: overlapped
ReadFile and WriteFile on the handle, the peer pid from the pipe, and an
end that wrote is flushed on a thread of its own before it closes, since
closing throws away what the peer has not read.

Two contract tests pin it on every system: one connect is one accepted
connection, and an answer written just before the end is dropped arrives
whole. The listener also gives up an instance it cannot clear, and the
contract step has a timeout of its own.
…rve ends

The hide CLI treated the Unsupported write timeout of a Windows pipe as
hide_unavailable, so no caller ever reached the bootstrap there. It is now
read as no write timeout, as the Herdr client already does. The bootstrap's
accept thread is closed by a guard when serve ends or is dropped, and an
accept that fails with ConnectionAborted before that is reported rather
than read as the daemon's own stop.
A new handshake test sends a bootstrap request through the hide CLI's own
path and expects hided's refusal, never hide_unavailable. The Explorer
test joins its paths one component at a time, because the canonical
Windows home has a \\?\ prefix after which / is not a separator; the
file index test stays Unix only, since which separator the wire carries
on Windows is not settled. The Windows check also runs the pane_auth unit
tests, and a failed Herdr fetch fails its own step.
The test makes the state folder long to pass a Unix socket's limit of
about a hundred bytes. Windows has no such limit, and hide-platform's
private files there take paths below MAX_PATH, so the bootstrap record
could not be made under a 260-character folder (os error 3). The folder
is now four segments deep on Windows and twelve on Unix.
An event the test waits on now fails with the core's last editor and
status sections, so a Windows run that gets no answer says why. The
Windows check runs hided against the pinned Herdr whatever the
end-to-end step answered, since that proof stands on its own.
…s Windows paths

Windows CI showed why the open got no tab: the core answered
file.open_failed, "The file is not inside its checkout", because
files::relative_under takes a checkout-relative path after a `/` and a
Windows path is `\`-separated. The test's refusals all hold on Windows
and still run there; the open itself waits for the Windows path model.
The Windows watcher started its first ReadDirectoryChangesW on its own
thread after watch had returned, and a folder is watched only from that
read on, so a file made right after watch could go unreported. The
contract test that does exactly that failed once in four Windows runs
("a created file ... was not reported within 2s: []"). watch now waits
until the thread has started its first read.
@yansfil
yansfil marked this pull request as ready for review October 3, 2026 07:02
@yansfil
yansfil merged commit af80a96 into main Oct 3, 2026
21 checks passed
@yansfil
yansfil deleted the platform/win-start branch October 3, 2026 07:14
yansfil added a commit that referenced this pull request Oct 29, 2026
## Summary

사이드바 내 차례가 운영자가 답해야 할 것을 빠뜨리거나 흐리게 보여 주던 문제를 고칩니다.
- 미션의 판단 대기는 Conductor 행의 질문(`판단 · …`)으로 내 차례에 들어오고, 미션 칩은 진행 수를 지킨 채
`!`만 더합니다. 맵에서 답하면 바로 빠집니다.
- 읽었지만 답하지 않은 질문은 다시 볼 것으로 옮기지 않고 내 차례에 흐리게(빈 `!`, `읽음`) 남습니다. 알림은 다시
울리지 않고, ☆는 다시 볼 것으로, `치우기`는 새 질문 전까지 치웁니다.
- 자식의 질문은 행의 `!N` 대신 루트의 질문으로 보이고, 여러 건이면 `외 N건`이 붙습니다. `!N`은 트리 팝오버에만
남습니다.
- 기다리는 행은 `대기` 대신 무엇을 기다리는지(`자식 기다림`, `CI 기다림 · PR #n`, `답장 기다림`, `백그라운드
기다림`) 말합니다.
- 라벨 프롬프트는 질문인지 끝남인지 애매하면 질문으로 봅니다(v24). 치운 질문과 끝남 뒤의 답은 id만 담은 진단으로
남깁니다.

![태스크 list
(dark)](https://github.com/yansfil/pr-assets/blob/main/hide/gen-prd-needs-you-cleanup/def38d8/session-panel-dark.png?raw=true)
갤러리 태스크 목록: 내 차례 넷째가 판단 행과 `! 미션 0/8`, 다섯째가 읽은 질문, 대기 아래 둘(`자식 기다림 · 자식
2개 작업 중`, `CI 기다림 · PR #1846`)이 원인을 말하는 대기 줄입니다.

## Review

- **판단해 주세요**: 읽은 질문의 흐림 정도(빈 `!`, 연한 줄, `읽음` 태그)가 "아직 내 차례"로 읽히는지.
- **판단해 주세요**: 맵에서 답했지만 전달이 확인되지 않은 판단도 행에서 빠집니다(맵 배너가 다시 보내기를 띄움). 행에
남겨야 하는지.
- **조심해서 볼 파일**: `herdr-core/src/runtime/plans.rs` - snapshot pull마다 도는
경로. core 질문 목록을 장부 편집 때만 다시 만들고, 같으면 행을 다시 깔지 않습니다.
- **조심해서 볼 파일**: `herdr-core/src/agent_state/turn.rs` - 루트의 선두 질문과 `외
N건` 계산, 폰 알림에서 읽은 질문을 Seen으로 보는 규칙.
- **조심해서 볼 파일**: `contracts/hided-ws.schema.json`,
`contracts/snapshot-wire-enums.json` - snapshot wire의
`ask_subject.cause`에 `mission_decision` 추가. 옛 서비스 워커는 원래 문장으로 대체합니다.
- **대기 행의 자리**: 앱에서 wait 원인이 있는 행은, 쉬는 중이면 대기 그룹에(`tasks.rs` state, 별표나
읽은 질문이 없을 때), 에이전트가 실제로 일하는 중이면 작업 중에 섭니다. 바뀐 줄은 대기 그룹 행에서 보입니다.
- **비용 검토**: Herdr 행 동기화마다 plan·mission 장부를 한 번 훑어 질문 목록을 만듭니다(장부 크기 비례,
행 수와 무관). 잠금 안 I/O 없음.
- **질문**: raised 자손 때문에만 내 차례에 있는 루트에 ☆를 누르면 지금은 별만 붙고 내 차례에 남습니다. 다시 볼
것으로 옮겨야 하는지 정해 주세요.

## Evidence

- **확인한 것**: 최종 head에서 `sasu implement verify` 통과(`verify-cargo.sh
test`, `lint`), `scripts/verify-web.sh` 통과(web 2,252개, desktop 294개).
- **확인한 것**: 미션 판단의 깔기·교체·맵 답·새 질문·해제·닫기와 동기화 직후 해제 경합을 core 테스트로 확인.
- **확인한 것**: 읽은 질문의 내 차례·폰 그룹·☆·치우기, 프로젝트 할 일에서 치운 기록 질문 제외, 선두 질문 순서와
`외 N건`, 읽은 질문 무알림을 core/hided 테스트로 확인.
- **확인한 것**: 서비스 워커가 `판단 · 줄`로 쓰고, 옛 페이지 단어나 모르는 원인은 원래 문장으로 대체함을 실제
`sw.js`로 확인.
- **확인한 것**: 부하(load 50~180) 중 verify 네 번이 이 브랜치와 무관한 테스트로 실패했고, 모두 단독
실행에서 통과해 hide-private #331-#334 quarantine으로 올렸습니다.
- **확인한 것**: 새 계약에 맞춘 Playwright 세 spec(`session-panel`, `mission-map`,
`mobile`)을 로컬 격리 Herdr로 실행해 통과.
- **확인하지 못한 것**: 격리된 후보 앱의 네이티브 화면 확인(스크린샷은 갤러리 데이터), 연결된 기기의 Conductor
행.
- **확인하지 못한 것**: 라벨 프롬프트 변경이 실제 판정에 주는 효과, `verdict.answer_after_done`
worker 단위 테스트, 데스크톱에서 판단이 한 번만 알리는지.
- **확인하지 못한 것**: 기기 행에서 ☆로 읽음 처리는 기기의 다음 동기화 때 반영됩니다(즉시 아님).

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

![태스크 list
(light)](https://github.com/yansfil/pr-assets/blob/main/hide/gen-prd-needs-you-cleanup/def38d8/session-panel-light.png?raw=true)
라이트 테마, 같은 갤러리 상태.

</details>

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

- PRD: `agents/prd/needs-you-cleanup/prd.md` (sha256
b2812e065e39a4effde7a242232e2d4c954c75ec269777e9618afa4e5e27beb3)
- Base d8da3e4 → head 3b50142, verified 2026-10-29T15:00:55.966Z: PASS
- Verification report:
`agents/runs/needs-you-cleanup/verification-report.json` and
`agents/runs/needs-you-cleanup/verification-report.md`; source
fingerprint
28ed3f64104feb33b697bca11cdfec8b1040f9f5096c50619ae3a86966059250
- Suites:
  - S1: GREEN `bash scripts/verify-cargo.sh test` (exit 0)
  - S2: GREEN `bash scripts/verify-cargo.sh lint` (exit 0)
- Reviews:
- Fidelity (77d2707, follow-ups on 119d783 and 70ddb04): Fix now
B3 decision answered from the map stayed in 내 차례 (fixed, 6f2032c) and
stale `! N` docs (fixed, 119d783); Follow-up ☆ on a root held only by
a raised descendant and phone/Overview without `외 N건` stand for the PRD
owner; 70ddb04, def38d8 (gallery) and 3b50142 (e2e expectations):
no Fix now; optional Follow-up: assert the Conductor row in the tree's
raised 내 차례 band and the first needs_you row by pane in e2e.
- Code (77d2707, follow-ups on 119d783 and 70ddb04): Fix now
put-away record ask still listed in 할 일 (fixed, bd989fc) and thin core
tests (added, 86887cb); Follow-up relay cost, laid-ask stamp, answered
decision, legacy date and diagnostics order fixed (6f2032c, bd989fc,
71cfa43); sync race found on follow-up fixed (70ddb04); 70ddb04
and def38d8 (gallery): no Fix now or Follow-up; 3b50142 (e2e
expectations): no Fix now, Follow-up: `session-panel.spec` no longer
pins which 내 차례 row sorts first (pin it in a `Tasks::settle` test).
- Evidence: 2 registered (2 screenshot); paths are local to the run
directory
  - agents/runs/needs-you-cleanup/screens/session-panel-dark.png
  - agents/runs/needs-you-cleanup/screens/session-panel-light.png
- Changed paths: 66 (see Files changed)
- Delivery: mode pr, branch `gen-prd/needs-you-cleanup`, base `main`

</details>
yansfil added a commit that referenced this pull request Oct 30, 2026
…s and a Windows Node warm-up (#1863)

Closes with-hide/hide-private#331
Closes with-hide/hide-private#332
Closes with-hide/hide-private#333
Closes with-hide/hide-private#338
Closes with-hide/hide-private#329

## Summary

Six flaky tests in five crates came from three causes, and each is fixed
once for its class.
- Tests read through a product time budget they are not about: Memory
reads were cut at the hook's 100 ms and returned no cards, and the usage
store's 250 ms step cut a 40,000-row prune.
A Memory read now has no deadline of its own (the 100 ms stays in the
hook alone), and the usage store's tests hold its clock still.
- Fixture `git` read the account's settings, so a commit failed whenever
the commit-signing agent did not answer; the fixtures now read no global
or system git file.
- The Windows Node test warmed Node with `--version`, which skips most
of Node's start, so the guarded run still paid the slow first start; the
warm-up now runs the same script.

Per issue:

| Issue | Handling |
| --- | --- |
| #331 usage store prune | Cause fixed: store budgets measured on an
injected clock; store tests open it on a still one |
| #332 herdr-core memory tests | Cause fixed: `MemoryStore::retrieve`
has no deadline; memory_hook tests use `answer_until` with a still clock
|
| #338 hide-memory store tests | Same cause as #332, same fix; the store
and hook tests in its latest comments read through
`retrieve_with_expiry`, which no longer adds a wall clock of its own |
| #333 hide-host fixture commit | Cause fixed:
`GIT_CONFIG_GLOBAL=/dev/null`, `GIT_CONFIG_NOSYSTEM=1`; four other
fixtures with the same inheritance too |
| #329 hide-kit Windows Node | Cause fixed: the first start runs the
guarded script, not `--version` |
| #334 omp observed false | Stays open by the lead's decision: the
helper's 1.2 s send budget is in another process; the failure now prints
the time, the recorded cause and the stand-in's calls |

The Windows process end (with-hide/hide-private#327) was in this pull
request and moved to a pull request of its own; its commits here are
taken back out, so `hide-platform`, `hide-ai`'s omp test and its
documentation are as on main.

스크린샷 없음: no screen changes.

## Review

- **조심해서 볼 파일**:
- `hide-memory/src/store.rs`, `hide-memory/src/hook.rs` -
`RetrievalQuery.deadline` is removed. The product's only Memory reader
is the hook (`hook::context_for` and `herdr_core::memory_hook::answer`,
both through `hide_memory::hook::within_hook_budget`, which adds the 100
ms); every `retrieve` call left is in a test.
- `herdr-core/src/usage_ledger/store.rs` - `Store` carries `clock: fn()
-> Instant`; `open` passes `Instant::now`, so product timing is
unchanged.
- `hide-host/src/worktrees.rs` and four test fixtures - git runs with no
global or system configuration file.
- **질문**: #329's readying pays Node's first full start before the 30 s
guard; the test is about the environment the kit hands Node (it aborts
without `SystemRoot`), not its start time. If a cold first start is ever
the operator's own concern, that is a separate product issue.

## Evidence

- **확인한 것**:
- Local macOS at load 30 to 84: `hide-memory --lib` 205/205 four times
(the parallel run that failed in #338), `hide-host --lib` 154/154,
`herdr-core --lib` usage_ledger, memory_hook, project_memory,
memory_analysis and real_agent_trust 135/135, `hide-agent-hooks`
adapter_contract and codex_binary 6/6.
- Windows CI on 7af7724 and 6fe4f39: every Rust suite of `windows
check` passed, including the hide-kit Node test (#329).
- `clippy --all-targets -D warnings` clean for hide-memory, herdr-core,
hide-host, hide-kit, hide-agent-hooks, hide-ai on macOS.
- **확인하지 못한 것**:
  - Windows tests run only on PR CI; this Mac cannot run them.
  - #334 is not fixed; it fails less silently.
- `windows check` failures seen on this branch were outside its diff:
two web unit tests timing out at 5 s together (open
with-hide/hide-private#354, commented there) and a web unit suite that
could not rename a fixture program another worker built (filed as
with-hide/hide-private#371).
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.

Windows에서 LocalListener가 연결 후 즉시 끊는 클라이언트 반복에 막힙니다

1 participant