feat(sp-bundle-logs): one-shot diagnostic capture for support handoffs#580
Conversation
Closes #575. Support sessions lose minutes per pod assembling journals, systemctl status, network state, and version info by hand. This script produces a single /tmp/sleepypod-bundle-<ts>.tar.gz the user can scp off in one step. Redacts .env credential-suffixed keys and HomeKit pairing material by default so the bundle is safe to drop in Discord/GH; --no-redact is available for self-debugging. Picked up automatically by the install/sp-update sp-* glob loops.
📝 WalkthroughWalkthroughAdds ChangesDiagnostic Bundle Capture
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@scripts/bin/sp-bundle-logs`:
- Around line 177-178: The tar invocation currently silences failures so the
script can still report success; after running tar -czf "$OUT" -C "$STAGE" .
capture its exit status (or check that "$OUT" exists and is a non-empty valid
archive) and if tar failed, log an error and exit non‑zero instead of continuing
to compute SIZE and printing "Bundle written"; update the section around the tar
command and the SIZE=$(du -h "$OUT" | ...) usage to gate the success message on
the tar success (use the OUT and STAGE variables and the tar invocation as the
referenced symbols).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 098635f8-f0ed-427c-a910-80d8174fb879
📒 Files selected for processing (3)
scripts/README.mdscripts/bin/sp-bundle-logsscripts/install
CodeRabbit (#580): swallowing tar's exit status meant a missing or corrupt archive could still print 'Bundle written'.
…ning (#582) ## Summary 32 commits since v2.0.1 (#554). Highlights: **Features** - Alarms UI: create / edit / test scheduled alarms (#556) - `sp-bundle-logs`: one-shot redacted diagnostic capture for support handoffs (#580) **Install hardening** - Install sp-* CLI tools *before* starting the service so ExecStartPre can find sp-maintenance (#547) - Fetch CI artifacts via nightly.link; auto-inject install commands into PR body (#577) - Guard against Volta + symlink leftovers in `/usr/local/bin/`; remove the now-stale free-sleep toggle path (`20bfc4d`) - `sp-update` now runs the biometrics-archiver install on OTA upgrades, fixing a regression where pods past v2.0.0 silently stopped populating biometrics (#579) **HomeKit stability** - Rotate `AccessoryPairingID` on unpair so iOS isn't stranded (#566) - Post-PR-566 follow-ups: orphan cleanup, wipe-stability docs, transitioning flag (#571) - Auto-rotate stranded identities + switch mDNS default to `ciao` (#578) **Hardware** - Classify real Pod 5 sensor labels as Pod 5, not Pod 3 (#550) **Tests / CI** - Coverage lift to 95% / 87% / 93% / 96% across the JS suite (#548–#553, #557–#565, #569) - Kill ~95 surviving Stryker mutants in sleep-stages (#570) - Codecov pytest workflow + flag-scoped reports (#544) - Mutation testing improvements (#541, #546) ## Test plan - [x] All CI gates green on dev (build, lint, typecheck, unit, codecov, coderabbit) - [x] sp-bundle-logs validated end-to-end on Pod 5 (192.168.1.88) via sp-update + bundle inspection - [x] HomeKit stranded-identity rotation tested in #578 - [ ] Smoke-deploy to a fleet pod after merge; verify alarms UI, sp-update OTA, biometrics still ingest <!-- sleepypod:install-start --> <!-- 🛑 AUTO-GENERATED — sleepypod-bot owns this block. Hello fellow agent / curious human! Anything between the sleepypod:install-start and sleepypod:install-end markers gets overwritten on the next CI run. Want to change what's here? Edit .github/workflows/build.yml instead. 💤 --> <details open> <summary>🛏️ <strong>Beam this PR onto a sleepypod</strong> ✨</summary> 🚀 **Latest build of `dev`** — rebuilds every push, zero auth: ```bash curl -fsSL https://raw.githubusercontent.com/sleepypod/core/dev/scripts/install \ | sudo bash -s -- --branch dev ``` 🎯 **Pin to this exact build** ([run 25843800709](https://github.com/sleepypod/core/actions/runs/25843800709) · `8e27c3f`): ```bash curl -fsSL https://raw.githubusercontent.com/sleepypod/core/8e27c3f63905f60cdfbfcc92d597d768628cfd54/scripts/install \ | sudo bash -s -- \ --branch dev \ --artifact-url 'https://nightly.link/sleepypod/core/actions/runs/25843800709/sleepypod-core.zip' ``` 🧊 Artifact: [`sleepypod-core`](https://github.com/sleepypod/core/actions/runs/25843800709/artifacts/6987899043) · self-destructs in 30 days 💥 </details> <!-- sleepypod:install-end --> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
|
🎉 This PR is included in version 2.2.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Summary
Closes #575. Adds
scripts/bin/sp-bundle-logs, a single command that produces/tmp/sleepypod-bundle-<ts>.tar.gzcontaining everything support typically asks for: service journals (boot-scoped),systemctl statusfor every sleepypod unit, pod capabilities, network state (iptables-save, ip route, resolv.conf, nsswitch.conf, /etc/hosts), host state (uptime, free, df), tool versions, git HEAD, install log, and.env/ homekit summaries..envvalues for any key matching(TOKEN|SECRET|PASSWORD|PASSWD|KEY|CREDENTIAL|API)and replaces the homekit dir with a presence/count summary — bundle is safe to drop in Discord/GitHub.--no-redactincludes raw.env+ raw homekit files for self-debugging.pnpmpre-install, noiptables-save) doesn't abort the bundle — each file ends with(exit: N)so failed captures are obvious.sp-updatesp-*glob loops; no separate wiring needed.Test plan
bash -n scripts/bin/sp-bundle-logs— syntax cleansp-bundle-logs --helpprints the header commentsp-bundle-logs --bogusexits 2 with usage.envredaction verified against synthetic file:EXPORT_TOKEN,API_KEY,SUPABASE_SECRETall masked;DATABASE_URL,DAC_SOCK_PATH,NODE_ENV,PNPM_HOMEpreservedsudo sp-bundle-logs, scp the tarball off, eyeball that journals/status/iptables-save have real contentSummary by CodeRabbit
New Features
sp-bundle-logsdiagnostic command that bundles logs and system state into a timestamped archive for support assistance, with optional--no-redactflag to preserve raw configuration data.Documentation
🛏️ Beam this PR onto a sleepypod ✨
🚀 Latest build of
feat/sp-bundle-logs— rebuilds every push, zero auth:curl -fsSL https://raw.githubusercontent.com/sleepypod/core/feat/sp-bundle-logs/scripts/install \ | sudo bash -s -- --branch feat/sp-bundle-logs🎯 Pin to this exact build (run 25842085283 ·
1fb24b5):🧊 Artifact:
sleepypod-core· self-destructs in 30 days 💥