Skip to content

WIP: feat: background monitoring (sub-project 2/6) - #2

Draft
quinnbot-ai wants to merge 6 commits into
mainfrom
feat/background-monitoring
Draft

WIP: feat: background monitoring (sub-project 2/6)#2
quinnbot-ai wants to merge 6 commits into
mainfrom
feat/background-monitoring

Conversation

@quinnbot-ai

Copy link
Copy Markdown
Owner

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 frames
  • ThresholdEvaluator + QuietHoursWindow (handles wrap-around midnight)
  • MonitorStateMachine — arming/triggered/cooldown with sustained-threshold debouncing and tail extension

Phase 2 (data + crypto):

  • MonitorSession SwiftData model
  • MonitorSessionSigner — signs session start metadata, parallel to EventSigner
  • NoiseEvent.monitorTriggerJSON field, included in the signed canonical blob

Phase 3+4 (services, code complete):

  • MonitorAudioWriter — AVAudioFile wrapper, explicit close() to flush AAC header
  • ThresholdSettingsStore — UserDefaults-backed thresholds
  • MonitorSessionService — start/finalize + crash recovery
  • EventCaptureService.finalizeTriggered — signs triggered events with monitorTriggerJSON

Remaining (13 tasks)

  • NoiseMonitor glue class (AVAudioEngine + buffer + state machine + writer)
  • iOS Background Audio mode (Info.plist, MPNowPlayingInfoCenter)
  • UI: MonitorStartSheet, MonitorSessionView, MonitorSummarySheet, ThresholdSettingsView, RecordView entry point
  • PDF integrity section trigger context
  • ContentView crash recovery hook
  • E2E test, README, final verification

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. recoverCrashed test marked .disabled to reduce surface area; doesn't help.

Need a fresh debug session to:

  1. Reset simulator state thoroughly (xcrun simctl erase all)
  2. Try a different sim runtime (26.2 instead of 26.4)
  3. Add XCTSkip guards or split the suite into multiple bundles
  4. Or move to a real-device test target

Test plan

  • Resolve runner instability and confirm full suite green
  • Implement remaining 13 tasks
  • Manual device test of background recording, lock-screen card, crash recovery
  • openssl verification of a triggered event's PDF

QuinnBot 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.
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