@oss-autopilot/core 3.42.4 → 3.43.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-pre-action.js +8 -3
- package/dist/cli-registry.js +272 -25
- package/dist/cli.bundle.cjs +183 -154
- package/dist/commands/check-integration.js +1 -0
- package/dist/commands/cleanup.d.ts +76 -0
- package/dist/commands/cleanup.js +269 -0
- package/dist/commands/comments.d.ts +6 -0
- package/dist/commands/comments.js +6 -2
- package/dist/commands/config.js +37 -5
- package/dist/commands/daily-dismiss-filter.d.ts +7 -0
- package/dist/commands/daily-dismiss-filter.js +17 -1
- package/dist/commands/daily-ledger.d.ts +122 -0
- package/dist/commands/daily-ledger.js +225 -0
- package/dist/commands/daily-recent-prs.d.ts +26 -0
- package/dist/commands/daily-recent-prs.js +55 -0
- package/dist/commands/daily.d.ts +2 -1
- package/dist/commands/daily.js +59 -89
- package/dist/commands/dashboard-cache.d.ts +2 -0
- package/dist/commands/dashboard-cache.js +33 -8
- package/dist/commands/dashboard-data.js +71 -36
- package/dist/commands/dashboard-gist-sync.js +3 -1
- package/dist/commands/dashboard-lifecycle.js +1 -1
- package/dist/commands/dashboard-process.d.ts +14 -1
- package/dist/commands/dashboard-process.js +46 -7
- package/dist/commands/dashboard-server.js +89 -23
- package/dist/commands/detect-formatters.js +1 -0
- package/dist/commands/dismiss.js +5 -2
- package/dist/commands/doctor.d.ts +15 -1
- package/dist/commands/doctor.js +73 -5
- package/dist/commands/draft.d.ts +77 -0
- package/dist/commands/draft.js +218 -0
- package/dist/commands/eval.js +1 -0
- package/dist/commands/guidelines.d.ts +23 -1
- package/dist/commands/guidelines.js +49 -4
- package/dist/commands/index.d.ts +24 -4
- package/dist/commands/index.js +15 -3
- package/dist/commands/issue-thread.d.ts +46 -0
- package/dist/commands/issue-thread.js +123 -0
- package/dist/commands/ledger-backfill.d.ts +9 -0
- package/dist/commands/ledger-backfill.js +44 -1
- package/dist/commands/list-mark-done.d.ts +2 -1
- package/dist/commands/list-mark-done.js +3 -1
- package/dist/commands/list-move-tier.d.ts +2 -1
- package/dist/commands/list-move-tier.js +3 -1
- package/dist/commands/local-repos.js +10 -5
- package/dist/commands/locate-issue-list.d.ts +40 -17
- package/dist/commands/locate-issue-list.js +148 -88
- package/dist/commands/move.js +7 -1
- package/dist/commands/overnight-handoff.d.ts +17 -7
- package/dist/commands/overnight-handoff.js +36 -14
- package/dist/commands/overnight-push-prep.d.ts +13 -8
- package/dist/commands/overnight-push-prep.js +106 -34
- package/dist/commands/overnight-tool-rules.d.ts +54 -0
- package/dist/commands/overnight-tool-rules.js +217 -0
- package/dist/commands/overnight.d.ts +5 -6
- package/dist/commands/overnight.js +61 -140
- package/dist/commands/parse-list.js +7 -1
- package/dist/commands/policy.d.ts +86 -0
- package/dist/commands/policy.js +263 -0
- package/dist/commands/pr-preflight.d.ts +43 -0
- package/dist/commands/pr-preflight.js +294 -0
- package/dist/commands/repo-vet.d.ts +9 -0
- package/dist/commands/repo-vet.js +36 -11
- package/dist/commands/scout-bridge.js +18 -8
- package/dist/commands/search.js +7 -0
- package/dist/commands/setup.d.ts +3 -3
- package/dist/commands/setup.js +46 -18
- package/dist/commands/skip-add.js +10 -1
- package/dist/commands/startup.d.ts +5 -3
- package/dist/commands/startup.js +65 -49
- package/dist/commands/state-cmd.d.ts +2 -0
- package/dist/commands/state-cmd.js +5 -1
- package/dist/commands/stats.js +1 -0
- package/dist/commands/status.js +1 -0
- package/dist/commands/strategy.js +1 -0
- package/dist/commands/vet-list.d.ts +6 -0
- package/dist/commands/vet-list.js +25 -0
- package/dist/commands/vet.d.ts +12 -0
- package/dist/commands/vet.js +118 -1
- package/dist/core/__fixtures__/prompt-injection-payloads.js +31 -0
- package/dist/core/anti-llm-policy.d.ts +3 -0
- package/dist/core/anti-llm-policy.js +3 -0
- package/dist/core/auth.js +2 -0
- package/dist/core/checklist-analysis.js +50 -12
- package/dist/core/ci-analysis.d.ts +7 -2
- package/dist/core/ci-analysis.js +76 -21
- package/dist/core/comment-utils.d.ts +1 -1
- package/dist/core/comment-utils.js +7 -1
- package/dist/core/commit-date.d.ts +19 -0
- package/dist/core/commit-date.js +17 -0
- package/dist/core/compliance-score.js +11 -7
- package/dist/core/config-registry.js +11 -5
- package/dist/core/contributing.d.ts +2 -3
- package/dist/core/contributing.js +2 -3
- package/dist/core/daily-logic.d.ts +27 -5
- package/dist/core/daily-logic.js +57 -19
- package/dist/core/errors.d.ts +37 -3
- package/dist/core/errors.js +54 -5
- package/dist/core/gist-health.d.ts +15 -3
- package/dist/core/gist-health.js +8 -0
- package/dist/core/gist-state-store.d.ts +24 -4
- package/dist/core/gist-state-store.js +97 -46
- package/dist/core/github-stats.d.ts +104 -16
- package/dist/core/github-stats.js +282 -97
- package/dist/core/http-cache.d.ts +0 -10
- package/dist/core/http-cache.js +0 -19
- package/dist/core/index.d.ts +12 -5
- package/dist/core/index.js +15 -5
- package/dist/core/issue-conversation.d.ts +8 -2
- package/dist/core/issue-conversation.js +31 -12
- package/dist/core/local-config.d.ts +95 -0
- package/dist/core/local-config.js +271 -0
- package/dist/core/merged-pr-notes.d.ts +2 -2
- package/dist/core/pagination.d.ts +55 -0
- package/dist/core/pagination.js +59 -0
- package/dist/core/paths.d.ts +7 -0
- package/dist/core/paths.js +9 -0
- package/dist/core/pr-assembly.js +6 -2
- package/dist/core/pr-graphql.d.ts +37 -3
- package/dist/core/pr-graphql.js +73 -12
- package/dist/core/pr-monitor.d.ts +29 -12
- package/dist/core/pr-monitor.js +71 -23
- package/dist/core/pr-preflight.d.ts +113 -0
- package/dist/core/pr-preflight.js +364 -0
- package/dist/core/pr-quality-rubric.d.ts +0 -6
- package/dist/core/pr-quality-rubric.js +0 -8
- package/dist/core/pr-template.d.ts +2 -0
- package/dist/core/pr-template.js +5 -1
- package/dist/core/repo-policy.d.ts +105 -0
- package/dist/core/repo-policy.js +400 -0
- package/dist/core/repo-score-manager.d.ts +48 -0
- package/dist/core/repo-score-manager.js +111 -1
- package/dist/core/review-analysis.d.ts +34 -19
- package/dist/core/review-analysis.js +74 -19
- package/dist/core/reviewed-prs-fetch.js +11 -29
- package/dist/core/reviewed-prs.js +8 -15
- package/dist/core/stale-data.d.ts +41 -0
- package/dist/core/stale-data.js +115 -0
- package/dist/core/state-persistence.d.ts +62 -27
- package/dist/core/state-persistence.js +338 -117
- package/dist/core/state-schema.d.ts +113 -210
- package/dist/core/state-schema.js +165 -80
- package/dist/core/state.d.ts +60 -8
- package/dist/core/state.js +192 -46
- package/dist/core/status-determination.js +26 -8
- package/dist/core/strategy.js +3 -1
- package/dist/core/types.d.ts +22 -1
- package/dist/core/types.js +1 -0
- package/dist/core/untrusted-content.d.ts +30 -11
- package/dist/core/untrusted-content.js +77 -42
- package/dist/core/urls.d.ts +9 -0
- package/dist/core/urls.js +18 -0
- package/dist/dashboard/assets/{chart-panel-DPKNBUts.js → chart-panel-C_C1lFTI.js} +1 -1
- package/dist/dashboard/assets/{index-B25bZOYX.js → index-B--H66Jk.js} +1 -1
- package/dist/dashboard/index.html +1 -1
- package/dist/formatters/json.d.ts +262 -6
- package/dist/formatters/json.js +77 -1
- package/package.json +1 -1
- package/dist/core/ci-enforced-tools.d.ts +0 -35
- package/dist/core/ci-enforced-tools.js +0 -109
- package/dist/core/comment-decision.d.ts +0 -79
- package/dist/core/comment-decision.js +0 -82
- package/dist/core/extraction-categories.d.ts +0 -55
- package/dist/core/extraction-categories.js +0 -108
- package/dist/core/follow-up-history.d.ts +0 -40
- package/dist/core/follow-up-history.js +0 -71
- package/dist/core/issue-effort.d.ts +0 -29
- package/dist/core/issue-effort.js +0 -47
- package/dist/core/maintainer-hints.d.ts +0 -23
- package/dist/core/maintainer-hints.js +0 -36
- package/dist/core/workflow-state.d.ts +0 -56
- package/dist/core/workflow-state.js +0 -101
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ledger upkeep the daily run does before it rewrites per-repo counts. Kept
|
|
3
|
+
* out of daily.ts so ledger rules live in one small place.
|
|
4
|
+
*/
|
|
5
|
+
import { firstMaintainerResponseFromDigest, lastReviewStateFromDigest } from '../core/daily-logic.js';
|
|
6
|
+
import { CLOSED_LEDGER_TRUNCATED_MESSAGE, fetchClosedPRsSince, fetchMergedPRsSince, gapFetchWatermark, MERGED_LEDGER_TRUNCATED_MESSAGE, } from '../core/github-stats.js';
|
|
7
|
+
import { errorMessage } from '../core/errors.js';
|
|
8
|
+
import { debug, warn } from '../core/logger.js';
|
|
9
|
+
import { findRepoTransfers } from '../core/repo-score-manager.js';
|
|
10
|
+
import { recordWarning } from './daily-warnings.js';
|
|
11
|
+
const MODULE = 'daily';
|
|
12
|
+
/**
|
|
13
|
+
* Bring the stored merged/closed ledgers in line with what GitHub reports now.
|
|
14
|
+
* Must run before anything reads or writes repoScores in the same batch.
|
|
15
|
+
*
|
|
16
|
+
* 1. Re-key transferred/renamed repos, so the old name isn't zeroed and then
|
|
17
|
+
* re-bumped from stored PR URLs on the next load (which double counted its
|
|
18
|
+
* merges in getStats).
|
|
19
|
+
* 2. Drop closed-ledger entries that were reopened (now in `openPRs`) or have
|
|
20
|
+
* since merged, so the count reconciliation that follows no longer raises
|
|
21
|
+
* `closedWithoutMergeCount` back to a ledger that still holds them (#1923).
|
|
22
|
+
* This runs every day, so state inflated before the fix heals on the next
|
|
23
|
+
* run, as does an entry another machine's older copy brought back.
|
|
24
|
+
*
|
|
25
|
+
* @param searchedPRs - every merged/closed PR the count searches returned
|
|
26
|
+
* @param openPRs - the user's currently open PRs, as just fetched
|
|
27
|
+
*/
|
|
28
|
+
export function syncLedgersWithGitHub(stateManager, searchedPRs, openPRs) {
|
|
29
|
+
const stored = [...stateManager.getMergedPRs(), ...stateManager.getClosedPRs()];
|
|
30
|
+
for (const [from, to] of findRepoTransfers(stored, searchedPRs)) {
|
|
31
|
+
stateManager.renameRepo(from, to);
|
|
32
|
+
}
|
|
33
|
+
stateManager.evictClosedPRs(openPRs.map((pr) => pr.url));
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Write the star counts and languages a repository read returned, then drop
|
|
37
|
+
* what is stored about repositories whose PRs are never tracked (#1924):
|
|
38
|
+
* those in `config.untrackedOrgs`, and those this read reported private.
|
|
39
|
+
* The fetches no longer return either kind; this removes what earlier
|
|
40
|
+
* versions stored, and what another machine's older copy brings back.
|
|
41
|
+
*
|
|
42
|
+
* Only an explicit `isPrivate: true` in `repoMetadata` counts as private. A
|
|
43
|
+
* repository missing from the map (404, network error, aborted chunk, or the
|
|
44
|
+
* whole fetch failing) or with no flag is left alone, so deleted, renamed and
|
|
45
|
+
* transferred repositories keep their rows.
|
|
46
|
+
*/
|
|
47
|
+
export function applyRepoMetadata(stateManager, repoMetadata, warnings) {
|
|
48
|
+
let failures = 0;
|
|
49
|
+
const privateRepos = [];
|
|
50
|
+
for (const [repo, { stars, language, isPrivate }] of repoMetadata) {
|
|
51
|
+
if (isPrivate === true) {
|
|
52
|
+
// Evicted below; writing its stars first would only recreate the entry.
|
|
53
|
+
privateRepos.push(repo);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
stateManager.updateRepoScore(repo, { stargazersCount: stars, language });
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
failures++;
|
|
61
|
+
warn(MODULE, `Failed to update metadata for ${repo}: ${errorMessage(error)}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (failures > 0) {
|
|
65
|
+
warnings.push({
|
|
66
|
+
phase: 'repo-scores',
|
|
67
|
+
operation: 'update repo metadata',
|
|
68
|
+
message: `${failures} of ${repoMetadata.size} metadata update(s) failed. This may indicate corrupted state.`,
|
|
69
|
+
});
|
|
70
|
+
warn(MODULE, `[METADATA_UPDATES_FAILED] ${failures} of ${repoMetadata.size} metadata update(s) failed.`);
|
|
71
|
+
}
|
|
72
|
+
const evicted = stateManager.evictExcludedRepos(privateRepos);
|
|
73
|
+
if (evicted.untrackedOrgRows + evicted.privateRows + evicted.repos > 0) {
|
|
74
|
+
warn(MODULE, `Removed PRs that are never tracked: ${evicted.untrackedOrgRows} ledger row(s) in untracked organisations, ` +
|
|
75
|
+
`${evicted.privateRows} in private repositories, ${evicted.repos} repo score(s).`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Zero `closedWithoutMergeCount` for repos the closed-PR count search no
|
|
80
|
+
* longer returns, mirroring the stale reset daily does for merged counts.
|
|
81
|
+
* Without it, a repo whose closed PRs were all reopened or merged leaves the
|
|
82
|
+
* search and keeps its last search-set count for good (#1923). The count
|
|
83
|
+
* reconciliation that follows in the same batch raises each repo back to its
|
|
84
|
+
* closed-ledger count, so only the surplus over the ledger is dropped.
|
|
85
|
+
*
|
|
86
|
+
* Skipped, like the merged reset, when the search returned nothing while state
|
|
87
|
+
* has closed counts (possible transient API failure) or when it hit its
|
|
88
|
+
* pagination cap (an absent repo may still have closed PRs).
|
|
89
|
+
*/
|
|
90
|
+
export function resetStaleClosedCounts(stateManager, closedCounts, wasSearchTruncated) {
|
|
91
|
+
const withClosed = Object.values(stateManager.getState().repoScores).filter((score) => (score.closedWithoutMergeCount || 0) > 0);
|
|
92
|
+
if (closedCounts.size === 0 && withClosed.length > 0) {
|
|
93
|
+
warn(MODULE, `Skipping stale closed count reset: API returned 0 closed PR results but state has ${withClosed.length} repo(s) with closed PRs. Possible transient API issue.`);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (wasSearchTruncated) {
|
|
97
|
+
debug(MODULE, 'Skipping stale closed count reset: closed PR search was truncated.');
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
for (const score of withClosed) {
|
|
101
|
+
if (!closedCounts.has(score.repo))
|
|
102
|
+
stateManager.updateRepoScore(score.repo, { closedWithoutMergeCount: 0 });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/** Run one gap fetch, recording a failure or truncation in `warnings`. */
|
|
106
|
+
async function fetchLedgerGap(kind, fetch, truncatedMessage, warnings) {
|
|
107
|
+
const operation = `fetch ${kind} PRs for the ledger`;
|
|
108
|
+
let gap;
|
|
109
|
+
try {
|
|
110
|
+
gap = await fetch();
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
recordWarning(warnings, 'fetch', operation, error);
|
|
114
|
+
}
|
|
115
|
+
if (gap?.truncated)
|
|
116
|
+
warnings.push({ phase: 'fetch', message: truncatedMessage, operation });
|
|
117
|
+
return gap;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Compare a ledger with GitHub's all-time count. A hole older than the newest
|
|
121
|
+
* entry is invisible to the gap fetch; the count is the one signal that shows
|
|
122
|
+
* it, and `ledger-backfill` is what fills it. The count search and the ledger
|
|
123
|
+
* fetch share one scope (externalPRScope: public, not the user's own, no
|
|
124
|
+
* untracked organisations), so the two are comparable; when that scope cannot
|
|
125
|
+
* be put in a query the count is undefined and the check is skipped.
|
|
126
|
+
*
|
|
127
|
+
* A ledger larger than the public total is expected while rows GitHub no
|
|
128
|
+
* longer lists (or private ones not yet evicted) remain; each such row can
|
|
129
|
+
* mask one missing public PR until it is gone.
|
|
130
|
+
*/
|
|
131
|
+
function checkLedgerCount(kind, stored, allTimeCount, warnings) {
|
|
132
|
+
const missing = (allTimeCount ?? 0) - stored;
|
|
133
|
+
if (missing > 0) {
|
|
134
|
+
warnings.push({
|
|
135
|
+
phase: 'analytics',
|
|
136
|
+
operation: `check ${kind}-PR ledger`,
|
|
137
|
+
message: `The ${kind}-PR ledger holds ${stored} of the ${allTimeCount} ${kind} PRs GitHub reports ` +
|
|
138
|
+
`(${missing} missing). Run \`ledger-backfill\` to fetch them.`,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Fetch every merged PR since the ledger's newest entry (#1924). The recent
|
|
144
|
+
* list daily shows covers seven days, so after a longer pause it alone left
|
|
145
|
+
* the merges in between out of the ledger for good. Must run before anything
|
|
146
|
+
* in this run adds to the merged ledger: the watermark is read here.
|
|
147
|
+
*
|
|
148
|
+
* A failed or truncated fetch is recorded in `warnings`, and
|
|
149
|
+
* {@link storeMergedLedger} then stores nothing, so the next run asks for the
|
|
150
|
+
* same range again. Until a run stores them, today's merges are not in the
|
|
151
|
+
* ledger, so the "extract learnings" nudge, which counts ledger rows of
|
|
152
|
+
* recent merges, is also held back for them.
|
|
153
|
+
*/
|
|
154
|
+
export function fetchMergedLedgerGap(octokit, stateManager, warnings) {
|
|
155
|
+
const { config } = stateManager.getState();
|
|
156
|
+
const watermark = stateManager.getMergedPRWatermark();
|
|
157
|
+
return fetchLedgerGap('merged', () => fetchMergedPRsSince(octokit, config, watermark), MERGED_LEDGER_TRUNCATED_MESSAGE, warnings);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* The closed-ledger mirror of {@link fetchMergedLedgerGap} (#1925). Without
|
|
161
|
+
* it the recent closed list seeded a fresh ledger with last week's closes,
|
|
162
|
+
* and the dashboard's fetch then started from that newest row, so older
|
|
163
|
+
* closed history was never fetched. Must run before anything in this run adds
|
|
164
|
+
* to the closed ledger.
|
|
165
|
+
*
|
|
166
|
+
* A ledger an older version already left short of `allTimeCount` is fetched
|
|
167
|
+
* from the start while it is under the backfill ceiling (see
|
|
168
|
+
* gapFetchWatermark), so it heals without a manual `ledger-backfill`.
|
|
169
|
+
*/
|
|
170
|
+
export function fetchClosedLedgerGap(octokit, stateManager, warnings, allTimeCount) {
|
|
171
|
+
const { config } = stateManager.getState();
|
|
172
|
+
const watermark = gapFetchWatermark(stateManager.getClosedPRWatermark(), stateManager.getClosedPRs().length, allTimeCount);
|
|
173
|
+
return fetchLedgerGap('closed', () => fetchClosedPRsSince(octokit, config, watermark), CLOSED_LEDGER_TRUNCATED_MESSAGE, warnings);
|
|
174
|
+
}
|
|
175
|
+
/** Fields both ledgers fill the same way from a fetched or recent row. */
|
|
176
|
+
function ledgerFields(pr, previousDigest) {
|
|
177
|
+
return {
|
|
178
|
+
url: pr.url,
|
|
179
|
+
title: pr.title,
|
|
180
|
+
openedAt: pr.openedAt,
|
|
181
|
+
firstMaintainerResponseAt: firstMaintainerResponseFromDigest(previousDigest, pr.url),
|
|
182
|
+
issueUrl: pr.issueUrl,
|
|
183
|
+
...lastReviewStateFromDigest(previousDigest, pr.url),
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Add this run's merges to the merged ledger: the gap since its newest entry
|
|
188
|
+
* plus the recent list (which can also fill an older hole inside its window).
|
|
189
|
+
*
|
|
190
|
+
* Nothing is stored unless the gap was fetched whole. The ledger's newest
|
|
191
|
+
* entry is the next run's starting point, so a recent row stored without the
|
|
192
|
+
* rows before it would move that point past merges nobody fetched.
|
|
193
|
+
*
|
|
194
|
+
* Then compares the ledger with GitHub's all-time merged count (see
|
|
195
|
+
* checkLedgerCount).
|
|
196
|
+
*/
|
|
197
|
+
export function storeMergedLedger(stateManager, input) {
|
|
198
|
+
const { gap, previousDigest } = input;
|
|
199
|
+
if (!gap || gap.truncated)
|
|
200
|
+
return;
|
|
201
|
+
const rows = [...input.recentlyMergedPRs, ...gap.prs].map((pr) => ({
|
|
202
|
+
...ledgerFields(pr, previousDigest),
|
|
203
|
+
mergedAt: pr.mergedAt,
|
|
204
|
+
}));
|
|
205
|
+
if (rows.length > 0)
|
|
206
|
+
stateManager.addMergedPRs(rows);
|
|
207
|
+
checkLedgerCount('merged', stateManager.getMergedPRs().length, input.allTimeCount, input.warnings);
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* The closed-ledger mirror of {@link storeMergedLedger} (#1925): the gap
|
|
211
|
+
* plus the recent closed list, stored only when the gap was fetched whole,
|
|
212
|
+
* then checked against GitHub's all-time closed-without-merge count.
|
|
213
|
+
*/
|
|
214
|
+
export function storeClosedLedger(stateManager, input) {
|
|
215
|
+
const { gap, previousDigest } = input;
|
|
216
|
+
if (!gap || gap.truncated)
|
|
217
|
+
return;
|
|
218
|
+
const rows = [...input.recentlyClosedPRs, ...gap.prs].map((pr) => ({
|
|
219
|
+
...ledgerFields(pr, previousDigest),
|
|
220
|
+
closedAt: pr.closedAt,
|
|
221
|
+
}));
|
|
222
|
+
if (rows.length > 0)
|
|
223
|
+
stateManager.addClosedPRs(rows);
|
|
224
|
+
checkLedgerCount('closed', stateManager.getClosedPRs().length, input.allTimeCount, input.warnings);
|
|
225
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The daily run's recently closed and recently merged PR lists (#1928).
|
|
3
|
+
* Split out of daily.ts so a failed or partial list is recorded in one place:
|
|
4
|
+
* both land in `warnings[]`, and a merged list that may be missing entries is
|
|
5
|
+
* named as a reason to distrust "no successor PR exists" (Phase 3.6).
|
|
6
|
+
*
|
|
7
|
+
* "Truncation" here is the recent-list truncation (these two 7-day lists),
|
|
8
|
+
* not the count-search truncation of the all-time merged and closed counts.
|
|
9
|
+
*/
|
|
10
|
+
import type { ClosedPR, MergedPR, PRMonitor } from '../core/index.js';
|
|
11
|
+
import type { DailyWarning } from '../formatters/json.js';
|
|
12
|
+
export interface RecentPRLists {
|
|
13
|
+
recentlyClosedPRs: ClosedPR[];
|
|
14
|
+
recentlyMergedPRs: MergedPR[];
|
|
15
|
+
/** `recentlyMergedPRs` is the [] fallback of a failed fetch, not an empty result (Phases 3.6 and 3.7). */
|
|
16
|
+
recentlyMergedFetchFailed: boolean;
|
|
17
|
+
/** Why a merged PR could be missing from `recentlyMergedPRs`; empty when the list is whole. */
|
|
18
|
+
successorGapReasons: string[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Fetch both lists in parallel. Neither failure is fatal: a failed fetch is
|
|
22
|
+
* a warning and an empty list. A partial list (page cap reached, or GitHub
|
|
23
|
+
* flagged the search incomplete) is kept and reported as a warning; for the
|
|
24
|
+
* merged list it is also a successor gap, like a failed fetch.
|
|
25
|
+
*/
|
|
26
|
+
export declare function fetchRecentPRLists(prMonitor: Pick<PRMonitor, 'fetchRecentlyClosedPRs' | 'fetchRecentlyMergedPRs'>, warnings: DailyWarning[]): Promise<RecentPRLists>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The daily run's recently closed and recently merged PR lists (#1928).
|
|
3
|
+
* Split out of daily.ts so a failed or partial list is recorded in one place:
|
|
4
|
+
* both land in `warnings[]`, and a merged list that may be missing entries is
|
|
5
|
+
* named as a reason to distrust "no successor PR exists" (Phase 3.6).
|
|
6
|
+
*
|
|
7
|
+
* "Truncation" here is the recent-list truncation (these two 7-day lists),
|
|
8
|
+
* not the count-search truncation of the all-time merged and closed counts.
|
|
9
|
+
*/
|
|
10
|
+
import { recordWarning } from './daily-warnings.js';
|
|
11
|
+
const TRUNCATED_OPERATION = 'fetch recent PRs (truncated)';
|
|
12
|
+
/** Successor-gap reason for a partial merged list; it ends up in the "withheld" warning next to each PR. */
|
|
13
|
+
const MERGED_LIST_TRUNCATED_REASON = 'the recently-merged list was truncated; release the claim by hand if no PR replaced this one, the automatic release stays off while the list is over the page cap';
|
|
14
|
+
/**
|
|
15
|
+
* The list, or undefined (with a warning) when its fetch failed. Rate-limit
|
|
16
|
+
* and auth errors are a warning here too, as they were before #1928:
|
|
17
|
+
* rethrowing would end the whole daily run where it used to degrade.
|
|
18
|
+
*/
|
|
19
|
+
async function fetchOrWarn(fetch, operation, warnings) {
|
|
20
|
+
try {
|
|
21
|
+
return await fetch;
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
recordWarning(warnings, 'fetch', operation, error);
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Fetch both lists in parallel. Neither failure is fatal: a failed fetch is
|
|
30
|
+
* a warning and an empty list. A partial list (page cap reached, or GitHub
|
|
31
|
+
* flagged the search incomplete) is kept and reported as a warning; for the
|
|
32
|
+
* merged list it is also a successor gap, like a failed fetch.
|
|
33
|
+
*/
|
|
34
|
+
export async function fetchRecentPRLists(prMonitor, warnings) {
|
|
35
|
+
const closedTruncations = [];
|
|
36
|
+
const mergedTruncations = [];
|
|
37
|
+
const [closed, merged] = await Promise.all([
|
|
38
|
+
fetchOrWarn(prMonitor.fetchRecentlyClosedPRs(7, closedTruncations), 'fetch recently closed PRs', warnings),
|
|
39
|
+
fetchOrWarn(prMonitor.fetchRecentlyMergedPRs(7, mergedTruncations), 'fetch recently merged PRs', warnings),
|
|
40
|
+
]);
|
|
41
|
+
for (const { message } of [closedTruncations, mergedTruncations].flat()) {
|
|
42
|
+
warnings.push({ message, phase: 'fetch', operation: TRUNCATED_OPERATION });
|
|
43
|
+
}
|
|
44
|
+
const successorGapReasons = [];
|
|
45
|
+
if (merged === undefined)
|
|
46
|
+
successorGapReasons.push('the recently-merged fetch failed');
|
|
47
|
+
if (mergedTruncations.length > 0)
|
|
48
|
+
successorGapReasons.push(MERGED_LIST_TRUNCATED_REASON);
|
|
49
|
+
return {
|
|
50
|
+
successorGapReasons,
|
|
51
|
+
recentlyClosedPRs: closed ?? [],
|
|
52
|
+
recentlyMergedPRs: merged ?? [],
|
|
53
|
+
recentlyMergedFetchFailed: merged === undefined,
|
|
54
|
+
};
|
|
55
|
+
}
|
package/dist/commands/daily.d.ts
CHANGED
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
import { type WorkClaim, type ClosedPRStatusUpdate, type MergedPRNotes, type ReviewedPRFollowUp, type AttentionSummary, type DailyDigest, type CommentedIssue, type PRCheckFailure, type RepoGroup } from '../core/index.js';
|
|
10
10
|
import { type StrategyResult } from '../core/strategy.js';
|
|
11
11
|
import { type DailyOutput, type DailyWarning, type CapacityAssessment, type ActionableIssue, type ActionMenu, type MergedPRListUpdate, type PendingLearnings } from '../formatters/json.js';
|
|
12
|
-
export { applyStatusOverrides, computeRepoSignals, groupPRsByRepo, assessCapacity, collectActionableIssues, computeActionMenu, toShelvedPRRef,
|
|
12
|
+
export { applyStatusOverrides, computeRepoSignals, groupPRsByRepo, assessCapacity, collectActionableIssues, computeActionMenu, toShelvedPRRef, CRITICAL_STATUSES, } from '../core/index.js';
|
|
13
|
+
export { formatBriefSummary, formatSummary, printDigest } from './daily-render.js';
|
|
13
14
|
/**
|
|
14
15
|
* Internal result of the daily check, using full (non-deduplicated) types.
|
|
15
16
|
* Consumed by printDigest() (text mode) and converted to DailyOutput (JSON mode)
|
package/dist/commands/daily.js
CHANGED
|
@@ -6,30 +6,33 @@
|
|
|
6
6
|
* Domain logic lives in src/core/daily-logic.ts; this file is a thin
|
|
7
7
|
* orchestration layer that wires up the phases and handles I/O.
|
|
8
8
|
*/
|
|
9
|
-
import { getStateManager, parseGitHubUrl, issueRefKey, PRMonitor, IssueConversationMonitor, requireGitHubToken, renderGistWarning, CRITICAL_STATUSES, applyStatusOverrides, computeRepoSignals, computeLedgerRepoSignals, GistConcurrencyError, groupPRsByRepo, assessCapacity, collectActionableIssues, computeActionMenu, collectEngagedIssues,
|
|
9
|
+
import { getStateManager, parseGitHubUrl, issueRefKey, PRMonitor, IssueConversationMonitor, requireGitHubToken, renderGistWarning, renderUnknownModeWarning, CRITICAL_STATUSES, shouldAutoUnshelve, shelveReasonsOf, withoutShelvedNeedsAddressing, applyStatusOverrides, computeRepoSignals, computeLedgerRepoSignals, GistConcurrencyError, groupPRsByRepo, assessCapacity, collectActionableIssues, computeActionMenu, collectEngagedIssues, getOctokit, toShelvedPRRef, summarizeAttentionBuckets, shouldSuggestClose, selectClosedPRStatusCandidates, toClosedPRStatusUpdate, activeWorkClaims, finishedImplementations, } from '../core/index.js';
|
|
10
10
|
import { errorMessage, isRateLimitOrAuthError } from '../core/errors.js';
|
|
11
11
|
import { DEFAULT_CONCURRENCY, runWorkerPool } from '../core/concurrency.js';
|
|
12
12
|
import { wrapUntrustedContent } from '../core/untrusted-content.js';
|
|
13
13
|
import { computeStrategy, shouldComputeStrategy } from '../core/strategy.js';
|
|
14
14
|
import { debug, warn } from '../core/logger.js';
|
|
15
15
|
import { emptyPRCountsResult } from '../core/github-stats.js';
|
|
16
|
-
import { findRepoTransfers } from '../core/repo-score-manager.js';
|
|
17
16
|
import { updateMonthlyAnalytics } from './dashboard-data.js';
|
|
18
17
|
import { deduplicateDigest, compactActionableIssues, compactRepoGroups, buildStalenessWarning, } from '../formatters/json.js';
|
|
19
18
|
import { reconcileMergedPRsWithList } from './merge-loop.js';
|
|
20
19
|
import { describeError, httpStatusLabel, isGoneError, nonFatalCatchWithWarning, recordWarning, } from './daily-warnings.js';
|
|
20
|
+
import { formatBriefSummary, formatSummary } from './daily-render.js';
|
|
21
21
|
import { fenceMergedPRNotes, runMergedPRNotesPhase } from './daily-merged-pr-notes.js';
|
|
22
|
+
import { fetchRecentPRLists } from './daily-recent-prs.js';
|
|
22
23
|
import { fenceReviewedPR, runReviewedPRsPhase } from './daily-reviewed-prs.js';
|
|
23
|
-
import { batchOnFreshBaseline, filterDismissedIssues } from './daily-dismiss-filter.js';
|
|
24
|
+
import { batchOnFreshBaseline, filterDismissedIssues, reloadOrWarn } from './daily-dismiss-filter.js';
|
|
25
|
+
import { applyRepoMetadata, fetchClosedLedgerGap, fetchMergedLedgerGap, resetStaleClosedCounts, storeClosedLedger, storeMergedLedger, syncLedgersWithGitHub, } from './daily-ledger.js';
|
|
24
26
|
const MODULE = 'daily';
|
|
25
27
|
// Re-export domain functions so existing consumers (tests, dashboard, startup)
|
|
26
28
|
// can continue importing from './daily.js' without changes.
|
|
27
|
-
export { applyStatusOverrides, computeRepoSignals, groupPRsByRepo, assessCapacity, collectActionableIssues, computeActionMenu, toShelvedPRRef,
|
|
29
|
+
export { applyStatusOverrides, computeRepoSignals, groupPRsByRepo, assessCapacity, collectActionableIssues, computeActionMenu, toShelvedPRRef, CRITICAL_STATUSES, } from '../core/index.js';
|
|
30
|
+
export { formatBriefSummary, formatSummary, printDigest } from './daily-render.js';
|
|
28
31
|
// buildStarFilter moved to core/daily-logic.ts so the dashboard layer can
|
|
29
32
|
// reuse it without crossing the commands → sibling-command boundary
|
|
30
33
|
// (#1208 M7). Re-exported here for backward compatibility with anyone
|
|
31
34
|
// importing from this module.
|
|
32
|
-
import { buildStarFilter
|
|
35
|
+
import { buildStarFilter } from '../core/daily-logic.js';
|
|
33
36
|
/** Lowercased `owner/repo` of a GitHub PR or issue URL, or undefined when it does not parse. */
|
|
34
37
|
function repoKeyOf(url) {
|
|
35
38
|
const parsed = parseGitHubUrl(url);
|
|
@@ -107,8 +110,7 @@ async function fetchPRData(prMonitor, token, warnings) {
|
|
|
107
110
|
// Fetch merged PR counts, closed PR counts, recently closed PRs, recently merged PRs, and commented issues in parallel
|
|
108
111
|
// All stats fetches are non-critical (cosmetic/scoring), so isolate their failure
|
|
109
112
|
const issueMonitor = new IssueConversationMonitor(token);
|
|
110
|
-
|
|
111
|
-
const [mergedResult, closedResult, recentlyClosedPRs, recentlyMergedPRs] = await Promise.all([
|
|
113
|
+
const [mergedResult, closedResult, recentPRs] = await Promise.all([
|
|
112
114
|
prMonitor.fetchUserMergedPRCounts(starFilter).catch(nonFatalCatchWithWarning({
|
|
113
115
|
warnings,
|
|
114
116
|
phase: 'fetch',
|
|
@@ -121,24 +123,11 @@ async function fetchPRData(prMonitor, token, warnings) {
|
|
|
121
123
|
operation: 'fetch closed PR counts',
|
|
122
124
|
fallback: emptyPRCountsResult(),
|
|
123
125
|
})),
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
operation: 'fetch recently closed PRs',
|
|
128
|
-
fallback: [],
|
|
129
|
-
})),
|
|
130
|
-
prMonitor.fetchRecentlyMergedPRs().catch((error) => {
|
|
131
|
-
// Phase 3.6 treats a fallback here as an incomplete view of the
|
|
132
|
-
// user's PRs (a just-merged successor would be invisible).
|
|
133
|
-
didRecentlyMergedFetchFail = true;
|
|
134
|
-
return nonFatalCatchWithWarning({
|
|
135
|
-
warnings,
|
|
136
|
-
phase: 'fetch',
|
|
137
|
-
operation: 'fetch recently merged PRs',
|
|
138
|
-
fallback: [],
|
|
139
|
-
})(error);
|
|
140
|
-
}),
|
|
126
|
+
// Phase 3.6 treats a failed or partial merged list as an incomplete view
|
|
127
|
+
// of the user's PRs (a just-merged successor would be invisible).
|
|
128
|
+
fetchRecentPRLists(prMonitor, warnings),
|
|
141
129
|
]);
|
|
130
|
+
const { recentlyClosedPRs, recentlyMergedPRs } = recentPRs;
|
|
142
131
|
// Issue conversations run after the PR lists: the engaged set (#1862)
|
|
143
132
|
// needs the open, recently closed and recently merged PRs. The fetch has
|
|
144
133
|
// custom messaging based on the error content, so it keeps its bespoke catch.
|
|
@@ -183,8 +172,7 @@ async function fetchPRData(prMonitor, token, warnings) {
|
|
|
183
172
|
const successorGaps = { everywhere: [], failedRepos: new Set() };
|
|
184
173
|
if (fetchResult.searchTruncated)
|
|
185
174
|
successorGaps.everywhere.push('the open-PR search was truncated');
|
|
186
|
-
|
|
187
|
-
successorGaps.everywhere.push('the recently-merged fetch failed');
|
|
175
|
+
successorGaps.everywhere.push(...recentPRs.successorGapReasons);
|
|
188
176
|
for (const failure of failures) {
|
|
189
177
|
const repoKey = repoKeyOf(failure.prUrl);
|
|
190
178
|
if (repoKey)
|
|
@@ -194,8 +182,10 @@ async function fetchPRData(prMonitor, token, warnings) {
|
|
|
194
182
|
}
|
|
195
183
|
return {
|
|
196
184
|
searchedPRs: [...mergedResult.searchedPRs, ...closedResult.searchedPRs],
|
|
197
|
-
recentlyMergedFetchFailed:
|
|
198
|
-
|
|
185
|
+
recentlyMergedFetchFailed: recentPRs.recentlyMergedFetchFailed,
|
|
186
|
+
truncatedSearches: { merged: mergedResult.truncated, closed: closedResult.truncated },
|
|
187
|
+
mergedTotalCount: mergedResult.totalCount,
|
|
188
|
+
closedTotalCount: closedResult.totalCount,
|
|
199
189
|
successorGaps,
|
|
200
190
|
prs,
|
|
201
191
|
failures,
|
|
@@ -215,20 +205,16 @@ async function fetchPRData(prMonitor, token, warnings) {
|
|
|
215
205
|
* Applies stale repo reset, updates merged/closed counts, computes and stores
|
|
216
206
|
* repo signals from open PR data, refreshes star counts, and syncs trusted projects.
|
|
217
207
|
*/
|
|
218
|
-
async function updateRepoScores(prMonitor, prs, mergedCounts,
|
|
208
|
+
async function updateRepoScores(prMonitor, prs, mergedCounts, truncatedSearches, closedCounts, searchedPRs, warnings) {
|
|
219
209
|
const stateManager = getStateManager();
|
|
220
210
|
// Batch all synchronous score mutations for a single disk write.
|
|
221
211
|
// Per-repo try-catch: a single corrupted repo should not prevent updates to others.
|
|
222
212
|
// Outer try-catch: save failure should not crash the daily check (in-memory mutations still apply).
|
|
223
213
|
try {
|
|
224
214
|
batchOnFreshBaseline(stateManager, () => {
|
|
225
|
-
// Re-key transferred
|
|
226
|
-
//
|
|
227
|
-
|
|
228
|
-
const stored = [...stateManager.getMergedPRs(), ...stateManager.getClosedPRs()];
|
|
229
|
-
for (const [from, to] of findRepoTransfers(stored, searchedPRs)) {
|
|
230
|
-
stateManager.renameRepo(from, to);
|
|
231
|
-
}
|
|
215
|
+
// Re-key transferred repos and evict reopened/merged PRs from the closed
|
|
216
|
+
// ledger before anything below reads or writes repoScores (#1923).
|
|
217
|
+
syncLedgersWithGitHub(stateManager, searchedPRs, prs);
|
|
232
218
|
// Reset stale repos first (so excluded/removed repos get zeroed).
|
|
233
219
|
// Guard: if the API returned zero results but we have existing repos with merged PRs,
|
|
234
220
|
// skip the reset to avoid wiping scores due to transient API failures.
|
|
@@ -236,7 +222,7 @@ async function updateRepoScores(prMonitor, prs, mergedCounts, wasMergedSearchTru
|
|
|
236
222
|
if (mergedCounts.size === 0 && existingReposWithMerges.length > 0) {
|
|
237
223
|
warn(MODULE, `Skipping stale repo reset: API returned 0 merged PR results but state has ${existingReposWithMerges.length} repo(s) with merges. Possible API issue.`);
|
|
238
224
|
}
|
|
239
|
-
else if (
|
|
225
|
+
else if (truncatedSearches.merged) {
|
|
240
226
|
// A repo absent from a pagination-capped search may still have merges (#1897).
|
|
241
227
|
debug(MODULE, 'Skipping stale repo reset: merged PR search was truncated.');
|
|
242
228
|
}
|
|
@@ -270,11 +256,9 @@ async function updateRepoScores(prMonitor, prs, mergedCounts, wasMergedSearchTru
|
|
|
270
256
|
});
|
|
271
257
|
warn(MODULE, `[MERGED_COUNT_UPDATES_FAILED] ${mergedCountFailures} of ${mergedCounts.size} merged count update(s) failed.`);
|
|
272
258
|
}
|
|
273
|
-
// Populate closedWithoutMergeCount in repo scores
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
warn(MODULE, `API returned 0 closed PR results but state has ${existingReposWithClosed.length} repo(s) with closed PRs. Possible transient API issue.`);
|
|
277
|
-
}
|
|
259
|
+
// Populate closedWithoutMergeCount in repo scores: zero the repos that
|
|
260
|
+
// left the closed search, then write the counts it returned.
|
|
261
|
+
resetStaleClosedCounts(stateManager, closedCounts, truncatedSearches.closed);
|
|
278
262
|
let closedCountFailures = 0;
|
|
279
263
|
for (const [repo, count] of closedCounts) {
|
|
280
264
|
try {
|
|
@@ -353,24 +337,8 @@ async function updateRepoScores(prMonitor, prs, mergedCounts, wasMergedSearchTru
|
|
|
353
337
|
// Batch metadata + trust sync mutations for a single disk write
|
|
354
338
|
try {
|
|
355
339
|
batchOnFreshBaseline(stateManager, () => {
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
try {
|
|
359
|
-
stateManager.updateRepoScore(repo, { stargazersCount: stars, language });
|
|
360
|
-
}
|
|
361
|
-
catch (error) {
|
|
362
|
-
metadataUpdateFailures++;
|
|
363
|
-
warn(MODULE, `Failed to update metadata for ${repo}: ${errorMessage(error)}`);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
if (metadataUpdateFailures > 0) {
|
|
367
|
-
warnings.push({
|
|
368
|
-
phase: 'repo-scores',
|
|
369
|
-
operation: 'update repo metadata',
|
|
370
|
-
message: `${metadataUpdateFailures} of ${repoMetadata.size} metadata update(s) failed. This may indicate corrupted state.`,
|
|
371
|
-
});
|
|
372
|
-
warn(MODULE, `[METADATA_UPDATES_FAILED] ${metadataUpdateFailures} of ${repoMetadata.size} metadata update(s) failed.`);
|
|
373
|
-
}
|
|
340
|
+
// Stars and languages in, then untracked and private repositories out (#1924).
|
|
341
|
+
applyRepoMetadata(stateManager, repoMetadata, warnings);
|
|
374
342
|
// Auto-sync trustedProjects from repos with merged PRs
|
|
375
343
|
let trustSyncFailures = 0;
|
|
376
344
|
for (const [repo] of mergedCounts) {
|
|
@@ -426,14 +394,17 @@ function partitionPRs(prMonitor, prs, recentlyClosedPRs, recentlyMergedPRs, warn
|
|
|
426
394
|
let digest;
|
|
427
395
|
try {
|
|
428
396
|
batchOnFreshBaseline(stateManager, () => {
|
|
397
|
+
const shelvedPRInfo = stateManager.getState().config.shelvedPRInfo;
|
|
429
398
|
for (const pr of overriddenPRs) {
|
|
430
399
|
if (stateManager.isPRShelved(pr.url)) {
|
|
431
|
-
if (
|
|
400
|
+
if (shouldAutoUnshelve(pr, shelvedPRInfo)) {
|
|
432
401
|
stateManager.unshelvePR(pr.url);
|
|
433
402
|
autoUnshelvedPRs.push(toShelvedPRRef(pr));
|
|
434
403
|
activePRs.push(pr);
|
|
435
404
|
}
|
|
436
405
|
else {
|
|
406
|
+
// Still shelved: record its reasons if the shelve could not (#1922).
|
|
407
|
+
stateManager.fillShelvedPRReasons(pr.url, shelveReasonsOf(pr));
|
|
437
408
|
shelvedPRs.push(toShelvedPRRef(pr));
|
|
438
409
|
}
|
|
439
410
|
}
|
|
@@ -451,7 +422,7 @@ function partitionPRs(prMonitor, prs, recentlyClosedPRs, recentlyMergedPRs, warn
|
|
|
451
422
|
// output) reflect dashboard/CLI reclassifications.
|
|
452
423
|
// Note: digest.openPRs contains ALL fetched PRs (including shelved).
|
|
453
424
|
// We override summary fields below to reflect active-only counts.
|
|
454
|
-
digest = prMonitor.generateDigest(overriddenPRs, recentlyClosedPRs, recentlyMergedPRs);
|
|
425
|
+
digest = withoutShelvedNeedsAddressing(prMonitor.generateDigest(overriddenPRs, recentlyClosedPRs, recentlyMergedPRs), shelvedPRs);
|
|
455
426
|
// Attach shelve info to digest
|
|
456
427
|
digest.shelvedPRs = shelvedPRs;
|
|
457
428
|
digest.autoUnshelvedPRs = autoUnshelvedPRs;
|
|
@@ -487,7 +458,7 @@ function partitionPRs(prMonitor, prs, recentlyClosedPRs, recentlyMergedPRs, warn
|
|
|
487
458
|
throw new Error(`Daily digest generation failed and no previously persisted digest exists to fall back to` +
|
|
488
459
|
(recorded ? `: ${recorded.message}` : '.'));
|
|
489
460
|
}
|
|
490
|
-
return { activePRs, shelvedPRs, autoUnshelvedPRs, digest: persisted };
|
|
461
|
+
return { activePRs, shelvedPRs, autoUnshelvedPRs, digest: withoutShelvedNeedsAddressing(persisted, shelvedPRs) };
|
|
491
462
|
}
|
|
492
463
|
return { activePRs, shelvedPRs, autoUnshelvedPRs, digest };
|
|
493
464
|
}
|
|
@@ -500,7 +471,7 @@ function generateDigestOutput(digest, activePRs, shelvedPRs, commentedIssues, fa
|
|
|
500
471
|
const stateManager = getStateManager();
|
|
501
472
|
// Assess capacity from active PRs only (shelved PRs excluded). Reload first
|
|
502
473
|
// so maxActivePRs reflects a config change made while the run was fetching.
|
|
503
|
-
stateManager
|
|
474
|
+
reloadOrWarn(stateManager, warnings);
|
|
504
475
|
const capacity = assessCapacity(activePRs, stateManager.getState().config.maxActivePRs, shelvedPRs.length);
|
|
505
476
|
// One nudge per issue (#1863): an issue listed under closedPRStatusUpdates
|
|
506
477
|
// leaves the commented-issue list for this run unless it carries a new
|
|
@@ -846,7 +817,9 @@ async function executeDailyCheckInternal(token) {
|
|
|
846
817
|
// `gistInitWarning` duplicate — see `jsonSuccess` in formatters/json.ts.
|
|
847
818
|
const gistHealth = getStateManager().getGistHealth();
|
|
848
819
|
if (gistHealth.degraded) {
|
|
849
|
-
recordWarning(warnings, 'gist-init', 'Gist persistence degraded', null,
|
|
820
|
+
recordWarning(warnings, 'gist-init', 'Gist persistence degraded', null, gistHealth.degraded.cause === 'unknown-mode'
|
|
821
|
+
? renderUnknownModeWarning(gistHealth.degraded.mode)
|
|
822
|
+
: renderGistWarning(gistHealth.degraded.cause));
|
|
850
823
|
}
|
|
851
824
|
// Surface Gist staleness up-front so consumers see it even if Phase 1 fails (#1193).
|
|
852
825
|
const staleness = getStateManager().getStateStaleness();
|
|
@@ -861,9 +834,14 @@ async function executeDailyCheckInternal(token) {
|
|
|
861
834
|
(loadRecovery.rejectedPath ? `; rejected file preserved at ${loadRecovery.rejectedPath}` : '')));
|
|
862
835
|
}
|
|
863
836
|
// Phase 1: Fetch all PR data from GitHub
|
|
864
|
-
const { prs, failures, mergedCounts,
|
|
837
|
+
const { prs, failures, mergedCounts, truncatedSearches, mergedTotalCount, closedTotalCount, closedCounts, searchedPRs, monthlyCounts, monthlyClosedCounts, openedFromMerged, openedFromClosed, recentlyClosedPRs, recentlyMergedPRs, recentlyMergedFetchFailed, commentedIssues, successorGaps, } = await fetchPRData(prMonitor, token, warnings);
|
|
865
838
|
// Phase 2: Update repo scores (signals, star counts, trust sync)
|
|
866
|
-
await updateRepoScores(prMonitor, prs, mergedCounts,
|
|
839
|
+
await updateRepoScores(prMonitor, prs, mergedCounts, truncatedSearches, closedCounts, searchedPRs, warnings);
|
|
840
|
+
// Merges and closes since each ledger's newest entry, fetched before Phase 3 adds to it (#1924, #1925).
|
|
841
|
+
const [mergedGap, closedGap] = await Promise.all([
|
|
842
|
+
fetchMergedLedgerGap(getOctokit(token), getStateManager(), warnings),
|
|
843
|
+
fetchClosedLedgerGap(getOctokit(token), getStateManager(), warnings, closedTotalCount),
|
|
844
|
+
]);
|
|
867
845
|
// Phase 3: Persist monthly analytics and store merged/closed PR history.
|
|
868
846
|
// try-catch: analytics are supplementary — save failure should not crash the daily check.
|
|
869
847
|
try {
|
|
@@ -886,28 +864,20 @@ async function executeDailyCheckInternal(token) {
|
|
|
886
864
|
// missing ledger fields in place), so overlaps are safe. openedAt comes
|
|
887
865
|
// free from the search result; firstMaintainerResponseAt is best-effort
|
|
888
866
|
// from the previous run's enriched digest — zero new API calls (#1461).
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
title: pr.title,
|
|
904
|
-
closedAt: pr.closedAt,
|
|
905
|
-
openedAt: pr.openedAt,
|
|
906
|
-
firstMaintainerResponseAt: firstMaintainerResponseFromDigest(previousDigest, pr.url),
|
|
907
|
-
issueUrl: pr.issueUrl,
|
|
908
|
-
...lastReviewStateFromDigest(previousDigest, pr.url),
|
|
909
|
-
})));
|
|
910
|
-
}
|
|
867
|
+
storeMergedLedger(getStateManager(), {
|
|
868
|
+
gap: mergedGap,
|
|
869
|
+
allTimeCount: mergedTotalCount,
|
|
870
|
+
recentlyMergedPRs,
|
|
871
|
+
previousDigest,
|
|
872
|
+
warnings,
|
|
873
|
+
});
|
|
874
|
+
storeClosedLedger(getStateManager(), {
|
|
875
|
+
gap: closedGap,
|
|
876
|
+
allTimeCount: closedTotalCount,
|
|
877
|
+
recentlyClosedPRs,
|
|
878
|
+
previousDigest,
|
|
879
|
+
warnings,
|
|
880
|
+
});
|
|
911
881
|
});
|
|
912
882
|
}
|
|
913
883
|
catch (error) {
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { type DashboardJsonData } from './dashboard-data.js';
|
|
11
11
|
import { type DailyDigest, type AgentState, type CommentedIssue, type MergedPR, type ClosedPR } from '../core/types.js';
|
|
12
|
+
/** Forget cached foreign-checkout verdicts so the next lookup re-runs Git. */
|
|
13
|
+
export declare function clearForeignVerdicts(): void;
|
|
12
14
|
/**
|
|
13
15
|
* Get the mtime of the vetted issue list file in ms, or null if unknown.
|
|
14
16
|
* Used to detect external edits and invalidate the cached dashboard payload.
|