testsAndMisc/docs/superpowers/evidence/night-lockdown-wake-fixes-2026-07-18.json
Krzysztof kuhy Rudnicki e393207e3a fix(night-lockdown): close console-blank gap, recover DP link, floor wake alarm
The 23:00 lockdown -> 05:00 unlock cycle exposed three live bugs: a visible
console-text flash before the screen went black (blank_console only ran once
systemctl stop lightdm.service fully returned, leaving a gap), DP-0 needing a
manual xrandr/replug after wake, and the morning alarm firing only 6h after a
late lockdown entry instead of waiting a full 8h.

- Blank the console continuously in a background poller for the whole GUI
  teardown instead of a single after-the-fact call.
- Retry autorandr --change against a saved profile after lightdm restarts.
- Stamp lockdown-entry time and gate the alarm on entry + 8h, decoupled from
  the console/GUI-restore idempotency so it can fire on a later staggered
  trigger instead of only the first one.
- Add DRY_RUN NOTE banners so a clean dry run is never mistaken for proof the
  console-blank and autorandr fixes work for real (they need a live cycle).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S4YWZhDcEUMUi8cyw9AzTR
2026-07-18 06:44:17 +02:00

50 lines
4.4 KiB
JSON

{
"intent": "Fix three live night-lockdown/wake bugs: (1) console briefly showed old kernel/systemd text instead of going black, (2) DP-0 did not reliably reconnect after wake, (3) the morning wake alarm could fire less than 8h after a late lockdown entry (23:00 lockdown -> 05:00 alarm).",
"scope": [
"linux_configuration/scripts/periodic_background/digital_wellbeing/setup_night_lockdown.sh",
"Deployed artifacts: /usr/local/bin/night-lockdown-{enter,unlock}.sh, /etc/night-lockdown.conf",
"One-time manual action: autorandr --save default (outside the script)",
"Non-goal: did not redesign the VT-blank approach to an X-stays-alive black overlay (deferred fallback if this smaller fix doesn't hold)"
],
"changes": [
"Enter script: blank the console in a background poller for the full duration of 'systemctl stop lightdm.service' (plus a final guaranteed blank after), instead of a single blank call only once stop returns, closing the visible-text gap.",
"Enter script: stamp $STATE_DIR/locked_at_epoch when entering lockdown.",
"Unlock script: add step 2a — retry 'autorandr --change --default default' for up to 15s as the desktop user after lightdm restarts, to recover a DisplayPort link that didn't re-enumerate cleanly.",
"Unlock script: decouple maybe_start_morning_alarm() from the LOCKED/UNLOCKED idempotency gate (now also called from the already-UNLOCKED early-exit branch) so it can fire on a later staggered trigger (05:15/05:30/06:00/07:00) instead of only the first one.",
"maybe_start_morning_alarm(): add MIN_WAKE_AFTER_LOCKDOWN_HOURS (default 8) floor check against locked_at_epoch, and its own alarm_started_date daily dedup marker.",
"New config vars in /etc/night-lockdown.conf: MIN_WAKE_AFTER_LOCKDOWN_HOURS=8, AUTORANDR_PROFILE=default.",
"Added explicit DRY_RUN NOTE banners to both scripts stating DRY_RUN cannot validate the console-blank timing race or the autorandr reconnect (pure log-only mode), so a clean dry run is never mistaken for proof those specific fixes work."
],
"verification": [
{
"command": "bash -n setup_night_lockdown.sh; shellcheck -s bash setup_night_lockdown.sh (plus extracted enter/unlock heredoc bodies)",
"result": "pass",
"evidence": "Only pre-existing SC1091 info notice (unrelated source of ../../lib/common.sh); no new warnings."
},
{
"command": "sudo setup_night_lockdown.sh setup",
"result": "pass",
"evidence": "Redeployed /usr/local/bin/night-lockdown-{enter,unlock}.sh and /etc/night-lockdown.conf; verification block reported all files present and timer enabled."
},
{
"command": "sudo DRY_RUN=1 night-lockdown-enter.sh / night-lockdown-unlock.sh, with locked_at_epoch temporarily set to 0h-ago and 9h-ago",
"result": "pass",
"evidence": "0h-ago logged 'too soon since lockdown entry (480m remaining) - skipping alarm this trigger'; 9h-ago proceeded to 'would wait for graphical session then start morning-routine.service'. Real STATE_FILE untouched under DRY_RUN and restored from backup after manual LOCKED-state tests."
},
{
"command": "autorandr --save default; autorandr --change --default default",
"result": "pass",
"evidence": "Saved profile matches current live DP-0 (3840x2160 primary) + HDMI-0 (2560x1440) layout; reapplication reports 'default (detected) (current)'."
}
],
"risks": [
"Real-world effectiveness of the console-blank poller and the autorandr reconnect is NOT yet confirmed by a live (non-DRY_RUN) cycle -- user declined a live disruptive test during this session; verification deferred to tonight's real 23:00->05:00 cycle, to be checked via journalctl the next morning.",
"autorandr recovery depends on the one-time saved profile staying valid; if the monitor arrangement changes, the profile must be re-saved or the unlock step will WARN and require manual xrandr.",
"If the console-blank timing race turns out not to be fully fixed by reordering/hardening, the user has already agreed the fallback is a bigger redesign (X-stays-alive black overlay) rather than further patching this approach."
],
"rollback": [
"git revert this commit and re-run 'sudo setup_night_lockdown.sh setup' to redeploy the prior script version.",
"After rollback, confirm /etc/night-lockdown.conf no longer references MIN_WAKE_AFTER_LOCKDOWN_HOURS/AUTORANDR_PROFILE and that a lockdown/unlock cycle still completes without error."
]
}