validate(): extract resume-file parsing into a named helper#1209
Merged
validate(): extract resume-file parsing into a named helper#1209
Conversation
Addresses @snimu's readability feedback: the previous resume block was a three-level nested ``for``/``try``/``if`` chain inline, which obscured the simple intent ("parse prior JSONL, filter to in-range indices"). Pulling it out into ``_read_prior_rows(path)`` leaves the top-level flow legible: if resume and out_path_p.exists(): prior_rows, completed_indices = _read_prior_rows(out_path_p) if prior_rows: logger.info(...) else: out_path_p.write_text("") The helper preserves the existing semantics: * only rows whose ``index`` is in ``[0, total)`` are kept (so resuming with a smaller ``n`` doesn't leak out-of-range rows into the returned result list or the summary stats); * blank / non-JSON lines and rows without an integer ``index`` are silently skipped; * it returns ``(rows, indices)`` — the indices set is what the main loop uses for the ``todo`` filter. No behavior change; just a refactor + brief docstring explaining the in-range filter rationale.
snimu
reviewed
Apr 20, 2026
| prior_rows.append(row) | ||
| completed_indices.add(row["index"]) | ||
| prior_rows, completed_indices = _read_prior_rows(out_path_p) | ||
| if prior_rows: |
Contributor
There was a problem hiding this comment.
can we move the logging into the helper as well?
Addresses @snimu's follow-up: the log belongs next to the work that produced the row count, so the caller no longer has to reach back for len(prior_rows).
Member
Author
|
Done in 8c14c2e — moved the |
snimu
approved these changes
Apr 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses @snimu's readability feedback on the resume block in
TaskSet.validate()— the previous code was a three-level nestedfor/try/ifchain inline, which obscured the simple intent ("parse prior JSONL, filter to in-range indices").Changes
verifiers/envs/experimental/composable/task.py:Pulls the resume-file reader into a local helper
_read_prior_rows(path) -> (rows, indices)with a brief docstring explaining the in-range filter rationale.Top-level resume flow is now flat and reads top-to-bottom:
No behavior change
Helper preserves existing semantics:
indexis in[0, total)are kept — resuming with a smallernthan a prior run still doesn't leak out-of-range rows into the result list or summary stats.indexare silently skipped (same as before).(rows, indices)so the main loop'stodofilter keeps working unchanged.Test plan
ruff check/ruff format --checkclean🤖 Generated with Claude Code
Note
Low Risk
Low risk refactor confined to
TaskSet.validate()resume handling; intended behavior is preserved but could affect edge cases around malformed JSONL or index filtering if incorrect.Overview
Refactors
TaskSet.validate()resume logic by extracting prior JSONL parsing into a local_read_prior_rows()helper with a docstring, reducing nested control flow.Resume behavior remains the same: it reads existing
out_pathJSONL, filters to in-range integerindexvalues (< total), skips malformed/blank lines, and returns bothprior_rowsandcompleted_indicesfor subsequent validation and logging.Reviewed by Cursor Bugbot for commit 8c14c2e. Bugbot is set up for automated code reviews on this repo. Configure here.