test: calendar dead-daemon e2e + chaos matrix coverage (hw-c195)#252
Merged
Conversation
Scout hw-xthx (blind spot #4) found the calendar status-line segment had no direct coverage of its freshness gate: cli_test.go exercises only the fresh render paths, so a regression in feedData's TTL check (the sole thing standing between a dead daemon and a permanently-stale calendar segment) would pass every existing test. Adds direct unit tests for feedData — malformed/missing envelopes, default-TTL expiry, custom ttl_seconds override in both directions, and placeholder-source suppression — and for renderCalendarSegment across fresh/stale/missing cache plus the next_event shape variants (string, time-fallback, name-only, empty, unexpected type). The stale case uses the same payload as the fresh case with only the embedded timestamp moved, proving omission is caused by the freshness gate alone. Validation: GOMEMLIMIT=4GiB go test -race -p 2 ./cmd/hookwise/ passes; golangci-lint clean. Test-only change, no production code touched.
No integration test covered the calendar feed end-to-end (scout hw-xthx blind spot #4): TestIntegration_DaemonLifecycleWithCacheBridge registers only pulse/weather mocks, so the daemon->cache->status-line pipeline for calendar was validated by inspection only. Adds an integration-tagged e2e test in cmd/hookwise (it must live here: renderBuiltinSegment is package main): a real daemon writes a calendar envelope, the daemon stops, and the test asserts (1) the fresh leftover envelope still renders the segment — the presence detector that keeps the omission assertion honest — and (2) after aging the EMBEDDED timestamp past the daemon-injected ttl_seconds, the segment is omitted even though rewriting the file makes its mtime current. That mtime-fresh/content-stale divergence is exactly what a dead daemon leaves behind; freshness must key on content (bridge.IsEnvelopeFresh), never mtime. The TTL offset is derived from the on-disk ttl_seconds the daemon actually injected, not a hardcoded constant. Honors the #228 isolation contract: HOOKWISE_STATE_DIR=t.TempDir(), and an explicit short /tmp socket path because DefaultSocketPath is frozen at package init and ignores the env override. //go:build integration keeps it in the nightly tier, off the per-PR path. Validation: GOMEMLIMIT=4GiB go test -race -p 2 -tags integration ./cmd/hookwise/ passes (new test + full package).
internal/chaos had zero calendar references while weather/pulse were exercised (scout hw-xthx blind spot #4). Mirrors the existing chaos patterns for calendar: corrupt-cache-skipped (valid calendar.json survives corrupt siblings), producer-panic-recovery (a panicking calendar producer neither crashes the daemon nor blocks sibling feeds, and leaves no cache file), and a new dead-daemon staleness transition (envelope fresh right after daemon stop, stale once its embedded timestamp ages past the daemon-injected ttl_seconds, with file mtime deliberately fresh to pin content-based freshness). The panic test enables Calendar in FeedsConfig — calendar is a recognised feed that defaults to disabled, and a skipped producer would never exercise the panic-recovery path. Reuses the package's existing goodProducer/panicProducer/shortSocketPath helpers; #228 isolation (HOOKWISE_STATE_DIR + explicit socket path) throughout. Validation: GOMEMLIMIT=4GiB go test -race -p 2 -tags integration ./internal/chaos/ passes (new tests + full package).
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughAdds calendar cache and status-line tests covering freshness, rendering variants, corrupt files, producer panics, and stale data left after daemon shutdown. ChangesCalendar cache and daemon behavior
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Blind spot #4 from the calendar-staleness scout (hw-xthx): calendar had zero integration/chaos coverage and the status-line calendar render path had no direct tests. Adds: dead-daemon e2e (daemon stopped, cache aged past TTL via embedded timestamp, status line must omit the segment; fresh control case proves detection), calendar in the chaos matrix mirroring weather/pulse, and direct feedData/renderCalendarSegment tests for fresh/stale/missing. Integration-tagged (nightly tier per #228 convention) with full state-dir isolation.
🤖 Generated with Claude Code
https://claude.ai/code/session_01EjWqH4FMkdczkSagzXw3dQ
Summary by CodeRabbit