Repository navigation
feat(pm-console): report a unit that keeps failing on its timer, once, and its mending - #12719
Conversation
…, and its mending On 2026-11-22 pm-git-sync failed every 30 seconds for two hours and the only record was the journal. The notifier reported a failed unit the first time it saw one, which for a unit on a timer is either noise (one bad run the next run mends) or, once it had been seen, silence for as long as it went on being caught between "failed" and "starting". A service with a timer of the same name is now reported once it has failed run after run for five minutes, with what the unit is for, and again when it is seen well. Being caught mid-run is neither. Services that stay up are reported at once, as before. Six planted faults in the new logic are each caught. Refs #12520. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YLT5K1QVuzZjfWGFhXSSNF
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 52 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0521a095f9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const sustained = at - entry.since >= SUSTAINED_MS; | ||
| if (!entry.told && (!onTimer(u.unit) || sustained)) { |
There was a problem hiding this comment.
Reevaluate pending failures on unchanged host reports
On the edge, a timer service that consistently reports failed can remain unreported indefinitely. EdgeLink.once() sends section payloads only when their hashes change (src/sync.ts), and the edge sync handler invokes notifier.tick() only when a watched payload changes (edge/src/edge.ts:665–666). Consequently, the first failed snapshot starts this five-minute window, but subsequent identical snapshots never reevaluate it unless another watched section changes or a user action triggers the notifier. The edge has no periodic notifier loop, and its alarm only handles host silence. Reevaluate pending episodes on fresh host confirmations even when their content is unchanged.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Real: a unit that stays failed reads the same in every report, so at the edge the five minutes never elapsed. Fixed in the next commit: while a unit's failing is being timed (Notifier.pending()), the edge runs the notifier on every report, changed or not. New edge test: the unit goes failed, eleven identical reports follow, nothing is sent at four and a half minutes, one message after five, none after that, and one more when it mends. Reverting the condition fails that test.
Generated by Claude Code
| await this.docs.touch(WATCHED.filter((n) => !skip.includes(n))); | ||
| const now = Object.fromEntries(WATCHED.map((n) => [n, this.docs.good(n)])) as State; | ||
| const { messages, seen } = changes(await this.load(), now); | ||
| const { messages, seen } = changes(await this.load(), now, this.now()); |
There was a problem hiding this comment.
Check service freshness before advancing failure duration
If one timer failure is observed and subsequent service reads fail, the local notifier can still announce sustained failure five minutes later without another successful observation. Docs.refresh() retains the previous data on errors, and Docs.good("services") returns that cached snapshot, so this call repeatedly evaluates the original failure against the current wall clock. The new services: null test does not exercise this production path because failed refreshes do not return null after an initial successful read. Carry service-read health and timestamps into the comparison so stale snapshots cannot establish sustained failure.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Real, and the services: null test did not reach it, as you say. Fixed in the next commit: the time is no longer the clock but when the unit list was last actually read (Docs.goodAt), so a list that has stopped being read cannot age a failure. And after a gap longer than the wait itself the count starts again from the next sighting, since nothing is known of what the unit did in between. New test at the Notifier level with the real Docs: one failed run is seen, the list is unreadable for half an hour (nothing sent), reads resume and it is reported after five observed minutes. Planted faults for clock-based time, for counting across a gap, and for ignoring a mid-run sighting are each caught.
Generated by Claude Code
…unting at the edge Two review findings on the sustained-failure report: - At the edge the notifier only ran when a watched section changed, and a unit that stays failed reads the same in every report, so the five minutes never elapsed. While a unit's failing is being timed, the edge now looks again on every report. - On the laptop, a list of units that could no longer be read kept its last copy, and the old failure in it was timed against the clock. How long a unit has been failing is now counted between readings, from the time the list was last actually read; and after a gap longer than the wait itself the count starts again, since nothing is known of what happened in between. Four planted faults in these fixes are each caught. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YLT5K1QVuzZjfWGFhXSSNF
Why
On 2026-11-22
pm-git-syncfailed every 30 seconds for two hours, the laptop deployed nothing that was merged, and the only record was the journal (#12520, second part).pm-git-sync.serviceand its timer are in the console's unit list (pm-*), so the notifier could see it. What it did with a unit on a timer was wrong both ways: it reported the first failed run it happened to see, which is noise when the next run mends it, and after that said nothing for as long as the unit went on being caught between "failed" and "starting".What changes
Checks
bun test: 144 pass. The new test walks one bad run, a mended run, sustained failure through mid-run sightings, the single report, the single recovery, a second episode, services without a timer, a timer with another name, an older kept state, a unit that leaves the list, and a pass where the services could not be read.Not checked
systemctl --user list-unitsgives for a oneshot on a timer.Refs #12520.
Generated by Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.