@oss-autopilot/core 3.33.1 → 3.35.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 +38 -1
- package/dist/cli.bundle.cjs +133 -123
- package/dist/commands/daily.js +5 -1
- package/dist/commands/dashboard-data.js +3 -1
- package/dist/commands/eval.d.ts +11 -0
- package/dist/commands/eval.js +11 -0
- package/dist/commands/index.d.ts +1 -0
- package/dist/commands/index.js +1 -0
- package/dist/commands/ledger-backfill.d.ts +40 -0
- package/dist/commands/ledger-backfill.js +222 -0
- package/dist/commands/vet-list.js +16 -6
- package/dist/commands/vet.js +4 -2
- package/dist/core/close-reason.d.ts +36 -0
- package/dist/core/close-reason.js +56 -0
- package/dist/core/daily-logic.d.ts +12 -0
- package/dist/core/daily-logic.js +10 -0
- package/dist/core/eval-report.d.ts +55 -0
- package/dist/core/eval-report.js +213 -0
- package/dist/core/gist-state-store.js +4 -1
- package/dist/core/github-stats.d.ts +9 -0
- package/dist/core/github-stats.js +26 -0
- package/dist/core/index.d.ts +2 -1
- package/dist/core/index.js +2 -1
- package/dist/core/pick-snapshot.d.ts +23 -0
- package/dist/core/pick-snapshot.js +51 -0
- package/dist/core/state-persistence.js +6 -2
- package/dist/core/state-schema.d.ts +337 -34
- package/dist/core/state-schema.js +125 -22
- package/dist/core/state.d.ts +22 -1
- package/dist/core/state.js +64 -10
- package/dist/core/types.d.ts +1 -1
- package/dist/formatters/json.d.ts +8 -0
- package/package.json +1 -1
|
@@ -6,9 +6,19 @@
|
|
|
6
6
|
* re-exported through types.ts.
|
|
7
7
|
*
|
|
8
8
|
* Schemas are defined bottom-up (leaf types first, composites last).
|
|
9
|
-
* Unknown keys are stripped by default (Zod 4 behavior)
|
|
9
|
+
* Unknown keys are stripped by default (Zod 4 behavior), EXCEPT on the schemas
|
|
10
|
+
* marked `.passthrough()` (#1831): see the note above AgentStateSchema.
|
|
10
11
|
*/
|
|
11
12
|
import { z } from 'zod';
|
|
13
|
+
import { CLOSE_REASONS, SELF_CLOSE_REASONS } from './close-reason.js';
|
|
14
|
+
/**
|
|
15
|
+
* An enum that also accepts values it does not know (#1831): a newer release
|
|
16
|
+
* may add a value, and a strict enum would make this release reject the whole
|
|
17
|
+
* state. Known values keep editor completion; read sites must handle others.
|
|
18
|
+
*/
|
|
19
|
+
function openEnum(_values) {
|
|
20
|
+
return z.custom((v) => typeof v === 'string');
|
|
21
|
+
}
|
|
12
22
|
// ── 1. Enum / union schemas ───────────────────────────────────────────
|
|
13
23
|
export const IssueStatusSchema = z.enum(['candidate', 'claimed', 'in_progress', 'pr_submitted']);
|
|
14
24
|
export const FetchedPRStatusSchema = z.enum(['needs_addressing', 'waiting_on_maintainer']);
|
|
@@ -28,7 +38,8 @@ export const RepoSignalsSchema = z.object({
|
|
|
28
38
|
isResponsive: z.boolean(),
|
|
29
39
|
hasHostileComments: z.boolean(),
|
|
30
40
|
});
|
|
31
|
-
export const RepoScoreSchema = z
|
|
41
|
+
export const RepoScoreSchema = z
|
|
42
|
+
.object({
|
|
32
43
|
repo: z.string(),
|
|
33
44
|
score: z.number(),
|
|
34
45
|
mergedPRCount: z.number(),
|
|
@@ -39,8 +50,45 @@ export const RepoScoreSchema = z.object({
|
|
|
39
50
|
signals: RepoSignalsSchema,
|
|
40
51
|
stargazersCount: z.number().optional(),
|
|
41
52
|
language: z.string().nullable().optional(),
|
|
42
|
-
})
|
|
43
|
-
|
|
53
|
+
})
|
|
54
|
+
.passthrough();
|
|
55
|
+
/**
|
|
56
|
+
* What the tool predicted about an issue when it was vetted (#1824). Recorded
|
|
57
|
+
* by `vet` / `vet-list` keyed by issue URL, then copied onto the outcome
|
|
58
|
+
* ledger entry of the PR that closes that issue, so outcomes can be compared
|
|
59
|
+
* against the prediction that picked them (calibration).
|
|
60
|
+
*/
|
|
61
|
+
export const PickSnapshotSchema = z
|
|
62
|
+
.object({
|
|
63
|
+
issueUrl: z.string(),
|
|
64
|
+
/** Success-likelihood grade (1-10) from issue-grading. */
|
|
65
|
+
grade: z.number(),
|
|
66
|
+
recommendation: z.string(),
|
|
67
|
+
stargazersCount: z.number().optional(),
|
|
68
|
+
/** `list`: the curated list's `**Tier (N/10)**` score, imported by ledger-backfill. */
|
|
69
|
+
source: openEnum(['vet', 'vet-list', 'list']),
|
|
70
|
+
/** When the vet ran. Absent for `list` picks: the list does not record vet dates reliably. */
|
|
71
|
+
capturedAt: z.string().optional(),
|
|
72
|
+
})
|
|
73
|
+
.passthrough();
|
|
74
|
+
/**
|
|
75
|
+
* Outcome-ledger fields added by #1824, shared by merged and closed entries.
|
|
76
|
+
* All optional: entries written before #1824 have none of them.
|
|
77
|
+
*/
|
|
78
|
+
const LedgerPredictionFields = {
|
|
79
|
+
/** Issue the PR closes, parsed from a closing keyword in the PR body. */
|
|
80
|
+
issueUrl: z.string().optional(),
|
|
81
|
+
/** The vet-time prediction for `issueUrl`, when one was recorded. */
|
|
82
|
+
pick: PickSnapshotSchema.optional(),
|
|
83
|
+
/** Review decision from the last digest that saw the PR open. */
|
|
84
|
+
lastReviewDecision: z.string().optional(),
|
|
85
|
+
/** CI status from the last digest that saw the PR open. */
|
|
86
|
+
lastCiStatus: z.string().optional(),
|
|
87
|
+
/** When ledger-backfill got GitHub's answer for this PR; later runs skip it. */
|
|
88
|
+
backfilledAt: z.string().optional(),
|
|
89
|
+
};
|
|
90
|
+
export const StoredMergedPRSchema = z
|
|
91
|
+
.object({
|
|
44
92
|
url: z.string(),
|
|
45
93
|
title: z.string(),
|
|
46
94
|
mergedAt: z.string(),
|
|
@@ -64,8 +112,11 @@ export const StoredMergedPRSchema = z.object({
|
|
|
64
112
|
commentsFetchedAt: z.string().datetime().optional(),
|
|
65
113
|
/** When the host last ran LLM extraction over this PR's comment bundle (#867). */
|
|
66
114
|
learningsExtractedAt: z.string().datetime().optional(),
|
|
67
|
-
|
|
68
|
-
|
|
115
|
+
...LedgerPredictionFields,
|
|
116
|
+
})
|
|
117
|
+
.passthrough();
|
|
118
|
+
export const StoredClosedPRSchema = z
|
|
119
|
+
.object({
|
|
69
120
|
url: z.string(),
|
|
70
121
|
title: z.string(),
|
|
71
122
|
closedAt: z.string(),
|
|
@@ -82,7 +133,13 @@ export const StoredClosedPRSchema = z.object({
|
|
|
82
133
|
commentsFetchedAt: z.string().datetime().optional(),
|
|
83
134
|
/** When the host last ran LLM extraction over this PR's comment bundle (#867). */
|
|
84
135
|
learningsExtractedAt: z.string().datetime().optional(),
|
|
85
|
-
|
|
136
|
+
...LedgerPredictionFields,
|
|
137
|
+
/** Why it closed unmerged (#1824), set by ledger-backfill. */
|
|
138
|
+
closeReason: openEnum(CLOSE_REASONS).optional(),
|
|
139
|
+
/** For `self-closed`: superseded, no traction, after feedback, or no response (#1824). */
|
|
140
|
+
selfCloseReason: openEnum(SELF_CLOSE_REASONS).optional(),
|
|
141
|
+
})
|
|
142
|
+
.passthrough();
|
|
86
143
|
export const AnalyzedIssueConversationSchema = z.object({
|
|
87
144
|
url: z.string(),
|
|
88
145
|
repo: z.string(),
|
|
@@ -184,7 +241,8 @@ export const StatusOverrideSchema = z.object({
|
|
|
184
241
|
lastActivityAt: z.string(),
|
|
185
242
|
});
|
|
186
243
|
// ── 5. Config schema ─────────────────────────────────────────────────
|
|
187
|
-
export const AgentConfigSchema = z
|
|
244
|
+
export const AgentConfigSchema = z
|
|
245
|
+
.object({
|
|
188
246
|
setupComplete: z.boolean().default(false),
|
|
189
247
|
setupCompletedAt: z.string().optional(),
|
|
190
248
|
persistence: z.enum(['local', 'gist']).default('local'),
|
|
@@ -285,7 +343,11 @@ export const AgentConfigSchema = z.object({
|
|
|
285
343
|
* local network.
|
|
286
344
|
*/
|
|
287
345
|
slmTriageHost: z.string().default(''),
|
|
288
|
-
})
|
|
346
|
+
})
|
|
347
|
+
// Passthrough (#1831): a newer release's config fields survive this
|
|
348
|
+
// version's load/save. Retired fields must be dropped explicitly instead.
|
|
349
|
+
.passthrough()
|
|
350
|
+
.transform(({ snoozedPRs: _retired, ...config }) => config);
|
|
289
351
|
// ── 6. Cache schemas ─────────────────────────────────────────────────
|
|
290
352
|
export const LocalRepoCacheSchema = z.object({
|
|
291
353
|
repos: z.record(z.string(), z.object({
|
|
@@ -310,6 +372,8 @@ export const ClosedPRSchema = z.object({
|
|
|
310
372
|
* Optional: digests persisted by older producers don't have it.
|
|
311
373
|
*/
|
|
312
374
|
openedAt: z.string().optional(),
|
|
375
|
+
/** Issue the PR closes, parsed from the PR body (#1824). */
|
|
376
|
+
issueUrl: z.string().optional(),
|
|
313
377
|
});
|
|
314
378
|
export const MergedPRSchema = z.object({
|
|
315
379
|
url: z.string(),
|
|
@@ -323,6 +387,8 @@ export const MergedPRSchema = z.object({
|
|
|
323
387
|
* Optional: digests persisted by older producers don't have it.
|
|
324
388
|
*/
|
|
325
389
|
openedAt: z.string().optional(),
|
|
390
|
+
/** Issue the PR closes, parsed from the PR body (#1824). */
|
|
391
|
+
issueUrl: z.string().optional(),
|
|
326
392
|
});
|
|
327
393
|
export const DailyDigestSummarySchema = z.object({
|
|
328
394
|
totalActivePRs: z.number(),
|
|
@@ -408,7 +474,8 @@ export const SearchSeenEntrySchema = z.object({
|
|
|
408
474
|
* run; `overnight push-prep` (#1698) may later stage it under `prep/*` on the
|
|
409
475
|
* user's fork and fills in `pushedRef`, `pushedAt` and `compareUrl`.
|
|
410
476
|
*/
|
|
411
|
-
export const OvernightPreparedSchema = z
|
|
477
|
+
export const OvernightPreparedSchema = z
|
|
478
|
+
.object({
|
|
412
479
|
url: z.string(),
|
|
413
480
|
branch: z.string(),
|
|
414
481
|
worktree: z.string().optional(),
|
|
@@ -421,20 +488,24 @@ export const OvernightPreparedSchema = z.object({
|
|
|
421
488
|
compareUrl: z.string().optional(),
|
|
422
489
|
/** Why the last `overnight push-prep` did not push this branch; cleared once it is pushed. */
|
|
423
490
|
pushProblem: z.string().optional(),
|
|
424
|
-
})
|
|
491
|
+
})
|
|
492
|
+
.passthrough();
|
|
425
493
|
/** The latest overnight run (#1574); `startup` surfaces its freshness. */
|
|
426
494
|
/**
|
|
427
495
|
* One list issue the overnight run tried to implement (#1715). Kept across
|
|
428
496
|
* runs so a blocked issue is not retried every night; cleared when the
|
|
429
497
|
* issue leaves the list.
|
|
430
498
|
*/
|
|
431
|
-
export const OvernightImplementAttemptSchema = z
|
|
499
|
+
export const OvernightImplementAttemptSchema = z
|
|
500
|
+
.object({
|
|
432
501
|
url: z.string(),
|
|
433
502
|
attemptedAt: z.string(),
|
|
434
503
|
outcome: z.enum(['prepared', 'blocked']),
|
|
435
504
|
note: z.string().optional(),
|
|
436
|
-
})
|
|
437
|
-
|
|
505
|
+
})
|
|
506
|
+
.passthrough();
|
|
507
|
+
export const OvernightRecordSchema = z
|
|
508
|
+
.object({
|
|
438
509
|
runAt: z.string(),
|
|
439
510
|
reportPath: z.string(),
|
|
440
511
|
prepareCount: z.number().int().nonnegative(),
|
|
@@ -443,23 +514,38 @@ export const OvernightRecordSchema = z.object({
|
|
|
443
514
|
/** The one curated-list issue picked for implementation this run, if any (#1715). */
|
|
444
515
|
implementUrl: z.string().optional(),
|
|
445
516
|
implementAttempts: z.array(OvernightImplementAttemptSchema).optional(),
|
|
446
|
-
})
|
|
517
|
+
})
|
|
518
|
+
.passthrough();
|
|
447
519
|
/**
|
|
448
520
|
* Mirrors oss-scout's `searchRotation`: the broad-phase language cursor, the
|
|
449
521
|
* repo-window cursors of the capped phases, and the round-robin strategy
|
|
450
|
-
* cursor (oss-scout 1.7.0).
|
|
451
|
-
*
|
|
452
|
-
*
|
|
522
|
+
* cursor (oss-scout 1.7.0). List every cursor so it gets its default;
|
|
523
|
+
* passthrough (#1831) keeps a cursor added by a newer bundled scout instead of
|
|
524
|
+
* resetting it to 0 on this release's next save.
|
|
453
525
|
*/
|
|
454
|
-
export const SearchRotationSchema = z
|
|
526
|
+
export const SearchRotationSchema = z
|
|
527
|
+
.object({
|
|
455
528
|
languageOffset: z.number().int().nonnegative().default(0),
|
|
456
529
|
phase0Offset: z.number().int().nonnegative().default(0),
|
|
457
530
|
starredOffset: z.number().int().nonnegative().default(0),
|
|
458
531
|
maintainedOffset: z.number().int().nonnegative().default(0),
|
|
459
532
|
strategyOffset: z.number().int().nonnegative().default(0),
|
|
460
533
|
lastRotatedAt: z.string().optional(),
|
|
461
|
-
})
|
|
462
|
-
|
|
534
|
+
})
|
|
535
|
+
.passthrough();
|
|
536
|
+
/**
|
|
537
|
+
* Forward compatibility (#1831). The state Gist is shared by clients on
|
|
538
|
+
* different releases, and a strict parse let an older client drop a newer
|
|
539
|
+
* release's fields on its next save. Schemas for data that is written once and
|
|
540
|
+
* kept (root, config, repoScores, the outcome ledger and pick snapshots,
|
|
541
|
+
* lastOvernight, searchRotation) are `.passthrough()`; schemas regenerated on
|
|
542
|
+
* every run (lastDigest) or rarely extended still strip. Persisted enums that
|
|
543
|
+
* grow (closeReason, pick source) accept unknown strings via {@link openEnum}.
|
|
544
|
+
* Inferred types drop the passthrough index signature ({@link KnownKeys}) so a
|
|
545
|
+
* misspelled key still fails to compile.
|
|
546
|
+
*/
|
|
547
|
+
export const AgentStateSchema = z
|
|
548
|
+
.object({
|
|
463
549
|
version: z.literal(4),
|
|
464
550
|
gistId: z.string().optional(),
|
|
465
551
|
repoScores: z.record(z.string(), RepoScoreSchema).default({}),
|
|
@@ -509,6 +595,12 @@ export const AgentStateSchema = z.object({
|
|
|
509
595
|
* it cannot grow without bound.
|
|
510
596
|
*/
|
|
511
597
|
searchSeen: z.array(SearchSeenEntrySchema).default([]),
|
|
598
|
+
/**
|
|
599
|
+
* Vet-time predictions keyed by issue URL (#1824), newest last. Joined onto
|
|
600
|
+
* outcome-ledger entries at merge/close detection. Capped at
|
|
601
|
+
* MAX_PICK_SNAPSHOTS so it cannot grow without bound.
|
|
602
|
+
*/
|
|
603
|
+
pickSnapshots: z.array(PickSnapshotSchema).default([]),
|
|
512
604
|
/** Latest overnight run (#1574). Absent until the first `overnight`. */
|
|
513
605
|
lastOvernight: OvernightRecordSchema.optional(),
|
|
514
606
|
/**
|
|
@@ -518,4 +610,15 @@ export const AgentStateSchema = z.object({
|
|
|
518
610
|
* here and fed into the next scout state. Absent until the first search.
|
|
519
611
|
*/
|
|
520
612
|
searchRotation: SearchRotationSchema.optional(),
|
|
521
|
-
})
|
|
613
|
+
})
|
|
614
|
+
.passthrough();
|
|
615
|
+
/** Top-level state keys this release does not know, i.e. written by another (usually newer) release (#1831). */
|
|
616
|
+
export function unknownStateKeys(raw) {
|
|
617
|
+
if (!raw || typeof raw !== 'object')
|
|
618
|
+
return [];
|
|
619
|
+
const known = new Set(Object.keys(AgentStateSchema.shape));
|
|
620
|
+
return Object.keys(raw).filter((k) => !known.has(k));
|
|
621
|
+
}
|
|
622
|
+
/** Warning tail for state written by a newer release (#1831), shared by the Gist and local loaders. */
|
|
623
|
+
export const NEWER_WRITER_HINT = 'was written by a different oss-autopilot release (usually a newer one); this version keeps those fields ' +
|
|
624
|
+
'but cannot use them. If you are not on the latest release, update with `claude plugin update oss-autopilot@oss-autopilot` and restart Claude Code.';
|
package/dist/core/state.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Thin coordinator that delegates persistence to state-persistence.ts
|
|
4
4
|
* and scoring logic to repo-score-manager.ts.
|
|
5
5
|
*/
|
|
6
|
-
import { AgentState, TrackedIssue, RepoScore, RepoScoreUpdate, DailyDigest, LocalRepoCache, StatusOverride, FetchedPRStatus, StoredMergedPR, StoredClosedPR, SearchSeenEntry, OvernightRecord, SearchRotation } from './types.js';
|
|
6
|
+
import { AgentState, TrackedIssue, RepoScore, RepoScoreUpdate, DailyDigest, LocalRepoCache, StatusOverride, FetchedPRStatus, StoredMergedPR, StoredClosedPR, SearchSeenEntry, PickSnapshot, OvernightRecord, SearchRotation } from './types.js';
|
|
7
7
|
import { type LoadRecoveryInfo } from './state-persistence.js';
|
|
8
8
|
import type { Stats } from './repo-score-manager.js';
|
|
9
9
|
import { GistStateStore } from './gist-state-store.js';
|
|
@@ -13,6 +13,8 @@ import { type GistHealth } from './gist-health.js';
|
|
|
13
13
|
export { acquireLock, releaseLock, atomicWriteFileSync } from './state-persistence.js';
|
|
14
14
|
export type { LoadRecoveryInfo } from './state-persistence.js';
|
|
15
15
|
export type { Stats } from './repo-score-manager.js';
|
|
16
|
+
/** Cap on `state.pickSnapshots` (#1824): ~180 bytes each, so ~55 KB at the cap. */
|
|
17
|
+
export declare const MAX_PICK_SNAPSHOTS = 300;
|
|
16
18
|
/**
|
|
17
19
|
* Push state to the backing Gist when Gist mode is active. Best-effort:
|
|
18
20
|
* network/auth failures are logged via `warn()` but never propagated —
|
|
@@ -257,6 +259,12 @@ export declare class StateManager {
|
|
|
257
259
|
added: number;
|
|
258
260
|
dropped: number;
|
|
259
261
|
};
|
|
262
|
+
/**
|
|
263
|
+
* Copy the vet-time prediction for the PR's closing issue onto a ledger
|
|
264
|
+
* entry (#1824). Returns the entry unchanged when it has no issueUrl, already
|
|
265
|
+
* carries a pick, or no snapshot was recorded for that issue.
|
|
266
|
+
*/
|
|
267
|
+
private withPick;
|
|
260
268
|
/** Returns the most recent merge date, used as a watermark for incremental fetching. */
|
|
261
269
|
getMergedPRWatermark(): string | undefined;
|
|
262
270
|
/** Returns all stored closed-without-merge PRs (sorted by close date descending via addClosedPRs). */
|
|
@@ -362,6 +370,19 @@ export declare class StateManager {
|
|
|
362
370
|
* @param status - The overridden status
|
|
363
371
|
* @param lastActivityAt - ISO timestamp of PR's last activity when override was set
|
|
364
372
|
*/
|
|
373
|
+
/** Vet-time predictions awaiting a ledger join (#1824), oldest first. */
|
|
374
|
+
getPickSnapshots(): PickSnapshot[];
|
|
375
|
+
/**
|
|
376
|
+
* Record vet-time predictions (#1824). The first prediction for an issue
|
|
377
|
+
* wins: a later re-vet (often after the user's own PR exists) must not
|
|
378
|
+
* replace the one that picked it. The oldest entries are dropped past
|
|
379
|
+
* {@link MAX_PICK_SNAPSHOTS}.
|
|
380
|
+
*
|
|
381
|
+
* ponytail: never refreshed, so an issue vetted months before it is picked
|
|
382
|
+
* keeps its old grade. Replace snapshots older than N days if that skews
|
|
383
|
+
* calibration.
|
|
384
|
+
*/
|
|
385
|
+
recordPickSnapshots(snapshots: PickSnapshot[]): void;
|
|
365
386
|
/**
|
|
366
387
|
* The durable search seen-set (#1528) — issue URLs surfaced by recent
|
|
367
388
|
* searches, fed into oss-scout for result rotation. Returns `[]` when none
|
package/dist/core/state.js
CHANGED
|
@@ -37,8 +37,20 @@ function filterValidUrlEntries(entries, kind) {
|
|
|
37
37
|
}
|
|
38
38
|
return { valid, dropped };
|
|
39
39
|
}
|
|
40
|
+
/** Optional outcome-ledger fields (#1461, #1824) that a re-seen entry may fill in. */
|
|
41
|
+
const LEDGER_FIELDS = [
|
|
42
|
+
'openedAt',
|
|
43
|
+
'firstMaintainerResponseAt',
|
|
44
|
+
'issueUrl',
|
|
45
|
+
'pick',
|
|
46
|
+
'lastReviewDecision',
|
|
47
|
+
'lastCiStatus',
|
|
48
|
+
'backfilledAt',
|
|
49
|
+
'closeReason',
|
|
50
|
+
'selfCloseReason',
|
|
51
|
+
];
|
|
40
52
|
/**
|
|
41
|
-
* Fill outcome-ledger
|
|
53
|
+
* Fill outcome-ledger fields (#1461, #1824) missing on an existing stored PR
|
|
42
54
|
* from a richer re-seen entry. Only fills absent fields — never overwrites —
|
|
43
55
|
* so an earlier enriched write (and stamps like commentsFetchedAt that live
|
|
44
56
|
* solely on the stored entry) cannot be clobbered by a later minimal one.
|
|
@@ -46,16 +58,16 @@ function filterValidUrlEntries(entries, kind) {
|
|
|
46
58
|
*/
|
|
47
59
|
function upgradeLedgerFields(existing, incoming) {
|
|
48
60
|
let changed = false;
|
|
49
|
-
|
|
50
|
-
existing
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
existing.firstMaintainerResponseAt = incoming.firstMaintainerResponseAt;
|
|
55
|
-
changed = true;
|
|
61
|
+
for (const key of LEDGER_FIELDS) {
|
|
62
|
+
if (incoming[key] !== undefined && existing[key] === undefined) {
|
|
63
|
+
existing[key] = incoming[key];
|
|
64
|
+
changed = true;
|
|
65
|
+
}
|
|
56
66
|
}
|
|
57
67
|
return changed;
|
|
58
68
|
}
|
|
69
|
+
/** Cap on `state.pickSnapshots` (#1824): ~180 bytes each, so ~55 KB at the cap. */
|
|
70
|
+
export const MAX_PICK_SNAPSHOTS = 300;
|
|
59
71
|
/**
|
|
60
72
|
* Push state to the backing Gist when Gist mode is active. Best-effort:
|
|
61
73
|
* network/auth failures are logged via `warn()` but never propagated —
|
|
@@ -590,7 +602,8 @@ export class StateManager {
|
|
|
590
602
|
addMergedPRs(prs) {
|
|
591
603
|
if (prs.length === 0)
|
|
592
604
|
return { added: 0, dropped: 0 };
|
|
593
|
-
const { valid, dropped } = filterValidUrlEntries(prs, 'merged');
|
|
605
|
+
const { valid: unpicked, dropped } = filterValidUrlEntries(prs, 'merged');
|
|
606
|
+
const valid = unpicked.map((pr) => this.withPick(pr));
|
|
594
607
|
if (valid.length === 0)
|
|
595
608
|
return { added: 0, dropped };
|
|
596
609
|
if (!this.state.mergedPRs)
|
|
@@ -616,6 +629,18 @@ export class StateManager {
|
|
|
616
629
|
this.autoSave();
|
|
617
630
|
return { added: newPRs.length, dropped };
|
|
618
631
|
}
|
|
632
|
+
/**
|
|
633
|
+
* Copy the vet-time prediction for the PR's closing issue onto a ledger
|
|
634
|
+
* entry (#1824). Returns the entry unchanged when it has no issueUrl, already
|
|
635
|
+
* carries a pick, or no snapshot was recorded for that issue.
|
|
636
|
+
*/
|
|
637
|
+
withPick(pr) {
|
|
638
|
+
if (!pr.issueUrl || pr.pick)
|
|
639
|
+
return pr;
|
|
640
|
+
const key = pr.issueUrl.toLowerCase();
|
|
641
|
+
const pick = this.getPickSnapshots().find((p) => p.issueUrl.toLowerCase() === key);
|
|
642
|
+
return pick ? { ...pr, pick } : pr;
|
|
643
|
+
}
|
|
619
644
|
/** Returns the most recent merge date, used as a watermark for incremental fetching. */
|
|
620
645
|
getMergedPRWatermark() {
|
|
621
646
|
return this.state.mergedPRs?.[0]?.mergedAt || undefined;
|
|
@@ -640,7 +665,8 @@ export class StateManager {
|
|
|
640
665
|
addClosedPRs(prs) {
|
|
641
666
|
if (prs.length === 0)
|
|
642
667
|
return { added: 0, dropped: 0 };
|
|
643
|
-
const { valid, dropped } = filterValidUrlEntries(prs, 'closed');
|
|
668
|
+
const { valid: unpicked, dropped } = filterValidUrlEntries(prs, 'closed');
|
|
669
|
+
const valid = unpicked.map((pr) => this.withPick(pr));
|
|
644
670
|
if (valid.length === 0)
|
|
645
671
|
return { added: 0, dropped };
|
|
646
672
|
if (!this.state.closedPRs)
|
|
@@ -876,6 +902,34 @@ export class StateManager {
|
|
|
876
902
|
* @param status - The overridden status
|
|
877
903
|
* @param lastActivityAt - ISO timestamp of PR's last activity when override was set
|
|
878
904
|
*/
|
|
905
|
+
/** Vet-time predictions awaiting a ledger join (#1824), oldest first. */
|
|
906
|
+
getPickSnapshots() {
|
|
907
|
+
return this.state.pickSnapshots ?? [];
|
|
908
|
+
}
|
|
909
|
+
/**
|
|
910
|
+
* Record vet-time predictions (#1824). The first prediction for an issue
|
|
911
|
+
* wins: a later re-vet (often after the user's own PR exists) must not
|
|
912
|
+
* replace the one that picked it. The oldest entries are dropped past
|
|
913
|
+
* {@link MAX_PICK_SNAPSHOTS}.
|
|
914
|
+
*
|
|
915
|
+
* ponytail: never refreshed, so an issue vetted months before it is picked
|
|
916
|
+
* keeps its old grade. Replace snapshots older than N days if that skews
|
|
917
|
+
* calibration.
|
|
918
|
+
*/
|
|
919
|
+
recordPickSnapshots(snapshots) {
|
|
920
|
+
const known = new Set(this.getPickSnapshots().map((p) => p.issueUrl.toLowerCase()));
|
|
921
|
+
const fresh = snapshots.filter((p) => {
|
|
922
|
+
const key = p.issueUrl.toLowerCase();
|
|
923
|
+
if (known.has(key))
|
|
924
|
+
return false;
|
|
925
|
+
known.add(key);
|
|
926
|
+
return true;
|
|
927
|
+
});
|
|
928
|
+
if (fresh.length === 0)
|
|
929
|
+
return;
|
|
930
|
+
this.state.pickSnapshots = [...this.getPickSnapshots(), ...fresh].slice(-MAX_PICK_SNAPSHOTS);
|
|
931
|
+
this.autoSave();
|
|
932
|
+
}
|
|
879
933
|
/**
|
|
880
934
|
* The durable search seen-set (#1528) — issue URLs surfaced by recent
|
|
881
935
|
* searches, fed into oss-scout for result rotation. Returns `[]` when none
|
package/dist/core/types.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Core types for the Open Source Contribution Agent
|
|
3
3
|
*/
|
|
4
4
|
import type { FetchedPRStatus, RepoSignals, TrackedIssue, IssueVettingResult, IssueScope, DiffTool, AgentConfig, AgentState } from './state-schema.js';
|
|
5
|
-
export type { IssueStatus, FetchedPRStatus, ProjectCategory, IssueScope, DiffTool, RepoSignals, RepoScore, StoredMergedPR, StoredClosedPR, AnalyzedIssueConversation, ContributionGuidelines, IssueVettingResult, TrackedIssue, ShelvedPRRef, StatusOverride, AgentConfig, LocalRepoCache, ClosedPR, MergedPR, DailyDigest, AgentState, SearchSeenEntry, OvernightPrepared, OvernightRecord, OvernightImplementAttempt, SearchRotation, } from './state-schema.js';
|
|
5
|
+
export type { IssueStatus, FetchedPRStatus, ProjectCategory, IssueScope, DiffTool, RepoSignals, RepoScore, StoredMergedPR, StoredClosedPR, AnalyzedIssueConversation, ContributionGuidelines, IssueVettingResult, TrackedIssue, ShelvedPRRef, StatusOverride, AgentConfig, LocalRepoCache, ClosedPR, MergedPR, DailyDigest, AgentState, SearchSeenEntry, PickSnapshot, OvernightPrepared, OvernightRecord, OvernightImplementAttempt, SearchRotation, } from './state-schema.js';
|
|
6
6
|
/** CI pipeline status for a PR's latest commit. */
|
|
7
7
|
export type CIStatus = 'passing' | 'failing' | 'pending' | 'unknown';
|
|
8
8
|
/**
|
|
@@ -1575,6 +1575,10 @@ export interface VetListOutput {
|
|
|
1575
1575
|
*/
|
|
1576
1576
|
error?: string;
|
|
1577
1577
|
};
|
|
1578
|
+
/** Set when the vet-time predictions (#1824) could not be saved locally. */
|
|
1579
|
+
pickRecordError?: string;
|
|
1580
|
+
/** Set when the saved predictions could not be pushed to the Gist. */
|
|
1581
|
+
gistSyncWarning?: string;
|
|
1578
1582
|
}
|
|
1579
1583
|
/** Output of the vet command */
|
|
1580
1584
|
export interface VetOutput {
|
|
@@ -1629,6 +1633,10 @@ export interface VetOutput {
|
|
|
1629
1633
|
score: number;
|
|
1630
1634
|
reason: string;
|
|
1631
1635
|
};
|
|
1636
|
+
/** Set when the vet-time prediction (#1824) could not be saved locally. */
|
|
1637
|
+
pickRecordError?: string;
|
|
1638
|
+
/** Set when the saved prediction could not be pushed to the Gist. */
|
|
1639
|
+
gistSyncWarning?: string;
|
|
1632
1640
|
}
|
|
1633
1641
|
/** Output of the comments command */
|
|
1634
1642
|
export interface CommentsOutput {
|