Skip to content

test(opencode): isolate automation registry cross-platform - #675

Closed
pascalandr wants to merge 1 commit into
devfrom
fix/automation-registry-test-platform
Closed

test(opencode): isolate automation registry cross-platform#675
pascalandr wants to merge 1 commit into
devfrom
fix/automation-registry-test-platform

Conversation

@pascalandr

Copy link
Copy Markdown
Contributor

Summary

  • isolate automation bridge registry tests through both LOCALAPPDATA and XDG_RUNTIME_DIR
  • suppress inherited WSL registry discovery inside these unit tests
  • derive the asserted registry path with the production resolver instead of hard-coding the Windows layout

Why

The V2 migration added a registry-pressure test that always constructed <temp>/CodeNomad/automation-bridges. Linux ignores LOCALAPPDATA and resolves the registry through XDG_RUNTIME_DIR or the home directory, so the test failed with ENOENT in every current PR while also allowing neighboring tests to touch the runner's real registry location.

Validation

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.
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

PR builds are available as GitHub Actions artifacts:

https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/33872651625

Artifacts expire in 7 days.
Artifacts:

  • pr-675-c0106bd7fda4a3aa959beaf63e1ac99ae891971a-electron-macos
  • pr-675-c0106bd7fda4a3aa959beaf63e1ac99ae891971a-tauri-macos
  • pr-675-c0106bd7fda4a3aa959beaf63e1ac99ae891971a-tauri-macos-arm64
  • pr-675-c0106bd7fda4a3aa959beaf63e1ac99ae891971a-tauri-windows
  • pr-675-c0106bd7fda4a3aa959beaf63e1ac99ae891971a-electron-linux
  • pr-675-c0106bd7fda4a3aa959beaf63e1ac99ae891971a-tauri-linux
  • pr-675-c0106bd7fda4a3aa959beaf63e1ac99ae891971a-electron-windows

@pascalandr
pascalandr requested a review from shantur September 4, 2026 12:58
@pascalandr

Copy link
Copy Markdown
Contributor Author

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

@pascalandr

Copy link
Copy Markdown
Contributor Author

Gatekeeper overlap verdict for c0106bd7

The implementation is sound, but this PR must not be merged alongside #671.

#675 contains the same stale-registry correction as #671 and additionally refactors the other Developer Mode tests through a shared isolation helper. The two branches modify the same test block from the same base and are not patch-equivalent; merging both as independent PRs would create avoidable overlap/conflict.

To preserve the required #671#666 merge order, this PR is superseded by #671. The broader all-test helper can be proposed later as a clean follow-up rebased on the post-#671 dev head if still desirable.

Verdict: close as superseded; do not merge this head.

@pascalandr pascalandr closed this Sep 5, 2026
shantur pushed a commit that referenced this pull request Sep 6, 2026
## 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.
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