Skip to content

fix(cli): say when a messages read came back at its limit - #5721

Open
Chessing234 wants to merge 2 commits into
block:mainfrom
Chessing234:fix/messages-read-truncation-5595
Open

fix(cli): say when a messages read came back at its limit#5721
Chessing234 wants to merge 2 commits into
block:mainfrom
Chessing234:fix/messages-read-truncation-5595

Conversation

@Chessing234

Copy link
Copy Markdown
Contributor

A messages get that returns exactly 50 rows is byte-for-byte indistinguishable from a complete history, so an agent rebuilding channel context reconstructs a prefix of the conversation and acts on it as if it were the whole thing. Same for search (default 20, hard cap 100 — --limit 500 silently returns 100) and thread (100/500).

The report ranked "say so" first, and that is what this does:

  • stderr note when a read comes back at its limit, naming the bound that actually applied — the default, the --limit you passed, or the cap it was clamped to — and how to see more: showing 100 results — --limit 500, capped at 100 was reached, so more may exist; narrow the window with --since / --before to page through the rest.
  • stdout is untouched. It stays the plain sig-stripped JSON array, so no consumer parsing the array breaks. That is why the signal is not a truncated: true field — it would change the documented read shape for every reader.
  • --limit help now states the default and the cap for get / thread / search. It previously read "Maximum number of results to return", with no hint that a default existed or that search ignores anything above 100.
  • --before / --since are marked inclusive. crates/buzz-core/src/filter.rs:48-58 rejects on created_at < since and created_at > until, so both bounds keep their own second and a naive pager double-counts the boundary event.

Two deliberate limits, since the report asked for total counts:

  • No total is reported. The relay answers a filter, not a count. Getting 113 would mean a second POST /count round-trip on every read, which felt like the wrong default for the hot path — so the note says "may exist" instead of claiming a number.
  • A short read stays silent. That is the only provably complete case. A result set exactly the size of the limit is possible, so the note is deliberately a "may", not an assertion of truncation.

thread counts only the replies — the root event rides along in the same response but is not part of the reply page, and counting it would report truncation one reply early.

Raising the defaults is not part of this, per the report: any default truncates something; the bug is the silence.

Verified locally: cargo fmt --all --check, cargo clippy -p buzz-cli --all-targets (clean), cargo test -p buzz-cli --lib — 351 pass, including 8 new tests on the notice. The notice text itself is unit-tested; I did not exercise it against a live relay.

Closes #5595

buzz messages get returns the newest 50 messages when --limit is
omitted, with nothing in the output to say the result is a prefix. A
truncated history is byte-for-byte indistinguishable from a complete
one, so an agent rebuilding context from a channel read reconstructs a
plausible-but-wrong past and acts on it.

Emit a note on stderr when the read comes back at its limit, naming the
bound that applied - the default, the requested --limit, or the cap it
was silently clamped to - and how to see more. stdout keeps the plain
JSON array, so the machine contract is unchanged.

The note says "may exist" rather than reporting a total: the relay
answers a filter, not a count, and a result set exactly the size of the
limit is possible. A short read is the only provably complete case and
stays silent.

Refs block#5595

Signed-off-by: Taksh <takshkothari09@gmail.com>
search defaults to 20 and hard-caps at 100, so `--limit 500` returns
exactly 100 with nothing indicating the flag was ignored. thread has
the same shape at 100/500. Both now emit the same stderr note.

thread counts only the replies: the root event rides along in the same
response but is not part of the reply page, so including it would
report truncation one reply early.

Also state the defaults and caps in --limit's help, which previously
read "Maximum number of results to return" with no hint that a default
existed, and mark --before / --since inclusive - `until` and `since`
are both inclusive comparisons in the filter matcher, so a naive pager
double-counts the boundary event without that note.

Closes block#5595

Signed-off-by: Taksh <takshkothari09@gmail.com>
@Chessing234
Chessing234 requested a review from a team as a code owner August 13, 2026 00:45
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.

buzz messages get silently truncates to 50 with no indication; messages search hard-caps at 100

1 participant