@oss-autopilot/core 3.35.0 → 3.36.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 (37) hide show
  1. package/dist/cli-registry.js +24 -1
  2. package/dist/cli.bundle.cjs +125 -114
  3. package/dist/commands/daily.js +5 -2
  4. package/dist/commands/repo-cap.d.ts +10 -0
  5. package/dist/commands/repo-cap.js +23 -0
  6. package/dist/commands/scout-bridge.js +8 -2
  7. package/dist/commands/search.js +7 -1
  8. package/dist/commands/setup.js +6 -4
  9. package/dist/commands/vet-list.js +2 -0
  10. package/dist/commands/vet.js +2 -0
  11. package/dist/core/ci-analysis.js +14 -1
  12. package/dist/core/comment-utils.d.ts +5 -2
  13. package/dist/core/comment-utils.js +11 -3
  14. package/dist/core/config-registry.js +12 -0
  15. package/dist/core/daily-logic.d.ts +3 -1
  16. package/dist/core/daily-logic.js +11 -3
  17. package/dist/core/index.d.ts +1 -1
  18. package/dist/core/index.js +1 -1
  19. package/dist/core/pr-assembly.d.ts +11 -1
  20. package/dist/core/pr-assembly.js +21 -4
  21. package/dist/core/pr-attention.d.ts +14 -0
  22. package/dist/core/pr-attention.js +18 -0
  23. package/dist/core/pr-graphql.d.ts +31 -1
  24. package/dist/core/pr-graphql.js +49 -5
  25. package/dist/core/pr-monitor.d.ts +37 -0
  26. package/dist/core/pr-monitor.js +42 -0
  27. package/dist/core/repo-cap.d.ts +46 -0
  28. package/dist/core/repo-cap.js +102 -0
  29. package/dist/core/review-analysis.d.ts +64 -0
  30. package/dist/core/review-analysis.js +92 -1
  31. package/dist/core/state-schema.d.ts +12 -0
  32. package/dist/core/state-schema.js +9 -0
  33. package/dist/core/status-determination.js +11 -11
  34. package/dist/core/types.d.ts +32 -2
  35. package/dist/formatters/json.d.ts +25 -0
  36. package/dist/formatters/json.js +13 -0
  37. package/package.json +1 -1
@@ -6,7 +6,7 @@
6
6
  * Domain logic lives in src/core/daily-logic.ts; this file is a thin
7
7
  * orchestration layer that wires up the phases and handles I/O.
8
8
  */
9
- import { getStateManager, parseGitHubUrl, PRMonitor, IssueConversationMonitor, requireGitHubToken, renderGistWarning, CRITICAL_STATUSES, applyStatusOverrides, computeRepoSignals, groupPRsByRepo, assessCapacity, collectActionableIssues, computeActionMenu, toShelvedPRRef, formatBriefSummary, formatSummary, summarizeAttentionBuckets, } from '../core/index.js';
9
+ import { getStateManager, parseGitHubUrl, PRMonitor, IssueConversationMonitor, requireGitHubToken, renderGistWarning, CRITICAL_STATUSES, applyStatusOverrides, computeRepoSignals, groupPRsByRepo, assessCapacity, collectActionableIssues, computeActionMenu, toShelvedPRRef, formatBriefSummary, formatSummary, summarizeAttentionBuckets, shouldSuggestClose, } from '../core/index.js';
10
10
  import { errorMessage, isRateLimitOrAuthError } from '../core/errors.js';
11
11
  import { wrapUntrustedContent } from '../core/untrusted-content.js';
12
12
  import { computeStrategy, shouldComputeStrategy } from '../core/strategy.js';
@@ -492,7 +492,10 @@ function generateDigestOutput(digest, activePRs, shelvedPRs, commentedIssues, fa
492
492
  // the same buckets per-PR, so the headline counts cannot diverge.
493
493
  const attention = summarizeAttentionBuckets(activePRs);
494
494
  const briefSummary = formatBriefSummary(digest, actionableIssues.length, issueResponses.length, attention);
495
- const actionMenu = computeActionMenu(actionableIssues, capacity, filteredCommentedIssues, attention, unextractedMergeCount);
495
+ // Close candidates are usually dormant and auto-shelved, so count them over
496
+ // all open PRs (digest.openPRs includes shelved), not activePRs.
497
+ const closeSuggested = digest.openPRs.filter(shouldSuggestClose).length;
498
+ const actionMenu = computeActionMenu(actionableIssues, capacity, filteredCommentedIssues, { ...attention, closeSuggested }, unextractedMergeCount);
496
499
  const repoGroups = groupPRsByRepo(activePRs);
497
500
  // Periodic strategy snapshot (#1270 Step 2). Cadence-gated to fire every
498
501
  // 30 days OR after 5+ PRs merge since the last snapshot, whichever comes
@@ -0,0 +1,10 @@
1
+ /**
2
+ * repo-cap command: per-repo open-PR cap and excludeRepos check for one repo.
3
+ * Used by the draft-first workflow before pushing. The open-PR count is live
4
+ * from GitHub so PRs opened earlier in the same session count; merges (for
5
+ * the cold cap) come from local state.
6
+ */
7
+ import { type RepoCapStatus } from '../core/repo-cap.js';
8
+ export declare function runRepoCap(options: {
9
+ repo: string;
10
+ }): Promise<RepoCapStatus>;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * repo-cap command: per-repo open-PR cap and excludeRepos check for one repo.
3
+ * Used by the draft-first workflow before pushing. The open-PR count is live
4
+ * from GitHub so PRs opened earlier in the same session count; merges (for
5
+ * the cold cap) come from local state.
6
+ */
7
+ import { getOctokit, getStateManager, requireGitHubToken } from '../core/index.js';
8
+ import { ConfigurationError } from '../core/errors.js';
9
+ import { getRepoCapStatus } from '../core/repo-cap.js';
10
+ import { validateRepoIdentifier } from './validation.js';
11
+ export async function runRepoCap(options) {
12
+ const repo = validateRepoIdentifier(options.repo);
13
+ const state = getStateManager().getState();
14
+ const username = state.config.githubUsername;
15
+ if (!username) {
16
+ throw new ConfigurationError('githubUsername is not configured; run setup first.');
17
+ }
18
+ const { data } = await getOctokit(requireGitHubToken()).search.issuesAndPullRequests({
19
+ q: `is:pr is:open author:${username} repo:${repo}`,
20
+ per_page: 1,
21
+ });
22
+ return getRepoCapStatus(state, repo, { openPRCount: data.total_count });
23
+ }
@@ -2,6 +2,7 @@
2
2
  * Bridge between oss-autopilot's AgentState and oss-scout's OssScout API.
3
3
  * Maps state fields and creates scout instances for search/vet commands.
4
4
  */
5
+ import { reposAtCap } from '../core/repo-cap.js';
5
6
  import { createScout } from '@oss-scout/core';
6
7
  import { getStateManager, isLinkedPRStalled, parseGitHubUrl, requireGitHubToken } from '../core/index.js';
7
8
  import { SearchRotationSchema } from '../core/state-schema.js';
@@ -120,6 +121,11 @@ export function buildScoutState(diagnostics) {
120
121
  // count/anchorThreshold/splitRatio/broad), so preferences are the only
121
122
  // channel by which bias can reach the features path.
122
123
  const strategy = computeStrategy(state);
124
+ // Repos at the per-repo open-PR cap (core/repo-cap.ts) are excluded like
125
+ // excludeRepos, so they use no result slots or rotation entries in search
126
+ // and features, and are dropped from the affinity bias.
127
+ const cappedRepos = reposAtCap(state);
128
+ const cappedSet = new Set(cappedRepos.map((r) => r.toLowerCase()));
123
129
  return {
124
130
  version: 1,
125
131
  // Scout 1.8.1 made this required on the inferred ScoutState type. Scout
@@ -131,7 +137,7 @@ export function buildScoutState(diagnostics) {
131
137
  languages: config.languages,
132
138
  labels: config.labels,
133
139
  scope: config.scope,
134
- excludeRepos: config.excludeRepos,
140
+ excludeRepos: [...config.excludeRepos, ...cappedRepos],
135
141
  excludeOrgs: config.excludeOrgs ?? [],
136
142
  preferredOrgs: config.preferredOrgs ?? [],
137
143
  aiPolicyBlocklist: config.aiPolicyBlocklist,
@@ -167,7 +173,7 @@ export function buildScoutState(diagnostics) {
167
173
  // command uses per-call; avoidRepos/boostIssueTypes are user settings
168
174
  // (config-registry keys); diversityRatio matches the search policy.
169
175
  preferLanguages: strategy?.recommendations.languages ?? [],
170
- preferRepos: strategy?.recommendations.repos ?? [],
176
+ preferRepos: (strategy?.recommendations.repos ?? []).filter((r) => !cappedSet.has(r.toLowerCase())),
171
177
  diversityRatio: SEARCH_DIVERSITY_RATIO,
172
178
  avoidRepos: config.avoidRepos ?? [],
173
179
  boostIssueTypes: config.boostIssueTypes ?? [],
@@ -9,6 +9,7 @@ import { gradeFromCandidate, reconcileRecommendation } from '../core/issue-gradi
9
9
  import { computeStrategy } from '../core/strategy.js';
10
10
  import { refreshStarredReposIfStale } from '../core/starred-repos.js';
11
11
  import { debug, warn } from '../core/logger.js';
12
+ import { reposAtCap as findReposAtCap } from '../core/repo-cap.js';
12
13
  import { SCOUT_ROTATION_TTL_DAYS, SEARCH_SEEN_RETENTION_DAYS } from '../core/state-prune.js';
13
14
  const MODULE = 'search';
14
15
  /**
@@ -162,7 +163,11 @@ export async function runSearch(options) {
162
163
  // not passed per-call: scout reads them from the bridge-built preferences.
163
164
  const strategy = computeStrategy(stateManager.getState());
164
165
  const preferLanguages = strategy?.recommendations.languages ?? undefined;
165
- const preferRepos = strategy?.recommendations.repos ?? undefined;
166
+ // Repos at the per-repo open-PR cap are excluded inside scout (scout-bridge)
167
+ // so they use no result slots; keep the per-call bias from pulling them back.
168
+ const reposAtCap = findReposAtCap(stateManager.getState());
169
+ const cappedSet = new Set(reposAtCap.map((r) => r.toLowerCase()));
170
+ const preferRepos = strategy?.recommendations.repos?.filter((r) => !cappedSet.has(r.toLowerCase()));
166
171
  if (preferLanguages?.length || preferRepos?.length) {
167
172
  debug(MODULE, `Applying strategy bias to search: preferLanguages=${JSON.stringify(preferLanguages ?? [])}, preferRepos=${JSON.stringify(preferRepos ?? [])}`);
168
173
  }
@@ -276,6 +281,7 @@ export async function runSearch(options) {
276
281
  excludedRepos: result.excludedRepos,
277
282
  aiPolicyBlocklist: result.aiPolicyBlocklist,
278
283
  hiddenOwnPRCount,
284
+ reposAtCap,
279
285
  };
280
286
  if (gistSyncWarning) {
281
287
  searchOutput.gistSyncWarning = gistSyncWarning;
@@ -65,10 +65,12 @@ export async function runSetup(options) {
65
65
  results[key] = value;
66
66
  break;
67
67
  }
68
- case 'maxActivePRs': {
69
- const maxPRs = parseNonNegativeInt(value, 'maxActivePRs');
70
- stateManager.updateConfig({ maxActivePRs: maxPRs });
71
- results[key] = String(maxPRs);
68
+ case 'maxActivePRs':
69
+ case 'maxOpenPRsPerRepo':
70
+ case 'maxOpenPRsColdRepo': {
71
+ const limit = parseNonNegativeInt(value, key);
72
+ stateManager.updateConfig({ [key]: limit });
73
+ results[key] = String(limit);
72
74
  break;
73
75
  }
74
76
  case 'dormantDays': {
@@ -7,6 +7,7 @@ import { adaptScoutLinkedPR, buildCandidateLinkedPR, createAutopilotScout } from
7
7
  import { runParseList, pruneIssueList } from './parse-list.js';
8
8
  import { detectIssueList } from './startup.js';
9
9
  import { computeSuccessGrade, gradeFromCandidate, reconcileRecommendation } from '../core/issue-grading.js';
10
+ import { repoCapField } from '../core/repo-cap.js';
10
11
  import { ValidationError } from '../core/errors.js';
11
12
  import { getStateManager, classifyLinkedPR, pickSnapshotFromVet, persistPickSnapshots, getOctokit, requireGitHubToken, parseGitHubUrl, verifyIssuesBatch, } from '../core/index.js';
12
13
  const UNKNOWN_GRADE = computeSuccessGrade({ avgResponseDays: null, mergeRate: null, daysSinceLastCommit: null });
@@ -238,6 +239,7 @@ export async function runVetList(options = {}) {
238
239
  ...(linkedPR && { linkedPR }),
239
240
  slmTriage: candidate.slmTriage ?? null,
240
241
  grade,
242
+ ...repoCapField(getStateManager().getState(), candidate.issue.repo),
241
243
  };
242
244
  const pick = recordPick ? pickSnapshotFromVet(vetResult, 'vet-list') : undefined;
243
245
  if (pick)
@@ -5,6 +5,7 @@
5
5
  import { adaptScoutLinkedPR, buildCandidateLinkedPR, createAutopilotScout } from './scout-bridge.js';
6
6
  import { ISSUE_URL_PATTERN, validateGitHubUrl, validateUrl } from './validation.js';
7
7
  import { gradeFromCandidate, reconcileRecommendation } from '../core/issue-grading.js';
8
+ import { repoCapField } from '../core/repo-cap.js';
8
9
  import { getStateManager, classifyLinkedPR, pickSnapshotFromVet, persistPickSnapshots } from '../core/index.js';
9
10
  /**
10
11
  * Vet a specific GitHub issue for claimability and project health.
@@ -48,6 +49,7 @@ export async function runVet(options) {
48
49
  ...(linkedPR && { linkedPR }),
49
50
  slmTriage: candidate.slmTriage ?? null,
50
51
  grade,
52
+ ...repoCapField(getStateManager().getState(), candidate.issue.repo),
51
53
  };
52
54
  const pick = pickSnapshotFromVet(output, 'vet');
53
55
  return { ...output, ...(await persistPickSnapshots(getStateManager(), pick ? [pick] : [])) };
@@ -32,8 +32,21 @@ const FORK_LIMITATION_PATTERNS = [
32
32
  /**
33
33
  * Known CI check name patterns that indicate authorization gates (#81).
34
34
  * These require maintainer approval and are not real failures.
35
+ * Label/triage gates (e.g. "check PR labels", "Check PR type labels",
36
+ * "needs-triage") are included: only maintainers can apply the labels that
37
+ * satisfy them, so the contributor has nothing to fix.
35
38
  */
36
- const AUTH_GATE_PATTERNS = [/authoriz/i, /approval/i, /\bcla\b/i, /license\/cla/i];
39
+ const AUTH_GATE_PATTERNS = [
40
+ /authoriz/i,
41
+ /approval/i,
42
+ /\bcla\b/i,
43
+ /license\/cla/i,
44
+ // Anchored to gate wording so real checks like "label-studio / build" or
45
+ // "e2e-label-tests" stay actionable.
46
+ /\b(?:pr|type|require[sd]?|check|missing)[\s-]+(?:\w+[\s-]+)?labels?\b/i,
47
+ /\blabeler\b/i,
48
+ /\btriage\b/i,
49
+ ];
37
50
  /**
38
51
  * Known CI check name patterns that indicate infrastructure/transient failures (#145).
39
52
  * These are runner issues, dependency install problems, or service outages — not code failures.
@@ -4,9 +4,12 @@
4
4
  */
5
5
  /**
6
6
  * Check if a comment author is a bot account.
7
- * Matches the [bot] suffix convention and known bot usernames (case-insensitive).
7
+ * Matches the [bot] suffix convention (GitHub Apps; the GraphQL path maps
8
+ * `__typename: 'Bot'` to it), user-account bots named `*-bot` / `*-robot`
9
+ * (e.g. `miq-bot`, `k8s-ci-robot`), known bot usernames (case-insensitive),
10
+ * and REST `user.type === 'Bot'` when the caller has it (e.g. `Copilot`).
8
11
  */
9
- export declare function isBotAuthor(author: string): boolean;
12
+ export declare function isBotAuthor(author: string, userType?: string | null): boolean;
10
13
  /**
11
14
  * Detect acknowledgment comments that don't require a response.
12
15
  * Returns true only when: no question mark, matches an acknowledgment keyword, and under 100 chars.
@@ -8,6 +8,7 @@ const KNOWN_BOT_USERNAMES = new Set([
8
8
  'changeset-bot',
9
9
  'claassistant',
10
10
  'codecov-commenter',
11
+ 'copilot',
11
12
  'greenkeeper',
12
13
  'imgbot',
13
14
  'netlify',
@@ -16,13 +17,20 @@ const KNOWN_BOT_USERNAMES = new Set([
16
17
  'sonarcloud',
17
18
  'stale',
18
19
  'vercel',
20
+ 'web-flow',
19
21
  ]);
20
22
  /**
21
23
  * Check if a comment author is a bot account.
22
- * Matches the [bot] suffix convention and known bot usernames (case-insensitive).
24
+ * Matches the [bot] suffix convention (GitHub Apps; the GraphQL path maps
25
+ * `__typename: 'Bot'` to it), user-account bots named `*-bot` / `*-robot`
26
+ * (e.g. `miq-bot`, `k8s-ci-robot`), known bot usernames (case-insensitive),
27
+ * and REST `user.type === 'Bot'` when the caller has it (e.g. `Copilot`).
23
28
  */
24
- export function isBotAuthor(author) {
25
- return author.includes('[bot]') || KNOWN_BOT_USERNAMES.has(author.toLowerCase());
29
+ export function isBotAuthor(author, userType) {
30
+ if (userType === 'Bot')
31
+ return true;
32
+ const lower = author.toLowerCase();
33
+ return (lower.includes('[bot]') || lower.endsWith('-bot') || lower.endsWith('-robot') || KNOWN_BOT_USERNAMES.has(lower));
26
34
  }
27
35
  /**
28
36
  * Detect acknowledgment comments that don't require a response.
@@ -31,6 +31,18 @@ export const CONFIG_KEY_REGISTRY = [
31
31
  settableVia: 'setup',
32
32
  valueHint: 'non-negative integer (0 = no limit)',
33
33
  },
34
+ {
35
+ key: 'maxOpenPRsPerRepo',
36
+ description: 'Discovery leaves out a repo once you have this many open PRs there, and the pre-push check warns. Default 0 (off).',
37
+ settableVia: 'setup',
38
+ valueHint: 'non-negative integer (0 = no limit)',
39
+ },
40
+ {
41
+ key: 'maxOpenPRsColdRepo',
42
+ description: 'Per-repo open-PR cap while none of your PRs in that repo have merged (default 1). Discovery leaves the repo out and the pre-push check warns. 0 disables.',
43
+ settableVia: 'setup',
44
+ valueHint: 'non-negative integer (0 = no limit)',
45
+ },
34
46
  {
35
47
  key: 'dormantDays',
36
48
  description: 'Alias for dormantThresholdDays: days of inactivity before a PR is considered dormant.',
@@ -159,5 +159,7 @@ export declare function collectActionableIssues(prs: FetchedPR[], lastDigestAt?:
159
159
  * @param unextractedMergeCount - Recently merged PRs whose learnings have not been extracted yet (#1463); non-zero adds an extract_learnings item
160
160
  * @returns Action menu with context flags for orchestration
161
161
  */
162
- export declare function computeActionMenu(actionableIssues: ActionableIssue[], capacity: CapacityAssessment, commentedIssues?: CommentedIssue[], attention?: Pick<AttentionSummary, 'stuckCI' | 'dormantFollowup'>, unextractedMergeCount?: number): ActionMenu;
162
+ export declare function computeActionMenu(actionableIssues: ActionableIssue[], capacity: CapacityAssessment, commentedIssues?: CommentedIssue[], attention?: Pick<AttentionSummary, 'stuckCI' | 'dormantFollowup'> & {
163
+ closeSuggested?: number;
164
+ }, unextractedMergeCount?: number): ActionMenu;
163
165
  export { formatActionHint, formatBriefSummary, formatSummary, printDigest } from '../commands/daily-render.js';
@@ -416,19 +416,27 @@ export function computeActionMenu(actionableIssues, capacity, commentedIssues =
416
416
  // summarizeAttentionBuckets get a menu path to workflows/dormant-pr-follow-up.md
417
417
  // instead of only a headline count. Emitted only when a bucket is non-zero,
418
418
  // so menus without stuck/dormant PRs are unchanged.
419
+ // closeSuggested (shouldSuggestClose) counts dormant PRs already pinged
420
+ // twice with no reply; they are usually auto-shelved, so they would
421
+ // otherwise never reach this menu.
419
422
  const stuckCI = attention?.stuckCI ?? 0;
420
423
  const dormantFollowup = attention?.dormantFollowup ?? 0;
421
- if (stuckCI > 0 || dormantFollowup > 0) {
424
+ const closeSuggested = attention?.closeSuggested ?? 0;
425
+ if (stuckCI > 0 || dormantFollowup > 0 || closeSuggested > 0) {
422
426
  const parts = [];
423
427
  if (stuckCI > 0)
424
428
  parts.push(`${stuckCI} stuck-CI`);
425
429
  if (dormantFollowup > 0)
426
430
  parts.push(`${dormantFollowup} dormant`);
427
- const total = stuckCI + dormantFollowup;
431
+ if (closeSuggested > 0)
432
+ parts.push(`${closeSuggested} close-candidate`);
433
+ const total = stuckCI + dormantFollowup + closeSuggested;
428
434
  items.push({
429
435
  key: 'follow_up',
430
436
  label: `Follow up on ${parts.join(' and ')} PR${total === 1 ? '' : 's'}`,
431
- description: 'Waiting PRs that may need a nudge (pending CI or no review activity)',
437
+ description: closeSuggested > 0
438
+ ? 'Waiting PRs that may need a nudge, or a close with an offer to reopen after repeated unanswered pings'
439
+ : 'Waiting PRs that may need a nudge (pending CI or no review activity)',
432
440
  });
433
441
  }
434
442
  // Extract-learnings nudge (#1463) — recently merged PRs whose ledger
@@ -24,7 +24,7 @@ export { computeContributionStats, type ContributionStats, type ComputeStatsInpu
24
24
  export { fetchPRTemplate, type PRTemplateResult } from './pr-template.js';
25
25
  export { classifyLinkedPR, isLinkedPRStalled, STALLED_PR_THRESHOLD_DAYS, type LinkedPR, type LinkedPRClassification, type LinkedPRState, } from './linked-pr-classification.js';
26
26
  export { classifyIssueAvailability, fetchIssueVerification, verifyIssuesBatch, MAX_VERIFY_CONCURRENCY, type BatchVerificationResult, type IssueAvailabilityVerdict, type IssueVerification, type LinkedPRLinkType, type VerifiedLinkedPR, type VerifyIssueParams, } from './issue-verification.js';
27
- export { classifyAttentionBucket, summarizeAttentionBuckets, STUCK_CI_THRESHOLD_DAYS, DORMANT_FOLLOWUP_THRESHOLD_DAYS, type AttentionBucket, type AttentionInput, type AttentionSummary, } from './pr-attention.js';
27
+ export { classifyAttentionBucket, summarizeAttentionBuckets, shouldSuggestClose, STUCK_CI_THRESHOLD_DAYS, DORMANT_FOLLOWUP_THRESHOLD_DAYS, type AttentionBucket, type AttentionInput, type AttentionSummary, } from './pr-attention.js';
28
28
  export { scanForAntiLLMPolicy, type AntiLLMCategory, type AntiLLMMatch, type AntiLLMScanResult, } from './anti-llm-policy.js';
29
29
  export { detectFormatters, diagnoseCIFormatterFailure, getPreferredFormatter, type DetectedFormatter, type FormatterDetectionResult, type CIFormatterDiagnosis, type FormatterName, } from './formatter-detection.js';
30
30
  export { CONFIG_KEY_REGISTRY, type ConfigKeyDef, type SettableVia, isKnownKey, getKeyDef, getSetupKeys, getConfigKeys, suggestKey, formatUnknownKeyError, } from './config-registry.js';
@@ -25,7 +25,7 @@ export { computeContributionStats } from './stats.js';
25
25
  export { fetchPRTemplate } from './pr-template.js';
26
26
  export { classifyLinkedPR, isLinkedPRStalled, STALLED_PR_THRESHOLD_DAYS, } from './linked-pr-classification.js';
27
27
  export { classifyIssueAvailability, fetchIssueVerification, verifyIssuesBatch, MAX_VERIFY_CONCURRENCY, } from './issue-verification.js';
28
- export { classifyAttentionBucket, summarizeAttentionBuckets, STUCK_CI_THRESHOLD_DAYS, DORMANT_FOLLOWUP_THRESHOLD_DAYS, } from './pr-attention.js';
28
+ export { classifyAttentionBucket, summarizeAttentionBuckets, shouldSuggestClose, STUCK_CI_THRESHOLD_DAYS, DORMANT_FOLLOWUP_THRESHOLD_DAYS, } from './pr-attention.js';
29
29
  export { scanForAntiLLMPolicy, } from './anti-llm-policy.js';
30
30
  export { detectFormatters, diagnoseCIFormatterFailure, getPreferredFormatter, } from './formatter-detection.js';
31
31
  export { CONFIG_KEY_REGISTRY, isKnownKey, getKeyDef, getSetupKeys, getConfigKeys, suggestKey, formatUnknownKeyError, } from './config-registry.js';
@@ -10,12 +10,14 @@
10
10
  * regardless of the transport used to fetch the data.
11
11
  */
12
12
  import { FetchedPR, CIStatusResult } from './types.js';
13
- import { type ReviewComment } from './review-analysis.js';
13
+ import { type ReviewComment, type ActivityEvent } from './review-analysis.js';
14
14
  /** Issue comment in the shape `checkUnrespondedComments`/`getFirstMaintainerResponseAt` read. */
15
15
  export interface AssemblyComment {
16
16
  user?: {
17
17
  login?: string;
18
+ type?: string | null;
18
19
  } | null;
20
+ author_association?: string | null;
19
21
  body?: string | null;
20
22
  created_at: string;
21
23
  }
@@ -23,7 +25,9 @@ export interface AssemblyComment {
23
25
  export interface AssemblyReview {
24
26
  user?: {
25
27
  login?: string;
28
+ type?: string | null;
26
29
  } | null;
30
+ author_association?: string | null;
27
31
  body?: string | null;
28
32
  submitted_at?: string | null;
29
33
  state?: string | null;
@@ -51,6 +55,12 @@ export interface PRSignals {
51
55
  comments: AssemblyComment[];
52
56
  reviews: AssemblyReview[];
53
57
  reviewComments: ReviewComment[];
58
+ /**
59
+ * Non-comment activity that can mark maintainer engagement: commits (by
60
+ * author and committer), force-pushes, review requests, labels. Optional;
61
+ * absent means comments/reviews alone drive the dormancy clock.
62
+ */
63
+ activityEvents?: ActivityEvent[];
54
64
  ciStatus: CIStatusResult;
55
65
  }
56
66
  /** Config subset the assembly needs — the fields `determineStatus` and comment analysis consume. */
@@ -11,7 +11,7 @@
11
11
  */
12
12
  import { daysBetween } from './dates.js';
13
13
  import { determineStatus } from './status-determination.js';
14
- import { determineReviewDecision, getLatestChangesRequestedDate, checkUnrespondedComments, getFirstMaintainerResponseAt, } from './review-analysis.js';
14
+ import { determineReviewDecision, getLatestChangesRequestedDate, checkUnrespondedComments, getFirstMaintainerResponseAt, getLastMaintainerActivity, } from './review-analysis.js';
15
15
  import { analyzeChecklist } from './checklist-analysis.js';
16
16
  import { extractMaintainerActionHints } from './maintainer-analysis.js';
17
17
  import { categorizeCIStatus, classifyFailingChecks } from './ci-analysis.js';
@@ -53,8 +53,16 @@ export async function assembleFetchedPR(signals, config, commitInfo) {
53
53
  const { hasIncompleteChecklist, checklistStats } = analyzeChecklist(signals.body || '');
54
54
  // Extract maintainer action hints from comments (delegated to maintainer-analysis module)
55
55
  const maintainerActionHints = extractMaintainerActionHints(lastMaintainerComment?.body, reviewDecision);
56
- // Calculate days since activity
57
- const daysSinceActivity = daysBetween(new Date(signals.updatedAt), new Date());
56
+ // Days since ANY activity (updatedAt). The contributor's own pings and
57
+ // rebases reset this, so it drives follow-up timing and stale-CI demotion,
58
+ // not dormancy.
59
+ const now = new Date();
60
+ const daysSinceActivity = daysBetween(new Date(signals.updatedAt), now);
61
+ // Days since the last non-contributor, non-bot activity (or PR creation).
62
+ // This drives stalenessTier so a PR the maintainers ignore goes dormant
63
+ // even while the contributor keeps pinging it.
64
+ const { lastMaintainerActivityAt, authorPingsSinceMaintainerActivity } = getLastMaintainerActivity(comments, reviews, reviewComments, signals.activityEvents ?? [], config.githubUsername, signals.createdAt);
65
+ const daysSinceMaintainerActivity = daysBetween(new Date(lastMaintainerActivityAt), now);
58
66
  // Find the date of the latest changes_requested review (delegated to review-analysis module)
59
67
  const latestChangesRequestedDate = getLatestChangesRequestedDate(reviews);
60
68
  const { status: ciStatus, failingCheckNames, failingCheckConclusions } = signals.ciStatus;
@@ -71,6 +79,7 @@ export async function assembleFetchedPR(signals, config, commitInfo) {
71
79
  hasIncompleteChecklist,
72
80
  reviewDecision,
73
81
  daysSinceActivity,
82
+ daysSinceMaintainerActivity,
74
83
  dormantThreshold: config.dormantThresholdDays,
75
84
  approachingThreshold: config.approachingDormantDays,
76
85
  latestCommitDate,
@@ -95,6 +104,9 @@ export async function assembleFetchedPR(signals, config, commitInfo) {
95
104
  updatedAt: signals.updatedAt,
96
105
  firstMaintainerResponseAt,
97
106
  daysSinceActivity,
107
+ lastMaintainerActivityAt,
108
+ daysSinceMaintainerActivity,
109
+ authorPingsSinceMaintainerActivity,
98
110
  ciStatus,
99
111
  failingCheckNames,
100
112
  classifiedChecks,
@@ -113,6 +125,11 @@ export async function assembleFetchedPR(signals, config, commitInfo) {
113
125
  // Compute display labels (#79) — delegated to display-utils module
114
126
  const { displayLabel, displayDescription } = computeDisplayLabel(pr);
115
127
  pr.displayLabel = displayLabel;
116
- pr.displayDescription = displayDescription;
128
+ // Incomplete checklist is informational, never needs_addressing on its own
129
+ // (see collectAllActionReasons); keep it visible as a note.
130
+ pr.displayDescription =
131
+ hasIncompleteChecklist && checklistStats
132
+ ? `${displayDescription} (note: checklist ${checklistStats.checked}/${checklistStats.total})`
133
+ : displayDescription;
117
134
  return pr;
118
135
  }
@@ -42,6 +42,20 @@ export type AttentionInput = Pick<FetchedPR, 'status' | 'ciStatus' | 'reviewDeci
42
42
  * diverge on what a count means.
43
43
  */
44
44
  export declare function classifyAttentionBucket(pr: AttentionInput): AttentionBucket;
45
+ /**
46
+ * Unanswered contributor pings after which a dormant PR becomes a
47
+ * close-with-offer-to-reopen candidate instead of another nudge.
48
+ */
49
+ export declare const CLOSE_SUGGESTION_MIN_PINGS = 2;
50
+ /**
51
+ * True when a PR is dormant on the maintainer clock (`stalenessTier`, which
52
+ * ignores the contributor's own activity), still waiting on the maintainer,
53
+ * and the contributor has already pinged at least
54
+ * {@link CLOSE_SUGGESTION_MIN_PINGS} times with no reply. Surfaced through
55
+ * the dormant follow-up workflow as a suggestion only; nothing is closed or
56
+ * posted automatically.
57
+ */
58
+ export declare function shouldSuggestClose(pr: Pick<FetchedPR, 'status' | 'stalenessTier' | 'authorPingsSinceMaintainerActivity'>): boolean;
45
59
  export interface AttentionSummary {
46
60
  needsAttention: number;
47
61
  stuckCI: number;
@@ -49,6 +49,24 @@ export function classifyAttentionBucket(pr) {
49
49
  }
50
50
  return 'waiting';
51
51
  }
52
+ /**
53
+ * Unanswered contributor pings after which a dormant PR becomes a
54
+ * close-with-offer-to-reopen candidate instead of another nudge.
55
+ */
56
+ export const CLOSE_SUGGESTION_MIN_PINGS = 2;
57
+ /**
58
+ * True when a PR is dormant on the maintainer clock (`stalenessTier`, which
59
+ * ignores the contributor's own activity), still waiting on the maintainer,
60
+ * and the contributor has already pinged at least
61
+ * {@link CLOSE_SUGGESTION_MIN_PINGS} times with no reply. Surfaced through
62
+ * the dormant follow-up workflow as a suggestion only; nothing is closed or
63
+ * posted automatically.
64
+ */
65
+ export function shouldSuggestClose(pr) {
66
+ return (pr.status === 'waiting_on_maintainer' &&
67
+ pr.stalenessTier === 'dormant' &&
68
+ (pr.authorPingsSinceMaintainerActivity ?? 0) >= CLOSE_SUGGESTION_MIN_PINGS);
69
+ }
52
70
  /** Count PRs per bucket — the shape both headline surfaces render from. */
53
71
  export function summarizeAttentionBuckets(prs) {
54
72
  const summary = { needsAttention: 0, stuckCI: 0, dormantFollowup: 0, waiting: 0 };
@@ -24,7 +24,7 @@
24
24
  */
25
25
  import type { Octokit } from '@octokit/rest';
26
26
  import { CIStatusResult } from './types.js';
27
- import type { ReviewComment } from './review-analysis.js';
27
+ import type { ActivityEvent, ReviewComment } from './review-analysis.js';
28
28
  import type { AssemblyComment, AssemblyReview, CommitInfo } from './pr-assembly.js';
29
29
  /** PRs per aliased GraphQL query. GitHub recommends modest batch sizes; ~10 keeps
30
30
  * each query cheap (~1 point) and well under node/complexity limits. */
@@ -39,6 +39,10 @@ export declare const THREAD_COMMENTS_CAP = 20;
39
39
  * contexts than this is sent to REST so a failing check beyond the cap can't be
40
40
  * silently dropped and mislabel the PR as passing. */
41
41
  export declare const CI_CONTEXTS_CAP = 100;
42
+ /** Newest timeline events (commits, force-pushes, review requests, labels)
43
+ * requested per PR. Only the newest non-contributor event matters for the
44
+ * dormancy clock, so overflow is not routed to REST. */
45
+ export declare const TIMELINE_CAP = 50;
42
46
  /** A single PR to enrich. */
43
47
  export interface PRRef {
44
48
  owner: string;
@@ -64,6 +68,7 @@ export interface NormalizedPRData {
64
68
  comments: AssemblyComment[];
65
69
  reviews: AssemblyReview[];
66
70
  reviewComments: ReviewComment[];
71
+ activityEvents: ActivityEvent[];
67
72
  ciStatus: CIStatusResult;
68
73
  commitInfo: CommitInfo;
69
74
  }
@@ -79,6 +84,24 @@ interface GraphQLActor {
79
84
  login: string;
80
85
  __typename?: string;
81
86
  }
87
+ type GraphQLGitActor = {
88
+ user: {
89
+ login: string;
90
+ } | null;
91
+ } | null;
92
+ type GraphQLTimelineNode = {
93
+ __typename: 'PullRequestCommit';
94
+ commit: {
95
+ authoredDate: string | null;
96
+ committedDate: string | null;
97
+ author: GraphQLGitActor;
98
+ committer: GraphQLGitActor;
99
+ } | null;
100
+ } | {
101
+ __typename: 'HeadRefForcePushedEvent' | 'ReviewRequestedEvent' | 'LabeledEvent';
102
+ createdAt: string;
103
+ actor: GraphQLActor | null;
104
+ };
82
105
  interface GraphQLCheckRunNode {
83
106
  __typename: 'CheckRun';
84
107
  name: string;
@@ -129,6 +152,7 @@ interface GraphQLPullRequestNode {
129
152
  totalCount: number;
130
153
  nodes: Array<{
131
154
  author: GraphQLActor | null;
155
+ authorAssociation?: string | null;
132
156
  body: string | null;
133
157
  createdAt: string;
134
158
  }>;
@@ -141,6 +165,7 @@ interface GraphQLPullRequestNode {
141
165
  body: string | null;
142
166
  submittedAt: string | null;
143
167
  author: GraphQLActor | null;
168
+ authorAssociation?: string | null;
144
169
  }>;
145
170
  };
146
171
  reviewThreads: {
@@ -153,6 +178,7 @@ interface GraphQLPullRequestNode {
153
178
  body: string | null;
154
179
  createdAt: string;
155
180
  author: GraphQLActor | null;
181
+ authorAssociation?: string | null;
156
182
  replyTo: {
157
183
  databaseId: number | null;
158
184
  } | null;
@@ -168,6 +194,10 @@ interface GraphQLPullRequestNode {
168
194
  commit: GraphQLCommitNode;
169
195
  }>;
170
196
  };
197
+ /** Optional so nodes from older fixtures/producers still normalize. */
198
+ timelineItems?: {
199
+ nodes: GraphQLTimelineNode[];
200
+ } | null;
171
201
  }
172
202
  /**
173
203
  * Build a parameterized aliased GraphQL query for a batch of PRs. Owner / repo /