fix(daemon): lease a forge turn for an hour, not ten minutes #5

Merged
vhaudiquet merged 1 commits from kosmos/rhema-claw:fix/forge-lease-ttl into main 2026-11-22 01:27:14 +00:00
Collaborator

A forge turn is being killed at ten minutes, every time, silently.

What happens

Observed on vhaudiquet/orcaslicer-snap#10 (the v2.5.1 build failure):

  • lease 1 granted 00:22:54, lease 2 granted 00:35:03 — each turn died exactly 600s after its grant, and the key came back up with last_outcome: null, revision bumped, inbox empty.
  • No failure anywhere: not in the log, not on the thread. From the dispatcher's point of view the key simply went idle.

The investigation itself was fine — it had cloned the repo, diffed OrcaSlicer 2.5.0 against 2.5.1, found that upstream replaced its vendored expat with find_package(EXPAT 2.10.0 REQUIRED) and written a fix — it just never got to finish it.

Why

Daemon::build's forge dispatcher was assembled on DispatcherConfig::default(). That default is rhema-rsd's, not ours: lease_ttl_millis: 600_000, documented as "the spec's example values" — sized for a single agent step, not a turn that clones a repo and builds a slicer.

Nothing renews the lease once the turn is under way:

  • SessionContext::poll_inbox renews, and the handler calls it once, at the start of the run (drain_news);
  • the commit hook that runs before every tool call checkpoints — which fails on a lapsed lease rather than extending a live one.

So the TTL is a hard ceiling on the whole turn, and crossing it is invisible by construction: the turn dies on its next tool call, and then Driver::drive's own checkpoint (and release) return Expired, which leaves no last_outcome behind. The interactive and jobs lanes never had this problem — they hardcode 3_600_000.

The change

forge_dispatch(): the library defaults with lease_ttl_millis: 3_600_000, the same hour the other two lanes lease for. Used by the resident loop and by --once (which took the same default, only with the debounce zeroed). A test pins the TTL and asserts the rest of the knobs still come from the library, so a future default change still reaches us.

Deliberately not in this PR

An hour is a longer ceiling, not no ceiling — a turn that runs longer still dies this way, and the lapse still records no outcome. A real heartbeat needs rhema-rsd to expose a renew without draining the inbox (poll_inbox is renew-and-drain, so calling it mid-turn would steal the run's own events). Worth an upstream issue; not a blocker here.

There is also a second, unrelated stall: Daemon::tick awaits forge_driver.run_once(), so a long turn starves detection — forge polls, task ticks, calendar reminders and phone delivery all wait behind it. Raising the TTL makes that window longer, so it should be fixed next; it is a separate change and a separate PR.

Tests

bin/gate.sh is green locally (fmt, clippy -D warnings, check — all targets). This box cannot execute test binaries, so the new unit test first runs in CI.

A forge turn is being killed at ten minutes, every time, silently. ## What happens Observed on `vhaudiquet/orcaslicer-snap#10` (the v2.5.1 build failure): - lease 1 granted 00:22:54, lease 2 granted 00:35:03 — each turn died exactly 600s after its grant, and the key came back up with `last_outcome: null`, `revision` bumped, `inbox` empty. - No failure anywhere: not in the log, not on the thread. From the dispatcher's point of view the key simply went idle. The investigation itself was fine — it had cloned the repo, diffed OrcaSlicer 2.5.0 against 2.5.1, found that upstream replaced its vendored expat with `find_package(EXPAT 2.10.0 REQUIRED)` and written a fix — it just never got to finish it. ## Why `Daemon::build`'s forge dispatcher was assembled on `DispatcherConfig::default()`. That default is **`rhema-rsd`'s**, not ours: `lease_ttl_millis: 600_000`, documented as "the spec's example values" — sized for a single agent step, not a turn that clones a repo and builds a slicer. Nothing renews the lease once the turn is under way: - `SessionContext::poll_inbox` renews, and the handler calls it **once**, at the start of the run (`drain_news`); - the commit hook that runs before every tool call *checkpoints* — which fails on a lapsed lease rather than extending a live one. So the TTL is a hard ceiling on the whole turn, and crossing it is invisible by construction: the turn dies on its next tool call, and then `Driver::drive`'s own `checkpoint` (and `release`) return `Expired`, which leaves no `last_outcome` behind. The interactive and jobs lanes never had this problem — they hardcode `3_600_000`. ## The change `forge_dispatch()`: the library defaults with `lease_ttl_millis: 3_600_000`, the same hour the other two lanes lease for. Used by the resident loop and by `--once` (which took the same default, only with the debounce zeroed). A test pins the TTL and asserts the rest of the knobs still come from the library, so a future default change still reaches us. ## Deliberately not in this PR An hour is a longer ceiling, not no ceiling — a turn that runs longer still dies this way, and the lapse still records no outcome. A real heartbeat needs `rhema-rsd` to expose a renew without draining the inbox (`poll_inbox` is renew-and-drain, so calling it mid-turn would steal the run's own events). Worth an upstream issue; not a blocker here. There is also a second, unrelated stall: `Daemon::tick` awaits `forge_driver.run_once()`, so a long turn starves detection — forge polls, task ticks, calendar reminders and phone delivery all wait behind it. Raising the TTL makes that window *longer*, so it should be fixed next; it is a separate change and a separate PR. ## Tests `bin/gate.sh` is green locally (fmt, clippy `-D warnings`, check — all targets). This box cannot execute test binaries, so the new unit test first runs in CI.
kosmos added 1 commit 2026-11-22 01:14:54 +00:00
fix(daemon): lease a forge turn for an hour, not ten minutes
android / release (pull_request) Skipped
android / debug (pull_request) Successful in 3m48s
ci / checks (pull_request) Successful in 1m3s
ci / test (pull_request) Successful in 39s
ci / chart (pull_request) Successful in 5s
ci / docker (pull_request) Successful in 1m30s
ci / web (pull_request) Successful in 13s
ci / publish-edge-images (deploy/docker/claw.Dockerfile, rhema-claw) (pull_request) Skipped
ci / publish-edge-images (deploy/docker/ui.Dockerfile, rhema-claw-ui) (pull_request) Skipped
ci / publish-edge-chart (pull_request) Skipped
android / debug (push) Successful in 2m13s
android / release (push) Successful in 2m4s
ci / checks (push) Successful in 1m4s
ci / test (push) Successful in 44s
ci / chart (push) Successful in 6s
ci / docker (push) Successful in 1m30s
ci / web (push) Successful in 13s
ci / publish-edge-images (deploy/docker/claw.Dockerfile, rhema-claw) (push) Successful in 1m33s
ci / publish-edge-images (deploy/docker/ui.Dockerfile, rhema-claw-ui) (push) Successful in 9s
ci / publish-edge-chart (push) Successful in 3s
78fdec4f49
The forge dispatcher was assembled on `DispatcherConfig::default()`,
whose ten-minute lease TTL is the spec's example value, sized for a
single agent step. A forge turn is not a step: it clones the repo, reads
it, and may build and test a fix. Nothing renews the lease once the turn
is under way — `poll_inbox` renews but is called once, at the start, and
the commit hook between tool calls checkpoints, which fails on a lapsed
lease rather than extending it — so the TTL is a hard ceiling on a whole
turn.

Crossing it is silent: the turn dies on its next tool call, the driver's
own checkpoint and release then report `Expired`, and the key ends with
no outcome recorded, indistinguishable from a pass that found nothing.

Give the forge lane its own timing — the library defaults with an
hour-long TTL, the same choice the interactive and jobs lanes already
make — and use it in both shapes (`--once` included).
kosmos force-pushed fix/forge-lease-ttl from c859df292d to 78fdec4f49 2026-11-22 01:14:54 +00:00 Compare
vhaudiquet merged commit 78fdec4f49 into main 2026-11-22 01:27:14 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vhaudiquet/rhema-claw#5