Skip to content

fix: a deliberate no-op exits 0, not 1 - #12

Merged
phmatray merged 1 commit into
mainfrom
fix/a-deliberate-no-op-exits-zero
Sep 4, 2026
Merged

fix: a deliberate no-op exits 0, not 1#12
phmatray merged 1 commit into
mainfrom
fix/a-deliberate-no-op-exits-zero

Conversation

@phmatray

@phmatray phmatray commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

The bug

macarchy-auto-appearance and macarchy-bar-contrast each detect that their precondition is absent, say so, correctly decline to act — and then return 1.

macarchy-auto-appearance: macarchy-sun could not compute today's sun; theme left alone
macarchy-auto-appearance.service: Main process exited, code=exited, status=1/FAILURE

macarchy-bar-contrast: grim missing
macarchy-bar-contrast.service: Main process exited, code=exited, status=1/FAILURE

Both are timer-driven oneshots, so a non-zero exit parks them in systemctl --user --failed for ever and fires their OnFailure= notifier. They were two of the three units failing in macarchy/macarchy-install#9 — the journals are in that issue, printed by the dump that PR added.

Not a CI artifact. Boot a real laptop before grim is installed, or before coordinates are set, and the same two units go permanently failed.

The fix

auto-appearance"theme left alone" is a decision. And the script already uses exit 0 for the sibling decision two screens down:

*) exit 0 ;;  # user chose something else; leave it alone

The sun case now matches its own convention. A genuine failure still reds: the final exec omarchy theme set "$want_theme" propagates that command's status.

bar-contrast — a missing capture tool and an absent bar layer both mean there is nothing on screen to sample. A grim that exists and then breaks, or a sample that comes back malformed, still exits 1 — unchanged, and still pinned by the existing bad sample exits 1 case.

About the three tests I changed

They asserted the old behaviour, so they encoded the bug. Worth being explicit, since changing a test to match code is usually the wrong move:

The invariant those cases defend is "it must not GUESS a theme" — that is the does not switch assertion sitting beside each of them, and it is untouched. Only the exit-code half moved, and all three inputs (FAKE_SUN_FAIL, 'not json', '{"state":""}') reach the same "no answer, changed nothing" branch, so they move together.

The error stays legible where an error belongs: status still reports error=sun, and both messages still reach the journal.

Test

tests/test_auto_appearance.sh · tests/test_bar_contrast.sh — including a new case that a missing capture tool is a skip and leaves the config untouched. Full suite: 3 shell suites pass, 14 pytest cases pass, bash -n clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SYBhT1xfp3MQ1w3687F4Mp

macarchy-auto-appearance and macarchy-bar-contrast each detected that their
precondition was absent, said so, correctly declined to act -- and then returned
1. Both are timer-driven oneshots, so that parked them in `systemctl --user
--failed` for ever and fired their OnFailure= notifier, on every machine with no
coordinates set or no compositor installed. macarchy-install#9 carries the
journals; they were two of the three units that had been failing there.

This is not a CI artifact. Boot a real laptop before grim is installed, or
before coordinates are set, and the same two units go permanently failed.

auto-appearance: "macarchy-sun could not compute today's sun; theme left alone"
is a decision, and the script ALREADY uses exit 0 for the sibling decision two
screens down ("user chose something else; leave it alone"). The sun case now
matches its own convention. A genuine failure still reds: the final
`exec omarchy theme set` propagates that command's status.

bar-contrast: a missing capture tool and an absent bar layer both mean there is
nothing on screen to sample. A grim that EXISTS and then breaks, or a sample
that comes back malformed, still exits 1 -- that side is unchanged and still
pinned by the "bad sample exits 1" case.

Three test cases asserted the old behaviour and are updated with the reasoning,
because they encoded the bug: the invariant they defend is "it must not GUESS a
theme", which is the `does not switch` assertion beside each of them, and that
one is untouched. The error stays legible where an error belongs -- `status`
still reports `error=sun`, and both messages still reach the journal.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SYBhT1xfp3MQ1w3687F4Mp
@phmatray
phmatray merged commit 2099698 into main Sep 4, 2026
1 check passed
@phmatray
phmatray deleted the fix/a-deliberate-no-op-exits-zero branch September 4, 2026 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant