nexus-agents 2.92.0 → 2.92.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.
@@ -8,7 +8,7 @@ import {
8
8
  checkSqlite,
9
9
  defaultConfig,
10
10
  initDataDirectories
11
- } from "./chunk-LOBVTRQQ.js";
11
+ } from "./chunk-ZNR3ZVC6.js";
12
12
  import {
13
13
  probeAllClis
14
14
  } from "./chunk-X5BQF6HM.js";
@@ -1987,4 +1987,4 @@ export {
1987
1987
  setupCommand,
1988
1988
  setupCommandAsync
1989
1989
  };
1990
- //# sourceMappingURL=chunk-VW2LBC7B.js.map
1990
+ //# sourceMappingURL=chunk-74AO4RKT.js.map
@@ -84,7 +84,7 @@ import {
84
84
  DEFAULT_TASK_TTL_MS,
85
85
  DEFAULT_TOOL_RATE_LIMITS,
86
86
  clampTaskTtl
87
- } from "./chunk-LOBVTRQQ.js";
87
+ } from "./chunk-ZNR3ZVC6.js";
88
88
  import {
89
89
  getAvailabilityCache,
90
90
  resolveFallback
@@ -51876,4 +51876,4 @@ export {
51876
51876
  detectBackend,
51877
51877
  createTaskTracker
51878
51878
  };
51879
- //# sourceMappingURL=chunk-HPV2D4HN.js.map
51879
+ //# sourceMappingURL=chunk-G3CYK3WA.js.map
@@ -3,19 +3,38 @@ import {
3
3
  DECISION_EMOJI,
4
4
  SEVERITY_EMOJI,
5
5
  SEVERITY_ORDER
6
- } from "./chunk-S4UF577T.js";
6
+ } from "./chunk-OK6U5N5Y.js";
7
7
  import {
8
8
  assessReputation,
9
+ gateWithReputation,
10
+ resolveReputationGatingMode,
9
11
  sanitizeInput
10
12
  } from "./chunk-NR4NSTJH.js";
13
+ import {
14
+ createLogger,
15
+ getTimeProvider
16
+ } from "./chunk-W5I6L4UT.js";
11
17
 
12
18
  // src/dogfooding/pr-reviewer-helpers.ts
13
19
  import { randomUUID } from "crypto";
14
- function assessPRReputation(pr, cache, enableReputation) {
20
+ var repLogger = createLogger({ component: "PRReviewer.reputation" });
21
+ async function fetchAccountAgeDays(provider, username) {
22
+ try {
23
+ const result = await provider.fetchUserMetadata(username);
24
+ if (!result.ok) return void 0;
25
+ const createdMs = Date.parse(result.value.createdAt);
26
+ if (!Number.isFinite(createdMs)) return void 0;
27
+ return Math.floor((getTimeProvider().now() - createdMs) / 864e5);
28
+ } catch {
29
+ return void 0;
30
+ }
31
+ }
32
+ function assessPRReputation(pr, cache, enableReputation, accountAgeDays) {
15
33
  if (!enableReputation) return void 0;
16
34
  const sanitizeResult = sanitizeInput(pr.body, "unknown", pr.author);
17
35
  const metadata = {
18
36
  username: pr.author,
37
+ ...accountAgeDays !== void 0 ? { accountAgeDays } : {},
19
38
  authorAssociation: pr.authorAssociation,
20
39
  injectionFlags: sanitizeResult.injectionFlags
21
40
  };
@@ -28,12 +47,34 @@ function buildPRTrustAssessment(trustResult, reputation, gateDecision) {
28
47
  userRole: trustResult.userRole,
29
48
  isAllowlisted: trustResult.isAllowlisted,
30
49
  reputationScore: reputation?.reputationScore,
50
+ suspiciousSignals: isTier1 ? [] : reputation?.suspiciousSignals ?? [],
31
51
  isSuspicious: isTier1 ? false : reputation?.isSuspicious ?? false,
32
52
  enforcedTrustTier: gateDecision.enforcedTier,
33
53
  reputationReconciledTier: gateDecision.reconciledTier,
34
54
  gatingMode: gateDecision.mode
35
55
  };
36
56
  }
57
+ function gatePRAuthor(pr, trustResult, accountAgeDays, cache, enableReputation) {
58
+ const reputation = assessPRReputation(pr, cache, enableReputation, accountAgeDays);
59
+ const gateDecision = gateWithReputation(
60
+ trustResult.trustTier,
61
+ reputation,
62
+ resolveReputationGatingMode()
63
+ );
64
+ if (gateDecision.demotionSuppressed) {
65
+ repLogger.warn("Reputation demotion suppressed by gating mode (would block under enforce)", {
66
+ prNumber: pr.number,
67
+ author: pr.author,
68
+ mode: gateDecision.mode,
69
+ classifierTier: trustResult.trustTier,
70
+ reconciledTier: gateDecision.reconciledTier
71
+ });
72
+ }
73
+ return {
74
+ gateDecision,
75
+ trustAssessment: buildPRTrustAssessment(trustResult, reputation, gateDecision)
76
+ };
77
+ }
37
78
  function parseSeverity(value) {
38
79
  if (typeof value === "string") {
39
80
  const lower = value.toLowerCase();
@@ -228,8 +269,10 @@ function createFailedReview(expertId, category, durationMs, error) {
228
269
  }
229
270
 
230
271
  export {
272
+ fetchAccountAgeDays,
231
273
  assessPRReputation,
232
274
  buildPRTrustAssessment,
275
+ gatePRAuthor,
233
276
  parseSeverity,
234
277
  parseCategory,
235
278
  extractSummary,
@@ -245,4 +288,4 @@ export {
245
288
  formatReviewComment,
246
289
  createFailedReview
247
290
  };
248
- //# sourceMappingURL=chunk-RS6RGSYG.js.map
291
+ //# sourceMappingURL=chunk-G5XKEUAP.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/dogfooding/pr-reviewer-helpers.ts"],"sourcesContent":["/**\n * nexus-agents/dogfooding - PR Reviewer Helpers\n *\n * Helper functions for PR review formatting and aggregation.\n *\n * @module dogfooding/pr-reviewer-helpers\n * (Source: Issue #161, Alignment Roadmap Phase 3)\n */\n\nimport { randomUUID } from 'node:crypto';\nimport type { Result } from '../core/index.js';\nimport { getTimeProvider, createLogger } from '../core/index.js';\nimport type { ScmUserMetadata } from '../scm/types.js';\nimport type {\n PRMetadata,\n PRReviewResult,\n PRTrustAssessment,\n ExpertReviewResult,\n ReviewFinding,\n ReviewCategory,\n ReviewSeverity,\n ReviewDecision,\n} from './pr-review-types.js';\nimport {\n SEVERITY_ORDER,\n CATEGORY_DISPLAY_NAMES,\n SEVERITY_EMOJI,\n DECISION_EMOJI,\n} from './pr-review-types.js';\nimport { sanitizeInput } from '../security/input-sanitizer.js';\nimport {\n assessReputation,\n gateWithReputation,\n resolveReputationGatingMode,\n} from '../security/reputation-model.js';\nimport type {\n ReputationCache,\n ReputationGateDecision,\n ReputationAssessment,\n GitHubUserMetadata,\n} from '../security/reputation-model.js';\nimport type { ClassifyResult } from '../security/trust-classifier.js';\n\nconst repLogger = createLogger({ component: 'PRReviewer.reputation' });\n\n// =============================================================================\n// Reputation Gating Helpers (#3123, epic #3118 Phase 5)\n// =============================================================================\n\n/**\n * Best-effort account-age lookup for a PR author (#3133, Phase-3 equivalent for\n * the PR path). Returns the author's real account age in days via the provider's\n * `fetchUserMetadata`, or `undefined` on any failure (err Result, unparseable\n * `createdAt`, or an unexpected rejection) — never fabricated, never throws, so\n * the review is never blocked by this lookup.\n */\nexport async function fetchAccountAgeDays(\n provider: { fetchUserMetadata: (u: string) => Promise<Result<ScmUserMetadata, Error>> },\n username: string\n): Promise<number | undefined> {\n try {\n const result = await provider.fetchUserMetadata(username);\n if (!result.ok) return undefined;\n const createdMs = Date.parse(result.value.createdAt);\n if (!Number.isFinite(createdMs)) return undefined;\n return Math.floor((getTimeProvider().now() - createdMs) / 86_400_000);\n } catch {\n return undefined;\n }\n}\n\n/**\n * Assesses the PR author's reputation from the signals available in the PR\n * event: author association + injection flags from the (sanitized) PR body, plus\n * the author's real account age when it was fetched (#3133). `accountAgeDays` is\n * OMITTED when the lookup failed — never fabricated, so the engine skips the\n * `new_account` signal. Returns undefined when reputation is disabled.\n */\nexport function assessPRReputation(\n pr: PRMetadata,\n cache: ReputationCache,\n enableReputation: boolean,\n accountAgeDays: number | undefined\n): ReputationAssessment | undefined {\n if (!enableReputation) return undefined;\n // Only `injectionFlags` is consumed here, and injection detection is\n // role-independent — the userRole arg ('unknown') and the sanitizer's own\n // trustTier output are intentionally irrelevant to this call.\n const sanitizeResult = sanitizeInput(pr.body, 'unknown', pr.author);\n const metadata: GitHubUserMetadata = {\n username: pr.author,\n ...(accountAgeDays !== undefined ? { accountAgeDays } : {}),\n authorAssociation: pr.authorAssociation,\n injectionFlags: sanitizeResult.injectionFlags,\n };\n return assessReputation(metadata, cache);\n}\n\n/** Builds the observability assessment surfaced on the review result (#3123). */\nexport function buildPRTrustAssessment(\n trustResult: ClassifyResult,\n reputation: ReputationAssessment | undefined,\n gateDecision: ReputationGateDecision\n): PRTrustAssessment {\n // Tier-1 (owner/allowlisted) authors cannot be suspicious.\n const isTier1 = trustResult.trustTier === '1';\n return {\n trustTier: trustResult.trustTier,\n userRole: trustResult.userRole,\n isAllowlisted: trustResult.isAllowlisted,\n reputationScore: reputation?.reputationScore,\n suspiciousSignals: isTier1 ? [] : (reputation?.suspiciousSignals ?? []),\n isSuspicious: isTier1 ? false : (reputation?.isSuspicious ?? false),\n enforcedTrustTier: gateDecision.enforcedTier,\n reputationReconciledTier: gateDecision.reconciledTier,\n gatingMode: gateDecision.mode,\n };\n}\n\n/**\n * Assesses the PR author's reputation and applies the gating rollout mode\n * (#3123). Returns the gate decision (for the policy gate) and the assessment\n * surfaced on the result. A suppressed demotion (audit/off) is logged.\n */\nexport function gatePRAuthor(\n pr: PRMetadata,\n trustResult: ClassifyResult,\n accountAgeDays: number | undefined,\n cache: ReputationCache,\n enableReputation: boolean\n): { gateDecision: ReputationGateDecision; trustAssessment: PRTrustAssessment } {\n const reputation = assessPRReputation(pr, cache, enableReputation, accountAgeDays);\n const gateDecision = gateWithReputation(\n trustResult.trustTier,\n reputation,\n resolveReputationGatingMode()\n );\n if (gateDecision.demotionSuppressed) {\n repLogger.warn('Reputation demotion suppressed by gating mode (would block under enforce)', {\n prNumber: pr.number,\n author: pr.author,\n mode: gateDecision.mode,\n classifierTier: trustResult.trustTier,\n reconciledTier: gateDecision.reconciledTier,\n });\n }\n return {\n gateDecision,\n trustAssessment: buildPRTrustAssessment(trustResult, reputation, gateDecision),\n };\n}\n\n// =============================================================================\n// Parsing Helpers\n// =============================================================================\n\nexport function parseSeverity(value: unknown): ReviewSeverity {\n if (typeof value === 'string') {\n const lower = value.toLowerCase();\n if (lower in SEVERITY_ORDER) return lower as ReviewSeverity;\n }\n return 'medium';\n}\n\nexport function parseCategory(value: unknown): ReviewCategory {\n if (typeof value === 'string') {\n const lower = value.toLowerCase();\n if (lower in CATEGORY_DISPLAY_NAMES) return lower as ReviewCategory;\n }\n return 'code_quality';\n}\n\nexport function extractSummary(output: Record<string, unknown>): string {\n if (typeof output.summary === 'string') return output.summary;\n if (typeof output.content === 'string') return output.content;\n if (typeof output.message === 'string') return output.message;\n return 'Review completed';\n}\n\nexport function extractStringField(\n record: Record<string, unknown>,\n ...keys: string[]\n): string | undefined {\n for (const key of keys) {\n const value = record[key];\n if (typeof value === 'string') return value;\n }\n return undefined;\n}\n\n// =============================================================================\n// Finding Parsing\n// =============================================================================\n\nexport function parseFindings(\n output: Record<string, unknown>,\n expertId: string,\n minSeverity: ReviewSeverity\n): ReviewFinding[] {\n const minOrder = SEVERITY_ORDER[minSeverity];\n const sources = collectSources(output);\n\n const findings: ReviewFinding[] = [];\n for (const source of sources) {\n if (!Array.isArray(source)) continue;\n for (const item of source) {\n const finding = parseOneFinding(item, expertId, minOrder);\n if (finding !== null) findings.push(finding);\n }\n }\n return findings;\n}\n\nfunction collectSources(output: Record<string, unknown>): unknown[] {\n return [\n output.findings,\n output.vulnerabilities,\n output.issues,\n (output as { content?: { findings?: unknown } }).content,\n ];\n}\n\nfunction parseOneFinding(item: unknown, expertId: string, minOrder: number): ReviewFinding | null {\n if (typeof item !== 'object' || item === null) return null;\n\n const record = item as Record<string, unknown>;\n const severity = parseSeverity(record.severity);\n if (SEVERITY_ORDER[severity] < minOrder) return null;\n\n return {\n id: randomUUID(),\n category: parseCategory(record.category),\n severity,\n title: extractStringField(record, 'title', 'name') ?? 'Finding',\n description: extractStringField(record, 'description', 'message') ?? '',\n file: typeof record.file === 'string' ? record.file : undefined,\n line: typeof record.line === 'number' ? record.line : undefined,\n suggestion: typeof record.suggestion === 'string' ? record.suggestion : undefined,\n expertId,\n confidence: typeof record.confidence === 'number' ? record.confidence : 0.7,\n };\n}\n\n// =============================================================================\n// Decision Helpers\n// =============================================================================\n\nexport function determineApproval(findings: ReviewFinding[]): boolean {\n const hasBlocking = findings.some((f) => f.severity === 'critical' || f.severity === 'high');\n return !hasBlocking;\n}\n\nexport function determineDecision(\n reviews: ExpertReviewResult[],\n findings: ReviewFinding[]\n): ReviewDecision {\n const hasCritical = findings.some((f) => f.severity === 'critical');\n const hasHigh = findings.some((f) => f.severity === 'high');\n const allApproved = reviews.every((r) => r.approved);\n\n if (hasCritical) return 'request_changes';\n if (hasHigh && !allApproved) return 'request_changes';\n if (findings.length > 0) return 'comment';\n return 'approve';\n}\n\nexport function calculateConsensus(reviews: ExpertReviewResult[]): number {\n if (reviews.length === 0) return 1;\n const approvals = reviews.filter((r) => r.approved).length;\n return approvals / reviews.length;\n}\n\n// =============================================================================\n// Counting Helpers\n// =============================================================================\n\nexport function countBySeverity(findings: ReviewFinding[]): Record<ReviewSeverity, number> {\n const counts: Record<ReviewSeverity, number> = {\n critical: 0,\n high: 0,\n medium: 0,\n low: 0,\n info: 0,\n };\n\n for (const f of findings) {\n counts[f.severity]++;\n }\n\n return counts;\n}\n\nexport function countByCategory(findings: ReviewFinding[]): Record<ReviewCategory, number> {\n const counts: Record<ReviewCategory, number> = {\n security: 0,\n performance: 0,\n code_quality: 0,\n testing: 0,\n documentation: 0,\n architecture: 0,\n };\n\n for (const f of findings) {\n counts[f.category]++;\n }\n\n return counts;\n}\n\nexport function sumFindings(counts: Record<ReviewSeverity, number>): number {\n return Object.values(counts).reduce((a, b) => a + b, 0);\n}\n\n// =============================================================================\n// Summary Generation\n// =============================================================================\n\nexport function generateSummary(\n pr: PRMetadata,\n reviews: ExpertReviewResult[],\n decision: ReviewDecision\n): string {\n const expertSummaries = reviews\n .map((r) => `- **${CATEGORY_DISPLAY_NAMES[r.expertType as ReviewCategory]}**: ${r.summary}`)\n .join('\\n');\n\n return `Reviewed PR #${String(pr.number)}: ${pr.title}\n\n**Decision:** ${decision.replaceAll('_', ' ')}\n**Experts consulted:** ${String(reviews.length)}\n\n${expertSummaries}`;\n}\n\n// =============================================================================\n// GitHub Comment Formatting\n// =============================================================================\n\n/**\n * Formats the review result as a GitHub comment.\n */\nexport function formatReviewComment(result: PRReviewResult): string {\n const emoji = DECISION_EMOJI[result.decision];\n const decisionText = result.decision.replaceAll('_', ' ').toUpperCase();\n\n const findingsSection = formatFindingsSection(result);\n const statsSection = formatStatsSection(result);\n\n return `## ${emoji} Nexus Agents Review: ${decisionText}\n\n${result.summary}\n\n${findingsSection}\n\n${statsSection}\n\n---\n*Reviewed by [nexus-agents](https://github.com/nexus-substrate/nexus-agents) in ${String(result.totalDurationMs)}ms*`;\n}\n\nfunction formatFindingsSection(result: PRReviewResult): string {\n const allFindings = result.expertReviews.flatMap((r) => r.findings);\n\n if (allFindings.length === 0) {\n return '_No issues found._';\n }\n\n const sorted = [...allFindings].sort(\n (a, b) => SEVERITY_ORDER[b.severity] - SEVERITY_ORDER[a.severity]\n );\n\n const lines = ['### Findings', ''];\n\n for (const f of sorted) {\n const emoji = SEVERITY_EMOJI[f.severity];\n const loc =\n f.file !== undefined\n ? ` (\\`${f.file}${f.line !== undefined ? `:${String(f.line)}` : ''}\\`)`\n : '';\n lines.push(`${emoji} **${f.title}**${loc}`);\n lines.push(`> ${f.description}`);\n if (f.suggestion !== undefined) {\n lines.push(`> 💡 ${f.suggestion}`);\n }\n lines.push('');\n }\n\n return lines.join('\\n');\n}\n\nfunction formatStatsSection(result: PRReviewResult): string {\n const { findingsBySeverity } = result;\n const total = sumFindings(findingsBySeverity);\n\n const parts: string[] = [];\n for (const severity of ['critical', 'high', 'medium', 'low', 'info'] as ReviewSeverity[]) {\n const count = findingsBySeverity[severity];\n if (count > 0) {\n parts.push(`${SEVERITY_EMOJI[severity]} ${String(count)} ${severity}`);\n }\n }\n\n return `<details>\n<summary>Review Statistics (${String(total)} findings)</summary>\n\n- Experts: ${String(result.expertCount)}\n- Consensus: ${(result.consensusScore * 100).toFixed(0)}%\n- Duration: ${String(result.totalDurationMs)}ms\n- Findings: ${parts.join(', ') || 'none'}\n\n</details>`;\n}\n\n// =============================================================================\n// Failed Review Factory\n// =============================================================================\n\nexport function createFailedReview(\n expertId: string,\n category: ReviewCategory,\n durationMs: number,\n error: string\n): ExpertReviewResult {\n return {\n expertId,\n expertType: category,\n approved: true, // Don't block on failures\n summary: `Review failed: ${error}`,\n findings: [],\n durationMs,\n confidence: 0,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AASA,SAAS,kBAAkB;AAkC3B,IAAM,YAAY,aAAa,EAAE,WAAW,wBAAwB,CAAC;AAarE,eAAsB,oBACpB,UACA,UAC6B;AAC7B,MAAI;AACF,UAAM,SAAS,MAAM,SAAS,kBAAkB,QAAQ;AACxD,QAAI,CAAC,OAAO,GAAI,QAAO;AACvB,UAAM,YAAY,KAAK,MAAM,OAAO,MAAM,SAAS;AACnD,QAAI,CAAC,OAAO,SAAS,SAAS,EAAG,QAAO;AACxC,WAAO,KAAK,OAAO,gBAAgB,EAAE,IAAI,IAAI,aAAa,KAAU;AAAA,EACtE,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AASO,SAAS,mBACd,IACA,OACA,kBACA,gBACkC;AAClC,MAAI,CAAC,iBAAkB,QAAO;AAI9B,QAAM,iBAAiB,cAAc,GAAG,MAAM,WAAW,GAAG,MAAM;AAClE,QAAM,WAA+B;AAAA,IACnC,UAAU,GAAG;AAAA,IACb,GAAI,mBAAmB,SAAY,EAAE,eAAe,IAAI,CAAC;AAAA,IACzD,mBAAmB,GAAG;AAAA,IACtB,gBAAgB,eAAe;AAAA,EACjC;AACA,SAAO,iBAAiB,UAAU,KAAK;AACzC;AAGO,SAAS,uBACd,aACA,YACA,cACmB;AAEnB,QAAM,UAAU,YAAY,cAAc;AAC1C,SAAO;AAAA,IACL,WAAW,YAAY;AAAA,IACvB,UAAU,YAAY;AAAA,IACtB,eAAe,YAAY;AAAA,IAC3B,iBAAiB,YAAY;AAAA,IAC7B,mBAAmB,UAAU,CAAC,IAAK,YAAY,qBAAqB,CAAC;AAAA,IACrE,cAAc,UAAU,QAAS,YAAY,gBAAgB;AAAA,IAC7D,mBAAmB,aAAa;AAAA,IAChC,0BAA0B,aAAa;AAAA,IACvC,YAAY,aAAa;AAAA,EAC3B;AACF;AA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AM,QAAQ,YAAY,kBAAkB;AAE5C,QAAM,QAAkB,CAAC;AACzB,aAAW,YAAY,CAAC,YAAY,QAAQ,UAAU,OAAO,MAAM,GAAuB;AACxF,UAAM,QAAQ,mBAAmB,QAAQ;AACzC,QAAI,QAAQ,GAAG;AACb,YAAM,KAAK,GAAG,eAAe,QAAQ,CAAC,IAAI,OAAO,KAAK,CAAC,IAAI,QAAQ,EAAE;AAAA,IACvE;AAAA,EACF;AAEA,SAAO;AAAA,8BACqB,OAAO,KAAK,CAAC;AAAA;AAAA,aAE9B,OAAO,OAAO,WAAW,CAAC;AAAA,gBACvB,OAAO,iBAAiB,KAAK,QAAQ,CAAC,CAAC;AAAA,cACzC,OAAO,OAAO,eAAe,CAAC;AAAA,cAC9B,MAAM,KAAK,IAAI,KAAK,MAAM;AAAA;AAAA;AAGxC;AAMO,SAAS,mBACd,UACA,UACA,YACA,OACoB;AACpB,SAAO;AAAA,IACL;AAAA,IACA,YAAY;AAAA,IACZ,UAAU;AAAA;AAAA,IACV,SAAS,kBAAkB,KAAK;AAAA,IAChC,UAAU,CAAC;AAAA,IACX;AAAA,IACA,YAAY;AAAA,EACd;AACF;","names":[]}
@@ -71,4 +71,4 @@ export {
71
71
  SEVERITY_EMOJI,
72
72
  DECISION_EMOJI
73
73
  };
74
- //# sourceMappingURL=chunk-S4UF577T.js.map
74
+ //# sourceMappingURL=chunk-OK6U5N5Y.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/dogfooding/pr-review-types.ts"],"sourcesContent":["/**\n * nexus-agents/dogfooding - PR Review Types\n *\n * Type definitions for automated pull request review using\n * multi-agent collaboration.\n *\n * @module dogfooding/pr-review-types\n * (Source: Issue #161, Alignment Roadmap Phase 3)\n */\n\nimport { z } from 'zod';\nimport type { FullCapableProvider } from '../scm/types.js';\n\n/**\n * Pull request file change information.\n */\nexport interface PRFileChange {\n /** File path */\n readonly filename: string;\n /** Change status */\n readonly status: 'added' | 'removed' | 'modified' | 'renamed' | 'copied';\n /** Number of additions */\n readonly additions: number;\n /** Number of deletions */\n readonly deletions: number;\n /** File patch/diff content */\n readonly patch?: string | undefined;\n /** Previous filename if renamed */\n readonly previousFilename?: string | undefined;\n}\n\n/**\n * Pull request metadata from GitHub API.\n */\nexport interface PRMetadata {\n /** PR number */\n readonly number: number;\n /** PR title */\n readonly title: string;\n /** PR description/body */\n readonly body: string;\n /** Author username */\n readonly author: string;\n /** GitHub API author_association (e.g., 'OWNER', 'COLLABORATOR', 'NONE') */\n readonly authorAssociation: string;\n /** Base branch */\n readonly base: string;\n /** Head branch */\n readonly head: string;\n /** Repository owner */\n readonly owner: string;\n /** Repository name */\n readonly repo: string;\n /** PR URL */\n readonly url: string;\n /** Whether PR is draft */\n readonly draft: boolean;\n /** PR labels */\n readonly labels: readonly string[];\n /** Changed files */\n readonly files: readonly PRFileChange[];\n /** Total additions */\n readonly additions: number;\n /** Total deletions */\n readonly deletions: number;\n /** Commit SHA of head */\n readonly headSha: string;\n}\n\n/**\n * Review severity levels.\n */\nexport type ReviewSeverity = 'critical' | 'high' | 'medium' | 'low' | 'info';\n\n/**\n * Review category for organizing findings.\n */\nexport type ReviewCategory =\n | 'security'\n | 'performance'\n | 'code_quality'\n | 'testing'\n | 'documentation'\n | 'architecture';\n\n/**\n * Individual review finding from an expert.\n */\nexport interface ReviewFinding {\n /** Unique finding ID */\n readonly id: string;\n /** Category of finding */\n readonly category: ReviewCategory;\n /** Severity level */\n readonly severity: ReviewSeverity;\n /** Finding title */\n readonly title: string;\n /** Detailed description */\n readonly description: string;\n /** Affected file (if applicable) */\n readonly file?: string | undefined;\n /** Line number (if applicable) */\n readonly line?: number | undefined;\n /** Suggested fix */\n readonly suggestion?: string | undefined;\n /** Expert that found this issue */\n readonly expertId: string;\n /** Confidence score (0-1) */\n readonly confidence: number;\n}\n\n/**\n * Review result from a single expert agent.\n */\nexport interface ExpertReviewResult {\n /** Expert ID */\n readonly expertId: string;\n /** Expert role/type */\n readonly expertType: string;\n /** Overall approval */\n readonly approved: boolean;\n /** Review summary */\n readonly summary: string;\n /** Individual findings */\n readonly findings: readonly ReviewFinding[];\n /** Execution time in ms */\n readonly durationMs: number;\n /** Confidence in review (0-1) */\n readonly confidence: number;\n}\n\n/**\n * Aggregated review decision after multi-agent debate.\n */\nexport type ReviewDecision = 'approve' | 'request_changes' | 'comment';\n\n/**\n * Complete PR review result from multi-agent collaboration.\n */\n/**\n * Trust + reputation assessment of the PR author, surfaced for observability\n * (#3123, epic #3118 Phase 5). Mirrors `issue_triage`'s assessment.\n */\nexport interface PRTrustAssessment {\n /** Classifier trust tier (1-4) from author association. */\n readonly trustTier: string;\n /** Author's GitHub role. */\n readonly userRole: string;\n /** Whether the author is on the maintainer allowlist. */\n readonly isAllowlisted: boolean;\n /** Reputation score (0-100) when reputation is enabled. */\n readonly reputationScore?: number | undefined;\n /** Suspicious signals detected (e.g. `new_account`, `injection_patterns_detected`). */\n readonly suspiciousSignals: readonly string[];\n /** Whether the author is flagged as suspicious. */\n readonly isSuspicious: boolean;\n /** Tier the policy gate ACTUALLY enforced (== trustTier under audit/off). */\n readonly enforcedTrustTier?: string | undefined;\n /** Tier reputation reconciliation computed — what enforce mode WOULD gate on. */\n readonly reputationReconciledTier?: string | undefined;\n /** Reputation-gating rollout mode applied: `off` | `audit` | `enforce`. */\n readonly gatingMode?: string | undefined;\n}\n\n/**\n * Result of fetching PR data plus best-effort author signals (#3133).\n */\nexport interface PRFetchData {\n readonly metadata: PRMetadata;\n readonly provider: FullCapableProvider;\n /** Author's real account age in days, when the lookup succeeded (#3133). */\n readonly accountAgeDays?: number;\n}\n\nexport interface PRReviewResult {\n /** Pull request number */\n readonly prNumber: number;\n /** Repository full name (owner/repo) */\n readonly repository: string;\n /** Overall decision */\n readonly decision: ReviewDecision;\n /** Executive summary */\n readonly summary: string;\n /** Individual expert reviews */\n readonly expertReviews: readonly ExpertReviewResult[];\n /** Aggregated findings by severity */\n readonly findingsBySeverity: Readonly<Record<ReviewSeverity, number>>;\n /** Aggregated findings by category */\n readonly findingsByCategory: Readonly<Record<ReviewCategory, number>>;\n /** Total execution time in ms */\n readonly totalDurationMs: number;\n /** Number of experts that participated */\n readonly expertCount: number;\n /** Consensus score (0-1) */\n readonly consensusScore: number;\n /** Debate rounds completed */\n readonly debateRounds: number;\n /** Timestamp of review */\n readonly timestamp: string;\n /** Author trust + reputation assessment (#3123). */\n readonly trustAssessment: PRTrustAssessment;\n}\n\n/**\n * Configuration for PR review.\n */\nexport interface PRReviewConfig {\n /** Experts to include in review */\n readonly experts: readonly ReviewCategory[];\n /** Maximum debate rounds */\n readonly maxDebateRounds: number;\n /** Consensus threshold (0-1) */\n readonly consensusThreshold: number;\n /** Minimum severity to report */\n readonly minSeverity: ReviewSeverity;\n /** Whether to post inline comments */\n readonly enableInlineComments: boolean;\n /** Whether to run in dry-run mode (no GitHub posting) */\n readonly dryRun: boolean;\n /** Whether to assess author reputation and gate on it (#3123). */\n readonly enableReputation: boolean;\n /** GitHub token for API access */\n readonly githubToken?: string | undefined;\n /** Model adapter configuration */\n readonly modelConfig?: {\n readonly temperature?: number;\n readonly maxTokens?: number;\n };\n}\n\n/**\n * Default PR review configuration.\n */\nexport const DEFAULT_PR_REVIEW_CONFIG: PRReviewConfig = {\n experts: ['security', 'code_quality', 'testing'],\n maxDebateRounds: 3,\n consensusThreshold: 0.7,\n minSeverity: 'low',\n enableInlineComments: true,\n dryRun: false,\n enableReputation: true,\n modelConfig: {\n temperature: 0.3,\n maxTokens: 8192,\n },\n};\n\n/**\n * Zod schema for PR review configuration.\n */\nexport const PRReviewConfigSchema = z.object({\n experts: z\n .array(\n z.enum([\n 'security',\n 'performance',\n 'code_quality',\n 'testing',\n 'documentation',\n 'architecture',\n ])\n )\n .default(['security', 'code_quality', 'testing']),\n maxDebateRounds: z.number().int().min(1).max(10).default(3),\n consensusThreshold: z.number().min(0).max(1).default(0.7),\n minSeverity: z.enum(['critical', 'high', 'medium', 'low', 'info']).default('low'),\n enableInlineComments: z.boolean().default(true),\n dryRun: z.boolean().default(false),\n enableReputation: z.boolean().default(true),\n githubToken: z.string().optional(),\n modelConfig: z\n .object({\n temperature: z.number().min(0).max(2).default(0.3),\n maxTokens: z.number().int().positive().default(8192),\n })\n .optional(),\n});\n\n/**\n * Severity order for comparison.\n */\nexport const SEVERITY_ORDER: Record<ReviewSeverity, number> = {\n critical: 5,\n high: 4,\n medium: 3,\n low: 2,\n info: 1,\n};\n\n/**\n * Category display names.\n */\nexport const CATEGORY_DISPLAY_NAMES: Record<ReviewCategory, string> = {\n security: 'Security',\n performance: 'Performance',\n code_quality: 'Code Quality',\n testing: 'Testing',\n documentation: 'Documentation',\n architecture: 'Architecture',\n};\n\n/**\n * Severity emoji for GitHub comments.\n */\nexport const SEVERITY_EMOJI: Record<ReviewSeverity, string> = {\n critical: ':rotating_light:',\n high: ':warning:',\n medium: ':yellow_circle:',\n low: ':large_blue_circle:',\n info: ':information_source:',\n};\n\n/**\n * Decision emoji for GitHub comments.\n */\nexport const DECISION_EMOJI: Record<ReviewDecision, string> = {\n approve: ':white_check_mark:',\n request_changes: ':x:',\n comment: ':speech_balloon:',\n};\n"],"mappings":";AAUA,SAAS,SAAS;AA+NX,IAAM,2BAA2C;AAAA,EACtD,SAAS,CAAC,YAAY,gBAAgB,SAAS;AAAA,EAC/C,iBAAiB;AAAA,EACjB,oBAAoB;AAAA,EACpB,aAAa;AAAA,EACb,sBAAsB;AAAA,EACtB,QAAQ;AAAA,EACR,kBAAkB;AAAA,EAClB,aAAa;AAAA,IACX,aAAa;AAAA,IACb,WAAW;AAAA,EACb;AACF;AAKO,IAAM,uBAAuB,EAAE,OAAO;AAAA,EAC3C,SAAS,EACN;AAAA,IACC,EAAE,KAAK;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH,EACC,QAAQ,CAAC,YAAY,gBAAgB,SAAS,CAAC;AAAA,EAClD,iBAAiB,EAAE,O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";
43
+ var VERSION = true ? "2.92.1" : "dev";
44
44
 
45
45
  // src/config/schemas-core.ts
46
46
  import { z } from "zod";
@@ -2096,7 +2096,7 @@ async function runDoctorFix(result) {
2096
2096
  writeLine2("\u2500".repeat(40));
2097
2097
  let fixCount = 0;
2098
2098
  if (!result.dataDirectory.rootExists || result.dataDirectory.subdirectories.some((d) => !d.exists || !d.writable)) {
2099
- const { runSetup } = await import("./setup-command-UN3XDJ2H.js");
2099
+ const { runSetup } = await import("./setup-command-AZAWBZOP.js");
2100
2100
  const setupResult = runSetup({
2101
2101
  skipMcp: true,
2102
2102
  skipRules: true,
@@ -2208,4 +2208,4 @@ export {
2208
2208
  startStdioServer,
2209
2209
  closeServer
2210
2210
  };
2211
- //# sourceMappingURL=chunk-LOBVTRQQ.js.map
2211
+ //# sourceMappingURL=chunk-ZNR3ZVC6.js.map
package/dist/cli.js CHANGED
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
- assessPRReputation,
4
- buildPRTrustAssessment,
5
3
  calculateConsensus,
6
4
  countByCategory,
7
5
  countBySeverity,
@@ -9,11 +7,13 @@ import {
9
7
  determineApproval,
10
8
  determineDecision,
11
9
  extractSummary,
10
+ fetchAccountAgeDays,
12
11
  formatReviewComment,
12
+ gatePRAuthor,
13
13
  generateSummary,
14
14
  parseFindings,
15
15
  sumFindings
16
- } from "./chunk-RS6RGSYG.js";
16
+ } from "./chunk-G5XKEUAP.js";
17
17
  import "./chunk-AQTHLUCP.js";
18
18
  import {
19
19
  buildOpenAICompatAdapters,
@@ -24,7 +24,7 @@ import {
24
24
  import {
25
25
  setupCommandAsync,
26
26
  verifyCommand
27
- } from "./chunk-VW2LBC7B.js";
27
+ } from "./chunk-74AO4RKT.js";
28
28
  import "./chunk-2SMTCNXP.js";
29
29
  import {
30
30
  AuthHandler,
@@ -164,14 +164,14 @@ import {
164
164
  validateCommand,
165
165
  validateWorkflow,
166
166
  wrapInMarkdownFence
167
- } from "./chunk-HPV2D4HN.js";
167
+ } from "./chunk-G3CYK3WA.js";
168
168
  import {
169
169
  resolveToken
170
170
  } from "./chunk-EAT4GTMT.js";
171
171
  import {
172
172
  CATEGORY_DISPLAY_NAMES,
173
173
  DEFAULT_PR_REVIEW_CONFIG
174
- } from "./chunk-S4UF577T.js";
174
+ } from "./chunk-OK6U5N5Y.js";
175
175
  import "./chunk-E6W4Z6GN.js";
176
176
  import "./chunk-3LKW4IEW.js";
177
177
  import {
@@ -212,8 +212,6 @@ import {
212
212
  import "./chunk-EFHZHCF2.js";
213
213
  import {
214
214
  ReputationCache,
215
- gateWithReputation,
216
- resolveReputationGatingMode,
217
215
  sanitizeInput
218
216
  } from "./chunk-NR4NSTJH.js";
219
217
  import "./chunk-57HMLBYN.js";
@@ -242,7 +240,7 @@ import {
242
240
  loadConfig,
243
241
  runDoctor,
244
242
  validateNexusEnv
245
- } from "./chunk-LOBVTRQQ.js";
243
+ } from "./chunk-ZNR3ZVC6.js";
246
244
  import "./chunk-SFZESA5O.js";
247
245
  import "./chunk-6Q33PBXC.js";
248
246
  import {
@@ -2866,7 +2864,7 @@ var PRReviewer = class {
2866
2864
  const { owner, repo, prNumber } = parseResult.value;
2867
2865
  const fetchResult = await this.fetchPRData(owner, repo, prNumber);
2868
2866
  if (!fetchResult.ok) return fetchResult;
2869
- const { metadata: prMetadata, provider } = fetchResult.value;
2867
+ const { metadata: prMetadata, provider, accountAgeDays } = fetchResult.value;
2870
2868
  const trustResult = this.classifyPRAuthor(prMetadata);
2871
2869
  logger2.info("PR author trust classified", {
2872
2870
  prNumber,
@@ -2875,7 +2873,13 @@ var PRReviewer = class {
2875
2873
  userRole: trustResult.userRole,
2876
2874
  isAllowlisted: trustResult.isAllowlisted
2877
2875
  });
2878
- const { gateDecision, trustAssessment } = this.gatePRAuthor(prMetadata, trustResult);
2876
+ const { gateDecision, trustAssessment } = gatePRAuthor(
2877
+ prMetadata,
2878
+ trustResult,
2879
+ accountAgeDays,
2880
+ this.reputationCache,
2881
+ this.config.enableReputation
2882
+ );
2879
2883
  const expertReviews = await this.runExpertReviews(prMetadata, traceId);
2880
2884
  const result = this.aggregateReviews(prMetadata, expertReviews, startTime, trustAssessment);
2881
2885
  if (!this.config.dryRun) {
@@ -2968,32 +2972,6 @@ var PRReviewer = class {
2968
2972
  authorAssociation: pr.authorAssociation
2969
2973
  });
2970
2974
  }
2971
- /**
2972
- * Assesses the PR author's reputation and applies the gating rollout mode
2973
- * (#3123). Returns the gate decision (for the policy gate) and the assessment
2974
- * surfaced on the result. A suppressed demotion (audit/off) is logged.
2975
- */
2976
- gatePRAuthor(pr, trustResult) {
2977
- const reputation = assessPRReputation(pr, this.reputationCache, this.config.enableReputation);
2978
- const gateDecision = gateWithReputation(
2979
- trustResult.trustTier,
2980
- reputation,
2981
- resolveReputationGatingMode()
2982
- );
2983
- if (gateDecision.demotionSuppressed) {
2984
- logger2.warn("Reputation demotion suppressed by gating mode (would block under enforce)", {
2985
- prNumber: pr.number,
2986
- author: pr.author,
2987
- mode: gateDecision.mode,
2988
- classifierTier: trustResult.trustTier,
2989
- reconciledTier: gateDecision.reconciledTier
2990
- });
2991
- }
2992
- return {
2993
- gateDecision,
2994
- trustAssessment: buildPRTrustAssessment(trustResult, reputation, gateDecision)
2995
- };
2996
- }
2997
2975
  /**
2998
2976
  * Sanitizes untrusted PR content (body/title) before embedding in expert tasks.
2999
2977
  * Uses the security/input-sanitizer pipeline to strip injection vectors.
@@ -3131,7 +3109,7 @@ ${file.patch}
3131
3109
  violations: policyResult.violations
3132
3110
  });
3133
3111
  }
3134
- const { formatReviewComment: formatReviewComment2 } = await import("./pr-reviewer-helpers-7D2W5HTO.js");
3112
+ const { formatReviewComment: formatReviewComment2 } = await import("./pr-reviewer-helpers-RBUEJI6V.js");
3135
3113
  const body = formatReviewComment2(result);
3136
3114
  const postResult = await provider.createReview(pr.prNumber, body, result.decision);
3137
3115
  if (!postResult.ok) {
@@ -3175,6 +3153,7 @@ ${file.patch}
3175
3153
  const detailResult = await provider.getPullRequestDetail(prNumber);
3176
3154
  if (!detailResult.ok) return err(detailResult.error);
3177
3155
  const detail = detailResult.value;
3156
+ const accountAgeDays = this.config.enableReputation ? await fetchAccountAgeDays(provider, detail.author) : void 0;
3178
3157
  const metadata = {
3179
3158
  number: detail.number,
3180
3159
  title: detail.title,
@@ -3200,7 +3179,11 @@ ${file.patch}
3200
3179
  additions: detail.additions,
3201
3180
  deletions: detail.deletions
3202
3181
  };
3203
- return ok({ metadata, provider });
3182
+ return ok({
3183
+ metadata,
3184
+ provider,
3185
+ ...accountAgeDays !== void 0 ? { accountAgeDays } : {}
3186
+ });
3204
3187
  }
3205
3188
  /**
3206
3189
  * Gets the SwarmObserver for debugging.