Skip to content

tidy-eventlog: Read stops asking twice whether a segment exists - #282

Merged
dinstein merged 1 commit into
mainfrom
tidy-eventlog
Aug 9, 2026
Merged

tidy-eventlog: Read stops asking twice whether a segment exists#282
dinstein merged 1 commit into
mainfrom
tidy-eventlog

Conversation

@dinstein

@dinstein dinstein commented Aug 9, 2026

Copy link
Copy Markdown
Owner

Nightly tidy pass over internal/eventlog (2026-08-10 03:17 round).

  • Pass AreadFile opens each segment, so os.Open already answers
    "is this file there". It discarded that answer and Read rebuilt it with
    a second stat. The wasted syscall is the small half; the real one is
    that a rotation between the open and the stat leaves Result.Files
    documented as which files a report covers, so a caller can tell "no
    records over three segments" from "no records over none" — naming a path
    nothing read, or omitting one that was.
  • Pass B — nothing cleared the bar.
  • Pass C — nothing to reconcile.

Also audited and holding, so it is worth naming: Kind's doc claims
"adding one means editing THREE places … test/buildrules fails until all
four are true". All three checks exist and cover the three relations from the
constant — eventkinds_test.go (the foundation.md table), eventselectors_test.go
(allKinds), eventwriters_test.go (something actually emits it).

A tree-wide sweep also ran this round, generalising last round's calllog
finding: a named constant coexisting with bare literals of its own value.
Restricted to distinctive values it returns nothing — every hit is a comment
quoting a method name or a JSON struct tag. The one apparent candidate,
oauthflow's form.Set("refresh_token", …), is the OAuth parameter name,
which merely spells the same as the grant-type value; replacing it with the
constant would couple two independent strings. internal/calllog was the
isolated case, and it landed last round.

Verification: make ci green.

readFile opens each segment, so os.Open already answers "is this file there".
It threw that answer away and returned (nil, 0, nil) for a missing file, and
Read reconstructed it with a second stat through a fileExists helper.

Two consequences, and the second is the one that matters. The syscall is
wasted; and between the open and the stat a rotation can rename the file, so
Result.Files — documented as "which files a report covers", precisely so a
caller can distinguish "no records over three segments" from "no records over
none" — could name a path nothing read, or omit one that was read. A list
whose whole job is to say what was covered is the wrong place to hold a
second opinion about it.

readFile now reports found, Read branches on it, and fileExists is gone.
Behaviour is unchanged for every reachable case, the empty-but-present
segment included: it is still found, and its path still joins Files.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@dinstein
dinstein merged commit a7012fc into main Aug 9, 2026
3 checks passed
@dinstein
dinstein deleted the tidy-eventlog branch August 9, 2026 19:29
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