GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — power-guard: gate UPower's critical-power hybrid-sleep behind a sustained-reading confirmation (laptop slept 2h40m on a glitched battery reading, 2026-10-28) · Issue #1687 · developing-today/code

power-guard: gate UPower's critical-power hybrid-sleep behind a sustained-reading confirmation (laptop slept 2h40m on a glitched battery reading, 2026-10-28) #1687

New issue
Copy link
New issue
Copy link
Open
Open
power-guard: gate UPower's critical-power hybrid-sleep behind a sustained-reading confirmation (laptop slept 2h40m on a glitched battery reading, 2026-10-28)#1687
Copy link
Labels
area/infraInfrastructure, deployment, and operationsarea/nixNix expressions, flakes, and packagingeffort/sSmall: expected under 2 hours of workkind/infrastructureInfrastructure / host-portability workmeta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/highImportant and time-sensitivequeue/queuedHas a queued queue tasksource/humanFiled directly by a humanuser/escalatedRequires a Drew decision or accesswork/assignedQueue worker lifecycle state

Description

@dezren39
dezren39
opened on Oct 28, 2026
Issue body actions

Incident (2026-10-28, laptop amd-6)

The laptop was unreachable fleet-wide ~06:11–09:00 CDT. Journal evidence:

  • 06:12:29 systemd-logind: hybrid-sleep requested from client PID 38231 ('upowerd') ... The system will hybrid sleep now!
  • 06:12:29 systemd[1]: Reached target Sleep / systemd-sleep: Performing sleep operation 'hybrid-sleep' / kernel PM: hibernation: hibernation entry
  • 08:53:10 systemd[1]: Stopped target Sleep (resume)

UPower's critical-power action (CriticalPowerAction=HybridSleep, PercentageAction=2, PercentageCritical=5, TimeAction=120) fired on a reading that could not have been real: no low-battery warnings were logged beforehand, and minutes after resume the battery read 99%, Charging, AC online=1. A real drain to 2% cannot recharge to 99% that fast. Most likely a glitched time-to-empty/percentage sample (the machine also carries several churning UCSI USB-C power-source entries). Cost: a ~2h40m fleet-wide laptop outage (46 queue items parked on the outage tracker).

UPower has no "wait and re-check" setting — it acts on a single sample. Drew's direction: keep sleep as the response to a genuine critical battery (this machine is normally on AC, but if it were on battery, sleep beats a hard power loss); a false sleep is worse than either.

The guard (built + tested 2026-10-28)

A small poller that adds the missing confirmation step. Tested implementation already exists on the laptop at ~/tools/power-guard.py (python3, no deps):

  • Polls /sys/class/power_supply every 15s.
  • While discharging and at/below 20% (UPower's PercentageLow) or a ≤900s time-to-empty, it holds a systemd-inhibit --what=sleep --mode=block lock, so UPower's sleep request cannot fire unconfirmed.
  • Any recovery (AC back, status Charging/Full, charge above the low line) releases the lock and resets all timers — a glitch never survives minutes of continuous polling.
  • Only a sustained critical state makes the guard release the lock and issue systemctl hybrid-sleep itself:
    • at/below 2% (UPower's PercentageAction): sustained 60s
    • at/below 5% or ≤300s-to-empty: sustained 300s
  • On AC it can never fire.

Fake-battery test (fake sysfs tree, stubbed inhibitor + sleep command, compressed timers) — all assertions passed:

  • engages the block when unplugged at 18%
  • detects critical at 4%, does not fire inside the confirmation window
  • AC returning mid-confirmation releases the block, no sleep
  • sustained 2% fires exactly once, via the edge path

Landing spec

  1. Add a power-guard systemd service to the laptop's NixOS config (the #amd system in this repo's flake), beside nixos/services/pm-stack/: runs the script as root, Restart=always, starts at boot. Install the script content from the tested ~/tools/power-guard.py on amd-6 (pin it into the repo; do not hand-copy at deploy time).
  2. Leave UPower's config and thresholds unchanged — the guard gates the action, it does not replace UPower's detection.
  3. After the switch, verify on the live machine: service active; systemd-inhibit --list shows the block only while discharging at/below the low line (test by a brief AC unplug above the critical line — expect block engaged, no sleep, release on replug).
  4. Retire the hand test copy at ~/tools/power-guard.py once the flake service is live (pointer comment is fine).

Drew approved the design + thresholds in chat 2026-10-28 09:13 CDT (5-minute confirmation, 1 minute at a true 2%).

Acceptance criteria

  • A power-guard systemd service exists in the laptop's NixOS config (the #amd system in this repo's flake), beside nixos/services/pm-stack/, running the guard script as root with Restart=always, starting at boot; the script content is pinned into the repo from the tested ~/tools/power-guard.py on amd-6 (not hand-copied at deploy time).
  • UPower's config and thresholds are unchanged — the guard gates the action, it does not replace UPower's detection.
  • Live verification after the switch: the service is active; systemd-inhibit --list shows the sleep block only while discharging at/below the low line; a brief AC unplug above the critical line engages the block with no sleep, and replugging releases it.
  • The hand test copy at ~/tools/power-guard.py is retired once the flake service is live (a pointer comment is fine).

Activity

Next
  1. developing-today commented on Oct 28, 2026

    @developing-today
    developing-todayBot
    on Oct 28, 2026 – with developing.today
    Contributor
    More actions

    CODE-677

  2. github-actions
    assigned
    dezren39
    on Oct 28, 2026
  3. dezren39
    added
    kind/infrastructureInfrastructure / host-portability work
    source/humanFiled directly by a human
    status/needs-triageNot yet triaged; needs a first look
    priority/highImportant and time-sensitive
    effort/sSmall: expected under 2 hours of work
    area/infraInfrastructure, deployment, and operations
    area/nixNix expressions, flakes, and packaging
    meta/enrichedIntake review done: acceptance criteria, links, and normalized labels added
    on Oct 28, 2026
  4. dezren39 commented on Oct 28, 2026

    @dezren39
    dezren39
    on Oct 28, 2026
    MemberAuthor
    More actions

    Intake review

    🤖 Agent note · filed

    • Agent: fleet monitor
    • Session / ID: repo-fleet-monitor run 2026-10-28 09:19 CDT
    • Found via: monitor reconciliation
    • Task: Intake enrichment (§5): verified still live, appended acceptance criteria, normalized labels.
    • Expectation: effort/s — the guard script is built and fake-battery tested; the remaining work is the flake service + live verification in the issue's landing spec.
    • Links: PR nixos: power-guard — confirm critical battery readings before UPower hybrid-sleeps the laptop #1689 (OPEN at intake) — "nixos: power-guard — confirm critical battery readings before UPower hybrid-sleeps the laptop"

    Still live: no merged PR resolves this. PR #1689 is open and implements exactly this landing spec — the intake does not close the issue; the worker on #1689 owns the live-machine verification steps.

    Related: dezren39/darwin-nix#1020 (the SSH-unreachability tracker this incident fed — the 06:11–09:00 CDT outage was this hybrid-sleep, not an sshd failure); the fleet parked ~46 queue items on that outage.

    Risks / notes:

    • The guard runs as root and holds a systemd sleep inhibitor — a bug in the release path could block genuine critical-battery sleep. The body's fake-battery test covers the fire/no-fire edges; keep those assertions with the pinned script.
    • Suggested approach: land nixos: power-guard — confirm critical battery readings before UPower hybrid-sleeps the laptop #1689, then do the body's step-3 live verification (brief AC unplug above the critical line) in a window where a mistaken sleep costs least.
  5. dezren39 commented on Nov 2, 2026

    @dezren39
    dezren39
    on Nov 2, 2026
    MemberAuthor
    More actions

    Agent note — picked up (OpenChamber scheduled lane)

    • Agent: queue worker (`repo-worker-code`), lane `bf419306-c4ef-470f-a553-beabf93239de`
    • Session / ID: queue task 2624 (triage), claimed 2026-11-02T23:04Z
    • Found via: atomic queue claim in `repo-health-code-pilot`.
    • Next: verify power-guard: gate UPower's critical-power hybrid-sleep behind a sustained-reading confirmation (laptop slept 2h40m on a glitched battery reading, 2026-10-28) #1687 on current main — check PR nixos: power-guard — confirm critical battery readings before UPower hybrid-sleeps the laptop #1689 state, power-guard in flake, live service.
  6. dezren39
    added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed
    status/needs-triageNot yet triaged; needs a first look
    on Nov 2, 2026
  7. 41 remaining items

  8. dezren39
    added
    queue/blockedQueue or user escalation state
    status/blockedQueue or user escalation state
    and removed
    status/in-progressQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    on Nov 12, 2026
  9. dezren39 commented on Nov 12, 2026

    @dezren39
    dezren39
    on Nov 12, 2026
    MemberAuthor
    More actions

    🤖 Agent note · escalated

    • Agent: queue worker (repo-worker-code), lane code-i (OpenChamber scheduled lane)
    • Session / ID: task 11954 (queue repo-health-code-pilot)
    • Found via: OpenChamber scheduled lane claim
    • Task: Triage the remaining scope of power-guard: gate UPower's critical-power hybrid-sleep behind a sustained-reading confirmation (laptop slept 2h40m on a glitched battery reading, 2026-10-28) #1687 after PRs nixos: power-guard — confirm critical battery readings before UPower hybrid-sleeps the laptop #1689 and fix(power-guard): validate timing env overrides, add daemon tests (#6477) #6485.
    • Expectation: Both code changes are merged; only the physical acceptance test remains. No fix packet was created.
    • Links: issue power-guard: gate UPower's critical-power hybrid-sleep behind a sustained-reading confirmation (laptop slept 2h40m on a glitched battery reading, 2026-10-28) #1687 · PR nixos: power-guard — confirm critical battery readings before UPower hybrid-sleeps the laptop #1689 · PR fix(power-guard): validate timing env overrides, add daemon tests (#6477) #6485 · current main 338c6cf03facbdd91d2a5e2e5a738c69bf3231d0

    Revalidated both PRs as merged and issue #1687 as open. The remaining acceptance criterion is the controlled physical test: while on battery in the low-battery band but above the critical threshold, confirm power-guard acquires sleep:block and prevents sleep; reconnect AC and confirm the inhibitor releases. Existing issue notes say this was not performed. This requires Drew at the laptop; no code remainder or follow-up fix task is appropriate. Queue task 11954 is blocked until the test is performed and recorded.

  10. dezren39
    added
    queue/queuedHas a queued queue task
    and removed
    queue/blockedQueue or user escalation state
    status/blockedQueue or user escalation state
    on Nov 14, 2026
  11. dezren39 commented on Nov 14, 2026

    @dezren39
    dezren39
    on Nov 14, 2026
    MemberAuthor
    More actions

    Released to the queue under Drew's 2026-11-13 unblock-all order (main chat, 23:53 CT). Task(s) 11954 moved from blocked/parked to queued in the fleet unblock-all pass (worker main-unblock-all-2026-11-13). Dependency gates still recorded on a task remain recorded — the dependency checker will re-block it if a gate is genuinely unmet.

  12. dezren39 commented on Nov 14, 2026

    @dezren39
    dezren39
    on Nov 14, 2026
    MemberAuthor
    More actions

    Triage of the remainder — task 11954 (lane code-d, 2026-11-14)

    • state: triaged — the landing is verified complete except one physical test that is Drew's; the user/escalated label stands (accurately)
    • task: 11954
    • issue: power-guard: gate UPower's critical-power hybrid-sleep behind a sustained-reading confirmation (laptop slept 2h40m on a glitched battery reading, 2026-10-28) #1687 — OPEN

    Landing spec, verified item by item against live state today:

    1. ✅ Flake service + pinned script: nixos/services/power-guard/default.nix and nixos/services/power-guard/power-guard.py are on main, wired via nixos/hosts/default.nix (landed by PR nixos: power-guard — confirm critical battery readings before UPower hybrid-sleeps the laptop #1689, merged 2026-10-28).
    2. ✅ UPower config/thresholds unchanged — the guard gates the action; nothing in the landing touched UPower.
    3. ◐ Live verification: the service half is verified — power-guard.service is enabled and active (running) since 2026-11-13 19:29 CST on amd-6 (PID 1254). The remaining half — the brief AC-unplug test (expect the inhibit block to engage while discharging above the critical line, no sleep, release on replug) — has no evidence on this issue and is a physical step at the machine.
    4. ✅ Hand copy retired: ~/tools/power-guard.py on amd-6 is a 9-line pointer stub ("RETIRED 2026-11-02 (queue task 6597) — pointer only, not code"), pointing at the pinned repo source.

    Remainder (one item, Drew's): the 30-second AC-unplug test from step 3, or an explicit waiver of it. Everything else in the spec is landed and verified, so once Drew does or waives that test, #1687 can close. This matches why lane code-i escalated the issue on 2026-11-12; Drew's 2026-11-13 unblock-all returned the task to the queue, and this triage confirms no fleet-side work remains.

  13. dezren39 commented on Nov 14, 2026

    @dezren39
    dezren39
    on Nov 14, 2026
    MemberAuthor
    More actions

    Duplicate packet — task 17168 (lane code-d, 2026-11-14)

    • state: done (already_done) — this is a second queue task for the same power-guard: gate UPower's critical-power hybrid-sleep behind a sustained-reading confirmation (laptop slept 2h40m on a glitched battery reading, 2026-10-28) #1687 remainder triage
    • task: 17168
    • The triage was completed this shift as task 11954: full item-by-item verification is recorded in the note above (2026-11-14, comment 6882569194). Summary: the landing spec is verified complete (flake service live since 2026-11-13, script pinned by PR nixos: power-guard — confirm critical battery readings before UPower hybrid-sleeps the laptop #1689, hand copy retired 2026-11-02) except Drew's physical AC-unplug live test from step 3, or his waiver of it; user/escalated stands. No further fleet-side work exists for this packet.
  14. dezren39 commented on Nov 17, 2026

    @dezren39
    dezren39
    on Nov 17, 2026
    MemberAuthor
    More actions

    Agent note — state: triaged · task 18129, lane code-c

    • Picked up: bulk-intake triage task 18129 for issue power-guard: gate UPower's critical-power hybrid-sleep behind a sustained-reading confirmation (laptop slept 2h40m on a glitched battery reading, 2026-10-28) #1687, lane code-c, assignment direct.
    • Fresh verification this shift (2026-11-16): issue power-guard: gate UPower's critical-power hybrid-sleep behind a sustained-reading confirmation (laptop slept 2h40m on a glitched battery reading, 2026-10-28) #1687 is OPEN, no hard-stop labels (held / user/owned / do-not-merge / do-not-auto-edit); it carries user/escalated (a fleet escalation label, not a Drew hold) and no status/needs-triage — triage already happened.
    • Existing triage stands: task 11954 (lane code-d, 2026-11-14, comment 6882569194) verified the landing item by item — power-guard flake service and pinned script on main via PR nixos: power-guard — confirm critical battery readings before UPower hybrid-sleeps the laptop #1689 (merged 2026-10-28), service enabled and active on the laptop since 2026-11-13, UPower config untouched. A prior duplicate packet (task 17168) already completed on exactly this basis.
    • Sole remainder: the controlled physical AC-unplug/replug acceptance test on the laptop, or Drew waiving it. That is a physical action no fleet lane can perform remotely; the user/escalated label stands accurately.
    • Flag for the escalation record: the pending-questions ledger sets that carried the power-guard: gate UPower's critical-power hybrid-sleep behind a sustained-reading confirmation (laptop slept 2h40m on a glitched battery reading, 2026-10-28) #1687 steer question (blocked-review-drew-decision-03, blocked-steer-on-site-01) are currently marked dropped, not answered — the hourly-questions owner may want to re-raise the physical-test ask in a fresh set.
    • Outcome for task 18129: completed as triaged, naming the existing triage. No new follow-on packet — the remainder is the escalated physical test, not queue work.
  15. dezren39
    removed their assignment
    on Nov 20, 2026
  16. dezren39 commented on Nov 22, 2026

    @dezren39
    dezren39
    on Nov 22, 2026
    MemberAuthor
    More actions

    Owner-parks batch (#12234, 2026-11-22) — sharpened to a hands item (marker now in the body).

    Everything fleet-side is done and verified: the power-guard service and pinned script are on main via PR #1689 (merged 2026-10-28), enabled and active on the laptop since 2026-11-13, UPower config untouched. The sole remainder is the controlled physical acceptance test no lane can perform remotely: unplug the laptop's AC adapter, confirm power-guard prevents the hybrid-sleep on a glitch reading, replug — or reply "waive" here and the test is recorded as waived. Either outcome closes the acceptance; nothing else waits on it.

  17. developing-today-fleet commented on Nov 26, 2026

    @developing-today-fleet
    developing-today-fleetBot
    on Nov 26, 2026 – with developing.today fleet
    Contributor
    More actions

    Triage verdict — code-j, 2026-11-26 (queue task 24358)

    Fresh check: #1687 OPEN. Labels carry user/escalated (fleet escalation label, not a hold) — no hold labels (held / user/owned / do-not-auto-edit), so triage proceeds.

    • Fleet-side work verified done, re-confirmed this run: pinned script + NixOS service + tests present in-tree at nixos/services/power-guard/ (power-guard.py, default.nix, test_power_guard.py, wired in nixos/hosts/default.nix); live copy present at ~/tools/power-guard.py. Matches the item-by-item verifications in tasks 11954 / 17168 / 18129 (PR nixos: power-guard — confirm critical battery readings before UPower hybrid-sleeps the laptop #1689 merged 2026-10-28, service active on the laptop since 2026-11-13).
    • Sole remainder is a hands item (marker in body): the controlled physical acceptance test — unplug AC, confirm the guard blocks a glitch-triggered hybrid-sleep, replug — or a waive reply. Only a person's hands can do it; no lane can perform it remotely.

    Verdict: no new packet routed — nothing fleet-side remains to implement. Issue stays open on the hands item. No code changed in this pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/infraInfrastructure, deployment, and operationsarea/nixNix expressions, flakes, and packagingeffort/sSmall: expected under 2 hours of workkind/infrastructureInfrastructure / host-portability workmeta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/highImportant and time-sensitivequeue/queuedHas a queued queue tasksource/humanFiled directly by a humanuser/escalatedRequires a Drew decision or accesswork/assignedQueue worker lifecycle state

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.