test(opencode): isolate automation registry cross-platform - #675
test(opencode): isolate automation registry cross-platform#675pascalandr wants to merge 1 commit into
Conversation
Configure both LOCALAPPDATA and XDG_RUNTIME_DIR for automation bridge tests so each platform resolves its registry inside the test-owned temporary directory. Temporarily clear WSL discovery as well to prevent a Linux test run from reading the host Windows registry. Use the production directory resolver for assertions instead of hard-coding the Windows registry layout. This fixes the deterministic Linux CI failure introduced with the V2 migration while keeping production behavior unchanged. Validate the complete 378-test server suite and the server TypeScript typecheck.
|
PR builds are available as GitHub Actions artifacts: https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/33872651625 Artifacts expire in 7 days.
|
|
@shantur This is the isolated CI fix to prioritize. It contains only the automation registry test isolation, and the complete Linux/Windows native test and cross-platform packaging matrix is green. Please review for squash merge when available. |
Gatekeeper overlap verdict for
|
## Summary Closes #676. This PR now addresses both mechanisms behind the window-state hang, rather than only reducing the thread count: - one lazy named worker, a capacity-one wakeup queue, and a 250 ms debounce; - native getters run before **any** client-state lock, including explicit close/shutdown captures; - move/resize/scale-factor/zoom handlers enqueue only the latest geometry per known window and never acquire the disk writer lock; - serialized publication merges queued captures, preserves normal bounds across maximize/fullscreen, and seeds clamped restore bounds before maximizing; - rollback preserves events arriving during snapshot/clear/disable/removal publication, including the window whose policy is tentatively changing; a successful destructive commit discards those speculative events; - shutdown closes capture admission, joins the worker without retaining the scheduler/writer mutex, drains an omitted wakeup, and retries captures merged by a failed flush before ownership release; - no application handle retained by the idle worker; - ownership-file validation in `load_window` moved outside the shared in-memory state lock. Electron already debounces native geometry; its production code is unchanged, with a new parity regression covering bursts, maximization, explicit flush, and closed-window cleanup. ## Why the initial version was insufficient The original head `bb38b1a2` fixed thread proliferation, but `capture_window_in_memory` still held `write_lock` across native getters. A slow fsync could block the UI through that mutex; a secondary-thread capture could also hold it while waiting for the same UI thread that was handling a move/resize event. This follow-up retains the useful scheduler behavior and completes the capture/persistence separation in the same PR. No competing #676 PR is being introduced. ## Before/after evidence An external Rust harness compiles the exact production capture, flush, release and scheduler function bodies, replacing only the native/disk adapters. It counts real Windows OS threads and uses controlled channel gates rather than relying on a randomly timed freeze. | Assertion | Base `52f0e629` | Initial PR `bb38b1a2` | Completed PR | | --- | --- | --- | --- | | 128 flush requests | +128 threads | +1 thread | +1 thread | | Capture completes before blocked disk publication is released | FAIL | FAIL | PASS | | UI can complete move/resize while a secondary capture waits for a native getter | FAIL | FAIL | PASS | | Explicit capture/flush retains geometry | PASS | PASS | PASS | | Future envelopes and ephemeral windows remain protected | PASS | PASS | PASS | Ten repetitions per compared version produced the same outcomes. This is a controlled reproduction of the concurrency mechanisms, not a claim of having run the reporter's macOS GUI session. ## Committed regression coverage The crate now includes **19 focused scheduler/capture tests** (the original three plus sixteen additional regressions), using the actual `ClientState`, native-read seam, scheduler and atomic-write adapter. Coverage includes: - 1,000 captures during a stalled disk write; bounded memory and latest geometry; - no client-state mutex held by native getters; simulated secondary getter/UI event cycle; - one worker/one trailing wakeup, callback lifetime, concurrent stop, cheap late submission and no restart after release; - independent windows, maximization/fullscreen, zoom, unknown-window rejection; - successful and failed destructive publication, simultaneous events on the mutating and another window, retry after failed flush; - final persistence and cross-host ownership handoff; - secondary ownership and future-envelope fencing. ## Validation - Full Windows Tauri crate: **158 tests passed**, including default test parallelism. - Electron native suite: **190 tests passed**. - UI/Electron typechecks passed. - Official Tauri resource preparation and server/UI builds passed during verification. - Windows release executable builds successfully. - `cargo fmt --check`, `git diff --check`, and workflow YAML parsing passed. - Added an independent **macOS ARM64 (`macos-26`) Tauri test job** to exercise the crate on the reported platform; packaging now depends on it as well. Its remote result must be checked before merging. ## CI dependency and limits The inherited Linux automation-registry test failure remains isolated in **#671**. #675 was closed as its duplicate and is not part of this fix. No duplicate registry patch or unrelated PR was merged into this branch. After #671 is integrated, update this branch and require the complete matrix before merge. Windows controlled reproductions and tests are not a substitute for a macOS ARM64 interactive launch/move/resize smoke test. Persistent disk failures are still logged and cannot guarantee saving to an unavailable disk. No claim of absolute absence of side effects is made. Maintenance note: `packages/tauri-app/src-tauri/src/client_state.rs` remains oversized (about 1,160 lines); focused capture and scheduler code/tests are kept in sibling modules instead of undertaking an unrelated refactor.
Summary
LOCALAPPDATAandXDG_RUNTIME_DIRWhy
The V2 migration added a registry-pressure test that always constructed
<temp>/CodeNomad/automation-bridges. Linux ignoresLOCALAPPDATAand resolves the registry throughXDG_RUNTIME_DIRor the home directory, so the test failed withENOENTin every current PR while also allowing neighboring tests to touch the runner's real registry location.Validation
node --import tsx --test "packages/server/src/**/*.test.ts"— 376 passed, 2 skippednpm run typecheck --workspace @neuralnomads/codenomad