Menu

#457 fix(worklog): anchor the coding wait to the hour's end, not to process start

closed
nobody
None
2026-07-17
2026-07-17
Anonymous
No

Originally created by: Akarsh-Hegde

What

await_coding_ready capped its wait with Instant::now() + CODING_MAX_WAIT — a process-relative deadline. Every daemon restart therefore restarts the 20-minute wait from zero, so a daemon that restarts more often than CODING_MAX_WAIT never reaches the cap and the hour is never processed at all.

This is now anchored to the hour's end in wall-clock: hour_end + CODING_MAX_WAIT against Utc::now(). The wait survives restarts, and an hour already past its cap (a backlog after downtime) proceeds best-effort immediately instead of buying a fresh 20 minutes on every attempt.

Why it matters

Observed live on this dev machine: cargo-watch restarting the daemon on every source save produced 13 restarts in ~5 minutes, exactly one distill, and the timeline frozen at noon for ~3 hours. A crash loop or a run of updates does the same in production. ledger.rs already documents the intended semantics — the aging escape fires "if an hour has been over for longer than the aging window" — i.e. anchored to the hour being over, not to when the daemon booted. This makes the code do what it already claims.

Scope (deliberately narrow)

  • Fixes the wait phase only. run_hour (distil + LLM calls) is still SIGKILLed by a restart mid-generation; surviving that is a separate concern.
  • A freshly-completed hour now waits until ~HH:20 rather than HH:03+20min — slightly shorter, and what the docstring always claimed.
  • A backlog after downtime proceeds without waiting — the documented aging-escape intent.
  • An unparseable hour bound escapes to Ready rather than stalling the hour, matching the module's existing "never block the worklog on a bad read" posture.

Tests

Three unit tests on the extracted pure coding_deadline(he): anchored-to-hour-end (and stable across calls), stale-hour deadline is already in the past, unparseable bound → None. cargo fmt, clippy -D warnings, and the full worklog_pipeline suite pass.

Note on target branch

Base is feat/llm-provider-connectivity-test per request, to land the fix in the branch the dev app currently builds. The fix is independent of the LLM-provider work; a sibling branch (fix/worklog-coding-wait-deadline) carries the same commit for a clean pre-main PR.

🤖 Generated with Claude Code

Related

Tickets: #454

Discussion

  • Anonymous

    Anonymous - 2026-07-17

    Originally posted by: coderabbitai[bot]

    [!IMPORTANT]

    Review skipped

    Auto reviews are disabled on base/target branches other than the default branch.

    Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.


    ⚙️ Run configuration

    Configuration used: Organization UI

    Review profile: ASSERTIVE

    Plan: Pro Plus

    Run ID: b918f0b6-ff67-4d8e-a2b4-a9be36544e6f

    You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

    Use the checkbox below for a quick retry:
    - [ ] 🔍 Trigger review

    ✨ Finishing Touches
    🧪 Generate unit tests (beta) - [ ] Create PR with unit tests - [ ] Commit unit tests in branch `fix/worklog-coding-deadline-on-llm`

    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.

    ❤️ Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

    Comment @coderabbitai help to get the list of available commands.

     
  • Anonymous

    Anonymous - 2026-07-17

    Ticket changed by: Akarsh-Hegde

    • status: open --> closed
     

Log in to post a comment.