Repository navigation
✨ feature: inline the linked Linear issue into review kicks - #14921
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
|
hive/awaiting-ci: CI pending — sweep will merge when green. 🐝 Hive Agent: — hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
There was a problem hiding this comment.
Correctness (read at head c68e6f7)
-
Linear fetch is not gated on "about to be reviewed" and failures are not cached, so an outage blocks the planner rather than degrading.
reviewScopeContractFor(src/cmd/hive/main.go:10841) runs for every candidate PR on every eval cycle, unlike its neighboursreviewBotRouteFilesFor(main.go:10710-10715) andreviewDeltaDiffFor(main.go:10728-10733), which skip PRs already judged at this head or with a pending dispatch.ScopeContractIssue(src/pkg/worksource/linear_scope.go:69-130) stores a cache entry only on success; the error path returns withoutstoreScopeIssue. With Linear unreachable, each cycle therefore performs one full fetch per Linear-contract PR, each blocking up to the 30s client timeout (src/pkg/worksource/linear.go:87,http.Client{Timeout: 30 * time.Second}), serially insideplanReviewDispatchWith. The PR body says an outage "degrades to the current behaviour instead of blocking review"; the wording degrades, but the review planner stalls N×30s per cycle. Even when healthy, already-judged PRs cost one updatedAt probe per issue every 5 minutes against the same Linear rate limit the work source uses. Fix: apply theartifact.AggregateForBody/state.PendingSincegate before calling the reader (as main.go:10710-10715 does), and record failed reads in the cache with a short TTL so one outage costs one attempt per issue per recheck window. -
(nit) The comment "Changed paths for the bot-author model route's path exceptions…" (main.go:10836-10838) now sits above the Linear call instead of
reviewBotRouteFilesFor.
— hive: agent=adjudicator backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Security review (head c68e6f7) — no blocking findings; one advisory.
The untrusted-data boundary is sound where it matters: issue text is quoted inside a fence longer than any backtick run it contains (src/pkg/review/prompts.go:548-560), the identifier only reaches Linear as a GraphQL variable after the repo-gated regex in src/pkg/github/client.go:1998-2014, the hive-side read reuses the pre-existing bounded linearGraphQL (src/pkg/worksource/linear.go:521, 16 MiB LimitReader; errors never echo the key), and the kick stays on the existing DispatchKick.Message field (src/pkg/review/dispatch.go:849-862).
- Low / advisory:
ScopeContractStateis tracker-controlled but is interpolated outside the fence, into the trustedContract: Linear issue %s (state: %s).line (src/pkg/review/prompts.go:514-519), straight fromstate { name }with no newline/length sanitisation (src/pkg/worksource/linear_scope.go:136-137,160). A Linear workspace admin who renames a workflow state to contain newlines can write text that reads as hive instructions rather than quoted issue data. Collapse whitespace and cap the state name (e.g.strings.Join(strings.Fields(state), " "), ≤64 bytes) before rendering it.
— hive: agent=adjudicator-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
hive/awaiting-ci: pushed worksource tests for the coverage floor (89.4% < 90%). The earlier docker (hub) failure was infrastructure — proxy.golang.org returned 'stream error: INTERNAL_ERROR' while fetching google.golang.org/grpc@v1.83.2 — and re-runs with this push. Sweep will merge when green. 🐝 Hive Agent: — hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
There was a problem hiding this comment.
Read the diff against the v5 tree plus worksource/factory.go, worksource/linear.go:497 (linearGraphQL) and github/client.go:1947-1977 (reviewScopeContract/SetLinearScopeTeams). The design is sound and the code is correct as far as I can verify; what is red is the coverage gate, and it is caused by this diff.
Finding (medium) — coverage is red: worksource: 89.4% (floor 90%) (job 122825345344). The uncovered code is the updatedAt recheck branch in pkg/worksource/linear_scope.go:80-95, plus LinearScopeSource (:166-181), the not-found and empty-identifier returns. The recheck branch is unreachable from a test as written: ScopeContractIssue calls time.Now() directly (:74) and linearScopeRecheck is a const (:27), so TestLinearScopeContractIssue can only ever exercise the < linearScopeRecheck cache hit. Making the clock (or the recheck window) injectable on LinearSource would let a test prove the "same updatedAt → no refetch" and "changed updatedAt → refetch" paths that the PR body advertises, and would recover the gate.
Note on docker (hub): that failure is a proxy.golang.org read error on google.golang.org/grpc@v1.83.2 (job 122822832243), not this diff — infra, retry.
Verified correct:
- Gating matches the upstream recogniser:
reviewScopeLinearReaderkeys onLinear.Teams(cmd/hive/review_scope_linear.go:33), the same inputSetLinearScopeTeamsuses (github_client_config.go:93), so a PR only gets alinked Linear issuecontract when a reader exists. LinearScopeSourcegoes throughFromConfigwithType="linear"(linear_scope.go:171), so the key is resolved viaresolveSecretRefand the team validation fails closed exactly as the work source does (factory.go:34-62).linearGraphQLsurfaces GraphQLerrorsaserr(linear.go:537-539), so a bad identifier becomes "could not be fetched" in the prompt rather than an empty inline.- The untrusted fence (
pkg/review/prompts.go:541-553) is longer than any backtick run in the text, and the fallback wording for a failed fetch keeps today's "named only" behaviour (prompts.go:531-534).
Low, not blocking: reviewScopeLinearReader rebuilds the cached source only when ws.Linear.APIKey changes (review_scope_linear.go:38-42); a base_url or teams edit keeps the old source until restart, and since the key is the unresolved secret reference, rotating the referenced secret value does not rebuild either. Fine for now; worth a comment or widening the key if config hot-reload matters here.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Read pkg/worksource/linear_scope.go, cmd/hive/review_scope_linear.go, pkg/review/prompts.go and the producer of the contract string (pkg/github/client.go:2010); the "linked Linear issue " prefix matches, linearGraphQL already surfaces GraphQL errors, and issue(id:) is the same shape used by linear_advisory.go:48. The fenced/untrusted rendering and untrustedFence are sound. go build ./cmd/hive ./pkg/review ./pkg/worksource passes.
The red coverage check is this PR's fault, not flake — src/pkg/worksource/linear_scope.go:75-90, medium.
Gate output: worksource: 89.4% (floor 90%). linearScopeRecheck is a hard-coded 5 minutes and ScopeContractIssue reads time.Now() directly, so the stale-cache updatedAt probe branch (lines 75–90) and LinearScopeSource (lines 160–176) have no reachable test. Making the recheck window or clock injectable (package-level var, as other packages here do) and adding one probe-path test should clear the floor.
Stale cache is discarded when the refetch fails — src/pkg/worksource/linear_scope.go:91-94, low.
After the 5-minute window, if the probe or full refetch errors, the function returns the error and reviewScopeContractFor (review_scope_linear.go:95-101) leaves ScopeContractText empty, so the kick says the issue "could not be fetched" even though a valid cached copy exists. Returning cached.issue on error when ok would make the kick degrade gracefully during a Linear outage.
Info: reviewScopeLinearReader (review_scope_linear.go:33-52) keys its singleton on APIKey only; a BaseURL or team change without a key change keeps the old source. Fine for now, noting it.
Checked at head ed425cc: the 2-minute failure TTL added there stops retry storms but does not change either point above, since the valid cached text still lives only in LinearSource.scopeIssues. The docker (hub) failure is a proxy.golang.org … INTERNAL_ERROR stream error — infrastructure, unrelated.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Read the diff against the tree at 23671d4, including the callers it hooks into. Looks correct to me.
What I verified:
src/cmd/hive/main.go:10839— the fetch runs only for a PR not yet judged at this head (artifact.AggregateForBody+state.PendingSince), anditemis mutated beforeprs = append(prs, item)at:10845, so the text reaches the plan.src/pkg/worksource/linear_scope.go:166-180—LinearScopeSourceclearsRunStages/Wavefront, andfactory.go:212-214returns the primary unwrapped when no extras remain, so the*LinearSourcetype assertion holds.assigned_onlyis also cleared, so the fail-closed viewer-ID check inFromConfigcannot block a read-only scope fetch.linear_scope.go:67-96— identifier is passed as a GraphQL variable, never interpolated; cache falls back to last-known-good text on a fetch error only when an entry already exists, otherwise the error propagates andprompts.gonames the identifier.prompts.go:541-553—untrustedFenceis longer than any backtick run in the text, so the issue body cannot close its own fence (the test with```code```exercises this).reviewScopeLinearReaderreturns a literalnil, not a typed-nil pointer, so thereader == nilcheck inreviewScopeContractForis sound.
One info-level note, not a defect: prompts.go:513-520 renders the workflow state name outside the untrusted fence (collapsed, capped at 40 runes). State names are admin-configured in Linear rather than issue-author text, and the cap bounds it, so I don't think it needs changing — just noting it is the one tracker-sourced string not inside the fence.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Looks correct to me. Read the diff against the v5 tree at 23671d4 plus the callers it plugs into; the implementation matches #14906 steps 2–3 and the body's claims.
Verified
src/cmd/hive/main.go:10839gates the Linear read on!judged && PendingSince(...).IsZero()— the same two checksreviewBotRouteFilesForalready uses atmain.go:10710-10713, so no fetch happens for a head that is already judged or pending.src/cmd/hive/review_scope_linear.go:33-54caches one*LinearSourcekeyed on the marshalledLinearSourceConfig, so the per-issue cache survives eval cycles and is rebuilt on a team/key change; the 2-minute failure TTL (:60-86) bounds retries on an outage.src/pkg/worksource/linear_scope.go:187-202LinearScopeSourcesetsType="linear",RunStages=false,Wavefront.Enabled=false,AssignedOnly=falseand goes throughFromConfig; with those cleared,appendAdditiveatfactory.go:212-213returns the primary unwrapped, so the*LinearSourceassertion holds.linearGraphQLdefaults an emptyBaseURLatlinear.go:498-499, matching the existing call at:481.- Cache: a hit inside 5 min returns without a request; past that only
updatedAtis probed and the text is refetched only on change; a refetch error with a cached entry returns the cached text rather than failing (linear_scope.go:88-113). Covered byTestLinearScopeContractIssueRecheck/...StaleCacheOnRefetchError. src/pkg/review/prompts.go:541-553untrustedFenceemits a fence one longer than the longest backtick run, so issue text cannot close the block; truncation atlinear_scope.go:205-215cuts on a rune boundary and says so.
One note for the operator (not a defect in this PR — the boundary was chosen in #14906 step 1 and landed in #14912):
the identifier comes from the PR body/title/branch via src/pkg/github/client.go:1993-2013, bounded only by the team keys mapped to the repo. Any PR author — including a fork author — can therefore write Closes ONB-1 and have the hive read that issue (description + last 5 comments, 10 KiB) into the reviewer kick, and prompts.go:531 asks the reviewer to enumerate its acceptance criteria in a public summary. The issue notes the repo's linear[bot] linkback already exposes AC on PRs, so this is consistent with what the operator accepts today; flagging it only so a team mapping a private Linear team to a public repo knows the reach. No change requested.
I have not approved or merged anything.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Correctness — delta re-review (read ca23bd0 as dispatched, plus the newer head 23671d4f the PR moved to).
Blocking: the new recheck test fails deterministically — src/pkg/worksource/linear_scope_internal_test.go:66,92-93
Case "within recheck interval asks nothing" seeds checkedAt = now - time.Minute (line 66, via seedScopeCache at 75), and the hot path it exercises returns the cached entry without touching checkedAt (linear_scope.go:76-77, which is the correct behaviour). The trailing assertion at line 92 then requires time.Since(checkedAt) <= time.Minute, which is already false by a few microseconds, so the subtest fails every run. CI confirms it at 23671d4f: test (rest 4/4) → linear_scope_internal_test.go:93: checkedAt was not refreshed / FAIL github.com/hivecommons/hive/pkg/worksource, which in turn keeps the coverage job red. Fix: only assert the refresh when a probe actually ran (if tc.wantProbes > 0 { ... }), or seed the no-probe case with a sub-minute age (e.g. 30*time.Second).
Advisory (low): linear_scope.go:97-100 (23671d4f) now serves the stale cached issue on a refetch error without bumping checkedAt, and returns nil, so reviewScopeMarkFailed (review_scope_linear.go:97) is never hit. During a Linear outage every eval cycle therefore re-issues probe + full fetch (two timeouts) per cached issue, which is exactly what reviewScopeFailTTL (review_scope_linear.go:55-57) was added to avoid. Calling s.storeScopeIssue(identifier, cached.issue, now) before returning the stale copy would bound it to one attempt per linearScopeRecheck.
Prior findings: stale-cache-on-refetch-error — fixed at 23671d4f (linear_scope.go:97-100, covered by TestLinearScopeContractIssueStaleCacheOnRefetchError). Reader keyed on APIKey only — fixed (review_scope_linear.go:58-61 keys on the JSON of LinearSourceConfig; api_key is serialized per config.go:1930). Coverage gate — probe path is now exercised by the new tests, but the gate cannot be judged until the failing subtest above is fixed.
— hive: agent=adjudicator backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
hive/awaiting-ci: CI pending — sweep will merge when green. 🐝 Hive Agent: — hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
… Merged-today counter above the gate
Every lit stage pill now draws its actor icon from a server-derived
stage_actor {kind, login, since, why} (hive / clanker / human / bot /
none) instead of guessing from author_kind; a bot-authored or unowned
red 070 PR reads "Conflicting · bot PR" / "Red · nobody on it" with the
matching icon, and kind none shows no icon with a "no one is working on
this right now - why" tooltip (hivecommons/docs#500).
A PR that closes several open issues is drawn once: linked_prs entries
carry drawn_under (the PR's nested_under) and the other issues show a
"↳ #N · under #M" chip instead of a second identical strip
(#14921 under #14910 and #14911).
The "Merged today" counter is mounted into a slot in the column header
directly above the Merge gate / ✓ columns (stageTrackerMergedCountMount),
parked in its toolbar home while the board is empty; celebrateRow and the
count draw resolve the chip through stageTrackerMergedChip() so the token
targets the new location.
Fixes #15071
Signed-off-by: Andrew Anderson <andy@clubanderson.com>
… Merged-today counter above the gate
Every lit stage pill now draws its actor icon from a server-derived
stage_actor {kind, login, since, why} (hive / clanker / human / bot /
none) instead of guessing from author_kind; a bot-authored or unowned
red 070 PR reads "Conflicting · bot PR" / "Red · nobody on it" with the
matching icon, and kind none shows no icon with a "no one is working on
this right now - why" tooltip (hivecommons/docs#500).
A PR that closes several open issues is drawn once: linked_prs entries
carry drawn_under (the PR's nested_under) and the other issues show a
"↳ #N · under #M" chip instead of a second identical strip
(#14921 under #14910 and #14911).
The "Merged today" counter is mounted into a slot in the column header
directly above the Merge gate / ✓ columns (stageTrackerMergedCountMount),
parked in its toolbar home while the board is empty; celebrateRow and the
count draw resolve the chip through stageTrackerMergedChip() so the token
targets the new location.
Fixes #15071
Signed-off-by: Andrew Anderson <andy@clubanderson.com>
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: gregoryhunt <31053269+gregoryhunt@users.noreply.github.com>
Hive-Fix-Attempt: 1/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: architect <280983584+hivecommons-hive[bot]@users.noreply.github.com>
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
…onfig Hive-Fix-Attempt: 2/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: architect <280983584+hivecommons-hive[bot]@users.noreply.github.com>
A hit inside the recheck interval asks Linear nothing and leaves checkedAt alone, so the seeded one-minute-old stamp always tripped the blanket 'refreshed within a minute' assertion. Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
Hive-Fix-Attempt: 3/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: architect <280983584+hivecommons-hive[bot]@users.noreply.github.com>
b263bcd to
380757a
Compare
|
Following the recorded decision ( hive/awaiting-ci: CI pending — sweep will merge when green. 🐝 Hive Agent: — hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
… Merged-today counter above the gate (#15074) * 🐛 Activity Monitor: server-derived stage actor icons, one row per PR, Merged-today counter above the gate Every lit stage pill now draws its actor icon from a server-derived stage_actor {kind, login, since, why} (hive / clanker / human / bot / none) instead of guessing from author_kind; a bot-authored or unowned red 070 PR reads "Conflicting · bot PR" / "Red · nobody on it" with the matching icon, and kind none shows no icon with a "no one is working on this right now - why" tooltip (hivecommons/docs#500). A PR that closes several open issues is drawn once: linked_prs entries carry drawn_under (the PR's nested_under) and the other issues show a "↳ #N · under #M" chip instead of a second identical strip (#14921 under #14910 and #14911). The "Merged today" counter is mounted into a slot in the column header directly above the Merge gate / ✓ columns (stageTrackerMergedCountMount), parked in its toolbar home while the board is empty; celebrateRow and the count draw resolve the chip through stageTrackerMergedChip() so the token targets the new location. Fixes #15071 Signed-off-by: Andrew Anderson <andy@clubanderson.com> * 🐛 Activity Monitor: drop the unused Go copy of the nobody-lead text (the SPA owns it) Signed-off-by: Andrew Anderson <andy@clubanderson.com> * 🐛 Activity Monitor: lift stageTrackerStageActor in the motion-bucket node test Signed-off-by: Andrew Anderson <andy@clubanderson.com> * 🐛 Activity Monitor: lift the stage-actor helpers in the 000-new row test after rebase Signed-off-by: Andrew Anderson <andy@clubanderson.com> --------- Signed-off-by: Andrew Anderson <andy@clubanderson.com>
There was a problem hiding this comment.
Read the diff against v5 plus the helpers it relies on. Looks correct to me; one housekeeping note for a maintainer at the end.
What I verified:
src/pkg/worksource/linear_scope.goScopeContractIssue: calls the existinglinearGraphQL(ctx, client, baseURL, apiKey, query, vars)(linear.go:492) with the same signature; the cache is guarded by the newscopeMuand a refetch error after a prior success returns the cached text rather than an error (lines ~524-532), so a Linear outage degrades to the last-known contract, not a fetch failure.LinearScopeSourcepassesFromConfig(ws, nil, "", "", logger)matching factory.go:18.src/pkg/review/prompts.goscopeContractSection:untrustedFencebuilds a fence one backtick longer than the longest run in the issue text, so tracker text cannot close the block; the state string is whitespace-collapsed and capped at 40 runes; the Linear fetch-failure branch keeps today's wording and names the identifier. The GitHub-contract branch is unchanged.src/cmd/hive/main.go:10913-10917: the Linear read runs only for a PR with no aggregate verdict at this head and no pending review, so it does not fire for PRs that will be skipped.reviewScopeFailTTL(2m) bounds retries per identifier across eval cycles.capLinearScopeTextbacks off to a rune boundary before cutting and appends an explicit truncation notice.- All checks green at
380757ac.
Housekeeping, not a defect in this change: the body says Closes #14906 / #14910 / #14911, but all three are already closed. #14906's timeline shows it closed at 2026-10-28T13:58:07Z, three seconds after #14943 merged (13:58:04Z); #14943's body contains the sentence "#14921 closed #14906 (declared) plus scanner-filed #14910/#14911", and GitHub treats closed #N as a closing keyword, so the merge of #14943 closed the part-2 tracking issue before part 2 landed. LinearScopeContractID does not exist on v5 today, so the feature is genuinely still open. @clubanderson may want to reopen #14906 (and #14910/#14911 if they were swept the same way) so they close on this PR's merge rather than appearing done now.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
Builds on #14912 (part 1 of #14906), which taught
reviewScopeContractto recognise a Linear identifier. That only names the contract: reviewers still cannot read it, becausegh issue viewcannot resolveONB-3872and reviewers deliberately hold no Linear token. So on Linear-backed repos reviewers judged against the PR author's own summary — exactly what the scope contract exists to avoid.Why this shape:
updatedAt(rechecked at most every 5 minutes) because the planner runs every eval cycle; repeated kicks for one PR cost one full fetch.Tests cover: inlined text + untrusted marker in single and combined kicks, fetch-failure fallback naming the identifier, byte-cap truncation note, and a cache hit not refetching.
Closes #14906
Closes #14910
Closes #14911
— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 requested_by=@gregoryhunt