@oss-autopilot/core 3.33.1 → 3.34.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.
@@ -0,0 +1,211 @@
1
+ /**
2
+ * Eval report (#1825): is oss-autopilot picking better over time?
3
+ *
4
+ * Pure computation over the outcome ledger. Every merged, closed-unmerged and
5
+ * dormant PR is one outcome; the `pick` snapshot recorded at vet time (#1824)
6
+ * is the prediction it is compared against. Merge rate counts dormant PRs in
7
+ * the denominator, so stalled work cannot flatter the number.
8
+ */
9
+ const HOUR = 3_600_000;
10
+ /** Minimum bucket size before a flag is raised. */
11
+ const MIN_FLAG_N = 5;
12
+ function repoOf(url) {
13
+ return url.split('/').slice(3, 5).join('/');
14
+ }
15
+ function hoursBetween(from, to) {
16
+ if (!from || !to)
17
+ return undefined;
18
+ const ms = Date.parse(to) - Date.parse(from);
19
+ return Number.isFinite(ms) && ms >= 0 ? ms / HOUR : undefined;
20
+ }
21
+ function median(values) {
22
+ if (values.length === 0)
23
+ return null;
24
+ const sorted = [...values].sort((a, b) => a - b);
25
+ const mid = Math.floor(sorted.length / 2);
26
+ const m = sorted.length % 2 ? sorted[mid] : (sorted[mid - 1] + sorted[mid]) / 2;
27
+ return Math.round(m * 10) / 10;
28
+ }
29
+ function rate(part, whole) {
30
+ return whole === 0 ? null : Math.round((part / whole) * 100) / 100;
31
+ }
32
+ function bucket(key, rows) {
33
+ const count = (o) => rows.filter((r) => r.outcome === o).length;
34
+ const merged = count('merged');
35
+ return {
36
+ key,
37
+ n: rows.length,
38
+ merged,
39
+ closed: count('closed'),
40
+ dormant: count('dormant'),
41
+ mergeRate: rate(merged, rows.length),
42
+ medianHoursToMerge: median(rows.flatMap((r) => (r.hoursToMerge === undefined ? [] : [r.hoursToMerge]))),
43
+ medianHoursToFirstResponse: median(rows.flatMap((r) => (r.hoursToFirstResponse === undefined ? [] : [r.hoursToFirstResponse]))),
44
+ };
45
+ }
46
+ /** Group rows by a key function, keeping `order` first and dropping empty groups. */
47
+ function groupBy(rows, keyOf, order = []) {
48
+ const groups = new Map(order.map((k) => [k, []]));
49
+ for (const r of rows) {
50
+ const k = keyOf(r);
51
+ if (!groups.has(k))
52
+ groups.set(k, []);
53
+ groups.get(k).push(r);
54
+ }
55
+ return [...groups].filter(([, g]) => g.length > 0).map(([k, g]) => bucket(k, g));
56
+ }
57
+ function gradeRange(grade) {
58
+ if (grade === undefined)
59
+ return 'none';
60
+ if (grade <= 4)
61
+ return '1-4';
62
+ if (grade <= 6)
63
+ return '5-6';
64
+ if (grade <= 8)
65
+ return '7-8';
66
+ return '9-10';
67
+ }
68
+ function starRange(stars) {
69
+ if (stars === undefined)
70
+ return 'unknown';
71
+ if (stars < 100)
72
+ return '<100';
73
+ if (stars < 1000)
74
+ return '100-1k';
75
+ if (stars < 10_000)
76
+ return '1k-10k';
77
+ return '10k+';
78
+ }
79
+ function collectRows(state) {
80
+ const starsOf = (repo) => state.repoScores[repo]?.stargazersCount;
81
+ const common = (e) => {
82
+ const repo = repoOf(e.url);
83
+ return {
84
+ url: e.url,
85
+ repo,
86
+ grade: e.pick?.grade,
87
+ gradeSource: e.pick ? (e.pick.source === 'list' ? 'list' : 'vet') : undefined,
88
+ stars: e.pick?.stargazersCount ?? starsOf(repo),
89
+ hoursToFirstResponse: hoursBetween(e.openedAt, e.firstMaintainerResponseAt),
90
+ changesRequested: e.lastReviewDecision ? e.lastReviewDecision === 'changes_requested' : undefined,
91
+ ciFailing: e.lastCiStatus ? e.lastCiStatus === 'failing' : undefined,
92
+ };
93
+ };
94
+ const merged = (state.mergedPRs ?? []).map((e) => ({
95
+ ...common(e),
96
+ outcome: 'merged',
97
+ month: e.mergedAt.slice(0, 7),
98
+ hoursToMerge: hoursBetween(e.openedAt, e.mergedAt),
99
+ }));
100
+ const closed = (state.closedPRs ?? []).map((e) => ({
101
+ ...common(e),
102
+ outcome: 'closed',
103
+ month: e.closedAt.slice(0, 7),
104
+ closeReason: e.closeReason,
105
+ }));
106
+ const dormant = (state.lastDigest?.openPRs ?? [])
107
+ .filter((pr) => pr.stalenessTier === 'dormant')
108
+ .map((pr) => ({ url: pr.url, repo: pr.repo, outcome: 'dormant', stars: starsOf(pr.repo) }));
109
+ return [...merged, ...closed, ...dormant];
110
+ }
111
+ const pct = (v) => (v === null ? 'n/a' : `${Math.round(v * 100)}%`);
112
+ const hrs = (v) => (v === null ? 'n/a' : `${v}h`);
113
+ export function computeEvalReport(state, now = new Date()) {
114
+ const rows = collectRows(state);
115
+ const graded = rows.filter((r) => r.gradeSource === 'vet' && r.outcome !== 'dormant');
116
+ const high = graded.filter((r) => r.grade >= 7);
117
+ const low = graded.filter((r) => r.grade <= 5);
118
+ const mergedShare = (g) => g.filter((r) => r.outcome === 'merged').length / g.length;
119
+ const separable = high.length >= MIN_FLAG_N && low.length >= MIN_FLAG_N;
120
+ const gap = separable ? Math.round((mergedShare(high) - mergedShare(low)) * 100) / 100 : null;
121
+ const closedRows = rows.filter((r) => r.outcome === 'closed');
122
+ const closeReasons = {};
123
+ const approachClosuresByMonth = {};
124
+ for (const r of closedRows) {
125
+ const reason = r.closeReason ?? 'unclassified';
126
+ closeReasons[reason] = (closeReasons[reason] ?? 0) + 1;
127
+ if ((r.closeReason === 'ai-policy' || r.closeReason === 'rejected') && r.month) {
128
+ approachClosuresByMonth[r.month] = (approachClosuresByMonth[r.month] ?? 0) + 1;
129
+ }
130
+ }
131
+ const reviewed = rows.filter((r) => r.changesRequested !== undefined);
132
+ const ciKnown = rows.filter((r) => r.ciFailing !== undefined);
133
+ const byGrade = groupBy(rows, (r) => (r.gradeSource ? `${r.gradeSource} ${gradeRange(r.grade)}` : 'no prediction'), [
134
+ 'vet 9-10',
135
+ 'vet 7-8',
136
+ 'vet 5-6',
137
+ 'vet 1-4',
138
+ 'list 9-10',
139
+ 'list 7-8',
140
+ 'list 5-6',
141
+ 'list 1-4',
142
+ 'no prediction',
143
+ ]);
144
+ const flags = byGrade
145
+ .filter((b) => /(?:9-10|7-8)$/.test(b.key) && b.n >= MIN_FLAG_N && (b.mergeRate ?? 1) < 0.6)
146
+ .map((b) => `${b.key}: high-grade picks merge at ${Math.round(b.mergeRate * 100)}% (n=${b.n})`);
147
+ if (gap !== null && gap <= 0) {
148
+ flags.push(`vet grades do not separate outcomes: grade>=7 merges at ${pct(rate(high.filter((r) => r.outcome === 'merged').length, high.length))} (n=${high.length}), grade<=5 at ${pct(rate(low.filter((r) => r.outcome === 'merged').length, low.length))} (n=${low.length})`);
149
+ }
150
+ return {
151
+ generatedAt: now.toISOString(),
152
+ totals: bucket('all', rows),
153
+ headlines: {
154
+ mergeRate1kStars: bucket('>=1k stars', rows.filter((r) => (r.stars ?? 0) >= 1000)),
155
+ calibration: { gap, highN: high.length, lowN: low.length },
156
+ approachClosuresByMonth,
157
+ },
158
+ byGrade,
159
+ byStars: groupBy(rows, (r) => starRange(r.stars), ['10k+', '1k-10k', '100-1k', '<100', 'unknown']),
160
+ byMonth: groupBy(rows.filter((r) => r.month), (r) => r.month).sort((a, b) => b.key.localeCompare(a.key)),
161
+ closeReasons,
162
+ quality: {
163
+ withReviewState: reviewed.length,
164
+ changesRequestedShare: rate(reviewed.filter((r) => r.changesRequested).length, reviewed.length),
165
+ ciFailingShare: rate(ciKnown.filter((r) => r.ciFailing).length, ciKnown.length),
166
+ },
167
+ calibrationPairs: graded.length,
168
+ flags,
169
+ };
170
+ }
171
+ function table(title, buckets) {
172
+ return [
173
+ `## ${title}`,
174
+ '',
175
+ '| Bucket | n | Merged | Closed | Dormant | Merge rate | Median to merge | Median to first response |',
176
+ '|---|---|---|---|---|---|---|---|',
177
+ ...buckets.map((b) => `| ${b.key} | ${b.n} | ${b.merged} | ${b.closed} | ${b.dormant} | ${pct(b.mergeRate)} | ${hrs(b.medianHoursToMerge)} | ${hrs(b.medianHoursToFirstResponse)} |`),
178
+ '',
179
+ ];
180
+ }
181
+ export function formatEvalMarkdown(r) {
182
+ const h = r.headlines;
183
+ const recentMonths = Object.keys(h.approachClosuresByMonth).sort().reverse().slice(0, 6);
184
+ return [
185
+ `# oss-autopilot eval (${r.generatedAt.slice(0, 10)})`,
186
+ '',
187
+ '## Headlines',
188
+ '',
189
+ `- Merge rate on repos with 1k+ stars: **${pct(h.mergeRate1kStars.mergeRate)}** (n=${h.mergeRate1kStars.n})`,
190
+ `- Calibration gap, vet grades (grade>=7 minus grade<=5 merge rate): **${h.calibration.gap ?? 'n/a'}** (n=${h.calibration.highN} vs ${h.calibration.lowN}; needs ${MIN_FLAG_N} each)`,
191
+ `- Approach or AI-policy closures by month: ${recentMonths.length ? recentMonths.map((m) => `${m}: ${h.approachClosuresByMonth[m]}`).join(', ') : 'none'}`,
192
+ `- Overall: ${r.totals.n} outcomes, merge rate ${pct(r.totals.mergeRate)} (dormant counted as not merged)`,
193
+ '',
194
+ ...(r.flags.length ? ['## Flags', '', ...r.flags.map((f) => `- ${f}`), ''] : []),
195
+ ...table('By grade at pick time', r.byGrade),
196
+ ...table('By repo stars', r.byStars),
197
+ ...table('By month', r.byMonth.slice(0, 12)),
198
+ '## Close reasons',
199
+ '',
200
+ ...Object.entries(r.closeReasons)
201
+ .sort((a, b) => b[1] - a[1])
202
+ .map(([k, v]) => `- ${k}: ${v}`),
203
+ '',
204
+ '## Review quality',
205
+ '',
206
+ `- PRs with a recorded review state: ${r.quality.withReviewState}`,
207
+ `- Changes requested before the outcome: ${pct(r.quality.changesRequestedShare)}`,
208
+ `- CI failing at last sight: ${pct(r.quality.ciFailingShare)}`,
209
+ '',
210
+ ].join('\n');
211
+ }
@@ -6,6 +6,15 @@ import { Octokit } from '@octokit/rest';
6
6
  import { ClosedPR, MergedPR, StoredMergedPR, StoredClosedPR, type StarFilter } from './types.js';
7
7
  /** TTL for cached PR count results (24 hours — these stats change slowly). */
8
8
  export declare const PR_COUNTS_CACHE_TTL_MS: number;
9
+ /**
10
+ * Issue URL a PR closes, from the first GitHub closing keyword in its body
11
+ * (#1824): `Fixes #12`, `closes owner/repo#12`, or `resolves <issue url>`.
12
+ * Joins the outcome ledger to vet-time predictions at zero API cost.
13
+ *
14
+ * ponytail: first keyword wins; a PR closing several issues links only the
15
+ * first. Switch to GraphQL `closingIssuesReferences` if that ever matters.
16
+ */
17
+ export declare function closingIssueUrl(body: string | null | undefined, prUrl: string): string | undefined;
9
18
  /** Return type shared by both merged and closed PR count functions. */
10
19
  export interface PRCountsResult<R> {
11
20
  repos: Map<string, R>;
@@ -15,6 +15,28 @@ export const PR_COUNTS_CACHE_TTL_MS = 24 * 60 * 60 * 1000;
15
15
  * 3 pages × 100 per_page = 300 results, which covers the vast majority of users.
16
16
  */
17
17
  const MAX_PAGINATION_PAGES = 3;
18
+ const CLOSING_KEYWORD_RE = /\b(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)(?::\s*|\s+)(?:https:\/\/github\.com\/([\w.-]+\/[\w.-]+)\/issues\/(\d+)|([\w.-]+\/[\w.-]+)?#(\d+))\b/i;
19
+ /** HTML comments and code: where PR templates keep example `Fixes #123` lines. */
20
+ const NON_PROSE_RE = /<!--[\s\S]*?-->|```[\s\S]*?```|(`+)[^`]*\1/g;
21
+ /** GitHub's PR body limit; also bounds NON_PROSE_RE's scan on an unclosed `<!--`. */
22
+ const MAX_BODY_CHARS = 65_536;
23
+ /**
24
+ * Issue URL a PR closes, from the first GitHub closing keyword in its body
25
+ * (#1824): `Fixes #12`, `closes owner/repo#12`, or `resolves <issue url>`.
26
+ * Joins the outcome ledger to vet-time predictions at zero API cost.
27
+ *
28
+ * ponytail: first keyword wins; a PR closing several issues links only the
29
+ * first. Switch to GraphQL `closingIssuesReferences` if that ever matters.
30
+ */
31
+ export function closingIssueUrl(body, prUrl) {
32
+ const m = body?.slice(0, MAX_BODY_CHARS).replace(NON_PROSE_RE, ' ').match(CLOSING_KEYWORD_RE);
33
+ if (!m)
34
+ return undefined;
35
+ const own = extractOwnerRepo(prUrl);
36
+ // A bare `#12` refers to the PR's own repo.
37
+ const target = m[1] ?? m[3] ?? (own && `${own.owner}/${own.repo}`);
38
+ return target ? `https://github.com/${target}/issues/${m[2] ?? m[4]}` : undefined;
39
+ }
18
40
  /** Returns an empty PRCountsResult. Used as the fallback when stats fetches fail or username is empty. */
19
41
  export function emptyPRCountsResult() {
20
42
  return { repos: new Map(), monthlyCounts: {}, monthlyOpenedCounts: {}, dailyActivityCounts: {}, searchedPRs: [] };
@@ -235,6 +257,7 @@ export async function fetchRecentlyClosedPRs(octokit, config, days = 7) {
235
257
  closedAt: item.closed_at || '',
236
258
  // Free on the search result — feeds the outcome ledger (#1461).
237
259
  openedAt: item.created_at || undefined,
260
+ issueUrl: closingIssueUrl(item.body, item.html_url),
238
261
  }), (item) => item.closed_at);
239
262
  }
240
263
  /**
@@ -255,6 +278,7 @@ export async function fetchRecentlyMergedPRs(octokit, config, days = 7) {
255
278
  mergedAt: mergedAt || item.closed_at || '',
256
279
  // Free on the search result — feeds the outcome ledger (#1461).
257
280
  openedAt: item.created_at || undefined,
281
+ issueUrl: closingIssueUrl(item.body, item.html_url),
258
282
  };
259
283
  }, (item) => item.pull_request?.merged_at || item.closed_at);
260
284
  }
@@ -323,6 +347,7 @@ export async function fetchMergedPRsSince(octokit, config, since) {
323
347
  mergedAt: date,
324
348
  // Free on the search result — feeds the outcome ledger (#1461).
325
349
  openedAt: item.created_at || undefined,
350
+ issueUrl: closingIssueUrl(item.body, item.html_url),
326
351
  }),
327
352
  }, since);
328
353
  }
@@ -344,6 +369,7 @@ export async function fetchClosedPRsSince(octokit, config, since) {
344
369
  closedAt: date,
345
370
  // Free on the search result — feeds the outcome ledger (#1461).
346
371
  openedAt: item.created_at || undefined,
372
+ issueUrl: closingIssueUrl(item.body, item.html_url),
347
373
  }),
348
374
  }, since);
349
375
  }
@@ -19,7 +19,7 @@ export { DEFAULT_CONCURRENCY } from './concurrency.js';
19
19
  export { OssAutopilotError, ConfigurationError, ValidationError, GistPermissionError, ConcurrencyError, GistConcurrencyError, GistFileSizeError, GIST_FILE_SIZE_REMEDY, errorMessage, getHttpStatusCode, isRateLimitError, isRateLimitOrAuthError, nonFatalCatch, resolveErrorCode, } from './errors.js';
20
20
  export { enableDebug, isDebugEnabled, debug, info, warn, timed } from './logger.js';
21
21
  export { HttpCache, getHttpCache, cachedRequest, type CacheEntry } from './http-cache.js';
22
- export { CRITICAL_STATUSES, applyStatusOverrides, computeRepoSignals, groupPRsByRepo, assessCapacity, collectActionableIssues, computeActionMenu, toShelvedPRRef, buildStarFilter, firstMaintainerResponseFromDigest, formatActionHint, formatBriefSummary, formatSummary, printDigest, } from './daily-logic.js';
22
+ export { CRITICAL_STATUSES, applyStatusOverrides, computeRepoSignals, groupPRsByRepo, assessCapacity, collectActionableIssues, computeActionMenu, toShelvedPRRef, buildStarFilter, firstMaintainerResponseFromDigest, lastReviewStateFromDigest, formatActionHint, formatBriefSummary, formatSummary, printDigest, } from './daily-logic.js';
23
23
  export { computeContributionStats, type ContributionStats, type ComputeStatsInput } from './stats.js';
24
24
  export { fetchPRTemplate, type PRTemplateResult } from './pr-template.js';
25
25
  export { classifyLinkedPR, isLinkedPRStalled, STALLED_PR_THRESHOLD_DAYS, type LinkedPR, type LinkedPRClassification, type LinkedPRState, } from './linked-pr-classification.js';
@@ -31,3 +31,4 @@ export { CONFIG_KEY_REGISTRY, type ConfigKeyDef, type SettableVia, isKnownKey, g
31
31
  export { DashboardDataSchema, DashboardStatsSchema, validateDashboardData, type DashboardDataParsed, } from './dashboard-data-schema.js';
32
32
  export { fetchPRCommentBundle, fetchPRCommentBundlesBatch, type PRCommentBundle, type PRReviewEntry, type PRReviewCommentEntry, type PRIssueCommentEntry, } from './pr-comments-fetcher.js';
33
33
  export * from './types.js';
34
+ export { pickSnapshotFromVet, persistPickSnapshots } from './pick-snapshot.js';
@@ -20,7 +20,7 @@ export { DEFAULT_CONCURRENCY } from './concurrency.js';
20
20
  export { OssAutopilotError, ConfigurationError, ValidationError, GistPermissionError, ConcurrencyError, GistConcurrencyError, GistFileSizeError, GIST_FILE_SIZE_REMEDY, errorMessage, getHttpStatusCode, isRateLimitError, isRateLimitOrAuthError, nonFatalCatch, resolveErrorCode, } from './errors.js';
21
21
  export { enableDebug, isDebugEnabled, debug, info, warn, timed } from './logger.js';
22
22
  export { HttpCache, getHttpCache, cachedRequest } from './http-cache.js';
23
- export { CRITICAL_STATUSES, applyStatusOverrides, computeRepoSignals, groupPRsByRepo, assessCapacity, collectActionableIssues, computeActionMenu, toShelvedPRRef, buildStarFilter, firstMaintainerResponseFromDigest, formatActionHint, formatBriefSummary, formatSummary, printDigest, } from './daily-logic.js';
23
+ export { CRITICAL_STATUSES, applyStatusOverrides, computeRepoSignals, groupPRsByRepo, assessCapacity, collectActionableIssues, computeActionMenu, toShelvedPRRef, buildStarFilter, firstMaintainerResponseFromDigest, lastReviewStateFromDigest, formatActionHint, formatBriefSummary, formatSummary, printDigest, } from './daily-logic.js';
24
24
  export { computeContributionStats } from './stats.js';
25
25
  export { fetchPRTemplate } from './pr-template.js';
26
26
  export { classifyLinkedPR, isLinkedPRStalled, STALLED_PR_THRESHOLD_DAYS, } from './linked-pr-classification.js';
@@ -35,3 +35,4 @@ export { DashboardDataSchema, DashboardStatsSchema, validateDashboardData, } fro
35
35
  // silently drift (#1208 M5).
36
36
  export { fetchPRCommentBundle, fetchPRCommentBundlesBatch, } from './pr-comments-fetcher.js';
37
37
  export * from './types.js';
38
+ export { pickSnapshotFromVet, persistPickSnapshots } from './pick-snapshot.js';
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Vet-time predictions for calibration (#1824): what `vet` / `vet-list`
3
+ * thought of an issue, kept so the outcome ledger can compare it against how
4
+ * the PR that closed the issue actually ended.
5
+ */
6
+ import type { VetOutput } from '../formatters/json.js';
7
+ import { type StateManager } from './state.js';
8
+ import type { PickSnapshot } from './types.js';
9
+ /**
10
+ * The prediction to keep for a vetted issue, or undefined when the user's own
11
+ * PR is already linked: scout then grades the issue as taken, which is a
12
+ * post-hoc verdict, not the prediction that picked it.
13
+ */
14
+ export declare function pickSnapshotFromVet(vet: VetOutput, source: PickSnapshot['source']): PickSnapshot | undefined;
15
+ /**
16
+ * Persist predictions without ever failing the vet that produced them. `vet`
17
+ * used to be read-only, so a state save here can race another writer; that
18
+ * and a failed Gist push (#1629) come back as envelope fields instead.
19
+ */
20
+ export declare function persistPickSnapshots(stateManager: StateManager, snapshots: PickSnapshot[]): Promise<{
21
+ pickRecordError?: string;
22
+ gistSyncWarning?: string;
23
+ }>;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Vet-time predictions for calibration (#1824): what `vet` / `vet-list`
3
+ * thought of an issue, kept so the outcome ledger can compare it against how
4
+ * the PR that closed the issue actually ended.
5
+ */
6
+ import { errorMessage } from './errors.js';
7
+ import { warn } from './logger.js';
8
+ import { maybeCheckpoint } from './state.js';
9
+ const MODULE = 'pick-snapshot';
10
+ /**
11
+ * The prediction to keep for a vetted issue, or undefined when the user's own
12
+ * PR is already linked: scout then grades the issue as taken, which is a
13
+ * post-hoc verdict, not the prediction that picked it.
14
+ */
15
+ // ponytail: scout reports only the first linked PR, so a standalone `vet` of an
16
+ // issue whose first reference is someone else's PR can still miss the user's
17
+ // own. First-wins in recordPickSnapshots limits this to never-vetted issues.
18
+ export function pickSnapshotFromVet(vet, source) {
19
+ if (vet.linkedPRClassification?.startsWith('user_'))
20
+ return undefined;
21
+ const stars = vet.projectHealth?.stargazersCount;
22
+ return {
23
+ issueUrl: vet.issue.url,
24
+ grade: vet.grade.score,
25
+ recommendation: vet.recommendation,
26
+ // Stars at pick time feed the eval's repo-size cut (#1825); not recoverable later.
27
+ ...(typeof stars === 'number' && { stargazersCount: stars }),
28
+ source,
29
+ capturedAt: new Date().toISOString(),
30
+ };
31
+ }
32
+ /**
33
+ * Persist predictions without ever failing the vet that produced them. `vet`
34
+ * used to be read-only, so a state save here can race another writer; that
35
+ * and a failed Gist push (#1629) come back as envelope fields instead.
36
+ */
37
+ export async function persistPickSnapshots(stateManager, snapshots) {
38
+ if (snapshots.length === 0)
39
+ return {};
40
+ try {
41
+ stateManager.reloadIfChanged();
42
+ stateManager.recordPickSnapshots(snapshots);
43
+ }
44
+ catch (error) {
45
+ const pickRecordError = `Could not record the vet prediction: ${errorMessage(error)}`;
46
+ warn(MODULE, pickRecordError);
47
+ return { pickRecordError };
48
+ }
49
+ const gistSyncWarning = await maybeCheckpoint(stateManager, MODULE);
50
+ return gistSyncWarning ? { gistSyncWarning } : {};
51
+ }
@@ -60,7 +60,41 @@ export declare const RepoScoreSchema: z.ZodObject<{
60
60
  stargazersCount: z.ZodOptional<z.ZodNumber>;
61
61
  language: z.ZodOptional<z.ZodNullable<z.ZodString>>;
62
62
  }, z.core.$strip>;
63
+ /**
64
+ * What the tool predicted about an issue when it was vetted (#1824). Recorded
65
+ * by `vet` / `vet-list` keyed by issue URL, then copied onto the outcome
66
+ * ledger entry of the PR that closes that issue, so outcomes can be compared
67
+ * against the prediction that picked them (calibration).
68
+ */
69
+ export declare const PickSnapshotSchema: z.ZodObject<{
70
+ issueUrl: z.ZodString;
71
+ grade: z.ZodNumber;
72
+ recommendation: z.ZodString;
73
+ stargazersCount: z.ZodOptional<z.ZodNumber>;
74
+ source: z.ZodEnum<{
75
+ vet: "vet";
76
+ "vet-list": "vet-list";
77
+ list: "list";
78
+ }>;
79
+ capturedAt: z.ZodOptional<z.ZodString>;
80
+ }, z.core.$strip>;
63
81
  export declare const StoredMergedPRSchema: z.ZodObject<{
82
+ issueUrl: z.ZodOptional<z.ZodString>;
83
+ pick: z.ZodOptional<z.ZodObject<{
84
+ issueUrl: z.ZodString;
85
+ grade: z.ZodNumber;
86
+ recommendation: z.ZodString;
87
+ stargazersCount: z.ZodOptional<z.ZodNumber>;
88
+ source: z.ZodEnum<{
89
+ vet: "vet";
90
+ "vet-list": "vet-list";
91
+ list: "list";
92
+ }>;
93
+ capturedAt: z.ZodOptional<z.ZodString>;
94
+ }, z.core.$strip>>;
95
+ lastReviewDecision: z.ZodOptional<z.ZodString>;
96
+ lastCiStatus: z.ZodOptional<z.ZodString>;
97
+ backfilledAt: z.ZodOptional<z.ZodString>;
64
98
  url: z.ZodString;
65
99
  title: z.ZodString;
66
100
  mergedAt: z.ZodString;
@@ -70,6 +104,30 @@ export declare const StoredMergedPRSchema: z.ZodObject<{
70
104
  learningsExtractedAt: z.ZodOptional<z.ZodString>;
71
105
  }, z.core.$strip>;
72
106
  export declare const StoredClosedPRSchema: z.ZodObject<{
107
+ closeReason: z.ZodOptional<z.ZodEnum<{
108
+ unknown: "unknown";
109
+ rejected: "rejected";
110
+ "ai-policy": "ai-policy";
111
+ superseded: "superseded";
112
+ stale: "stale";
113
+ "self-closed": "self-closed";
114
+ }>>;
115
+ issueUrl: z.ZodOptional<z.ZodString>;
116
+ pick: z.ZodOptional<z.ZodObject<{
117
+ issueUrl: z.ZodString;
118
+ grade: z.ZodNumber;
119
+ recommendation: z.ZodString;
120
+ stargazersCount: z.ZodOptional<z.ZodNumber>;
121
+ source: z.ZodEnum<{
122
+ vet: "vet";
123
+ "vet-list": "vet-list";
124
+ list: "list";
125
+ }>;
126
+ capturedAt: z.ZodOptional<z.ZodString>;
127
+ }, z.core.$strip>>;
128
+ lastReviewDecision: z.ZodOptional<z.ZodString>;
129
+ lastCiStatus: z.ZodOptional<z.ZodString>;
130
+ backfilledAt: z.ZodOptional<z.ZodString>;
73
131
  url: z.ZodString;
74
132
  title: z.ZodString;
75
133
  closedAt: z.ZodString;
@@ -323,6 +381,7 @@ export declare const ClosedPRSchema: z.ZodObject<{
323
381
  closedAt: z.ZodString;
324
382
  closedBy: z.ZodOptional<z.ZodString>;
325
383
  openedAt: z.ZodOptional<z.ZodString>;
384
+ issueUrl: z.ZodOptional<z.ZodString>;
326
385
  }, z.core.$strip>;
327
386
  export declare const MergedPRSchema: z.ZodObject<{
328
387
  url: z.ZodString;
@@ -331,6 +390,7 @@ export declare const MergedPRSchema: z.ZodObject<{
331
390
  title: z.ZodString;
332
391
  mergedAt: z.ZodString;
333
392
  openedAt: z.ZodOptional<z.ZodString>;
393
+ issueUrl: z.ZodOptional<z.ZodString>;
334
394
  }, z.core.$strip>;
335
395
  export declare const DailyDigestSummarySchema: z.ZodObject<{
336
396
  totalActivePRs: z.ZodNumber;
@@ -369,6 +429,7 @@ export declare const DailyDigestSchema: z.ZodPreprocess<z.ZodObject<{
369
429
  closedAt: z.ZodString;
370
430
  closedBy: z.ZodOptional<z.ZodString>;
371
431
  openedAt: z.ZodOptional<z.ZodString>;
432
+ issueUrl: z.ZodOptional<z.ZodString>;
372
433
  }, z.core.$strip>>;
373
434
  recentlyMergedPRs: z.ZodArray<z.ZodObject<{
374
435
  url: z.ZodString;
@@ -377,6 +438,7 @@ export declare const DailyDigestSchema: z.ZodPreprocess<z.ZodObject<{
377
438
  title: z.ZodString;
378
439
  mergedAt: z.ZodString;
379
440
  openedAt: z.ZodOptional<z.ZodString>;
441
+ issueUrl: z.ZodOptional<z.ZodString>;
380
442
  }, z.core.$strip>>;
381
443
  shelvedPRs: z.ZodArray<z.ZodObject<{
382
444
  number: z.ZodNumber;
@@ -599,6 +661,7 @@ export declare const AgentStateSchema: z.ZodObject<{
599
661
  closedAt: z.ZodString;
600
662
  closedBy: z.ZodOptional<z.ZodString>;
601
663
  openedAt: z.ZodOptional<z.ZodString>;
664
+ issueUrl: z.ZodOptional<z.ZodString>;
602
665
  }, z.core.$strip>>;
603
666
  recentlyMergedPRs: z.ZodArray<z.ZodObject<{
604
667
  url: z.ZodString;
@@ -607,6 +670,7 @@ export declare const AgentStateSchema: z.ZodObject<{
607
670
  title: z.ZodString;
608
671
  mergedAt: z.ZodString;
609
672
  openedAt: z.ZodOptional<z.ZodString>;
673
+ issueUrl: z.ZodOptional<z.ZodString>;
610
674
  }, z.core.$strip>>;
611
675
  shelvedPRs: z.ZodArray<z.ZodObject<{
612
676
  number: z.ZodNumber;
@@ -650,6 +714,22 @@ export declare const AgentStateSchema: z.ZodObject<{
650
714
  cachedAt: z.ZodString;
651
715
  }, z.core.$strip>>;
652
716
  mergedPRs: z.ZodOptional<z.ZodArray<z.ZodObject<{
717
+ issueUrl: z.ZodOptional<z.ZodString>;
718
+ pick: z.ZodOptional<z.ZodObject<{
719
+ issueUrl: z.ZodString;
720
+ grade: z.ZodNumber;
721
+ recommendation: z.ZodString;
722
+ stargazersCount: z.ZodOptional<z.ZodNumber>;
723
+ source: z.ZodEnum<{
724
+ vet: "vet";
725
+ "vet-list": "vet-list";
726
+ list: "list";
727
+ }>;
728
+ capturedAt: z.ZodOptional<z.ZodString>;
729
+ }, z.core.$strip>>;
730
+ lastReviewDecision: z.ZodOptional<z.ZodString>;
731
+ lastCiStatus: z.ZodOptional<z.ZodString>;
732
+ backfilledAt: z.ZodOptional<z.ZodString>;
653
733
  url: z.ZodString;
654
734
  title: z.ZodString;
655
735
  mergedAt: z.ZodString;
@@ -659,6 +739,30 @@ export declare const AgentStateSchema: z.ZodObject<{
659
739
  learningsExtractedAt: z.ZodOptional<z.ZodString>;
660
740
  }, z.core.$strip>>>;
661
741
  closedPRs: z.ZodOptional<z.ZodArray<z.ZodObject<{
742
+ closeReason: z.ZodOptional<z.ZodEnum<{
743
+ unknown: "unknown";
744
+ rejected: "rejected";
745
+ "ai-policy": "ai-policy";
746
+ superseded: "superseded";
747
+ stale: "stale";
748
+ "self-closed": "self-closed";
749
+ }>>;
750
+ issueUrl: z.ZodOptional<z.ZodString>;
751
+ pick: z.ZodOptional<z.ZodObject<{
752
+ issueUrl: z.ZodString;
753
+ grade: z.ZodNumber;
754
+ recommendation: z.ZodString;
755
+ stargazersCount: z.ZodOptional<z.ZodNumber>;
756
+ source: z.ZodEnum<{
757
+ vet: "vet";
758
+ "vet-list": "vet-list";
759
+ list: "list";
760
+ }>;
761
+ capturedAt: z.ZodOptional<z.ZodString>;
762
+ }, z.core.$strip>>;
763
+ lastReviewDecision: z.ZodOptional<z.ZodString>;
764
+ lastCiStatus: z.ZodOptional<z.ZodString>;
765
+ backfilledAt: z.ZodOptional<z.ZodString>;
662
766
  url: z.ZodString;
663
767
  title: z.ZodString;
664
768
  closedAt: z.ZodString;
@@ -745,6 +849,18 @@ export declare const AgentStateSchema: z.ZodObject<{
745
849
  url: z.ZodString;
746
850
  lastSeenAt: z.ZodString;
747
851
  }, z.core.$strip>>>;
852
+ pickSnapshots: z.ZodDefault<z.ZodArray<z.ZodObject<{
853
+ issueUrl: z.ZodString;
854
+ grade: z.ZodNumber;
855
+ recommendation: z.ZodString;
856
+ stargazersCount: z.ZodOptional<z.ZodNumber>;
857
+ source: z.ZodEnum<{
858
+ vet: "vet";
859
+ "vet-list": "vet-list";
860
+ list: "list";
861
+ }>;
862
+ capturedAt: z.ZodOptional<z.ZodString>;
863
+ }, z.core.$strip>>>;
748
864
  lastOvernight: z.ZodOptional<z.ZodObject<{
749
865
  runAt: z.ZodString;
750
866
  reportPath: z.ZodString;
@@ -787,6 +903,7 @@ export type ProjectCategory = z.infer<typeof ProjectCategorySchema>;
787
903
  export type IssueScope = z.infer<typeof IssueScopeSchema>;
788
904
  export type DiffTool = z.infer<typeof DiffToolSchema>;
789
905
  export type SearchSeenEntry = z.infer<typeof SearchSeenEntrySchema>;
906
+ export type PickSnapshot = z.infer<typeof PickSnapshotSchema>;
790
907
  export type OvernightPrepared = z.infer<typeof OvernightPreparedSchema>;
791
908
  export type OvernightRecord = z.infer<typeof OvernightRecordSchema>;
792
909
  export type OvernightImplementAttempt = z.infer<typeof OvernightImplementAttemptSchema>;