Skip to content

test: calendar dead-daemon e2e + chaos matrix coverage (hw-c195)#252

Merged
vishnujayvel merged 3 commits into
mainfrom
publish/hw-c195
Jul 11, 2026
Merged

test: calendar dead-daemon e2e + chaos matrix coverage (hw-c195)#252
vishnujayvel merged 3 commits into
mainfrom
publish/hw-c195

Conversation

@vishnujayvel

@vishnujayvel vishnujayvel commented Jul 11, 2026

Copy link
Copy Markdown
Owner

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

  • Tests
    • Added coverage for calendar status-line rendering, including upcoming event display and relative timing.
    • Added validation that stale or missing calendar data is omitted from output.
    • Added resilience checks for malformed cache files and producer failures.
    • Verified cached calendar data becomes stale after the daemon stops, even when files appear recently modified.

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).
@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: a80d194c-435e-464f-b689-5dd929834d1d

📥 Commits

Reviewing files that changed from the base of the PR and between 879f72c and 2eef8c1.

📒 Files selected for processing (3)
  • cmd/hookwise/cmd_status_line_calendar_e2e_test.go
  • cmd/hookwise/cmd_status_line_feeddata_test.go
  • internal/chaos/calendar_chaos_test.go

📝 Walkthrough

Walkthrough

Adds calendar cache and status-line tests covering freshness, rendering variants, corrupt files, producer panics, and stale data left after daemon shutdown.

Changes

Calendar cache and daemon behavior

Layer / File(s) Summary
Calendar cache and rendering contracts
cmd/hookwise/cmd_status_line_feeddata_test.go
Tests malformed, stale, placeholder, and fresh cache envelopes plus calendar rendering variants.
Dead-daemon status-line behavior
cmd/hookwise/cmd_status_line_calendar_e2e_test.go
Runs a calendar-enabled daemon, ages only the embedded timestamp, and verifies stale output is omitted.
Daemon and cache resilience scenarios
internal/chaos/calendar_chaos_test.go
Tests corrupt cache skipping, producer panic isolation, and stale transitions after daemon shutdown.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change, but it does not follow the required template and omits the Summary, Motivation, Test plan, and Checklist sections. Reformat the PR description to match the template and add the missing Summary, Motivation, Test plan, and Checklist sections.
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main addition of calendar dead-daemon e2e and chaos coverage.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch publish/hw-c195

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@vishnujayvel
vishnujayvel merged commit abfd6be into main Jul 11, 2026
6 checks passed
@vishnujayvel
vishnujayvel deleted the publish/hw-c195 branch July 11, 2026 07:14
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