@oss-autopilot/core 3.37.0 → 3.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/dist/cli-registry.js +7 -4
  2. package/dist/cli.bundle.cjs +134 -127
  3. package/dist/commands/comments.js +4 -3
  4. package/dist/commands/config.js +18 -11
  5. package/dist/commands/daily-dismiss-filter.d.ts +37 -0
  6. package/dist/commands/daily-dismiss-filter.js +80 -0
  7. package/dist/commands/daily-merged-pr-notes.d.ts +27 -0
  8. package/dist/commands/daily-merged-pr-notes.js +166 -0
  9. package/dist/commands/daily-reviewed-prs.d.ts +41 -0
  10. package/dist/commands/daily-reviewed-prs.js +270 -0
  11. package/dist/commands/daily-warnings.d.ts +28 -0
  12. package/dist/commands/daily-warnings.js +37 -0
  13. package/dist/commands/daily.d.ts +22 -1
  14. package/dist/commands/daily.js +299 -108
  15. package/dist/commands/dashboard-cache.js +9 -2
  16. package/dist/commands/dashboard-data.js +40 -20
  17. package/dist/commands/dashboard-gist-sync.d.ts +9 -1
  18. package/dist/commands/dashboard-gist-sync.js +24 -3
  19. package/dist/commands/dashboard-server.js +9 -5
  20. package/dist/commands/dismiss.d.ts +25 -5
  21. package/dist/commands/dismiss.js +40 -11
  22. package/dist/commands/guidelines.js +21 -14
  23. package/dist/commands/init.js +3 -2
  24. package/dist/commands/ledger-backfill.js +4 -3
  25. package/dist/commands/move.js +9 -6
  26. package/dist/commands/overnight-push-prep.js +5 -2
  27. package/dist/commands/overnight.js +62 -24
  28. package/dist/commands/scout-bridge.js +4 -1
  29. package/dist/commands/search.js +9 -6
  30. package/dist/commands/setup.js +7 -3
  31. package/dist/commands/validation.d.ts +11 -0
  32. package/dist/commands/validation.js +38 -0
  33. package/dist/core/checklist-analysis.js +34 -0
  34. package/dist/core/closed-pr-status.d.ts +73 -0
  35. package/dist/core/closed-pr-status.js +113 -0
  36. package/dist/core/comment-decision.d.ts +10 -3
  37. package/dist/core/comment-decision.js +13 -5
  38. package/dist/core/comment-utils.d.ts +38 -1
  39. package/dist/core/comment-utils.js +124 -1
  40. package/dist/core/concurrency.d.ts +6 -0
  41. package/dist/core/concurrency.js +13 -0
  42. package/dist/core/daily-logic.d.ts +13 -1
  43. package/dist/core/daily-logic.js +59 -2
  44. package/dist/core/engaged-issues.d.ts +93 -0
  45. package/dist/core/engaged-issues.js +183 -0
  46. package/dist/core/errors.d.ts +4 -0
  47. package/dist/core/errors.js +11 -1
  48. package/dist/core/eval-report.d.ts +9 -0
  49. package/dist/core/eval-report.js +4 -0
  50. package/dist/core/gist-state-store.d.ts +5 -2
  51. package/dist/core/gist-state-store.js +7 -4
  52. package/dist/core/github-stats.d.ts +10 -0
  53. package/dist/core/github-stats.js +35 -0
  54. package/dist/core/index.d.ts +10 -5
  55. package/dist/core/index.js +9 -4
  56. package/dist/core/issue-conversation.d.ts +83 -12
  57. package/dist/core/issue-conversation.js +306 -118
  58. package/dist/core/merged-pr-notes.d.ts +192 -0
  59. package/dist/core/merged-pr-notes.js +340 -0
  60. package/dist/core/pick-snapshot.js +1 -1
  61. package/dist/core/pr-assembly.js +3 -0
  62. package/dist/core/pr-monitor.d.ts +62 -0
  63. package/dist/core/pr-monitor.js +113 -3
  64. package/dist/core/reviewed-prs-fetch.d.ts +91 -0
  65. package/dist/core/reviewed-prs-fetch.js +271 -0
  66. package/dist/core/reviewed-prs.d.ts +244 -0
  67. package/dist/core/reviewed-prs.js +380 -0
  68. package/dist/core/state-persistence.js +8 -24
  69. package/dist/core/state-schema.d.ts +6 -0
  70. package/dist/core/state-schema.js +9 -0
  71. package/dist/core/state.d.ts +106 -11
  72. package/dist/core/state.js +246 -24
  73. package/dist/core/types.d.ts +47 -0
  74. package/dist/core/urls.d.ts +13 -0
  75. package/dist/core/urls.js +16 -0
  76. package/dist/formatters/json.d.ts +186 -1
  77. package/dist/formatters/json.js +78 -0
  78. package/package.json +1 -1
@@ -190,9 +190,21 @@ export declare function collectActionableIssues(prs: FetchedPR[], lastDigestAt?:
190
190
  * @param commentedIssues - Issues with comment activity
191
191
  * @param attention - Attention bucket counts; non-zero stuck-CI / dormant-followup buckets add a follow_up item
192
192
  * @param unextractedMergeCount - Recently merged PRs whose learnings have not been extracted yet (#1463); non-zero adds an extract_learnings item
193
+ * @param closedPRStatusCount - Closed-unmerged PRs whose linked issue still needs a status update (#1863); non-zero adds a closed_pr_status item
194
+ * @param mergedPRNotesCount - Recently merged PRs carrying maintainer notes the user has not answered (#1861); non-zero adds a merged_pr_notes item
195
+ * @param reviewedPRCount - PRs the user reviewed where the author pushed or replied since (#1857); non-zero adds a review_follow_ups item
193
196
  * @returns Action menu with context flags for orchestration
194
197
  */
195
198
  export declare function computeActionMenu(actionableIssues: ActionableIssue[], capacity: CapacityAssessment, commentedIssues?: CommentedIssue[], attention?: Pick<AttentionSummary, 'stuckCI' | 'dormantFollowup'> & {
196
199
  closeSuggested?: number;
197
- }, unextractedMergeCount?: number): ActionMenu;
200
+ }, unextractedMergeCount?: number, closedPRStatusCount?: number, mergedPRNotesCount?: number, reviewedPRCount?: number): ActionMenu;
201
+ /**
202
+ * Whether a dismiss stamped at `dismissedAt` still covers the reply posted
203
+ * at `lastResponseAt`: both parse and the dismiss is not older than the
204
+ * reply. A reply newer than the dismiss resurfaces the issue, so the daily
205
+ * run and the dashboard must agree on this one comparison (#1862). An
206
+ * unreadable stamp fails open (not covered), matching the daily run's
207
+ * dismiss filter.
208
+ */
209
+ export declare function isCoveredByDismiss(dismissedAt: string, lastResponseAt: string): boolean;
198
210
  export { formatActionHint, formatBriefSummary, formatSummary, printDigest } from '../commands/daily-render.js';
@@ -487,9 +487,12 @@ export function collectActionableIssues(prs, lastDigestAt) {
487
487
  * @param commentedIssues - Issues with comment activity
488
488
  * @param attention - Attention bucket counts; non-zero stuck-CI / dormant-followup buckets add a follow_up item
489
489
  * @param unextractedMergeCount - Recently merged PRs whose learnings have not been extracted yet (#1463); non-zero adds an extract_learnings item
490
+ * @param closedPRStatusCount - Closed-unmerged PRs whose linked issue still needs a status update (#1863); non-zero adds a closed_pr_status item
491
+ * @param mergedPRNotesCount - Recently merged PRs carrying maintainer notes the user has not answered (#1861); non-zero adds a merged_pr_notes item
492
+ * @param reviewedPRCount - PRs the user reviewed where the author pushed or replied since (#1857); non-zero adds a review_follow_ups item
490
493
  * @returns Action menu with context flags for orchestration
491
494
  */
492
- export function computeActionMenu(actionableIssues, capacity, commentedIssues = [], attention, unextractedMergeCount) {
495
+ export function computeActionMenu(actionableIssues, capacity, commentedIssues = [], attention, unextractedMergeCount, closedPRStatusCount = 0, mergedPRNotesCount = 0, reviewedPRCount = 0) {
493
496
  const issueResponses = commentedIssues.filter((i) => i.status === 'new_response');
494
497
  const items = [];
495
498
  const hasActionableIssues = actionableIssues.length > 0;
@@ -511,7 +514,7 @@ export function computeActionMenu(actionableIssues, capacity, commentedIssues =
511
514
  items.push({
512
515
  key: 'issue_replies',
513
516
  label: `Review ${issueResponses.length} issue repl${issueResponses.length === 1 ? 'y' : 'ies'}`,
514
- description: 'Maintainers responded to your comments on issues',
517
+ description: 'Replies on issues you commented on or are working on',
515
518
  });
516
519
  }
517
520
  // Follow-up nudges (#1462) — the stuck_ci / dormant_followup buckets from
@@ -553,6 +556,45 @@ export function computeActionMenu(actionableIssues, capacity, commentedIssues =
553
556
  description: 'Distill maintainer review feedback into per-repo contribution guidelines',
554
557
  });
555
558
  }
559
+ // Closed-PR status nudge (#1863) — the user's PR closed without merge and
560
+ // the linked issue has heard nothing from them since. Routes to
561
+ // workflows/closed-pr-status-update.md, which drafts the comment through
562
+ // draft-review-post; nothing posts automatically. Self-clears once the
563
+ // user comments on the issue or the PR leaves the recently-closed window.
564
+ if (closedPRStatusCount > 0) {
565
+ items.push({
566
+ key: 'closed_pr_status',
567
+ label: `Post status update on linked issue${closedPRStatusCount === 1 ? '' : 's'} (${closedPRStatusCount})`,
568
+ description: 'Your PR closed without merge; tell the issue what you found and whether you are stepping away',
569
+ });
570
+ }
571
+ // Merged-PR notes (#1861) — a maintainer thanked the user or explained a
572
+ // change at merge time and nobody answered. Routes to
573
+ // workflows/merged-pr-notes.md, which classifies each note and drafts the
574
+ // reply through draft-review-post; nothing posts automatically. Self-clears
575
+ // once the user comments on the PR, dismisses its URL, or the PR leaves
576
+ // the recently-merged window.
577
+ if (mergedPRNotesCount > 0) {
578
+ items.push({
579
+ key: 'merged_pr_notes',
580
+ label: `Merged PR${mergedPRNotesCount === 1 ? '' : 's'} with maintainer notes (${mergedPRNotesCount})`,
581
+ description: 'Maintainers left thanks or a follow-up note at merge; draft a short acknowledgment or reply',
582
+ });
583
+ }
584
+ // Review follow-ups (#1857) — a PR the user reviewed (not authored) where
585
+ // the author pushed commits or replied since the user's last review or
586
+ // comment. Routes to workflows/review-follow-ups.md, which re-reviews the
587
+ // compare range (or the commit list after a rebase) through review-panel
588
+ // and drafts answers through draft-review-post; nothing posts
589
+ // automatically. Self-clears once the user reviews or comments again,
590
+ // dismisses the PR URL, or the PR closes. Never counted in capacity.
591
+ if (reviewedPRCount > 0) {
592
+ items.push({
593
+ key: 'review_follow_ups',
594
+ label: `Review follow-ups (${reviewedPRCount})`,
595
+ description: 'PRs you reviewed where the author pushed or replied since; re-review the changes and answer their questions',
596
+ });
597
+ }
556
598
  // The orchestration layer (commands/oss.md Action Menu section) may insert issue-list
557
599
  // options before the search item when a curated list is available.
558
600
  const searchItem = {
@@ -589,6 +631,21 @@ export function computeActionMenu(actionableIssues, capacity, commentedIssues =
589
631
  },
590
632
  };
591
633
  }
634
+ /**
635
+ * Whether a dismiss stamped at `dismissedAt` still covers the reply posted
636
+ * at `lastResponseAt`: both parse and the dismiss is not older than the
637
+ * reply. A reply newer than the dismiss resurfaces the issue, so the daily
638
+ * run and the dashboard must agree on this one comparison (#1862). An
639
+ * unreadable stamp fails open (not covered), matching the daily run's
640
+ * dismiss filter.
641
+ */
642
+ export function isCoveredByDismiss(dismissedAt, lastResponseAt) {
643
+ const dismissedMs = Date.parse(dismissedAt);
644
+ const responseMs = Date.parse(lastResponseAt);
645
+ if (Number.isNaN(dismissedMs) || Number.isNaN(responseMs))
646
+ return false;
647
+ return dismissedMs >= responseMs;
648
+ }
592
649
  // ---------------------------------------------------------------------------
593
650
  // Rendering re-exports (back-compat)
594
651
  // ---------------------------------------------------------------------------
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Engaged issues (#1862): the issues the user is working on, as opposed to
3
+ * ones they commented on in passing.
4
+ *
5
+ * An issue is engaged when the user claimed it locally (`activeIssues`,
6
+ * candidates excluded) or one of their PRs closes it through a closing
7
+ * keyword: an open PR, a recently closed or merged PR, or a merged/closed
8
+ * ledger entry no older than {@link LEDGER_LINK_MAX_AGE_DAYS}. Plain
9
+ * mentions in a PR body ("similar to #12", "see #4 for the upstream bug") are
10
+ * not engagement: they named unrelated issues, bumped the engagement time
11
+ * past earlier maintainer replies, and ate into the direct-fetch cap.
12
+ * `IssueConversationMonitor` scans engaged issues under a wider reply rule
13
+ * (any substantive non-bot comment counts, not only maintainer or @mention
14
+ * replies) and fetches the live ones directly when the commenter search does
15
+ * not return them.
16
+ *
17
+ * Pure: builds a keyed map from the lists the daily run already holds. URLs
18
+ * are compared through `issueRefKey`, so `Org/Repo` and `org/repo`, trailing
19
+ * slashes and `#fragment`s all name the same issue.
20
+ */
21
+ import type { FetchedPR, IssueEngagement, TrackedIssue } from './types.js';
22
+ /**
23
+ * Oldest ledger link that still counts as engagement. A PR merged or closed
24
+ * longer ago than this is finished work: a comment on its issue months later
25
+ * is a new conversation, and the passing-comment rule (maintainer, @mention
26
+ * or quote reply) is the right one for it.
27
+ */
28
+ export declare const LEDGER_LINK_MAX_AGE_DAYS = 90;
29
+ /** One engaged issue, keyed for lookup against search results. */
30
+ export interface EngagedIssue extends IssueEngagement {
31
+ /** `issueRefKey` of the issue. */
32
+ key: string;
33
+ /** Canonical `https://github.com/owner/repo/issues/N` URL. */
34
+ url: string;
35
+ /**
36
+ * Whether the user claimed the issue locally, whatever `reason` says. An
37
+ * open PR outranks the claim as the reason, but a bare "any update?" on the
38
+ * issue still asks the claimant, so the monitor reads this, not `reason`.
39
+ */
40
+ claimed: boolean;
41
+ /**
42
+ * Fetch the issue directly when the comment search misses it. True for
43
+ * live engagements (claims, open PRs, the recent closed/merged lists);
44
+ * false for ledger links, which count only when the search already found
45
+ * the issue active.
46
+ */
47
+ fetchWhenMissing: boolean;
48
+ }
49
+ /** A closed or merged PR with its issue link, from the digest lists or the ledger. */
50
+ export interface EngagedPRLink {
51
+ url: string;
52
+ /** Issue the PR closes via a closing keyword. */
53
+ issueUrl?: string;
54
+ /** When the PR was opened; optional on older ledger entries. */
55
+ openedAt?: string;
56
+ }
57
+ /** Everything the daily run knows about the user's claims and PRs. */
58
+ export interface EngagedIssuesInput {
59
+ /** Local claims; `updatedAt` is the claim stamp (see `StateManager.addIssue`). `candidate` entries are not claims. */
60
+ claims: readonly Pick<TrackedIssue, 'url' | 'updatedAt' | 'status'>[];
61
+ /** Open PRs; only the closing link (`issueUrl`) is engagement, not body mentions. */
62
+ openPRs: readonly Pick<FetchedPR, 'url' | 'issueUrl' | 'createdAt'>[];
63
+ recentlyClosedPRs: readonly (EngagedPRLink & {
64
+ closedAt: string;
65
+ })[];
66
+ recentlyMergedPRs: readonly (EngagedPRLink & {
67
+ mergedAt: string;
68
+ })[];
69
+ ledgerClosedPRs: readonly (EngagedPRLink & {
70
+ closedAt: string;
71
+ })[];
72
+ ledgerMergedPRs: readonly (EngagedPRLink & {
73
+ mergedAt: string;
74
+ })[];
75
+ }
76
+ export interface CollectEngagedIssuesOptions {
77
+ /** Reference time for the ledger age bound; defaults to now. */
78
+ now?: Date;
79
+ }
80
+ /**
81
+ * Collect the user's engaged issues, keyed by `issueRefKey`. When several
82
+ * engagements name one issue, the entry keeps the strongest reason (and its
83
+ * PR), the latest `since`, is `claimed` if any engagement is a claim, and
84
+ * fetches directly if any engagement is live.
85
+ * Links that do not parse as GitHub URLs, or that name one of the user's own
86
+ * PRs, are skipped. Iteration order is strongest-reason first (engagements
87
+ * are visited in that order, so an issue is inserted at its strongest
88
+ * reason's position), so a caller that caps direct fetches keeps the open-PR
89
+ * and claim issues.
90
+ */
91
+ export declare function collectEngagedIssues(input: EngagedIssuesInput, options?: CollectEngagedIssuesOptions): Map<string, EngagedIssue>;
92
+ /** The `IssueEngagement` projection of an engaged issue, for the digest entry. */
93
+ export declare function toIssueEngagement({ reason, prUrl, since }: EngagedIssue): IssueEngagement;
@@ -0,0 +1,183 @@
1
+ /**
2
+ * Engaged issues (#1862): the issues the user is working on, as opposed to
3
+ * ones they commented on in passing.
4
+ *
5
+ * An issue is engaged when the user claimed it locally (`activeIssues`,
6
+ * candidates excluded) or one of their PRs closes it through a closing
7
+ * keyword: an open PR, a recently closed or merged PR, or a merged/closed
8
+ * ledger entry no older than {@link LEDGER_LINK_MAX_AGE_DAYS}. Plain
9
+ * mentions in a PR body ("similar to #12", "see #4 for the upstream bug") are
10
+ * not engagement: they named unrelated issues, bumped the engagement time
11
+ * past earlier maintainer replies, and ate into the direct-fetch cap.
12
+ * `IssueConversationMonitor` scans engaged issues under a wider reply rule
13
+ * (any substantive non-bot comment counts, not only maintainer or @mention
14
+ * replies) and fetches the live ones directly when the commenter search does
15
+ * not return them.
16
+ *
17
+ * Pure: builds a keyed map from the lists the daily run already holds. URLs
18
+ * are compared through `issueRefKey`, so `Org/Repo` and `org/repo`, trailing
19
+ * slashes and `#fragment`s all name the same issue.
20
+ */
21
+ import { issueRefKey, parseGitHubUrl } from './urls.js';
22
+ const REASON_RANK = { open_pr: 0, claim: 1, closed_pr: 2, merged_pr: 3 };
23
+ /**
24
+ * Oldest ledger link that still counts as engagement. A PR merged or closed
25
+ * longer ago than this is finished work: a comment on its issue months later
26
+ * is a new conversation, and the passing-comment rule (maintainer, @mention
27
+ * or quote reply) is the right one for it.
28
+ */
29
+ export const LEDGER_LINK_MAX_AGE_DAYS = 90;
30
+ /** The later of two optional ISO stamps; an unreadable or missing one loses. */
31
+ function laterOf(a, b) {
32
+ const aMs = a === undefined ? NaN : Date.parse(a);
33
+ const bMs = b === undefined ? NaN : Date.parse(b);
34
+ if (Number.isNaN(bMs))
35
+ return a;
36
+ if (Number.isNaN(aMs))
37
+ return b;
38
+ return bMs > aMs ? b : a;
39
+ }
40
+ /** Issues an open PR closes. */
41
+ function* openPREngagements(prs) {
42
+ for (const pr of prs) {
43
+ if (!pr.issueUrl)
44
+ continue;
45
+ yield { issueUrl: pr.issueUrl, reason: 'open_pr', prUrl: pr.url, since: pr.createdAt, fetchWhenMissing: true };
46
+ }
47
+ }
48
+ /**
49
+ * Issues closed or merged PRs link, dated by the opening time. An entry
50
+ * without one (older ledger rows) carries no `since`: the close or merge time
51
+ * is not when the user engaged, and a baseline later than the real engagement
52
+ * would hide replies, so the monitor falls back to the user's last comment.
53
+ */
54
+ function* linkedPREngagements(input, nowMs) {
55
+ const lists = [
56
+ { prs: input.recentlyClosedPRs, reason: 'closed_pr', isRecent: true },
57
+ { prs: input.recentlyMergedPRs, reason: 'merged_pr', isRecent: true },
58
+ { prs: input.ledgerClosedPRs, reason: 'closed_pr', isRecent: false },
59
+ { prs: input.ledgerMergedPRs, reason: 'merged_pr', isRecent: false },
60
+ ];
61
+ for (const { prs, reason, isRecent } of lists) {
62
+ for (const pr of prs) {
63
+ const engagement = linkedEngagement(pr, reason, isRecent, nowMs);
64
+ if (engagement)
65
+ yield engagement;
66
+ }
67
+ }
68
+ }
69
+ /**
70
+ * The engagement one finished PR carries, or undefined when it has no link or
71
+ * is too old a ledger row. `isRecent` marks the digest's recent lists, which
72
+ * are fetched directly when the search misses them; ledger rows are not.
73
+ */
74
+ function linkedEngagement(pr, reason, isRecent, nowMs) {
75
+ if (!pr.issueUrl)
76
+ return undefined;
77
+ if (!isRecent && !isWithinLedgerBound(pr, nowMs))
78
+ return undefined;
79
+ return { reason, issueUrl: pr.issueUrl, prUrl: pr.url, since: pr.openedAt, fetchWhenMissing: isRecent };
80
+ }
81
+ function isWithinLedgerBound(pr, nowMs) {
82
+ const endedMs = Date.parse('closedAt' in pr ? pr.closedAt : pr.mergedAt);
83
+ return !Number.isNaN(endedMs) && nowMs - endedMs <= LEDGER_LINK_MAX_AGE_DAYS * 24 * 60 * 60 * 1000;
84
+ }
85
+ /** Every engagement, strongest reason first. */
86
+ function* engagements(input, nowMs) {
87
+ yield* openPREngagements(input.openPRs);
88
+ for (const claim of input.claims) {
89
+ if (claim.status === 'candidate')
90
+ continue;
91
+ yield { issueUrl: claim.url, reason: 'claim', since: claim.updatedAt, fetchWhenMissing: true };
92
+ }
93
+ yield* linkedPREngagements(input, nowMs);
94
+ }
95
+ /**
96
+ * Keys of the user's own PRs. A closing keyword can name one of them
97
+ * ("closes #50" on a follow-up to PR #50); that is not an issue, and fetching
98
+ * it would spend one of the capped direct lookups to learn so.
99
+ */
100
+ function ownPRKeys(input) {
101
+ const keys = new Set();
102
+ const lists = [
103
+ input.openPRs,
104
+ input.recentlyClosedPRs,
105
+ input.recentlyMergedPRs,
106
+ input.ledgerClosedPRs,
107
+ input.ledgerMergedPRs,
108
+ ];
109
+ for (const prs of lists) {
110
+ for (const pr of prs) {
111
+ const key = issueRefKey(pr.url);
112
+ if (key)
113
+ keys.add(key);
114
+ }
115
+ }
116
+ return keys;
117
+ }
118
+ /** Fold one engagement into the map: strongest reason, latest since, claimed or fetched if any is. */
119
+ function record(byKey, engagement) {
120
+ const parsed = parseGitHubUrl(engagement.issueUrl);
121
+ const key = issueRefKey(engagement.issueUrl);
122
+ if (!parsed || !key)
123
+ return;
124
+ const isClaim = engagement.reason === 'claim';
125
+ const current = byKey.get(key);
126
+ if (!current) {
127
+ byKey.set(key, {
128
+ key,
129
+ url: `https://github.com/${parsed.owner}/${parsed.repo}/issues/${parsed.number}`,
130
+ reason: engagement.reason,
131
+ ...(engagement.prUrl !== undefined && { prUrl: engagement.prUrl }),
132
+ ...(engagement.since !== undefined && { since: engagement.since }),
133
+ claimed: isClaim,
134
+ fetchWhenMissing: engagement.fetchWhenMissing,
135
+ });
136
+ return;
137
+ }
138
+ current.claimed ||= isClaim;
139
+ if (REASON_RANK[engagement.reason] < REASON_RANK[current.reason]) {
140
+ current.reason = engagement.reason;
141
+ if (engagement.prUrl === undefined)
142
+ delete current.prUrl;
143
+ else
144
+ current.prUrl = engagement.prUrl;
145
+ }
146
+ const since = laterOf(current.since, engagement.since);
147
+ if (since === undefined)
148
+ delete current.since;
149
+ else
150
+ current.since = since;
151
+ current.fetchWhenMissing ||= engagement.fetchWhenMissing;
152
+ }
153
+ /**
154
+ * Collect the user's engaged issues, keyed by `issueRefKey`. When several
155
+ * engagements name one issue, the entry keeps the strongest reason (and its
156
+ * PR), the latest `since`, is `claimed` if any engagement is a claim, and
157
+ * fetches directly if any engagement is live.
158
+ * Links that do not parse as GitHub URLs, or that name one of the user's own
159
+ * PRs, are skipped. Iteration order is strongest-reason first (engagements
160
+ * are visited in that order, so an issue is inserted at its strongest
161
+ * reason's position), so a caller that caps direct fetches keeps the open-PR
162
+ * and claim issues.
163
+ */
164
+ export function collectEngagedIssues(input, options = {}) {
165
+ const nowMs = (options.now ?? new Date()).getTime();
166
+ const ownPRs = ownPRKeys(input);
167
+ const byKey = new Map();
168
+ for (const engagement of engagements(input, nowMs)) {
169
+ const key = issueRefKey(engagement.issueUrl);
170
+ if (key !== null && ownPRs.has(key))
171
+ continue;
172
+ record(byKey, engagement);
173
+ }
174
+ return byKey;
175
+ }
176
+ /** The `IssueEngagement` projection of an engaged issue, for the digest entry. */
177
+ export function toIssueEngagement({ reason, prUrl, since }) {
178
+ return {
179
+ reason,
180
+ ...(prUrl !== undefined && { prUrl }),
181
+ ...(since !== undefined && { since }),
182
+ };
183
+ }
@@ -114,6 +114,10 @@ export declare function errorMessage(e: unknown): string;
114
114
  * Returns undefined if the error doesn't have a numeric `status` property.
115
115
  */
116
116
  export declare function getHttpStatusCode(error: unknown): number | undefined;
117
+ /** `HTTP 404` when the error carries a status, else undefined. */
118
+ export declare function httpStatusLabel(error: unknown): string | undefined;
119
+ /** Warning text with the HTTP status in front when there is one (`HTTP 502: Bad Gateway`). */
120
+ export declare function describeError(error: unknown): string;
117
121
  /** Check if an error is a GitHub rate limit error (429 or rate-limit 403). */
118
122
  export declare function isRateLimitError(error: unknown): boolean;
119
123
  /**
@@ -133,7 +133,7 @@ export class GistConcurrencyError extends OssAutopilotError {
133
133
  remoteEtag;
134
134
  constructor(expectedEtag, remoteEtag) {
135
135
  super('Another machine pushed to the state Gist while this push was in flight, and the merge attempt also collided. ' +
136
- 'Re-run `oss-autopilot state --sync` to retry — your local mutations are still in memory.', 'CONCURRENCY_ERROR');
136
+ 'Your local mutations are still in memory, but `state --sync` cannot merge them: re-run the command that made the change.', 'CONCURRENCY_ERROR');
137
137
  this.expectedEtag = expectedEtag;
138
138
  this.remoteEtag = remoteEtag;
139
139
  this.name = 'GistConcurrencyError';
@@ -174,6 +174,16 @@ export function getHttpStatusCode(error) {
174
174
  }
175
175
  return undefined;
176
176
  }
177
+ /** `HTTP 404` when the error carries a status, else undefined. */
178
+ export function httpStatusLabel(error) {
179
+ const status = getHttpStatusCode(error);
180
+ return status === undefined ? undefined : `HTTP ${status}`;
181
+ }
182
+ /** Warning text with the HTTP status in front when there is one (`HTTP 502: Bad Gateway`). */
183
+ export function describeError(error) {
184
+ const label = httpStatusLabel(error);
185
+ return label ? `${label}: ${errorMessage(error)}` : errorMessage(error);
186
+ }
177
187
  /** Check if an error is a GitHub rate limit error (429 or rate-limit 403). */
178
188
  export function isRateLimitError(error) {
179
189
  const status = getHttpStatusCode(error);
@@ -34,6 +34,15 @@ export interface EvalReport {
34
34
  highN: number;
35
35
  lowN: number;
36
36
  };
37
+ /**
38
+ * Merged and closed PRs that close an issue, and how many of them carry a
39
+ * vet-time grade. A low share means picks skipped `vet`, so calibration
40
+ * cannot be measured.
41
+ */
42
+ vetCoverage: {
43
+ graded: number;
44
+ of: number;
45
+ };
37
46
  /** Closures as ai-policy or rejected, per close month. */
38
47
  approachClosuresByMonth: Record<string, number>;
39
48
  };
@@ -126,6 +126,7 @@ function collectRows(state) {
126
126
  return {
127
127
  url: e.url,
128
128
  repo,
129
+ issueUrl: e.issueUrl,
129
130
  firstInRepo: e.pick?.firstInRepo ?? isFirstAt(repo, Date.parse(e.openedAt ?? at)),
130
131
  pick: e.pick,
131
132
  grade: e.pick?.grade,
@@ -182,6 +183,7 @@ export function computeEvalReport(state, now = new Date()) {
182
183
  }
183
184
  }
184
185
  const picked = rows.filter((r) => r.pick);
186
+ const closesIssue = rows.filter((r) => r.issueUrl && r.outcome !== 'dormant');
185
187
  const reviewed = rows.filter((r) => r.changesRequested !== undefined);
186
188
  const ciKnown = rows.filter((r) => r.ciFailing !== undefined);
187
189
  const byGrade = groupBy(rows, (r) => (r.gradeSource ? `${r.gradeSource} ${gradeRange(r.grade)}` : 'no prediction'), [
@@ -207,6 +209,7 @@ export function computeEvalReport(state, now = new Date()) {
207
209
  headlines: {
208
210
  mergeRate1kStars: bucket('>=1k stars', rows.filter((r) => (r.stars ?? 0) >= 1000)),
209
211
  calibration: { gap, highN: high.length, lowN: low.length },
212
+ vetCoverage: { graded: closesIssue.filter((r) => r.gradeSource === 'vet').length, of: closesIssue.length },
210
213
  approachClosuresByMonth,
211
214
  },
212
215
  byGrade,
@@ -263,6 +266,7 @@ export function formatEvalMarkdown(r) {
263
266
  '',
264
267
  `- Merge rate on repos with 1k+ stars: **${pct(h.mergeRate1kStars.mergeRate)}** (n=${h.mergeRate1kStars.n})`,
265
268
  `- Calibration gap, vet grades (grade>=7 minus grade<=5 merge rate): **${h.calibration.gap ?? 'n/a'}** (n=${h.calibration.highN} vs ${h.calibration.lowN}; needs ${MIN_FLAG_N} each)`,
269
+ `- Vet grade recorded at pick: **${h.vetCoverage.graded} of ${h.vetCoverage.of}** merged or closed PRs that close an issue`,
266
270
  `- Approach or AI-policy closures by month: ${recentMonths.length ? recentMonths.map((m) => `${m}: ${h.approachClosuresByMonth[m]}`).join(', ') : 'none'}`,
267
271
  `- Overall: ${r.totals.n} outcomes, merge rate ${pct(r.totals.mergeRate)} (dormant counted as not merged)`,
268
272
  '',
@@ -271,10 +271,13 @@ export declare class GistStateStore {
271
271
  * outcomes that previously collapsed into a single boolean (#1209 L9):
272
272
  * - `{ status: 'refreshed' }` — fresh data loaded successfully.
273
273
  * - `{ status: 'no-gist' }` — store not in Gist mode (e.g. degraded).
274
- * - `{ status: 'throttled', sinceLastMs }` — within the 30s throttle.
274
+ * - `{ status: 'throttled', sinceLastMs }` — within the 30s throttle
275
+ * (skipped when `options.force` is set).
275
276
  * - `{ status: 'error', error }` — fetch attempt failed.
276
277
  */
277
- refreshFromGist(): Promise<RefreshResult>;
278
+ refreshFromGist(options?: {
279
+ force?: boolean;
280
+ }): Promise<RefreshResult>;
278
281
  /**
279
282
  * Refuse to write a file the Gist could no longer serve back (raw_url stops
280
283
  * at 10 MB), and warn once a file passes ~900 KB so growth is visible before
@@ -577,17 +577,20 @@ export class GistStateStore {
577
577
  * outcomes that previously collapsed into a single boolean (#1209 L9):
578
578
  * - `{ status: 'refreshed' }` — fresh data loaded successfully.
579
579
  * - `{ status: 'no-gist' }` — store not in Gist mode (e.g. degraded).
580
- * - `{ status: 'throttled', sinceLastMs }` — within the 30s throttle.
580
+ * - `{ status: 'throttled', sinceLastMs }` — within the 30s throttle
581
+ * (skipped when `options.force` is set).
581
582
  * - `{ status: 'error', error }` — fetch attempt failed.
582
583
  */
583
- async refreshFromGist() {
584
+ async refreshFromGist(options = {}) {
584
585
  if (!this.gistId)
585
586
  return { status: 'no-gist' };
586
587
  const now = Date.now();
587
588
  const sinceLastMs = now - this.lastRefreshAt;
588
589
  // Throttle hits are not failures — preserve any previous lastRefreshError
589
- // for the caller to inspect.
590
- if (sinceLastMs < GistStateStore.REFRESH_THROTTLE_MS) {
590
+ // for the caller to inspect. `force` bypasses the throttle for the
591
+ // conflict-recovery path: a retry that re-reads the same stale baseline
592
+ // fails identically (audit 2026-10-30 M1).
593
+ if (sinceLastMs < GistStateStore.REFRESH_THROTTLE_MS && !options.force) {
591
594
  return { status: 'throttled', sinceLastMs };
592
595
  }
593
596
  // Stamp the ATTEMPT, success or failure (#1443): the success-only stamp
@@ -15,6 +15,16 @@ export declare const PR_COUNTS_CACHE_TTL_MS: number;
15
15
  * first. Switch to GraphQL `closingIssuesReferences` if that ever matters.
16
16
  */
17
17
  export declare function closingIssueUrl(body: string | null | undefined, prUrl: string): string | undefined;
18
+ /**
19
+ * Every issue or PR a PR's title and body mention (#1863), as canonical issue
20
+ * URLs (`https://github.com/owner/repo/issues/N`). Issues and PRs share one
21
+ * number space per repo, so `/pull/N` folds into the same URL and a bare `#N`
22
+ * resolves against the PR's own repo. Unlike {@link closingIssueUrl} no
23
+ * closing keyword is needed: a follow-up PR that says "supersedes #8" or
24
+ * "alternative approach for #12" links too. Deduplicated, in order of
25
+ * appearance; HTML comments and code are ignored like in `closingIssueUrl`.
26
+ */
27
+ export declare function mentionedIssueUrls(title: string | null | undefined, body: string | null | undefined, prUrl: string): string[];
18
28
  /** Return type shared by both merged and closed PR count functions. */
19
29
  export interface PRCountsResult<R> {
20
30
  repos: Map<string, R>;
@@ -37,6 +37,41 @@ export function closingIssueUrl(body, prUrl) {
37
37
  const target = m[1] ?? m[3] ?? (own && `${own.owner}/${own.repo}`);
38
38
  return target ? `https://github.com/${target}/issues/${m[2] ?? m[4]}` : undefined;
39
39
  }
40
+ /**
41
+ * A github.com issue or pull URL, rewritten to ` owner/repo#N ` before the
42
+ * mention scan so one simple pattern covers both spellings. The padding
43
+ * spaces keep the rewritten form clear of the word boundary rule below.
44
+ */
45
+ const ISSUE_URL_RE = /https:\/\/github\.com\/([\w-]+\/[\w.-]+)\/(?:issues|pull)\/(\d+)\b/g;
46
+ /**
47
+ * `owner/repo#12` or a bare `#12`, closing keyword or not. Owners are GitHub
48
+ * logins (word characters and hyphens, no dots), and the mention must not
49
+ * sit inside a word or path (`C#5`, `example.com/page#5`), mirroring
50
+ * GitHub's autolink rule.
51
+ */
52
+ const ISSUE_MENTION_RE = /(?<![\w/.-])([\w-]+\/[\w.-]+)?#(\d+)\b/g;
53
+ /**
54
+ * Every issue or PR a PR's title and body mention (#1863), as canonical issue
55
+ * URLs (`https://github.com/owner/repo/issues/N`). Issues and PRs share one
56
+ * number space per repo, so `/pull/N` folds into the same URL and a bare `#N`
57
+ * resolves against the PR's own repo. Unlike {@link closingIssueUrl} no
58
+ * closing keyword is needed: a follow-up PR that says "supersedes #8" or
59
+ * "alternative approach for #12" links too. Deduplicated, in order of
60
+ * appearance; HTML comments and code are ignored like in `closingIssueUrl`.
61
+ */
62
+ export function mentionedIssueUrls(title, body, prUrl) {
63
+ const own = extractOwnerRepo(prUrl);
64
+ const text = `${title ?? ''}\n${body?.slice(0, MAX_BODY_CHARS) ?? ''}`
65
+ .replaceAll(NON_PROSE_RE, ' ')
66
+ .replaceAll(ISSUE_URL_RE, ' $1#$2 ');
67
+ const urls = new Set();
68
+ for (const m of text.matchAll(ISSUE_MENTION_RE)) {
69
+ const target = m[1] ?? (own && `${own.owner}/${own.repo}`);
70
+ if (target)
71
+ urls.add(`https://github.com/${target}/issues/${m[2]}`);
72
+ }
73
+ return [...urls];
74
+ }
40
75
  /** Returns an empty PRCountsResult. Used as the fallback when stats fetches fail or username is empty. */
41
76
  export function emptyPRCountsResult() {
42
77
  return { repos: new Map(), monthlyCounts: {}, monthlyOpenedCounts: {}, dailyActivityCounts: {}, searchedPRs: [] };
@@ -2,16 +2,16 @@
2
2
  * Core module exports
3
3
  * Re-exports all core functionality for convenient imports
4
4
  */
5
- export { StateManager, getStateManager, getStateManagerAsync, ensureGistPersistence, bootstrapGistBestEffort, type GistPersistenceStatus, maybeCheckpoint, resetStateManager, type Stats, } from './state.js';
5
+ export { StateManager, getStateManager, getStateManagerAsync, ensureGistPersistence, bootstrapGistBestEffort, type GistPersistenceStatus, maybeCheckpoint, resetStateManager, type Stats, type ReleaseIssueResult, } from './state.js';
6
6
  export { renderGistWarning, type GistHealth, type GistHealthDegradedCause, type GistWarningCause, } from './gist-health.js';
7
7
  export { GistStateStore } from './gist-state-store.js';
8
8
  export { guidelinesFilename, repoFromGuidelinesFilename, GUIDELINES_FILE_PREFIX, GUIDELINES_MAX_BYTES, GuidelinesNotAvailableError, GuidelinesTooLargeError, } from './guidelines-store.js';
9
9
  export { PRMonitor, type PRCheckFailure, type FetchPRsResult, computeDisplayLabel, classifyCICheck, classifyFailingChecks, } from './pr-monitor.js';
10
- export { IssueConversationMonitor } from './issue-conversation.js';
11
- export { isBotAuthor, isAcknowledgmentComment } from './comment-utils.js';
10
+ export { IssueConversationMonitor, MAX_DIRECT_ENGAGED_FETCHES, type FetchCommentedIssuesOptions, type FetchCommentedIssuesResult, } from './issue-conversation.js';
11
+ export { isBotAuthor, isAcknowledgmentComment, isReactionOnlyComment, isQuoteReplyTo, isStatusNudge, } from './comment-utils.js';
12
12
  export { wrapUntrustedContent, fenceFetchedPR, fenceFetchedPRTitles, labelGuidelinesContent, GUIDELINES_PROVENANCE_NOTE, extractFromFence, safeExtractFromFence, UNTRUSTED_OPEN_TAG_NAME, UNTRUSTED_CLOSE_TAG, type UntrustedContentMeta, } from './untrusted-content.js';
13
13
  export { getOctokit, checkRateLimit, type RateLimitInfo } from './github.js';
14
- export { parseGitHubUrl, splitRepo, isOwnRepo } from './urls.js';
14
+ export { parseGitHubUrl, issueRefKey, splitRepo, isOwnRepo } from './urls.js';
15
15
  export { daysBetween, formatRelativeTime, byDateDescending } from './dates.js';
16
16
  export { getCLIVersion, getDataDir, resolveDataDir, getStatePath, getBackupDir, getCacheDir, stateFileExists, } from './paths.js';
17
17
  export { getGitHubToken, getGitHubTokenAsync, requireGitHubToken, resetGitHubTokenCache, detectGitHubUsername, } from './auth.js';
@@ -19,8 +19,13 @@ export { DEFAULT_CONCURRENCY } from './concurrency.js';
19
19
  export { OssAutopilotError, ConfigurationError, ValidationError, GistPermissionError, ConcurrencyError, GistConcurrencyError, GistFileSizeError, GIST_FILE_SIZE_REMEDY, errorMessage, getHttpStatusCode, isRateLimitError, isRateLimitOrAuthError, nonFatalCatch, resolveErrorCode, } from './errors.js';
20
20
  export { enableDebug, isDebugEnabled, debug, info, warn, timed } from './logger.js';
21
21
  export { HttpCache, getHttpCache, cachedRequest, type CacheEntry } from './http-cache.js';
22
- export { CRITICAL_STATUSES, applyStatusOverrides, computeRepoSignals, computeLedgerRepoSignals, groupPRsByRepo, assessCapacity, collectActionableIssues, computeActionMenu, toShelvedPRRef, buildStarFilter, firstMaintainerResponseFromDigest, lastReviewStateFromDigest, formatActionHint, formatBriefSummary, formatSummary, printDigest, } from './daily-logic.js';
22
+ export { CRITICAL_STATUSES, applyStatusOverrides, computeRepoSignals, computeLedgerRepoSignals, groupPRsByRepo, assessCapacity, collectActionableIssues, computeActionMenu, isCoveredByDismiss, toShelvedPRRef, buildStarFilter, firstMaintainerResponseFromDigest, lastReviewStateFromDigest, formatActionHint, formatBriefSummary, formatSummary, printDigest, } from './daily-logic.js';
23
+ export { collectEngagedIssues, toIssueEngagement, LEDGER_LINK_MAX_AGE_DAYS, type CollectEngagedIssuesOptions, type EngagedIssue, type EngagedIssuesInput, type EngagedPRLink, } from './engaged-issues.js';
23
24
  export { computeContributionStats, type ContributionStats, type ComputeStatsInput } from './stats.js';
25
+ export { selectClosedPRStatusCandidates, toClosedPRStatusUpdate, CLOSED_PR_STATUS_WINDOW_DAYS, type ClosedPRStatusUpdate, type ClosedPRStatusCandidate, type IssueLinkedPR, } from './closed-pr-status.js';
26
+ export { collectMergedPRNotes, groupThanksOnlyAcknowledgments, isThanksOnlyNote, latestNoteAt, omitAcknowledgedViaCarrier, scanMergedPR, MERGED_PR_NOTES_PRE_MERGE_GRACE_MS, type CarrierReply, type MergedPRActivity, type MergedPRNote, type MergedPRNoteKind, type MergedPRNotes, type MergedPRScan, } from './merged-pr-notes.js';
27
+ export { scanReviewedPR, REVIEWED_PR_MAX_COMMITS, REVIEWED_PR_MAX_QUESTIONS, type ReviewedPRActivity, type ReviewedPRActivityList, type ReviewedPRActor, type ReviewedPRCommit, type ReviewedPRFollowUp, type ReviewedPRQuestion, type ReviewedPRQuestionKind, type ReviewedPRQuestionReason, type ReviewedPRRef, } from './reviewed-prs.js';
28
+ export { REVIEWED_PR_SEARCH_MAX_PAGES, type CompareStatus, type ReviewedPRSearchConfig, type ReviewedPRSearchResult, } from './reviewed-prs-fetch.js';
24
29
  export { fetchPRTemplate, type PRTemplateResult } from './pr-template.js';
25
30
  export { classifyLinkedPR, isLinkedPRStalled, STALLED_PR_THRESHOLD_DAYS, type LinkedPR, type LinkedPRClassification, type LinkedPRState, } from './linked-pr-classification.js';
26
31
  export { classifyIssueAvailability, fetchIssueVerification, verifyIssuesBatch, MAX_VERIFY_CONCURRENCY, RULED_OUT_VERDICTS, type BatchVerificationResult, type IssueAvailabilityVerdict, type IssueVerification, type LinkedPRLinkType, type VerifiedLinkedPR, type VerifyIssueParams, } from './issue-verification.js';