Skip to content

feat: export selectDebugInputFilePaths for stdio debug input files - #479

Merged
exKAZUu merged 6 commits into
mainfrom
feat/select-debug-input-files
Nov 26, 2026
Merged

exKAZUu merged 6 commits into
mainfrom
feat/select-debug-input-files

Conversation

@exKAZUu

@exKAZUu exKAZUu commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Why

A client that debugs a problem on a judge that has no copy of it must send the problem files itself. Sending everything would hand hidden test cases and model answers to the debugged program, so such a client wants to send only what stdioDebugPreset would give the program anyway: test_cases/_shared.fin/ and the .fin/ of the first example case. Sending only problem.md instead leaves the program without its input files (e.g. pd.read_csv('members.csv') fails in debug while the same code passes judging). Exporting the preset's selection rule lets such a client ship exactly the right files without re-implementing the rule and drifting from the preset.

Requirements

  • required: export from the package entry a pure function that, given problem-relative file paths, returns the paths a debug run may receive
  • required: use the exact rule stdioDebugPreset uses: _shared.fin/ plus the .fin/ of the first example case (sorted ids matching EXAMPLE_TEST_CASE_ID_PATTERN) that has one
  • required: stdioDebugPreset derives its choice from the same rule instead of duplicating it
  • required: never select hidden cases' files, .in/.out, model answers, solutions or templates
  • required: test at the public boundary

Customer Summary

No behavior change for problem authors or learners: stdioDebugPreset copies the same files as before. Tools built on this package can now call selectDebugInputFilePaths(paths) to learn which problem files a debug run receives.

Technical Summary

  • packages/problem-utils/src/helpers/selectDebugInputFilePaths.ts: selectDebugFileInputTestCaseIds holds the rule (sorted ids; _shared first, then the first example id, so the example's files overwrite shared ones at the same path); selectDebugInputFilePaths normalizes each path (./test_cases/... is accepted), maps test_cases/<id>.fin/... paths to ids, applies the rule, and returns the matching paths with their original spelling and order. Only the latter is exported from the package entry.
  • presets/stdio.ts: the debug run's input copying moved to copyDebugFileInputs, which feeds the ids of the existing .fin/ directories to the same rule. The warning for problems whose .fin/ inputs are all on hidden cases is kept.
  • readTestCases.ts: the _shared name is now the exported SHARED_TEST_CASE_ID so both places use one constant.
  • Check hardest: that the preset's choice and copy order are unchanged (sorting and example matching moved, not rewritten).

Testing

  • Added test/e2e/stdioDebugInputFiles.test.ts: on a problem with shared files, examples listed out of sorted order (with and without .fin/, one overriding a shared file), and hidden cases, it checks the helper's selection (including ./-prefixed paths) and that a real stdioDebugPreset run sees exactly those files with the example's content winning. It fails if the rule's sorting, the path normalization, or the preset's copy order regresses.
  • bun run verify passes; bun wb test test/e2e/stdioDebugInputFiles.test.ts test/e2e/stdioWorkingDirectory.test.ts test/e2e/debugAndJudge.test.ts passes.

Notes

  • A .fin/ directory with no files cannot appear in a path list, so in that edge case the helper may pick a later example than the preset; the preset copies nothing from such a directory either.
  • code-gauge reports a pre-existing error on stdioJudgePreset (cognitive complexity 54, ncss 88), which this change does not modify; left as is.

A client that ships only learner-visible files to debug a problem needs to
know which input files the stdio debug preset hands to the program. Export
a pure helper that selects them from problem-relative paths, and make the
preset derive its choice from the same rule.

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

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

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

exKAZUu commented Nov 26, 2026 •

Copy link
Copy Markdown
Member Author

ReviewFixLoop run summary

Run 5a94e38819d5-2 ended completed at ed0bd072b872.

Run page: https://reviewfixloop.com/runs/5a94e38819d5-2

Fixed (5)

  • r1 major packages/problem-utils/src/helpers/selectDebugInputFilePaths.ts:22 Accept problem-relative paths produced by find
    • Fix (662cbedf54e7): selectDebugInputFilePaths classified the raw first path segment, so './test_cases/...' spellings never matched; it now classifies path.posix.normalize(filePath) while returning the original spelling and order, which covers './', redundant segments and '..' that stays inside the root (a path escaping with a leading '../' is still ignored). Re-running repro-relative-paths.ts on 662cbed: selected ['./test_cases/example_1.fin/a.txt'] and the debug run with the shipped files reports ACCEPTED printing 'example'.
  • r2 minor test/e2e/stdioDebugInputFiles.test.ts:32 Exercise example selection with out-of-order file paths
    • Fix (96ad4c82504b): the fixture listed example_2 before example_3, so the caller's order and the sorted order agreed and a selector without sorting passed; the fixture now lists example_3 first while the test still expects example_2 to be selected and to reach the program. Re-run on the fix: the test passes, and with .toSorted() removed from selectDebugFileInputTestCaseIds it fails.
  • r3 minor test/e2e/stdioDebugInputFiles.test.ts:32 Boundary test never exercises the documented `./`-prefixed input paths
    • Fix (f048d5992c2a): the boundary test fed only canonical test_cases/ paths, so nothing tied normalization to selection; it now also asserts that ['./test_cases/example_2.fin/visible.txt', './test_cases/test_1.fin/secret.txt'] selects only the example path with its original spelling. Re-run: the test passes at f048d59 and fails with the helper's classification reverted to filePath.split('/').
  • r4 minor packages/problem-utils/src/helpers/selectDebugInputFilePaths.ts:12 Selector documentation conflates stdin/stdout entries with files inside .fin
    • Fix (ed0bd072b872): the JSDoc excluded '.in/.out files' without scoping it, although files of any name inside a selected .fin/ are selected and copied; it now says every file of any name in the selected .fin/ directories is selected and only the <id>.in/<id>.out entries directly under test_cases/ are excluded. Local to the comment; verify passes.
  • r5 minor test/e2e/stdioDebugInputFiles.test.ts:65 The boundary test still passes when shared inputs overwrite the example's inputs
    • Fix (4c89e6badd73): the fixture had disjoint destination paths and the program printed only names, so the copy order was unobservable; example_2.fin now also holds members.csv, the program prints each file with its content, and the test expects members.csv to hold the example's data. Re-run: passes at the pushed head and fails with the preset's copy loop reversed (ids.toReversed()).

exKAZUu and others added 5 commits November 26, 2026 17:00
Co-authored-by: WillBooster (Claude Code) <agent@willbooster.com>
Co-authored-by: WillBooster (Claude Code) <agent@willbooster.com>
Co-authored-by: WillBooster (Claude Code) <agent@willbooster.com>
Co-authored-by: WillBooster (Claude Code) <agent@willbooster.com>
Co-authored-by: WillBooster (Claude Code) <agent@willbooster.com>
@exKAZUu
exKAZUu merged commit 97c21e0 into main Nov 26, 2026
4 checks passed
@exKAZUu
exKAZUu deleted the feat/select-debug-input-files branch November 26, 2026 08:24
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