@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.
Files changed (49) hide show
  1. package/dist/cli-registry.js +25 -2
  2. package/dist/cli.bundle.cjs +142 -118
  3. package/dist/commands/daily.js +21 -2
  4. package/dist/commands/ledger-backfill.d.ts +7 -0
  5. package/dist/commands/ledger-backfill.js +116 -6
  6. package/dist/commands/repo-cap.d.ts +10 -0
  7. package/dist/commands/repo-cap.js +23 -0
  8. package/dist/commands/scout-bridge.js +8 -2
  9. package/dist/commands/search.js +7 -1
  10. package/dist/commands/setup.js +6 -4
  11. package/dist/commands/vet-list.js +20 -17
  12. package/dist/commands/vet.js +29 -2
  13. package/dist/core/ci-analysis.js +14 -1
  14. package/dist/core/comment-utils.d.ts +5 -2
  15. package/dist/core/comment-utils.js +11 -3
  16. package/dist/core/config-registry.js +12 -0
  17. package/dist/core/daily-logic.d.ts +36 -1
  18. package/dist/core/daily-logic.js +113 -3
  19. package/dist/core/eval-report.d.ts +8 -0
  20. package/dist/core/eval-report.js +81 -4
  21. package/dist/core/index.d.ts +4 -4
  22. package/dist/core/index.js +4 -4
  23. package/dist/core/issue-verification.d.ts +12 -0
  24. package/dist/core/issue-verification.js +18 -0
  25. package/dist/core/pick-snapshot.d.ts +19 -2
  26. package/dist/core/pick-snapshot.js +27 -1
  27. package/dist/core/pr-assembly.d.ts +11 -1
  28. package/dist/core/pr-assembly.js +21 -4
  29. package/dist/core/pr-attention.d.ts +14 -0
  30. package/dist/core/pr-attention.js +18 -0
  31. package/dist/core/pr-graphql.d.ts +31 -1
  32. package/dist/core/pr-graphql.js +49 -5
  33. package/dist/core/pr-monitor.d.ts +37 -6
  34. package/dist/core/pr-monitor.js +41 -12
  35. package/dist/core/repo-cap.d.ts +46 -0
  36. package/dist/core/repo-cap.js +102 -0
  37. package/dist/core/repo-score-manager.d.ts +0 -13
  38. package/dist/core/repo-score-manager.js +0 -24
  39. package/dist/core/review-analysis.d.ts +98 -14
  40. package/dist/core/review-analysis.js +145 -25
  41. package/dist/core/state-schema.d.ts +58 -0
  42. package/dist/core/state-schema.js +37 -0
  43. package/dist/core/state.d.ts +8 -15
  44. package/dist/core/state.js +19 -24
  45. package/dist/core/status-determination.js +11 -11
  46. package/dist/core/types.d.ts +32 -2
  47. package/dist/formatters/json.d.ts +29 -0
  48. package/dist/formatters/json.js +17 -0
  49. package/package.json +1 -1
@@ -9,7 +9,9 @@ export interface ReviewComment {
9
9
  id: number;
10
10
  user?: {
11
11
  login?: string;
12
+ type?: string | null;
12
13
  } | null;
14
+ author_association?: string | null;
13
15
  body?: string | null;
14
16
  created_at: string;
15
17
  in_reply_to_id?: number;
@@ -23,20 +25,30 @@ export interface ReviewComment {
23
25
  * Only APPROVED, CHANGES_REQUESTED and DISMISSED change a reviewer's standing
24
26
  * verdict on GitHub. COMMENTED is also what GitHub records for every inline
25
27
  * reply, so it must not overwrite an earlier verdict from the same reviewer.
28
+ *
29
+ * Bot-authored reviews (e.g. an AI review bot posting APPROVE) are ignored so a
30
+ * bot alone never reads as maintainer approval or a changes request (#1840).
26
31
  */
27
32
  export declare function determineReviewDecision(reviews: Array<{
28
33
  state?: string | null;
29
34
  user?: {
30
35
  login?: string;
36
+ type?: string | null;
31
37
  } | null;
32
38
  }>): ReviewDecision;
33
39
  /**
34
- * Get the date of the latest CHANGES_REQUESTED review (from any reviewer).
40
+ * Get the date of the latest CHANGES_REQUESTED review (from any human reviewer).
35
41
  * Used to detect needs_changes status when review feedback is in inline comments.
42
+ * Bot reviews are skipped (#1840): a bot re-reviewing every push would otherwise
43
+ * move the date past the author's fix commit.
36
44
  */
37
45
  export declare function getLatestChangesRequestedDate(reviews: Array<{
38
46
  state?: string | null;
39
47
  submitted_at?: string | null;
48
+ user?: {
49
+ login?: string;
50
+ type?: string | null;
51
+ } | null;
40
52
  }>): string | undefined;
41
53
  /**
42
54
  * Check if all inline comments in a COMMENTED review are self-replies.
@@ -59,21 +71,15 @@ export declare function getInlineCommentBody(reviewId: number, reviewComments: R
59
71
  export declare function reviewHasInlineComments(reviewId: number, reviewComments: ReviewComment[]): boolean;
60
72
  /**
61
73
  * Earliest maintainer response timestamp across issue comments and submitted
62
- * reviews (#1461). A "response" is any comment or review by a non-bot
63
- * account other than the contributor — acknowledgments and approvals count,
64
- * since for latency purposes any human maintainer reply is a response.
65
- * Computed from data fetchPRDetails already holds in memory (zero extra API
66
- * calls). Returns undefined when no maintainer has responded yet.
74
+ * reviews (#1461). "Maintainer" is the same rule the dormancy clock uses
75
+ * ({@link isMaintainerEngagement}): issue comments count only from OWNER /
76
+ * MEMBER / COLLABORATOR (any non-bot non-contributor when the association is
77
+ * unknown), reviews from any non-bot non-contributor. Acknowledgments and
78
+ * approvals count. Returns undefined when no maintainer has responded yet.
67
79
  */
68
- export declare function getFirstMaintainerResponseAt(comments: Array<{
69
- user?: {
70
- login?: string;
71
- } | null;
80
+ export declare function getFirstMaintainerResponseAt(comments: Array<ActorFields & {
72
81
  created_at: string;
73
- }>, reviews: Array<{
74
- user?: {
75
- login?: string;
76
- } | null;
82
+ }>, reviews: Array<ActorFields & {
77
83
  submitted_at?: string | null;
78
84
  }>, username: string): string | undefined;
79
85
  /**
@@ -84,12 +90,14 @@ export declare function getFirstMaintainerResponseAt(comments: Array<{
84
90
  export declare function checkUnrespondedComments(comments: Array<{
85
91
  user?: {
86
92
  login?: string;
93
+ type?: string | null;
87
94
  } | null;
88
95
  body?: string | null;
89
96
  created_at: string;
90
97
  }>, reviews: Array<{
91
98
  user?: {
92
99
  login?: string;
100
+ type?: string | null;
93
101
  } | null;
94
102
  body?: string | null;
95
103
  submitted_at?: string | null;
@@ -99,3 +107,79 @@ export declare function checkUnrespondedComments(comments: Array<{
99
107
  hasUnrespondedComment: boolean;
100
108
  lastMaintainerComment?: FetchedPR['lastMaintainerComment'];
101
109
  };
110
+ /** A non-comment PR event: a commit, force-push, review request or label. */
111
+ export interface ActivityEvent {
112
+ login?: string | null;
113
+ /** REST `user.type` / GraphQL `__typename` of the actor (`'Bot'` for apps). */
114
+ type?: string | null;
115
+ at?: string | null;
116
+ /**
117
+ * True for commits and force-pushes. A push by a bot still counts as
118
+ * maintainer activity (a maintainer's own GitHub App pushing fixes), unless
119
+ * the bot is an auto-fixer or dependency bot in {@link PUSH_BOT_DENYLIST}.
120
+ */
121
+ isPush?: boolean;
122
+ }
123
+ /**
124
+ * Minimum gap since the previous activity (maintainer or contributor) for a
125
+ * contributor comment to count as a "ping". A same-day reply to a maintainer
126
+ * is conversation, not a nudge.
127
+ */
128
+ export declare const PING_MIN_GAP_DAYS = 7;
129
+ type ActorFields = {
130
+ user?: {
131
+ login?: string;
132
+ type?: string | null;
133
+ } | null;
134
+ author_association?: string | null;
135
+ };
136
+ /**
137
+ * Version of {@link isMaintainerEngagement}. Bump it when the rule changes so
138
+ * ledger-backfill recomputes stored `firstMaintainerResponseAt` values. Rule 1
139
+ * (implicit, unstamped) counted any non-author non-bot issue comment.
140
+ */
141
+ export declare const MAINTAINER_RESPONSE_RULE = 2;
142
+ /**
143
+ * Whether a comment or review counts as maintainer engagement. Shared by the
144
+ * dormancy clock ({@link getLastMaintainerActivity}, #1842) and first-response
145
+ * latency ({@link getFirstMaintainerResponseAt}) so both agree on who a
146
+ * maintainer is: never the contributor or a bot; an issue comment additionally
147
+ * needs an OWNER / MEMBER / COLLABORATOR association when one is known, so
148
+ * drive-by "+1"s don't count. Reviews and inline review comments count from
149
+ * any other account, since codeowners often show as CONTRIBUTOR.
150
+ */
151
+ export declare function isMaintainerEngagement(actor: ActorFields, username: string, kind: 'issue-comment' | 'review'): boolean;
152
+ /**
153
+ * Latest maintainer activity on a PR, falling back to `createdAt` when no
154
+ * maintainer has engaged, plus the number of contributor pings since then.
155
+ *
156
+ * Maintainer activity is any of:
157
+ * - an issue comment by an OWNER / MEMBER / COLLABORATOR, so drive-by "+1"
158
+ * comments don't reset the clock (when the association is unknown, as on
159
+ * older data, any non-contributor non-bot author counts);
160
+ * - a review or inline review comment by any non-contributor non-bot user
161
+ * (codeowners often show as CONTRIBUTOR);
162
+ * - a commit authored or committed by someone else, or a force-push by
163
+ * someone else, including bots such as a maintainer's own GitHub App,
164
+ * except auto-fixer / dependency bots ({@link PUSH_BOT_DENYLIST});
165
+ * - a review request or label by a non-contributor non-bot actor.
166
+ *
167
+ * Staleness is measured from this timestamp rather than `updatedAt`, because
168
+ * `updatedAt` is bumped by the contributor's own follow-ups and rebases, so a
169
+ * PR the maintainers have ignored for months never looked dormant.
170
+ *
171
+ * A contributor comment counts as a ping only when it comes at least
172
+ * {@link PING_MIN_GAP_DAYS} after the previous activity (the maintainer
173
+ * activity or the contributor's own previous comment).
174
+ */
175
+ export declare function getLastMaintainerActivity(comments: Array<ActorFields & {
176
+ created_at: string;
177
+ }>, reviews: Array<ActorFields & {
178
+ submitted_at?: string | null;
179
+ }>, reviewComments: Array<ActorFields & {
180
+ created_at: string;
181
+ }>, events: ActivityEvent[], username: string, createdAt: string): {
182
+ lastMaintainerActivityAt: string;
183
+ authorPingsSinceMaintainerActivity: number;
184
+ };
185
+ export {};
@@ -4,6 +4,10 @@
4
4
  * Extracted from PRMonitor to isolate review-related logic (#263).
5
5
  */
6
6
  import { isBotAuthor, isAcknowledgmentComment } from './comment-utils.js';
7
+ /** True when a review's author is a bot (#1840); bots never set the review decision. */
8
+ function isBotReview(review) {
9
+ return isBotAuthor(review.user?.login ?? '', review.user?.type);
10
+ }
7
11
  /**
8
12
  * Determine review decision from reviews list.
9
13
  * Groups reviews by user, keeping each user's latest verdict, then checks
@@ -12,6 +16,9 @@ import { isBotAuthor, isAcknowledgmentComment } from './comment-utils.js';
12
16
  * Only APPROVED, CHANGES_REQUESTED and DISMISSED change a reviewer's standing
13
17
  * verdict on GitHub. COMMENTED is also what GitHub records for every inline
14
18
  * reply, so it must not overwrite an earlier verdict from the same reviewer.
19
+ *
20
+ * Bot-authored reviews (e.g. an AI review bot posting APPROVE) are ignored so a
21
+ * bot alone never reads as maintainer approval or a changes request (#1840).
15
22
  */
16
23
  export function determineReviewDecision(reviews) {
17
24
  if (reviews.length === 0) {
@@ -22,7 +29,7 @@ export function determineReviewDecision(reviews) {
22
29
  for (const review of reviews) {
23
30
  const login = review.user?.login;
24
31
  const state = review.state;
25
- if (!login || !state)
32
+ if (!login || !state || isBotReview(review))
26
33
  continue;
27
34
  if (state === 'DISMISSED') {
28
35
  latestByUser.delete(login);
@@ -41,13 +48,17 @@ export function determineReviewDecision(reviews) {
41
48
  return 'review_required';
42
49
  }
43
50
  /**
44
- * Get the date of the latest CHANGES_REQUESTED review (from any reviewer).
51
+ * Get the date of the latest CHANGES_REQUESTED review (from any human reviewer).
45
52
  * Used to detect needs_changes status when review feedback is in inline comments.
53
+ * Bot reviews are skipped (#1840): a bot re-reviewing every push would otherwise
54
+ * move the date past the author's fix commit.
46
55
  */
47
56
  export function getLatestChangesRequestedDate(reviews) {
48
57
  let latest;
49
58
  for (const review of reviews) {
50
- if (review.state === 'CHANGES_REQUESTED' && review.submitted_at && (!latest || review.submitted_at > latest)) {
59
+ if (review.state !== 'CHANGES_REQUESTED' || isBotReview(review))
60
+ continue;
61
+ if (review.submitted_at && (!latest || review.submitted_at > latest)) {
51
62
  latest = review.submitted_at;
52
63
  }
53
64
  }
@@ -106,30 +117,22 @@ export function reviewHasInlineComments(reviewId, reviewComments) {
106
117
  }
107
118
  /**
108
119
  * Earliest maintainer response timestamp across issue comments and submitted
109
- * reviews (#1461). A "response" is any comment or review by a non-bot
110
- * account other than the contributor — acknowledgments and approvals count,
111
- * since for latency purposes any human maintainer reply is a response.
112
- * Computed from data fetchPRDetails already holds in memory (zero extra API
113
- * calls). Returns undefined when no maintainer has responded yet.
120
+ * reviews (#1461). "Maintainer" is the same rule the dormancy clock uses
121
+ * ({@link isMaintainerEngagement}): issue comments count only from OWNER /
122
+ * MEMBER / COLLABORATOR (any non-bot non-contributor when the association is
123
+ * unknown), reviews from any non-bot non-contributor. Acknowledgments and
124
+ * approvals count. Returns undefined when no maintainer has responded yet.
114
125
  */
115
126
  export function getFirstMaintainerResponseAt(comments, reviews, username) {
116
- const usernameLower = username.toLowerCase();
127
+ const times = [
128
+ ...comments.filter((c) => isMaintainerEngagement(c, username, 'issue-comment')).map((c) => c.created_at),
129
+ ...reviews.filter((r) => isMaintainerEngagement(r, username, 'review')).map((r) => r.submitted_at),
130
+ ];
117
131
  let earliest;
118
- const consider = (author, createdAt) => {
119
- if (!author || !createdAt)
120
- return;
121
- if (author.toLowerCase() === usernameLower)
122
- return;
123
- if (isBotAuthor(author))
124
- return;
125
- if (!earliest || new Date(createdAt).getTime() < new Date(earliest).getTime()) {
126
- earliest = createdAt;
127
- }
128
- };
129
- for (const comment of comments)
130
- consider(comment.user?.login, comment.created_at);
131
- for (const review of reviews)
132
- consider(review.user?.login, review.submitted_at);
132
+ for (const t of times) {
133
+ if (t && Number.isFinite(Date.parse(t)) && (!earliest || Date.parse(t) < Date.parse(earliest)))
134
+ earliest = t;
135
+ }
133
136
  return earliest;
134
137
  }
135
138
  /**
@@ -145,6 +148,7 @@ export function checkUnrespondedComments(comments, reviews, reviewComments, user
145
148
  const author = comment.user?.login || 'unknown';
146
149
  timeline.push({
147
150
  author,
151
+ userType: comment.user?.type,
148
152
  body: comment.body || '',
149
153
  createdAt: comment.created_at,
150
154
  isUser: author.toLowerCase() === usernameLower,
@@ -174,6 +178,7 @@ export function checkUnrespondedComments(comments, reviews, reviewComments, user
174
178
  : '(posted inline review comments)');
175
179
  timeline.push({
176
180
  author,
181
+ userType: review.user?.type,
177
182
  body: resolvedBody,
178
183
  createdAt: review.submitted_at,
179
184
  isUser: author.toLowerCase() === usernameLower,
@@ -197,7 +202,7 @@ export function checkUnrespondedComments(comments, reviews, reviewComments, user
197
202
  continue; // Skip user's own comments
198
203
  if (item.author === 'unknown')
199
204
  continue; // Skip deleted/null accounts
200
- if (isBotAuthor(item.author))
205
+ if (isBotAuthor(item.author, item.userType))
201
206
  continue; // Skip bots
202
207
  const itemTime = new Date(item.createdAt);
203
208
  if (!lastUserCommentTime || itemTime > lastUserCommentTime) {
@@ -221,3 +226,118 @@ export function checkUnrespondedComments(comments, reviews, reviewComments, user
221
226
  lastMaintainerComment,
222
227
  };
223
228
  }
229
+ /**
230
+ * Bots whose pushes are automation, not maintainer engagement. Compared
231
+ * case-insensitively with any `[bot]` suffix stripped.
232
+ */
233
+ const PUSH_BOT_DENYLIST = new Set([
234
+ 'pre-commit-ci',
235
+ 'autofix-ci',
236
+ 'prettier-ci',
237
+ 'github-actions',
238
+ 'dependabot',
239
+ 'renovate',
240
+ 'web-flow',
241
+ ]);
242
+ /** Author associations that mark a commenter as a repo maintainer. */
243
+ const MAINTAINER_ASSOCIATIONS = new Set(['OWNER', 'MEMBER', 'COLLABORATOR']);
244
+ /**
245
+ * Minimum gap since the previous activity (maintainer or contributor) for a
246
+ * contributor comment to count as a "ping". A same-day reply to a maintainer
247
+ * is conversation, not a nudge.
248
+ */
249
+ export const PING_MIN_GAP_DAYS = 7;
250
+ /**
251
+ * Version of {@link isMaintainerEngagement}. Bump it when the rule changes so
252
+ * ledger-backfill recomputes stored `firstMaintainerResponseAt` values. Rule 1
253
+ * (implicit, unstamped) counted any non-author non-bot issue comment.
254
+ */
255
+ export const MAINTAINER_RESPONSE_RULE = 2;
256
+ /**
257
+ * Whether a comment or review counts as maintainer engagement. Shared by the
258
+ * dormancy clock ({@link getLastMaintainerActivity}, #1842) and first-response
259
+ * latency ({@link getFirstMaintainerResponseAt}) so both agree on who a
260
+ * maintainer is: never the contributor or a bot; an issue comment additionally
261
+ * needs an OWNER / MEMBER / COLLABORATOR association when one is known, so
262
+ * drive-by "+1"s don't count. Reviews and inline review comments count from
263
+ * any other account, since codeowners often show as CONTRIBUTOR.
264
+ */
265
+ export function isMaintainerEngagement(actor, username, kind) {
266
+ const login = actor.user?.login;
267
+ if (!login || login.toLowerCase() === username.toLowerCase())
268
+ return false;
269
+ if (isBotAuthor(login, actor.user?.type))
270
+ return false;
271
+ const association = actor.author_association;
272
+ return kind === 'review' || !association || MAINTAINER_ASSOCIATIONS.has(association);
273
+ }
274
+ /**
275
+ * Latest maintainer activity on a PR, falling back to `createdAt` when no
276
+ * maintainer has engaged, plus the number of contributor pings since then.
277
+ *
278
+ * Maintainer activity is any of:
279
+ * - an issue comment by an OWNER / MEMBER / COLLABORATOR, so drive-by "+1"
280
+ * comments don't reset the clock (when the association is unknown, as on
281
+ * older data, any non-contributor non-bot author counts);
282
+ * - a review or inline review comment by any non-contributor non-bot user
283
+ * (codeowners often show as CONTRIBUTOR);
284
+ * - a commit authored or committed by someone else, or a force-push by
285
+ * someone else, including bots such as a maintainer's own GitHub App,
286
+ * except auto-fixer / dependency bots ({@link PUSH_BOT_DENYLIST});
287
+ * - a review request or label by a non-contributor non-bot actor.
288
+ *
289
+ * Staleness is measured from this timestamp rather than `updatedAt`, because
290
+ * `updatedAt` is bumped by the contributor's own follow-ups and rebases, so a
291
+ * PR the maintainers have ignored for months never looked dormant.
292
+ *
293
+ * A contributor comment counts as a ping only when it comes at least
294
+ * {@link PING_MIN_GAP_DAYS} after the previous activity (the maintainer
295
+ * activity or the contributor's own previous comment).
296
+ */
297
+ export function getLastMaintainerActivity(comments, reviews, reviewComments, events, username, createdAt) {
298
+ const usernameLower = username.toLowerCase();
299
+ let latest = createdAt;
300
+ let latestMs = Date.parse(createdAt);
301
+ const consider = (login, type, at, isPush = false) => {
302
+ if (!login || !at)
303
+ return;
304
+ const lower = login.toLowerCase();
305
+ if (lower === usernameLower)
306
+ return;
307
+ if (isPush ? PUSH_BOT_DENYLIST.has(lower.replace(/\[bot\]$/, '')) : isBotAuthor(login, type))
308
+ return;
309
+ const ms = Date.parse(at);
310
+ if (ms > latestMs) {
311
+ latest = at;
312
+ latestMs = ms;
313
+ }
314
+ };
315
+ for (const c of comments) {
316
+ if (isMaintainerEngagement(c, username, 'issue-comment'))
317
+ consider(c.user?.login, c.user?.type, c.created_at);
318
+ }
319
+ for (const r of reviews) {
320
+ if (isMaintainerEngagement(r, username, 'review'))
321
+ consider(r.user?.login, r.user?.type, r.submitted_at);
322
+ }
323
+ for (const c of reviewComments) {
324
+ if (isMaintainerEngagement(c, username, 'review'))
325
+ consider(c.user?.login, c.user?.type, c.created_at);
326
+ }
327
+ for (const e of events)
328
+ consider(e.login, e.type, e.at, e.isPush);
329
+ const authorCommentTimes = comments
330
+ .filter((c) => c.user?.login?.toLowerCase() === usernameLower)
331
+ .map((c) => Date.parse(c.created_at))
332
+ .filter((ms) => ms > latestMs);
333
+ authorCommentTimes.sort((a, b) => a - b);
334
+ const minGapMs = PING_MIN_GAP_DAYS * 86_400_000;
335
+ let previousMs = latestMs;
336
+ let authorPingsSinceMaintainerActivity = 0;
337
+ for (const ms of authorCommentTimes) {
338
+ if (ms - previousMs >= minGapMs)
339
+ authorPingsSinceMaintainerActivity++;
340
+ previousMs = ms;
341
+ }
342
+ return { lastMaintainerActivityAt: latest, authorPingsSinceMaintainerActivity };
343
+ }
@@ -78,6 +78,13 @@ export declare const PickSnapshotSchema: z.ZodObject<{
78
78
  stargazersCount: z.ZodOptional<z.ZodNumber>;
79
79
  source: z.ZodCustom<(string & {}) | "vet" | "vet-list" | "list", (string & {}) | "vet" | "vet-list" | "list">;
80
80
  capturedAt: z.ZodOptional<z.ZodString>;
81
+ labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
82
+ issueAuthorAssociation: z.ZodOptional<z.ZodCustom<(string & {}) | "OWNER" | "MEMBER" | "COLLABORATOR" | "CONTRIBUTOR" | "FIRST_TIMER" | "FIRST_TIME_CONTRIBUTOR" | "MANNEQUIN" | "NONE", (string & {}) | "OWNER" | "MEMBER" | "COLLABORATOR" | "CONTRIBUTOR" | "FIRST_TIMER" | "FIRST_TIME_CONTRIBUTOR" | "MANNEQUIN" | "NONE">>;
83
+ issueAuthorIsBot: z.ZodOptional<z.ZodBoolean>;
84
+ competingPRs: z.ZodOptional<z.ZodNumber>;
85
+ mentioningPRs: z.ZodOptional<z.ZodNumber>;
86
+ firstInRepo: z.ZodOptional<z.ZodBoolean>;
87
+ commentCount: z.ZodOptional<z.ZodNumber>;
81
88
  }, z.core.$loose>;
82
89
  export declare const StoredMergedPRSchema: z.ZodObject<{
83
90
  issueUrl: z.ZodOptional<z.ZodString>;
@@ -88,10 +95,18 @@ export declare const StoredMergedPRSchema: z.ZodObject<{
88
95
  stargazersCount: z.ZodOptional<z.ZodNumber>;
89
96
  source: z.ZodCustom<(string & {}) | "vet" | "vet-list" | "list", (string & {}) | "vet" | "vet-list" | "list">;
90
97
  capturedAt: z.ZodOptional<z.ZodString>;
98
+ labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
99
+ issueAuthorAssociation: z.ZodOptional<z.ZodCustom<(string & {}) | "OWNER" | "MEMBER" | "COLLABORATOR" | "CONTRIBUTOR" | "FIRST_TIMER" | "FIRST_TIME_CONTRIBUTOR" | "MANNEQUIN" | "NONE", (string & {}) | "OWNER" | "MEMBER" | "COLLABORATOR" | "CONTRIBUTOR" | "FIRST_TIMER" | "FIRST_TIME_CONTRIBUTOR" | "MANNEQUIN" | "NONE">>;
100
+ issueAuthorIsBot: z.ZodOptional<z.ZodBoolean>;
101
+ competingPRs: z.ZodOptional<z.ZodNumber>;
102
+ mentioningPRs: z.ZodOptional<z.ZodNumber>;
103
+ firstInRepo: z.ZodOptional<z.ZodBoolean>;
104
+ commentCount: z.ZodOptional<z.ZodNumber>;
91
105
  }, z.core.$loose>>;
92
106
  lastReviewDecision: z.ZodOptional<z.ZodString>;
93
107
  lastCiStatus: z.ZodOptional<z.ZodString>;
94
108
  backfilledAt: z.ZodOptional<z.ZodString>;
109
+ responseRule: z.ZodOptional<z.ZodNumber>;
95
110
  url: z.ZodString;
96
111
  title: z.ZodString;
97
112
  mergedAt: z.ZodString;
@@ -111,10 +126,18 @@ export declare const StoredClosedPRSchema: z.ZodObject<{
111
126
  stargazersCount: z.ZodOptional<z.ZodNumber>;
112
127
  source: z.ZodCustom<(string & {}) | "vet" | "vet-list" | "list", (string & {}) | "vet" | "vet-list" | "list">;
113
128
  capturedAt: z.ZodOptional<z.ZodString>;
129
+ labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
130
+ issueAuthorAssociation: z.ZodOptional<z.ZodCustom<(string & {}) | "OWNER" | "MEMBER" | "COLLABORATOR" | "CONTRIBUTOR" | "FIRST_TIMER" | "FIRST_TIME_CONTRIBUTOR" | "MANNEQUIN" | "NONE", (string & {}) | "OWNER" | "MEMBER" | "COLLABORATOR" | "CONTRIBUTOR" | "FIRST_TIMER" | "FIRST_TIME_CONTRIBUTOR" | "MANNEQUIN" | "NONE">>;
131
+ issueAuthorIsBot: z.ZodOptional<z.ZodBoolean>;
132
+ competingPRs: z.ZodOptional<z.ZodNumber>;
133
+ mentioningPRs: z.ZodOptional<z.ZodNumber>;
134
+ firstInRepo: z.ZodOptional<z.ZodBoolean>;
135
+ commentCount: z.ZodOptional<z.ZodNumber>;
114
136
  }, z.core.$loose>>;
115
137
  lastReviewDecision: z.ZodOptional<z.ZodString>;
116
138
  lastCiStatus: z.ZodOptional<z.ZodString>;
117
139
  backfilledAt: z.ZodOptional<z.ZodString>;
140
+ responseRule: z.ZodOptional<z.ZodNumber>;
118
141
  url: z.ZodString;
119
142
  title: z.ZodString;
120
143
  closedAt: z.ZodString;
@@ -289,6 +312,8 @@ export declare const AgentConfigSchema: z.ZodPipe<z.ZodObject<{
289
312
  gist: "gist";
290
313
  }>>;
291
314
  maxActivePRs: z.ZodDefault<z.ZodNumber>;
315
+ maxOpenPRsPerRepo: z.ZodDefault<z.ZodNumber>;
316
+ maxOpenPRsColdRepo: z.ZodDefault<z.ZodNumber>;
292
317
  dormantThresholdDays: z.ZodDefault<z.ZodNumber>;
293
318
  approachingDormantDays: z.ZodDefault<z.ZodNumber>;
294
319
  maxIssueAgeDays: z.ZodDefault<z.ZodNumber>;
@@ -355,6 +380,8 @@ export declare const AgentConfigSchema: z.ZodPipe<z.ZodObject<{
355
380
  setupComplete: boolean;
356
381
  persistence: "local" | "gist";
357
382
  maxActivePRs: number;
383
+ maxOpenPRsPerRepo: number;
384
+ maxOpenPRsColdRepo: number;
358
385
  dormantThresholdDays: number;
359
386
  approachingDormantDays: number;
360
387
  maxIssueAgeDays: number;
@@ -403,6 +430,8 @@ export declare const AgentConfigSchema: z.ZodPipe<z.ZodObject<{
403
430
  setupComplete: boolean;
404
431
  persistence: "local" | "gist";
405
432
  maxActivePRs: number;
433
+ maxOpenPRsPerRepo: number;
434
+ maxOpenPRsColdRepo: number;
406
435
  dormantThresholdDays: number;
407
436
  approachingDormantDays: number;
408
437
  maxIssueAgeDays: number;
@@ -677,6 +706,8 @@ export declare const AgentStateSchema: z.ZodObject<{
677
706
  gist: "gist";
678
707
  }>>;
679
708
  maxActivePRs: z.ZodDefault<z.ZodNumber>;
709
+ maxOpenPRsPerRepo: z.ZodDefault<z.ZodNumber>;
710
+ maxOpenPRsColdRepo: z.ZodDefault<z.ZodNumber>;
680
711
  dormantThresholdDays: z.ZodDefault<z.ZodNumber>;
681
712
  approachingDormantDays: z.ZodDefault<z.ZodNumber>;
682
713
  maxIssueAgeDays: z.ZodDefault<z.ZodNumber>;
@@ -743,6 +774,8 @@ export declare const AgentStateSchema: z.ZodObject<{
743
774
  setupComplete: boolean;
744
775
  persistence: "local" | "gist";
745
776
  maxActivePRs: number;
777
+ maxOpenPRsPerRepo: number;
778
+ maxOpenPRsColdRepo: number;
746
779
  dormantThresholdDays: number;
747
780
  approachingDormantDays: number;
748
781
  maxIssueAgeDays: number;
@@ -791,6 +824,8 @@ export declare const AgentStateSchema: z.ZodObject<{
791
824
  setupComplete: boolean;
792
825
  persistence: "local" | "gist";
793
826
  maxActivePRs: number;
827
+ maxOpenPRsPerRepo: number;
828
+ maxOpenPRsColdRepo: number;
794
829
  dormantThresholdDays: number;
795
830
  approachingDormantDays: number;
796
831
  maxIssueAgeDays: number;
@@ -912,10 +947,18 @@ export declare const AgentStateSchema: z.ZodObject<{
912
947
  stargazersCount: z.ZodOptional<z.ZodNumber>;
913
948
  source: z.ZodCustom<(string & {}) | "vet" | "vet-list" | "list", (string & {}) | "vet" | "vet-list" | "list">;
914
949
  capturedAt: z.ZodOptional<z.ZodString>;
950
+ labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
951
+ issueAuthorAssociation: z.ZodOptional<z.ZodCustom<(string & {}) | "OWNER" | "MEMBER" | "COLLABORATOR" | "CONTRIBUTOR" | "FIRST_TIMER" | "FIRST_TIME_CONTRIBUTOR" | "MANNEQUIN" | "NONE", (string & {}) | "OWNER" | "MEMBER" | "COLLABORATOR" | "CONTRIBUTOR" | "FIRST_TIMER" | "FIRST_TIME_CONTRIBUTOR" | "MANNEQUIN" | "NONE">>;
952
+ issueAuthorIsBot: z.ZodOptional<z.ZodBoolean>;
953
+ competingPRs: z.ZodOptional<z.ZodNumber>;
954
+ mentioningPRs: z.ZodOptional<z.ZodNumber>;
955
+ firstInRepo: z.ZodOptional<z.ZodBoolean>;
956
+ commentCount: z.ZodOptional<z.ZodNumber>;
915
957
  }, z.core.$loose>>;
916
958
  lastReviewDecision: z.ZodOptional<z.ZodString>;
917
959
  lastCiStatus: z.ZodOptional<z.ZodString>;
918
960
  backfilledAt: z.ZodOptional<z.ZodString>;
961
+ responseRule: z.ZodOptional<z.ZodNumber>;
919
962
  url: z.ZodString;
920
963
  title: z.ZodString;
921
964
  mergedAt: z.ZodString;
@@ -935,10 +978,18 @@ export declare const AgentStateSchema: z.ZodObject<{
935
978
  stargazersCount: z.ZodOptional<z.ZodNumber>;
936
979
  source: z.ZodCustom<(string & {}) | "vet" | "vet-list" | "list", (string & {}) | "vet" | "vet-list" | "list">;
937
980
  capturedAt: z.ZodOptional<z.ZodString>;
981
+ labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
982
+ issueAuthorAssociation: z.ZodOptional<z.ZodCustom<(string & {}) | "OWNER" | "MEMBER" | "COLLABORATOR" | "CONTRIBUTOR" | "FIRST_TIMER" | "FIRST_TIME_CONTRIBUTOR" | "MANNEQUIN" | "NONE", (string & {}) | "OWNER" | "MEMBER" | "COLLABORATOR" | "CONTRIBUTOR" | "FIRST_TIMER" | "FIRST_TIME_CONTRIBUTOR" | "MANNEQUIN" | "NONE">>;
983
+ issueAuthorIsBot: z.ZodOptional<z.ZodBoolean>;
984
+ competingPRs: z.ZodOptional<z.ZodNumber>;
985
+ mentioningPRs: z.ZodOptional<z.ZodNumber>;
986
+ firstInRepo: z.ZodOptional<z.ZodBoolean>;
987
+ commentCount: z.ZodOptional<z.ZodNumber>;
938
988
  }, z.core.$loose>>;
939
989
  lastReviewDecision: z.ZodOptional<z.ZodString>;
940
990
  lastCiStatus: z.ZodOptional<z.ZodString>;
941
991
  backfilledAt: z.ZodOptional<z.ZodString>;
992
+ responseRule: z.ZodOptional<z.ZodNumber>;
942
993
  url: z.ZodString;
943
994
  title: z.ZodString;
944
995
  closedAt: z.ZodString;
@@ -1032,6 +1083,13 @@ export declare const AgentStateSchema: z.ZodObject<{
1032
1083
  stargazersCount: z.ZodOptional<z.ZodNumber>;
1033
1084
  source: z.ZodCustom<(string & {}) | "vet" | "vet-list" | "list", (string & {}) | "vet" | "vet-list" | "list">;
1034
1085
  capturedAt: z.ZodOptional<z.ZodString>;
1086
+ labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
1087
+ issueAuthorAssociation: z.ZodOptional<z.ZodCustom<(string & {}) | "OWNER" | "MEMBER" | "COLLABORATOR" | "CONTRIBUTOR" | "FIRST_TIMER" | "FIRST_TIME_CONTRIBUTOR" | "MANNEQUIN" | "NONE", (string & {}) | "OWNER" | "MEMBER" | "COLLABORATOR" | "CONTRIBUTOR" | "FIRST_TIMER" | "FIRST_TIME_CONTRIBUTOR" | "MANNEQUIN" | "NONE">>;
1088
+ issueAuthorIsBot: z.ZodOptional<z.ZodBoolean>;
1089
+ competingPRs: z.ZodOptional<z.ZodNumber>;
1090
+ mentioningPRs: z.ZodOptional<z.ZodNumber>;
1091
+ firstInRepo: z.ZodOptional<z.ZodBoolean>;
1092
+ commentCount: z.ZodOptional<z.ZodNumber>;
1035
1093
  }, z.core.$loose>>>;
1036
1094
  lastOvernight: z.ZodOptional<z.ZodObject<{
1037
1095
  runAt: z.ZodString;
@@ -69,6 +69,27 @@ export const PickSnapshotSchema = z
69
69
  source: openEnum(['vet', 'vet-list', 'list']),
70
70
  /** When the vet ran. Absent for `list` picks: the list does not record vet dates reliably. */
71
71
  capturedAt: z.string().optional(),
72
+ // Issue traits at vet time, for the eval's trait cuts. Older snapshots lack them.
73
+ labels: z.array(z.string()).optional(),
74
+ /** Raw GitHub author association of the issue author; the eval buckets it. */
75
+ issueAuthorAssociation: openEnum([
76
+ 'OWNER',
77
+ 'MEMBER',
78
+ 'COLLABORATOR',
79
+ 'CONTRIBUTOR',
80
+ 'FIRST_TIMER',
81
+ 'FIRST_TIME_CONTRIBUTOR',
82
+ 'MANNEQUIN',
83
+ 'NONE',
84
+ ]).optional(),
85
+ issueAuthorIsBot: z.boolean().optional(),
86
+ /** Open, non-draft PRs by others that close the issue (claims). */
87
+ competingPRs: z.number().optional(),
88
+ /** Open PRs by others that only cross-reference the issue (not claims). */
89
+ mentioningPRs: z.number().optional(),
90
+ /** The user had no merged PR in the repo yet. */
91
+ firstInRepo: z.boolean().optional(),
92
+ commentCount: z.number().optional(),
72
93
  })
73
94
  .passthrough();
74
95
  /**
@@ -86,6 +107,13 @@ const LedgerPredictionFields = {
86
107
  lastCiStatus: z.string().optional(),
87
108
  /** When ledger-backfill got GitHub's answer for this PR; later runs skip it. */
88
109
  backfilledAt: z.string().optional(),
110
+ /**
111
+ * Version of the maintainer rule (`MAINTAINER_RESPONSE_RULE`) ledger-backfill
112
+ * last computed `firstMaintainerResponseAt` under. Entries with an older or
113
+ * missing version are re-queried once and their value overwritten; a PR
114
+ * nobody answered carries the current version without the field.
115
+ */
116
+ responseRule: z.number().int().optional(),
89
117
  };
90
118
  export const StoredMergedPRSchema = z
91
119
  .object({
@@ -247,6 +275,15 @@ export const AgentConfigSchema = z
247
275
  setupCompletedAt: z.string().optional(),
248
276
  persistence: z.enum(['local', 'gist']).default('local'),
249
277
  maxActivePRs: z.number().default(10),
278
+ /**
279
+ * Per-repo open-PR caps (core/repo-cap.ts). Discovery leaves out a repo
280
+ * once the user has this many open PRs there; the cold cap applies while
281
+ * none of their PRs in the repo have merged (first PRs merge less often).
282
+ * The warm cap is off by default so it never blocks repos that merge.
283
+ * 0 disables either.
284
+ */
285
+ maxOpenPRsPerRepo: z.number().int().min(0).default(0),
286
+ maxOpenPRsColdRepo: z.number().int().min(0).default(1),
250
287
  dormantThresholdDays: z.number().default(30),
251
288
  approachingDormantDays: z.number().default(25),
252
289
  maxIssueAgeDays: z.number().default(90),
@@ -292,6 +292,14 @@ export declare class StateManager {
292
292
  * No-op when no PR with that URL is stored.
293
293
  */
294
294
  markPRCommentsFetched(url: string, fetchedAt: string): void;
295
+ /**
296
+ * Overwrite the first-response lookup on the merged or closed PR matching
297
+ * `url`. Unlike addMergedPRs/addClosedPRs, which only fill missing fields,
298
+ * this replaces `firstMaintainerResponseAt` (clearing it when `at` is
299
+ * undefined) so ledger-backfill can recompute values recorded under an older
300
+ * maintainer rule. No-op when no PR with that URL is stored.
301
+ */
302
+ setLedgerResponse(url: string, at: string | undefined, rule: number): void;
295
303
  /**
296
304
  * Stamp `learningsExtractedAt` on the merged or closed PR matching `url` (#867).
297
305
  * No-op when no PR with that URL is stored.
@@ -440,21 +448,6 @@ export declare class StateManager {
440
448
  * @param updates - Partial score fields to merge
441
449
  */
442
450
  updateRepoScore(repo: string, updates: RepoScoreUpdate): void;
443
- /**
444
- * Increment the merged PR count for a repository.
445
- * @param repo - Repository in "owner/repo" format
446
- */
447
- incrementMergedCount(repo: string): void;
448
- /**
449
- * Increment the closed-without-merge PR count.
450
- * @param repo - Repository in "owner/repo" format
451
- */
452
- incrementClosedCount(repo: string): void;
453
- /**
454
- * Mark a repository as hostile (score zeroed).
455
- * @param repo - Repository in "owner/repo" format
456
- */
457
- markRepoHostile(repo: string): void;
458
451
  /** Returns repository names that have at least one merged PR. */
459
452
  getReposWithMergedPRs(): string[];
460
453
  /** Returns repository names with open PRs but no merged PRs yet. */