Skip to content

fix(config): compute default write path once per process - #270

Merged
jmeridth merged 1 commit into
mainfrom
fix/flaky-default-write-path
Aug 5, 2026
Merged

jmeridth merged 1 commit into
mainfrom
fix/flaky-default-write-path

Conversation

@jmeridth

@jmeridth jmeridth commented Aug 5, 2026

Copy link
Copy Markdown
Member

What/Why

defaultWritePath() embedded time.Now() at second precision and was called both by NewConfig and by test assertions, so any pair of calls straddling a second boundary produced different paths. This made TestNewConfig flaky in CI (example: the failed run on #269) and meant multiple configs in one process could log to different directories. The path is now memoized with sync.OnceValue so it is stable for the life of the process.

Proof it works

go test ./... passes. Added an assertion in TestDefaultWritePath that two calls return the same path, which fails against the old implementation when calls straddle a second boundary.

Risk + AI role

Low. Behavior change is limited to reusing one timestamped directory per process instead of one per NewConfig call. AI-generated, human-reviewed.

Review focus

Whether a single shared log directory per process is the intended behavior for long-running processes that construct multiple configs.

What/Why

defaultWritePath embedded time.Now() at second precision and was called
both by NewConfig and by test assertions, so any call pair straddling a
second boundary produced different paths. This made TestNewConfig flaky
in CI and meant multiple configs in one run could log to different
directories. Memoize the path with sync.OnceValue so it is stable for
the life of the process.

Proof it works

go test ./... passes; go vet ./config/... clean. Added an assertion in
TestDefaultWritePath that two calls return the same path.

Risk + AI role

Low. Behavior change is limited to reusing one timestamped directory per
process instead of one per NewConfig call. AI-generated (Claude Fable 5),
human-reviewed.

Review focus

Whether a single shared log directory per process is the intended
behavior for long-running processes that construct multiple configs.

Signed-off-by: jmeridth <jmeridth@gmail.com>
@jmeridth jmeridth self-assigned this Aug 5, 2026
@github-actions github-actions Bot added the fix label Aug 5, 2026
@jmeridth
jmeridth marked this pull request as ready for review August 5, 2026 18:50
@jmeridth
jmeridth requested a review from a team August 5, 2026 18:50
@jmeridth
jmeridth merged commit 6a4d1f1 into main Aug 5, 2026
9 checks passed
@jmeridth
jmeridth deleted the fix/flaky-default-write-path branch August 5, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants