Repository navigation
feat(reconcile): record the first end of each closed PR - #92
Merged
Merged
Conversation
A repair now reads the issue events of every closed item and records the ended milestone at the earliest close, with state merged when a merged event shares its time. Events past three pages, or with no close, leave ended unclaimed and count as ambiguous. A recording or events read error clears the repository's first-page tag and leaves its watermark where it was. Generated-by: LLM effort=high;harness=claude-code:2.1.330;model=anthropic:claude-sonnet-5-5;session=sha-256-64:dd3f70854f2fb413;surface=sdk-cli
tbhb-agent
added a commit
that referenced
this pull request
Nov 23, 2026
Why Main failed its lint check at 5348ca7. #91 built a `RunResult` literal in its loop test. #92 then added five fields to that type. Each PR passed alone, and the merged result broke the `exhaustruct` lint rule at `internal/reconcile/loop_test.go:137`. Behavior change None. The change only lists the five new fields, each set to zero, in one test literal. Decisions The fields stay at zero, which matches what the test built before. The test reads only the merge counts and the result. Deviations from the task None. Needs human judgment None. Risk The change touches one test line and no production code. Verification `bazelisk test //:golangci_lint_test //internal/reconcile/...` passes both targets locally. Human steering None. Generated-by: LLM effort=medium;harness=claude-code:2.1.330;model=anthropic:claude-sonnet-5-5;session=sha-256-64:6507fa80a17e0653;started_at=2026-11-15T17:24:44Z;surface=cli
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The reconciler pass from #90 repairs the merge count only. When a webhook goes missing, a pull request that closed without a merge, or that someone reopened and closed again, loses its ended count. This change reads the issue events to find each first end and records the ended count as well.
Behavior change
For each closed item the pass reads up to three pages of issue events. The earliest
closedevent gives the first end time. The state ismergedwhen amergedevent shares that time, otherwiseclosed. An unmerged close now records as ended only.When the events run past three pages or lack a
closedevent, the pass records the merge and leaves the ended count unclaimed. It counts the item as ambiguous.When recording fails after a clean walk, the pass clears the repository's first-page tag and keeps its watermark. The next pass then reads the page in full instead of getting a 304. An events read error follows the same rule and ends the repository's items for that pass. This closes D-90a.
Decisions
Runtakes anEndReader, andListerprovides it. The reader clears each events page tag before it fetches, because the client would answer 304 with an empty body for a URL it saw before.RunResultgains ended outcome counts and an ambiguous count. Event pages count inPages.Runnow passes the item body toRecordClosed, because the cycle time starts from it.Deviations from the task
The design says to read events only for items that would record an ended count. This change reads them for every closed item, including items that come back as too old or before the floor. A gate needs a ledger read before the call. That adds one events request per closed item in a walk. The debt row D-91b tracks a later fix.
Needs human judgment
Whether D-91b needs a fix before the scheduler goes live, given the request budget.
Risk
The pass has no caller until the wiring change, so this change doesn't alter a running service. The events requests use the incremental budget priority, so a sweep or a webhook retry can still take precedence.
Verification
bazelisk test //...passes 32 tests with the macOS-only deploy test failing as before. The size check shows 400 of 400 code lines.Human steering
None.
Opened-by: LLM effort=medium;harness=claude-code:2.1.330;model=anthropic:claude-sonnet-5-5;session=sha-256-64:6507fa80a17e0653;surface=cli
Generated-by: LLM effort=high;harness=claude-code:2.1.330;model=anthropic:claude-sonnet-5-5;session=sha-256-64:dd3f70854f2fb413;surface=sdk-cli
Assisted-by: LLM effort=medium;harness=claude-code:2.1.330;model=anthropic:claude-sonnet-5-5;session=sha-256-64:6507fa80a17e0653;surface=cli