Skip to content

fix(control): keep recording a session's pull requests until D1 has them - #681

Merged
kalaspuff merged 3 commits into
mainfrom
fctl/1826-i-have-one-session-that-doesn-t-seem-to
Dec 4, 2026
Merged

kalaspuff merged 3 commits into
mainfrom
fctl/1826-i-have-one-session-that-doesn-t-seem-to

Conversation

@fctl-sh

@fctl-sh fctl-sh Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A session hears GitHub's news about a pull request (checks, state, conflicts, review findings, comments that mention @fctl) only once the pull request is recorded as the session's in D1 (pull_request_sessions). The session recorded each one only once, in a background task, when its agent first reported it. If that task failed (a D1 error) or was cut short (a deploy resets the session's object), the session kept listing the pull request but heard nothing of it, permanently: the hourly sweep looks up only the rows it already has. That fits a session whose pull request cards show no checks and whose review says "Its findings went to no session".

This makes the recording heal itself, in two layers:

  • The session retries. It keeps the pull requests it hasn't recorded yet, and its alarm records them and passes on their reviews' findings: at once, then a minute later, then waiting as long as it has already been trying, up to an hour between tries, for a day. A try counts only once both are done, and a try cut short is tried again, because the alarm for the next try is set before each try starts.
  • The hourly job repairs. It records the pull requests that sessions active in the last two weeks list but D1 doesn't, up to 200 a run, however old the session. Each must be neither merged nor closed, and its session neither archived nor a review agent's. This also covers sessions that already missed theirs before this change, and projects or workspaces that gain access to a repository only after their agent opened a pull request there.

Either way, the session then gets what it would have got at the start: the findings its reviews kept for it, a lookup of checks and state, and, where its project follows up on conflicts, word of them to its agent.

The new logic has unit tests, and the hourly job's query has tests against the D1 stand-in: what it records (an old session's new pull request included), and what it leaves out (merged pull requests, repositories out of reach, archived, quiet and review sessions, rows already recorded). cargo xtask check lint and the fctl-control and fctl-domain test suites pass. I couldn't run it end to end, as dev projects have no repository and open no pull requests.

Worth confirming

  • Decision: a pull request the hourly job repairs is treated as just found. So the first run after the deploy can bring agents back for review findings that went to no session, or for conflicts, on pull requests up to two weeks old that are still open.
  • Assumption: the session in the report lost its records to a failed or interrupted background write. That's the only path I found that would cut off one session and not the others, but I couldn't confirm it without production logs. Its pull requests should show their checks, and its review findings should reach its agent, after the first hourly run following the deploy.

fctl session


Note

Medium risk. It changes how a session's object records its pull requests in D1 and hands review findings to it, which webhooks, review findings and follow-ups depend on, though only the retry and repair paths are new.

What it does. A session that lists a pull request now keeps it in its own storage and retries from its alarm, with growing waits for up to a day, until D1 records it and the reviews' unsent findings have gone to the session. After a day, the hourly job repairs it, going by sessions.updated_at. reviews::listed now returns the first error of a failed send once it has tried every review, so a failed hand-over counts as an unfinished try.

Retry state in the session. A new unrecorded_pull_requests entry in each session's storage and a new step in the session's alarm; the hourly repair scans sessions by the unindexed updated_at.

fctl review's first look at 687f118 · 5 files, +607 −43 · Review agent settings

A session records each pull request its agent finds in D1's
pull_request_sessions, which GitHub's webhooks, review agents' findings and
follow-ups find sessions by. It did so once, in the background, as its agent
first reported the pull request: a D1 error or a deploy that cut it short
left the session listing the pull request while hearing nothing of it, for
good, as the hourly sweep looks up only the rows it has.

Now the session keeps the pull requests it hasn't recorded
(fctl_domain::pulls::Unrecorded) and its alarm records them, trying again a
minute later and then as long after as it has tried, up to an hour, for a
day. The hourly job records those that sessions of the last two weeks list
but D1 doesn't (pull_requests::heal), which also covers a project or
workspace that reaches a repository only later, and existing sessions that
missed theirs. Either way the session then gets what it would have: its
reviews' unsent findings, a lookup, and its agent word of conflicts.
@fctl-sh
fctl-sh Bot requested a review from kalaspuff as a code owner December 4, 2026 00:45
@fctl-review

This comment has been minimized.

Comment thread crates/fctl-control/src/do_session.rs Resolved
… recorded

From the review of #681: a session cleared what it hadn't recorded as soon
as the rows were in D1, though passing on its reviews' findings came after,
and nothing passed those on once the rows were there. It now counts a try
once both are done; a lookup that fails is left to the hourly job, which
looks up first the rows nobody has.

The hourly job also went by when sessions were created, so an older
session that found a pull request today, and couldn't record it for a day,
got no repair: it now goes by when sessions last changed.
@fctl-review

This comment has been minimized.

Comment thread crates/fctl-control/src/do_session.rs Resolved
… send

From the review of #681: reviews::listed logged a send that failed and
returned Ok, so the session counted its pull requests recorded and never
sent those findings. It now tries every review and then returns the first
error, and the session tries again; findings that went meanwhile don't go
twice, as sending claims them first.
@kalaspuff
kalaspuff merged commit 3180dc6 into main Dec 4, 2026
12 checks passed
@kalaspuff
kalaspuff deleted the fctl/1826-i-have-one-session-that-doesn-t-seem-to branch December 4, 2026 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant