Skip to content

fix: make stdioDebugPreset copy exactly the files selectDebugInputFilePaths selects - #480

Merged
exKAZUu merged 4 commits into
mainfrom
fix/stdio-debug-uses-select-helper
Nov 26, 2026
Merged

exKAZUu merged 4 commits into
mainfrom
fix/stdio-debug-uses-select-helper

Conversation

@exKAZUu

@exKAZUu exKAZUu commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Why

selectDebugInputFilePaths decides from a list of file paths, while stdioDebugPreset decided from the directories on disk. When an example .fin/ directory existed but contained no files, the preset picked that empty directory (and copied nothing from examples) while the helper skipped it and picked the next example that has files. Making the preset feed its file list to the helper removes the divergence, so both selections are one implementation.

Requirements

  • required: stdioDebugPreset selects its debug input files with the semantics of selectDebugInputFilePaths, so the two selections are literally one implementation.
  • required: the preset lists the files under test_cases/ as problem-relative paths, passes them to selectDebugInputFilePaths, and copies exactly the returned files.
  • required: placement and override order stay as today: shared files first, then the example's files overriding same-path shared files.
  • required: the warning debug: no example test case has input files, ... stays meaningful under the new rule.
  • required: the now-redundant internal rule is removed, and every comment, JSDoc and doc describing the old behavior or caveat is deleted or rewritten.
  • required: a boundary test with an empty example_1.fin/ and an example_2.fin/ with a file shows a real preset run sees example_2's file, matching the helper, and it fails without the change.
  • required: the exported selectDebugInputFilePaths signature and result (selected paths in the given order) are unchanged.
  • chosen: the preset copies each selected id's whole .fin/ directory with the judges' copyTestCaseFileInput rather than file by file, because a per-file copy crashed on a symlinked directory and dropped empty subdirectories that the judge places; for a .fin/ all of whose files are selected, the files copied are exactly the returned ones.
  • chosen: the warning fires when some non-shared .fin/ has files but no example's files are copied, because the old "a non-shared .fin/ directory exists" check would also fire for empty directories, which hand nothing to any run.

Customer Summary

A debug run of a standard stdio problem now receives the input files of the first example whose .fin/ has files, even if an earlier example's .fin/ directory is empty, matching what selectDebugInputFilePaths reports to clients.

Technical Summary

  • packages/problem-utils/src/helpers/selectDebugInputFilePaths.ts: the internal selectDebugFileInputTestCaseIds is gone; the id rule is inlined in selectDebugInputFilePaths, and path parsing is extracted to the internal parseFileInputTestCaseId.
  • packages/problem-utils/src/presets/stdio.ts (copyDebugFileInputs): reads the .fin/ directories with readTestCases (as the judge does), lists their files as problem-relative paths, passes them to selectDebugInputFilePaths, and copies the .fin/ of each selected id with copyTestCaseFileInput, shared first so the example's files overwrite same-path shared ones.
  • README.md and the stdioDebugPreset JSDoc: describe the debug preset as copying the .fin/ of the first example case that has input files.

Testing

  • bun run verify: passes.
  • bun wb test test/e2e/stdioDebugInputFiles.test.ts test/e2e/debugAndJudge.test.ts: 36 passed.
  • Added a case to test/e2e/stdioDebugInputFiles.test.ts that creates an empty example_1.fin/ in the temp fixture; with the source change reverted it fails (the run sees no files), and passes with it.
  • Manually ran the preset on a fixture with a symlinked directory and an empty subdirectory in example_1.fin/ (copied like the judge) and on one with an unreadable test_1.fout/ (debug still runs).

Notes

  • Compatibility: the only callers we know of run stdioDebugPreset on git-tracked problem directories (directly or via the server's default harness). Git cannot track empty directories, so no existing problem changes behavior.
  • code-gauge reports a pre-existing error on stdioJudgePreset (cognitive complexity 54, ncss 88), which this change does not modify; left as is.

…ePaths selects

The preset now lists the files under test_cases/, passes them to
selectDebugInputFilePaths, and copies the returned files (shared first, then
the example's), so an example whose .fin/ directory is empty is skipped in
favor of the next example with files, as the helper already did.

Co-authored-by: WillBooster (Claude Code) <agent@willbooster.com>
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request aligns the file selection logic of stdioDebugPreset with selectDebugInputFilePaths. Previously, these two mechanisms diverged when encountering empty directories, leading to inconsistent behavior. By centralizing the selection logic, the debug preset now correctly identifies and copies only the relevant input files, ignoring empty directories and ensuring consistent test case handling.

Highlights

  • Unified Selection Logic: Refactored stdioDebugPreset to use selectDebugInputFilePaths for selecting input files, ensuring that debug runs match the exact behavior of the judge.
  • Improved Empty Directory Handling: Fixed an issue where empty .fin/ directories were incorrectly selected for debug runs, causing them to be skipped in favor of valid test cases.
  • Code Cleanup: Inlined internal logic within selectDebugInputFilePaths and extracted path parsing into a reusable parseFileInputFilePath helper.
New Features

🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.


The files were picked in different ways, Causing bugs in debug days. Now one rule governs all the flow, And empty folders have to go.

Footnotes

  1. Review the Generative AI Prohibited Use Policy, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@exKAZUu exKAZUu self-assigned this Nov 26, 2026
@exKAZUu

exKAZUu commented Nov 26, 2026 •

Copy link
Copy Markdown
Member Author

ReviewFixLoop run summary

Run e28f2f149ca8-2 ended completed at 361d9b69969f.

Run page: https://reviewfixloop.com/runs/e28f2f149ca8-2

Fixed (4)

  • r1 minor packages/problem-utils/src/presets/stdio.ts:262 Document that the preset skips examples without input files
    • Fix (7d9054e0786f): The exported stdioDebugPreset JSDoc still described the old rule (the first example case's .fin/); the defect was local to that JSDoc, which now says it runs with the files selectDebugInputFilePaths selects: _shared.fin/ and the .fin/ of the first example case that has input files. Re-ran grep for 'first example' over packages/*/src, README.md and skills: only the updated JSDoc and the helper's matching JSDoc remain; bun run verify passes.
  • r4 major packages/problem-utils/src/presets/stdio.ts:467 Per-file debug copy places inputs differently from the judge's copyTestCaseFileInput
    • Fix (0f4e167157ee): copyDebugFileInputs had its own per-file mkdir/cp placement next to the judges' copyTestCaseFileInput, so a symlinked directory threw EINVAL and empty subdirectories were dropped. It now reads ids with readTestCases (real .fin directories only, as the judge), lists their files for selectDebugInputFilePaths, and copies each selected id's .fin/ (shared first, then the example) with copyTestCaseFileInput, removing the second placement rule for the whole class. Re-ran the reported fixture (example_1.fin/dir -> ../../common plus empty example_1.fin/out): exit 0 and the program lists dir,dir/data.t…
  • r5 major packages/problem-utils/src/presets/stdio.ts:454 Keep unreadable expected-output directories from aborting debug
    • Already fixed before the report: At 0f4e167 copyDebugFileInputs no longer walks test_cases/ recursively: it takes the .fin directories from readTestCases (top-level entries only, as the base did) and lists only those, so .fout and other non-.fin subtrees are never opened. Re-ran the reported fixture (readable example_1.fin/example.txt, test_1.fout mode 000) at 0f4e167: exit 0, stdout 'example\n'.
  • r6 minor packages/problem-utils/src/helpers/selectDebugInputFilePaths.ts:44 parseFileInputFilePath returns a pathInFileInput that no caller reads
    • Fix (361d9b69969f): Local to the parser: after the preset switched to copying whole .fin/ directories, no caller read pathInFileInput. The function is now parseFileInputTestCaseId returning only the id (or undefined) with the same file-inside-<id>.fin/ check and matching JSDoc; all three callers updated. grep for parseFileInputFilePath/pathInFileInput finds only the unrelated local in listFileInputFilePaths; bun run verify and the two e2e test files (36 tests) pass.

Rejected (1)

  • r2 major packages/problem-utils/src/presets/stdio.ts:457 Normalize paths before passing them to the POSIX parser on Windows
    • Reason: Windows is out of scope: AGENTS.md states 'Ensure compatibility only with macOS and Linux; do not include Windows-specific code', and stdioDebugPreset cannot run a program on Windows on the base either, because spawnWithTimeout.ts:29 throws 'GNU time (gtime on macOS, /usr/bin/time on Linux) is required.' and spawnWithLimits.ts:299 resolves the time command to /usr/bin/time on every non-darwin platform; the README documents GNU time on Linux/macOS as the runner. On macOS and Linux path.relative yields '/'-separated paths, which the boundary test exercises.

exKAZUu and others added 2 commits November 26, 2026 21:40
Co-authored-by: WillBooster (Claude Code) <agent@willbooster.com>
copyDebugFileInputs reads test cases with readTestCases, lists the files of
their .fin/ directories, and copies the .fin/ directories whose files
selectDebugInputFilePaths selects with copyTestCaseFileInput, so symlinks and
empty subdirectories are placed as the judge places them.

Co-authored-by: WillBooster (Claude Code) <agent@willbooster.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the selection and copying of debug input files in the stdioDebugPreset harness. It updates the documentation to clarify that the harness copies the .fin/ directory of the first example case that contains input files. The implementation in selectDebugInputFilePaths.ts and stdio.ts is updated to recursively read the test_cases directory and copy the selected files directly, rather than relying on readTestCases. Additionally, the end-to-end tests are refactored to reduce duplication and a new test case is added to verify that empty example input directories are skipped. The reviewer raised a concern regarding the potential performance impact of using fs.promises.readdir with recursive: true on large test_cases directories.

Co-authored-by: WillBooster (Claude Code) <agent@willbooster.com>
@exKAZUu
exKAZUu merged commit 42d378e into main Nov 26, 2026
4 checks passed
@exKAZUu
exKAZUu deleted the fix/stdio-debug-uses-select-helper branch November 26, 2026 13:03
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