Skip to content

test: keep the slack team-id spawn tests off real Windows process calls - #24613

Closed
iamwhatever wants to merge 1 commit into
mainfrom
fix/slack-team-id-env-windows
Closed

iamwhatever wants to merge 1 commit into
mainfrom
fix/slack-team-id-env-windows

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Make Backend Tests (Windows) shard 6 green again by fixing the six TestSpawnEnv tests that fail there.

test/test_slack_team_id_env.py::TestSpawnEnv fails 6/6 on Windows shard 6 with FileNotFoundError: [WinError 2] The system cannot find the file specified, raised by native CreateProcess of /usr/bin/kiro-cli acp. Seen on #24499 (head 3bb53f7, which touches no Python). The file came in with #22380 (a3ee04f).

Why it matters

Every PR whose Windows shards run gets a red shard 6 it did not cause. That blocks merges and wastes reruns until main is fixed.

Not a goal

  • Changing any product spawn code. The Windows cleanup seam is correct; only the test's mocks miss it.
  • Moving the other ACP spawn suites (test_acp_client_spawn.py and friends) back onto Windows. They are in test/windows-collect-ignore.txt today.

What changed (motivation → approach → change)

Symptom: WinError 2 from native CreateProcess in all six spawn-env tests, Windows only.

Root cause: the tests mock asyncio.create_subprocess_exec. On Windows, launch() (src/kiro_crew/acp/launch.py) wraps the spawn factory in platform_compat.create_windows_cleanup_owned_process, which calls it with a windows_cleanup_owner. With an owner, create_subprocess_limited (src/kiro_crew/sandbox_rlimit.py) goes to platform_compat._create_windows_subprocess_owned. That calls native CreateProcess directly and never reaches the mock, so the fake /usr/bin/kiro-cli is not found. The sibling ACP spawn suites use the same mocks but are not collected on Windows, which is why only this new file showed it.

Change, in test/test_slack_team_id_env.py only:

  • Patch kiro_crew.platform_compat.create_windows_cleanup_owned_process with a passthrough that calls the factory with no owner, as on POSIX. This is the pattern test/test_xdist_auto_cap.py already uses. The spawn then reaches the mocked asyncio.create_subprocess_exec.
  • Patch finish_suspended_spawn through the kiro_crew.acp.client facade, which mirrors it into client_start (patching the owner directly trips test/test_facade_mirror_guards.py). On Windows it resumes every thread of the pid it is handed, and the mocked pid 12345 is not our child. This was the blocking finding from the local GPT review.

The tests are not skipped or xfailed on Windows. What they check, the env the child is handed, is not POSIX-only.

Backwards compatibility

Compatible: test-only change; no product code is touched.

Removes nothing: the diff only adds two test patches and a helper.

Tests

test/test_slack_team_id_env.py (no new tests; the six existing TestSpawnEnv tests now run correctly on Windows).

Proof: not provable -- test-only change

  • Linux: test/test_slack_team_id_env.py 14 passed.
  • Windows branch forced on Linux (IS_WINDOWS=True, no spawn shim, cleanup seam hands a cleanup owner, native create raises): TestSpawnEnv 6 failed before the change, 6 passed after.
  • With the real finish_suspended_spawn replaced by one that raises, TestSpawnEnv still passes 6/6, so the facade patch reaches client_start.
  • Every tree_scan guard suite: 11265 passed, 14 skipped.
  • black, isort and flake8 are clean on the file.

Manual verification

N/A: the Windows shard in this PR's own CI is the real check; the local run forces the Windows branch on Linux.

Related Issues

Fixes #24612

Sibling sweep

Swept: for f in $(git grep -l "_spawn()" -- test/); grep -l "asyncio.create_subprocess_exec" without "create_windows_cleanup_owned_process"
Sibling: test/test_acp_client_spawn.py -- not affected -- listed in test/windows-collect-ignore.txt, never collected on Windows
Sibling: test/test_acp_client_binary_resolution.py -- not affected -- listed in test/windows-collect-ignore.txt, never collected on Windows
Sibling: test/test_acp_exit_signal_origin.py -- not affected -- patches platform_compat.IS_WINDOWS to False around its spawn
Sibling: test/test_dev_fleet_removal_pod_start.py -- not affected -- spawns its own real child, not AcpClient through launch()
Sibling: test/test_mcp_gateway_daemon_lifecycle.py -- not affected -- spawn tests carry a win32 skipif for /proc and unix sockets
Sibling: test/test_mcp_gateway_adopted_daemon_repair.py -- not affected -- spawn tests carry a POSIX-only skipif
Sibling: test/test_apple_speech.py -- not affected -- macOS-only suite, skipped elsewhere

Pattern harvest

Rule candidate: review-prompt
Pattern: a test that drives AcpClient._spawn by mocking asyncio.create_subprocess_exec must also pass through platform_compat.create_windows_cleanup_owned_process and stub finish_suspended_spawn, or it hits native CreateProcess on Windows.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license.

@iamwhatever
iamwhatever requested review from a team and KiroCrewCaptain as code owners October 26, 2026 22:26
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 26, 2026
@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision b7a4ef20ed560d91c5aaf8ed5291886dd7409311 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ⏭️ skipped

Revision b7a4ef20ed560d91c5aaf8ed5291886dd7409311 ships no reviewable capability (docs, tests or generated files only), so there is nothing to inventory. Does not block merge.

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of b7a4ef20ed560d91c5aaf8ed5291886dd7409311 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Test-only change. It mocks the Windows cleanup-owner seam where the product code calls it (tools.platform_compat.create_windows_cleanup_owned_process), so the product spawn path is untouched and nothing is taken away.

Notes

  • The proof is that the PR's own Windows shard 6 goes green. The local check only forces the Windows branch on Linux, so confirm shard 6 passes before merging.

[DESIGN-REVIEWED] b7a4ef2

Description read

[DESCRIPTION-READ] 9a798df5a328719c10ac18c87a5984edeb1c6d9e5a5b6a0248b4b6897c915111

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed b7a4ef20ed560d91c5aaf8ed5291886dd7409311 — this comment is updated in place on each push.

Review details

No findings.

Notes:

  • patch("kiro_crew.acp.client.finish_suspended_spawn") has no effect on the spawn: client_start._spawn imports finish_suspended_spawn by name from client_spawn_env and calls that copy (client_start.py:50,436). So on Windows the real function still runs on mocked pid 12345. Its ownership gate stops the destructive steps, but the comment above the patch says nothing touches that pid, and that isn't true. Patching kiro_crew.acp.client_start.finish_suspended_spawn would make it true.

[OPUS-REVIEWED] b7a4ef2

Verdict parsed from the review's SHA-scoped output markers for commit b7a4ef20ed560d91c5aaf8ed5291886dd7409311.

False positive or not applicable? A repository writer can comment:
/ai-review override fable b7a4ef20ed560d91c5aaf8ed5291886dd7409311 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of b7a4ef20ed560d91c5aaf8ed5291886dd7409311 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] b7a4ef2

False positive or not applicable? A repository writer can comment:
/ai-review override gpt b7a4ef20ed560d91c5aaf8ed5291886dd7409311 false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 26, 2026

@buluoray buluoray left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving 71bd912. This fixes the Windows-only red on main (Backend Tests (Windows) (6), main @ a3ee04f): every TestSpawnEnv case raised FileNotFoundError because on Windows the launch goes through platform_compat.create_windows_cleanup_owned_process, whose factory reaches native CreateProcess past the mocked asyncio.create_subprocess_exec. Running the factory the way the POSIX branch does is the same seam test/acp_launch_capture.py uses, and stubbing finish_suspended_spawn keeps the Windows resume step off the mocked pid. Test-only; every assertion stays.

One thing blocks the merge that is not code: PR Hygiene fails because the description is missing the template sections (Problem / Motivation, Why it matters, Not a goal, What changed, Tests). Rebuilding the body from .github/PULL_REQUEST_TEMPLATE.md clears it without a push.

@buluoray
buluoray enabled auto-merge (squash) October 26, 2026 22:48
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 26, 2026

@buluoray buluoray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This supersedes my approval on 71bd912.

The new patch patch("kiro_crew.acp.client_start.finish_suspended_spawn") reddens main's own guard: test/test_facade_mirror_guards.py::test_no_test_patches_a_shared_name_on_an_owner_directly fails on Backend Tests (3.12) shards 1-4 and Windows (2) with "a name more than one member of a mirrored family binds is patched through the facade". finish_suspended_spawn is bound by both client_spawn_env and client_start, so patching one owner directly leaves the other on the real function. kiro_crew.acp.client is a MirroredModule facade (client.py:954) that forwards a patch to every owner, so the patch belongs on the facade: patch("kiro_crew.acp.client.finish_suspended_spawn", return_value=True), the same seam test/acp_launch_capture.py uses. My earlier note that the facade patch would miss the call was wrong.

#24609 carries the facade form of the same fix and has no failing checks so far; either change this line or let #24609 land instead. The PR Hygiene description gap is still open too.

@buluoray
buluoray disabled auto-merge October 26, 2026 23:19
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 26, 2026
On Windows, launch() wraps the spawn factory in
platform_compat.create_windows_cleanup_owned_process, which hands it a
cleanup owner. create_subprocess_limited then calls native CreateProcess
through _create_windows_subprocess_owned instead of the mocked
asyncio.create_subprocess_exec, and the synthetic /usr/bin/kiro-cli is
not found (WinError 2). All six TestSpawnEnv tests failed on the
Windows shard.

Pass the factory straight through, as test_xdist_auto_cap.py already
does for the same seam, and stub finish_suspended_spawn, which on
Windows would resume every thread of the mocked pid 12345 on the host.
The behaviour under test (the env the child is handed) is not
POSIX-only, so the tests keep running on Windows.
@iamwhatever
iamwhatever force-pushed the fix/slack-team-id-env-windows branch from 71bd912 to b7a4ef2 Compare October 26, 2026 23:53
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 26, 2026

@buluoray buluoray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving b7a4ef2. This supersedes my request-changes review on 71bd912. The finish_suspended_spawn stub now goes through the facade (patch("kiro_crew.acp.client.finish_suspended_spawn")), which MirroredModule forwards to every owner, so test_facade_mirror_guards no longer fires. The description now carries the template sections. The rest of the fix is unchanged from the version I reviewed: the Windows cleanup seam runs the factory the POSIX way, test-only, every assertion kept.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 27, 2026
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 27, 2026
@buluoray
buluoray disabled auto-merge October 27, 2026 01:23
@buluoray

Copy link
Copy Markdown
Contributor

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: @iamwhatever, this is approved with auto-merge on, but it now conflicts with main, so it cannot land. Four PRs are waiting on it for the Windows test_slack_team_id_env red: #24625, #24632, #24637, #24645. A rebase when you have a moment would unblock them. Thank you.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Closing as superseded: #24609 (commit 5c11e4d) merged the same fix to main. It passes the Windows cleanup seam through and stubs finish_suspended_spawn via the kiro_crew.acp.client facade. Rebasing this branch onto main leaves an empty diff. Windows shard 6 is green on #24609.

@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Oct 27, 2026
@bolichen97
bolichen97 deleted the fix/slack-team-id-env-windows branch November 6, 2026 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge conflict Branch has merge conflicts with its base — author must resolve before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows shard 6: test_slack_team_id_env TestSpawnEnv fails with WinError 2

2 participants