Skip to content

511: date Bitbucket declines from the activity log - #527

Merged
lcorneliussen merged 7 commits into
mainfrom
issue-511-decline-time
Nov 25, 2026
Merged

lcorneliussen merged 7 commits into
mainfrom
issue-511-decline-time

Conversation

@lcorneliussen

@lcorneliussen lcorneliussen commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Refs #511: the decline-time slice. #511 is only partly resolved and stays open. Under a twg profile or bb, 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:

  • ClosedAt is the update that entered the current DECLINED state: the earliest update in the trailing run of DECLINED updates, 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.
  • The time stays unknown in four cases: the latest dated update is in another state; any state update has a missing or invalid date; the read fills TWG's 200-entry page; or the read is unavailable. updated_on and 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):

Context Decline time Activity reads
twg with a known credential (TWG_BBC_TOKEN, or a host read credential) and an updated_on dated one per credential context and updated_on, including after the cache expires
twg profile in TWG's own store unknown none
bb (deprecated) unknown none
no updated_on unknown none
  • Invalidation: the cached log is keyed by updated_on, so a reopen or re-decline (which changes updated_on) or a credential rotation (which changes the cache context) triggers a new read.
  • Why not a twg profile: 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.
  • Why not 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)

  • Valid but undatable (for example, a bad date, or a log that ends in a reopen): this is a complete read. It is cached under updated_on like any other read, so it costs one read and leaves the decline unknown.
  • Incomplete (a full 200-entry page) or malformed: the time is unknown and the reply is not cached. Each later status run retries it once. Every retry is an ordinary read under the same shared request budget and the same provider and rate-limit cooldowns, and a cooling provider refuses it. Tests pin one retry per operation and the refusal under a cooldown. A failure is not cached; adding a failure cache would change the cache contract, which is out of scope here.

Unverified provider assumption

The invalidation key assumes that Bitbucket changes a PR's updated_on when 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 until updated_on changes 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 with pull_request.id, update.state and update.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 changes updated_on on reopen and decline.

Tests

  • Parser table: single decline, offset date normalised to UTC, an edit after the decline, reopen and second decline, out-of-order entries, reopen after the decline, invalid and missing dates, no state update, a merged-only log, malformed input. The merge-time parser is unchanged.
  • Budget: a profile makes no reads and stays unknown. A known credential makes one read across cache expiry. A missing updated_on stays unknown. A re-decline and a rotated credential each read again. A full page stays unknown.
  • Contexts: a host read credential dates the decline. A known bb context still stays unknown with no read. An open PR makes no read. A merge is still dated.
  • Collector, three foreground refreshes under twg:
    • Under a profile, the decline sorts after the dated rows with no activity read.
    • With a known credential, the archive order across GitHub and Bitbucket is stable, the decline is read once across cache expiry, and the merged PR's activity is not read again.
  • Payloads: an undatable reply is read once. Incomplete and malformed replies are retried once per operation. A provider cooldown refuses the read.
  • Once per operation: one status operation can complete the same decline on several paths, sometimes concurrently: a detail read, a full confirmation of a PR omitted from the open list, and the collector. The existing single flight doesn't cover failures: a failed read stores nothing, so the next waiter reads again. A decline's read now goes through a keyed single flight owned by the status operation (statusOperationShared in status_auth_context.go), keyed by slug and number@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.
  • Interleaving tests: 16 concurrent callers of one key make one call and share its error. A new operation, another key, or a call with no operation calls again. 8 concurrent paths completing one decline while a slow, malformed read is in flight make one read per operation. Both tests fail against a non-atomic check-then-store and pass under the race detector. The list-omitted path with a fresh detail cache, and background runs with fresh or expired caches, each read once per operation.
  • Review history: hosted review, local review and maintainer review found three successive issues with how often a failed read repeated. They are fixed in 22d0e7d, 10884c1 and 635872f.
  • Mutation checks: removing any one guard makes a test fail: decline dating, the known-context gate, any-age reuse, the updated_on requirement, updated_on in the key, or the bb skip.

Also corrected: the StatusPRTerminalAt comment no longer claims that every Bitbucket decline is undated.

Still to do

  • Full CI on the current head
  • Local review on the current head

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 twg runs with a known credential (TWG_BBC_TOKEN or a host read credential) and the PR has updated_on, status reads the same activity log used for merges and sets ClosedAt from the update that entered the current DECLINED state—not from updated_on. Under a TWG profile or the deprecated bb client, decline time stays unknown and no activity call is made.

The implementation adds statusBBDeclineEventTime, extends statusBBCompleteMergeTimeContext for declined PRs, and introduces statusOperationShared so multiple collector/detail paths in one status run share a single activity fetch. Caching is keyed by credential context and updated_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.

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
@lcorneliussen

lcorneliussen commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner Author

🟢 Local review: pass: round 2, head 386ed16. Both round-1 findings are fixed. The change still stays within the stated decline-dating slice. Two minor comment-wording issues are open, and CI has not finished for this head.

Review bundle mode: public.

Minor / nits

Checks

  • checks.json for head 386ed16 reports PENDING (complete, requiredness unknown). That is not a green check, and no CI result is available yet. The PR checklist still lists "Full CI" as unchecked. This verdict is code-review judgment only.
  • No hosted reviews (Copilot, Cursor) were recorded for this head.
Concerns
concern status open findings note
correctness ok 0 Traced all four callers and the shared-admission fallbacks. The cache key number@updated_on prevents a re-decline from reusing the first decline's log
comments issues 2 minor Wording only; no behaviour change requested
tests-and-evidence ok 0 Parser, enrichment, budget, bb and collector tests match the diff. The 200-entry test matches the reader's guard
scope-and-hygiene ok 0 Six files, all in scope; no debug output, secrets or local paths
backwards-compat skipped 0 Needs downstream repositories, and the bundle includes none

Carry-over

  • 2 earlier findings remain fixed: decline-log reuse after a re-decline [correctness], and the bb activity shape now described as assumed [comments].

Comment cleanup plan

Notes

  • Spot-check: both open comment findings are confirmed in the source at the cited lines. No severities were changed and nothing was dropped.
  • Scope: the patch grew 48.8% since round 1, under the 50% threshold. The growth is the updated_on cache key and its tests, which answer the round-1 finding, and the PR description covers them.
  • Not verified and not counted as findings: a Bitbucket detail without updated_on falls back to the bare-number key, and it is unconfirmed whether such replies occur. A reopen and a decline with equal timestamps keep the provider's order. The bb page-limit facts come from package source outside this repository.
  • The mutation-check and "fails without the change" claims in the PR were not rerun by the reviewers. No tests were run in this review.

Forge checks

Observed checks: PENDING. Head 386ed166c2e2706beddc733aadec12b8bb360b31; observed 2026-11-24T09:18:42Z. Required-check policy is unknown. This evidence is separate from the code-review verdict.

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 386ed166c2e2 with file tools only (no commands or tests were run), and their writes were audited (source unchanged: true). Client restrictions are not an OS sandbox; administrator-managed client policy still applies.

Run stats
Concern Agent Time Tokens in / out (cache read) Cost
backwards-compat - - - -
comments claude:haiku 1m21s 20 / 16k (351k) $0.02
correctness claude:opus 1m10s 22 / 6.3k (398k) $0.66
scope-and-hygiene claude:haiku 46s 14 / 8.4k (184k) $0.01
tests-and-evidence claude:sonnet 26s 10 / 2.6k (96k) $0.15
lead claude:opus 31s 12 / 3.5k (76k) $0.21
Total 4m16s 78 / 37k (1.1M) $1.05

Wall-clock for the whole run: 1m53s (agent time summed: 4m16s).

wtc-review v1 head=386ed166c2e2706beddc733aadec12b8bb360b31 verdict=pass blockers=0 round=2 lead=claude:opus

Forge checks at publication

Observed checks: PENDING. Head 386ed166c2e2706beddc733aadec12b8bb360b31; observed 2026-11-24T09:20:57Z. Required-check policy is unknown. This evidence is separate from the code-review verdict.

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
@lcorneliussen

lcorneliussen commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner Author

🟢 Local review: pass: round 3, head b86186a. The decline-dating logic, cache key and read budget hold up. The only open items are comment wording: two carried over from round 2, plus two new ones outside the diff that this change has made stale. CI has not finished for this head.

Review bundle mode: public.

Minor / nits

  • internal/wtc/status_enlisted.go:769: The comment "A Bitbucket decline is final" contradicts the new doc at internal/wtc/status_enlisted.go:87, which says a decline can be reopened. Reword it to state the archive policy without calling the decline final. No behaviour change. Still open from round 2. [comments]
  • internal/wtc/status_render.go:49: The StatusPRTerminalAt comment says "(including every Bitbucket decline)" is unknown. With a known credential, a decline is now dated through ClosedAt. Drop the parenthetical, or say that a decline is unknown when the activity log does not date it. New, stale outside the diff. [comments]
  • internal/wtc/bitbucket_read.go:540 (nit): The full-page guard comment mentions only the merge event. It also protects decline dating, so it should say "may hide the merge or decline event". Still open from round 2. [comments]
  • internal/wtc/status_archive511_test.go:239 (nit): The helper comment (on line 237) says "it returns that directory", but the function returns the no-bb host and the directory. New. [comments]
Concerns
concern status open findings note
correctness ok 0 Traced all four callers and the stale and any-age fallbacks. The number@updated_on key keeps a re-decline from reusing an earlier log. A full 200-entry page is never cached
comments issues 2 minor, 2 nit Wording only; no behaviour change requested
tests-and-evidence ok 0 Parser, budget, context and collector tests match the diff and the PR's claims. The 200-entry fixture exercises the reader's guard
scope-and-hygiene ok 0 All six files are in scope, with no debug output, secrets or local paths. The description matches the code
backwards-compat skipped 0 Needs downstream repositories, and the bundle includes none

Carry-over

  • 2 earlier findings remain fixed: decline-log reuse after a re-decline [correctness], and the bb activity shape described as an assumption [comments].
  • 2 round-2 comment findings are still open (listed above).

Comment cleanup plan

  • Delete or reword: the "decline is final" reason at internal/wtc/status_enlisted.go:769 (keep the archive rule), the "every Bitbucket decline" parenthetical at internal/wtc/status_render.go:49, the merge-only wording at internal/wtc/bitbucket_read.go:540, and the return-value wording in the archive511TWG helper comment.
  • Refactor first: none. These comments explain a policy; they do not compensate for tangled code.
  • Keep: the cache-key, bb page-limit and known-credential rationale, the trailing-DECLINED-run doc, and the note on the assumed shape. These match the code.

Notes

  • Spot-check: I confirmed all four comment findings verbatim in the source at head. The test-helper wording is in the comment on line 237; the finding anchors to the function signature on line 239. No severities were changed and nothing was dropped.
  • Scope: the patch grew 9.3% since round 2, under the threshold. No new behaviour falls outside the description.
  • Round-3 checkpoint: no major concern persists, so the design-convergence question does not apply. The two carried-over items are minor wording fixes.
  • Not verified, and not counted as findings: whether a reopen and a decline with equal timestamps keep the provider's order; whether list and get replies format updated_on the same way (a mismatch would cost an extra read, not give a wrong time); and whether Bitbucket changes updated_on on reopen and decline, which the PR discloses. The bb page-limit facts come from package source outside this repository.
  • The PR's mutation-check claims were not rerun. No tests or commands were run in this review.

Checks

  • checks.json for head b86186a reports PENDING (complete, requiredness unknown). That is not a green check, and no CI result is available. The PR checklist still lists "Full CI on the current head" as unchecked. This verdict is code-review judgment only.

Forge checks

Observed checks: PENDING. Head b86186a388c651077c54b5e0ba2ae59949cecc84; observed 2026-11-24T09:27:58Z. Required-check policy is unknown. This evidence is separate from the code-review verdict.

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 b86186a388c6 with file tools only (no commands or tests were run), and their writes were audited (source unchanged: true). Client restrictions are not an OS sandbox; administrator-managed client policy still applies.

Run stats
Concern Agent Time Tokens in / out (cache read) Cost
backwards-compat - - - -
comments claude:haiku 1m28s 28 / 16k (628k) $0.03
correctness claude:opus 1m02s 18 / 5.9k (286k) $0.54
scope-and-hygiene claude:haiku 28s 8 / 4.5k (77k) $0.01
tests-and-evidence claude:sonnet 19s 8 / 1.9k (69k) $0.13
lead claude:opus 38s 12 / 4.1k (77k) $0.23
Total 3m57s 74 / 32k (1.1M) $0.94

Wall-clock for the whole run: 2m07s (agent time summed: 3m57s).

wtc-review v1 head=b86186a388c651077c54b5e0ba2ae59949cecc84 verdict=pass blockers=0 round=3 lead=claude:opus

Forge checks at publication

Observed checks: PENDING. Head b86186a388c651077c54b5e0ba2ae59949cecc84; observed 2026-11-24T09:30:16Z. Required-check policy is unknown. This evidence is separate from the code-review verdict.

Comment thread internal/wtc/status_archive511_test.go Resolved
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
@lcorneliussen

lcorneliussen commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner Author

🟢 Local review: pass: round 4, head 03b2fac. The decline-dating logic, the updated_on cache key and the read budget still hold up. The only open items are two comment-wording fixes carried over from earlier rounds. CI has not finished for this head.

Review bundle mode: public.

Minor / nits

  • internal/wtc/status_enlisted.go:769: The comment says "A Bitbucket decline is final", which contradicts the doc at internal/wtc/status_enlisted.go:87: a decline can be reopened. Reword the comment so it states the archive policy without calling the decline final. No behaviour change. Still open from round 2. [comments]
  • internal/wtc/bitbucket_read.go:540 (nit): The full-page guard comment names only the merge event. The guard also protects decline dating, so say "may hide the merge or decline event". Still open from round 2. [comments]
Concerns
concern status open findings note
correctness ok 0 Re-traced all four callers and the any-age and stale-on-cooldown fallbacks. The number@updated_on key keeps a re-decline from reusing an earlier log. A full 200-entry page is never cached
comments issues 1 minor, 1 nit Wording only. No behaviour change requested
tests-and-evidence ok 0 The parser, budget, context and collector tests match the PR's claims, including the new retry and cooldown cases
scope-and-hygiene ok 0 All changed files are in scope. No debug output, secrets or local paths. The description matches the code
backwards-compat skipped 0 Needs downstream repositories, and the bundle includes none

Carry-over

  • 4 earlier findings remain fixed: decline-log reuse after a re-decline [correctness], the bb activity shape described as an assumption [comments], the StatusPRTerminalAt "every Bitbucket decline" parenthetical [comments], and the archive511TWG helper return-value wording [comments].
  • 2 earlier comment findings are still open (listed above).

Comment cleanup plan

  • Delete or reword: the "decline is final" reason at internal/wtc/status_enlisted.go:769 (keep the archive rule and the GitHub sentence), and the merge-only wording at internal/wtc/bitbucket_read.go:540.
  • Refactor first: none.
  • Keep: the rationale for the cache key, the bb page limit, the known-credential gate and the trailing DECLINED run. It matches the code.

Notes

  • Spot-check: both open comment findings appear word for word in the source at head. I checked the new retry tests in TestStatusArchive511TWGDeclineReadBudget: undatable makes 1 read over 3 operations; incomplete (a 200-entry page) and malformed each make 3; a provider cooldown refuses the read. They match the PR's "retried once per operation" claim. No severities were changed and nothing was dropped.
  • Scope: the patch grew 7.5% since round 3, under the threshold. The new changes are retry tests and comment fixes. No behaviour falls outside the description.
  • Round-3+ checkpoint: no major concern persists, so the design-convergence question does not apply.
  • Not verified, and not counted as findings:
    • whether Bitbucket changes updated_on on reopen and decline (the PR and the docs disclose this assumption);
    • how a reopen and a decline with equal timestamps are ordered;
    • whether list and get replies format updated_on the same way (a mismatch would cost one extra read, not give a wrong time).
  • I did not rerun the PR's mutation-check claims. No tests or commands were run in this review.

Checks

  • checks.json for head 03b2fac reports PENDING (complete, requiredness unknown). That is not a green check, and no CI result is available. The PR checklist still lists "Full CI on the current head" as unchecked. This verdict is based on code review only.

Forge checks

Observed checks: PENDING. Head 03b2fac1164fe310204222de9be5f09bfe0e3a59; observed 2026-11-24T09:38:46Z. Required-check policy is unknown. This evidence is separate from the code-review verdict.

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 03b2fac1164f with file tools only (no commands or tests were run), and their writes were audited (source unchanged: true). Client restrictions are not an OS sandbox; administrator-managed client policy still applies.

Run stats
Concern Agent Time Tokens in / out (cache read) Cost
backwards-compat - - - -
comments claude:haiku 53s 18 / 10k (308k) $0.02
correctness claude:opus 50s 18 / 4.7k (281k) $0.49
scope-and-hygiene claude:haiku 46s 16 / 7.9k (248k) $0.01
tests-and-evidence claude:sonnet 23s 10 / 2.8k (106k) $0.17
lead claude:opus 36s 14 / 4.1k (100k) $0.26
Total 3m29s 76 / 30k (1.0M) $0.95

Wall-clock for the whole run: 1m29s (agent time summed: 3m29s).

wtc-review v1 head=03b2fac1164fe310204222de9be5f09bfe0e3a59 verdict=pass blockers=0 round=4 lead=claude:opus

Forge checks at publication

Observed checks: PENDING. Head 03b2fac1164fe310204222de9be5f09bfe0e3a59; observed 2026-11-24T09:40:27Z. Required-check policy is unknown. This evidence is separate from the code-review verdict.

@lcorneliussen
lcorneliussen marked this pull request as ready for review November 24, 2026 09:49

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread internal/wtc/status_enlisted.go Resolved
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
@lcorneliussen

lcorneliussen commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner Author

🟢 Local review: pass: round 5, head 22d0e7d. The foreground-only loop fix removes the double read on the background view path that the hosted review reported. One new minor read-budget gap remains on another background path, and the two comment-wording items from earlier rounds are still open. CI has not finished for this head.

Review bundle mode: public.

Minor / nits

  • internal/wtc/status_enlisted.go:597: A background run still reads an uncached decline's activity twice on the list-omitted and truncated paths. Lead spot-check confirmed the path. statusReadCachedDetailContext (:269 or :264) completes the decline at :200. statusConfirmFullPRContext then completes it again, either through statusReadCachedDetailContext at internal/wtc/status_full_refresh.go:397 when no full refresh is due, or at internal/wtc/status_full_refresh.go:412 when one is due. A malformed or full-page reply is not cached, so this costs a second shared-budget read in that run. Results stay correct, because the decline stays unknown. The new loop comment ("a run reads a decline's activity at most once") overstates the invariant. Suggested fix: record an attempted, uncached number@updated_on key once per operation inside statusBBCompleteMergeTimeContext. Then add a collector case with a fresh detail cache, because the current test expires the cache before each run and so always takes the view path. If you defer the fix, narrow the comment. [correctness]
  • internal/wtc/status_enlisted.go:771: "A Bitbucket decline is final" contradicts the reopen doc and the tests. Reword it to state the archive policy. This is a comment-only change. Still open from round 2. [comments]
  • internal/wtc/bitbucket_read.go:540 (nit): The full-page guard comment names only the merge event. Change it to "may hide the merge or decline event". Still open from round 2. [comments]
Concerns
concern status open findings note
correctness issues 1 minor Re-traced all callers of the completion step. Foreground declines are still dated once. One background path reads twice (above)
comments issues 1 minor, 1 nit Wording only. No behaviour change requested
tests-and-evidence ok 0 The parser, budget, context, payload-retry and collector tests match the PR's claims
scope-and-hygiene ok 0 All seven files are in scope. No debug output, secrets or local paths
backwards-compat skipped 0 Needs downstream repositories, and the bundle includes none

Carry-over

  • 4 earlier findings remain fixed. The hosted-review double read on the background view path is fixed in 22d0e7d.
  • 2 earlier comment findings are still open (listed above).

Comment cleanup plan

Notes

  • Spot-check: I verified the correctness finding against the source. The :264/:269 → :200 → status_full_refresh.go:397/:412 sequence exists, and the collector loop at :599 now skips background declines. I kept the severity at minor, because the problem is one extra budgeted read per undatable, uncached decline per background run and causes no wrong output. Both comment findings appear in the source word for word. No severities were changed and nothing was dropped.
  • The comments reviewer raised a possible second read in a foreground run but did not verify it. It is not counted as a finding.
  • Scope: the patch grew 7.5% since round 4, under the threshold. The new behaviour (the foreground-only loop gate) is described in the PR. Round-3+ checkpoint: no major concern persists.
  • Not verified, and not counted as findings: whether Bitbucket changes updated_on on reopen and decline (the PR discloses this assumption), and how a reopen and a decline with equal timestamps are ordered.
  • No tests or commands were run in this review.

Checks

  • checks.json for head 22d0e7d reports PENDING (complete, requiredness unknown). That is not a green check, and no CI result is available. The PR checklist still lists "Full CI on the current head" as unchecked. This verdict is based on code review only.

Forge checks

Observed checks: PENDING. Head 22d0e7d5045bcf3c2c2a93221d585f4474f0ae51; observed 2026-11-24T10:02:39Z. Required-check policy is unknown. This evidence is separate from the code-review verdict.

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 22d0e7d5045b with file tools only (no commands or tests were run), and their writes were audited (source unchanged: true). Client restrictions are not an OS sandbox; administrator-managed client policy still applies.

Run stats
Concern Agent Time Tokens in / out (cache read) Cost
backwards-compat - - - -
comments claude:haiku 1m01s 20 / 11k (418k) $0.02
correctness claude:opus 1m27s 24 / 8.4k (566k) $0.85
scope-and-hygiene claude:haiku 45s 14 / 8.0k (220k) $0.02
tests-and-evidence claude:sonnet 19s 8 / 1.9k (74k) $0.14
lead claude:opus 44s 14 / 5.0k (106k) $0.29
Total 4m18s 80 / 34k (1.4M) $1.32

Wall-clock for the whole run: 2m12s (agent time summed: 4m18s).

wtc-review v1 head=22d0e7d5045bcf3c2c2a93221d585f4474f0ae51 verdict=pass blockers=0 round=5 lead=claude:opus

Forge checks at publication

Observed checks: SUCCESS. Head 22d0e7d5045bcf3c2c2a93221d585f4474f0ae51; observed 2026-11-24T10:09:08Z. Required-check policy is unknown. This evidence is separate from the code-review verdict.

Comment thread internal/wtc/status_enlisted.go Resolved
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
@lcorneliussen

lcorneliussen commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner Author

🟢 Local review: pass: round 7, head 635872f. The new keyed single flight for each operation replaces the round-6 attempt record and also covers concurrent callers. No correctness, security, test or scope issues are open. Only the two comment-wording items from earlier rounds remain. CI has not reported a result for this head.

Review bundle mode: public.

Minor / nits

  • internal/wtc/status_enlisted.go:785: Stale comment. "A Bitbucket decline is final" contradicts the reopen contract this PR documents at internal/wtc/status_enlisted.go:87 and in docs/status.md. The archive rule itself is correct: it depends on ClosedOn age and does not need a current observation for DECLINED. Reword only the explanation and keep the policy. Open since round 2. [comments]
  • internal/wtc/bitbucket_read.go:540 (nit, lead carry-over): The full-page guard comment still says "may hide the merge event", but the guard also protects decline dating. Change it to "may hide the merge or decline event". I confirmed the wording in the source. The line is not in the diff, so it gets no inline comment. Open since round 2. [comments]
Concerns
concern status open findings note
correctness ok 0 Re-traced all four callers of the completion helper. The round-5 double read stays addressed, now through statusOperationShared
security ok 0 Cache keys are hashed and scoped to the credential. The shared result stays in memory for one operation only. Fixtures are synthetic
comments issues 1 minor (+1 lead carry-over nit) Wording only. No behaviour change requested
tests-and-evidence ok 0 Parser, budget, collector and interleaving tests match the PR's claims. Mutation and race runs are author evidence and were not rerun
scope-and-hygiene ok 0 All changed files are in scope. No debug output, secrets or local paths
backwards-compat skipped 0 Needs downstream repositories, and the bundle includes none

Carry-over

  • 5 earlier findings remain fixed. The round-5 background double read was fixed in 10884c1 and is now replaced by an operation-owned keyed single flight in 635872f. The correctness finding at internal/wtc/status_enlisted.go:131 is still recorded as addressed.
  • 2 earlier comment findings are still open (listed above).

Comment cleanup plan

  • Delete or reword: the "decline is final" reason at internal/wtc/status_enlisted.go:785 (keep the archive rule and the GitHub sentence), and the merge-only wording at internal/wtc/bitbucket_read.go:540.
  • Refactor first: none.
  • Keep: the rationale for the known-credential gate, updated_on as the cache key, the bb page limit, the trailing DECLINED run, and the once-per-operation sharing. It all matches the code, and the unverified updated_on-on-reopen assumption is labelled as unverified.
  • Optional nit: the statusOperationShared doc says waiting callers "receive its outcome", but a waiter whose context is cancelled returns ctx.Err() instead. One clause would make that clear.

Notes

  • Spot-check: I read statusOperationShared (internal/wtc/status_auth_context.go:256). The check and the store both happen under state.mu. The owner runs fetch outside the lock and closes done in a defer, and waiters return on done or on context cancellation. This confirms the correctness reviewer's analysis. Both comment items appear in the source word for word. No severities were changed and nothing was dropped.
  • The security reviewer's notes give statusOperationShared as lines 657-679. It is actually at line 256. That is a citation error in the notes only and does not change the conclusion.
  • Not verified, and not counted as findings: whether Bitbucket changes updated_on on reopen and decline (the PR and docs disclose this), and how a reopen and a decline with equal timestamps are ordered.
  • Scope: the patch grew 17.5% since round 6, under the threshold. The PR description covers the new keyed single flight. Round-3+ checkpoint: no major concern persists.
  • No tests or commands were run in this review. All test claims come from reading the code.

Checks

  • checks.json for head 635872f reports PENDING (complete, requiredness unknown). PENDING is not a passing result. No CI result is available for this head, and the required-check policy is unknown. The PR checklist still lists "Full CI on the current head" as unchecked. This verdict is based on code review only.

Forge checks

Observed checks: PENDING. Head 635872fe2ee4a27353fcc37810502955c2d4ce06; observed 2026-11-24T10:26:14Z. Required-check policy is unknown. This evidence is separate from the code-review verdict.

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 635872fe2ee4 with file tools only (no commands or tests were run), and their writes were audited (source unchanged: true). Client restrictions are not an OS sandbox; administrator-managed client policy still applies.

Run stats
Concern Agent Time Tokens in / out (cache read) Cost
backwards-compat - - - -
comments claude:haiku 50s 14 / 9.7k (251k) $0.02
correctness claude:opus 1m13s 22 / 6.6k (446k) $0.73
scope-and-hygiene claude:haiku 39s 10 / 7.7k (130k) $0.01
security claude:opus 37s 18 / 3.4k (167k) $0.33
tests-and-evidence claude:sonnet 22s 6 / 2.5k (46k) $0.15
lead claude:opus 46s 14 / 4.7k (103k) $0.28
Total 4m29s 84 / 35k (1.1M) $1.51

Wall-clock for the whole run: 1m59s (agent time summed: 4m29s).

wtc-review v1 head=635872fe2ee4a27353fcc37810502955c2d4ce06 verdict=pass blockers=0 round=7 lead=claude:opus

Forge checks at publication

Observed checks: PENDING. Head 635872fe2ee4a27353fcc37810502955c2d4ce06; observed 2026-11-24T10:28:24Z. Required-check policy is unknown. This evidence is separate from the code-review verdict.

@lcorneliussen
lcorneliussen merged commit b12fb9b into main Nov 25, 2026
6 checks passed
lcorneliussen added a commit that referenced this pull request Nov 25, 2026
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