Thanks to visit codestin.com
Credit goes to github.com

Skip to content

docs: specify the bioassert generate command#59

Merged
PeterKneale merged 1 commit into
mainfrom
docs/generate-spec
Jun 25, 2026
Merged

docs: specify the bioassert generate command#59
PeterKneale merged 1 commit into
mainfrom
docs/generate-spec

Conversation

@PeterKneale

Copy link
Copy Markdown
Owner

What

Adds specs/generate.md, the design specification for a new bioassert generate <file> command. Spec only; implementation is a separate follow-up.

bioassert generate a.tsv inspects a file and composes sensible default assertions from its extension and current properties, then writes them to <file>.assertions.txt (the format bioassert run consumes) and informs the user. Example for a TSV: file exists, same column count, and rows within +/- 50% of the current row count.

Design highlights

  • Per-family suggestion providers (file, delimited, bam, fasta) each contribute optional structured Suggestions. text.* is inline-literal only so it contributes nothing for a file path.
  • Ordered, grouped output: an orchestrator accumulates suggestions broadest-first (mirroring the executor dispatch order) and renders the file grouped by metric provider (the first segment of the metric name) with # comment headers and a provenance banner.
  • Defaults: counts that represent a schema are pinned with eq (columns, fasta records, bam references); magnitudes use a +/- 50% band (gte floor(0.5R), lte ceil(1.5R)); the universal file group stays broad (file.exists eq true, file.size gt 0B).
  • Reuses existing property functions (column_count, line_count, read_header, read_records, ...); no executor or dispatch changes.
  • CLI: generate <file> [--output FILE] [--force], default output <file>.assertions.txt, refuses to clobber without --force.

Covers the data model, provider trait, orchestrator, CLI/binary wiring, edge cases, and a unit + integration (snapshot + round-trip) test plan, in the house spec style.

🤖 Generated with Claude Code

Add specs/generate.md, the design for a `bioassert generate <file>` command
that inspects a file and composes a set of default assertions from its
extension and current properties, writing them to <file>.assertions.txt.

Design: per-family suggestion providers (file, delimited, bam, fasta) each
contribute optional structured suggestions, an orchestrator accumulates them
broadest-first and renders an assertions file grouped by metric provider
(first metric segment) with # comment headers. Counts are pinned with eq;
magnitudes use a +/- 50% band. Covers the data model, provider trait, CLI
wiring, edge cases, and a unit + integration test plan.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings June 25, 2026 04:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new design specification document describing the planned bioassert generate <file> command, including its data model, provider/orchestrator architecture, CLI shape, and a proposed test plan. This fits into the codebase’s existing “specs/” design-doc set (alongside existing BAM/FASTA/etc specs) and is intended to guide a follow-up implementation PR.

Changes:

  • Introduces specs/generate.md, specifying the bioassert generate command behavior and output format.
  • Documents a provider-based suggestion pipeline, output grouping, and default assertion heuristics (including +/-50% “band” rules).
  • Proposes CLI flags, wiring points, and unit/integration test coverage for the future implementation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread specs/generate.md
Comment on lines +23 to +26
- `Value::Display` (`src/core/values/value.rs`) already renders the way an assertions file needs:
`BytesValue` renders like `1.00MB` (binary, 1024-based), `IntegerValue` renders as a plain number
with no `K`/`M` suffix, `BooleanValue` renders `true`/`false`, `StringValue` renders verbatim. It is
the single rendering path and is reused so generated values round-trip through the parser.
Comment thread specs/generate.md
Comment on lines +27 to +29
- `Comparator::Display` (`src/core/comparisons/comparator.rs`) renders SYMBOLS (`>=`, `==`), but an
assertions file needs the KEYWORD form (`gte`, `eq`). The two must not be confused. Suggestions store
the comparator as the keyword, not as the `Comparator` enum, so the symbol form can never leak.
Comment thread specs/generate.md
Comment on lines +50 to +52
**The comparator is stored as a keyword, the value pre-rendered.** A suggestion carries
`comparator: &'static str` (one of `eq`, `gte`, `lte`) rather than the `Comparator` enum, because the
enum's `Display` renders symbols and an assertions file needs keywords. The set of comparators a
Comment thread specs/generate.md
Comment on lines +42 to +45
- An output line is the assertion syntax `resource metric comparator value`, optionally followed by
` # comment`. The resource is the file path as given. A path containing whitespace is single-quoted
so it round-trips through the grammar, the same rule the parser enforces for locators.
- The `text.*` family is inline-literal only and is not file-backed, so it contributes nothing when the
Comment thread specs/generate.md
Comment on lines +127 to +131
- **Provider order.** An ordered registry `providers()` mirrors the dispatch order in
`src/engine/executor.rs`, broadest first: `FileProvider`, `DelimitedProvider`, `BamProvider`,
`FastaProvider`. `FileProvider` handles any existing file; each format provider handles only its
extensions. This single list is the ordering authority, so generated files and run-time dispatch
agree on precedence.
Comment thread specs/generate.md
Comment on lines +92 to +96
The generated file is ordinary bioassert assertion syntax with `#` comments. It opens with a two-line
provenance banner, then one group per contributing provider. Each group is led by a `# <prefix>` header
and separated from the next by a blank line. Each assertion is `resource metric comparator value`, with
an optional inline `# comment`.

Comment thread specs/generate.md

| Provider | Handles | Suggestions |
|---|---|---|
| file | any existing file | `file.exists eq true`; `file.size gt 0B` |
@PeterKneale PeterKneale merged commit d3aae8d into main Jun 25, 2026
4 checks passed
@PeterKneale PeterKneale deleted the docs/generate-spec branch June 25, 2026 04:18
@github-actions github-actions Bot mentioned this pull request Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants