fix: keep the dates in log digests (#39) #40

Closed
david wants to merge 0 commits from fix/log-digest-dates into main
Owner

Closes #39.

normalizeLogLine stripped timestamp= first, so a signature could not say when it was seen: an ENOSPC: no space left on device from Oct 22 (fixed the same day) and a provider billing rejection from Nov 1 rendered as identical-looking lines. A digest is only useful if a resolved fault can be told apart from a live one.

Signatures are now {text, first, last} and render with their day (2026-10-22 …) or range (2026-10-01..2026-11-01 …), ordered most recently seen first so the summary's err: sample leads with what is live now.

Against the real opencode.log, the case that motivated this now reads:

2026-11-01 level=ERROR run=<RUN> message="Failed to drain Session" cause="… Insufficient account funds …
2026-11-01 level=ERROR run=<RUN> message="Failed to drain Session" cause="… requires Global regions …
2026-10-22 level=ERROR run=<RUN> message="Failed to fetch models.dev" cause="… ENOSPC: no space left on device …

Times of day, run ids and session/message ids still normalize away, so the content hash stays stable within a day and moves only when a recurring error recurs on a new day — exactly when the digest should be rewritten.

Tests

TestLogContentHashStability asserted the old day-independent behaviour, so it is replaced by:

  • TestLogContentHashStableWithinDay — volatile ids/times/noise do not move the hash; a new distinct error does.
  • TestLogContentHashTracksNewDays — the same error on a new day does move it.
  • TestLogDigestKeepsDates — renders a date range, and a single day renders one date.

go test ./..., go vet, gofmt clean. Ingester version bumped to log-parser/v3.

Closes #39. `normalizeLogLine` stripped `timestamp=` first, so a signature could not say when it was seen: an `ENOSPC: no space left on device` from Oct 22 (fixed the same day) and a provider billing rejection from Nov 1 rendered as identical-looking lines. A digest is only useful if a resolved fault can be told apart from a live one. Signatures are now `{text, first, last}` and render with their day (`2026-10-22 …`) or range (`2026-10-01..2026-11-01 …`), ordered most recently seen first so the summary's `err:` sample leads with what is live now. Against the real `opencode.log`, the case that motivated this now reads: ``` 2026-11-01 level=ERROR run=<RUN> message="Failed to drain Session" cause="… Insufficient account funds … 2026-11-01 level=ERROR run=<RUN> message="Failed to drain Session" cause="… requires Global regions … 2026-10-22 level=ERROR run=<RUN> message="Failed to fetch models.dev" cause="… ENOSPC: no space left on device … ``` Times of day, run ids and session/message ids still normalize away, so the content hash stays stable within a day and moves only when a recurring error recurs on a new day — exactly when the digest should be rewritten. ## Tests `TestLogContentHashStability` asserted the old day-independent behaviour, so it is replaced by: - `TestLogContentHashStableWithinDay` — volatile ids/times/noise do not move the hash; a new distinct error does. - `TestLogContentHashTracksNewDays` — the same error on a new day does move it. - `TestLogDigestKeepsDates` — renders a date range, and a single day renders one date. `go test ./...`, `go vet`, `gofmt` clean. Ingester version bumped to `log-parser/v3`.
david force-pushed fix/log-digest-dates from 01b2cafa7b to aa8bfa61e1 2026-11-08 23:00:51 +00:00 Compare
david closed this pull request 2026-11-09 00:27:09 +00:00
Some checks are pending
build / test (push) Successful in 4m16s
build / image (push) Successful in 22s

Pull request closed

Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: david/knox#40