Skip to content

fix(telemetry): a sink record's day comes from the moment it parses to - #827

Merged
blafourcade merged 1 commit into
nextfrom
fix/sink-day-from-parsed-moment
Sep 10, 2026
Merged

blafourcade merged 1 commit into
nextfrom
fix/sink-day-from-parsed-moment

Conversation

@blafourcade

Copy link
Copy Markdown
Contributor

🎯 What & why

telemetrySinkRecordDayKey decides which UTC day a stored telemetry record belongs to. That day chooses the periods a report counts it in. Once the timestamp parsed, it took a shortcut: any string ending in Z was sliced to its first ten characters. A moment that parses but is not in canonical ISO form got the wrong day, or a key that is no day at all. That key sits outside every period, so the record silently left a report without being counted as undated.

event_timestamp Before After
2026-09-10T24:00:00Z 2026-09-10 2026-09-11
Thu, 10 Sep 2026 23:00:00 Z Thu, 10 Se 2026-09-10
+002026-09-10T10:00:00Z +002026-09 2026-09-10

🛠️ How it works

  • The shortcut and the three comment lines that justified it are deleted. The day is always parsed.toISOString().slice(0, 10).
  • The src comment ceiling in comments.arch.test.ts drops by the same three lines, 4474 → 4471.

🧪 How to verify

cd cli && pnpm vitest run --project unit tests/contexts/telemetry/domain/telemetry-sink-record.unit.test.ts
Run Result
Before the change red: "expected '2026-09-10' to be '2026-09-11'" and "expected 'Thu, 10 Se' to be '2026-09-10'"
After 13 of 13 pass
Telemetry suite 56 files, 852 tests passed
test:arch 126 passed

Typecheck, lint, knip and type honesty are clean.

⚠️ Heads-up

  • Latent: this CLI writes canonical toISOString() timestamps itself. A sink shared through AIDD_TELEMETRY_DIR can still hold lines another writer produced.
  • The in-memory sink double calls the same function, so tests and the adapter still agree.

🔗 Linked issue

Fixes #825

✅ I certify

  • I have read the contributing guide and followed the PR template.
  • The tests were red before the fix and every gate listed above passed locally.

🤖 Generated with Claude Code

https://claude.ai/code/session_011x4ms5qcGuZgYhCxfdHMUb

…o, never from its text

telemetrySinkRecordDayKey sliced the first ten characters of any parseable
timestamp ending in Z. A moment not written in canonical ISO form got the
wrong day or no day at all: "2026-09-10T24:00:00Z" read as 2026-09-10
instead of 2026-09-11, "Thu, 10 Sep 2026 23:00:00 Z" as "Thu, 10 Se", a
key outside every period, so the record left a report without being
counted as undated. The day is now always the parsed moment's UTC day.

Two tests, both red before the change. The three comment lines that
explained the shortcut go with it, and the src comment ceiling drops by
the same three.

Fixes #825

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011x4ms5qcGuZgYhCxfdHMUb
AIDD-Session-Id: 4acc9a1c-19bc-4468-b8b6-e86644bcba60
@blafourcade
blafourcade requested a review from a team as a code owner September 10, 2026 10:11
@blafourcade
blafourcade merged commit 70f9bca into next Sep 10, 2026
24 checks passed
@blafourcade
blafourcade deleted the fix/sink-day-from-parsed-moment branch September 11, 2026 07:42
@aidd-bot aidd-bot Bot mentioned this pull request Sep 24, 2026
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