WIP: feat: background monitoring (sub-project 2/6) - #2
Draft
quinnbot-ai wants to merge 6 commits into
Draft
Conversation
added 6 commits
April 11, 2026 19:24
Rolling buffer dashcam model, schedule-aware absolute dB thresholds, explicit timed sessions with 12h cap, iOS Background Audio mode, sustained-threshold debouncing with tail extension for merged events, MonitorSession signed metadata + per-session audit chain.
…ice, triggered capture WARNING: test runner crashes non-deterministically when running the full suite under iPhone 17 sim 26.4. The crash happens at varying entry points even with parallelism disabled, suggesting a simulator stability issue rather than a code bug (the same simulator ran sub-project #1's 51 tests cleanly earlier in the session). Individual subsystem tests pass when run in isolation. Code added in this commit: - MonitorAudioWriter (Float32 -> m4a, with explicit close to flush AAC header) - ThresholdSettingsStore (UserDefaults-backed thresholds + quiet hours) - MonitorSessionService (start/finalize/recoverCrashed with in-Swift filter) - EventCaptureService.finalizeTriggered (stamps signed monitorTriggerJSON) Known follow-up: investigate runner stability before adding NoiseMonitor + UI; recoverCrashed test temporarily marked .disabled with TODO.
P0 shipped: memory write capturing architecture + blockers. P0 outstanding: test runner crash root cause, recoverCrashed launch crash risk. P1: SE device test, openssl roundtrip, CI, deleted-events UI, displayName validation.
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.
Status: DRAFT — runner instability blocking final verification
This PR has 9 of 22 planned tasks implemented from
docs/superpowers/plans/2026-04-11-soundcase-background-monitoring.md.What's done
Phase 1 (pure-logic, fully tested):
CircularAudioBuffer— ring buffer for pre-trigger PCM framesThresholdEvaluator+QuietHoursWindow(handles wrap-around midnight)MonitorStateMachine— arming/triggered/cooldown with sustained-threshold debouncing and tail extensionPhase 2 (data + crypto):
MonitorSessionSwiftData modelMonitorSessionSigner— signs session start metadata, parallel toEventSignerNoiseEvent.monitorTriggerJSONfield, included in the signed canonical blobPhase 3+4 (services, code complete):
MonitorAudioWriter— AVAudioFile wrapper, explicit close() to flush AAC headerThresholdSettingsStore— UserDefaults-backed thresholdsMonitorSessionService— start/finalize + crash recoveryEventCaptureService.finalizeTriggered— signs triggered events with monitorTriggerJSONRemaining (13 tasks)
NoiseMonitorglue class (AVAudioEngine + buffer + state machine + writer)Blocker
The Xcode 26.4 + iPhone 17 simulator test runner crashes non-deterministically when running the full SoundCase test suite. The crash entry point varies between runs, suggesting a simulator stability issue rather than a specific test bug. Sub-project #1's 51 tests ran cleanly on the same sim earlier in the session.
recoverCrashedtest marked.disabledto reduce surface area; doesn't help.Need a fresh debug session to:
xcrun simctl erase all)XCTSkipguards or split the suite into multiple bundlesTest plan