Skip to content

feat(coverage): show clause discharge next to the marker count in coverage --tests and trace (#1168) - #1171

Merged
avrabe merged 2 commits into
mainfrom
feat/issue-1168-coverage-discharge
Nov 5, 2026
Merged

avrabe merged 2 commits into
mainfrom
feat/issue-1168-coverage-discharge

Conversation

@avrabe

@avrabe avrabe commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Closes #1168

rivet coverage --tests now prints the clause discharge that rivet verify recorded (#838 / #1164) next to each requirement's marker count. rivet trace and rivet trace-results print the same value for the traced requirement. Before this, 1 test marker read the same as a full discharge.

  REQ-1  1 test marker  clauses 2/3
  REQ-2  1 test marker  clauses —

Acceptance criteria

  • A partially discharged requirement shows 2/3 in text and JSON.
    • Text: coverage --tests prints REQ-1 1 test marker clauses 2/3. trace REQ-1 and trace-results REQ-1 print clauses discharged: 2/3.
    • JSON: coverage --tests --format json gains a discharge object keyed by artifact id, with "REQ-1": {"discharged": 2, "total": 3, "stale": false}. trace-results --format json gains "discharge": {...} for the root.
    • Covered by the CLI test coverage_and_trace_show_clause_discharge, which asserts each exact cell.
  • An edited requirement shows stale.
    • After a clause line is edited, so the fingerprint no longer matches (discharge-stale), the text cell reads clauses stale / clauses discharged: stale.
    • JSON reads {"discharged": null, "total": 3, "stale": true}. The old fraction is not shown.
    • The same CLI test covers this, plus the unit test discharge_state_reports_fraction_stale_or_nothing. That test includes the case where the clause list was removed: the record still reads stale, not silently absent.
  • A requirement with no clause list shows no fraction.
    • coverage --tests prints clauses —.
    • trace and trace-results print no discharge line.
    • JSON has no discharge entry for that id, and none on the trace-results root.
    • The same CLI test covers this.
  • Each case gets a CLI test asserting the exact cell: rivet-cli/tests/cli_commands.rs::coverage_and_trace_show_clause_discharge.

Design notes

  • The logic lives in rivet_core::discharge::discharge_state(&Artifact) -> Option<DischargeState>, built on the existing discharge_summary and is_stale. Staleness uses the same is_stale(description, fingerprint) call as the discharge-stale rule in validate.rs.
  • A description that states clauses but has no recorded discharge reads 0/N.
  • A record stored as the string "[1, 2]" is still read as a record, so it doesn't show as 0/N. This covers records written before the field was typed from common.yaml. An independent review pass flagged it.
  • JSON shape. The coverage --tests rows are serialized as [id, markers] tuples, so the per-requirement object goes in a top-level discharge map keyed by id rather than inside each row. Both JSON additions appear only when there is something to report, so the output for a project without clause lists is unchanged.
  • Ambiguous numbering. A description that rivet verify would refuse as ambiguous shows —, the same as no list. The docs say so and point to rivet verify --explain-clauses.
  • Docs. rivet docs verify-clauses has a new "In the reports" section, and docs/reference/verify-clauses.md is regenerated. There is also a CHANGELOG entry.

Gates (run locally)

Gate Result
cargo fmt --all -- --check clean
cargo clippy --all-targets -- -D warnings clean
cargo test --workspace 2786 passed, 0 failed
rivet validate PASS
rivet docs check only the 5 ChangelogStructure findings already on main (no tags in this shallow clone, plus duplicate headings in old released sections)

Trailers: Implements: REQ-308, Refs: #1168.


Generated by Claude Code

…erage --tests and trace (#1168)

`rivet coverage --tests` now prints the discharge `rivet verify` recorded
beside each requirement's marker count (`clauses 2/3`, `clauses stale`, or
`clauses —` when the description states no clause list), and `rivet trace`
and `rivet trace-results` print it for the traced requirement. JSON gains a
`discharge` object of the form {discharged, total, stale}; a stale record
carries no fraction. The logic lives in rivet_core::discharge::discharge_state.

Implements: REQ-308
Refs: #1168

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KEjmjar6S6RytNLRfgD24W
…e ambiguous and gone-list cells (#1168)

A `discharged-clauses` value stored as the string "[1, 2]" is now read as
a record instead of reading as 0/N. The verify-clauses topic now says that
`—` also covers ambiguous numbering, and that a stale record whose clause
list is gone has a JSON entry with total null.

Implements: REQ-308
Refs: #1168

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KEjmjar6S6RytNLRfgD24W
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

📐 Rivet artifact delta

No artifact changes in this PR. Code-only changes (renderer, CLI wiring, tests) don't touch the artifact graph.

@avrabe
avrabe added this pull request to the merge queue Nov 5, 2026
@codecov

codecov Bot commented Nov 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.96907% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
rivet-core/src/discharge.rs 98.96% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Merged via the queue into main with commit 56d12bf Nov 5, 2026
36 checks passed
@avrabe
avrabe deleted the feat/issue-1168-coverage-discharge branch November 5, 2026 15:15
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.

coverage --tests / trace: show clause discharge (discharged/total) next to the marker count

2 participants