Item 32: hint when zero .py files found but a .py.txt candidate exists - #426
Conversation
Windows hides known file extensions by default, so a beginner who saves script.py from a text editor or downloads one as an email attachment can end up with script.py.txt without realizing it. REQ-002's empty-repo path previously gave no hint toward this specific, common cause. New :check_hidden_ext_hint subroutine (run_setup.bat), called from the PYCOUNT==0 branch: a cheap errorlevel-only `dir *.py.txt` existence probe gates two extra console/log lines pointing at File Explorer's "File name extensions" setting. Deliberately never echoes the matched filename, since a legal Windows filename can contain '&' -- a live cmd.exe operator once substituted into :log's unquoted echo. Purely additive; never changes ~bootstrap.status.json's state or exit code. Regression test: tests/selftest.ps1's new self.empty_repo.pytxt_hint scenario. Moves Item 32 from CLAUDE.md's Active Backlog to docs/agent-closed-backlog.md; registers the new row in docs/agent-ndjson.md. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A4iE1BRSkUETwz237XeuTW
|
@coderabbitai review Generated by Claude Code |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
|
|
Important Review skippedNo new commits to review since the last review. ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe bootstrapper detects hidden ChangesHidden extension diagnostic
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant Bootstrapper
participant FileSystem
participant Console
participant Log
Bootstrapper->>FileSystem: Check for *.py.txt after no Python files are found
FileSystem-->>Bootstrapper: Return match status
Bootstrapper->>Console: Print extension guidance when matched
Bootstrapper->>Log: Record extension guidance without the filename
Bootstrapper-->>Bootstrapper: Preserve successful empty-repository status
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/selftest.ps1`:
- Around line 91-101: The self.empty_repo.pytxt_hint assertion must validate the
persisted status exit code as well as $pytxtExit. Update $pytxtPass to require
$pytxtStatus.exitCode to match the expected successful value, following the
contract established by the plain empty-folder scenario, and add that persisted
exit-code value to the row’s details.
- Around line 80-85: Move creation of the hidden_ext.py.txt candidate from
before Invoke-Setup to after Invoke-Setup completes its workspace cleanup and
before the setup command probes the directory. Update the surrounding
tests/selftest flow to preserve the existing pytxt hint scenario while ensuring
Invoke-Setup receives the intended work directory.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: f889ef51-771a-440e-8339-2faeb31cdd8f
📒 Files selected for processing (5)
CLAUDE.mddocs/agent-closed-backlog.mddocs/agent-ndjson.mdrun_setup.battests/selftest.ps1
💤 Files with no reviewable changes (1)
- CLAUDE.md
📜 Review details
⏰ Context from checks skipped due to timeout. (9)
- GitHub Check: auto_merge
- GitHub Check: Batch syntax/run check (real)
- GitHub Check: Batch syntax/run check (cache)
- GitHub Check: Batch syntax/run check (contract-uv)
- GitHub Check: Batch syntax/run check (contract-uv-fail)
- GitHub Check: Batch syntax/run check (justme-test)
- GitHub Check: Batch syntax/run check (uv)
- GitHub Check: Batch syntax/run check (conda-full)
- GitHub Check: Batch syntax/run check (uv-dl-fallback)
🧰 Additional context used
📓 Path-based instructions (13)
**/*.ps1
📄 CodeRabbit inference engine (AGENTS.md)
**/*.ps1: Prepend the TLS 1.2SecurityProtocolassignment and retain-UseBasicParsingon every PowerShell 5.1Invoke-WebRequestcall.
Before system-wide installation, silently check elevation withfsutil dirty query %systemdrive% >nul 2>&1; on failure, use the per-user fallback.Do not download packages from PSGallery in CI; use syntax-only PowerShell validation instead.
Files:
tests/selftest.ps1
**/*.{ps1,psm1,psd1}
📄 CodeRabbit inference engine (AGENTS.md)
Validate modified PowerShell files with the .NET AST parser or
tools/ps-compileall.ps1; do not skip validation on Linux, and directly invoke modified scripts after installingpwshwhere practical.
Files:
tests/selftest.ps1
**/*.{bat,cmd,ps1,py,yml,yaml,json}
📄 CodeRabbit inference engine (AGENTS.md)
Run
tools/check_delimiters.pyto validate paired delimiters and quotes while respecting language-specific comments and escaping.
Files:
tests/selftest.ps1run_setup.bat
**/*.{yml,yaml,bat,ps1,py}
📄 CodeRabbit inference engine (AGENTS.md)
Enforce conda-forge only: add conda-forge and remove defaults before updates or installs, and always install with
--override-channels -c conda-forge.
Files:
tests/selftest.ps1run_setup.bat
**/*.{md,bat,cmd,ps1,py,sh,yml,yaml,json}
📄 CodeRabbit inference engine (AGENTS.md)
Keep text ASCII-only and do not manually change line endings; follow
.gitattributes.
Files:
tests/selftest.ps1run_setup.batdocs/agent-ndjson.mddocs/agent-closed-backlog.md
**/*.{bat,cmd,ps1}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{bat,cmd,ps1}: Use ASCII-only characters in batch and PowerShell files; avoid emojis, curly quotes, em-dashes, and other non-ASCII characters.
Preserve CRLF line endings in.bat,.cmd, and.ps1files; do not manually override the repository's.gitattributeshandling.
Files:
tests/selftest.ps1run_setup.bat
**/*.{bat,ps1}
📄 CodeRabbit inference engine (CLAUDE.md)
Quote or escape batch special characters (
&,%,^,!, and~) in variable values; double%insideforloops.
Files:
tests/selftest.ps1run_setup.bat
tests/**/*.ps1
📄 CodeRabbit inference engine (CLAUDE.md)
PowerShell scenario tests should use the
tests/selfapps_<scenario>.ps1naming convention and be wired intotests/harness.ps1with NDJSON rows.
Files:
tests/selftest.ps1
**/*.{bat,ps1,py,yml,json}
📄 CodeRabbit inference engine (CLAUDE.md)
Validate delimiter and bracket/quote balance for supported changed files with
tools/check_delimiters.py.
Files:
tests/selftest.ps1run_setup.bat
**/*
📄 CodeRabbit inference engine (CLAUDE.md)
**/*: Update the relevant knowledge document in the same commit when a change teaches or invalidates a lesson; edit existing entries rather than only appending.
Freeze scope during an iteration loop, implement exactly one missing feature slice, and add exactly one missing test per loop.
Files:
tests/selftest.ps1run_setup.batdocs/agent-ndjson.mddocs/agent-closed-backlog.md
run_setup.bat
📄 CodeRabbit inference engine (AGENTS.md)
run_setup.bat:run_setup.batmust function as a single bootstrapper when dropped beside the application, without requiring committed helper files.
Every branch added torun_setup.bator its related helpers must have a CI test, including feature flags, fallbacks, recovery paths, and fast/full paths.
Keep bootstrapper log messages synchronized with CI parsers; update workflow checks whenever messages or status summaries change.
All embedded helpers must remain base64-encoded under:define_helper_payloads; changing one requires synchronizing the matchingHP_*line and rerunning delimiter checks.
Do not remove tilde prefixes from runtime artifact paths such as~bootstrap.status.json,~setup.log,~environment.lock.txt, and~env.state.json.
run_setup.bat: Keeprun_setup.batself-contained: do not add committed helper files for bootstrap logic; embed helpers as base64 payloads under:define_helper_payloads, and usepython tools/sync_payload.pyto refresh them.
Runpython tools/check_delimiters.py run_setup.batafter every edit torun_setup.bat.
When invoking conda fromrun_setup.bat, usecall "%CONDA_BAT%" ...so the parent batch process continues.
All conda installs must use--override-channels -c conda-forgeto prevent defaults-channel contamination.
Do not depend on console scripts during bootstrap; invoke tools through explicit interpreter paths or direct Python modules/APIs, such aspython -m pipreqs.pipreqs.
Anchor every bootstrap tool invocation to an explicit Python executable such as%HP_PY%or%CONDA_PREFIX%\python.exe; never rely on PATH or activation to select the interpreter.
Keep pipreqs pinned to version 0.4.13; do not upgrade it to 0.5.0 unless the Python-version compatibility constraint is deliberately re-evaluated.
Use tilde-prefixed temporary files such as~setup.logand~bootstrap.status.jsonso they remain easy to ignore and survive crashes.
AvoidEnableDelayedExpansion; if it is necessary, scope it as n...
Files:
run_setup.bat
**/*.{bat,cmd}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{bat,cmd}: For batch assignments, useset "VAR=value"; do not useset VAR="value". Quote variables at every filesystem command call site, except NSIS/D=parameters, which must remain unquoted.
Avoid unscopedEnableDelayedExpansion, preserve correct escaping of special characters, and use ASCII plain text.
Runtools/check_delimiters.pyand apply its batch heuristics, including caret escaping, quoted filesystem variables, escaped pipes, PowerShell operator placement, and spacing afterrem.
Usetools/sync_payload.pyas the only sanctioned method for re-encoding embeddedHP_*payloads inrun_setup.bat; never hand-roll the splice process.
Files:
run_setup.bat
**/*.md
📄 CodeRabbit inference engine (AGENTS.md)
Cite
run_setup.batlocations by stable label or subroutine name rather than exact line number in documentation.
Files:
docs/agent-ndjson.mddocs/agent-closed-backlog.md
🧠 Learnings (1)
📚 Learning: 2026-08-01T02:27:53.952Z
Learnt from: mixmansoundude
Repo: mixmansoundude/Python_vs_Windows PR: 408
File: docs/agent-closed-backlog.md:0-0
Timestamp: 2026-08-01T02:27:53.952Z
Learning: In the documentation files describing the removed UNC warning check in `run_setup.bat`, state only verified behavior: the check emitted `[WARN] UNC paths not supported` for an ordinary local path and was removed because the separate UNC-prefix guard already handles UNC detection. Do not assert the exact `findstr` or cmd.exe backslash-parsing mechanism, since it was not independently verified.
Applied to files:
docs/agent-closed-backlog.md
🪛 Blinter (1.0.113)
run_setup.bat
[warning] 2093-2093: Missing optimization flags for directory operations. Explanation: Directory operations can be faster with appropriate flags. Recommendation: Use /F flag for large directory operations: DIR /F. Context: DIR command could be optimized with /F flag for large directories
(P010)
🔇 Additional comments (4)
run_setup.bat (1)
523-523: LGTM!Also applies to: 2084-2101
tests/selftest.ps1 (1)
84-100: 🔒 Security & Privacy | ⚡ Quick winTest the no-filename logging guarantee.
The scenario passes if the bootstrapper also writes
hidden_ext.py.txtto the log. Use a candidate name containing&, then assert that the candidate name is absent from$pytxtLog.This protects the cmd.exe metacharacter safety property documented in
docs/agent-closed-backlog.mdat Lines 1809-1812.[ suggest_recommended_refactor]
docs/agent-closed-backlog.md (1)
1804-1808: 🎯 Functional CorrectnessVerify the probe scope against
PYCOUNT.The documented command at Line 1806 checks only the current directory. If
PYCOUNTscans subdirectories, a nestedmodule.py.txtfile will not trigger the hint.Confirm the scope in
run_setup.bat. Align the probe with the.pyscan or add a nested regression case. This verification depends on the omittedrun_setup.batimplementation.docs/agent-ndjson.md (1)
201-201: LGTM!
… wipe CodeRabbit review on PR #426: Invoke-Setup deletes and recreates $WorkDir as its first action, which was wiping out the hidden_ext.py.txt file the pytxt hint scenario seeded before calling it -- the scenario would always run against an empty directory and throw. Fixed by adding an optional -Prepare scriptblock to Invoke-Setup, invoked after the workspace wipe/recreate/ batch-copy but before run_setup.bat runs. Also: assert the persisted ~bootstrap.status.json exitCode (not just the process exit code), and use a candidate filename containing '&' to prove the hint's own log lines never echo the matched filename (the load-bearing security property :check_hidden_ext_hint's header comment describes). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A4iE1BRSkUETwz237XeuTW
|
@coderabbitai review Generated by Claude Code |
|
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/selftest.ps1`:
- Around line 79-117: Move the self.empty_repo.pytxt_hint scenario from
tests/selftest.ps1 into tests/selfapps_hidden_ext_hint.ps1, preserving its
setup, assertions, output, and failure behavior. Register the new scenario in
tests/harness.ps1 and batch-check.yml using the existing scenario-test
conventions.
- Around line 97-99: Update the filename-leak checks around $pytxtNameLeaked to
read ~setup.log in addition to $pytxtLog, evaluate the escaped candidate name
against both bootstrap log streams, and require absence from both in $pytxtPass.
Record the two leak-check results in the scenario details alongside the existing
status information.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 96659fe3-a516-40db-a027-7f031da1fa42
📒 Files selected for processing (1)
tests/selftest.ps1
📜 Review details
🧰 Additional context used
📓 Path-based instructions (9)
**/*.ps1
📄 CodeRabbit inference engine (AGENTS.md)
**/*.ps1: Prepend the TLS 1.2SecurityProtocolassignment and retain-UseBasicParsingon every PowerShell 5.1Invoke-WebRequestcall.
Before system-wide installation, silently check elevation withfsutil dirty query %systemdrive% >nul 2>&1; on failure, use the per-user fallback.Do not download modules from PSGallery in CI; use syntax-only validation where applicable.
Files:
tests/selftest.ps1
**/*.{ps1,psm1,psd1}
📄 CodeRabbit inference engine (AGENTS.md)
Validate modified PowerShell files with the .NET AST parser or
tools/ps-compileall.ps1; do not skip validation on Linux, and directly invoke modified scripts after installingpwshwhere practical.
Files:
tests/selftest.ps1
**/*.{bat,cmd,ps1,py,yml,yaml,json}
📄 CodeRabbit inference engine (AGENTS.md)
Run
tools/check_delimiters.pyto validate paired delimiters and quotes while respecting language-specific comments and escaping.
Files:
tests/selftest.ps1
**/*.{yml,yaml,bat,ps1,py}
📄 CodeRabbit inference engine (AGENTS.md)
Enforce conda-forge only: add conda-forge and remove defaults before updates or installs, and always install with
--override-channels -c conda-forge.
Files:
tests/selftest.ps1
**/*.{md,bat,cmd,ps1,py,sh,yml,yaml,json}
📄 CodeRabbit inference engine (AGENTS.md)
Keep text ASCII-only and do not manually change line endings; follow
.gitattributes.
Files:
tests/selftest.ps1
**/*.{bat,ps1}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{bat,ps1}: Use ASCII-only characters in Windows batch and PowerShell files; do not add emojis, curly quotes, em dashes, or other non-ASCII characters.
Preserve CRLF line endings in.batand.ps1files.
Files:
tests/selftest.ps1
**/*.{bat,ps1,py}
📄 CodeRabbit inference engine (CLAUDE.md)
Use tilde-prefixed temporary and generated files such as
~setup.logand~bootstrap.status.json.
Files:
tests/selftest.ps1
**/*.{bat,ps1,py,yml}
📄 CodeRabbit inference engine (CLAUDE.md)
Tag non-obvious constraints with comments such as
# derived requirement: <why>so future changes do not regress them.
Files:
tests/selftest.ps1
**/tests/**/*.{py,ps1,bat}
📄 CodeRabbit inference engine (CLAUDE.md)
Add Python unit tests as
tests/test_<topic>.pyand PowerShell scenario tests astests/selfapps_<scenario>.ps1; wire new PowerShell scenarios intotests/harness.ps1andbatch-check.yml.
Files:
tests/selftest.ps1
🧠 Learnings (1)
📓 Common learnings
Learnt from: CR
Repo: mixmansoundude/Python_vs_Windows
Timestamp: 2026-08-09T04:36:08.111Z
Learning: Keep the knowledge documents current in the same commit when a change teaches or invalidates a lesson; edit existing entries rather than only appending.
Learnt from: CR
Repo: mixmansoundude/Python_vs_Windows
Timestamp: 2026-08-09T04:36:08.111Z
Learning: Freeze scope for the current iteration loop; defer new requirements to the backlog and implement exactly one missing feature slice and one missing test per loop.
Learnt from: CR
Repo: mixmansoundude/Python_vs_Windows
Timestamp: 2026-08-09T04:36:08.111Z
Learning: Fix CI and pipeline problems before test errors, test assertions, and product code; after reaching green, verify there are no false positives.
Learnt from: CR
Repo: mixmansoundude/Python_vs_Windows
Timestamp: 2026-08-09T04:36:08.111Z
Learning: Run the full mandatory sanity sweep before every commit, extending the ASCII file list to cover all touched files.
🔇 Additional comments (1)
tests/selftest.ps1 (1)
44-50: LGTM!
CodeRabbit review on PR #426: the pytxt hint scenario only checked the captured console output (~pytxt_bootstrap.log) for the candidate filename, not run_setup.bat's own internal %LOG% stream (~setup.log) -- a leak into that second stream would have passed the scenario undetected. Now checks both and records each result separately in the row's details. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A4iE1BRSkUETwz237XeuTW
|
@coderabbitai review Generated by Claude Code |
|
|
Summary
Closes CLAUDE.md Active Backlog Item 32. Windows hides known file extensions by default, so a
beginner who saves
script.pyfrom a text editor or downloads one as an email attachment canend up with
script.py.txtwithout realizing it. REQ-002's zero-.py-files path previouslyprinted only the generic
Python file count: 0/No Python files detected; skipping environment bootstrap.with no hint toward this specific, common cause.New
:check_hidden_ext_hintsubroutine (run_setup.bat), called from thePYCOUNT=="0"branch right after the existing message: a cheap
dir /b /a-d *.py.txt >nul 2>&1existenceprobe (errorlevel only, no capture) gates two extra console/log lines pointing at File
Explorer's View tab "File name extensions" setting.
&-- a live cmd.exe operator once substituted into
:log's unquoted echo (seedocs/agent-lessons-learned.md's ":log echoes UNQUOTED" entry). An errorlevel-only existencecheck sidesteps the whole hazard class instead of needing to sanitize a captured name.
~bootstrap.status.json'sstateorexitCode.Regression test:
tests/selftest.ps1's newself.empty_repo.pytxt_hintscenario -- a freshscratch dir with only a
hidden_ext.py.txtfile (no real.pyfile), assertingstate == no_python_files,pyFiles == 0,exitCode == 0(identical to the plain empty-folder case)AND that the hint text appears in the bootstrap log. New row registered in
docs/agent-ndjson.md;tools/check_ndjson_registry.pyconfirms no doc/code mismatch.Item 32 moved from CLAUDE.md's Active Backlog to
docs/agent-closed-backlog.md's Closed ActiveBacklog Items section (keeping its original number).
Test plan
tools/run_sanity_sweep.sh run_setup.bat tests/selftest.ps1 docs/agent-ndjson.md docs/agent-closed-backlog.md-- all clean, 515 passed / 3 skipped.python tools/check_delimiters.py run_setup.bat-- clean.python tools/check_ndjson_registry.py-- 298/298 doc-registered IDs match code-emittedIDs, no mismatch (new
self.empty_repo.pytxt_hintrow correctly cross-referenced).tests/selftest.ps1-- clean.Generated by Claude Code