@oss-autopilot/core 3.35.0 → 3.37.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.
- package/dist/cli-registry.js +25 -2
- package/dist/cli.bundle.cjs +142 -118
- package/dist/commands/daily.js +21 -2
- package/dist/commands/ledger-backfill.d.ts +7 -0
- package/dist/commands/ledger-backfill.js +116 -6
- package/dist/commands/repo-cap.d.ts +10 -0
- package/dist/commands/repo-cap.js +23 -0
- package/dist/commands/scout-bridge.js +8 -2
- package/dist/commands/search.js +7 -1
- package/dist/commands/setup.js +6 -4
- package/dist/commands/vet-list.js +20 -17
- package/dist/commands/vet.js +29 -2
- package/dist/core/ci-analysis.js +14 -1
- package/dist/core/comment-utils.d.ts +5 -2
- package/dist/core/comment-utils.js +11 -3
- package/dist/core/config-registry.js +12 -0
- package/dist/core/daily-logic.d.ts +36 -1
- package/dist/core/daily-logic.js +113 -3
- package/dist/core/eval-report.d.ts +8 -0
- package/dist/core/eval-report.js +81 -4
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.js +4 -4
- package/dist/core/issue-verification.d.ts +12 -0
- package/dist/core/issue-verification.js +18 -0
- package/dist/core/pick-snapshot.d.ts +19 -2
- package/dist/core/pick-snapshot.js +27 -1
- package/dist/core/pr-assembly.d.ts +11 -1
- package/dist/core/pr-assembly.js +21 -4
- package/dist/core/pr-attention.d.ts +14 -0
- package/dist/core/pr-attention.js +18 -0
- package/dist/core/pr-graphql.d.ts +31 -1
- package/dist/core/pr-graphql.js +49 -5
- package/dist/core/pr-monitor.d.ts +37 -6
- package/dist/core/pr-monitor.js +41 -12
- package/dist/core/repo-cap.d.ts +46 -0
- package/dist/core/repo-cap.js +102 -0
- package/dist/core/repo-score-manager.d.ts +0 -13
- package/dist/core/repo-score-manager.js +0 -24
- package/dist/core/review-analysis.d.ts +98 -14
- package/dist/core/review-analysis.js +145 -25
- package/dist/core/state-schema.d.ts +58 -0
- package/dist/core/state-schema.js +37 -0
- package/dist/core/state.d.ts +8 -15
- package/dist/core/state.js +19 -24
- package/dist/core/status-determination.js +11 -11
- package/dist/core/types.d.ts +32 -2
- package/dist/formatters/json.d.ts +29 -0
- package/dist/formatters/json.js +17 -0
- package/package.json +1 -1
package/dist/commands/daily.js
CHANGED
|
@@ -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, computeLedgerRepoSignals, 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';
|
|
@@ -255,6 +255,22 @@ async function updateRepoScores(prMonitor, prs, mergedCounts, closedCounts, sear
|
|
|
255
255
|
});
|
|
256
256
|
warn(MODULE, `[CLOSED_COUNT_UPDATES_FAILED] ${closedCountFailures} of ${closedCounts.size} closed count update(s) failed.`);
|
|
257
257
|
}
|
|
258
|
+
// Ledger-derived signals, recomputed each run for every scored repo so a
|
|
259
|
+
// corrected closeReason clears hostility and repos without samples reset to null.
|
|
260
|
+
const ledgerSignals = computeLedgerRepoSignals([...stateManager.getMergedPRs(), ...stateManager.getClosedPRs()], prs);
|
|
261
|
+
for (const repo of Object.keys(stateManager.getState().repoScores)) {
|
|
262
|
+
const derived = ledgerSignals.get(repo);
|
|
263
|
+
const update = {
|
|
264
|
+
avgResponseDays: derived?.avgResponseDays ?? null,
|
|
265
|
+
signals: { hasHostileComments: derived?.hasHostileComments ?? false },
|
|
266
|
+
};
|
|
267
|
+
try {
|
|
268
|
+
stateManager.updateRepoScore(repo, update);
|
|
269
|
+
}
|
|
270
|
+
catch (error) {
|
|
271
|
+
warn(MODULE, `Failed to update ledger signals for ${repo}: ${errorMessage(error)}`);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
258
274
|
// Update repo signals from observed open PR data
|
|
259
275
|
const repoSignals = computeRepoSignals(prs);
|
|
260
276
|
let signalUpdateFailures = 0;
|
|
@@ -492,7 +508,10 @@ function generateDigestOutput(digest, activePRs, shelvedPRs, commentedIssues, fa
|
|
|
492
508
|
// the same buckets per-PR, so the headline counts cannot diverge.
|
|
493
509
|
const attention = summarizeAttentionBuckets(activePRs);
|
|
494
510
|
const briefSummary = formatBriefSummary(digest, actionableIssues.length, issueResponses.length, attention);
|
|
495
|
-
|
|
511
|
+
// Close candidates are usually dormant and auto-shelved, so count them over
|
|
512
|
+
// all open PRs (digest.openPRs includes shelved), not activePRs.
|
|
513
|
+
const closeSuggested = digest.openPRs.filter(shouldSuggestClose).length;
|
|
514
|
+
const actionMenu = computeActionMenu(actionableIssues, capacity, filteredCommentedIssues, { ...attention, closeSuggested }, unextractedMergeCount);
|
|
496
515
|
const repoGroups = groupPRsByRepo(activePRs);
|
|
497
516
|
// Periodic strategy snapshot (#1270 Step 2). Cadence-gated to fire every
|
|
498
517
|
// 30 days OR after 5+ PRs merge since the last snapshot, whichever comes
|
|
@@ -8,6 +8,12 @@
|
|
|
8
8
|
* - `openedAt` and `issueUrl` (GitHub's `closingIssuesReferences`) via
|
|
9
9
|
* batched GraphQL; each answered PR is stamped `backfilledAt` so later
|
|
10
10
|
* runs only query new entries.
|
|
11
|
+
* - `firstMaintainerResponseAt` (earliest maintainer comment or review, by
|
|
12
|
+
* the dormancy clock's rule), which feeds each repo's `avgResponseDays`.
|
|
13
|
+
* Each lookup stamps `responseRule`; entries with an older or missing rule
|
|
14
|
+
* (never looked up, or recorded under the old any-non-author rule) are
|
|
15
|
+
* re-queried once and their value overwritten. When the first page has no
|
|
16
|
+
* maintainer response, later pages are fetched (up to RESPONSE_MAX_PAGES).
|
|
11
17
|
* - `closeReason` for closed-unmerged entries, from who closed the PR and its
|
|
12
18
|
* last comments (core/close-reason.ts).
|
|
13
19
|
* - `pick` for entries with no vet-time snapshot, from the curated issue list
|
|
@@ -26,6 +32,7 @@ export interface LedgerBackfillOutput {
|
|
|
26
32
|
issueUrl: number;
|
|
27
33
|
closeReason: number;
|
|
28
34
|
pick: number;
|
|
35
|
+
firstMaintainerResponseAt: number;
|
|
29
36
|
};
|
|
30
37
|
/** Curated-list files scanned for vet scores. */
|
|
31
38
|
listFiles: string[];
|
|
@@ -8,6 +8,12 @@
|
|
|
8
8
|
* - `openedAt` and `issueUrl` (GitHub's `closingIssuesReferences`) via
|
|
9
9
|
* batched GraphQL; each answered PR is stamped `backfilledAt` so later
|
|
10
10
|
* runs only query new entries.
|
|
11
|
+
* - `firstMaintainerResponseAt` (earliest maintainer comment or review, by
|
|
12
|
+
* the dormancy clock's rule), which feeds each repo's `avgResponseDays`.
|
|
13
|
+
* Each lookup stamps `responseRule`; entries with an older or missing rule
|
|
14
|
+
* (never looked up, or recorded under the old any-non-author rule) are
|
|
15
|
+
* re-queried once and their value overwritten. When the first page has no
|
|
16
|
+
* maintainer response, later pages are fetched (up to RESPONSE_MAX_PAGES).
|
|
11
17
|
* - `closeReason` for closed-unmerged entries, from who closed the PR and its
|
|
12
18
|
* last comments (core/close-reason.ts).
|
|
13
19
|
* - `pick` for entries with no vet-time snapshot, from the curated issue list
|
|
@@ -23,6 +29,7 @@ import { classifyCloseReason, classifySelfClose } from '../core/close-reason.js'
|
|
|
23
29
|
import { errorMessage, isRateLimitOrAuthError } from '../core/errors.js';
|
|
24
30
|
import { getOctokit, requireGitHubToken, getStateManager, parseGitHubUrl } from '../core/index.js';
|
|
25
31
|
import { isGraphqlRateLimited } from '../core/pr-graphql.js';
|
|
32
|
+
import { getFirstMaintainerResponseAt, MAINTAINER_RESPONSE_RULE } from '../core/review-analysis.js';
|
|
26
33
|
import { maybeCheckpoint } from '../core/state.js';
|
|
27
34
|
import { detectIssueListPath } from './locate-issue-list.js';
|
|
28
35
|
import { findListEntryUrlByPrUrl } from './merge-loop.js';
|
|
@@ -30,12 +37,101 @@ import { parseIssueList } from './parse-list.js';
|
|
|
30
37
|
const BATCH_SIZE = 40;
|
|
31
38
|
/** The curated list keeps issues scored at least this (see /oss-search's score filter). */
|
|
32
39
|
const LIST_KEEP_SCORE = 6;
|
|
40
|
+
/** Comments and reviews fetched per page when looking for the first maintainer response. */
|
|
41
|
+
const RESPONSE_PAGE_SIZE = 10;
|
|
42
|
+
/**
|
|
43
|
+
* Pages of each scanned before a PR is recorded as unanswered.
|
|
44
|
+
* ponytail: a PR with 50+ non-maintainer comments and reviews before the
|
|
45
|
+
* first maintainer reply reads as unanswered; raise this if that shows up.
|
|
46
|
+
*/
|
|
47
|
+
const RESPONSE_MAX_PAGES = 5;
|
|
48
|
+
const responseSelection = (isPaged) => `
|
|
49
|
+
firstComments: comments(first: ${RESPONSE_PAGE_SIZE}${isPaged ? `, after: $c` : ''}) {
|
|
50
|
+
pageInfo { hasNextPage endCursor } nodes { author { __typename login } authorAssociation createdAt } }
|
|
51
|
+
reviews(first: ${RESPONSE_PAGE_SIZE}${isPaged ? `, after: $rc` : ''}) {
|
|
52
|
+
pageInfo { hasNextPage endCursor } nodes { author { __typename login } submittedAt } }`;
|
|
33
53
|
const PR_FIELDS = `
|
|
34
54
|
createdAt
|
|
35
55
|
author { __typename login }
|
|
36
56
|
closingIssuesReferences(first: 1) { nodes { url } }
|
|
37
57
|
timelineItems(itemTypes: [CLOSED_EVENT], last: 1) { nodes { ... on ClosedEvent { actor { __typename login } } } }
|
|
38
|
-
comments(last: 5) { nodes { author { __typename login } body } }`;
|
|
58
|
+
comments(last: 5) { nodes { author { __typename login } body } }${responseSelection(false)}`;
|
|
59
|
+
const MORE_RESPONSES_QUERY = `query($o: String!, $r: String!, $n: Int!, $c: String, $rc: String) {
|
|
60
|
+
repository(owner: $o, name: $r) { pullRequest(number: $n) {${responseSelection(true)}} } }`;
|
|
61
|
+
/** GraphQL actor in the REST `user` shape; `type: 'Bot'` lets isBotAuthor drop bots without a `[bot]` suffix. */
|
|
62
|
+
const restUser = (a) => (a ? { login: a.login, type: a.__typename } : null);
|
|
63
|
+
/** Earliest maintainer comment or review, by the same rule as live enrichment and the dormancy clock. */
|
|
64
|
+
function firstResponseAt(node) {
|
|
65
|
+
const comments = (node.firstComments?.nodes ?? [])
|
|
66
|
+
.filter((c) => c !== null)
|
|
67
|
+
.map((c) => ({ user: restUser(c.author), author_association: c.authorAssociation, created_at: c.createdAt }));
|
|
68
|
+
const reviews = (node.reviews?.nodes ?? [])
|
|
69
|
+
.filter((r) => r !== null)
|
|
70
|
+
.map((r) => ({ user: restUser(r.author), submitted_at: r.submittedAt }));
|
|
71
|
+
return node.author?.login ? getFirstMaintainerResponseAt(comments, reviews, node.author.login) : undefined;
|
|
72
|
+
}
|
|
73
|
+
const hasMore = (node) => !!(node.firstComments?.pageInfo?.hasNextPage || node.reviews?.pageInfo?.hasNextPage);
|
|
74
|
+
/** The next page of comments and reviews after the cursors `node` holds. */
|
|
75
|
+
async function fetchNextResponsePage(octokit, ref, node) {
|
|
76
|
+
const data = await octokit.graphql(MORE_RESPONSES_QUERY, {
|
|
77
|
+
o: ref.owner,
|
|
78
|
+
r: ref.repo,
|
|
79
|
+
n: ref.number,
|
|
80
|
+
c: node.firstComments?.pageInfo?.endCursor ?? null,
|
|
81
|
+
rc: node.reviews?.pageInfo?.endCursor ?? null,
|
|
82
|
+
});
|
|
83
|
+
return data.repository?.pullRequest;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* First maintainer response for `node`, fetching later comment/review pages
|
|
87
|
+
* while none is found and more exist. Returns `isPending` when a page fetch
|
|
88
|
+
* failed, so the entry is left for the next run instead of recorded as
|
|
89
|
+
* unanswered. Rate-limit and auth errors rethrow.
|
|
90
|
+
*/
|
|
91
|
+
async function resolveFirstResponse(octokit, url, node, warnings) {
|
|
92
|
+
const ref = parseGitHubUrl(url);
|
|
93
|
+
let at = firstResponseAt(node);
|
|
94
|
+
for (let page = 1; !at && ref && page < RESPONSE_MAX_PAGES && hasMore(node); page++) {
|
|
95
|
+
let more;
|
|
96
|
+
try {
|
|
97
|
+
more = await fetchNextResponsePage(octokit, ref, node);
|
|
98
|
+
}
|
|
99
|
+
catch (err) {
|
|
100
|
+
if (isRateLimitOrAuthError(err) || isGraphqlRateLimited(err))
|
|
101
|
+
throw err;
|
|
102
|
+
warnings.push(`response lookup for ${url} failed: ${errorMessage(err)}`);
|
|
103
|
+
return { isPending: true };
|
|
104
|
+
}
|
|
105
|
+
if (!more)
|
|
106
|
+
return { isPending: true };
|
|
107
|
+
// Earlier pages held no response, so only the new page matters. An
|
|
108
|
+
// exhausted connection re-queried past its last cursor comes back empty.
|
|
109
|
+
node.firstComments = more.firstComments;
|
|
110
|
+
node.reviews = more.reviews;
|
|
111
|
+
at = firstResponseAt(node);
|
|
112
|
+
}
|
|
113
|
+
return { at, isPending: false };
|
|
114
|
+
}
|
|
115
|
+
/** Record each fetched node's first response (URL -> at) in `responses`; pending lookups are left out. */
|
|
116
|
+
async function resolveResponses(octokit, nodes, responses, warnings) {
|
|
117
|
+
if (!nodes)
|
|
118
|
+
return;
|
|
119
|
+
for (const [url, node] of nodes) {
|
|
120
|
+
const { at, isPending } = await resolveFirstResponse(octokit, url, node, warnings);
|
|
121
|
+
if (!isPending)
|
|
122
|
+
responses.set(url, at);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/** Lookups in `responses` that found a response. */
|
|
126
|
+
function countFound(responses) {
|
|
127
|
+
let found = 0;
|
|
128
|
+
for (const at of responses.values())
|
|
129
|
+
if (at)
|
|
130
|
+
found++;
|
|
131
|
+
return found;
|
|
132
|
+
}
|
|
133
|
+
/** True when the entry's first response was never computed under the current maintainer rule. */
|
|
134
|
+
const isResponseStale = (e) => e.responseRule !== MAINTAINER_RESPONSE_RULE;
|
|
39
135
|
/** One aliased GraphQL query for a batch of PR URLs. Fatal errors rethrow; null means the batch failed outright. */
|
|
40
136
|
async function fetchBatch(octokit, urls, warnings) {
|
|
41
137
|
const varDefs = [];
|
|
@@ -135,15 +231,18 @@ export async function runLedgerBackfill(options = {}) {
|
|
|
135
231
|
if (!listPath)
|
|
136
232
|
warnings.push('no curated issue list found; list vet scores were not imported');
|
|
137
233
|
const lists = listPath ? readListFiles(listPath, warnings) : [];
|
|
138
|
-
// 1. GitHub: openedAt, closing issue, close reason,
|
|
139
|
-
// backfilled, plus
|
|
234
|
+
// 1. GitHub: openedAt, closing issue, close reason, first response, for
|
|
235
|
+
// entries not yet backfilled, plus one-time re-fetches for fields added
|
|
236
|
+
// later: selfCloseReason on self-closed entries, and firstMaintainerResponseAt
|
|
237
|
+
// on entries not looked up under the current maintainer rule.
|
|
140
238
|
const needsFetch = [
|
|
141
|
-
...stateManager.getMergedPRs().filter((e) => !e.backfilledAt),
|
|
239
|
+
...stateManager.getMergedPRs().filter((e) => !e.backfilledAt || isResponseStale(e)),
|
|
142
240
|
...stateManager
|
|
143
241
|
.getClosedPRs()
|
|
144
|
-
.filter((e) => !e.backfilledAt || (e.closeReason === 'self-closed' && !e.selfCloseReason)),
|
|
242
|
+
.filter((e) => !e.backfilledAt || isResponseStale(e) || (e.closeReason === 'self-closed' && !e.selfCloseReason)),
|
|
145
243
|
].map((e) => e.url);
|
|
146
244
|
const nodes = new Map();
|
|
245
|
+
const responses = new Map();
|
|
147
246
|
let fatal;
|
|
148
247
|
if (needsFetch.length > 0) {
|
|
149
248
|
const octokit = getOctokit(requireGitHubToken());
|
|
@@ -155,6 +254,7 @@ export async function runLedgerBackfill(options = {}) {
|
|
|
155
254
|
failedBatches++;
|
|
156
255
|
for (const [url, node] of batch ?? [])
|
|
157
256
|
nodes.set(url, node);
|
|
257
|
+
await resolveResponses(octokit, batch, responses, warnings);
|
|
158
258
|
}
|
|
159
259
|
catch (err) {
|
|
160
260
|
// Rate limit or auth: keep what earlier batches got, persist it, then rethrow.
|
|
@@ -181,7 +281,12 @@ export async function runLedgerBackfill(options = {}) {
|
|
|
181
281
|
// A vet-time snapshot (joined by addMergedPRs/addClosedPRs) beats the list
|
|
182
282
|
// score, and a list score for a different issue than the PR closes is dropped.
|
|
183
283
|
const pick = fromList && fromList.issueUrl === issueUrl && !snapshotFor(issueUrl) ? fromList : undefined;
|
|
184
|
-
return {
|
|
284
|
+
return {
|
|
285
|
+
openedAt: node?.createdAt,
|
|
286
|
+
issueUrl,
|
|
287
|
+
pick,
|
|
288
|
+
...(node && { backfilledAt: now }),
|
|
289
|
+
};
|
|
185
290
|
};
|
|
186
291
|
stateManager.batch(() => {
|
|
187
292
|
stateManager.addMergedPRs(merged.map((e) => ({ url: e.url, title: e.title, mergedAt: e.mergedAt, ...recovered(e) })));
|
|
@@ -201,6 +306,9 @@ export async function runLedgerBackfill(options = {}) {
|
|
|
201
306
|
const selfCloseReason = context && (e.closeReason ?? closeReason) === 'self-closed' ? classifySelfClose(context) : undefined;
|
|
202
307
|
return { url: e.url, title: e.title, closedAt: e.closedAt, ...recovered(e), closeReason, selfCloseReason };
|
|
203
308
|
}));
|
|
309
|
+
// Overwrite, not fill-missing: a value recorded under an older rule is replaced.
|
|
310
|
+
for (const [url, at] of responses)
|
|
311
|
+
stateManager.setLedgerResponse(url, at, MAINTAINER_RESPONSE_RULE);
|
|
204
312
|
});
|
|
205
313
|
const after = countFilled([...stateManager.getMergedPRs(), ...stateManager.getClosedPRs()]);
|
|
206
314
|
const gistSyncWarning = await maybeCheckpoint(stateManager, 'ledger-backfill');
|
|
@@ -213,6 +321,8 @@ export async function runLedgerBackfill(options = {}) {
|
|
|
213
321
|
issueUrl: after.issueUrl - before.issueUrl,
|
|
214
322
|
closeReason: after.closeReason - before.closeReason,
|
|
215
323
|
pick: after.pick - before.pick,
|
|
324
|
+
// Lookups that found a response (overwrites included), not a before/after delta.
|
|
325
|
+
firstMaintainerResponseAt: countFound(responses),
|
|
216
326
|
},
|
|
217
327
|
listFiles: lists.map((l) => l.file),
|
|
218
328
|
unresolved: needsFetch.length - nodes.size,
|
|
@@ -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 ?? [],
|
package/dist/commands/search.js
CHANGED
|
@@ -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
|
-
|
|
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;
|
package/dist/commands/setup.js
CHANGED
|
@@ -65,10 +65,12 @@ export async function runSetup(options) {
|
|
|
65
65
|
results[key] = value;
|
|
66
66
|
break;
|
|
67
67
|
}
|
|
68
|
-
case 'maxActivePRs':
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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,8 +7,9 @@ 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
|
-
import { getStateManager, classifyLinkedPR, pickSnapshotFromVet, persistPickSnapshots, getOctokit, requireGitHubToken, parseGitHubUrl, verifyIssuesBatch, } from '../core/index.js';
|
|
12
|
+
import { getStateManager, classifyLinkedPR, pickSnapshotFromVet, persistPickSnapshots, traitsFromVerification, isFirstInRepo, getOctokit, requireGitHubToken, parseGitHubUrl, verifyIssuesBatch, RULED_OUT_VERDICTS, } from '../core/index.js';
|
|
12
13
|
const UNKNOWN_GRADE = computeSuccessGrade({ avgResponseDays: null, mergeRate: null, daysSinceLastCommit: null });
|
|
13
14
|
const KNOWN_SKIP_REASONS = new Set([
|
|
14
15
|
'issue_closed',
|
|
@@ -118,12 +119,6 @@ export function listStatusFromVerdict(verdict) {
|
|
|
118
119
|
}
|
|
119
120
|
}
|
|
120
121
|
}
|
|
121
|
-
/**
|
|
122
|
-
* Verdicts that conclusively rule an issue out as a new opportunity. For these
|
|
123
|
-
* we skip scout's grade/health vet entirely — there is nothing to grade — and
|
|
124
|
-
* build the result row straight from the verification.
|
|
125
|
-
*/
|
|
126
|
-
const RULED_OUT_VERDICTS = new Set(['closed', 'taken', 'own-open-pr']);
|
|
127
122
|
/** The per-row `verification` sub-object: the authoritative facts behind the
|
|
128
123
|
* status, projected from the full {@link IssueVerification}. */
|
|
129
124
|
function toVerificationSummary(v) {
|
|
@@ -203,11 +198,12 @@ export async function runVetList(options = {}) {
|
|
|
203
198
|
// Vet-time predictions for calibration (#1824), recorded once after the fan-out.
|
|
204
199
|
const picks = [];
|
|
205
200
|
/**
|
|
206
|
-
* Run scout's grade/health vet for an issue (the search-driven path).
|
|
207
|
-
*
|
|
208
|
-
* linked-PR check can miss the user's own
|
|
201
|
+
* Run scout's grade/health vet for an issue (the search-driven path). A pick is
|
|
202
|
+
* recorded only with a `verification`: on the verify-errored fallback, without
|
|
203
|
+
* verify's own-open-pr verdict, scout's linked-PR check can miss the user's own
|
|
204
|
+
* PR and record a post-hoc grade.
|
|
209
205
|
*/
|
|
210
|
-
async function runScoutVet(item,
|
|
206
|
+
async function runScoutVet(item, verification) {
|
|
211
207
|
const candidate = await scout.vetIssue(item.url);
|
|
212
208
|
const grade = gradeFromCandidate({
|
|
213
209
|
repo: candidate.issue.repo,
|
|
@@ -238,10 +234,16 @@ export async function runVetList(options = {}) {
|
|
|
238
234
|
...(linkedPR && { linkedPR }),
|
|
239
235
|
slmTriage: candidate.slmTriage ?? null,
|
|
240
236
|
grade,
|
|
237
|
+
...repoCapField(getStateManager().getState(), candidate.issue.repo),
|
|
241
238
|
};
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
239
|
+
if (verification) {
|
|
240
|
+
const pick = pickSnapshotFromVet(vetResult, 'vet-list', {
|
|
241
|
+
...traitsFromVerification(verification),
|
|
242
|
+
firstInRepo: isFirstInRepo(candidate.issue.repo, getStateManager().getRepoScore(candidate.issue.repo), getStateManager().getState().mergedPRs),
|
|
243
|
+
});
|
|
244
|
+
if (pick)
|
|
245
|
+
picks.push(pick);
|
|
246
|
+
}
|
|
245
247
|
return { vetResult, skipReason: extractSkipReason(candidate) };
|
|
246
248
|
}
|
|
247
249
|
function errorRow(item, error) {
|
|
@@ -281,7 +283,7 @@ export async function runVetList(options = {}) {
|
|
|
281
283
|
: toMessage(verifyError),
|
|
282
284
|
};
|
|
283
285
|
try {
|
|
284
|
-
const { vetResult, skipReason } = await runScoutVet(item
|
|
286
|
+
const { vetResult, skipReason } = await runScoutVet(item);
|
|
285
287
|
return { ...vetResult, listStatus: classifyListStatus(vetResult, skipReason), ...verifyErrorTag };
|
|
286
288
|
}
|
|
287
289
|
catch (error) {
|
|
@@ -291,14 +293,15 @@ export async function runVetList(options = {}) {
|
|
|
291
293
|
const v = verification.verification;
|
|
292
294
|
const summary = toVerificationSummary(v);
|
|
293
295
|
const listStatus = listStatusFromVerdict(v.verdict);
|
|
294
|
-
// Conclusively ruled out
|
|
296
|
+
// Conclusively ruled out: skip the scout vet entirely and build the row
|
|
297
|
+
// straight from the verification.
|
|
295
298
|
if (RULED_OUT_VERDICTS.has(v.verdict)) {
|
|
296
299
|
return { ...ruledOutVetOutput(v), listStatus, verification: summary };
|
|
297
300
|
}
|
|
298
301
|
// available / at-risk: still worth grading. The verdict stays authoritative
|
|
299
302
|
// for listStatus; scout only supplies grade/health/recommendation.
|
|
300
303
|
try {
|
|
301
|
-
const { vetResult } = await runScoutVet(item,
|
|
304
|
+
const { vetResult } = await runScoutVet(item, v);
|
|
302
305
|
return { ...vetResult, listStatus, verification: summary };
|
|
303
306
|
}
|
|
304
307
|
catch (error) {
|
package/dist/commands/vet.js
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
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 {
|
|
8
|
+
import { repoCapField } from '../core/repo-cap.js';
|
|
9
|
+
import { getStateManager, getOctokit, classifyLinkedPR, pickSnapshotFromVet, persistPickSnapshots, fetchIssueVerification, RULED_OUT_VERDICTS, traitsFromVerification, isFirstInRepo, requireGitHubToken, errorMessage, warn, } from '../core/index.js';
|
|
9
10
|
/**
|
|
10
11
|
* Vet a specific GitHub issue for claimability and project health.
|
|
11
12
|
*
|
|
@@ -48,7 +49,33 @@ 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
|
-
const pick =
|
|
54
|
+
const pick = await pickFor(output);
|
|
53
55
|
return { ...output, ...(await persistPickSnapshots(getStateManager(), pick ? [pick] : [])) };
|
|
54
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* The pick to record for this vet. One verify GraphQL call supplies the issue
|
|
59
|
+
* author, comment count and competing PRs, and applies vet-list's rule: no pick
|
|
60
|
+
* for a closed, taken or own-PR issue (scout's first-linked-PR check can miss these). A failed verify never fails the vet:
|
|
61
|
+
* the pick then falls back to scout's facts.
|
|
62
|
+
*/
|
|
63
|
+
async function pickFor(output) {
|
|
64
|
+
if (output.linkedPRClassification?.startsWith('user_'))
|
|
65
|
+
return undefined;
|
|
66
|
+
const { repo, number, url } = output.issue;
|
|
67
|
+
const [owner, name] = repo.split('/', 2);
|
|
68
|
+
let verification;
|
|
69
|
+
try {
|
|
70
|
+
verification = await fetchIssueVerification(getOctokit(requireGitHubToken()), { repo: name, owner, number });
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
warn('vet', `Could not verify ${url} for pick traits: ${errorMessage(error)}`);
|
|
74
|
+
}
|
|
75
|
+
if (verification && RULED_OUT_VERDICTS.has(verification.verdict))
|
|
76
|
+
return undefined;
|
|
77
|
+
return pickSnapshotFromVet(output, 'vet', {
|
|
78
|
+
...(verification && traitsFromVerification(verification)),
|
|
79
|
+
firstInRepo: isFirstInRepo(repo, getStateManager().getRepoScore(repo), getStateManager().getState().mergedPRs),
|
|
80
|
+
});
|
|
81
|
+
}
|
package/dist/core/ci-analysis.js
CHANGED
|
@@ -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 = [
|
|
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
|
|
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
|
|
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
|
-
|
|
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.',
|