tidy-eventlog: Read stops asking twice whether a segment exists - #282
Merged
Conversation
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>
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.
Nightly tidy pass over
internal/eventlog(2026-08-10 03:17 round).readFileopens each segment, soos.Openalready answers"is this file there". It discarded that answer and
Readrebuilt it witha second
stat. The wasted syscall is the small half; the real one isthat 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.
Also audited and holding, so it is worth naming:
Kind's doc claims"adding one means editing THREE places …
test/buildrulesfails until allfour are true". All three checks exist and cover the three relations from the
constant —
eventkinds_test.go(thefoundation.mdtable),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'sform.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/calllogwas theisolated case, and it landed last round.
Verification:
make cigreen.