A count taken from truncated output describes the window, not the data
A view capped with head, tail or a page limit returns a well-formed list of rows, so counting it produces a well-formed number — the window's size, not the population's — and nothing in the output says rows were cut.
Resurfaces when
- about to state how many times something happened after reading it off a listing
- piping head or tail into wc or uniq -c
- writing a count into a decision record or report from output that was trimmed to fit the screen
- summarising a log by eyeballing its last N lines
- a count that is smaller than expected but looks plausible
- reading a total off the first page of a paginated API or UI
The lesson’s retrieval contract, weighted three times heavier than its body. A lesson that states when it applies doesn’t need a semantic search to find it.
The lesson
tail -45, head -20, a page size of 50: each is a decision about how much to look at, taken
before anyone knew what they would need to count. A window truncates silently, and every row in
it is a real row, so a count taken over it is a real-looking number. It is the size of the window's
overlap with the data, and it is always less than or equal to the truth — never above it, so it
never looks alarming.
The failure is not the truncation; trimming output to fit is sensible. It is using a view made
for looking as the source of a number. Once a figure will be written down, count at the source —
grep -c, wc -l on the unfiltered stream, the API's total field — never the listing you
happened to scroll.
The failure that taught it
Investigating a usage report, an agent grepped an append-only event log for one session's
denials and piped the result through tail -45 so it would fit on screen. It read that window,
confirmed the report's shape, and wrote "that session took 13 denials" into a permanent decision
record and into its summary to the user. A later check counted the same filter without the tail:
21. The first eight rows had scrolled off the top of the window, and nothing in the 45 lines
shown suggested it was incomplete. The number was plausible, it supported the claim being made,
and it was wrong by 40%.
How to apply it
- Before writing any count into a record, a commit message or a report, re-derive it with a
command whose last stage is the counter —
grep -c pattern file,... | wc -l— with nohead,tailor limit anywhere upstream. - A
head/tailpiped intowc -l,grep -coruniq -cis a counter over a window: the answer is capped by the flag, not the data. The scanner flags that shape. - For a paginated API or UI, read the total the source reports (a count field, a header), or page to exhaustion — never multiply or read off page one.
- When a count comes out lower than expected and still plausible, that is the case to recheck. Truncation can only undercount, so it never looks alarming.
Signature tightened 2026-09-26
The first pattern allowed anything but a pipe or newline between the window and the counter, so it
joined a head -5 in one command to a | wc -l in the next command on the same line
(head -5; echo …; grep -o x f | wc -l). Measured over 14,324 recorded Bash commands, it matched
102, almost all of that shape, and the scanner's record for this signature was 5 dismissed and 0
changed. The defect is counting output that head or tail cut earlier in the same pipeline, so the
gap now also stops at ;, & and ), the characters that end a pipeline.
Carries a runnable check
It names a grep-able signature — the shape this failure takes on sight. Prose doesn’t prevent recurrence; executable checks do. This one runs today, against every edit, as signature-scan.
Where this claim comes from
- Lesson
A count taken from truncated output describes the window, not the data
- Distillationmechanism stated
Written from the mechanism, not the incident — which is what lets it transfer to code sharing nothing with the original.
- Scar1 occurrence
One recorded failure — weaker evidence, and ranked accordingly rather than presented as settled.
- Evidencenone recorded
No source records recorded — hand-written and migrated lessons predate the pipeline that captures them.
What happened when it was used
- 2
- retrieved
- 0
- acted on
- 0
- held up
- 0
- did not hold up
Retrieved but never acted on — a demotion, not a neutral result. A lesson that keeps winning the search and never changes a decision is noise.