fix(cli): audit tail -n 0 shows nothing instead of the whole ledger - #13
Merged
Conversation
`entries()[-n:]` is the classic negative-slice trap: for n == 0, `[-0:]` is `[0:]` — the ENTIRE list — so `flightdeck audit tail -n 0` dumped every ledger entry instead of zero. A negative -n was equally wrong (`[5:]`). Guard the slice: `all[-n:] if n > 0 else []`. Also key the "ledger is empty" notice off the real ledger rather than the truncated view, so `tail -n 0` on a populated ledger prints nothing (not a false "empty"). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Owner
Author
bughunt gate —
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
flightdeck audit tail -n 0printed the entire ledger (thousands of entries) instead of zero. On the demo org that's 6731 lines of output for a command that asked for none. A negative-nwas wrong too.Root cause
entries = Ledger(...).entries()[-n:]— the classic negative-slice trap. Forn == 0,[-0:]is[0:], i.e. the whole list (-0 == 0). Forn == -5,[5:]drops the first five and shows the rest.Fix
Guard the slice:
all_entries[-n:] if n > 0 else [], so asking for 0 (or fewer) entries shows none. Also key the "ledger is empty" notice off the real ledger (all_entries) rather than the truncated view, sotail -n 0on a populated ledger prints nothing rather than a misleading "ledger is empty".Tests
test_audit_tail_n_zero_shows_nothing: after a run,tail -n 0prints no entries and no false "empty" notice, whiletail -n 5still shows the recent ones.test_audit_tail_reports_a_truly_empty_ledger: a genuinely empty ledger still reports "ledger is empty".The
-n 0test fails onmain(printsrun_completed) and passes with the fix.Full suite: 167 passed, 92.65% coverage (gate 85%);
ruffclean; offlineflightdeck demo+audit verifyintact (andaudit tail -n 0now prints 0 lines, was 6731).Found and fixed by an autonomous
bughuntiteration.