Repository navigation
511: date Bitbucket declines from the activity log - #527
Conversation
A declined Bitbucket PR had no terminal time, so it sorted after every dated archive row. The existing bounded, cached activity read that dates a Bitbucket merge now also dates a decline: ClosedAt is the update that entered the current DECLINED state (earliest of the trailing DECLINED run by event date). A later reopen, an undated state update or an unavailable read leaves it unknown; updated_on never stands in and archive eligibility (ClosedOn) is unchanged. Refs #511
A decline, unlike a merge, is not persisted and can be reopened. Its activity log is now keyed by the PR's updated_on, which any reopen or re-decline changes, and a log cached under that key is reused at any age. With a known twg credential that bounds reads to one per updated_on; under a twg profile the cache is operation-private, so a declined PR costs one activity read per status run (pinned by a collector regression against a merged PR's single read). bb pr activity stops at its default page limit and its JSON does not say whether it did, so a decline stays unknown under bb and costs no read. A full 200-entry twg page stays unknown and is not cached as a time. Tests now run the decline path through the default twg client. Refs #511
|
🟢 Local review: pass: round 2, head Review bundle mode: public. Minor / nits
Checks
Concerns
Carry-over
Comment cleanup plan
Notes
Forge checksObserved checks: PENDING. Head Execution context: isolated public review. Concern and lead processes ran in a fresh directory outside the authoring collection with an allowlisted environment and without project or user agent configuration, read a read-only snapshot of Run stats
Wall-clock for the whole run: 1m53s (agent time summed: 4m16s).
Forge checks at publicationObserved checks: PENDING. Head |
A TWG profile kept in TWG's own store has no local identity, so the auth-cache contract keeps its observations operation-private and never lets them serve a later run. A decline, unlike a merge, is not recorded, so dating it under a profile cost one activity read per status run with no bound. Declines are now dated only when twg reads with a known credential (an environment token or a host read credential) and the PR reports updated_on. The log is keyed by updated_on and reused at any age, so each credential context reads a decline once per updated_on; a reopen, re-decline or credential change reads again. Under a TWG profile, under bb, or without updated_on the decline stays unknown and no activity is read. Tests pin the budget: no reads under a profile, one read across cache expiry with a known credential, a new read after a re-decline or a rotated credential, and a collector run over three refreshes. Refs #511
|
🟢 Local review: pass: round 3, head Review bundle mode: public. Minor / nits
Concerns
Carry-over
Comment cleanup plan
Notes
Checks
Forge checksObserved checks: PENDING. Head Execution context: isolated public review. Concern and lead processes ran in a fresh directory outside the authoring collection with an allowlisted environment and without project or user agent configuration, read a read-only snapshot of Run stats
Wall-clock for the whole run: 2m07s (agent time summed: 3m57s).
Forge checks at publicationObserved checks: PENDING. Head |
An undatable activity reply is a complete read and is cached under updated_on like any other, so it costs one read. An incomplete (full page) or malformed reply is not cached, so each later status run retries it once, through the same shared budget and cooldowns; a provider cooldown refuses the read. Tests now pin each case, and the status docs disclose the retry and that the updated_on invalidation key is an unverified assumption about Bitbucket. StatusPRTerminalAt no longer claims every Bitbucket decline is undated. Refs #511
|
🟢 Local review: pass: round 4, head Review bundle mode: public. Minor / nits
Concerns
Carry-over
Comment cleanup plan
Notes
Checks
Forge checksObserved checks: PENDING. Head Execution context: isolated public review. Concern and lead processes ran in a fresh directory outside the authoring collection with an allowlisted environment and without project or user agent configuration, read a read-only snapshot of Run stats
Wall-clock for the whole run: 1m29s (agent time summed: 3m29s).
Forge checks at publicationObserved checks: PENDING. Head |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 03b2fac. Configure here.
A background collection dates a Bitbucket decline inside its detail read, and the collector loop then tried again. An incomplete or malformed reply is not cached, so that second attempt was another live read and another budget slot in the same run. The loop now completes a decline only for a foreground refresh, which skips the detail-read path; merges are unchanged. A collector regression pins one read per background run for a malformed reply and still dates a readable one. Refs #511
|
🟢 Local review: pass: round 5, head Review bundle mode: public. Minor / nits
Concerns
Carry-over
Comment cleanup plan
Notes
Checks
Forge checksObserved checks: PENDING. Head Execution context: isolated public review. Concern and lead processes ran in a fresh directory outside the authoring collection with an allowlisted environment and without project or user agent configuration, read a read-only snapshot of Run stats
Wall-clock for the whole run: 2m12s (agent time summed: 4m18s).
Forge checks at publicationObserved checks: SUCCESS. Head |
One status operation can complete the same decline on several paths: a detail read, a full confirmation of a PR omitted from the open list, and the collector. An incomplete, malformed or refused activity read is not cached, so each of those paths read again. The previous fix covered only the collector on the view path; with a fresh detail cache the list-omitted path still read twice. Record, per decline activity key (slug#number@updated_on), the operation that last read it without a cacheable result, and skip a second read in that operation. One entry per key bounds the map by the declined PRs observed; a new operation retries. The collector-loop gate is reverted, as the record covers every path. Tests: the list-omitted path with a fresh detail cache and a REST open list reads once per operation; background runs with fresh and expired detail caches read once each. Refs #511
10884c1 kept an uncached decline read to once per operation with a process-wide map from activity key to the nonce of the last operation. Its entries accumulated across PRs and updated_on values, overlapping operations overwrote each other's nonce, and two concurrent paths of one operation could both pass the check before either recorded it. The existing single flight does not cover failures: it serializes through the cache-file lock, and a failed read stores nothing, so the next waiter reads again. The status operation now owns a keyed single flight (statusOperationShared) beside its other per-operation state: the first caller for a key runs the read; concurrent and later callers in that operation wait for it and receive its outcome, error included; the record is released with the operation. A decline's read goes through it, keyed by slug and number@updated_on, and the process-wide map is removed. Merges are unchanged. Tests: 16 concurrent callers of one key and operation make one call and share its error, while a new operation, another key or no operation call again; 8 concurrent paths completing one decline while its slow, malformed activity read is in flight make one read per operation. Both fail with a non-atomic check-then-store, and run clean under the race detector. Refs #511
|
🟢 Local review: pass: round 7, head Review bundle mode: public. Minor / nits
Concerns
Carry-over
Comment cleanup plan
Notes
Checks
Forge checksObserved checks: PENDING. Head Execution context: isolated public review. Concern and lead processes ran in a fresh directory outside the authoring collection with an allowlisted environment and without project or user agent configuration, read a read-only snapshot of Run stats
Wall-clock for the whole run: 1m59s (agent time summed: 4m29s).
Forge checks at publicationObserved checks: PENDING. Head |

Refs #511: the decline-time slice. #511 is only partly resolved and stays open. Under a
twgprofile orbb, a declined Bitbucket PR still has no time.What changed
A declined Bitbucket PR had no terminal time, so it sorted after every dated archive row. In a known credential context, the activity read that already dates a Bitbucket merge now also dates a decline:
ClosedAtis the update that entered the currentDECLINEDstate: the earliest update in the trailing run ofDECLINEDupdates, ordered by event date. A later edit while declined doesn't move it. After a reopen and a second decline, the second decline sets the time.updated_onand observation time never stand in.ClosedOn(archive eligibility and age) is unchanged, and so is MERGED behaviour. Other states make no activity read, and rendering makes no forge calls.Where a decline is dated, and the read budget
Unlike a merge, a decline is not recorded and can be reopened. It is dated only where one read can serve later runs without breaking the authenticated-cache contract (
docs/status-auth-cache.md):twgwith a known credential (TWG_BBC_TOKEN, or a host read credential) and anupdated_onupdated_on, including after the cache expirestwgprofile in TWG's own storebb(deprecated)updated_onupdated_on, so a reopen or re-decline (which changesupdated_on) or a credential rotation (which changes the cache context) triggers a new read.twgprofile: a profile has no local identity. The contract keeps its observations operation-private, so dating declines under a profile would cost one read per status run indefinitely.bb:bb pr activity --json(bb 2.2.1) stops at its default limit of 25 and doesn't say whether more entries exist.Invalid and incomplete replies (retries)
updated_onlike any other read, so it costs one read and leaves the decline unknown.Unverified provider assumption
The invalidation key assumes that Bitbucket changes a PR's
updated_onwhen it is reopened or declined again. This has not been verified against a live provider. If the assumption is wrong, a re-declined PR could keep its earlier decline time untilupdated_onchanges for some other reason or the credential changes. The status docs state this assumption.Contract evidence
TWG 1.4.4's local help,
twg help describe "bitbucket pull-requests activity", documents a chronological list withpull_request.id,update.stateandupdate.date. The bb facts come from the installed bb 2.2.1 package source. No live provider read was made, and the fixtures are synthetic. Neither envelope is live-verified, and neither is the assumption that Bitbucket changesupdated_onon reopen and decline.Tests
updated_onstays unknown. A re-decline and a rotated credential each read again. A full page stays unknown.bbcontext still stays unknown with no read. An open PR makes no read. A merge is still dated.twg:statusOperationSharedinstatus_auth_context.go), keyed by slug andnumber@updated_on. The first caller runs the read. Concurrent and later callers in that operation get its outcome, error included. The record is released with the operation, and a new operation reads again. No process-wide state is kept. Merges are unchanged.updated_onrequirement,updated_onin the key, or thebbskip.Also corrected: the
StatusPRTerminalAtcomment no longer claims that every Bitbucket decline is undated.Still to do
Note
Medium Risk
Changes forge activity reads, authenticated cache keys, and archive ordering for Bitbucket declines, though behavior is gated by credentials and covered by extensive tests.
Overview
Declined Bitbucket pull requests can now participate in archive ordering by terminal time. When
twgruns with a known credential (TWG_BBC_TOKENor a host read credential) and the PR hasupdated_on, status reads the same activity log used for merges and setsClosedAtfrom the update that entered the currentDECLINEDstate—not fromupdated_on. Under a TWG profile or the deprecatedbbclient, decline time stays unknown and no activity call is made.The implementation adds
statusBBDeclineEventTime, extendsstatusBBCompleteMergeTimeContextfor declined PRs, and introducesstatusOperationSharedso multiple collector/detail paths in one status run share a single activity fetch. Caching is keyed by credential context andupdated_on; malformed or incomplete responses are retried once per operation. The PR collector pass now completes Bitbucket decline times as well as merges. Documentation and release notes describe the behavior and assumptions.Reviewed by Cursor Bugbot for commit 635872f. Bugbot is set up for automated code reviews on this repo. Configure here.