Skip to content

test(plan-mode): serialize tests that touch the process-wide plan pointers - #528

Merged
emal-avala merged 1 commit into
mainfrom
fix/plan-pointer-test-race
Jul 27, 2026
Merged

test(plan-mode): serialize tests that touch the process-wide plan pointers#528
emal-avala merged 1 commit into
mainfrom
fix/plan-pointer-test-race

Conversation

@emal-avala

Copy link
Copy Markdown
Member

Summary

  • plan_mode::tests::plan_pointer_roundtrip_and_pid_fallback fails intermittently under parallel execution (~1 run in 6). It surfaces as a red CI check on whatever PR is unlucky, costing review cycles chasing a failure that has nothing to do with the change under review — it was hit on fix(bash): unquote tokens before the destructive-command scan #506 today.
  • The cause isn't that test in isolation: clear_active_plan_path deliberately removes the pid-scoped and legacy pointers alongside the session one, so every ExitPlanMode test wipes shared state the roundtrip test is midway through asserting on. Session-scoped paths are unique per test and were never the problem.
  • Both sides now take a shared-pointer lock: the roundtrip test plus the seven tests that drive ExitPlanMode. The guard ignores mutex poisoning so a panic in one test can't cascade into unrelated failures.

Test plan

  • 12 consecutive runs of the plan_mode suite: zero failures, against a baseline that failed roughly one run in six
  • cargo test --all-targets green apart from the 3 known environmental bwrap_* failures
  • cargo clippy --all-targets -- -D warnings, cargo fmt --all -- --check

Note: a second known flake exists independently — services::git::tests::test_status_and_diff races on process-global PATH set by MCP binding tests via EnvGuard. That one needs the tests driven through the env map instead; not addressed here.

plan_pointer_roundtrip_and_pid_fallback failed intermittently under
parallel execution (~1 run in 6), which surfaces as unrelated CI
failures on whatever PR happens to hit it.

The cause is not the test alone: clear_active_plan_path deliberately
removes the pid-scoped and legacy pointers alongside the session one,
so every ExitPlanMode test wipes state the roundtrip test is midway
through asserting on. Session-scoped paths are unique per test and
were never the problem.

Both sides now take a shared-pointer lock — the roundtrip test and the
seven tests that drive ExitPlanMode. The guard ignores mutex poisoning
so a panic in one test cannot cascade into unrelated failures.

Verified with 12 consecutive runs of the plan_mode suite: zero
failures, against a baseline that failed roughly one run in six.
@emal-avala
emal-avala force-pushed the fix/plan-pointer-test-race branch from 40d8734 to 44bea50 Compare July 27, 2026 06:52
@emal-avala

Copy link
Copy Markdown
Member Author

@codex review

emal-avala added a commit that referenced this pull request Jul 27, 2026
The catalog now lists a user <config>/themes/auto.toml as the sole
'auto' row, but the runtime facade intercepted the id before any
palette lookup: from_name and resolve_theme both converted 'auto' to
one-dark or solarized-light, so selecting the advertised row silently
applied a built-in the user never chose.

Both sites now defer when a user palette owns the id, matching how
dark/light already shadow. The rule is a pure auto_detection_applies
so it is testable without mutating the process environment — writing
a themes dir would have needed XDG_CONFIG_HOME, and process-global
env in tests is exactly the pattern behind the flake fixed in #528.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 44bea506e6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@emal-avala
emal-avala merged commit f1b805a into main Jul 27, 2026
14 checks passed
@emal-avala
emal-avala deleted the fix/plan-pointer-test-race branch July 27, 2026 07:20
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