Skip to content

fix(apps): check the app folder off the event loop before a lifecycle script - #39100

Merged
javenciu merged 1 commit into
mainfrom
fix/sync-io-lifecycle-app-folder
Nov 18, 2026
Merged

javenciu merged 1 commit into
mainfrom
fix/sync-io-lifecycle-app-folder

Conversation

@javenciu

@javenciu javenciu commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: run_lifecycle_script stops checking the app folder on the event loop, so a slow or stuck mount cannot freeze every session's turn while an app is enabled, disabled or uninstalled.

The sync-io gate lists src/kiro_crew/apps/lifecycle_scripts.py in .github/sync-io-in-async-fs-baseline.txt: run_lifecycle_script called app_root.is_dir() on the loop thread before every lifecycle script.

Why it matters

A stat on a mount that stops answering blocks the loop for as long as the kernel takes. Past the loop-stall limit the watchdog restarts the gateway.

Not a goal

  • The other files in the baseline are untouched.
  • No change to what the function returns, logs or raises.

What changed (motivation → approach → change)

  • lifecycle_scripts.py: the check is now await asyncio.to_thread(app_root.is_dir), the idiom the neighbouring code uses.
  • The file's line is removed from the baseline (scripts/check_sync_io_in_async.py --update-baseline).

Backwards compatibility

Compatible: the same result and message for a missing app folder; only the thread that runs the stat changes.

Tests

  • test_app_directory_check_runs_off_the_event_loop records the thread that calls Path.is_dir for the app folder.
  • RED on origin/main source: it fails with "the app directory check ran on the event loop thread", and the sync-io gate with the baseline line removed fails on lifecycle_scripts.py:73.
  • GREEN on this head: the test and the gate pass, and 423 tests in the lifecycle, app-execution, cancel, uninstall, update, gate and line-cap files pass.

Proof: PROVEN test_app_directory_check_runs_off_the_event_loop (head c166b0b)

Sibling sweep

Swept: python3 scripts/check_sync_io_in_async.py --report
Sibling: src/kiro_crew/apps/registry_pipeline/recovery.py -- not affected -- its cancel-time undo is synchronous on purpose so another cancel cannot interrupt it; its baseline row stays

Pattern harvest

Not generalizable: the sync-io gate already catches this class; the fix is the one listed call.

Related Issues

None.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • 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

@javenciu
javenciu requested review from a team and KiroCrewCaptain as code owners November 18, 2026 13:15
@javenciu
javenciu requested a review from CrysisDeu November 18, 2026 13:15
@javenciu
javenciu enabled auto-merge (squash) November 18, 2026 13:15
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

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

@github-actions

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing to check. This is a one-line move of the folder stat onto a worker thread, it uses the same pattern as the code around it, and the function returns the same results as before.

[DESIGN-REVIEWED] c166b0b

Description read

[DESCRIPTION-READ] a91de18ede535188b68a113e0e85ded299e3b3cb659d544a71678c902666bef8

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

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of c166b0ba777ae35241b73f92d184fe9be4497dd0 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks: this fixes the mechanism behind a defect the sync-io gate's baseline records. The fix is one line plus its baseline row and a test.

What this change ships

Inventory (3 items) — 3 justified

Intent: stop the lifecycle-script app-folder check from stalling every session's turn when a mount hangs. FIX.

  1. While an app is enabled, disabled or uninstalled, the app folder is checked on a worker thread instead of the event loop. — justified
  2. lifecycle_scripts.py is no longer listed in the sync-io gate baseline, so a new on-loop call there now fails CI. — justified
  3. A test records which thread checks the app folder. — justified

[FIRST-PRINCIPLES-REVIEWED] c166b0b

Description read

[DESCRIPTION-READ] 4180a3e3631117e196b8beb84f42215ca20e3f907dbe1d12b3a29acf7481cc48

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] c166b0b

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

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

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] c166b0b

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

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 18, 2026
@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: A person should decide

Why: the decider estimates a 4% chance that this change introduces a defect, within the 12% limit for approving on its own, but it is held at tier pending: being reviewed.

This is a one-line fix: the app_root.is_dir() check in run_lifecycle_script now runs through asyncio.to_thread. The return value and message are unchanged, asyncio was already imported, and the same pattern is used throughout apps/. The new await sits before anything is spawned, and the function already awaited wrap_argv_async before spawning, so cancellation behaviour doesn't change for the three callers (enable, uninstall, teardown). The baseline row is removed so the gate now enforces this file. The new test records which thread runs Path.is_dir, fails on main's code and passes on this head. CI is green on Linux and Windows.

Tier: pending: being reviewed.

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit c166b0ba77 · 26 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I reviewed head c166b0b and found nothing blocking. The check app_root.is_dir() in run_lifecycle_script now runs through asyncio.to_thread. The signature and return values are the same, so the three callers in routes_lifecycle.py, routes_uninstall.py and teardown.py are unaffected. The denial check and the sandbox wrap are untouched. The row removed from .github/sync-io-in-async-fs-baseline.txt tightens the ratchet, and PR Readiness is green on this head.

Done well: the new test records which thread runs Path.is_dir and checks that the check ran at all (assert seen). So it fails if the change is reverted, and it cannot pass without checking anything.

Optional:

  • app_execution_denied runs first and still calls app_root.resolve(strict=True) on the event loop (execution.py:431). On a stuck mount the loop can still block there before it reaches the moved check. That code is older than this PR, and #34390 moves it off the loop. A short PR comment saying so would keep the claimed outcome accurate.
  • #10599, #34390, #38758 and #34777 also touch lifecycle_scripts.py or the baseline file. When you resolve those conflicts, do not restore the removed baseline row.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: passed Eligible automated validation passed for the current revision readiness: checking Automated validation is still running labels Nov 18, 2026
@javenciu
javenciu merged commit 9f2919b into main Nov 18, 2026
105 of 106 checks passed
@javenciu
javenciu deleted the fix/sync-io-lifecycle-app-folder branch November 18, 2026 15:34
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 18, 2026
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.

2 participants