Repository navigation
power-ab: stop measurements on unavailable battery samples - #226
Conversation
Do not count failed sysfs reads as zero current or retain incomplete charge samples. Validate exposed properties before writing a row and exit through the restoration trap on failure. Keep absent optional properties supported. Test the production sampler against missing and malformed properties, signed current and EXIT cleanup. The regression fails on the base and passes with this fix. Co-Authored-By: OpenAI Codex <noreply@openai.com>
|
Thanks, the bug is real: an empty voltage or current field is averaged as zero and makes the drain look smaller than it is. Two things before it lands. First, power-ab normally runs with |
|
Thanks, Gr-linkk, this covers everything: the reason lands in the CSV so a detached run explains itself, the optional fields stay empty instead of ending the run, and the two required reads get one retry, all with tests. One optional tweak: the retry comes straight after the failed read, so after a resume a |
Give the gauge time to recover after resume before retrying a failed required sample. Co-Authored-By: Codex <noreply@openai.com>
|
Thanks, @Gr-linkk. The |
Keep current main test coverage and the sampler regression when resolving the tests/all conflict. The sampler still needs this fix; main retains unchecked voltage/current reads. Preserve the merged preflight and tool help updates without changing their behavior. Co-Authored-By: Codex <noreply@openai.com>
|
Thanks, @Gr-linkk. I checked the refresh: the change to Nothing more is needed from you. What's left is mine: the short run on my Pixel 7 Pro (a baseline run with the cable out, and one s2idle phase for the read after a wake). Once that's done I'll squash it with a hand-written message, since the branch carries merge commits. |
Resolve tests/all by retaining main including build-packages-host-tools and the sampler regression on its own line. The accepted sampler and its regression remain byte-identical; preserve main preflight/detach checks. Co-Authored-By: Codex <noreply@openai.com>
|
Thanks, @Gr-linkk. I checked the new head: Nothing is needed from you. One small thing I may adjust myself when I merge: the test's line in What's left is still mine: the short run on my Pixel 7 Pro (a baseline with the cable out and one s2idle phase for the read after a wake). Then I'll squash it with a hand-written message. |
Retain main's complete suite list and move the sampler regression into the one-suite-per-line block requested in review. This avoids conflicts with additions to the neighbouring loop without changing the sampler. Co-Authored-By: Codex <noreply@openai.com>
|
Thank you for the new head, @Gr-linkk: The Pixel 7 Pro run is done (Omarchy 4.5.0-3,
So the sampler holds on the phone it was written against. Merging, with the message written by hand. |
…zero (derekross#226) A failed voltage_now or current_now read became an empty CSV field, which the summary's awk averaged as zero, so the drain looked smaller than it was. The sampler now validates each required value, retries once after a second (for the read right after a wake), and otherwise writes the reason into the CSV as a # line and exits through the restore trap, so a detached run explains itself; the optional charge and average fields stay empty on a failed read. tests/power-ab/samples.py runs the real sample() against files. Tested on the Pixel 7 Pro (7.3.0-rc6-omamobile-g1a9d1d4e9289, 2026-11-11): a baseline run of 232 whole rows, and an s2idle run with the cable out where the RTC alarm woke the phone after 299 s and the row written right after the wake was whole; no stop line in either. Co-Authored-By: Codex <noreply@openai.com>
A failed voltage/current sysfs read previously became an empty CSV field, which awk counted as zero. This could understate drain when a cached battery provider rejects stale telemetry. Failed charge reads could also leave incomplete charge measurements.
Collect and validate each sample before emitting its CSV row. Retry invalid or unavailable voltage/current once after a one-second pause, then record the failure as a CSV comment and stop through the existing restoration trap without generating a misleading summary. Optional average-current and charge fields stay empty on a failed or malformed read rather than ending the run.
Validation: the production sampler regression covers signed and zero current, missing/malformed required fields, retry delay and recovery, optional-field failures, CSV diagnostics and EXIT-trap execution. It passes after merging current main. Repository
tests/all, package tests, Bash syntax, repository policy and whitespace checks pass. No phone operations or hardware qualification performed.Branch refresh (2026-11-11): normal merge of main at
92074ca. Retained main's complete suite list and moved the sampler regression into the existing one-suite-per-line block, as suggested in review, to avoid repeated conflicts with additions to the neighbouring loop. The accepted sampler and regression code remain unchanged. Main's sleep preflight and pre-detach checks are preserved. Derek's short phone run remains outstanding; no new diagnostics or features are included.Scope note: this is a bounded measurement correctness fix, not Pixel 6 display or battery enablement. Local Oriole backlight and battery functional prototypes survive, but their startup packages rely on private pinned modules, loaders and safety services absent from current main. They require a separate kernel/package integration effort; their recorded hardware results do not qualify this upstream tree. This patch does not establish snapshot coherence or freshness when a provider silently returns old data.