@oss-autopilot/core 3.36.0 → 3.38.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 +1 -1
- package/dist/cli.bundle.cjs +143 -130
- package/dist/commands/comments.js +4 -3
- package/dist/commands/config.js +18 -11
- package/dist/commands/daily.js +29 -2
- package/dist/commands/dashboard-gist-sync.d.ts +5 -1
- package/dist/commands/dashboard-gist-sync.js +19 -2
- package/dist/commands/dashboard-server.js +9 -5
- package/dist/commands/dismiss.js +4 -3
- package/dist/commands/guidelines.js +21 -14
- package/dist/commands/init.js +3 -2
- package/dist/commands/ledger-backfill.d.ts +7 -0
- package/dist/commands/ledger-backfill.js +120 -9
- package/dist/commands/move.js +9 -6
- package/dist/commands/overnight-push-prep.js +5 -2
- package/dist/commands/overnight.js +48 -23
- package/dist/commands/search.js +9 -6
- package/dist/commands/setup.js +7 -3
- package/dist/commands/validation.js +22 -0
- package/dist/commands/vet-list.js +18 -17
- package/dist/commands/vet.js +27 -2
- package/dist/core/daily-logic.d.ts +33 -0
- package/dist/core/daily-logic.js +102 -0
- package/dist/core/errors.js +1 -1
- package/dist/core/eval-report.d.ts +17 -0
- package/dist/core/eval-report.js +85 -4
- package/dist/core/gist-state-store.d.ts +5 -2
- package/dist/core/gist-state-store.js +7 -4
- package/dist/core/index.d.ts +3 -3
- package/dist/core/index.js +3 -3
- package/dist/core/issue-verification.d.ts +12 -0
- package/dist/core/issue-verification.js +18 -0
- package/dist/core/pick-snapshot.d.ts +19 -2
- package/dist/core/pick-snapshot.js +28 -2
- package/dist/core/pr-monitor.d.ts +0 -6
- package/dist/core/pr-monitor.js +0 -13
- package/dist/core/repo-score-manager.d.ts +0 -13
- package/dist/core/repo-score-manager.js +0 -24
- package/dist/core/review-analysis.d.ts +34 -14
- package/dist/core/review-analysis.js +61 -32
- package/dist/core/state-persistence.js +4 -1
- package/dist/core/state-schema.d.ts +46 -0
- package/dist/core/state-schema.js +28 -0
- package/dist/core/state.d.ts +44 -18
- package/dist/core/state.js +164 -38
- package/dist/formatters/json.d.ts +4 -0
- package/dist/formatters/json.js +4 -0
- package/package.json +1 -1
|
@@ -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
|
|
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).
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
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
|
|
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
|
|
119
|
-
if (!
|
|
120
|
-
|
|
121
|
-
|
|
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
|
/**
|
|
@@ -244,6 +247,30 @@ const MAINTAINER_ASSOCIATIONS = new Set(['OWNER', 'MEMBER', 'COLLABORATOR']);
|
|
|
244
247
|
* is conversation, not a nudge.
|
|
245
248
|
*/
|
|
246
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
|
+
}
|
|
247
274
|
/**
|
|
248
275
|
* Latest maintainer activity on a PR, falling back to `createdAt` when no
|
|
249
276
|
* maintainer has engaged, plus the number of contributor pings since then.
|
|
@@ -286,15 +313,17 @@ export function getLastMaintainerActivity(comments, reviews, reviewComments, eve
|
|
|
286
313
|
}
|
|
287
314
|
};
|
|
288
315
|
for (const c of comments) {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
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);
|
|
293
326
|
}
|
|
294
|
-
for (const r of reviews)
|
|
295
|
-
consider(r.user?.login, r.user?.type, r.submitted_at);
|
|
296
|
-
for (const c of reviewComments)
|
|
297
|
-
consider(c.user?.login, c.user?.type, c.created_at);
|
|
298
327
|
for (const e of events)
|
|
299
328
|
consider(e.login, e.type, e.at, e.isPush);
|
|
300
329
|
const authorCommentTimes = comments
|
|
@@ -86,7 +86,10 @@ export function releaseLock(lockPath) {
|
|
|
86
86
|
* preventing partial/corrupt state files if the process crashes mid-write.
|
|
87
87
|
*/
|
|
88
88
|
export function atomicWriteFileSync(filePath, data, mode) {
|
|
89
|
-
|
|
89
|
+
// Per-process name: two unlocked writers (MCP server + a CLI run, both in
|
|
90
|
+
// Gist mode) sharing one `<file>.tmp` could publish each other's partial
|
|
91
|
+
// write via rename (audit 2026-10-30 L2).
|
|
92
|
+
const tmpPath = `${filePath}.${process.pid}.tmp`;
|
|
90
93
|
fs.writeFileSync(tmpPath, data, { mode: mode ?? 0o600 });
|
|
91
94
|
fs.renameSync(tmpPath, filePath);
|
|
92
95
|
// Ensure permissions are correct (rename preserves the tmp file's mode,
|
|
@@ -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;
|
|
@@ -924,10 +947,18 @@ export declare const AgentStateSchema: z.ZodObject<{
|
|
|
924
947
|
stargazersCount: z.ZodOptional<z.ZodNumber>;
|
|
925
948
|
source: z.ZodCustom<(string & {}) | "vet" | "vet-list" | "list", (string & {}) | "vet" | "vet-list" | "list">;
|
|
926
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>;
|
|
927
957
|
}, z.core.$loose>>;
|
|
928
958
|
lastReviewDecision: z.ZodOptional<z.ZodString>;
|
|
929
959
|
lastCiStatus: z.ZodOptional<z.ZodString>;
|
|
930
960
|
backfilledAt: z.ZodOptional<z.ZodString>;
|
|
961
|
+
responseRule: z.ZodOptional<z.ZodNumber>;
|
|
931
962
|
url: z.ZodString;
|
|
932
963
|
title: z.ZodString;
|
|
933
964
|
mergedAt: z.ZodString;
|
|
@@ -947,10 +978,18 @@ export declare const AgentStateSchema: z.ZodObject<{
|
|
|
947
978
|
stargazersCount: z.ZodOptional<z.ZodNumber>;
|
|
948
979
|
source: z.ZodCustom<(string & {}) | "vet" | "vet-list" | "list", (string & {}) | "vet" | "vet-list" | "list">;
|
|
949
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>;
|
|
950
988
|
}, z.core.$loose>>;
|
|
951
989
|
lastReviewDecision: z.ZodOptional<z.ZodString>;
|
|
952
990
|
lastCiStatus: z.ZodOptional<z.ZodString>;
|
|
953
991
|
backfilledAt: z.ZodOptional<z.ZodString>;
|
|
992
|
+
responseRule: z.ZodOptional<z.ZodNumber>;
|
|
954
993
|
url: z.ZodString;
|
|
955
994
|
title: z.ZodString;
|
|
956
995
|
closedAt: z.ZodString;
|
|
@@ -1044,6 +1083,13 @@ export declare const AgentStateSchema: z.ZodObject<{
|
|
|
1044
1083
|
stargazersCount: z.ZodOptional<z.ZodNumber>;
|
|
1045
1084
|
source: z.ZodCustom<(string & {}) | "vet" | "vet-list" | "list", (string & {}) | "vet" | "vet-list" | "list">;
|
|
1046
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>;
|
|
1047
1093
|
}, z.core.$loose>>>;
|
|
1048
1094
|
lastOvernight: z.ZodOptional<z.ZodObject<{
|
|
1049
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({
|
package/dist/core/state.d.ts
CHANGED
|
@@ -31,8 +31,12 @@ export declare const MAX_PICK_SNAPSHOTS = 300;
|
|
|
31
31
|
* after its retry — previously that was discarded everywhere except
|
|
32
32
|
* `state --sync`, so a failed cross-machine sync reported clean success
|
|
33
33
|
* (#1370). stderr `warn()` alone is invisible to MCP/dashboard consumers.
|
|
34
|
+
*
|
|
35
|
+
* Pass `reapply` (the same mutation the caller just performed) to make a
|
|
36
|
+
* `GistConcurrencyError` recoverable: the state is force-refreshed from the
|
|
37
|
+
* Gist, `reapply` runs on the fresh baseline, and the push is retried once.
|
|
34
38
|
*/
|
|
35
|
-
export declare function maybeCheckpoint(stateManager: StateManager, callerModule: string): Promise<string | null>;
|
|
39
|
+
export declare function maybeCheckpoint(stateManager: StateManager, callerModule: string, reapply?: () => void): Promise<string | null>;
|
|
36
40
|
/**
|
|
37
41
|
* Singleton manager for persistent agent state stored in ~/.oss-autopilot/state.json.
|
|
38
42
|
*
|
|
@@ -68,6 +72,10 @@ export declare class StateManager {
|
|
|
68
72
|
protected gistDegraded: boolean;
|
|
69
73
|
private staleness;
|
|
70
74
|
private lastSuccessfulRefreshAt;
|
|
75
|
+
private mutationDepth;
|
|
76
|
+
/** Gist mode: a mutation was saved since the last successful push. */
|
|
77
|
+
private unpushed;
|
|
78
|
+
private refreshCount;
|
|
71
79
|
private loadRecovery;
|
|
72
80
|
/**
|
|
73
81
|
* Create a new StateManager instance.
|
|
@@ -193,11 +201,36 @@ export declare class StateManager {
|
|
|
193
201
|
* fresh state because the main file was corrupt or invalid (#1371).
|
|
194
202
|
*/
|
|
195
203
|
getLoadRecovery(): LoadRecoveryInfo | null;
|
|
204
|
+
/**
|
|
205
|
+
* Run `fn` as an in-flight mutation: non-forced `refreshFromGist()` calls
|
|
206
|
+
* are skipped until it settles so a concurrent refresh cannot swap
|
|
207
|
+
* `this.state` out from under it (audit 2026-10-30 M2).
|
|
208
|
+
*
|
|
209
|
+
* Deliberately a counter, not a serializing promise chain: parallel MCP
|
|
210
|
+
* tool bodies from one host message may depend on each other through the
|
|
211
|
+
* host, so queuing them would deadlock. The gap that leaves (a sibling's
|
|
212
|
+
* *forced* conflict-recovery refresh swaps the state object mid-body) is
|
|
213
|
+
* closed by `maybeCheckpoint` re-applying every mutation right before its
|
|
214
|
+
* push; bodies that cannot re-apply (`daily`) watch `refreshGeneration`.
|
|
215
|
+
*/
|
|
216
|
+
runMutation<T>(fn: () => Promise<T>): Promise<T>;
|
|
217
|
+
/**
|
|
218
|
+
* Number of times a Gist refresh replaced the in-memory state. A successful
|
|
219
|
+
* push resolves earlier un-pushed changes only if this did not advance in
|
|
220
|
+
* between (the #1443 loss-notice invariant); a long run compares it to the
|
|
221
|
+
* value at its start to learn its mutations were swapped out.
|
|
222
|
+
*/
|
|
223
|
+
get refreshGeneration(): number;
|
|
224
|
+
/** Gist mode: whether a saved mutation has not reached the Gist yet. */
|
|
225
|
+
hasUnpushedChanges(): boolean;
|
|
196
226
|
/**
|
|
197
227
|
* Re-fetch state from the backing Gist (if in Gist mode).
|
|
198
|
-
* Throttled to once per 30 seconds by GistStateStore
|
|
228
|
+
* Throttled to once per 30 seconds by GistStateStore unless `force` is set.
|
|
229
|
+
* Returns true if state was refreshed.
|
|
199
230
|
*/
|
|
200
|
-
refreshFromGist(
|
|
231
|
+
refreshFromGist(options?: {
|
|
232
|
+
force?: boolean;
|
|
233
|
+
}): Promise<boolean>;
|
|
201
234
|
/**
|
|
202
235
|
* Returns a staleness marker when the in-memory state diverged from the
|
|
203
236
|
* canonical Gist (refresh failure or degraded bootstrap), or `null` when
|
|
@@ -292,6 +325,14 @@ export declare class StateManager {
|
|
|
292
325
|
* No-op when no PR with that URL is stored.
|
|
293
326
|
*/
|
|
294
327
|
markPRCommentsFetched(url: string, fetchedAt: string): void;
|
|
328
|
+
/**
|
|
329
|
+
* Overwrite the first-response lookup on the merged or closed PR matching
|
|
330
|
+
* `url`. Unlike addMergedPRs/addClosedPRs, which only fill missing fields,
|
|
331
|
+
* this replaces `firstMaintainerResponseAt` (clearing it when `at` is
|
|
332
|
+
* undefined) so ledger-backfill can recompute values recorded under an older
|
|
333
|
+
* maintainer rule. No-op when no PR with that URL is stored.
|
|
334
|
+
*/
|
|
335
|
+
setLedgerResponse(url: string, at: string | undefined, rule: number): void;
|
|
295
336
|
/**
|
|
296
337
|
* Stamp `learningsExtractedAt` on the merged or closed PR matching `url` (#867).
|
|
297
338
|
* No-op when no PR with that URL is stored.
|
|
@@ -440,21 +481,6 @@ export declare class StateManager {
|
|
|
440
481
|
* @param updates - Partial score fields to merge
|
|
441
482
|
*/
|
|
442
483
|
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
484
|
/** Returns repository names that have at least one merged PR. */
|
|
459
485
|
getReposWithMergedPRs(): string[];
|
|
460
486
|
/** Returns repository names with open PRs but no merged PRs yet. */
|