@oss-autopilot/core 3.19.0 → 3.19.1

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.
@@ -6,7 +6,7 @@ import * as fs from 'node:fs';
6
6
  import { adaptScoutLinkedPR, buildCandidateLinkedPR, createAutopilotScout } from './scout-bridge.js';
7
7
  import { runParseList, pruneIssueList } from './parse-list.js';
8
8
  import { detectIssueList } from './startup.js';
9
- import { computeSuccessGrade, gradeFromCandidate } from '../core/issue-grading.js';
9
+ import { computeSuccessGrade, gradeFromCandidate, reconcileRecommendation } from '../core/issue-grading.js';
10
10
  import { ValidationError } from '../core/errors.js';
11
11
  import { getStateManager, classifyLinkedPR, getOctokit, requireGitHubToken, parseGitHubUrl, verifyIssuesBatch, } from '../core/index.js';
12
12
  const UNKNOWN_GRADE = computeSuccessGrade({ avgResponseDays: null, mergeRate: null, daysSinceLastCommit: null });
@@ -220,7 +220,7 @@ export async function runVetList(options = {}) {
220
220
  url: candidate.issue.url,
221
221
  labels: candidate.issue.labels,
222
222
  },
223
- recommendation: candidate.recommendation,
223
+ recommendation: reconcileRecommendation(candidate.recommendation, grade),
224
224
  reasonsToApprove: candidate.reasonsToApprove,
225
225
  reasonsToSkip: candidate.reasonsToSkip,
226
226
  projectHealth: candidate.projectHealth,
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import { adaptScoutLinkedPR, buildCandidateLinkedPR, createAutopilotScout } from './scout-bridge.js';
6
6
  import { ISSUE_URL_PATTERN, validateGitHubUrl, validateUrl } from './validation.js';
7
- import { gradeFromCandidate } from '../core/issue-grading.js';
7
+ import { gradeFromCandidate, reconcileRecommendation } from '../core/issue-grading.js';
8
8
  import { getStateManager, classifyLinkedPR } from '../core/index.js';
9
9
  /**
10
10
  * Vet a specific GitHub issue for claimability and project health.
@@ -38,7 +38,7 @@ export async function runVet(options) {
38
38
  url: candidate.issue.url,
39
39
  labels: candidate.issue.labels,
40
40
  },
41
- recommendation: candidate.recommendation,
41
+ recommendation: reconcileRecommendation(candidate.recommendation, grade),
42
42
  reasonsToApprove: candidate.reasonsToApprove,
43
43
  reasonsToSkip: candidate.reasonsToSkip,
44
44
  projectHealth: candidate.projectHealth,
@@ -25,6 +25,29 @@ export interface GradeResult {
25
25
  /** Short human-readable explanation of what drove the score. */
26
26
  reason: string;
27
27
  }
28
+ /** Recommendation verdict, mirroring `@oss-scout/core`'s candidate field. */
29
+ export type IssueRecommendation = 'approve' | 'skip' | 'needs_review';
30
+ /**
31
+ * Grade bands are 10/7/4/1. At or above this an "approve" is trustworthy;
32
+ * below it (the bottom band, 1 — "unknown/worst") the grade and an "approve"
33
+ * contradict each other.
34
+ */
35
+ export declare const KEEP_GRADE_THRESHOLD = 4;
36
+ /**
37
+ * Reconcile a scout recommendation with the computed grade (#1575 defect 2).
38
+ * Scout derives "approve" from its own checks without consulting the grade, so
39
+ * an "approve" can coexist with a bottom-band grade. Downgrade such an
40
+ * "approve" to "needs_review" — never a hard skip — so the two signals a caller
41
+ * sees can't flatly contradict. Any non-approve recommendation is returned
42
+ * unchanged.
43
+ *
44
+ * Apply this ONLY where the grade is high-fidelity — i.e. computed from freshly
45
+ * fetched health (the `vet` / `vet-list` surfaces). The `search` and `features`
46
+ * surfaces pass a `checkFailed` health sentinel and grade from history alone, so
47
+ * any repo we lack history with scores the bottom band for missing data, not for
48
+ * being bad; reconciling there would wrongly downgrade well-vetted candidates.
49
+ */
50
+ export declare function reconcileRecommendation(recommendation: IssueRecommendation, grade: GradeResult): IssueRecommendation;
28
51
  /**
29
52
  * Build `GradeSignals` from a vet candidate's project health plus the
30
53
  * optional autopilot-tracked repo score.
@@ -47,6 +70,14 @@ export declare function deriveGradeSignals(params: {
47
70
  projectHealth: {
48
71
  avgIssueResponseDays: number | null;
49
72
  daysSinceLastCommit: number | null;
73
+ /**
74
+ * Repo-intrinsic recent merge rate from `@oss-scout/core`'s
75
+ * `projectHealth.recentMergeRate` (repo-wide merged / closed over 90 days).
76
+ * Preferred over the relationship-derived rate so a healthy repo we've never
77
+ * contributed to grades on its own merits instead of collapsing to F (#248).
78
+ * Absent (undefined/null) until the scout release that supplies it.
79
+ */
80
+ recentMergeRate?: number | null;
50
81
  checkFailed?: boolean;
51
82
  };
52
83
  repoScore: {
@@ -10,6 +10,29 @@
10
10
  * (missing data is treated as a risk, not ignored). This matches the policy
11
11
  * previously described as prose in agents/issue-scout.md.
12
12
  */
13
+ /**
14
+ * Grade bands are 10/7/4/1. At or above this an "approve" is trustworthy;
15
+ * below it (the bottom band, 1 — "unknown/worst") the grade and an "approve"
16
+ * contradict each other.
17
+ */
18
+ export const KEEP_GRADE_THRESHOLD = 4;
19
+ /**
20
+ * Reconcile a scout recommendation with the computed grade (#1575 defect 2).
21
+ * Scout derives "approve" from its own checks without consulting the grade, so
22
+ * an "approve" can coexist with a bottom-band grade. Downgrade such an
23
+ * "approve" to "needs_review" — never a hard skip — so the two signals a caller
24
+ * sees can't flatly contradict. Any non-approve recommendation is returned
25
+ * unchanged.
26
+ *
27
+ * Apply this ONLY where the grade is high-fidelity — i.e. computed from freshly
28
+ * fetched health (the `vet` / `vet-list` surfaces). The `search` and `features`
29
+ * surfaces pass a `checkFailed` health sentinel and grade from history alone, so
30
+ * any repo we lack history with scores the bottom band for missing data, not for
31
+ * being bad; reconciling there would wrongly downgrade well-vetted candidates.
32
+ */
33
+ export function reconcileRecommendation(recommendation, grade) {
34
+ return recommendation === 'approve' && grade.score < KEEP_GRADE_THRESHOLD ? 'needs_review' : recommendation;
35
+ }
13
36
  // Band values, best→worst. A signal always resolves to one of these, so
14
37
  // degradeOneStep can step down the ladder by index.
15
38
  const BANDS = [10, 7, 4, 1];
@@ -90,8 +113,11 @@ export function deriveGradeSignals(params) {
90
113
  const daysSinceLastCommit = healthTrusted
91
114
  ? sanitize(projectHealth.daysSinceLastCommit, 0, Number.MAX_SAFE_INTEGER)
92
115
  : null;
93
- let mergeRate = null;
94
- if (repoScore) {
116
+ // Prefer scout's repo-intrinsic merge rate (#248); fall back to the
117
+ // relationship-derived rate (our own merged/closed counts) when scout didn't
118
+ // supply one, preserving prior behavior for repos with contribution history.
119
+ let mergeRate = healthTrusted ? sanitize(projectHealth.recentMergeRate, 0, 1) : null;
120
+ if (mergeRate === null && repoScore) {
95
121
  const merged = sanitize(repoScore.mergedPRCount, 0, Number.MAX_SAFE_INTEGER);
96
122
  const closed = sanitize(repoScore.closedWithoutMergeCount, 0, Number.MAX_SAFE_INTEGER);
97
123
  if (merged !== null && closed !== null) {
@@ -126,6 +152,10 @@ export function gradeFromCandidate(params) {
126
152
  : {
127
153
  avgIssueResponseDays: ph.avgIssueResponseDays,
128
154
  daysSinceLastCommit: ph.daysSinceLastCommit,
155
+ // Repo-intrinsic recent merge rate (#248). Absent → null →
156
+ // deriveGradeSignals falls back to the relationship-derived rate,
157
+ // preserving prior behavior for repos with contribution history.
158
+ recentMergeRate: ph.recentMergeRate ?? null,
129
159
  checkFailed: false,
130
160
  };
131
161
  return computeSuccessGrade(deriveGradeSignals({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oss-autopilot/core",
3
- "version": "3.19.0",
3
+ "version": "3.19.1",
4
4
  "description": "CLI and core library for managing open source contributions",
5
5
  "type": "module",
6
6
  "bin": {
@@ -55,7 +55,7 @@
55
55
  "@octokit/plugin-retry": "^8.1.0",
56
56
  "@octokit/plugin-throttling": "^11.0.3",
57
57
  "@octokit/rest": "^22.0.1",
58
- "@oss-scout/core": "^1.3.0",
58
+ "@oss-scout/core": "^1.5.0",
59
59
  "commander": "^15.0.0",
60
60
  "zod": "^4.4.3"
61
61
  },