fix(power): coalesce charge-limit reapply events
All checks were successful
Check / eval (push) Successful in 3m16s

USB-C power event bursts could repeatedly restart and SIGTERM the settling oneshot until systemd reached its start limit. Let successful runs return inactive and use coalescing start jobs for immediate and delayed reapplication.

Verified: V0 nix flake check --no-build, module parse, and git diff --check; V2 focused battery-charge-limit KVM test with a 12-event active-run burst. V3 hardware item #101 remains queued.
This commit is contained in:
2026-07-13 14:09:05 +01:00
parent 2a34c7398b
commit 7bfe1af5b1
6 changed files with 102 additions and 19 deletions

View File

@@ -11,6 +11,20 @@ the **T14s** (webcam case).
## Any machine (dev box is fine)
- [ ] **#101 charge-limit service survives USB-C power-event bursts** —
after updating/rebuilding to the commit carrying this entry, clear the
old failure with `sudo systemctl reset-failed
nomarchy-battery-charge-limit.service`. Plug and unplug the powered
USB-C dock twice, allowing five seconds after the last transition.
**Pass:** `systemctl show nomarchy-battery-charge-limit.service -p
ActiveState -p Result` reports `ActiveState=inactive` and
`Result=success`; `systemctl is-failed
nomarchy-battery-charge-limit.service` is false; BAT0's
`charge_control_end_threshold` still matches the configured/live limit;
and `journalctl -b -u nomarchy-battery-charge-limit.service` contains
no new `SIGTERM`, `start-limit-hit`, or `Failed with result` lines after
the rebuild. Capture that journal plus `udevadm monitor
--subsystem-match=power_supply` if it fails.
- [ ] **Docking recovery round 4 (#100, closed-lid BenQ sequence)** — after
updating to the commit carrying this entry, run `nomarchy-home` and
relogin. With the lid open, put visible windows on at least workspaces

View File

@@ -19,6 +19,21 @@ Template:
---
## 2026-07-13 — #101 charge-limit AC-event burst recovery (this commit)
- **Task:** Fix `nomarchy-battery-charge-limit.service` failing when USB-C
dock power events arrive while its settling write is still active.
- **Did:** The oneshot now returns inactive after success; immediate and
delayed udev paths use coalescing `start` jobs instead of interrupting
`restart` jobs. Strengthened the focused VM with a 12-event Mains burst
during an extended active run and explicit failed/start-limit assertions.
- **Verified:** V0 `nix flake check --no-build`, module parse, and
`git diff --check`; V2
`nix build .#checks.x86_64-linux.battery-charge-limit --no-link -L`
under KVM — the 12-event active-run burst finished inactive/success,
changed InvocationID, and produced no failed/start-limit journal result.
- **Pending:** V3 post-rebuild dock-power burst check in HARDWARE-QUEUE.
- **Next suggestion:** run V3 #101 alongside docking round 4, then #91.
## 2026-07-13 — #100 dock transition recovery (this commit)
- **Task:** Fix the real T14s dangling workspace, closed-lid cable-removal
suspend/apparent crash, and BenQ audio miss after 7ebfab4.

View File

@@ -77,7 +77,10 @@ iteration would otherwise rediscover.
examples to crib from: `distro-id` (boots + `switch-to-configuration
dry-activate`), `hardware-toggles` (kernel cmdline/PAM assertions),
`battery-charge-limit` (fake Mains adapter via `test_power`, real udev
uevent, `InvocationID` change proves the restart).
event burst while the oneshot is active; clean inactive result plus an
`InvocationID` change proves coalesced AC re-apply). AC udev hooks for a
settling oneshot must use `start`, never `restart`: USB-C docks emit event
bursts and restarts SIGTERM the in-flight pass into `start-limit-hit`.
- Themed-desktop screenshots work headlessly: software-GL Hyprland
(`LIBGL_ALWAYS_SOFTWARE` on virtio-gpu) + `machine.screenshot()` QMP
dump — prototyped 2026-06-19, kept as the fallback for theme previews