feat: batch validation with auto-managed, resumable sessions#185
Draft
kikkomep wants to merge 15 commits into
Draft
feat: batch validation with auto-managed, resumable sessions#185kikkomep wants to merge 15 commits into
kikkomep wants to merge 15 commits into
Conversation
Introduce the storage location for auto-managed batch validation sessions. Sessions live under the user cache directory (XDG-compliant) in a dedicated `sessions/` subdir; each session file name is a deterministic SHA1 hash of the batch target (scan root, glob pattern, relevant settings) so re-running the same batch command resolves to the same file and can be resumed.
Add the data model backing batch validation: - BatchCrateEntry: per-crate outcome (status, profiles, stats, issues, size, duration) with dict (de)serialization. - BatchSession: the persistent, JSON-serializable session state, tracking the crate entries, validation settings and progress counts, with load/save and completion helpers so a run can be inspected and resumed. - BatchValidationResult: the aggregated result over a session, exposing the overall verdict and the passed/failed entries for reporting.
Add the batch validation service on top of the batch models: - discover_ro_crates(): scan a directory for RO-Crates matching a glob pattern. - resolve_batch_session_path(): map a batch target to its session file. - batch_validate(): validate every discovered crate, persisting progress to the session so an interrupted run can be resumed; resolves profiles per crate (auto-detection), reports progress via a callback, and handles SIGINT by saving the session before aborting.
Add single_choice(): render a single-select list menu from (value, label) pairs and return the chosen value. Used by the interactive session pickers to let the user select a batch session to show or resume.
Serialize a BatchValidationResult to JSON via its to_dict(), adding a `meta` block (generator name and version), and register the formatter for the BatchValidationResult type so batch runs support `--format json`.
Add a statistics reporting module for a batch run, with two entry points: render_statistics() for rich console/text output and render_statistics_md() for markdown. It aggregates per-crate outcomes into an overview (pass/fail/ error), error-type and per-check issue attribution, duration and outlier breakdowns, and detailed tables. Consumed by `sessions show --stats`.
Add the text-mode batch view: BatchValidationCommandView renders a live progress bar on stderr (passed/failed/remaining counts), a per-crate summary table and verbose failure details. Extract shared helpers — render_batch_header, render_batch_footer, format_crate_line and format_profile_selection — so the `validate --batch` run and the `sessions` commands render consistently.
Extend `validate` with batch validation: new -b/--batch, --batch-pattern and --no-resume options. Batch runs discover the RO-Crates under the target, resolve (and auto-resume) the batch session, validate with a progress bar, write the aggregated report — including the new batch-only `csv` format — and exit with the combined status. The single-crate path is extracted into _run_single_validations to keep the two flows separate.
Add the `sessions` command group to inspect and manage the auto-managed batch validation sessions: `path`, `show` (with --stats and text/markdown file export), `resume`, `list`/`ls` and `clear`/`rm` (by ID prefix, --completed or --all). Sessions can be selected by ID prefix or picked from an interactive menu. Register the group with the CLI.
Add tests for batch validation and session management: the validate `--batch` mode and `--batch-pattern`, session auto-resume and `--no-resume`, JSON/CSV report output and statistics, and the `sessions` subcommands (list, show, resume, clear and file export)
kikkomep
marked this pull request as draft
July 13, 2026 11:39
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.
This PR adds batch validation to the CLI:
validate --batchvalidates every RO-Crate found under a directory and aggregates the results, with progress reporting, a per-crate summary table and machine-readable outputs. Each run is recorded as an auto-managed session that is saved incrementally (one save per validated crate), so an interrupted run —Ctrl+C, a crash, a killed job — can be resumed from where it stopped, either automatically by re-running the same command or explicitly via the newsessionssubcommand.What's included
CLI —
validate --batch--batch/-bvalidates every crate underRO-CRATE-URI(subdirectory crates, zipped crates and detached*-ro-crate-metadata.jsonfiles);--batch-patternfilters the crate names.-vadds the details of every failed crate.text(console or file),json,csv(one row per crate).CLI —
sessionssessions list(aliasls): stored sessions with status, progress and target (--status,--json).sessions show <ID>: re-render the recorded output of a session without re-validating anything;--statsfor the statistics,-o report.md -f mdto write them to a file.sessions resume <ID>: continue an interrupted session (only the pending crates are processed).sessions clear(aliasrm) andsessions pathto manage the history.Sessions & resumability
selection and severity: re-running the same command resumes the same session automatically;
--no-resumestarts over. Changing profiles or severity intentionally starts a new session.Memory behaviour
Batch runs keep memory usage flat regardless of the corpus size: per-crate outcomes are persisted to the session file instead of being retained in memory (retaining every live
ValidationResultpinned ~4 MB/crate and got large batches OOM-killed). Live results can still be retained explicitly for debugging or scripting purposes viabatch_validate(..., keep_results=True), exposed asBatchValidationResult.live_results; the recorded outcome of every crate is always available in.crates.Usage