Repository navigation
feat(recorder): claim each PR milestone once - #85
Merged
Merged
Conversation
Add ClosedPR and RecordClosed, which apply the 24-hour, store creation and repair floor rules and claim each milestone through a Ledger before it counts. The webhook Record reads pull_request.node_id and claims before any other Add, and a closed body with no node_id counts as a drop with reason no_node_id. recorder.New now takes the ledger. main passes the store as the ledger and reads the repair floor at every start, which stamps the floor and applies a reset flag. Generated-by: LLM effort=high;harness=claude-code:2.1.330;model=anthropic:claude-sonnet-5-5;session=sha-256-64:af415c6f0d052b90;surface=sdk-cli
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
tbhb-agent
force-pushed
the
agent/gm-rec-b-sonnet
branch
from
November 23, 2026 07:28
130400e to
370653b
Compare
…n the store 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 design (#82, PR B of its split) needs one shared rule for counting a merge and a first end, so a webhook and a later repair never count the same pull request twice. This PR adds the webhook half of that rule and wires the store from #84 into the service.
Behavior change
A closed pull request webhook now claims its merge and its first end in the store before it counts them. A redelivery doesn't count a second time. A closed body with no
node_idis a drop with reasonno_node_id. When a webhook reports a reopen of a PR created before the store existed, the recorder claims the first end without counting it, and a later merge leaves cycle time alone for a first close that an earlier version may already have counted. A reopen of a newer PR claims nothing, because this version counts that first close in any delivery order.recorder.Newrefuses a nil ledger.Decisions
RecordClosedtakes aClosedPRthat holds the first end's time and state together, so a close followed by a reopen and merge still records cycle time with stateclosed. Each milestone claims before it counts. A claim error skips the count and returns the error. The caller retries. A milestone older than 24 hours, or no later than the store's creation time, claims without counting. PR F takes the repair floor and the repair path, because that PR adds the first repair caller.Deviations from the task
The brief had the run leave main's wiring for later, since #84 hadn't merged. It merged first, so main passes the store in this PR. Review round 8 found two blocks. This PR fixes the reopen block. The second block belongs to the repair floor code, which moved to PR F to keep this PR under 400 lines. PR F must read the floor at every start and must not claim a merge at or before it.
Needs human judgment
The round 10 review ruling leaves two gaps as tech debt. A PR closed before the deploy and reopened after can count a second cycle time. A late first close after a reopen and a merge loses its observation. The repair floor PR must limit the reopen claim by that floor.
Risk
Medium. The change alters when closed pull requests count, and a wrong claim loses a count or doubles one. The tests cover each outcome. The diff is 396 of 400 code lines.
Verification
bazelisk test //... bazelisk run @tbhb_rules//lint:pr_size -- origin/main HEADThe local run passes but for
//deploy:deploy_test, which fails on macOS only. The tests cover a first claim, a second delivery, age and creation-time cutoffs, a claim error, claim order, a missingnode_id, the first end after a reopen, and plus a reopen that arrives before or after the first close. A Claude session read the recorder diff before opening the PR. A Sonnet 5.5 run wrote the code.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:af415c6f0d052b90;surface=sdk-cli
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