Unify repo-tidy and lfs-tidy JSON emit onto the shared write_json_flat path#199
Merged
Conversation
…t path repo-tidy and lfs-tidy were the last two scan tools still emitting --json via a hand-rolled `result.repos…map(JsonX::from).collect()` followed by `write_json_pretty`; every uniform tool (remote/tag/stash/branch/worktree) already routes through the shared `IntoJsonItem` + `write_json_flat` mechanism. These two are the plan's structural exceptions (#117 §4): they keep their bespoke result types — repo-tidy's flat `RepoScanResult` with disk metrics and the cross-cutting `dirty` count, lfs-tidy's `LfsScanResult` with the `lfs_installed` flag — so they cannot use the blanket `FlatJsonItems for ScanResult<T>` impl in core. Instead they each implement `IntoJsonItem` on their item row type and hand-write a `FlatJsonItems` impl on their bespoke result, then call `shared::write_json_flat`. This is a consistency-only change: the JSON is byte-identical (the same `JsonRepo`/`JsonLfsItem` values in the same order, serialized by the same `write_json_pretty` underneath `write_json_flat`), so the existing `json_output_valid` and `json_*_from_info` tests pass unchanged. No result/group types, classification folds, or orchestration change; both tools stay on Layer 1 (`parallel_classify`) per the plan. With this, all seven scan-shaped tools share one JSON-emit path. Also drop the dead `scan_empty_repo_no_lfs` lfs test stub, which built a mock and then asserted nothing (its real coverage lives in the integration tests). Part of #117
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
repo-tidy and lfs-tidy were the last two scan tools still emitting
--jsonvia a hand-rolledresult.repos…map(JsonX::from).collect()+shared::write_json_pretty. Every uniform tool (remote/tag/stash/branch/worktree) already routes through the sharedIntoJsonItem+write_json_flatmechanism. This change moves the two remaining tools onto it, so all seven scan-shaped tools share one JSON-emit path.Why these two are different
They are the plan's structural exceptions (#117 §4): they keep their bespoke result types — repo-tidy's flat
RepoScanResult(disk metrics + the cross-cuttingdirtycount) and lfs-tidy'sLfsScanResult(thelfs_installedflag) — and stay on Layer 1 (parallel_classify), notrun_pipeline. Because their results are bespoke, they cannot use the blanketimpl<T: IntoJsonItem> FlatJsonItems for ScanResult<T>in core. So each tool:IntoJsonItemon its item row type (RepoInfo/LfsInfo), delegating to the existingFrom, matching the convention of the 5 migrated tools; andFlatJsonItemsimpl on its bespoke result (lfs flattensrepos → items; repo maps its flatreposdirectly, since it has noRepoGroup).write_jsonthen collapses toshared::write_json_flat(out, result).Output is byte-identical
The same
JsonRepo/JsonLfsItemvalues, in the same order, serialized by the samewrite_json_prettyunderneathwrite_json_flat. The existingjson_output_validandjson_*_from_infotests pass unchanged. No result/group types, classification folds, or orchestration change; the audit runner (|r| &r.counts) is untouched.Also
Drops the dead
scan_empty_repo_no_lfslfs test stub, which built a mock and then asserted nothing (its real coverage lives in the integration tests).Local gate jobs green:
cargo fmt --check,cargo clippy --workspace --all-targets -D clippy::all,cargo test --workspace,cargo +1.93.0 check --workspace(MSRV).Part of #117