@oss-autopilot/core 3.39.0 → 3.39.2
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.bundle.cjs +156 -140
- package/dist/commands/daily.js +22 -4
- package/dist/commands/dashboard-data.js +16 -7
- package/dist/commands/dashboard-gist-sync.d.ts +0 -4
- package/dist/commands/dashboard-gist-sync.js +16 -7
- package/dist/core/engaged-issue-lookup.d.ts +82 -0
- package/dist/core/engaged-issue-lookup.js +157 -0
- package/dist/core/engaged-issues.d.ts +3 -3
- package/dist/core/engaged-issues.js +5 -5
- package/dist/core/issue-conversation.d.ts +68 -21
- package/dist/core/issue-conversation.js +157 -75
- package/dist/core/pr-graphql.d.ts +2 -0
- package/dist/core/pr-graphql.js +2 -2
- package/dist/core/state.d.ts +4 -0
- package/dist/core/state.js +6 -0
- package/package.json +1 -1
package/dist/commands/daily.js
CHANGED
|
@@ -54,6 +54,25 @@ function successorGapsFor(pr, gaps) {
|
|
|
54
54
|
* Retrieves open PRs, merged/closed counts, recently closed/merged PRs, and
|
|
55
55
|
* issue conversation data — all in parallel where possible.
|
|
56
56
|
*/
|
|
57
|
+
/**
|
|
58
|
+
* Record the issue monitor's non-fatal notes under the fetch phase (#1862):
|
|
59
|
+
* its warnings (a gone issue, a truncated thread, issues past the
|
|
60
|
+
* comment-fetch cap) and, under their own operation, the engaged issues
|
|
61
|
+
* whose batched lookup failed and so were not checked at all this run. The
|
|
62
|
+
* per-issue detail is in `failures`; the rollup below counts them too.
|
|
63
|
+
*/
|
|
64
|
+
function recordIssueMonitorNotes(warnings, result) {
|
|
65
|
+
for (const message of result.warnings) {
|
|
66
|
+
warnings.push({ phase: 'fetch', operation: 'fetch commented issues', message });
|
|
67
|
+
}
|
|
68
|
+
if (result.lookupFailures > 0) {
|
|
69
|
+
warnings.push({
|
|
70
|
+
phase: 'fetch',
|
|
71
|
+
operation: 'look up engaged issues',
|
|
72
|
+
message: `${result.lookupFailures} engaged issue lookup(s) failed; those issues were not checked this run`,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
57
76
|
async function fetchPRData(prMonitor, token, warnings) {
|
|
58
77
|
// Fetch all open PRs fresh from GitHub
|
|
59
78
|
const fetchResult = await prMonitor.fetchUserOpenPRs();
|
|
@@ -143,13 +162,12 @@ async function fetchPRData(prMonitor, token, warnings) {
|
|
|
143
162
|
return {
|
|
144
163
|
issues: [],
|
|
145
164
|
failures: [{ issueUrl: 'N/A', error: `Issue conversation fetch failed: ${msg}` }],
|
|
165
|
+
lookupFailures: 0,
|
|
146
166
|
warnings: [],
|
|
147
167
|
};
|
|
148
168
|
});
|
|
149
|
-
const { issues: commentedIssues
|
|
150
|
-
|
|
151
|
-
warnings.push({ phase: 'fetch', operation: 'fetch commented issues', message });
|
|
152
|
-
}
|
|
169
|
+
const { issues: commentedIssues } = issueConversationResult;
|
|
170
|
+
recordIssueMonitorNotes(warnings, issueConversationResult);
|
|
153
171
|
if (issueConversationResult.failures.length > 0) {
|
|
154
172
|
warnings.push({
|
|
155
173
|
phase: 'fetch',
|
|
@@ -166,12 +166,20 @@ export function updateMonthlyAnalytics(prs, monthlyCounts, monthlyClosedCounts,
|
|
|
166
166
|
return failures;
|
|
167
167
|
}
|
|
168
168
|
/**
|
|
169
|
-
* The partial-data banner
|
|
170
|
-
*
|
|
171
|
-
*
|
|
169
|
+
* The partial-data banner entries for the issue monitor's non-fatal notes
|
|
170
|
+
* (#1862). Its warnings (a gone issue, a truncated thread, an engagement
|
|
171
|
+
* time that does not parse, issues past the comment-fetch cap) collapse to
|
|
172
|
+
* one label: the monitor already logged each one, and the banner lists
|
|
173
|
+
* operations. Engaged issues whose batched lookup failed were not checked
|
|
174
|
+
* at all this run, so they get their own label.
|
|
172
175
|
*/
|
|
173
|
-
function engagedScanLabels(
|
|
174
|
-
|
|
176
|
+
function engagedScanLabels(result) {
|
|
177
|
+
const labels = [];
|
|
178
|
+
if (result.lookupFailures > 0)
|
|
179
|
+
labels.push('look up engaged issues');
|
|
180
|
+
if (result.warnings.length > 0)
|
|
181
|
+
labels.push('scan engaged issues');
|
|
182
|
+
return labels;
|
|
175
183
|
}
|
|
176
184
|
/**
|
|
177
185
|
* Fetch fresh dashboard data from GitHub.
|
|
@@ -263,11 +271,12 @@ export async function fetchDashboardData(token) {
|
|
|
263
271
|
return {
|
|
264
272
|
issues: [],
|
|
265
273
|
failures: [{ issueUrl: 'N/A', error: `Issue conversation fetch failed: ${msg}` }],
|
|
274
|
+
lookupFailures: 0,
|
|
266
275
|
warnings: [],
|
|
267
276
|
};
|
|
268
277
|
});
|
|
269
|
-
const { issues: commentedIssues
|
|
270
|
-
partialFailures.push(...engagedScanLabels(
|
|
278
|
+
const { issues: commentedIssues } = fetchedIssues;
|
|
279
|
+
partialFailures.push(...engagedScanLabels(fetchedIssues));
|
|
271
280
|
if (fetchedIssues.failures.length > 0) {
|
|
272
281
|
warn(MODULE, `${fetchedIssues.failures.length} issue conversation check(s) failed`);
|
|
273
282
|
}
|
|
@@ -39,10 +39,6 @@ export declare class GistSyncCoordinator {
|
|
|
39
39
|
/** Push-before-pull (#1417): an un-pushed mutation would be silently
|
|
40
40
|
* reverted by the next Gist pull. Retry the checkpoint first so a recovered
|
|
41
41
|
* network turns the pending warning into a real push before any pull runs.
|
|
42
|
-
* Also pushes saves that never recorded a warning: fetchDashboardData
|
|
43
|
-
* writes the digest and merged/closed caches through save() with no
|
|
44
|
-
* checkpoint, and the pull right after it reverted them and raised the
|
|
45
|
-
* "un-pushed changes" stale banner on every refresh.
|
|
46
42
|
* No-op when nothing is pending. */
|
|
47
43
|
flushPendingGistSync(): Promise<void>;
|
|
48
44
|
/** One health snapshot from the one source (#1444). Defensive: this is an
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { getStateManager, getGitHubToken, maybeCheckpoint, ensureGistPersistence, } from '../core/index.js';
|
|
11
11
|
import { errorMessage, ConfigurationError } from '../core/errors.js';
|
|
12
|
-
import { warn } from '../core/logger.js';
|
|
12
|
+
import { debug, warn } from '../core/logger.js';
|
|
13
13
|
const GIST_DEGRADED_WARNING = 'Gist persistence is configured but this dashboard process is running LOCAL-ONLY; ' +
|
|
14
14
|
'changes made here will NOT sync and may be overwritten by the next successful Gist read. ' +
|
|
15
15
|
'Recovery is retried automatically.';
|
|
@@ -110,15 +110,24 @@ export class GistSyncCoordinator {
|
|
|
110
110
|
/** Push-before-pull (#1417): an un-pushed mutation would be silently
|
|
111
111
|
* reverted by the next Gist pull. Retry the checkpoint first so a recovered
|
|
112
112
|
* network turns the pending warning into a real push before any pull runs.
|
|
113
|
-
* Also pushes saves that never recorded a warning: fetchDashboardData
|
|
114
|
-
* writes the digest and merged/closed caches through save() with no
|
|
115
|
-
* checkpoint, and the pull right after it reverted them and raised the
|
|
116
|
-
* "un-pushed changes" stale banner on every refresh.
|
|
117
113
|
* No-op when nothing is pending. */
|
|
118
114
|
async flushPendingGistSync() {
|
|
119
|
-
if (this.pendingGistSyncWarnings.length
|
|
115
|
+
if (this.pendingGistSyncWarnings.length > 0) {
|
|
116
|
+
this.recordGistSyncOutcome(await maybeCheckpoint(this.manager, this.module));
|
|
120
117
|
return;
|
|
121
|
-
|
|
118
|
+
}
|
|
119
|
+
if (!this.manager.hasUnpushedChanges())
|
|
120
|
+
return;
|
|
121
|
+
// No mutation warning is pending, so the un-pushed saves are
|
|
122
|
+
// fetchDashboardData's GitHub-derived digest and merged/closed caches,
|
|
123
|
+
// which every refresh rebuilds. Push them best-effort; on failure (e.g. a
|
|
124
|
+
// concurrent Gist write) let the pull revert them quietly instead of
|
|
125
|
+
// raising a loss banner for data nobody entered.
|
|
126
|
+
const failure = await maybeCheckpoint(this.manager, this.module);
|
|
127
|
+
if (failure === null)
|
|
128
|
+
return;
|
|
129
|
+
debug(this.module, `Dropping un-pushed refresh data before the Gist pull: ${failure}`);
|
|
130
|
+
this.manager.forgetUnpushedChanges();
|
|
122
131
|
}
|
|
123
132
|
/** One health snapshot from the one source (#1444). Defensive: this is an
|
|
124
133
|
* advisory probe that runs on EVERY request path (rebuilds, recovery
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Batched GraphQL lookup of engaged issues the comment search missed (#1862).
|
|
3
|
+
*
|
|
4
|
+
* The REST path spent one `issues.get` per engaged issue to learn whether it
|
|
5
|
+
* was still open and had changed since the engagement, and capped those
|
|
6
|
+
* lookups in insertion order, so a user with more engaged issues than the cap
|
|
7
|
+
* never had the tail looked at on any run. One aliased GraphQL query per
|
|
8
|
+
* {@link ENGAGED_LOOKUP_BATCH_SIZE} issues answers the same question from
|
|
9
|
+
* GitHub's separate GraphQL point bucket (a few points per query), so every
|
|
10
|
+
* engaged issue is checked and the cap moves to the comment fetches, applied
|
|
11
|
+
* only to the issues that actually changed.
|
|
12
|
+
*
|
|
13
|
+
* `issueOrPullRequest` rather than `issue`: a closing keyword can name a pull
|
|
14
|
+
* request, and `issue(number:)` reports one as NOT_FOUND, the same as a deleted
|
|
15
|
+
* issue. The union keeps the two apart, so a PR number is skipped quietly
|
|
16
|
+
* instead of warned about as gone.
|
|
17
|
+
*
|
|
18
|
+
* Outcomes per issue: `found` (an issue node), `pull_request`, `gone` (a null
|
|
19
|
+
* node, or a NOT_FOUND error in a partial response: deleted or now private;
|
|
20
|
+
* GitHub follows a transferred issue to its new repo, so the node's `url`
|
|
21
|
+
* can differ from the ref's), or `failed` (any other per-alias error, or a
|
|
22
|
+
* whole query that failed for a reason other than rate limiting or auth;
|
|
23
|
+
* those rethrow).
|
|
24
|
+
*/
|
|
25
|
+
import type { Octokit } from '@octokit/rest';
|
|
26
|
+
/** Issues per aliased GraphQL query. */
|
|
27
|
+
export declare const ENGAGED_LOOKUP_BATCH_SIZE = 50;
|
|
28
|
+
/** One engaged issue to look up. */
|
|
29
|
+
export interface EngagedIssueRef {
|
|
30
|
+
owner: string;
|
|
31
|
+
repo: string;
|
|
32
|
+
number: number;
|
|
33
|
+
/** Canonical issue URL; the result map is keyed by it. */
|
|
34
|
+
url: string;
|
|
35
|
+
}
|
|
36
|
+
/** The fields read off an issue node. */
|
|
37
|
+
export interface EngagedIssueNode {
|
|
38
|
+
__typename: 'Issue';
|
|
39
|
+
url: string;
|
|
40
|
+
number: number;
|
|
41
|
+
title: string;
|
|
42
|
+
state: 'OPEN' | 'CLOSED';
|
|
43
|
+
updatedAt: string;
|
|
44
|
+
author: {
|
|
45
|
+
login: string;
|
|
46
|
+
} | null;
|
|
47
|
+
labels: {
|
|
48
|
+
nodes: Array<{
|
|
49
|
+
name: string;
|
|
50
|
+
} | null>;
|
|
51
|
+
} | null;
|
|
52
|
+
}
|
|
53
|
+
export type EngagedIssueLookup = {
|
|
54
|
+
kind: 'found';
|
|
55
|
+
node: EngagedIssueNode;
|
|
56
|
+
} | {
|
|
57
|
+
kind: 'pull_request';
|
|
58
|
+
} | {
|
|
59
|
+
kind: 'gone';
|
|
60
|
+
reason: string;
|
|
61
|
+
} | {
|
|
62
|
+
kind: 'failed';
|
|
63
|
+
error: string;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Build the aliased query for one batch. Owner, repo and number travel as
|
|
67
|
+
* GraphQL variables, never interpolated into the query text.
|
|
68
|
+
*/
|
|
69
|
+
export declare function buildEngagedIssueQuery(refs: EngagedIssueRef[]): {
|
|
70
|
+
query: string;
|
|
71
|
+
variables: Record<string, string | number>;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Look up every ref, one query per batch, sequentially (GitHub recommends
|
|
75
|
+
* serial GraphQL requests). A batch that fails outright (a 502, a network
|
|
76
|
+
* blip, a server-side timeout on a large query) is retried once as two
|
|
77
|
+
* half-size queries, so one bad response does not fail fifty issues; a half
|
|
78
|
+
* that fails again fails its refs. Returns an outcome per ref, keyed by URL.
|
|
79
|
+
*
|
|
80
|
+
* @throws The GraphQL error when it is a rate-limit or auth failure.
|
|
81
|
+
*/
|
|
82
|
+
export declare function lookupEngagedIssues(octokit: Octokit, refs: EngagedIssueRef[]): Promise<Map<string, EngagedIssueLookup>>;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Batched GraphQL lookup of engaged issues the comment search missed (#1862).
|
|
3
|
+
*
|
|
4
|
+
* The REST path spent one `issues.get` per engaged issue to learn whether it
|
|
5
|
+
* was still open and had changed since the engagement, and capped those
|
|
6
|
+
* lookups in insertion order, so a user with more engaged issues than the cap
|
|
7
|
+
* never had the tail looked at on any run. One aliased GraphQL query per
|
|
8
|
+
* {@link ENGAGED_LOOKUP_BATCH_SIZE} issues answers the same question from
|
|
9
|
+
* GitHub's separate GraphQL point bucket (a few points per query), so every
|
|
10
|
+
* engaged issue is checked and the cap moves to the comment fetches, applied
|
|
11
|
+
* only to the issues that actually changed.
|
|
12
|
+
*
|
|
13
|
+
* `issueOrPullRequest` rather than `issue`: a closing keyword can name a pull
|
|
14
|
+
* request, and `issue(number:)` reports one as NOT_FOUND, the same as a deleted
|
|
15
|
+
* issue. The union keeps the two apart, so a PR number is skipped quietly
|
|
16
|
+
* instead of warned about as gone.
|
|
17
|
+
*
|
|
18
|
+
* Outcomes per issue: `found` (an issue node), `pull_request`, `gone` (a null
|
|
19
|
+
* node, or a NOT_FOUND error in a partial response: deleted or now private;
|
|
20
|
+
* GitHub follows a transferred issue to its new repo, so the node's `url`
|
|
21
|
+
* can differ from the ref's), or `failed` (any other per-alias error, or a
|
|
22
|
+
* whole query that failed for a reason other than rate limiting or auth;
|
|
23
|
+
* those rethrow).
|
|
24
|
+
*/
|
|
25
|
+
import { errorMessage, isRateLimitOrAuthError } from './errors.js';
|
|
26
|
+
import { chunk, isGraphqlRateLimited } from './pr-graphql.js';
|
|
27
|
+
/** Issues per aliased GraphQL query. */
|
|
28
|
+
export const ENGAGED_LOOKUP_BATCH_SIZE = 50;
|
|
29
|
+
/** Labels requested per issue; the labels are display-only on the digest entry. */
|
|
30
|
+
const LABELS_CAP = 20;
|
|
31
|
+
const ISSUE_FIELDS = `
|
|
32
|
+
__typename
|
|
33
|
+
... on Issue {
|
|
34
|
+
url
|
|
35
|
+
number
|
|
36
|
+
title
|
|
37
|
+
state
|
|
38
|
+
updatedAt
|
|
39
|
+
author { login }
|
|
40
|
+
labels(first: ${LABELS_CAP}) { nodes { name } }
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
/**
|
|
44
|
+
* Build the aliased query for one batch. Owner, repo and number travel as
|
|
45
|
+
* GraphQL variables, never interpolated into the query text.
|
|
46
|
+
*/
|
|
47
|
+
export function buildEngagedIssueQuery(refs) {
|
|
48
|
+
const varDefs = [];
|
|
49
|
+
const selections = [];
|
|
50
|
+
const variables = {};
|
|
51
|
+
for (const [i, ref] of refs.entries()) {
|
|
52
|
+
varDefs.push(`$o${i}: String!, $r${i}: String!, $n${i}: Int!`);
|
|
53
|
+
variables[`o${i}`] = ref.owner;
|
|
54
|
+
variables[`r${i}`] = ref.repo;
|
|
55
|
+
variables[`n${i}`] = ref.number;
|
|
56
|
+
selections.push(`i${i}: repository(owner: $o${i}, name: $r${i}) {\n issueOrPullRequest(number: $n${i}) {${ISSUE_FIELDS}}\n}`);
|
|
57
|
+
}
|
|
58
|
+
const query = `query engagedIssues(${varDefs.join(', ')}) {\n${selections.join('\n')}\n}`;
|
|
59
|
+
return { query, variables };
|
|
60
|
+
}
|
|
61
|
+
/** The errors of a partial response: keyed by the alias they point at, plus the ones without a path. */
|
|
62
|
+
function partitionErrors(err) {
|
|
63
|
+
const byAlias = new Map();
|
|
64
|
+
const unattributed = [];
|
|
65
|
+
const errors = err?.errors;
|
|
66
|
+
if (!Array.isArray(errors))
|
|
67
|
+
return { byAlias, unattributed };
|
|
68
|
+
for (const entry of errors) {
|
|
69
|
+
if (!entry)
|
|
70
|
+
continue;
|
|
71
|
+
const alias = entry.path?.[0];
|
|
72
|
+
if (typeof alias === 'string') {
|
|
73
|
+
const list = byAlias.get(alias) ?? [];
|
|
74
|
+
list.push(entry);
|
|
75
|
+
byAlias.set(alias, list);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
unattributed.push(entry);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return { byAlias, unattributed };
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Run one batch. A partial-data error keeps the aliases that resolved and the
|
|
85
|
+
* errors for the rest; rate-limit and auth errors (REST-style status or the
|
|
86
|
+
* GraphQL-native `RATE_LIMITED`) rethrow; anything else fails the batch.
|
|
87
|
+
*/
|
|
88
|
+
async function runChunk(octokit, refs) {
|
|
89
|
+
const { query, variables } = buildEngagedIssueQuery(refs);
|
|
90
|
+
try {
|
|
91
|
+
const data = await octokit.graphql(query, variables);
|
|
92
|
+
return { data, byAlias: new Map(), unattributed: [] };
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
if (isRateLimitOrAuthError(err) || isGraphqlRateLimited(err))
|
|
96
|
+
throw err;
|
|
97
|
+
const partial = err.data;
|
|
98
|
+
if (partial)
|
|
99
|
+
return { data: partial, ...partitionErrors(err) };
|
|
100
|
+
return { failure: errorMessage(err) };
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function describeEntry(entry) {
|
|
104
|
+
return `${entry.type ?? 'GraphQL'}: ${entry.message ?? 'error'}`;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The outcome for one alias of a resolved batch. A null node is gone only
|
|
108
|
+
* when GitHub said NOT_FOUND for it, or returned no error at all; a null
|
|
109
|
+
* node in a response whose errors have no path (a server-side timeout, say)
|
|
110
|
+
* is a failure, not a missing issue.
|
|
111
|
+
*/
|
|
112
|
+
function outcomeFor(chunk, alias) {
|
|
113
|
+
const node = chunk.data[alias]?.issueOrPullRequest;
|
|
114
|
+
if (node)
|
|
115
|
+
return node.__typename === 'PullRequest' ? { kind: 'pull_request' } : { kind: 'found', node };
|
|
116
|
+
const errors = chunk.byAlias.get(alias) ?? [];
|
|
117
|
+
const blocking = errors.find((e) => e.type !== 'NOT_FOUND');
|
|
118
|
+
if (blocking)
|
|
119
|
+
return { kind: 'failed', error: describeEntry(blocking) };
|
|
120
|
+
const notFound = errors[0];
|
|
121
|
+
if (notFound)
|
|
122
|
+
return { kind: 'gone', reason: `NOT_FOUND: ${notFound.message ?? ''}`.trim() };
|
|
123
|
+
const unattributed = chunk.unattributed[0];
|
|
124
|
+
if (unattributed)
|
|
125
|
+
return { kind: 'failed', error: describeEntry(unattributed) };
|
|
126
|
+
return { kind: 'gone', reason: 'not returned by GitHub' };
|
|
127
|
+
}
|
|
128
|
+
/** Record one batch's result, an outcome per ref; aliases index from `i0` within each query. */
|
|
129
|
+
function recordChunk(outcomes, batch, result) {
|
|
130
|
+
for (const [i, ref] of batch.entries()) {
|
|
131
|
+
outcomes.set(ref.url, 'failure' in result ? { kind: 'failed', error: result.failure } : outcomeFor(result, `i${i}`));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Look up every ref, one query per batch, sequentially (GitHub recommends
|
|
136
|
+
* serial GraphQL requests). A batch that fails outright (a 502, a network
|
|
137
|
+
* blip, a server-side timeout on a large query) is retried once as two
|
|
138
|
+
* half-size queries, so one bad response does not fail fifty issues; a half
|
|
139
|
+
* that fails again fails its refs. Returns an outcome per ref, keyed by URL.
|
|
140
|
+
*
|
|
141
|
+
* @throws The GraphQL error when it is a rate-limit or auth failure.
|
|
142
|
+
*/
|
|
143
|
+
export async function lookupEngagedIssues(octokit, refs) {
|
|
144
|
+
const outcomes = new Map();
|
|
145
|
+
for (const batch of chunk(refs, ENGAGED_LOOKUP_BATCH_SIZE)) {
|
|
146
|
+
const result = await runChunk(octokit, batch);
|
|
147
|
+
if (!('failure' in result) || batch.length === 1) {
|
|
148
|
+
recordChunk(outcomes, batch, result);
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
const half = Math.ceil(batch.length / 2);
|
|
152
|
+
for (const part of [batch.slice(0, half), batch.slice(half)]) {
|
|
153
|
+
recordChunk(outcomes, part, await runChunk(octokit, part));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return outcomes;
|
|
157
|
+
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* ledger entry no older than {@link LEDGER_LINK_MAX_AGE_DAYS}. Plain
|
|
9
9
|
* mentions in a PR body ("similar to #12", "see #4 for the upstream bug") are
|
|
10
10
|
* not engagement: they named unrelated issues, bumped the engagement time
|
|
11
|
-
* past earlier maintainer replies, and ate into the
|
|
11
|
+
* past earlier maintainer replies, and ate into the comment-fetch cap.
|
|
12
12
|
* `IssueConversationMonitor` scans engaged issues under a wider reply rule
|
|
13
13
|
* (any substantive non-bot comment counts, not only maintainer or @mention
|
|
14
14
|
* replies) and fetches the live ones directly when the commenter search does
|
|
@@ -85,8 +85,8 @@ export interface CollectEngagedIssuesOptions {
|
|
|
85
85
|
* Links that do not parse as GitHub URLs, or that name one of the user's own
|
|
86
86
|
* PRs, are skipped. Iteration order is strongest-reason first (engagements
|
|
87
87
|
* are visited in that order, so an issue is inserted at its strongest
|
|
88
|
-
* reason's position)
|
|
89
|
-
*
|
|
88
|
+
* reason's position). The monitor looks every live entry up regardless of
|
|
89
|
+
* order; its comment-fetch cap ranks by the issue's own update time.
|
|
90
90
|
*/
|
|
91
91
|
export declare function collectEngagedIssues(input: EngagedIssuesInput, options?: CollectEngagedIssuesOptions): Map<string, EngagedIssue>;
|
|
92
92
|
/** The `IssueEngagement` projection of an engaged issue, for the digest entry. */
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* ledger entry no older than {@link LEDGER_LINK_MAX_AGE_DAYS}. Plain
|
|
9
9
|
* mentions in a PR body ("similar to #12", "see #4 for the upstream bug") are
|
|
10
10
|
* not engagement: they named unrelated issues, bumped the engagement time
|
|
11
|
-
* past earlier maintainer replies, and ate into the
|
|
11
|
+
* past earlier maintainer replies, and ate into the comment-fetch cap.
|
|
12
12
|
* `IssueConversationMonitor` scans engaged issues under a wider reply rule
|
|
13
13
|
* (any substantive non-bot comment counts, not only maintainer or @mention
|
|
14
14
|
* replies) and fetches the live ones directly when the commenter search does
|
|
@@ -94,8 +94,8 @@ function* engagements(input, nowMs) {
|
|
|
94
94
|
}
|
|
95
95
|
/**
|
|
96
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
|
|
98
|
-
* it would
|
|
97
|
+
* ("closes #50" on a follow-up to PR #50); that is not an issue, and looking
|
|
98
|
+
* it up would only confirm so.
|
|
99
99
|
*/
|
|
100
100
|
function ownPRKeys(input) {
|
|
101
101
|
const keys = new Set();
|
|
@@ -158,8 +158,8 @@ function record(byKey, engagement) {
|
|
|
158
158
|
* Links that do not parse as GitHub URLs, or that name one of the user's own
|
|
159
159
|
* PRs, are skipped. Iteration order is strongest-reason first (engagements
|
|
160
160
|
* are visited in that order, so an issue is inserted at its strongest
|
|
161
|
-
* reason's position)
|
|
162
|
-
*
|
|
161
|
+
* reason's position). The monitor looks every live entry up regardless of
|
|
162
|
+
* order; its comment-fetch cap ranks by the issue's own update time.
|
|
163
163
|
*/
|
|
164
164
|
export function collectEngagedIssues(input, options = {}) {
|
|
165
165
|
const nowMs = (options.now ?? new Date()).getTime();
|
|
@@ -16,19 +16,24 @@
|
|
|
16
16
|
* emoji-only reactions do not, except that a bare status request on a
|
|
17
17
|
* claimed issue is addressed to the claimant and counts. Engaged issues
|
|
18
18
|
* the comment search does not return (the user never commented, or not
|
|
19
|
-
* within the window) are
|
|
20
|
-
*
|
|
19
|
+
* within the window) are looked up in batched GraphQL queries, and the
|
|
20
|
+
* ones still open and updated since the engagement have their comments
|
|
21
|
+
* read directly, up to {@link MAX_DIRECT_ENGAGED_FETCHES} per run, most
|
|
22
|
+
* recently updated first.
|
|
21
23
|
*/
|
|
22
24
|
import type { CommentedIssue } from './types.js';
|
|
23
25
|
import { type EngagedIssue } from './engaged-issues.js';
|
|
24
26
|
/**
|
|
25
|
-
* Most engaged issues
|
|
26
|
-
* misses them (#1862).
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
27
|
+
* Most engaged issues whose comments are read directly per run when the
|
|
28
|
+
* comment search misses them (#1862). Only issues the batched lookup found
|
|
29
|
+
* open and updated since the engagement count; each costs its comment pages,
|
|
30
|
+
* ETag-cached, so a quiet day is mostly 304s. The cap bounds a first run for
|
|
31
|
+
* a user with many active claims. Most recently updated issues come first,
|
|
32
|
+
* so an issue that gets a new comment moves to the front on the next run,
|
|
33
|
+
* but one that stays quiet behind a hundred busier ones is not read until
|
|
34
|
+
* the busier ones settle. That is why hitting the cap is a warning.
|
|
30
35
|
*/
|
|
31
|
-
export declare const MAX_DIRECT_ENGAGED_FETCHES =
|
|
36
|
+
export declare const MAX_DIRECT_ENGAGED_FETCHES = 100;
|
|
32
37
|
export interface FetchCommentedIssuesOptions {
|
|
33
38
|
/** Window for the comment search, in days (default 30). */
|
|
34
39
|
maxDays?: number;
|
|
@@ -37,14 +42,27 @@ export interface FetchCommentedIssuesOptions {
|
|
|
37
42
|
}
|
|
38
43
|
export interface FetchCommentedIssuesResult {
|
|
39
44
|
issues: CommentedIssue[];
|
|
45
|
+
/**
|
|
46
|
+
* Per-issue failures: the batched lookup of an engaged issue the search
|
|
47
|
+
* missed (the first `lookupFailures` entries), then the comment fetches
|
|
48
|
+
* and analyses that threw.
|
|
49
|
+
*/
|
|
40
50
|
failures: Array<{
|
|
41
51
|
issueUrl: string;
|
|
42
52
|
error: string;
|
|
43
53
|
}>;
|
|
44
54
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
55
|
+
* How many of `failures` are engaged-issue lookups that failed (#1862),
|
|
56
|
+
* as opposed to comment fetches. A lookup failure means an engaged issue
|
|
57
|
+
* was not checked at all this run, so the dashboard names it separately.
|
|
58
|
+
*/
|
|
59
|
+
lookupFailures: number;
|
|
60
|
+
/**
|
|
61
|
+
* Non-fatal problems for the run's warning channel: a claimed or open-PR
|
|
62
|
+
* issue that is gone, a comment thread too long to read to the end, an
|
|
63
|
+
* engagement time that does not parse, engaged issues with new activity
|
|
64
|
+
* left unread because the comment-fetch cap bit. Each means the result
|
|
65
|
+
* may be missing or misreporting something the user can act on.
|
|
48
66
|
*/
|
|
49
67
|
warnings: string[];
|
|
50
68
|
}
|
|
@@ -74,17 +92,46 @@ export declare class IssueConversationMonitor {
|
|
|
74
92
|
/** Repo-level exclusions shared by the search results and the direct fetches. */
|
|
75
93
|
private isRepoAllowed;
|
|
76
94
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
95
|
+
* Candidates for the engaged issues the comment search did not return
|
|
96
|
+
* (#1862): one batched GraphQL lookup for all of them, then the issues
|
|
97
|
+
* still open, not the user's own, and updated since the later of the
|
|
98
|
+
* search window's start and the engagement step, most recently updated
|
|
99
|
+
* first, up to {@link MAX_DIRECT_ENGAGED_FETCHES}. The window keeps this
|
|
100
|
+
* path consistent with the commenter search (a reply older than `maxDays`
|
|
101
|
+
* is not surfaced either way); the engagement step tightens it because
|
|
102
|
+
* only comments after that step can be replies to the user. The issues
|
|
103
|
+
* past the cap are named in a warning: the next run reorders by update
|
|
104
|
+
* time again, so one that is commented on moves to the front, but with a
|
|
105
|
+
* hundred busier issues ahead of it a quiet one can wait a long time.
|
|
106
|
+
*
|
|
107
|
+
* @throws The lookup's rate-limit or auth error; other lookup failures are
|
|
108
|
+
* recorded per issue in `report.failures`.
|
|
109
|
+
*/
|
|
110
|
+
private collectDirectCandidates;
|
|
111
|
+
/**
|
|
112
|
+
* The direct candidate one lookup outcome yields, or undefined with the
|
|
113
|
+
* reason logged: a lookup failure (recorded), a gone issue (a warning only
|
|
114
|
+
* while a claim or an open PR still points at it), a pull request number,
|
|
115
|
+
* a closed issue, one the user authored, or one untouched since the
|
|
116
|
+
* engagement. The candidate's repo and number come from the node's URL,
|
|
117
|
+
* not the engagement's: GitHub follows a transferred issue to its new
|
|
118
|
+
* repo, and the comments live there. So the repo exclusions and the
|
|
119
|
+
* search dedupe run again on that URL: a transfer into an excluded repo
|
|
120
|
+
* is skipped, and one onto an issue the search already returned adds no
|
|
121
|
+
* second candidate but lends that one the engagement (the engaged reply
|
|
122
|
+
* rule applies there too) unless it has its own.
|
|
123
|
+
*/
|
|
124
|
+
private toDirectCandidate;
|
|
125
|
+
/**
|
|
126
|
+
* Why a looked-up issue needs no candidate at the URL GitHub returned it,
|
|
127
|
+
* or undefined when it does (and its key is then marked seen). Only a
|
|
128
|
+
* transferred issue can be covered: the engagement's own repo passed the
|
|
129
|
+
* exclusions before the lookup and its own key was not among the search
|
|
130
|
+
* results. A transfer into an excluded repo is skipped; one onto an
|
|
131
|
+
* issue the search returned lends that candidate the engagement unless
|
|
132
|
+
* it has its own, so the engaged reply rule applies there.
|
|
86
133
|
*/
|
|
87
|
-
private
|
|
134
|
+
private transferredIssueCoverage;
|
|
88
135
|
/**
|
|
89
136
|
* Analyze a single issue's comment thread to determine conversation status.
|
|
90
137
|
* Returns null when there is nothing to report: the user never commented
|