Repository navigation
Conversation
bolichen97
left a comment
There was a problem hiding this comment.
Close to ready: the fix is correct and the test is a real regression pin. One should-fix remains.
Head reviewed: 677cefb. The same-repo AI lanes do not apply to fork PRs, and no fork lane comment is on this head yet. Readiness is action required.
What I verified:
- The root cause matches the code on main: the wrapper appends with
>>and2>>,start()only retired.winresult, andrecent_journaltails both log files. - The new test passes on this head (
test/test_pod_windows.py: 52 passed, 2 skipped on Linux). It fails when onlypod/windows.pyis reverted to the base, so it pins the bug. log_pathsparent exists at that point, becausewrite_task_scriptcreates it.
🟡 1 should-fix (inline): the bare unlink on a log file can fail with a sharing violation on Windows. Before this change that turned into no error. After it, pod up rolls back and fails.
CI notes, not caused by this diff:
PR Hygienefailed against an earlier version of the PR body; the re-run on the edited body was cancelled. Edit the body again or push to re-trigger it.Backend Tests (Windows) (1)failed ontest_ci_ipv6_routing.py(a collection subprocess timeout) and(4)ontest_extras.py(a requirements pin mismatch). Neither touches pod code. The branch is 63 commits behind main, so a rebase may clear the pin mismatch.
| # The wrapper appends to these files, so retire the previous boot's output | ||
| # before scheduling this one; otherwise a refusal can report a stale FATAL. | ||
| for log_path in log_paths(cfg, name): | ||
| log_path.unlink(missing_ok=True) |
There was a problem hiding this comment.
🟡 A sharing violation on a log file now aborts pod up
The wrapper is not the only process that can hold these logs open. This module already retries ERROR_SHARING_VIOLATION on the task wrapper (_unlink_waiting_out_sharing), because an indexer, antivirus, or Task Scheduler can hold a just-used file for a moment. A freshly written log file is a typical scan target. The gateway child also inherits these handles, so any leftover descendant keeps them open. If unlink raises PermissionError (WinError 32), the except OSError below runs _rollback_start, and pod up fails. Before this change, the same state started normally and only appended to the old log.
for log_path in log_paths(cfg, name):
log_path.unlink(missing_ok=True)Why it matters: a cosmetic problem (a stale line in the journal) becomes a failed start on a timing condition the operator cannot see.
Suggestion: use the existing helper, so a brief hold is waited out and a long hold still fails closed:
for log_path in log_paths(cfg, name):
_unlink_waiting_out_sharing(log_path)Add one test that makes the first unlink raise PermissionError with winerror=32 and asserts that start() still succeeds. If you prefer that a held log never blocks a start, you can catch the error, and truncate or skip the retirement instead. Either is fine. Please choose one deliberately.
Rule: AGENTS.md "Cross-platform"; precedent in _unlink_waiting_out_sharing (#16124).
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
Design Review (Opus 5.5, fork) — 🔴 BLOCK (blocking)Design-level review of Design-Verdict: BLOCK The PR deletes the previous boots' logs to fix a stale-FATAL problem that BlockersFix targets an already-marked path and deletes history the docs say is kept
[DESIGN-REVIEWED] 1348e46 Description read[DESCRIPTION-READ] b5a35c86b073a7f11c468c6e594681c61c233a4ef6e830e158ba2ca3f110b0e8 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 |
First Principles Review (Opus 5.5, fork) — 🔴 BLOCKPremise-level review of First-Principles-Verdict: BLOCK Deleting the previous boots' logs repeats what Not justified as shipped
What this change shipsInventory (3 items) — 0 justifiedIntent: Windows pod failures should show only the current boot's cause. FIX.
Blockers
[FIRST-PRINCIPLES-REVIEWED] 1348e46 Description read[DESCRIPTION-READ] f6d5d3547a01ea51b733b03a2dbe1dd914319a564c12b7c0a6ce3a985cac7adb That sha256 names the PR description this verdict read. Recompute it with |
GPT 6.1 Review (fork) — 🔴 changes requested (blocking)Reviewed 1 of 1 blocking finding(s) are security-class and were withheld from adjudication, so the blocking verdict stands. BLOCKING -- src/kiro_crew/pod/windows.py:705 -- Reset journal offsets when recreating the logs
Adjudication (Opus 5.5) — is blocking on each finding proportionate?There are no adjudicable findings. The one fenced finding, F1, stands as written: its trigger is common, so the record a FLAG needs can't be completed. F1 (fenced). The defect is confirmed in code.
Why the trigger is common: the same boot failure repeated on Windows, such as the same FATAL message twice, produces output of identical length. That is an ordinary situation, not an extreme one. Recovery: the full current log is still on disk and readable with [ADJUDICATION] 1348e46 total=0 uphold=0 downgrade=0 [ADJUDICATION-FENCED] 1348e46 fenced=1 flagged=0 |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings blocking merge. FINDING — src/kiro_crew/pod/windows.py:711 — [OPUS-REVIEWED] 1348e46 |
dde47de to
1348e46
Compare
|
Thank you for the fix and for the clear regression test. Main has since solved the same issue in a different way: #21729 (merged, and it closed #21571). On main, With that change on main, this PR is no longer needed, and merging it would now cause a problem. I am closing this as superseded by #21729. If you still see a stale line on Windows with current main, please open a new issue with the output and we will take a look. Thanks again for the contribution. |
Problem / Motivation
Goal: Windows
pod up/pod downrefusals report the current boot's outcome, never stale log lines from a previous boot.On Windows, the Task Scheduler pod wrapper appends boot output to
pod.out.log/pod.err.log(src/kiro_crew/pod/windows.py:443-444), and thepod down/pod upfail-closed refusal tails those files viarecent_journal(src/kiro_crew/pod/cli.py:679,src/kiro_crew/pod/windows.py:1281). Becausestart()never retired the previous boot's logs, a refusal that carried no fault of its own still printed a stale line such asFATAL: no built distfrom an earlier failed start.Why it matters
Windows pod operators get a misleading failure message: the fail-closed refusal surfaces an error left over from a previous boot, so the operator debugs a problem that no longer exists — or masks the real cause. The journal is the only evidence
pod down/pod upprint, so stale entries directly corrupt the diagnosis of every refusal.Not a goal
recent_journaltails them.What changed (motivation → approach → change)
pod down/pod uprefusal printedFATAL: no built distleft over from an earlier failed start.start()retired the previous boot'sresult_pathbut left the previous boot'spod.out.log/pod.err.login place, andrecent_journaltails both files.start()now unlinks the previous boot'spod.out.log/pod.err.log(vialog_paths) beforeschtasks /Create, alongside the existingresult_pathunlink;unlink(missing_ok=True)keeps first-ever starts safe, and the call sits afterwrite_task_script, which already creates the artifacts directory. So the journal only ever contains the current boot's output.Backwards compatibility
Compatible: nothing that works today stops working. The only behavior delta is that the journal no longer contains lines from boots before the current one; the wrapper recreates both log files on every boot, and no key, field, validator, type, or public function is renamed, removed, or narrowed.
Removes nothing: the change only deletes transient log files that the next boot recreates; no path, record, key, or public symbol is taken away.
Tests
test/test_pod_windows.py::test_start_logs_only_the_current_boot_output— a fakeschtasksappends new output to pre-seeded logs containingprevious stdout/FATAL: no built dist, thenrecent_journalmust show only the current boot's lines.src/kiro_crew/pod/windows.pyreverted toorigin/main, the new test fails (AssertionError: assert 'previous stdout' not in ...); restored, it passes..venv/bin/pytest test/test_pod_windows.py -n0— 52 passed, 2 skipped (both skips are win32-only real-schtasks.exetests, skipped on Linux by design)..venv/bin/pytest test/test_pod_windows.py test/test_pod_windows_boot.py test/test_pod_windows_boot_failures.py test/test_pod.py -n0— 614 passed, 6 skipped (same win32-only skips).pod/windows.py::startand its test file.Manual verification
N/A — unit coverage sufficient: the wrapper's log writes and the journal tail are both exercised by the new test and the existing pod suites; no UI, external service, or integration path is involved.
Screenshots / video
N/A — the diff touches no user-visible frontend surface (backend pod lifecycle only).
Related Issues
Pattern harvest
Rule candidate: review-prompt
Pattern: a fail-closed path that tails a shared log file must ensure the producer retires (not appends across runs to) that file at the start of each run, or stale output from a previous run is reported as the current failure.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.