Repository navigation
fix(tests): green the Windows test suite across agent, loop, channels, tui and cli - #576
Merged
Merged
Conversation
…, tui and cli Running the suites on Windows surfaced two kinds of problems: platform assumptions baked into tests, and real Windows-only bugs the tests were papering over. Both are fixed here. Production fixes (Windows behaviour, verified by the tests): - resolve home as HOME -> USERPROFILE instead of `dirs::home_dir()`, which reads the token profile on Windows and ignores a redirected home (channels config, loop console/leak scan, tui logs and `~` handling, cli browser config). The affected tests were reading and writing the developer's real `~/.future`. - loop: `pid_alive` probes Windows (`OpenProcess` + exit code) instead of always reporting alive, so dead lease/lock holders are reclaimed; a live ACTIVE_GOAL_STATE.md holder is waited for briefly instead of failing the command; `read_ledger` retries the mandatory byte-range lock a concurrent appender holds instead of silently replaying an empty ledger; workspace paths are stored without the `\\?\` extended-length prefix. - cli: `unzip` on Windows now fails for a corrupt archive (PowerShell reports it as a non-terminating error and still exits 0). - agent: the models-cache fallback uses the platform temp dir, and a saved home-prefix rule is rendered as `~/...`. Test fixes: - platform-spelled paths and separators instead of hard-coded POSIX fixtures. - the Windows shell contract is asserted as-is (a killed run reports `[exit: signal]`, commands run through PowerShell) instead of Unix expectations. - loop: the late-agent startup test drives readiness through the mock rather than relying on TCP refusal timing; async/UI assertions wait for the message instead of a fixed pump window. - cli: the embedded-agent failure test binds the port it asks the agent to serve on (port 1 is only privileged on POSIX, so Windows served there and left a stray agent that then broke every `127.0.0.1:1` fixture); the tools-stdin test isolates HOME and clears the key env vars; endpoint probing uses a bound-but-silent listener instead of the default 9222 port a developer's Chrome may own. - Unix-only tests (symlink installs, `#!/bin/sh` fakes, broken-symlink and read-only-dir fixtures, pprof flamegraphs, and the Linux sandbox helper protocol) are gated to the platforms they exercise; the tui tests that need a console skip when one is unavailable.
The home-prefix shortening renders `\` as `/` so a saved rule or an agent-list row reads the same on every host. Limit the rewrite to Windows: on POSIX a backslash is an ordinary filename character, so replacing it would misreport a path that genuinely contains one.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Running the test suites on Windows surfaced two different problems: platform assumptions baked
into tests, and real Windows-only bugs those tests were hiding. Both are fixed here — the
suites are green locally on all five workspace crates.
Before → after (Windows,
--no-fail-fast):future-agentcli_smokefuture-loopfuture-channelfuture-tuifuture-clibincargo fmt --checkandcargo clippy --all-targets -- -D warningsare clean on Windows for thosecrates; CI (Linux) is the backstop for the other platforms.
Production fixes (Windows behaviour, each one covered by a test)
dirs::home_dir()reads the token profile onWindows and observes neither
$HOMEnorUSERPROFILE, so channels config, the loop console/leakscan, the TUI's logs and
~handling, and the CLI's browser config all resolved to the real userprofile. The affected tests were reading — and writing — the developer's actual
~/.future(achannels test loaded real credentials and started a bridge, which is where the suite wedged).
Everything now resolves
$HOME→USERPROFILEfirst, with the profile API as a last resort.future-loop: dead holders were never reclaimed.pid_alivereturnedtrueunconditionallyoff unix, so a killed run's lease or the
ACTIVE_GOAL_STATE.md.locksidecar stayed "live"forever. Windows now probes via
OpenProcess+GetExitCodeProcess; an inaccessible processstill counts as alive, and a live lock holder is waited for briefly (it holds the lock for one
projection write) instead of failing the command outright.
future-loop: a locked ledger read replayed as empty. Windows byte-range locks are mandatory,so reading
events.jsonlwhile a concurrent append held it failed withERROR_LOCK_VIOLATION— and the read path swallowed the error, reporting a registered agent as"not registered" and an existing todo as "unknown". The read now retries that window and surfaces
anything else.
future-loop: workspace paths leaked the\\?\extended-length prefix thatcanonicalizereturns on Windows, into stored rules, ledger audits and user-facing conflict reports.
future-cli: a corrupt skill archive installed as if it were valid. PowerShell'sExpand-Archivereports a bad zip as a non-terminating error (message on stdout) and still exits0, so
unzipreported success and the caller blamed the package contents.future-agent: the models-cache fallback used a hard-coded/tmp(not a real path onWindows) — it now uses the platform temp dir; and a saved
~/…rule is rendered with forwardslashes so the rule round-trips through tilde expansion.
Test fixes
[exit: signal]output ratherthan a timeout error, commands run through PowerShell,
cmd.exeis the shell that must resolve.future-cli: the embedded-agent failure test asked the agent to serve on port 1 and expected abind failure. Port 1 is only privileged on POSIX, so on Windows the agent served happily, never
exited, and its stray process then broke every other
127.0.0.1:1"nothing is listening"fixture in the suite. It now binds a port first and hands that over. (I killed the leftover agents
this had accumulated locally.)
future-cli: thetools call --stdintest isolated HOME and cleared the API-key env vars (alogged-in machine made it exit 0), and the saved-endpoint probe uses a bound-but-silent listener
instead of the default
127.0.0.1:9222, which a developer's own Chrome with DevTools serves.future-tui: the late-agent startup test drives readiness through the mock instead of relyingon TCP refusal timing (a refused loopback connect takes ~2 s on Windows, longer than the fixtures'
budgets), and the async UI assertions wait for the message rather than a fixed pump window.
#!/bin/shfakebinaries, broken-symlink and read-only-directory fixtures, pprof flamegraphs, and the Linux sandbox
helper protocol (POSIX absolute paths / bwrap). TUI tests that need a console now skip instead of
unwrapping when a redirected runner has none.
Notes for review
#[cfg(all(test, unix))]; they still run on Linux CIunchanged.
orchestration/loopgained a Windows-onlywindows-sysdependency (already used byagentandtui) for the process probe.tui rpc::grpc_client::tests::subscribe_stream_event_bookkeeping(fixed sleeps) failed once in ~8 local runs.