Build history and observation sessions¶
Daemonitor supports two complementary mechanisms for turning continuous process samples into build-level records: passive build detection and observation sessions.
Passive build detection¶
Gradle daemon-log correlation¶
For active GRADLE_DAEMON processes, Daemonitor tails <GRADLE_USER_HOME>/daemon/<version>/daemon-<pid>.out.log and correlates log markers with SQLite process_samples:
- Tracks daemon identity via
DefaultDaemonContextuidso PID reuse cannot merge builds from two different daemons. - Opens a build window on
Marking the daemon as busyand closes it onMarking the daemon as idle(requiring at least oneBuild{id=..., currentDir=...}orStarting ... build in daemonline to discard health/expiration brackets). - Parses
BUILD SUCCESSFUL|FAILED in <duration>when present (COMPLETED_NO_OUTCOMEotherwise;INTERRUPTEDif the daemon exits mid-build). - Aggregates
PeakMemoryMB,AvgMemoryMB, andPeakCPUPercentfrom samples inside[busyTimeMs, endMs]. - Infers invocation source (
IDE,TERMINAL,UNKNOWN) and coding agent (Claude Code,Cursor,Codex,Gemini CLI,Aider, orAI_*) fromConfiguring env variables: [...].
Passive Xcode sessions¶
When daemonitor-cored observes an XCODE_BUILD (xcodebuild) process without an explicit session, it automatically opens a passive observation session, accelerates polling to 1s, and persists the closed summary into the builds table (daemonIdentity prefixed xcode:).
Explicit observation sessions¶
Explicit sessions bound monitoring to a specific build invocation via:
daemonitor-cli observe -- <CMD> [ARGS...]POST /v1/sessionsandPOST /v1/sessions/{id}/closeondaemonitor-cored- The experimental Gradle plugin
Session lifecycle and correlation¶
- Open: Records
session_id,ecosystem(gradle,xcode, orgeneric),mode(explicitorpassive),root_project_path, redactedcommand_line, and anchor(pid, start_time_ms). Wakes the poll loop immediately. - Collect: Polls at
<= 1sintervals, linking observed processes to the session insession_process_linkswith attribution confidence: confirmed: Anchor process, descendant within parent depth 8, or matching-derivedDataPath/ project path.inferred: Related ecosystem process active during the session window.ambiguous: Concurrent overlapping builds (for example, twoxcodebuildruns without distinct-derivedDataPath).- Close: Triggers one final poll refresh, computes per-tick peak simultaneous RSS/footprint/parallelism and per-incarnation CPU/disk I/O deltas, persists the summary, and returns
sessions.Summarywith per-role rollups.
Passive monitoring vs. explicit sessions¶
| Aspect | Passive monitoring | Explicit observe session |
|---|---|---|
| Setup required | None | Wrap command with daemonitor-cli observe -- ... |
Works with --no-daemon / arbitrary commands |
No | Yes |
| Polling cadence | 2s (or 1s for xcodebuild) |
<= 1s with immediate wake |
| Command line recorded | null for passive Gradle builds |
Redacted command line |
| Machine-readable summary on exit | Query builds / history |
Printed to stderr + optional --output JSON file |