Realignment simplify pass: one rule, one target constant, docs back on their own items - #51
Merged
Merged
Conversation
…n their own items A four-angle review of the realignment surface, prompted by two bugs that both traced to the same rule existing in several copies. **The duplication that caused those bugs was still there.** `DEFAULT_TARGET_BUILD` was exported so the UI could name the build it offers, and then only the Simple mode modal used it: both Advanced cards still carried the literal, and one compared builds with `eq_ignore_ascii_case` where the job uses `builds_match`, which trims. A stored " chm13v2.0" was offered by the card and refused by the job. `is_target_build` is now `pub` and the UI asks it instead of spelling out a comparison. The per-alignment card was also missing the `bam_path` condition, so it offered to re-map rows with no file. **Four doc comments documented the wrong item** — a new item inserted between an existing doc block and its function, four times, twice on public API. The worst had one sentence severed across two items and its tail orphaned twenty lines below. **Measured wins, benchmarked rather than guessed.** The revert's FASTQ writer issued seven `write_all` calls per read into the gzip encoder, paying the encoder's per-call overhead seven times: 1,882 ns/record against 539 for the same bytes assembled once, ~13 minutes of CPU per realignment. `realignable_in_project` was an N+1 over members where the grouped query already existed: 2.7 ms against 17.7 ms on a 2,504-member project, twice per batch. **And one bug, fixed at its own altitude.** Simple mode's running card matched on alignment id, and once the offer was gone it had nothing to match against — so it claimed *any* running job, and a page open on one person announced another person's realignment as theirs. `RealignState` now carries the owning subject, resolved once per job by `App::subject_of_alignment`, and the card matches on that. Tightening the old predicate would have broken the Done card instead; the ownership question needed answering where the mapping lives. Also: `preflight`/`resume_preflight` were the same function twice, `discard` had two implementations, the project card cloned a Vec per frame to read its length, finished states carried progress fields nobody reads, and a user-visible string held an 18-space run. 983 tests, clippy clean, fmt clean. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
A four-angle review (reuse, simplification, efficiency, altitude) of the realignment surface, prompted by two bugs that both traced to one rule existing in several copies.
The duplication that caused those bugs was still there
DEFAULT_TARGET_BUILDwas exported specifically so the UI could name the build it offers — and then only the Simple-mode modal used it. Both Advanced cards still carried the literal, andsources.rscompared builds witheq_ignore_ascii_casewhere the job usesbuilds_match, which trims. A stored" chm13v2.0"would be offered by the card and then refused by the job.is_target_buildis nowpub, and the UI asks it rather than spelling out its own comparison. The per-alignment card was also missing thebam_pathcondition, so it offered to re-map rows with no file — the job fails those atMissingPaths.Four doc comments documented the wrong item
A new item inserted between an existing doc block and the function it documents, four times, twice on public API. The worst had one sentence severed across two items with its tail orphaned twenty lines below. Three were mine from this week.
Measured, not guessed
revert/writer.rs— 7write_allper read into the gzip encoderrealignable_in_project— N+1 over membersproject_reportuses on the same tab; runs twice per batchOne bug, fixed at its own altitude
Simple mode's running card matched on alignment id — and once the offer was gone it had nothing to match against, so it claimed any running job. A page open on subject A during a job on subject B told A their genome was being rebuilt.
RealignStatenow carries the owning subject, resolved once per job byApp::subject_of_alignment, and the card matches on that. Tightening the old predicate tois_some_andwould have broken the "Done" card instead — the ownership question had to be answered where the alignment→subject mapping actually lives.Also
preflight/resume_preflightwere the same function twice differing in sizing and one noun;discardhad two implementations; the project card cloned aVecper frame to read its length; finished states carried progress fields no consumer reads;open_bamwas a one-line alias; the confirm state re-spelledRealignOfferas a tuple; and a user-visible string held an 18-space run (visible in a screenshot of the project card).Deliberately not done
PacedFiledoesn't reachnavigator-align.mapped.bam— ~60 GB, the pipeline's largest write — is unpaced and uncounted, which is why the run log reads0 MB/sthrough the whole mapping stage. Real, and the module exists precisely to record that; but it needs the accounting moved to a crate both sides depend on. Own change.cram.rs/finalize.rsbypassindex::ensure_index, which is the guarded path for the CRAM multi-reference-slice panic. Correctness, not simplification — belongs to/code-review..bai, then SHA-256). All real; all performance features rather than cleanups.worker.rsrather than behindApp— genuine altitude finding, but a refactor of a path that cannot be exercised end-to-end in a quality pass.The review also defended several things: the resume machinery is not redundant (
resumable_by_markerhas a production caller and the two rules catch different failures), the global write counter is the right shape,openvsopen_manyshould stay a caller choice, and the Simple-only confirmation is correct because confirmation belongs to the reader's context rather than to the job.Validation
983 tests, 0 failed — unchanged from before the pass, which is what a behavior-preserving cleanup plus one bug fix should look like. Clippy clean under
-D warnings; fmt clean.🤖 Generated with Claude Code