Flow
How I want my backfill to change
1Label each value
Store how the commit was found and when.
2Blank seed commits
Leave the commit empty when the upload can’t know it.
3Look back in time
Use the commit from when the session ended, when the host allows it.
4Remember failures
Stop retrying sessions that can never be fixed.
5Read every page
Don’t stop at the first page of branches.
Where each session's branch points today is what the new backfill uses to fill in a commit for old coding sessions. That's the wrong question, and I shipped it.
I log my coding-agent sessions so I can link them to errors my error tracker catches. Each session should know its branch, its commit, and its repository. Lots of old ones only know the branch. So the sync button now runs a job that fills in the rest.
Where today's commit comes from
It finds sessions with a branch but no commit or no repository. It matches each one's remote URL to a repository I've registered. That part works. Then it asks the code host for a page of branches and their current commits, and writes that onto the old sessions.
Today's answer to an old question
The commit field is meant to say which commit the session was working from. The job can only say which commit the branch points at now. If the branch kept moving after the session, those differ. A session from early in a long branch gets the branch's last commit.
There are other ways the same field gets filled. A session that arrives with a branch but no commit gets the branch's current commit from the server, which is close enough when it's fresh. If that branch is gone, the server takes the most recently updated closed pull request from a branch with that name and, if it was merged, uses its merge commit, which didn't exist yet during the session. And none of these values are labeled, so nobody reading the data can tell them apart.
The seed command
The command that uploads old sessions used to leave branch and commit blank on purpose. This change made it fill them from my local clone, as it is today. If the old branch is gone, it uses whatever I have checked out. As I read the guard on that, it only catches me being on the main branch. On any other branch, an old session can get today's unrelated commit.
Why stricter matching raises the stakes
Linking a session to an error got stricter in the same change. It used to match if one commit was a prefix of the other, so an empty value matched everything. Now the two must be full-length and equal. That's correct, but it means a wrong commit now gives a confident wrong answer.
A queue that clogs
Recent sessions that can never be fixed get picked first on every run, so they can crowd out older ones that could be. The job reads only one page of branches. Two runs close together can redo the same work. And nothing in this change tests it.
Saying how each commit was found
If you're building something similar, record how each value was found.
Each row stores the commit, how it was found, and when it was resolved.
Then I'd do four things, starting with the seed command:
- make the seed command leave the commit blank when it can't know
- look up the commit as of when the session ended, when the code host allows it
- remember sessions that failed so they stop clogging the front of the queue
- read every page of branches