Skip to content

Keep CDP teardown outside the held focus request - #383

Merged
yansfil merged 3 commits into
mainfrom
fix/focus-burst-test-timing
Oct 4, 2026
Merged

yansfil merged 3 commits into
mainfrom
fix/focus-burst-test-timing

Conversation

@yansfil

@yansfil yansfil commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Related: #372, #381, #382

Summary

The rapid pane-click test waited for CDP teardown while withholding a real Herdr focus response.
Moving teardown exposed a second race: CDP ACKs arrived before the test observed the complete outgoing focus burst.
Wait for all forty completed terminal_click frames on the same WebSocket before reading the final pane and accepted-focus count.
Keep a separate CDP session per burst, with the first detach after gate release and confirmation.
All original expectations, forty clicks, timeouts, retries and skip remain unchanged.

Review

  • web/e2e/pane-focus-ordering.spec.ts: input completion and CDP lifetime only; Unix gate and unknown-result test are unchanged.
  • The passive observer adds one numeric click counter without retaining click payloads or changing the page's send.
  • The test has at most one live CDP session; finally closes it and protects original fixture cleanup on detach failure.
  • Existing 64 focus-record and 32 timing-stage bounds remain; polls read memory every 25ms with unchanged default timeouts.
  • This main-based branch excludes Observe terminal input and announce Windows fixture readiness #372's Windows pipe and fixture changes.

Evidence

  • Measured macOS run: 17 passed; detach took 2,083ms before gate release.
  • macOS regression: expected count froze at 6, actual acceptance reached 40.
  • Linux 2/6 regression: final-pane evidence was read before the last click arrived.
  • Source confirms mouseup emits terminal_click after focus on one socket; both are processed by the same passive observer.
  • Exact spec lint/syntax and source comparison pass; every original assertion and ordered input command is preserved.
  • Repaired-head runtime CI is unconfirmed; no local native build, execution, dependency install or server was added.
  • Linux 6/6 tab-strip-fit.spec.ts:82 is outside this change and untouched.

@yansfil yansfil changed the title Remove held focus test waits from the transport deadline Keep CDP teardown outside the held focus request Oct 4, 2026
@yansfil

yansfil commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

7f6b44a push 완료: macOS 단계 측정에서 detach 2,083ms와 두 진단 poll 864/860ms를 확인해 CDP 준비·종료를 held 요청 밖으로 옮기고 관찰 간격만 25ms로 수정했으며, 기대값·40회 클릭·시간 제한·재시도·skip·Unix 게이트·#372 Windows 변경은 보존했습니다; 최종 head CI 대기, 로컬 native 실행 없음.

yansfil added a commit that referenced this pull request Oct 4, 2026
Related: #383 (the rapid-click wait fix the guide cites as its case),
#372 (the Windows fixture work behind the operating-system rules)

## Summary

How to write a test was spread across `VERIFICATION.md`,
`CONTRIBUTING.md` and three package `AGENTS.md` files, and the rules
learned from today's flaky failures were written nowhere.
This adds `docs/TESTING.md` as the one guide for writing tests, split
from running them: `TESTING.md` owns the layer choice, fixtures,
deterministic waiting and ordering, the flaky policy and a review
checklist; `VERIFICATION.md` keeps check selection, e2e run traps,
native QA and device checks.
The fixture section and the `@flaky` quarantine paragraph move verbatim
and leave links behind; no code, test or CI file changes.

## Review

- **Please judge**: the two flaky rules under "These rules are checked
by the reviewer" are new policy (an added `@flaky` links an open issue
with a recorded failure and names what ends it; a PR touching a
quarantined test removes the tag or records why it stays).
- **Please judge**: "Wait for state, not time" bans fixed waits for new
tests only; `web/e2e` and `desktop/e2e` still have 54 `waitForTimeout`
calls.
- **Files to watch**: `CONTRIBUTING.md` - the two lane sentences about
`@flaky` (shard 1 only, never the macOS `@platform` job; nightly
blocking) moved into `TESTING.md#flaky-tests`; check they still match
`pr.yml` and `web-e2e.yml`.
- **Files to watch**: `docs/TESTING.md` "Operating-system differences" -
the shared fixture helper is described as not on `main` yet; it names
only files that exist.
- **Follow-up, not in this PR**: a check script refusing new
`waitForTimeout` in e2e specs, and one refusing a `@flaky` tag without
an `issue` annotation.

## Evidence

- **Confirmed**: the moved "Writing a fixture" section is byte-identical
to the original (`diff` of the extracted sections).
- **Confirmed**: the `@flaky` lane facts were read against
`.github/workflows/pr.yml`, `web-e2e.yml` and `nightly.yml`; Playwright
retries are not configured in either suite.
- **Confirmed**: every file the guide names exists on `main`
(`focusGate`, `s2.spec.ts`'s owner hash, `ownUntilWorkerExit`,
`fixture.ts`'s `AggregateError`).
- **Confirmed**: `check-no-workstation-identity.sh`,
`check-no-attribution.py`, `check-harness-ignore-anchor.sh`,
`check-herdr-pin-single-source.sh` pass.
- **Not confirmed**: the stage timings in the rapid-click case (2.1 s
detach, 0.9 s poll backoff, release at 4.4 s) come from the
investigation behind #383, not re-measured here.
- **Not confirmed**: the Windows `EACCES`, owner-hash and `EBUSY`
failures come from the Windows fixture runs behind #372, not reproduced
here.
- **Not run**: Rust, web and e2e suites, since no code changed.
@yansfil

yansfil commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

80d8832 push 완료: 같은 WebSocket의 실제 terminal_click 40개 처리 완료를 기다린 뒤 lastPane/acceptedAfter를 계산하고 burst별 CDP 세션과 gate release 이후 detach를 적용했습니다; 기존 기대값·40클릭·timeout·retry·skip 보존, 파일 lint/구문 PASS, 수정 head CI 미확인, Linux 6/6 무관 실패 미수정.

@yansfil
yansfil marked this pull request as ready for review October 4, 2026 08:30
@yansfil
yansfil merged commit 3e14a35 into main Oct 4, 2026
21 checks passed
@yansfil
yansfil deleted the fix/focus-burst-test-timing branch October 4, 2026 08:30
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.
yansfil added a commit that referenced this pull request Oct 5, 2026
## Summary

`desktop e2e` (macOS) is the longest job of a verify run and the last to
finish in 16 of the last 25 successful runs, so it sets the time
`verify` takes (job median 13.8 minutes).
Its `Remote mailbox over private SSH` step took 2.1 minutes of that
(median 126 s: about 57 s compiling the workspace again under the test's
feature set, about 53 s for the one test).
The macOS `@platform` web e2e job also holds a macOS runner, builds
hided and fetches the pinned Herdr, and finishes earlier (median 9.0
minutes).
This moves the lane there: `web-e2e.yml` takes a `remote-mailbox` input,
which builds the CLI (`verify-cargo.sh cli`, every binary the lane
starts) instead of `build -p hided` and runs the same nextest command
after the suite; `pr.yml` sets it for the macOS lane and drops the step
from `desktop e2e`.
The OS contract's macOS leg stays in `desktop e2e`.

## Review

- **판단해 주세요**: the lane now runs when `web-e2e-platform` is planned
instead of `desktop-e2e`. On the last 80 merged pull requests that is 62
runs instead of 59 (table below); `ci-plan.py` gets a comment that a
narrower `web-e2e-platform` rule would drop the lane.
- **판단해 주세요**: the mailbox test resolves dependency features differently
from the CLI build, so about 48 dependencies build a second variant that
the macOS web e2e cache (saved from `build -p hided`) does not hold:
about 25 s per run on this pull request's run. rust-cache saves only
when its key changes, and the key hashes `Cargo.toml` and `Cargo.lock`,
so main's first run after the next manifest change saves both builds;
until then the 25 s stays.
- **조심해서 볼 파일**: `.github/workflows/web-e2e.yml`, the reusable lane
nightly and the Linux and Windows lanes also call; with the input unset
(its default) their steps and cache keys are unchanged.

## Evidence

- **확인한 것 (plan)**: `ci-plan.py` (main, after #490) over the file lists
of the last 80 merged pull requests (#371-#492):

| | before (in `desktop-e2e`) | after (in `web-e2e-platform`) |
| --- | --- | --- |
| pull requests running the mailbox lane | 59 | 62 |
| lose it | | #462, #466, #487: only `desktop/` files, which the lane
does not read |
| gain it | | #381, #383, #429, #444, #447, #488: `web/e2e` specs tagged
`@platform` |

- **확인한 것 (catches)**: of 232 failed `pr.yml` runs since 2026-09-05, the
mailbox step failed in 2 (#409 `prd/hcoord-retire`, #456 cargo `typify`
bump); both plan every lane, so both still run it.
- **확인한 것 (before)**: medians of the last 22 successful verify runs:
`desktop e2e` 13.8 min, its mailbox step 126 s; `web e2e macos` 9.0 min
(build 88 s, End-to-end 382 s).
- **확인한 것 (after)**: this pull request's verify run
[37288613490](https://github.com/modakbul-gongbang/hide/actions/runs/37288613490)
(first commit; the second only removed a cache `key` line rust-cache
ignores next to `shared-key`):

| | before (median, n=22) | after (this run) |
| --- | --- | --- |
| `desktop e2e` | 13.8 min, mailbox step 126 s | 12.2 min, no mailbox
step (its suite step took 518 s against a 494 s median) |
| `web e2e macos` | 9.0 min | 11.3 min: CLI build 91 s (was `build -p
hided` 88 s), suite 383 s, mailbox step 128 s (compile 82 s of which
about 25 s dependency variants, test 43 s) |
| macOS job-minutes for the two | 22.8 | 23.5 |

Second run, on the squashed commit,
[37290394720](https://github.com/modakbul-gongbang/hide/actions/runs/37290394720):
`desktop e2e` 12.0 min, `web e2e macos` 12.6 min (CLI build 99 s, suite
386 s, mailbox step 170 s), `verify` 13.4 min.
The two macOS jobs now end within a minute of each other (12.0-12.6
against 13.8 and 9.0), so the macOS ceiling of a run drops by about 1.5
minutes, and by about 25 s more once the cache holds the dependency
variants.
- **확인한 것**: `python3 -m unittest discover -s scripts/tests` passes (125
tests); both workflow files parse.
- **확인하지 못한 것**: the warm steady state of the macOS web e2e job is seen
only after main's first run saves the new cache; the first pull-request
runs after merge are that measurement.
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