Skip to content

feat(reconcile): record the first end of each closed PR - #92

Merged
tbhb-agent merged 1 commit into
mainfrom
agent/gm-rec-e2-sonnet
Nov 23, 2026
Merged

tbhb-agent merged 1 commit into
mainfrom
agent/gm-rec-e2-sonnet

Conversation

@tbhb-agent

Copy link
Copy Markdown
Collaborator

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 closed event gives the first end time. The state is merged when a merged event shares that time, otherwise closed. An unmerged close now records as ended only.

When the events run past three pages or lack a closed event, 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

Run takes an EndReader, and Lister provides 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.

RunResult gains ended outcome counts and an ambiguous count. Event pages count in Pages.

Run now passes the item body to RecordClosed, 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

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
tbhb-agent merged commit 5348ca7 into main Nov 23, 2026
8 checks passed
@tbhb-agent
tbhb-agent deleted the agent/gm-rec-e2-sonnet branch November 23, 2026 12:08
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant