Skip to content

fix: discover Windows listener owners for safe cleanup - #376

Merged
yansfil merged 6 commits into
mainfrom
fix/windows-ports-cleanup
Oct 4, 2026
Merged

yansfil merged 6 commits into
mainfrom
fix/windows-ports-cleanup

Conversation

@yansfil

@yansfil yansfil commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Related: with-hide/hide-private#103

Summary

Windows listener discovery currently fails when lsof is absent, leaving checkout cleanup unreadable.
Use native IPv4/IPv6 owner tables and a separate, bounded cwd observation API.
Resolve observed directories through the filesystem so junction, case and verbatim spellings preserve cleanup exclusion.
Authentication and the kernel-proof working-directory API retain their existing contract.

Review

  • Judgment: unreadable live owners or unsafe path spellings refuse the complete sample and destructive cleanup.
  • Watch: hide-platform/src/listeners/ and listeners.rs, native ABI, process identity, resource limits and failure paths.
  • Watch: herdr-core/src/ports.rs, platform adapter and actual cleanup-caller regression; no runtime-lock work is added.

Evidence

  • Confirmed: unchanged Windows listener tests on d0d and 954 failed because lsof was unavailable.
  • Confirmed: whitespace, attribution and workstation checks pass; process/authentication source has no diff.
  • Failed: first candidate Windows OS contract refused a complete sample because live TCP owner PID 4 was unreadable (Access is denied, OS error 5).
  • Confirmed: corrected candidate CI passes fmt, Clippy, full Rust workspace tests (1856 passed, 0 failed, 13 existing ignored), Linux OS contract and Windows workspace compilation.
  • Unrun: canonical local Rust phases; no local heavyweight process was started.
  • Blocked: native listener and cleanup acceptance, and overall required CI.
  • Confirmed: independent source review accepts exact0812, with no correction finding; native acceptance stays blocked.
Additional evidence

Original required Windows diagnostic: run37167225922/job111332572865, exit101 after a 0.01s test.
Raw log SHA256: f408d87929e8feaeb18ac2ce8fde3498a701fbb61f75816b88ed56115d1cece8.
A later unchanged native test on run37168605186/job111336729663 failed identically; raw SHA25685f5a0b86ab59511afe0ed1a1a2e247161580254d3b069ac4d157dd2ad87c9f9.
Candidate source: 0812add, base af15ad6.
The foreign fixture connects to its real IPv4/IPv6 sockets, then the complete-sample assertion fails on the unrelated protected live owner.
The failed required job is run37170450000/job111342179360, 1 passed and 1 failed in 0.03s; raw SHA256bea02707451dc05e3e2434cd874d5e55200e6b84d6656ea9792567b422b7b277.
The original complete-sample assertions remain unchanged; no protected-owner omission or privilege change was added.
The unrun cleanup regression launches through alternate spellings and checks the actual exclusion decision on two fresh reads; it performs no destructive removal.
Commit0812 corrects five decoder Clippy expressions and the Windows cleanup fixture import.
Its required run37171009311 checks merge716cfa0fdebe599316d588dd52c8370a2c418709, source0812 into main31123442224037662d1b0f6f26e21730fbfa184e.
Rust job111343819351 and Linux OS job111343819337 pass; Windows compilation job111343819202 passes.
Windows OS job111343819358 still fails the same complete-sample assertion on owner4, fixture1 passed and1 failed in0.02s, exit101; raw SHA256eba109e3bbbbf92953c9ca5f3d72ff528cbf9032400e5ab84f3edeedf93f3ae5.
Remaining work needs a proven bounded attribution model for protected live listener owners while keeping unknown owners and destructive cleanup fail-closed.
That design and evidence are outside this run; original native assertions and required gates remain in place.
Limits: 4096 rows, 512 owners, 1 MiB tables and cwd sample text, three allocations per table, six bounded memory reads per owner.
The ten-second budget is cooperative between synchronous native calls; it does not preempt a kernel call.
The existing five-second refresh and notifier remain, with no extra subprocess, resident thread or pending queue.

@yansfil

yansfil commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

All three coherent commits are pushed at 36b38432765a0ea3ef8cea8ad6ac6d06887b73cf.

Remaining work and blockers:

  • bash scripts/verify-cargo.sh test and bash scripts/verify-cargo.sh lint are unrun. The corrected local controller is queued under the existing FIFO resource policy; its earlier size-check failure occurred before Rust started and is preserved.
  • Native Windows execution must cover the original real-listener test, the foreign IPv4/IPv6 fixture, and ports::tests::cleanup_keeps_a_checkout_in_use_when_a_listener_starts_through_another_spelling. The present workflow compiles the last test; its execution route is being added to the existing Windows diagnostic lane by the CI owner.
  • Required CI against current main and final review binding to the checked source remain pending. Source correction review at this exact commit is clear.

Next action: finish the existing local test and lint phases with isolated HOME/target and two build/test threads, retain actual exits and owned cleanup evidence, then supply the exact source and native/required CI results for final review. Any failure stays visible and is corrected only within this PR's listener scope.

The PR remains a draft until these gates are resolved.

@yansfil

yansfil commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

Current source is fully pushed at 0812add8d7e84c4a0c76a3c5075d9e18e98b43cc.

The first candidate run 37170450000 exposed two source defects: five decoder Clippy expressions, and the Windows cleanup fixture import pointing to the wrong module. Commit 0812add8 corrects those two owned files with the same validation predicates and behavior assertions. The failed logs are retained; the new candidate has not yet passed required CI.

The Windows OS contract also executed the foreign IPv4/IPv6 listener regression and failed at hide-platform/tests/listeners.rs:103: TCP listener owner 4 cwd unavailable: Access is denied. (os error 5). That job reported 1 passed, 1 failed, 0 ignored in 0.03 seconds. Actual failing job.

Remaining blocker: the current safety contract refuses an incomplete sample when a live owner is unreadable, while the native regression requires a complete successful observation. No protected-owner exclusion, elevated privilege, fallback, assertion relaxation or timeout increase has been added. A technical decision on that boundary is pending; cleanup remains fail-closed.

Next action: resolve that exact native boundary within the current scope, execute the unchanged native listener and cleanup regressions through the existing Windows CI route, then bind the existing independent review to the final candidate. Canonical local Rust test and lint remain unrun; no local Rust process has started. This PR stays draft and is not merge-ready.

@yansfil

yansfil commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

Final current-scope handoff: all four coherent commits are fully pushed at 0812add8d7e84c4a0c76a3c5075d9e18e98b43cc; the source worktree is clean. Independent source review accepts the two-file compile/lint correction with no remaining source finding.

Corrected candidate CI tested merge 716cfa0fdebe599316d588dd52c8370a2c418709, combining this source with main 31123442224037662d1b0f6f26e21730fbfa184e:

  • Rust fmt, Clippy and full workspace tests passed: 1,856 passed, 0 failed, 13 existing ignored. The label worker standby regression passed.
  • Linux OS contract passed.
  • Windows workspace compilation passed, including the new cleanup regression.
  • Windows OS contract failed the real foreign listener fixture: live owner PID 4 returned Access Denied, OS error 5. The fixture reported 1 passed, 1 failed, 0 ignored in 0.02s, exit 101. Raw log SHA256 eba109e3bbbbf92953c9ca5f3d72ff528cbf9032400e5ab84f3edeedf93f3ae5.

The native failure is retained. An unreadable live owner keeps the complete observation unavailable and destructive cleanup fail-closed. No PID 4 exclusion, privilege elevation, guessed cwd, timeout increase, skipped test or assertion waiver was introduced. The original native listener and alias cleanup cases remain in the parent Windows verification route.

Remaining blocker and next action: establish a proven, bounded attribution model for protected live listener owners before native acceptance can pass. That design and evidence are outside this finalized scope; the cleanup issue and required gates remain open. The cleanup regression has compiled but has not passed native execution. Canonical local Rust phases remain unrun; no local heavyweight process was started. No merge or completion is claimed; this PR remains draft.

Exclude only cwd observations that return PermissionDenied so inaccessible listener owners do not invalidate accessible user processes. Preserve owner-table and process-identity checks and all other observation errors. Add a regression and align the platform contract.
@yansfil

yansfil commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

dfb89515에서 cwd PermissionDenied owner만 제외하고 다른 cwd·owner·identity 오류 거부를 유지했습니다. scripts/verify-cargo.sh의 hide-platform/herdr-core 로컬 1,293 PASS·기존 7 ignored 유지; 필수 verify CI 대기, Windows 실행 증명은 CI로 확인하며 추가 GUI QA는 미실행입니다.

@yansfil

yansfil commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

dc4bb8e2에서 Windows IPv4/IPv6 행 루프 두 줄만 as_chunks::<{ size_of::<...>() }>().0로 변경해 push했습니다. 나머지 바이트 처리와 포인터·테스트·예산은 유지했으며, Windows 검증은 새 CI 확인 대기입니다.

@yansfil
yansfil marked this pull request as ready for review October 4, 2026 04:41
@yansfil
yansfil merged commit 9db5174 into main Oct 4, 2026
21 checks passed
@yansfil
yansfil deleted the fix/windows-ports-cleanup branch October 4, 2026 04:41
yansfil added a commit that referenced this pull request Oct 4, 2026
Related: #293; merged prerequisites #372, #376 and #383.

## Summary

The Windows required lane now runs the existing listener-attribution and
checkout-in-use tests.
A native read failure reaches `verify` with its actual reason, alongside
the browser smoke result.
`CONTRIBUTING.md` lists both commands.

## Review

- `.github/workflows/pr.yml`: both tests run and either failure keeps
the Windows job red.
- `CONTRIBUTING.md`: the Windows gate description matches the executed
commands.
- Runtime, listeners, fixtures and smoke specs use merged main; no
timeout, retry or quarantine policy changes.

## Evidence

- Local workspace check, both listener tests, web/desktop types and
lint, desktop units and CI script tests passed.
- Current-head Windows smoke and required `verify` remain in progress in
[CI](https://github.com/modakbul-gongbang/hide/actions/runs/37195702212).
- Local listener proof is on macOS; native Windows and GUI behavior are
not inferred from it.

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

- Base: `316fa7d4be8c6bd80bd31ce5e5af572ebf92356b`; head:
`e5595408620a076176352a6c5c69e494b8a063d4`.
- `verify-cargo.sh check --workspace --all-targets`: passed.
- Both existing core listener tests: one passed each, no skips.
- `verify-web.sh`: web and desktop typecheck/lint passed; desktop units
99 passed, 3 existing skips.
- CI Python tests: 9 passed.
- Main listener/fixture/smoke/focus preservation: 12 matching blobs.
- Owned command groups reaped; cold check 128.485s, cold listener
compile/run 105.689s, warm alias test 0.538s.
- [Windows required
job](https://github.com/modakbul-gongbang/hide/actions/runs/37195702212/job/111416992651):
in progress.

</details>
yansfil added a commit that referenced this pull request Oct 4, 2026
## Summary

Every PR ran Rust, the unit suites on three OSes and the full E2E, even
a docs-only PR.
The median time for the required checks to finish was 32.45 min (Orca
16.22, Paseo 20.65).
Now a `plan` job reads the changed paths (`HEAD^1..HEAD` of the PR merge
commit) and plans only the lanes the change needs.
The same plan sets each job's `if:` and is what `verify` checks the
results against.

- `verify` passes only when every **planned** lane is `success` and
every **unplanned** lane is `skipped`. A planned lane that was skipped,
failed or cancelled fails `verify`, and so does a `needs` entry the plan
doesn't know or a failed plan.
- The Windows browser `@platform` smoke moves out of `windows check`
into its own `windows e2e` lane, which calls `web-e2e.yml` the same way
nightly does. Compile, unit tests and the OS contract stay in `windows
check`.
- `checks` is split into `policy` (on every plan), `web checks`,
`desktop checks` and `hcoord`.
- A main push, a comparison that fails (base missing, not a merge
commit, diff parse failure, `cargo metadata` failure) and any
unclassified path all run **every** lane.
- Main pushes no longer cancel each other (`cancel-in-progress` is now
PR-only). `design-contract.yml` also cancels only the same PR's previous
run.
- The rules live in one place, `scripts/ci-plan.py`; the table in
`docs/TESTING.md`, "Which lanes a pull request runs", explains them.

## Review

- **판단해 주세요**: whether it is acceptable that **main's full run is the
safety net** for a lane wrongly left out. A wrongly skipped lane
surfaces as a failure on main after the merge, not on the PR.
- **판단해 주세요**: whether to keep the Windows smoke now skipping `@flaky`
tests, as macOS already did. No `@platform` test is tagged `@flaky`
today, so the behavior is the same for now.
- **판단해 주세요**: web code shared with the desktop host (`SHARED_WEB`) also
runs the desktop lanes and the macOS/Windows `@platform` lanes. That is
broader than the brief's "desktop 연결까지"; I chose it because terminal,
input and shortcut changes are Windows-impacting.
- **조심해서 볼 파일**: `scripts/ci-plan.py` `READERS` and `SHARED_WEB`. These
two hand-kept lists are where a lane can be dropped wrongly (the failure
path). Review found five omissions from tests reading files across
folders and they are fixed (below).
- **조심해서 볼 파일**: the `verify` job in `.github/workflows/pr.yml` and
`aggregate()`. This is the merge gate itself.
- **질문**: `site/`, `tools/`, `spikes/`, `.github/*.md` and `agents/prd`
currently fall under "unknown path → everything". Should a follow-up
narrow them?

## Evidence

**Plan replay over the last 20 merged PRs.** Each row runs the
classifier on the merge commit's `^1..` diff:

| PR | 경로 수 | 계획 | 생략되는 lane | Rust crate |
| --- | ---: | --- | --- | --- |
| #389 | 7 | 전체 (`scripts/web-shell-measure/run.sh`) | - | 전체 |
| #388 | 6 | 부분 | desktop-checks, hcoord, os-contract, windows-check,
windows-e2e, macOS-e2e, desktop-e2e | herdr-core |
| #385 | 125 | 전체 (`.github/pull_request_template.md`) | - | 전체 |
| #387 | 70 | 전체 (`contracts/hided-ws.schema.json`) | - | 전체 |
| #386 | 61 | 전체 (`contracts/hided-ws.schema.json`) | - | 전체 |
| #368 | 2 | 전체 (`.github/workflows/pr.yml`) | - | 전체 |
| #372 | 23 | 전체 (`.github/workflows/nightly.yml`) | - | 전체 |
| #382 | 3 | 부분 | web-checks, desktop-checks, hcoord | herdr-core,
hide-host, hided |
| #383 | 1 | 부분 | rust, desktop-checks, hcoord, os-contract,
windows-check, desktop-e2e | - |
| #384 | 8 | 부분 | web-checks, desktop-checks, hcoord, os-contract,
windows-check, windows-e2e, web-e2e, macOS-e2e, desktop-e2e | herdr-core
|
| #380 | 2 | 부분 | web-checks, desktop-checks, hcoord | herdr-core, hided
|
| #381 | 1 | 부분 | rust, desktop-checks, hcoord, os-contract,
windows-check, desktop-e2e | - |
| #378 | 58 | 전체 (`.github/workflows/nightly.yml`) | - | 전체 |
| #377 | 11 | 부분 | hcoord | herdr-core, hided |
| #361 | 91 | 전체 (`agents/prd/three-column-panel/prd.md`) | - | 전체 |
| #376 | 7 | 부분 | web-checks, desktop-checks, hcoord | herdr-core,
hide-agent-hooks, hide-ai, hide-herdr-client, hide-host, hide-kit,
hide-memory, hide-platform, hide-session, hided |
| #367 | 27 | 부분 | hcoord | herdr-core, hide-host, hided |
| #375 | 2 | 부분 | web-checks, desktop-checks, hcoord | herdr-core,
hide-agent-hooks, hide-host, hide-kit, hide-memory, hided |
| #366 | 8 | 전체 (`.github/workflows/release.yml`) | - | 전체 |
| #362 | 153 | 전체 (`agents/prd/overview-request-view/prd.md`) | - | 전체 |

- **줄어드는 lane**:
- 11 of 20 PRs would run a partial plan; 9 run everything because they
touch `.github/`, `contracts/`, `scripts/` or `agents/`.
- A docs-only PR (#384) runs no E2E, Windows or macOS lane. It still
runs `rust -p herdr-core`, because a herdr-core test reads the root
`AGENTS.md`.
- A web display change (#388) runs no Windows, macOS, desktop or
OS-contract lane.
- A Rust crate change tests only that crate and its reverse
dependencies, from `cargo metadata`. For example #380 tests `herdr-core`
and `hided` only.
- **확인한 것**:
  - `scripts/tests/test_ci_plan.py` passes 19 cases. They cover:
    - Docs-only, which excludes Rust and E2E.
    - A pure web display change, which excludes the Windows smoke.
    - `hide-platform`, which includes Windows and the OS contract.
- Shared web, a `@platform` spec, `desktop/src/main` and leaf-crate
reverse dependencies.
    - Every `READERS` entry.
- Unknown paths, lockfiles and workflows, a type change, an empty diff,
a missing base, a non-merge HEAD and a missing crate graph, which all
run everything.
- The aggregate rejecting a skipped, failed or cancelled planned lane,
an unplanned lane that ran, a missing or extra `needs` entry, a failed
plan and an empty plan.
- The full `python3 -m unittest discover -s scripts/tests` suite passes
(108). That includes the check that every gate a workflow runs is a
tracked script.
- actionlint passes on every workflow. `check-herdr-pin-single-source`,
`check-hide-design-enforcement`, `check-no-workstation-identity`,
`check-harness-ignore-anchor` and `verify-cargo.sh fmt-check` all pass.
- Running `plan` on #388 produced the expected `GITHUB_OUTPUT` (`lanes`,
`full`, `rust-packages`) and the job-summary table.
- Running `aggregate` with a fake `needs` passed when the results
matched the plan and failed when a planned lane was skipped.
- **리뷰 반영**: a code review and a fidelity review against the brief found
these, now fixed:
- Tests read files across folders, so these changes now plan the lanes
that read them: the root `AGENTS.md` (herdr-core test), `web/src` and
`hided/src` (herdr-core structure tests), `wirePath.ts` (imported by web
e2e) and `design/tokens.json` (read by web tests).
  - Every crate change now runs `windows check`.
  - Main pushes no longer cancel each other.
  - `docs/PERFORMANCE_TESTING.md` no longer describes the old lanes.
- **CI ([run
37214808511](https://github.com/modakbul-gongbang/hide/actions/runs/37214808511))**:
- The plan was full (the change touches `.github/` and `scripts/`), and
every lane ran, including the separate `windows e2e`. All passed.
- The first attempt failed in Linux web e2e shard 2/6 on
`home.spec.ts:82` (the location bar read `Home/hde-…` instead of
`Home/~/hide`). This PR touches no web or test code. `verify` reported
exactly `web-e2e: planned, expected success, got failure`.
  - One rerun of the failed jobs passed, and `verify` is green.
- The `home.spec` failure is a flaky-test candidate; it belongs to the
main-green work, not this PR.
- **확인하지 못한 것**:
- Partial plans have never run on Actions. A docs-only or web-only PR
has not been tried; the first one after the merge will show it.
- The cold-cache time of the `windows e2e` lane is unmeasured. It uses
the same path as the nightly Windows lane.
- Main runs now queue instead of cancelling, but GitHub keeps only one
pending run per group. If three merges land in a row, the middle merge's
full run can be dropped.
- **안전망과 위험**: a lane that should have run but was skipped is the risk.
Main's full run catches it after the merge; the fix is then a rule in
`scripts/ci-plan.py` plus a test case.

Does not include: a failure ledger or history, a quarantine registry,
cache changes, a `max-parallel` experiment, or the `package.yml` `paths`
trigger (all out of scope).
If this and the main-green PR overlap in `pr.yml`, whichever merges
later rebases.
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