AGENTS.md — VarDictRust¶
Universal Coding Agent Contract (Open standard for Claude, Cursor, Copilot, Codex, Gemini CLI, Antigravity, and AI pair-programmers; formerly
CLAUDE.md). In-code citations citingCLAUDE.md §Xrefer directly to section §X of this file (AGENTS.md).
VarDictRust is an idiomatic-Rust rewrite of VarDictJava v1.8.3 (a somatic/germline variant caller for NGS), consolidating its fragmented Java→R→Perl pipeline into a single, statically-compiled, memory-safe binary that scales to deep WGS. It is built under the rewrites.bio manifesto.
- Reference implementation:
./VarDictJava(v1.8.3, commit0886261; Perl/R submodule./VarDictJava/VarDict, commit009e017). - Prime directive: a faster, more robust tool that produces output identical to VarDictJava v1.8.3 on valid inputs by default (
--compat=vardictjava/--parity), with opt-in--compat=off(CompatProfile) correctness fixes and explicit CLI capabilities (--vcf-all-alleles,--output,--tbi/--csi). We are not writing a speculative caller and not transliterating Java line-by-line. - Architecture & Governance: see ROADMAP.md for
--compat=vardictjava|off(CompatProfile) governance, consolidatedvar2vcfflags, and roadmap milestones. - Testing & Verification Matrix: see docs/testing/test-matrix-and-ci-audit.md and harness/README.md. This file is the always-loaded agent contract.
0. Meta-rule — evidence before completion¶
Never claim a task is done without evidence. Evidence = a passing harness/compare.sh MATCH, a passing
cargo test, or a diff that shows a match. "It should work" / "this looks right" is not evidence. If you
cannot produce evidence, say so explicitly and keep working.
0b. Integrity — never fake a pass¶
The success criterion exists to catch you being wrong. Do not defeat it. You must NEVER:
- relax --eps, narrow a --cols range, compare fewer records, or edit/skip/#[ignore]/comment-out/delete a failing test or anything in harness/ to turn a MISMATCH into a MATCH;
- hand-edit golden/, expected/, or oracle output to match your code (golden files change ONLY after a verified upstream correction, with explicit provenance documented in golden/PROVENANCE);
- manually edit engine fingerprints, variant counts, or metrics in benchmarks/evidence/*.json or fake runner receipts to satisfy acceptance gates. Modifying evidence JSON files by hand without executing the underlying live validation runners (harness/run_extended_coverage.sh, harness/run_multimodal_slices.sh, or harness/recertify.sh) is a Class-0 integrity violation. Success criteria must come from verifiable runner execution per docs/testing/test-matrix-and-ci-audit.md. If a fingerprint changes due to a dependency or code update, re-certify honestly via bash harness/recertify.sh;
- report a MATCH or a passing test you did not actually run, or paste expected output you did not observe.
If a check fails, your code (or your understanding) is wrong — fix the port, not the test. If you can't make it pass honestly, stop and report the MISMATCH with the diff. A real mismatch reported honestly is worth far more than a fake match.
Oracle nondeterminism: VarDictJava has known run-to-run output-ordering nondeterminism (issue #282; see VarDictJava/tests/integration/test_non_deterministic_behavior). The comparators align records by chrom/pos/ref/alt, so ordering alone never causes a false mismatch — if order is the only difference it is already a MATCH; never change the engine to chase it.
0c. Real-data empirical grounding — never base findings or rulings on synthetic data or theory alone¶
Every scientific, calling, normalization, statistical, or performance finding and autonomous ruling MUST be grounded in real sequencing data.
- Before adopting or certifying any calling heuristic, allele-consolidation policy, strand/statistical model, CompatProfile switch, or performance claim, validate it empirically against real public sequencing BAMs/CRAMs and orthogonal truth callsets (e.g. scratch/g4: NIST GIAB HG002 + CMRG, NIST GIAB HG008, FDA SEQC2 HCC1395/HCC1395BL, COLO829, Wave-4 QIAseq SPE ctDNA & Illumina Amplicon PE) using read-level inspection (QNAME, CIGAR, pileup -p -D) and truth-set evaluation (rtg vcfeval, bcftools norm).
- Synthetic micro-BAMs and unit tests (engine_behavior.rs, fixtures/micro/) exist to lock in minimal deterministic regression cases after behavior is proven on real sequencing alignments; they are never sufficient on their own to justify a scientific finding or design ruling.
The four behavioral principles below are Andrej Karpathy's (multica-ai/andrej-karpathy-skills), reproduced and merged with VarDictRust-specific notes (marked VR:) as that file invites.
Tradeoff: these guidelines bias toward caution over speed. For trivial tasks, use judgment. They override habit, not the project rules in §5–§18.
1. Think Before Coding¶
Don't assume. Don't hide confusion. Surface tradeoffs.
Before implementing: - State your assumptions explicitly. If uncertain, ask. - If multiple interpretations exist, present them — don't pick silently. - If a simpler approach exists, say so. Push back when warranted. - If something is unclear, stop. Name what's confusing. Ask. - VR: before porting any function, read its VarDictJava source and restate in one sentence what it does; flag any ambiguity in the Java before writing Rust.
2. Simplicity First¶
Minimum code that solves the problem. Nothing speculative.
- No features beyond what was asked.
- No abstractions for single-use code.
- No "flexibility" or "configurability" that wasn't requested.
- No error handling for impossible scenarios.
- If you write 200 lines and it could be 50, rewrite it.
Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, simplify.
- VR: the primary exception is fidelity — replicating VarDict's exact heuristics and edge cases in default --compat=vardictjava mode is the task, so it is never "speculative." Beyond parity, only governed opt-in CompatProfile (--compat=off) corrections and explicit CLI flags (--vcf-all-alleles, --output, --tbi/--csi, --stats-json) in ROADMAP.md are permitted.
3. Surgical Changes¶
Touch only what you must. Clean up only your own mess.
When editing existing code: - Don't "improve" adjacent code, comments, or formatting. - Don't refactor things that aren't broken. - Match existing style, even if you'd do it differently. - If you notice unrelated dead code, mention it — don't delete it.
When your changes create orphans: - Remove imports/variables/functions that YOUR changes made unused. - Don't remove pre-existing dead code unless asked.
The test: every changed line should trace directly to the task.
4. Goal-Driven Execution¶
Define success criteria. Loop until verified.
Transform tasks into verifiable goals:
- "Port isGoodVar" → "write the unit test encoding VarDictJava's accept/reject table, then make it pass"
- "Fix the mismatch" → "make bash harness/compare.sh <ref> <bam> <bed> print MATCH"
- "Refactor the pileup" → "bash harness/run_integration.sh and bash harness/rgate.sh are green before and after"
For multi-step tasks, state a brief plan:
Strong success criteria let you loop independently. Weak criteria ("make it work") require constant clarification. Here the criterion is almost always harness/compare.sh exits 0 (MATCH) or the named cargo test passes.
These principles are working if: fewer unnecessary changes in diffs, fewer rewrites due to overcomplication, and clarifying questions come before implementation rather than after mistakes.
5. Emulate exactly (the rewrites.bio prime directive)¶
Default output (--compat=vardictjava / --parity) must match VarDictJava v1.8.3 on valid inputs:
- Exact: the variant set (chrom/pos/ref/alt), every FILTER decision, the INFO/FORMAT keys present, genotypes, TYPE, somatic STATUS, and the intermediate column counts & order — Simple 36/38, Amplicon 38/40, Somatic 55/61 (no---fisher / with---fisher).
- Float tolerance: Fisher p-values/SBF/SSF, odds ratios, AF/AdjAF/HIAF, QUAL means within ε = 1e-6, after replicating R's 5-decimal HALF_EVEN rounding (Fisher MLE tol ulp(1)^0.25).
- Bug policy (v1.x default parity vs --compat=off): if v1.8.3 has an output bug, replicate it under default --compat=vardictjava (--parity) and track it — do not silently change default output. Bona fide corrections to upstream output bugs ship under opt-in --compat=off (CompatProfile, stamping ##VarDictRustCompat=off in VCF headers). Where v1.8.3 crashes (e.g. modifyCigar), do not crash: produce the same output it would on valid inputs. That is allowed and is the whole point.
- Three commitments: credit the original (README.md/--version/Lai et al. 2016/AstraZeneca-NGS); emulate exactly by default; be transparent about AI (document tools, role, and exactly what was/wasn't validated, against which version + dataset).
- Release policy (v1.x Default Parity vs v1.1.0+ CompatProfile & Opt-In Flags): Default invocations across v1.x (--compat=vardictjava, aliases vardictjava-1.8.3 / 1.8.3, or --parity) preserve 100% byte-for-byte parity with v1.8.3: no default output-changing fixes and zero per-bug --fix CLI flags — except parity-restoring fixes, which ship UNGATED as default. A fix qualifies iff (a) it MATCHes the v1.8.3 oracle everywhere measured, (b) the prior default never matched the oracle on that path (Rust-only artifact, no upstream behavior replicated), and (c) any unreleased gating plumbing is removed rather than kept as a no-op. Precedent: splice-tile-ownership, mate-window-ownership (ROADMAP.md "Landed as Default"). True output-changing corrections to upstream v1.8.3 bugs ship from v1.1.0+ per ROADMAP.md as fields on CompatProfile activated together by --compat=off (default off, zero per-bug --fix flags) with a diff-confinement gate, alongside explicit opt-in CLI feature flags (--vcf-all-alleles / --all-alleles, --output, --tbi / --csi, --stats-json).
6. Coordinate indexing — the #1 silent footgun¶
- BAM/SAM positions from noodles are 0-based, half-open → type
Pos0. - VCF output and VarDict-internal logic are 1-based → type
Pos1. - Convert only via
.to_one_based()/.to_zero_based(). Never add a raw integer to a position. - If you are unsure whether a value is 0- or 1-based: STOP and re-read the Java. Do not guess. Coordinate errors are silent and clinically catastrophic.
7. The port loop (rewrites.bio "work small")¶
Pick ONE VarDictJava function
→ read its source (cite it: /// ports CigarModifier.java:61-71)
→ write the Rust port + its unit test
→ run harness/compare.sh `<case>` (or `cargo test <name>`)
MATCH → commit, pick the next function
MISMATCH→ debug THIS function; change nothing else
8. Fidelity hazards (these break output equivalence silently)¶
- Iteration order is correctness. Use
indexmap::IndexMapwhere Java usesLinkedHashMap,BTreeMapwhere Java usesTreeMap. Never iterate aHashMapin an output/realignment path. - Rounding. Every float written to a
.var/VCF field goes throughround_half_even(default--compat=vardictjavaOpenJDKDecimalFormatbanker's rounding) orround_half_even_compat(whenCompatProfile::exact_binary_half_evenis active under--compat=off), never Rust's default. Replicate the formatter split: no---fisherkeeps trailing zeros (x==0?0:fmt);--fisherstrips trailing zeros. - Sequences are bytes. Use
&[u8]/Vec<u8>, neverString. Replace Java's negative-indexcharAt/substrwith bounds-checked slice helpers returningOption. - Quality is Phred+33.
Phred(byte.saturating_sub(33)). maxReadLengthpropagation matters: SomaticMode seeds BAM2's pipeline with BAM1's value.- Java
HashMapiteration that reaches output is emulated withJavaHashMap. It portsjava.util.HashMapspread, bin, resize and treeify-trigger semantics, and is validated against real Java by the op-log tests. This is the only sanctioned non-sorted order. Never usestd::collections::HashMapthere.
9. Idiomatic Rust + the no-panic rule¶
- No panics in library code. In
crates/vardictrust-core/src/**(outside#[cfg(test)]) you may not useunwrap,expect,panic!,unreachable!, bare slice indexingx[i]without a prior bounds check, or arithmetic that can overflow on input. UseResult<_, VardictError>+?,.get(i)?, checked/saturating math. This is what fixes the VarDictJava crash-issue family by design. #![forbid(unsafe_code)]invardictrust-core.unsafeonly via vetted SIMD crates (e.g.block-aligner) behind safe APIs.- Model the data contract as types, not strings:
enum VariantDesc/CigarOp/VarType/SomaticStatuseach with aDisplaythat reproduces the exact VarDict tokens (+seq,-len,&,^,#,<DUP>,StrongSomatic, …). thiserrorfor the library error enum,anyhowin the CLI. Errors must be actionable (no cryptic stacktraces).- Pass
Arc<Config>explicitly — no mutable global singleton. - Prefer iterators/pattern-matching over index loops and string-switches — while preserving iteration order.
- Decompose large Java god-classes (e.g. the 2376-line
CigarParser) into cohesive functions. Add traits only where there are ≥2 real implementations.
10. Scale rules (optimize for large WGS by default)¶
- Bounded memory at any depth. The unit of work is a region tile with a halo; never hold whole-chromosome state. Stream reads through the per-tile pipeline and drop them promptly (RAII).
- Tiled output must equal a single-region run (overlap + boundary-variant dedup). Scale optimizations must never change output.
rayonwork-stealing across tiles; deterministic ordered output (stable sort + ordered collect; bounded backpressure).- Sort only within a tile (no global sort). Multi-thread BGZF. AVX2 (
block-aligner) for the realignment hot path — but only after correctness is established, and re-validate viabash harness/acceptance.shafter. - Cluster Resource Etiquette & Concurrency Guidelines:
- Multi-threaded testing and variant calling should be matched to available cores without exhausting host memory (
-th <N>, default all cores; for tests,RUST_TEST_THREADS=4or--test-threads=8). - On shared multi-tenant clusters or memory-constrained machines, wrap long-running benchmarks or differential tests with
harness/courtesy.sh(nice -n 19 ionice -c 3, with disk headroomMIN_FREE_GB=150and memory headroomMIN_AVAIL_GB=12).
11. Which VarDictJava issues we fix (default parity vs --compat=off)¶
- Default parity (
--compat=vardictjava/--parity): fixes only issues that change no valid-input output (staying byte-comparable to v1.8.3 while strictly more robust): themodifyCigarcrash family (#341/#243/#253/#283/#7/#38/…), NPE/AIOOBE/div-by-zero, OOM (#197/#384 — fixed by tiling in §10), CRAM (#249/#380 — noodles +-Gdecode), locale-independent formatting, fail-fast on missing index (#187) and missing/past-end FASTA.faicontigs (#393), BED column 4'apostrophe gene annotations such as3'_UTR(VarDict #172 — no Rread.tablequote truncation), lenient SAM validation, nondeterminism (#282/#181/#356), and correct##contiglengths from.fai(#320). - Opt-in
v1.1.x+--compat=off(CompatProfile,##VarDictRustCompat=off),--orientation-bias,--noise-model,--methylation&--vcf-all-alleles: activates 49 verified correctness fixes without per-bug--fixflags (sanitize_sample_infoAstraZeneca-NGS/VarDictJava#116,standard_dup_symbolic_altAstraZeneca-NGS/VarDictJava#342<dup-N>\(\to\)<DUP>,shift3_3prime_allelesAstraZeneca-NGS/VarDictJava#292,strict_region_boundsAstraZeneca-NGS/VarDictJava#369,suppress_pileup_sentinelsUB-1/UB-2,live_duprate,preserve_mixed_sex_contigs,cigar_homopolymer_mergeAstraZeneca-NGS/VarDictJava#402,eqx_cigar_read_lengthSAM=/X,preserve_discordant_svsUB-5,mark_dup_sv_inclusive_endUB-6,sv_lazy_mate_pileup,exact_binary_half_even,reconcile_vd_dpAstraZeneca-NGS/VarDictJava#92/AstraZeneca-NGS/VarDictJava#386/AstraZeneca-NGS/VarDictJava#400,coordinate_sorted_varsUB-3/AstraZeneca-NGS/VarDictJava#282,exact_35_overlap,exact_cigar_dlen_match,somatic_continue_after_bad_varjoachimwolff/VarDictJava#4/clintval/vartovcf#139,adaptor_all_consensus_dirsAstraZeneca-NGS/VarDictJava#240/AstraZeneca-NGS/VarDict#119,canonical_sv_vcf_anchoringAstraZeneca-NGS/VarDictJava#398/clintval/vartovcf#192,paired_somatic_ampliconAstraZeneca-NGS/VarDictJava#378,cigar_strip_outer_hard_clipsAstraZeneca-NGS/VarDictJava#341/AstraZeneca-NGS/VarDictJava#103,nonnegative_subtracted_meansbcbio/bcbio-nextgen#1704,reconcile_strand_and_hq_sumsAstraZeneca-NGS/VarDictJava#316/clintval/vartovcf#120/clintval/vartovcf#142,reconcile_rd_vd_dpAstraZeneca-NGS/VarDict#168/AstraZeneca-NGS/VarDictJava#323/clintval/vartovcf#102,sanitize_iupac_alt_allelesAstraZeneca-NGS/VarDictJava#267/AstraZeneca-NGS/VarDictJava#287/bcbio/bcbio-nextgen#3321,sv_respect_min_lenAstraZeneca-NGS/VarDictJava#328/AstraZeneca-NGS/VarDict#157,pileup_preserve_shifted_refAstraZeneca-NGS/VarDictJava#330,recompute_vartype_after_adj_complexclintval/vartovcf#109/clintval/vartovcf#147,strict_vcf_ad_number_rclintval/vartovcf#101/AstraZeneca-NGS/VarDict#75/AstraZeneca-NGS/VarDict#76/EBIvariation/vcf-validator#99,omit_nonsv_vcf_endclintval/vartovcf#105,canonical_vcf_gtclintval/vartovcf#99/clintval/vartovcf#54/AstraZeneca-NGS/VarDictJava#344/AstraZeneca-NGS/VarDict#186,sclip_majority_count_firstVariationUtils.java:90,mate_overlap_both_strandsClinical-Genomics/BALSAMIC#1396/AstraZeneca-NGS/VarDictJava#239,canonical_vcf_complex_left_alignAstraZeneca-NGS/VarDictJava#264/mskcc/vcf2maf#279,somatic_reconcile_split_allelesclintval/vartovcf#191/clintval/vartovcf#195,adj_snv_full_sclip_matchclintval/vartovcf#181/clintval/vartovcf#186,indel_only_shift3AstraZeneca-NGS/VarDictJava#263/clintval/vartovcf#117,somatic_loh_homozygous_altSomaticPostProcessModule.java:221,238,mnp_exact_right_foldclintval/vartovcf#101/clintval/vartovcf#155/clintval/vartovcf#160,strict_unspanned_lgins_stitchVariationRealigner.java:1872-1960/AstraZeneca-NGS/VarDictJava#363,consensus_bam_compatpalakpsheth/VarDictRust#96fgumi/fgbiocD/aD/bD/MIconsensus-BAM/CRAM interop,insertion_hicov_and_local_amp_dpToVarsBuilder.java:395,551,868,mnp_cis_haplotype_phasingVariationRealigner.java:280-360/clintval/vartovcf#160,complex_indel_and_lgins_concordanceVariationRealigner.java:903,2061/AstraZeneca-NGS/VarDictJava#363,spliced_overhang_and_homopolymer_filterCigarParser.java/AstraZeneca-NGS/VarDictJava#381,somatic_multiallelic_loh_rescueSomaticPostProcessModule.java:221,238,continuous_pstd_qstdclintval/vartovcf#140/AstraZeneca-NGS/VarDictJava#274, andsv_downstream_vcf_interoppalakpsheth/VarDictRust#160VCFv4.2/v4.3SVLEN Number=A,<INS>, and pairedSPLITREAD/SPANPAIRSV/BND interop), while explicit--vcf-all-alleles(--all-alleles, hidden alias--vcfall) resolves UB-7/AstraZeneca-NGS/VarDictJava#65multi-allelic collapsing (var2vcf_*.pl -A),--orientation-biasannotatesF1R2/F2R1/OBP/SOBand filters low-AF FFPE/8-oxoG artifacts,--noise-modelannotatesINFO/ERRPand filters sub-ceiling polymer-stutter indels (PolymerNoise, enabled by default on--preset hifi|ont),--methylationannotatesFORMAT/METHandINFO/DMETHfromMM:Z/ML:B:C,--amplicon-single-primer(-sp) supports single-primer extension panels (AstraZeneca-NGS/VarDictJava#303), and--preset wgs|wes|amplicon|ctdna|hifi|ontcalibrates short-read, ctDNA, and PacBio HiFi / ONT long-read workflows. - Deferred (
v2.0): specification-gated calling heuristics (AstraZeneca-NGS/VarDictJava#62over-filtering,AstraZeneca-NGS/VarDictJava#363realignment drops,AstraZeneca-NGS/VarDictJava#381low-AF noise) and next-generation features (native in-caller UMI collapsing, learned Beta-Binomial orientation priors, and 2-bit DNA / ring-buffer pileup optimizations). See ROADMAP.md and docs/upstream-bugs.md.
12. Unsupported features error loudly¶
If a flag/mode isn't implemented: return Err(VardictError::Unsupported("--foo not implemented in VarDictRust; use VarDictJava")) (e.g., -C, -Z/--downsample, -VS STRICT, and AstraZeneca-NGS/VarDictJava#378 paired -b "tumor|normal" + -a in default --compat=vardictjava VCF mode), reject unknown --compat targets with VardictError::Unsupported, and reject conflicting --compat/--parity flags with VardictError::Parse.
Never silently ignore a flag or emit wrong output.
13. Do NOT use these crates (hallucinated or unfit)¶
genomicframe-core, rustalign-simd, ksw2rs, seqair, cyanea-align.
Use: noodles (BAM/CRAM/FASTA/VCF/BGZF), bio + (later) block-aligner (alignment), statrs +
fishers_exact (stats), rayon, clap, anyhow/thiserror, indexmap.
14. Commands¶
Setup (run once): see CONTRIBUTING.md (Prerequisites) — rustup, miniconda, samtools, JDK, and reference-genome setup. Confirm every version prints before starting development.
Testing Hierarchy Details: see docs/testing/test-matrix-and-ci-audit.md and harness/README.md.
# Build / test / lint / format — ALL must pass before any commit (zero warnings):
cargo fmt --all
cargo clippy --all-targets --all-features -- -D warnings
cargo test
cargo build --release
# Reference oracle (VarDictJava 1.8.3 via bioconda, env "vardict-oracle"):
bash harness/setup_oracle.sh
bash harness/run_oracle.sh <ref.fa> <bam|tumor.bam|normal.bam> <bed> <out.vcf> [sample]
# Differential testing (Acceptance gates — see harness/README.md):
# Tier 1 (Intermediate Table Parity): validates .var schema (36/38, 38/40, 55/61 cols), ratios, p-values
python3 harness/compare_var.py golden/<case>.var <ours.var>
# Tier 2 (Full VCF Parity): validates VCF coordinates, alleles, INFO/FORMAT tags, half-even float rounding
bash harness/compare.sh <ref> <bam|tumor.bam|normal.bam> <bed> [sample]
# Fast developer inner-loop gate (<30s):
bash harness/rgate.sh
# Slice big BAMs for the dev loop:
bash harness/slice.sh <in.bam> <chr:start-end> <out.bam>
15. Definition of done (every change)¶
cargo fmt --all,cargo clippy --all-targets --all-features -- -D warnings,cargo testall pass.- The relevant
harness/compare.shprints MATCH (or the named test passes). Pre-PR compound gate passes:bash harness/pr_check.sh(Tier A Per-PR Gate: workspace tests, 92-fixture Tier-1 corpus,micro+s1a..s9slices, 17-modality extended coverage--no-record, 18-slice multimodal suite--no-record,perf_budget.py, andgitleaks). golden/updated if output legitimately changed (with provenance).- Two-Tier Release Recertification Policy: Normal feature/fix PRs run
bash harness/pr_check.shwithout rewritingbenchmarks/evidence/*.json. When cutting a release (release/vX.Y.Z) or certifying a milestone baseline, runbash harness/recertify.shto refresh all 15 non-scalebenchmarks/evidence/*.jsonfiles, synchronize documentation SHA-256/fingerprint tables (python3 harness/sync_evidence_docs.py), and passbash harness/acceptance.sh(8/8) under docs/testing/test-matrix-and-ci-audit.md. Runbash harness/scale_bench.shonly whenengine_fingerprint.sh --perf(PERF_FP) changed sincebenchmarks/evidence/scale.json. - The commit/PR states: "validated vs VarDictJava 1.8.3, dataset
<name>, cmd<…>". gitleaks protect --staged(commit) /gitleaks detect --source .(push) clean.- The PR body completes
.github/pull_request_template.md, which is authoritative on what may be skipped: engine-gate boxes are either run or marked N/A with a one-line justification under the template's docs/infra-only note (the same code-change filter the pre-push hook enforces). - Mandatory Multi-Skill Review & Copilot Review Thread Resolution Gate: Every PR must be reviewed and fixed through
/ponytail-review,/rust-router, and/pragmatic-rust-guidelinesbefore merge. Every PR must also wait forcopilot-pull-request-reviewer[bot](and any other automated or human reviewers) to finish its review — never merge solely because CI checks are green while Copilot review is pending or in progress. Every review comment must be refuted or fixed with an inline reply (repos/<owner>/<repo>/pulls/<PR>/comments/<ID>/replies) and every review thread must be resolved (resolveReviewThreadGraphQL mutation) before squash-merging. - Real-Data Empirical Grounding (
§0c): Any PR introducing or modifying calling, normalization, statistical, or performance rulings must validate its claims on real public sequencing BAMs/CRAMs and truth sets (scratch/g4), never on synthetic fixtures alone.
16. Repo layout¶
crates/vardictrust-core/ engine library (all logic; #![forbid(unsafe_code)])
crates/vardictrust/ bin "vardictrust" (clap front-end → core)
harness/ compare.sh, compare_var.py, compare_vcf.py, slice.sh, run_oracle.sh, setup_oracle.sh
golden/ versioned oracle outputs (.vcf, .var) + PROVENANCE
benchmarks/ hardware, datasets, exact commands
VarDictJava/ the v1.8.3 reference (read-only; the source of truth for ports)
ROADMAP.md --compat=vardictjava|off (CompatProfile) governance and architecture roadmap
17. Quick map: where things live in VarDictJava (for porting)¶
src/main/java/com/astrazeneca/vardict/ — modes/{Simple,Somatic,Amplicon,Splicing}Mode (orchestration);
modules/CigarModifier (read-level CIGAR rewrite → src/cigar/modify.rs); modules/CigarParser (the pileup
engine → src/cigar/parse.rs); modules/VariationRealigner (→ src/realign.rs); modules/ToVarsBuilder
(variant finalization → src/tovars.rs); modules/StructuralVariantsProcessor (→ src/sv.rs);
data/fishertest/{FisherExact,UnirootZeroIn} (→ src/stats/fisher.rs); postprocessmodules/* (filter +
somatic STATUS → src/postprocess/); printers/* (→ src/output/); variations/* (→ src/variations/).
Somatic STATUS is computed in Java (SomaticPostProcessModule.determinateType), not Perl.
18. Commits¶
Atomic commits per task: git add -A && git commit -m "<type>: <short desc>". Branch off origin/main (git fetch origin && git checkout -b <type>/<slug> origin/main); never push main directly (the pre-push hook blocks it) — merge via a PR opened with gh, with the PR template filled, /ponytail-review + /rust-router + /pragmatic-rust-guidelines completed, and copilot-pull-request-reviewer[bot] review waited for, replied to inline, and resolved (resolveReviewThread) per §15.8. Run bash harness/setup_hooks.sh once per clone so the repo-managed hooks are active. Full gate semantics live in CONTRIBUTING.md §§5–6 and harness/pr_check.sh (6 stages).
Never commit secrets, data (BAM/CRAM/FASTA/VCF beyond the tiny golden/ fixtures), target/, conda envs, or ephemeral agent scratch/planning trees (e.g. docs/superpowers/ — agent plans belong in the external <appDataDir>/brain/<conversation-id> artifact store; see .gitignore). Do commit Cargo.lock (this is an application workspace). MIT-licensed, open-source project. Do not include Co-Authored-By commit trailers; machine assistance and AI tool participation are disclosed transparently in README.md and CITATION.cff.
19. Repository-Specific Agent Skills (.agents/skills/)¶
Specialized workflow skills live under .agents/skills/<name>/SKILL.md (validated by harness/tests/test_bioconda_recipe.py):
- vardictrust-issue: Filing, triaging, reproducing, or auditing GitHub issues (default --compat=vardictjava parity/robustness vs v1.1+ --compat=off CompatProfile classification, harness/slice.sh minimal slices, and compare.sh oracle receipts).
- vardictrust-pr: Opening, updating, reviewing, recertifying (harness/recertify.sh), or squash-merging pull requests, completing .github/pull_request_template.md, and replying inline to review comments.
- vardictrust-profiling: Profiling CPU (profile-cpu), jemalloc heap (profile-heap), or DHAT allocation churn (profile-dhat) via harness/profile.sh and harness/profile_catalog.py (references/rust-profiling-api.md).
- vardictrust-release: Multi-channel release engineering across GitHub Releases (cargo-dist SLSA Level 3), Crates.io, Bioconda, Nextflow nf-core/modules, and ReadTheDocs (scripts/check_release_consistency.py and references/version-surface-map.md).
Agent Discovery: .agents/skills/ is committed in-tree and auto-discovered natively by Gemini CLI, OpenAI Codex, GitHub Copilot, Cursor, and OpenCode.