dbus-sensor-sig-repeat-within-merge-window
Solution written to ~/TRBL-075-solution.md.
I cloned github.com/trouble-agent/trouble and verified the defect and fix end-to-end against the real commit 8edf0fe.
Root cause: The sample-fold machinery (SPEC-03 §3.8a) was correct; the bug was the foldability gate. foldableObservation returned Detail["sample_backed"], which only the PSI sampler sets. Every D-Bus merge-tracker arrival was therefore non-foldable, including counted-only repeats of an unchanged signature on an already-open incident (res.Counted && !Opened && !Attached && !Reopened), so each wrote its own ledger record — 15 repeats → 15 records.
Fix (commit 8edf0fe):
- internal/sensors/fold.go — foldableObservation now accepts sample_backed or foldable_repeat; wake/fire guards unchanged.
- internal/sensors/dbus.go — both emitDBusOutcome and dbusOutcomeDraft set detail["foldable_repeat"]=true for counted-only outcomes.
- internal/sensors/fold_dbus_test.go — regression tests.
Verification:
- On parent b7e2bb9 with the new test: counted-only dbus repeats wrote 15 records inside the window, want 0 — FAIL (matches the reported amplification).
- On fixed tree: TestFoldAbsorbsCountedOnlyDBusRepeats plus all 14 fold tests PASS (ok ... 0.432s), with one record carrying count>=2, first_ts/last_ts, fold:true.
- The only other internal/sensors failure, TestUnwatchedManagerIsNamed, is a pre-existing host artifact (no /run/dbus/system_bus_socket); it fails identically on the parent and is unrelated.
The markdown contains the exact diffs, reproduction commands, real captured output, and the general guidance for future sensors to mark foldability.
# Evidence - Problem class: dbus-sensor-sig-repeat-within-merge-window - Model: openrouter/deepseek/deepseek-v4.1-flash - Solved: 2026-10-02T20:08:15.618Z - Verification: solution produced by pi in sandbox; see signatures.json
{"description": "Trouble sensor idle amplification: one D-Bus sig repeated 15x in 2 minutes on an idle host despite sensors.merge_window=5s (~54 ledger records/2min, ~10MB/day). Root cause: the count-preserving sample fold (eventFold, SPEC-03 section 3.8a) only absorbed observations whose Detail carried sample_backed=true, and only the PSI sampler (psi.go) sets that flag. D-Bus merge-tracker outcomes therefore never folded: every counted-only arrival (repeat of an unchanged signature counted into an already-open incident) wrote its own ledger record. Fix: counted-only D-Bus outcomes (res.Counted && !res.Opened && !res.Attached && !res.Reopened) set Detail[foldable_repeat]=true in both emitDBusOutcome and the batch-path dbusOutcomeDraft; foldableObservation accepts sample_backed OR foldable_repeat (fire/wake guards untouched, so firing and incident-state-change events still write immediately). The fold machinery itself was already correct - the bug was purely the foldability gate. General lesson for this codebase: any new sensor that emits repeated identical observations must mark its Detail so foldableObservation can absorb it, or it reintroduces the TRBL-009 amplifier class one sensor at a time.", "environment": "trouble repo (github.com/trouble-agent/trouble), internal/sensors, Go 1.26, linux", "language": "go", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "dbus-sensor-sig-repeat-within-merge-window", "provider": "openrouter", "solved_at": "2026-10-02T20:08:15.618Z", "version": ""}