@oss-autopilot/core 3.39.1 → 3.40.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 +105 -1
- package/dist/cli.bundle.cjs +163 -144
- package/dist/commands/daily.d.ts +6 -1
- package/dist/commands/daily.js +29 -6
- package/dist/commands/dashboard-data.js +16 -7
- package/dist/commands/index.d.ts +3 -0
- package/dist/commands/index.js +2 -0
- package/dist/commands/scout-bridge.js +23 -1
- package/dist/commands/setup.js +2 -1
- package/dist/commands/vet-list.js +18 -1
- package/dist/commands/vet.js +7 -1
- package/dist/commands/work.d.ts +134 -0
- package/dist/commands/work.js +313 -0
- package/dist/core/config-registry.js +6 -0
- package/dist/core/daily-logic.d.ts +2 -1
- package/dist/core/daily-logic.js +12 -1
- 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/gist-state-store.js +6 -2
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +2 -0
- package/dist/core/issue-conversation.d.ts +68 -21
- package/dist/core/issue-conversation.js +157 -75
- package/dist/core/machine-id.d.ts +18 -0
- package/dist/core/machine-id.js +131 -0
- package/dist/core/paths.d.ts +8 -0
- package/dist/core/paths.js +10 -0
- package/dist/core/pr-graphql.d.ts +2 -0
- package/dist/core/pr-graphql.js +2 -2
- package/dist/core/state-persistence.d.ts +8 -0
- package/dist/core/state-persistence.js +14 -1
- package/dist/core/state-schema.d.ts +54 -1
- package/dist/core/state-schema.js +68 -0
- package/dist/core/state.d.ts +39 -1
- package/dist/core/state.js +86 -2
- package/dist/core/types.d.ts +1 -1
- package/dist/core/work-claims.d.ts +89 -0
- package/dist/core/work-claims.js +196 -0
- package/dist/formatters/json.d.ts +130 -1
- package/dist/formatters/json.js +26 -0
- package/package.json +1 -1
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
import * as fs from 'node:fs';
|
|
49
49
|
import { AgentStateSchema, NEWER_WRITER_HINT, unknownStateKeys } from './state-schema.js';
|
|
50
50
|
import { serializeState } from './state-prune.js';
|
|
51
|
-
import { atomicWriteFileSync, createFreshState, migrateV1ToV2, migrateV2ToV3, migrateV3ToV4, } from './state-persistence.js';
|
|
51
|
+
import { atomicWriteFileSync, createFreshState, migrateV1ToV2, migrateV2ToV3, migrateV3ToV4, warnMalformedWorkClaims, } from './state-persistence.js';
|
|
52
52
|
import { getGistIdPath, getStateCachePath } from './paths.js';
|
|
53
53
|
import { debug, warn } from './logger.js';
|
|
54
54
|
import { ConfigurationError, GistPermissionError, GistConcurrencyError, GistCorruptError, GistFileSizeError, isRateLimitError, isTransientNetworkError, errorMessage, } from './errors.js';
|
|
@@ -220,6 +220,7 @@ export class GistStateStore {
|
|
|
220
220
|
obj = migrateV3ToV4(obj);
|
|
221
221
|
}
|
|
222
222
|
const cachedState = AgentStateSchema.parse(obj);
|
|
223
|
+
warnMalformedWorkClaims(obj, cachedState, 'Local state cache');
|
|
223
224
|
debug(MODULE, 'Loaded state from local cache in degraded mode');
|
|
224
225
|
return { gistId: '', state: cachedState, created: false, degraded: true };
|
|
225
226
|
}
|
|
@@ -315,6 +316,7 @@ export class GistStateStore {
|
|
|
315
316
|
obj = migrateV3ToV4(obj);
|
|
316
317
|
}
|
|
317
318
|
const cachedState = AgentStateSchema.parse(obj);
|
|
319
|
+
warnMalformedWorkClaims(obj, cachedState, 'Local state cache');
|
|
318
320
|
debug(MODULE, 'bootstrapWithMigration: loaded state from local cache in degraded mode');
|
|
319
321
|
return { gistId: '', state: cachedState, created: false, degraded: true, migrated: false };
|
|
320
322
|
}
|
|
@@ -761,7 +763,9 @@ export class GistStateStore {
|
|
|
761
763
|
const newer = unknownStateKeys(obj);
|
|
762
764
|
if (newer.length > 0)
|
|
763
765
|
warn(MODULE, `Gist state (fields: ${newer.join(', ')}) ${NEWER_WRITER_HINT}`);
|
|
764
|
-
|
|
766
|
+
const state = AgentStateSchema.parse(obj);
|
|
767
|
+
warnMalformedWorkClaims(obj, state, 'Gist state');
|
|
768
|
+
return state;
|
|
765
769
|
}
|
|
766
770
|
catch (err) {
|
|
767
771
|
const rejectedPath = preserveRejectedGistContent(raw, this.gistId ?? 'unknown');
|
package/dist/core/index.d.ts
CHANGED
|
@@ -37,3 +37,5 @@ export { DashboardDataSchema, DashboardStatsSchema, validateDashboardData, type
|
|
|
37
37
|
export { fetchPRCommentBundle, fetchPRCommentBundlesBatch, type PRCommentBundle, type PRReviewEntry, type PRReviewCommentEntry, type PRIssueCommentEntry, } from './pr-comments-fetcher.js';
|
|
38
38
|
export * from './types.js';
|
|
39
39
|
export { pickSnapshotFromVet, persistPickSnapshots, traitsFromVerification, isFirstInRepo } from './pick-snapshot.js';
|
|
40
|
+
export { WORK_CLAIM_DEFAULT_TTL_HOURS, WORK_CLAIM_FINISHED_TTL_HOURS, WORK_CLAIM_MAX_TTL_HOURS, workClaimKey, isWorkClaimActive, activeWorkClaims, findWorkClaim, heldByOtherSession, finishWorkClaim, finishedImplementations, runningImplementations, normalizeWorktreePath, checkImplementationClaim, workClaimAge, describeWorkClaim, workClaimVetFields, type ImplementationClaimConflict, type CheckoutLocation, } from './work-claims.js';
|
|
41
|
+
export { getMachineId } from './machine-id.js';
|
package/dist/core/index.js
CHANGED
|
@@ -41,3 +41,5 @@ export { DashboardDataSchema, DashboardStatsSchema, validateDashboardData, } fro
|
|
|
41
41
|
export { fetchPRCommentBundle, fetchPRCommentBundlesBatch, } from './pr-comments-fetcher.js';
|
|
42
42
|
export * from './types.js';
|
|
43
43
|
export { pickSnapshotFromVet, persistPickSnapshots, traitsFromVerification, isFirstInRepo } from './pick-snapshot.js';
|
|
44
|
+
export { WORK_CLAIM_DEFAULT_TTL_HOURS, WORK_CLAIM_FINISHED_TTL_HOURS, WORK_CLAIM_MAX_TTL_HOURS, workClaimKey, isWorkClaimActive, activeWorkClaims, findWorkClaim, heldByOtherSession, finishWorkClaim, finishedImplementations, runningImplementations, normalizeWorktreePath, checkImplementationClaim, workClaimAge, describeWorkClaim, workClaimVetFields, } from './work-claims.js';
|
|
45
|
+
export { getMachineId } from './machine-id.js';
|
|
@@ -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
|
|
@@ -16,8 +16,10 @@
|
|
|
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 { getOctokit } from './github.js';
|
|
23
25
|
import { isBotAuthor, isAcknowledgmentComment, isReactionOnlyComment, isQuoteReplyTo, isStatusNudge, } from './comment-utils.js';
|
|
@@ -28,18 +30,22 @@ import { daysBetween } from './dates.js';
|
|
|
28
30
|
import { splitRepo, extractOwnerRepo, isOwnRepo, parseGitHubUrl, issueRefKey } from './urls.js';
|
|
29
31
|
import { runWorkerPool, DEFAULT_CONCURRENCY } from './concurrency.js';
|
|
30
32
|
import { toIssueEngagement } from './engaged-issues.js';
|
|
33
|
+
import { lookupEngagedIssues, } from './engaged-issue-lookup.js';
|
|
31
34
|
import { ConfigurationError, ValidationError, errorMessage, getHttpStatusCode, isRateLimitOrAuthError, } from './errors.js';
|
|
32
35
|
import { debug, warn } from './logger.js';
|
|
33
36
|
const MODULE = 'issue-conversation';
|
|
34
37
|
const MAX_CONCURRENT_REQUESTS = DEFAULT_CONCURRENCY;
|
|
35
38
|
/**
|
|
36
|
-
* Most engaged issues
|
|
37
|
-
* misses them (#1862).
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
39
|
+
* Most engaged issues whose comments are read directly per run when the
|
|
40
|
+
* comment search misses them (#1862). Only issues the batched lookup found
|
|
41
|
+
* open and updated since the engagement count; each costs its comment pages,
|
|
42
|
+
* ETag-cached, so a quiet day is mostly 304s. The cap bounds a first run for
|
|
43
|
+
* a user with many active claims. Most recently updated issues come first,
|
|
44
|
+
* so an issue that gets a new comment moves to the front on the next run,
|
|
45
|
+
* but one that stays quiet behind a hundred busier ones is not read until
|
|
46
|
+
* the busier ones settle. That is why hitting the cap is a warning.
|
|
41
47
|
*/
|
|
42
|
-
export const MAX_DIRECT_ENGAGED_FETCHES =
|
|
48
|
+
export const MAX_DIRECT_ENGAGED_FETCHES = 100;
|
|
43
49
|
/** Associations that indicate someone with repo-level permissions. */
|
|
44
50
|
const MAINTAINER_ASSOCIATIONS = new Set(['OWNER', 'MEMBER', 'COLLABORATOR']);
|
|
45
51
|
function parseMs(value) {
|
|
@@ -51,15 +57,15 @@ function parseMs(value) {
|
|
|
51
57
|
function excerpt(body) {
|
|
52
58
|
return body.slice(0, 200) + (body.length > 200 ? '...' : '');
|
|
53
59
|
}
|
|
60
|
+
/** The label names on a looked-up issue node; GitHub may return null entries. */
|
|
61
|
+
function labelNames(node) {
|
|
62
|
+
const labelNodes = node.labels?.nodes ?? [];
|
|
63
|
+
return labelNodes.filter((label) => label !== null).map((label) => label.name);
|
|
64
|
+
}
|
|
54
65
|
function describeError(error) {
|
|
55
66
|
const status = getHttpStatusCode(error);
|
|
56
67
|
return status === undefined ? errorMessage(error) : `HTTP ${status}: ${errorMessage(error)}`;
|
|
57
68
|
}
|
|
58
|
-
/** 404/410: the issue is gone (deleted, transferred, or now private). */
|
|
59
|
-
function isGoneError(error) {
|
|
60
|
-
const status = getHttpStatusCode(error);
|
|
61
|
-
return status === 404 || status === 410;
|
|
62
|
-
}
|
|
63
69
|
/**
|
|
64
70
|
* Whether a gone engaged issue is worth a warning: a claim or an open PR
|
|
65
71
|
* still points at it and the user can release the claim or fix the PR's
|
|
@@ -117,7 +123,8 @@ export class IssueConversationMonitor {
|
|
|
117
123
|
const cutoffDate = new Date();
|
|
118
124
|
cutoffDate.setDate(cutoffDate.getDate() - maxDays);
|
|
119
125
|
const since = cutoffDate.toISOString().split('T', 1)[0];
|
|
120
|
-
const
|
|
126
|
+
const report = { warnings: [], failures: [] };
|
|
127
|
+
const { warnings, failures } = report;
|
|
121
128
|
debug(MODULE, `Fetching commented issues for @${username} (last ${maxDays} days)...`);
|
|
122
129
|
// Search for open issues the user has commented on, updated within window
|
|
123
130
|
// Single page (100) is sufficient for most users; log if truncated.
|
|
@@ -134,6 +141,7 @@ export class IssueConversationMonitor {
|
|
|
134
141
|
// Also parse repo info for each candidate to avoid re-parsing in analyzeIssueConversation.
|
|
135
142
|
const candidates = [];
|
|
136
143
|
const seenKeys = new Set();
|
|
144
|
+
const searchCandidates = new Map();
|
|
137
145
|
for (const item of data.items) {
|
|
138
146
|
// Defensive: skip pull requests in case type:issue qualifier is unreliable
|
|
139
147
|
if (item.pull_request)
|
|
@@ -151,7 +159,9 @@ export class IssueConversationMonitor {
|
|
|
151
159
|
continue;
|
|
152
160
|
if (!this.isRepoAllowed(repoFullName, config))
|
|
153
161
|
continue;
|
|
154
|
-
|
|
162
|
+
const candidate = { item, repoFullName, engagement: engaged.get(key), url: item.html_url };
|
|
163
|
+
candidates.push(candidate);
|
|
164
|
+
searchCandidates.set(key, candidate);
|
|
155
165
|
}
|
|
156
166
|
// Live engaged issues the search did not return are looked up directly.
|
|
157
167
|
const missing = [];
|
|
@@ -163,33 +173,17 @@ export class IssueConversationMonitor {
|
|
|
163
173
|
continue;
|
|
164
174
|
missing.push(entry);
|
|
165
175
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
for (const entry of missing.slice(0, MAX_DIRECT_ENGAGED_FETCHES)) {
|
|
173
|
-
const parsed = parseGitHubUrl(entry.url);
|
|
174
|
-
if (!parsed)
|
|
175
|
-
continue;
|
|
176
|
-
candidates.push({
|
|
177
|
-
url: entry.url,
|
|
178
|
-
repoFullName: `${parsed.owner}/${parsed.repo}`,
|
|
179
|
-
number: parsed.number,
|
|
180
|
-
engagement: entry,
|
|
181
|
-
});
|
|
182
|
-
}
|
|
176
|
+
const context = { username, config, cutoffDate, seenKeys, searchCandidates, report };
|
|
177
|
+
candidates.push(...(await this.collectDirectCandidates(missing, context)));
|
|
178
|
+
// Lookup failures are already in `failures`; the analysis tallies below
|
|
179
|
+
// count only the candidates the pool analyzed.
|
|
180
|
+
const lookupFailures = failures.length;
|
|
183
181
|
debug(MODULE, `Found ${candidates.length} commented issues to check`);
|
|
184
182
|
// Fetch comments for each issue using worker pool.
|
|
185
183
|
const results = [];
|
|
186
|
-
const failures = [];
|
|
187
184
|
await runWorkerPool(candidates, async (candidate) => {
|
|
188
185
|
try {
|
|
189
|
-
const
|
|
190
|
-
if (!item)
|
|
191
|
-
return;
|
|
192
|
-
const issue = await this.analyzeIssueConversation(item, candidate.repoFullName, username, candidate.engagement, warnings);
|
|
186
|
+
const issue = await this.analyzeIssueConversation(candidate.item, candidate.repoFullName, username, candidate.engagement, warnings);
|
|
193
187
|
if (issue) {
|
|
194
188
|
results.push(issue);
|
|
195
189
|
return;
|
|
@@ -211,27 +205,19 @@ export class IssueConversationMonitor {
|
|
|
211
205
|
// aborting the run just like PRMonitor's 429s do.
|
|
212
206
|
if (isRateLimitOrAuthError(error))
|
|
213
207
|
throw error;
|
|
214
|
-
if (candidate.item === undefined && isGoneError(error)) {
|
|
215
|
-
// Only a direct fetch can see a 404/410: the issue was deleted,
|
|
216
|
-
// transferred, or made private since the PR or claim linked it.
|
|
217
|
-
// Worth telling the user only while something of theirs still
|
|
218
|
-
// points at it (a claim to release, an open PR's closing link).
|
|
219
|
-
const message = `${candidate.url}: issue no longer reachable (${describeError(error)}); dropped`;
|
|
220
|
-
if (isActionableEngagement(candidate.engagement))
|
|
221
|
-
warnings.push(message);
|
|
222
|
-
else
|
|
223
|
-
debug(MODULE, message);
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
208
|
const msg = describeError(error);
|
|
227
209
|
failures.push({ issueUrl: candidate.url, error: msg });
|
|
228
210
|
warn(MODULE, `Error analyzing issue ${candidate.url}: ${msg}`);
|
|
229
211
|
}
|
|
230
212
|
}, MAX_CONCURRENT_REQUESTS);
|
|
231
|
-
|
|
232
|
-
|
|
213
|
+
const analysisFailures = failures.length - lookupFailures;
|
|
214
|
+
if (lookupFailures > 0) {
|
|
215
|
+
warn(MODULE, `${lookupFailures} engaged issue lookup(s) failed`);
|
|
216
|
+
}
|
|
217
|
+
if (analysisFailures > 0) {
|
|
218
|
+
warn(MODULE, `${analysisFailures}/${candidates.length} issue analysis call(s) failed`);
|
|
233
219
|
}
|
|
234
|
-
if (
|
|
220
|
+
if (analysisFailures === candidates.length && candidates.length > 0) {
|
|
235
221
|
warn(MODULE, `All ${candidates.length} issue analysis call(s) failed. Possible systemic issue (network, GitHub availability).`);
|
|
236
222
|
}
|
|
237
223
|
for (const message of warnings)
|
|
@@ -244,7 +230,7 @@ export class IssueConversationMonitor {
|
|
|
244
230
|
};
|
|
245
231
|
results.sort((a, b) => statusOrder[a.status] - statusOrder[b.status]);
|
|
246
232
|
debug(MODULE, `Analyzed ${results.length} issue conversations (${results.filter((i) => i.status === 'new_response').length} with new responses)`);
|
|
247
|
-
return {
|
|
233
|
+
return { failures, lookupFailures, warnings, issues: results };
|
|
248
234
|
}
|
|
249
235
|
/** Repo-level exclusions shared by the search results and the direct fetches. */
|
|
250
236
|
isRepoAllowed(repoFullName, config) {
|
|
@@ -260,33 +246,129 @@ export class IssueConversationMonitor {
|
|
|
260
246
|
return !blocklist.includes(repoFullName.toLowerCase());
|
|
261
247
|
}
|
|
262
248
|
/**
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
*
|
|
269
|
-
*
|
|
270
|
-
*
|
|
271
|
-
*
|
|
249
|
+
* Candidates for the engaged issues the comment search did not return
|
|
250
|
+
* (#1862): one batched GraphQL lookup for all of them, then the issues
|
|
251
|
+
* still open, not the user's own, and updated since the later of the
|
|
252
|
+
* search window's start and the engagement step, most recently updated
|
|
253
|
+
* first, up to {@link MAX_DIRECT_ENGAGED_FETCHES}. The window keeps this
|
|
254
|
+
* path consistent with the commenter search (a reply older than `maxDays`
|
|
255
|
+
* is not surfaced either way); the engagement step tightens it because
|
|
256
|
+
* only comments after that step can be replies to the user. The issues
|
|
257
|
+
* past the cap are named in a warning: the next run reorders by update
|
|
258
|
+
* time again, so one that is commented on moves to the front, but with a
|
|
259
|
+
* hundred busier issues ahead of it a quiet one can wait a long time.
|
|
260
|
+
*
|
|
261
|
+
* @throws The lookup's rate-limit or auth error; other lookup failures are
|
|
262
|
+
* recorded per issue in `report.failures`.
|
|
272
263
|
*/
|
|
273
|
-
async
|
|
274
|
-
const
|
|
275
|
-
const
|
|
276
|
-
|
|
264
|
+
async collectDirectCandidates(missing, context) {
|
|
265
|
+
const refs = [];
|
|
266
|
+
for (const entry of missing) {
|
|
267
|
+
const parsed = parseGitHubUrl(entry.url);
|
|
268
|
+
if (parsed)
|
|
269
|
+
refs.push({ owner: parsed.owner, repo: parsed.repo, number: parsed.number, url: entry.url });
|
|
270
|
+
}
|
|
271
|
+
if (refs.length === 0)
|
|
272
|
+
return [];
|
|
273
|
+
const lookups = await lookupEngagedIssues(this.octokit, refs);
|
|
274
|
+
const active = [];
|
|
275
|
+
for (const entry of missing) {
|
|
276
|
+
const outcome = lookups.get(entry.url);
|
|
277
|
+
if (!outcome)
|
|
278
|
+
continue;
|
|
279
|
+
const direct = this.toDirectCandidate(entry, outcome, context);
|
|
280
|
+
if (direct)
|
|
281
|
+
active.push(direct);
|
|
282
|
+
}
|
|
283
|
+
active.sort((a, b) => b.updatedMs - a.updatedMs);
|
|
284
|
+
const deferred = active.slice(MAX_DIRECT_ENGAGED_FETCHES);
|
|
285
|
+
if (deferred.length > 0) {
|
|
286
|
+
const plural = deferred.length === 1 ? '' : 's';
|
|
287
|
+
context.report.warnings.push(`${deferred.length} engaged issue${plural} with new activity ${deferred.length === 1 ? 'was' : 'were'} not scanned this run (cap of ${MAX_DIRECT_ENGAGED_FETCHES} comment fetches per run, most recently updated first; replies there stay unseen until fewer issues are busier): ${deferred.map((d) => d.candidate.url).join(', ')}`);
|
|
288
|
+
}
|
|
289
|
+
return active.slice(0, MAX_DIRECT_ENGAGED_FETCHES).map((d) => d.candidate);
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* The direct candidate one lookup outcome yields, or undefined with the
|
|
293
|
+
* reason logged: a lookup failure (recorded), a gone issue (a warning only
|
|
294
|
+
* while a claim or an open PR still points at it), a pull request number,
|
|
295
|
+
* a closed issue, one the user authored, or one untouched since the
|
|
296
|
+
* engagement. The candidate's repo and number come from the node's URL,
|
|
297
|
+
* not the engagement's: GitHub follows a transferred issue to its new
|
|
298
|
+
* repo, and the comments live there. So the repo exclusions and the
|
|
299
|
+
* search dedupe run again on that URL: a transfer into an excluded repo
|
|
300
|
+
* is skipped, and one onto an issue the search already returned adds no
|
|
301
|
+
* second candidate but lends that one the engagement (the engaged reply
|
|
302
|
+
* rule applies there too) unless it has its own.
|
|
303
|
+
*/
|
|
304
|
+
toDirectCandidate(entry, outcome, context) {
|
|
305
|
+
const { username, cutoffDate, report } = context;
|
|
306
|
+
if (outcome.kind === 'failed') {
|
|
307
|
+
report.failures.push({ issueUrl: entry.url, error: outcome.error });
|
|
308
|
+
warn(MODULE, `Error looking up engaged issue ${entry.url}: ${outcome.error}`);
|
|
309
|
+
return undefined;
|
|
310
|
+
}
|
|
311
|
+
if (outcome.kind === 'gone') {
|
|
312
|
+
// The issue was deleted, transferred, or made private since the PR or
|
|
313
|
+
// claim linked it. Worth telling the user only while something of
|
|
314
|
+
// theirs still points at it (a claim to release, an open PR's closing
|
|
315
|
+
// link); a finished PR's link is history.
|
|
316
|
+
const message = `${entry.url}: issue no longer reachable (${outcome.reason}); dropped`;
|
|
317
|
+
if (isActionableEngagement(entry))
|
|
318
|
+
report.warnings.push(message);
|
|
319
|
+
else
|
|
320
|
+
debug(MODULE, message);
|
|
321
|
+
return undefined;
|
|
322
|
+
}
|
|
277
323
|
const skip = (reason) => {
|
|
278
|
-
debug(MODULE, `Skipping engaged issue ${
|
|
324
|
+
debug(MODULE, `Skipping engaged issue ${entry.url}: ${reason}`);
|
|
279
325
|
};
|
|
280
|
-
if (
|
|
326
|
+
if (outcome.kind === 'pull_request')
|
|
281
327
|
return skip('the number is a pull request');
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
328
|
+
const { node } = outcome;
|
|
329
|
+
if (node.state !== 'OPEN')
|
|
330
|
+
return skip(`issue is ${node.state.toLowerCase()}`);
|
|
331
|
+
if (node.author?.login.toLowerCase() === username.toLowerCase())
|
|
285
332
|
return skip('authored by the user');
|
|
286
|
-
const
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
333
|
+
const updatedMs = parseMs(node.updatedAt);
|
|
334
|
+
const activitySinceMs = Math.max(cutoffDate.getTime(), parseMs(entry.since));
|
|
335
|
+
if (updatedMs < activitySinceMs)
|
|
336
|
+
return skip(`not updated since ${node.updatedAt}`);
|
|
337
|
+
const parsed = extractOwnerRepo(node.url);
|
|
338
|
+
if (!parsed) {
|
|
339
|
+
report.warnings.push(`${entry.url}: skipped; GitHub returned it at an unparseable URL "${node.url}"`);
|
|
340
|
+
return undefined;
|
|
341
|
+
}
|
|
342
|
+
const repoFullName = `${parsed.owner}/${parsed.repo}`;
|
|
343
|
+
const covered = this.transferredIssueCoverage(entry, node.url, repoFullName, context);
|
|
344
|
+
if (covered)
|
|
345
|
+
return skip(covered);
|
|
346
|
+
const item = { html_url: node.url, number: node.number, title: node.title, labels: labelNames(node) };
|
|
347
|
+
const candidate = { item, repoFullName, url: node.url, engagement: entry };
|
|
348
|
+
return { candidate, updatedMs };
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Why a looked-up issue needs no candidate at the URL GitHub returned it,
|
|
352
|
+
* or undefined when it does (and its key is then marked seen). Only a
|
|
353
|
+
* transferred issue can be covered: the engagement's own repo passed the
|
|
354
|
+
* exclusions before the lookup and its own key was not among the search
|
|
355
|
+
* results. A transfer into an excluded repo is skipped; one onto an
|
|
356
|
+
* issue the search returned lends that candidate the engagement unless
|
|
357
|
+
* it has its own, so the engaged reply rule applies there.
|
|
358
|
+
*/
|
|
359
|
+
transferredIssueCoverage(entry, url, repoFullName, { config, seenKeys, searchCandidates }) {
|
|
360
|
+
if (!this.isRepoAllowed(repoFullName, config))
|
|
361
|
+
return `now at ${url}, a repo that is excluded`;
|
|
362
|
+
const key = issueRefKey(url) ?? url;
|
|
363
|
+
const found = searchCandidates.get(key);
|
|
364
|
+
if (found) {
|
|
365
|
+
found.engagement ??= entry;
|
|
366
|
+
return `now at ${url}, which the search already returned`;
|
|
367
|
+
}
|
|
368
|
+
if (seenKeys.has(key))
|
|
369
|
+
return `now at ${url}, which is already covered`;
|
|
370
|
+
seenKeys.add(key);
|
|
371
|
+
return undefined;
|
|
290
372
|
}
|
|
291
373
|
/**
|
|
292
374
|
* Analyze a single issue's comment thread to determine conversation status.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable machine identity (#1856): a random UUID written once to
|
|
3
|
+
* `~/.oss-autopilot/machine-id` and read back on every later need.
|
|
4
|
+
*
|
|
5
|
+
* Work claims record the id next to a `worktree` path so two claims are
|
|
6
|
+
* compared as the same checkout only when they are on the same machine. A
|
|
7
|
+
* hostname cannot do that: it changes with the network (`air.local`) or a
|
|
8
|
+
* rename (`air` to `air-2`), and two machines can share one. The file lives
|
|
9
|
+
* outside `state.json`, so the Gist never carries it and no machine inherits
|
|
10
|
+
* another's id. A read or write failure yields no id (with a debug line);
|
|
11
|
+
* claims then fall back to the hostname rule.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* This machine's id, creating `~/.oss-autopilot/machine-id` on first need.
|
|
15
|
+
* Returns undefined when the file can neither be read nor written; callers
|
|
16
|
+
* treat that as "unknown machine" rather than failing.
|
|
17
|
+
*/
|
|
18
|
+
export declare function getMachineId(): string | undefined;
|