Skip to content

fix(history): an empty record is not a failed match - #66

Merged
ChelseaKR merged 1 commit into
mainfrom
fix/history-all-is-not-a-failed-match
Sep 6, 2026
Merged

fix(history): an empty record is not a failed match#66
ChelseaKR merged 1 commit into
mainfrom
fix/history-all-is-not-a-failed-match

Conversation

@ChelseaKR

Copy link
Copy Markdown
Owner

What was wrong

Found by smoke-testing the four new verbs together on main after #65 merged,
which is the check the brief asks for after a burst of merges.

data/changes/ does not exist in this repository — the watch has not recorded a
revision yet — but data/parsed/ is committed. In exactly that state:

$ ca-tariff-parse history --id smud-r-tod --all
smud-r-tod: no record matched None. That is not the same as a record that has
never changed, which is reported with one state
# History of smud-r-tod

No record matched.
$ echo $?
5

Two things wrong with that.

--all asks for nothing by name, so nothing coming back is a statement
about what has been committed, not a request that failed. Exiting 5 tells a
script the request was wrong when the record is simply empty — the same shape as
the defects this verb was written to avoid, on the other side of the fence.

{args.match!r} renders None when --all was used, so the message names a
match nobody made.

What changed

  • history --all with no committed reports exits 0 and says which directory
    holds no reports, and that this is a statement about what has been committed
    rather than about whether the document has changed. --match selecting
    nothing still exits 5.
  • The empty report body now says that neither an empty match nor an empty report
    set means the document has not changed — it means the committed record does
    not cover it. The old wording, "No record matched.", was the only thing a
    reader saw and it was not true for --all.

How it was verified

Full gate green: ruff check, ruff format --check, mypy (strict), pytest,
coverage 93.86% against an 85% floor. Two tests added.

The added test builds the repository's actual state — a reviewed baseline
committed with an empty changes/ beside it — rather than an empty directory,
because with neither present an earlier guard fires first and the test would
have passed without exercising this path at all.

Negative control: reverting the --all branch (if False:, read back at
cli.py:324) turns test_all_with_no_committed_reports_is_not_a_failed_match
red. Restored from a pre-edit byte copy (diff clean) and re-run green.

Prepared with AI assistance; reviewed before submission.

With a reviewed baseline committed and no change reports beside it -- the state
of this repository today, since data/changes/ does not exist until the watch
records a revision -- `history --all` exited 5 and printed
"no record matched None".

`--all` asks for nothing by name, so nothing coming back is a statement about
what has been committed, not a request that failed, and a script reading exit 5
was told the request was wrong. It now exits 0 and names the directory that
holds no reports. The report says that neither an empty match nor an empty
report set means the document has not changed: it means the committed record
does not cover it. `--match` selecting nothing still exits 5.
@ChelseaKR
ChelseaKR merged commit 73d5cf7 into main Sep 6, 2026
3 checks passed
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.

1 participant