Skip to content

test(hooks): kill useSensorStream surviving mutants (#591 hit list) - #776

Merged
ng merged 6 commits into
devfrom
test/useSensorStream-mutants-591
Oct 6, 2026
Merged

ng merged 6 commits into
devfrom
test/useSensorStream-mutants-591

Conversation

@ng

@ng ng commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Weekly mutation hit list (#591, scheduled run 37119263099, commit 3cbbc1b): src/hooks/useSensorStream.ts was the top surviving file with 38 mutants. This PR adds 11 tests that kill the 23 actionable ones. No source changes.

Line Mutants Killed by
L412 >= → >, cond → false (snapshot frame replaces previous) equal-ts and newer-ts snapshot frames must replace the live frame
L414 ×6 (filter removed, arrow → undefined, cond true/false, !== → ===, * 1000 → / 1000) snapshot lastSensorTime is newest non-deviceStatus measurement in ms; deviceStatus-only snapshot leaves it null
L417 Math.max → Math.min same snapshot test with two sensor timestamps
L459 < → <= equal-ts live frame replaces previous
L462 ×4 (slice removed, filter removed, cond → true, >= → >) 10 s window inclusive boundary + 40-frame cap
L499 === '1' → false / '1' → "" demo socket only when NEXT_PUBLIC_DEMO === '1' (module mock)
L501 subprotocol → "" fake WS now records the protocol arg
L549 disconnect += 1 → -= 1 request id advances by one on disconnect
L608 ++ → -- second seek's requestId > first
L610 'get_waveform' → "" exact wire message shape
L612 id check → true superseded seek timer must not time out the newer request
L619 goLive += 1 → -= 1 stale reply cannot match a seek issued after goLive
L620 isSeeking: false → true goLive clears isSeeking

Each mutation was hand-applied locally and confirmed to fail the suite (23/23).

The useSensorStream artifact reports 263 killed, 15 surviving, 1 uncovered, 1 timeout, and 114 compile-error mutants (plus 12 ignored). The remaining survivors are outside the targeted behavioral changes or the previously identified equivalent cases; this PR does not claim a perfect mutation score.

Test plan

  • pnpm exec vitest run src/hooks/tests/useSensorStream.test.ts — 84 passed
  • eslint clean on the test file
  • Each of the 23 targeted mutations hand-applied → suite fails
  • Hooks shard passed in mutation run 37253648883, with the report artifact inspected. The hook implementation and test file are unchanged from that run; later commits only integrate dev.

🤖 Generated with Claude Code

🛏️ Beam this PR onto a sleepypod ✨

Pick the snippet that matches your pod. Already-installed pods can't use the curl bootstraps below — sleepypod's egress firewall DROPs github.com, and the script that knows how to unblock WAN is the very file curl is trying to fetch. Use sp-update instead; it's on disk and opens WAN as its first step.

🔄 Already on a sleepypod (most common — review a PR on a running pod):

sudo sp-update test/useSensorStream-mutants-591

🚀 Fresh pod / first install — bootstraps from GitHub, rebuilds every push:

curl -fsSL https://raw.githubusercontent.com/sleepypod/core/test/useSensorStream-mutants-591/scripts/install \
  | sudo bash -s -- --branch test/useSensorStream-mutants-591

🎯 Pin to this exact build (run 37405779525 · 78de3b3) — fresh-pod path, locked to one CI artifact for reproducible review:

curl -fsSL https://raw.githubusercontent.com/sleepypod/core/78de3b369f2d807b35e38a70bec1e63ac969915b/scripts/install \
  | sudo bash -s -- \
      --branch test/useSensorStream-mutants-591 \
      --artifact-url 'https://nightly.link/sleepypod/core/actions/runs/37405779525/sleepypod-core.zip'

🧊 Artifact: sleepypod-core · self-destructs in 30 days 💥

Summary by CodeRabbit

  • New Features
    • Demo system information now includes NATS firmware and transport details, probe signals, and piezo-dual stream timing, including the latest frame timestamp, age, and uptime.

ng and others added 3 commits October 3, 2026 23:17
The Settings → Device card polls system.getSensorSource every 10 s, and each
poll spawned systemctl three times plus mountpoint and read two files to
re-detect firmware that cannot change while the core is running. Memoize the
probe for the process lifetime and keep only the stream fields live; a service
restart re-detects.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
… source

A probe killed by its 3 s timeout says nothing about the firmware, so it is
served once but not memoized (CodeRabbit on #770). The demo coverage test
has been red on dev since #765 and #769 landed together because no demo
handler answered system.getSensorSource.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@ng ng added the mutation-test Opt-in: trigger mutation testing on this PR label Oct 5, 2026
@vercel

vercel Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
sleepypod-demo Ignored Ignored Preview Oct 6, 2026 2:46am UTC

@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b3b1420f-307f-46ff-80f6-faaeba1560a7
📥 Commits

Reviewing files that changed from the base of the PR and between 0348650 and a5542fc.

📒 Files selected for processing (2)
  • src/demo/handlers/system.ts
  • src/hooks/tests/useSensorStream.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The demo system handler now returns sensor-source firmware and stream metadata. The sensor-stream test suite adds WebSocket mock support and coverage for snapshot timestamps, waveform requests, demo-socket selection, and seek behavior.

Changes

Demo sensor source

Layer / File(s) Summary
Sensor-source response
src/demo/handlers/system.ts
Adds getSensorSource(). It returns fixed firmware signals and piezo-dual stream metadata, including the latest whole-second frame timestamp and age, a fixed first-frame duration, and uptime relative to DEMO_UPTIME_START.

Sensor-stream hook tests

Layer / File(s) Summary
Test harness and behavior coverage
src/hooks/tests/useSensorStream.test.ts
Updates the fake WebSocket and demo-socket mock, and restores environment and mock state after each test. Adds assertions for snapshot freshness and replacement, waveform retention and request IDs, demo-socket selection, stale replies, disconnect invalidation, and superseded seek timeouts.

Priority: ⬇️ Low

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

Change: Other

Merge Risk: ⚪ Minimal · up to a5542

The existing test covers stale replies after go-live, and the new demo sensor-source response fits the Device settings contract. No actionable merge-blocking issue remains.

Security Architecture Review

Security architecture risk: ⚪ Minimal · up to a5542

The new response supplies simulated diagnostics within demo mode. It does not contact a real device, change access controls, or modify persistent state. No material security risk was identified in the reviewed changes.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The new procedure's effects are bounded to simulated diagnostics in the browser demo. Caller-controlled input cannot direct it to a device, service, tenant, or data store because the handler does not consume input or invoke such resources.

Trust Boundaries and Controls

  • observed — The demo-versus-real-service routing boundary is unchanged. The real GET /system/sensor-source endpoint is already public and unprotected; this PR neither introduces that exposure nor replaces its implementation with the simulated handler.
  • observed — The flagged FakeWS declarations and demo-socket replacement are test-owned mocks, not production entrypoints. Their changes do not alter production socket selection or sensor-stream state ownership.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: tests for useSensorStream that target surviving mutants. The added demo handler is a secondary change.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Mutation test report

Shard Score Killed Survived No cov Timeout Errors Total
homekit 98.1% 459 8 0 1 202 695
hooks 96.9% 1263 36 2 3 525 1848
services-scheduler 89.5% 847 76 18 5 329 1286
streaming 88.0% 1653 196 8 22 609 2496

Full HTML reports: mutation-report-<shard> artifacts. Actionable hit list: mutation-hitlist artifact.

…ettings → Device UI

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@ng

ng commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Scope: full branch at a5542fcb249c34df875e671c31982b575e75a089 against dev.

Standard-depth adversarial review complete: independent Optimizer followed by Skeptic, using the inherited GPT-6 runtime because the skill’s legacy models are unavailable. Reviewed both the hook regression tests and demo system.getSensorSource handler (the actual diff includes this production demo change).

No actionable introduced findings. Skeptic agrees with confidence 94/100. No consensus fixes, disputed items, lower-confidence findings, or pre-existing findings retained.

Exact-head CI lint, typecheck, both builds and unit tests passed. Locally, 84 hook tests and the demo coverage/contract tests passed. Required codecov/patch is missing because the uploader download failed TLS; the Unit Tests job has been rerun to retry upload. Recommendation: approve on code, merge only once required checks are complete.

@codecov

codecov Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@ng

ng commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Integration follow-up at 9bf39712: incorporated #770 and kept its demo sensor handler exactly, so merging the two PRs cannot create a duplicate getSensorSource property. The independent Skeptic verified the integration; the hook tests are unchanged.

219 focused integration tests, TypeScript and ESLint pass. Pre-push checks also passed both Drizzle schema checks and 433 related tests. New-head CI is pending; merge remains gated on those checks.

@ng
ng enabled auto-merge October 6, 2026 02:46
@ng
ng added this pull request to the merge queue Oct 6, 2026
Merged via the queue into dev with commit c29fc0b Oct 6, 2026
9 checks passed
@ng
ng deleted the test/useSensorStream-mutants-591 branch October 6, 2026 02:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mutation-test Opt-in: trigger mutation testing on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant