Process discovery and classification¶
Daemonitor discovers build processes passively by enumerating OS processes on each poll cycle and matching executable and command-line signatures—no build-tool instrumentation is required for live monitoring.
Discovery pipeline¶
In daemonitor-cored (cored/internal/poll/poll.go), each poll runs in two passes:
- Pass 1 — OS discovery and classification:
- Enumerates PIDs via
gopsutiland reads each process's command line. - Applies strict-precedence classification rules. Processes that do not match any rule are dropped (there is no
UNKNOWNcatch-all type). - Collects OS metrics (RSS, virtual memory, CPU counters, threads, I/O, page faults, context switches, file descriptors, and platform-specific metrics such as macOS
proc_pid_rusageor Linux cgroups/PSS). - Pass 1b (Xcode children): If at least one
XCODE_BUILDorXCODE_BUILD_SERVICEprocess is live, candidate child tools (codesign,lipo,strip,plutil,sh/bash/zsh, or unscoped compilers) are verified by walking parent PIDs up to depth 6. - Pass 2 — Bounded JVM probes:
- Runs
jcmd,jstat, andjinfoconcurrently up toProbeConcurrency(default2) with a750mstimeout per probe on eligible JVM processes. - Probe failures never drop the process's OS row; unavailable JVM fields remain
nulland record sanitized diagnostics (heap_probe_diagnostics).
In the Kotlin --jvm-collector fallback (ProcessCollector.kt), OSHI enumerates processes scoped to the same effective UID (excluding selfPid), and skips Pass 1b Xcode ancestor-child verification.
Classification dimensions¶
Daemonitor classifies every discovered process along four independent dimensions (cored/internal/model/classification.go and ProcessClassification.kt):
| Dimension | Values | Purpose |
|---|---|---|
BuildSystem |
GRADLE, BAZEL, XCODE, AMPER (Kotlin Toolchain), UNKNOWN |
Build system responsible for the process (display order: Gradle → Bazel → Xcode → Kotlin Toolchain → Other / Unknown) |
Runtime |
JVM, NATIVE, UNKNOWN |
Execution runtime — controls column layouts and gates live JVM probing (jcmd/jstat) |
Toolchain |
JAVA, KOTLIN, SWIFT, CLANG, CPP, GO, RUST, UNKNOWN |
Language/compiler toolchain associated with the process |
ProcessType |
GRADLE_DAEMON, BAZEL_SERVER, BAZEL_WORKER, BAZEL_TEST, KOTLIN_DAEMON, KOTLIN_TOOLCHAIN, XCODE_BUILD, etc. |
Specific role of the observed process |
Classification examples¶
| Workload | BuildSystem |
Runtime |
Toolchain |
ProcessType |
|---|---|---|---|---|
| Gradle Kotlin daemon | GRADLE |
JVM |
KOTLIN |
KOTLIN_DAEMON |
Bazel rules_kotlin worker |
BAZEL |
JVM |
KOTLIN |
BAZEL_WORKER |
| Bazel Swift persistent worker | BAZEL |
NATIVE |
SWIFT |
BAZEL_WORKER |
| Bazel native test leaf | BAZEL |
NATIVE |
UNKNOWN / toolchain |
BAZEL_TEST |
| Xcode Swift compiler | XCODE |
NATIVE |
SWIFT |
XCODE_COMPILER |
| Kotlin Toolchain / Amper CLI | AMPER |
JVM |
KOTLIN |
KOTLIN_TOOLCHAIN |
| Unattributed Kotlin daemon | UNKNOWN |
JVM |
KOTLIN |
KOTLIN_DAEMON |
Ambiguous classifications and conservative fallbacks¶
- Build system: Validated OS ancestry takes precedence (
BazelOwnerPID>HasAmperAncestor>HasGradleAncestor>HasXcodeAncestor), followed by command-line markers. An unattributedKOTLIN_DAEMONdefaults toBuildSystem.UNKNOWNrather than assuming Gradle. - Runtime:
BAZEL_WORKER,BAZEL_TEST, andGRADLE_WRAPPERinspect the OS executable (java/javaw→JVM; shell/sandbox wrappers →NATIVE; ambiguous →UNKNOWN). Live JVM probing runs only whenruntime == JVMand the executable is a JVM binary.
Process identity and PID reuse protection¶
Operating systems reuse PIDs after a process exits. Daemonitor guards against PID-reuse corruption across every layer using (pid, createTimeMs) (plus hostID in SQLite):
- CPU delta calculation: Keyed by
incarnationKey{pid, createTimeMs}with monotonic counter checks (user,system,totalmust not decrease). - Platform collector: If the OS reports a creation time differing by
> 1000msfrom the expectedCreateTimeMs, metrics are markedstale. - JVM probe cache: Keyed by
(pid, startTimeMs). - SQLite lifecycle tracking:
process_instances.id = "<hostID>:<pid>:<createTimeMs>"(UNIQUE(host_id, pid, create_time_ms)), emittingprocess.first_observed,process.disappearance_detected, andprocess.configuration_observedevents without fabricating exit codes. - TUI termination & hierarchy: Verifies live OS
CreateTimematchesstartTimeMsimmediately before sending a termination signal.