Skip to content

fix(notification): bound omarchy-notification-wait by wall clock - #8872

Open
MeGaurav4 wants to merge 1 commit into
omacom:quattrofrom
MeGaurav4:fix/8870-notification-wait-wall-clock
Open

MeGaurav4 wants to merge 1 commit into
omacom:quattrofrom
MeGaurav4:fix/8870-notification-wait-wall-clock

Conversation

@MeGaurav4

Copy link
Copy Markdown

Closes #8870

I noticed omarchy-notification-wait says its argument is
[timeout-seconds] but it actually uses timeout*10 attempts with
sleep 0.1. Each attempt also costs the omarchy-shell IPC timeout
(2s), so omarchy-notification-wait 10 was really blocking
omarchy-crash-watch for 3.5 minutes and then silently dropping the
crash. I fixed the helper to bound by wall clock (SECONDS +
timeout) so the budget finally means what it says.

I saw your suggested fix 1 for the caller at
bin/omarchy-crash-watch:33 to log the drop, but I am leaving that
for maintainers to decide, and I can do it too so lmk if you want
me to add it.

The helper documented its argument as [timeout-seconds] but used it
as an attempt count (timeout*10) with sleep 0.1, so each attempt
costs omarchy-shell IPC 2s + 0.1s = 21x longer than documented.
omarchy-notification-wait 10 blocks omarchy-crash-watch for 3.5 min
then silently drops the crash.

Bound the wait by SECONDS + timeout so the budget means what it says.

Closes omacom#8870

Signed-off-by: MeGaurav4 <gaurav3.141592@gmail.com>
Copilot AI balanced review requested due to automatic review settings August 29, 2026 05:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed on a disposable VM against head 965e4f1.

The bug reproduces exactly as #8870 describes. Against a stub qs that accepts and never answers, the base branch takes 21s for omarchy-notification-wait 1 and 210s for the default — the reporter's measurements, confirmed independently on a clean worker. Worth being precise about the mechanism, because the issue title makes it sound like a units error: the sleep 0.1 is correctly paired with timeout * 10, so the sleep arithmetic alone is exact. The overshoot is that each iteration also pays omarchy-shell's IPC timeout (bin/omarchy-shell:58, 2s), making the real cost timeout * 10 * (2s + 0.1s) — a ~21x multiplier.

The fix is correct. Measured on the same worker with the same stub: 1 → 2s, 3 → 4s, no argument → 11s, all exiting 1. The bound is now timeout plus at most one in-flight probe — O(timeout + probe) instead of O(timeout × probe). Edge cases behave: 0 and -1 skip the loop and exit 1 immediately, an absent argument still defaults to 10, and a non-numeric argument aborts under set -u at line 10 exactly as the old arithmetic did at line 21, so that is unchanged rather than a new failure mode.

No caller-contract break. Exit 0 on ready, exit 1 on timeout, nothing on stdout — all as before, so bin/omarchy-crash-watch:33, bin/omarchy-migrate-notify:33 and bin/omarchy-provision-first-run:87 are unaffected. test/shell.d/crash-capture-test.sh, migrate-notify-test.sh and restart-shell-test.sh all pass on the worker (48 assertions).

Two things worth knowing, neither of them introduced by this PR:

  • No regression test. The existing caller tests stub the helper out entirely (test/shell.d/migrate-notify-test.sh:29, crash-capture-test.sh:79), so nothing in the suite would catch a return to attempt-count timing. A test driving the real helper with a deliberately slow failing probe would pin it.
  • busctl is still unbounded. notification_server_ready (line 12) calls busctl with no --timeout, and sd-bus defaults to 25s. In the case where the shell ping succeeds but the notification bus name is not yet claimed, one probe can overshoot the deadline by roughly that much. Pre-existing and outside what omarchy-notification-wait treats its timeout argument as an attempt count: a crash can block the watcher for 3.5 minutes and then be dropped with no trace #8870 asks for, but it means this bounds when new probes start, not end-to-end wall clock.

Reviewed by Claude Opus 5 in Claude Code, with an independent second opinion from Codex at xhigh reasoning. Codex agreed the fix is correct and found no medium or high severity defect; its independence is not currently guaranteed, so that agreement is worth less than the two mechanisms it added that I had not reasoned about — the busctl 25s default above, and that bash's SECONDS follows the system clock rather than a monotonic one, so a backward clock step extends the wait (true of any SECONDS-based deadline, and of #8881 equally).

Heads up that #8881 also fixes #8870, with a wider change that additionally touches bin/omarchy-crash-watch. Both are sound on the part they share. Which one to take is @dhh's call — nothing in this comment is a request for changes, and I have not touched either branch.

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

Labels

bug Something isn't working

Projects

None yet

3 participants