Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .cargo/mutants.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Mutation testing configuration.
#
# `cargo mutants` changes the source (flips a comparison, replaces a function
# body with a default) and reports whether the test suite notices. A surviving
# mutant is a piece of logic no test distinguishes: either a test is missing, or
# the logic does not do anything, and both are worth knowing.
#
# It is advisory. A surviving mutant is a question, not a defect, and it never
# fails CI.

# The library: everything that decides what a distance is. `src/main.rs` is
# outside this on purpose. It is argument handling, warning text and output
# plumbing, and most of its mutants are equivalent: the batch and buffer size
# constants change how fast the run is and not what it prints, and the warning
# conditions change wording. The integration tests cover its behaviour
# end-to-end, which is the right granularity for a command line.
#
# The one part of main.rs worth mutating is `write_fixed_fast`, and it does not
# need this: it is checked directly against the standard formatter over 200,000
# random values, along the rounding boundaries at every precision, and on
# subnormals and signed zero. A mutation of it fails that immediately.
examine_globs = [
"src/lib.rs",
"src/parser.rs",
"src/lca.rs",
"src/midpoint.rs",
"src/tree.rs",
]

# Generated trees for the randomised checks, not logic anything depends on.
exclude_globs = ["src/testutil.rs"]

# The unit tests finish in well under a second, so anything still running after
# a minute is a mutant that made the code loop rather than one under test. There
# are twenty of those in the parser, which is what a mutated `pos += 1` in a
# byte scanner does, and they are reported as timeouts rather than survivors.
timeout_multiplier = 5.0
minimum_test_timeout = 60

# Ten mutants survive in this scope as of the run that wrote this file, out of
# roughly 250. They fall into three groups, named rather than chased:
#
# - Four are equivalent, in the sense that the mutated code is still correct:
# `depth_top[u] < depth_top[v]` in `mrca` becoming `<=` only changes which of
# two equally deep nodes is swapped; `dist_u > best_dist` in `farthest_from`
# becoming `>=` picks a different tie among equally distant leaves, and both
# are valid diameter endpoints; and `path.len() - 1` in `midpoint_root`
# becoming `+` or `/` is unreachable, because the loop always returns from
# inside before it runs off the end.
#
# - One is the `+ 1` in `levels`, and it took a while to accept. Two attempts
# were made to kill it, with a ladder and with two deep chains, and both
# passed with the level removed. The reason is that the second phase of `mrca`
# is a greedy descent that accumulates jumps rather than taking one: it can
# climb 2^levels - 1 in total, which is at least n - 1, which is at least the
# depth of any tree with n nodes. `ceil(log2 n)` levels is therefore already
# sufficient and the `+ 1` is margin. It stays, because margin on the
# structure the whole tool depends on is worth eight bytes a node.
#
# - Three are in `skip_whitespace_bytes`, which looks dead: the whitespace
# outside quoted labels is already gone by the time the parser runs. It is not
# dead. Making it panic if it ever skipped anything, and running the suite,
# found an input from the torture test that reaches it, because a malformed
# quote leaves whitespace inside what the stripper took for a quoted region.
# No unit test reaches it, which is what the mutants are reporting.
#
# - The last two only change which error message an invalid tree gets, in
# `parse_newick` and `parse_label_bytes`. Both inputs are rejected either way.
#
# `test_lifting_table_is_deep_enough_for_a_ladder` in src/lca.rs came out of
# this run: it does not kill a mutant, but nothing else put a tree that deep
# through the LCA path at all.
128 changes: 128 additions & 0 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
paula.ruiz.rodriguez@csic.es.
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series
of actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
the community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.

Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
61 changes: 61 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Contributing

Issues and pull requests are welcome at
[PathoGenOmics-Lab/distree](https://github.com/PathoGenOmics-Lab/distree).

The fullest version of this is on the documentation site, under
[Contributing](https://pathogenomics-lab.github.io/distree/about/contributing/).
What follows is the short form.

## Reporting a problem

The most useful bug report is one somebody else can run: the exact command, the
version, a tree that still shows it, and what you expected against what you got.

The dangerous failures here are the quiet ones. A matrix that is wrong looks
exactly like a matrix that is right, so a report saying "these distances
disagree with `ape::cophenetic` and here are both" is worth more than a stack
trace.

If the tree carries anything identifiable, do not attach it. Tip labels can be
replaced with `S1`, `S2` and so on without changing the behaviour.

## Building and checking

```bash
cargo build --release
cargo test
cargo test --release
cargo clippy --all-targets -- -D warnings
```

CI runs all four on every push and every pull request. A change that fails any
of them will not go in.

Two deeper checks are run on purpose rather than on every push:

```bash
# Against ape, over 250 generated trees. Needs R with ape and phangorn.
Rscript scripts/crossvalidate.R 250 target/release/distree

# Coverage-guided fuzzing. Needs a nightly toolchain.
cargo +nightly fuzz run parse_newick fuzz/seeds
```

## Conventions the code follows

- **Refuse rather than guess.** If the input is ambiguous or truncated, error
with the position. A matrix that looks right and is not costs more than a
failed run.
- **Warnings go to stderr**, never into the matrix, so a piped run stays clean.
- **Keep the tree traversals iterative.** The parser, the flattener, the LCA
build and `RawNode`'s `Drop` are all loops with explicit stacks, because a
ladder-shaped tree hundreds of thousands of levels deep is a real input.
- **Do not put work in the serial write loop.** Whatever a worker can do to its
own row, it should, including formatting the numbers.
- **Output is byte-identical unless the change is about the output.** If it
changes, say so in the pull request: it is a change to everyone's files.

## Code of conduct

By taking part you agree to the [Code of Conduct](CODE_OF_CONDUCT.md).
104 changes: 104 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Bug report
description: distree crashed, refused a tree it should accept, or produced numbers that are wrong
labels: ["bug"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to report this.

The failures worth reporting here are not only the loud ones. A run that
finishes and returns a matrix that looks entirely reasonable and is
wrong is the more expensive kind, and the harder one to notice, so a
report saying "these distances disagree with `ape::cophenetic` and here
are both" is worth more than a stack trace.

If distree **refused** your tree, check
[Input](https://pathogenomics-lab.github.io/distree/guide/input/) first:
several things it used to accept are now rejected on purpose, because
accepting them produced a wrong matrix rather than an error.

- type: input
id: version
attributes:
label: Version
description: The output of `distree --version`.
placeholder: distree 1.0.1
validations:
required: true

- type: dropdown
id: install
attributes:
label: How it was installed
options:
- Bioconda (conda install -c bioconda distree)
- Binary from the Releases page
- Built from source (cargo build --release)
- Other
validations:
required: true

- type: dropdown
id: os
attributes:
label: Operating system
options:
- Linux (x86-64)
- Linux (arm64)
- macOS (Apple silicon)
- macOS (Intel)
- Other
validations:
required: true

- type: textarea
id: command
attributes:
label: The command
description: The whole thing, with every flag.
placeholder: distree tree.nwk --midpoint --lmm -p 8 -o varcovar.tsv
render: shell
validations:
required: true

- type: textarea
id: expected
attributes:
label: What you expected, and what you got
description: >-
If the numbers are wrong rather than absent, say how you know: the tool
you compared against, the pair of tips that disagrees, and both values.
validations:
required: true

- type: textarea
id: output
attributes:
label: What it printed
description: Everything on stderr, including any warnings before the error.
render: shell

- type: textarea
id: tree
attributes:
label: The tree
description: >-
The smaller the better. A tree with the labels replaced by S1, S2, ...
usually still reproduces the problem, and a generated tree of the same
shape often does too.


**Do not attach anything identifiable.** Sample names in a Newick file
are data like any other.
render: text

- type: checkboxes
id: checks
attributes:
label: Before submitting
options:
- label: I am on the latest release, or I have said above why not.
required: true
- label: The tree above reproduces it, or I have said why I cannot share one.
required: true
22 changes: 22 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Blank issues stay available. The forms cover the reports that arrive most
# often, but a small tool gets questions that fit no form, and having nowhere to
# put them is worse than an unstructured issue.
#
# There is no Q&A link here because Discussions are not enabled on this
# repository. If they are turned on, add one: an answer in Q&A gets marked as the
# answer and the next person finds it, while an answer in an issue is seen once.
blank_issues_enabled: true

contact_links:
- name: Documentation
url: https://pathogenomics-lab.github.io/distree/
about: The CLI reference, the output formats, and what the three distance modes mean.
- name: Tutorial
url: https://pathogenomics-lab.github.io/distree/tutorial/
about: A worked outbreak investigation, from the tree to transmission clusters.
- name: What distree accepts and rejects
url: https://pathogenomics-lab.github.io/distree/guide/input/
about: Worth a look first if it refused your tree.
- name: Report a security vulnerability
url: https://github.com/PathoGenOmics-Lab/distree/security/advisories/new
about: Please report vulnerabilities privately rather than in a public issue.
Loading
Loading