@imdeadpool/guardex 8.4.20 → 8.4.22

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/README.md CHANGED
@@ -12,6 +12,16 @@ See the [project README](https://github.com/opencue/gitguardex#readme) for setup
12
12
  and workflows, and the [repository](https://github.com/opencue/gitguardex)
13
13
  for source and contributing information.
14
14
 
15
+ ## PR impact and risk
16
+
17
+ `gx pr-review` asks the selected review model for the magnitude of each benefit
18
+ or risk, with a reason and a changed-diff line. The strongest supported
19
+ benefit and risk set independent 1–100 scores, for example **Impact: 63/100 ·
20
+ Risk: 21/100**. A benefit cannot lower a risk score. The risk score describes
21
+ severity if it happens; the row reports the estimated likelihood separately.
22
+ Missing evidence is **not established**, not zero or a default 50. These
23
+ estimates are advisory, not measurements or merge verdicts.
24
+
15
25
  ## Agent handoffs
16
26
 
17
27
  - Request a contested file with `gx locks handoff-request -- <path>`. The owner
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imdeadpool/guardex",
3
- "version": "8.4.20",
3
+ "version": "8.4.22",
4
4
  "description": "Guardian T-Rex for your multi-agent repo. Isolated worktrees, file locks, and PR-only merges stop parallel Codex & Claude agents from overwriting each other's work. Auto-wires Oh My Codex, Oh My Claude, OpenSpec, and Caveman.",
5
5
  "license": "MIT",
6
6
  "preferGlobal": true,
@@ -65,5 +65,5 @@
65
65
  "prepublishOnly": "node scripts/prepublish-bump-version.js",
66
66
  "postinstall": "node -e \"require('./src/heavy').installReport()\""
67
67
  },
68
- "gitHead": "75e19acecbd80624b8dc0b0c0a5e2de1664847ed"
68
+ "gitHead": "2e8f574686bf363c2a9775db85f32f5e5410030e"
69
69
  }
@@ -1,11 +1,11 @@
1
1
  ---
2
2
  name: pr-impact-opportunities
3
- description: Find evidence-backed feature follow-ups that could move a GitGuardex PR toward the 80–100 impact band. Use with a PR diff or Code Assist impact review, not to rescore the current PR.
3
+ description: Find evidence-backed feature follow-ups that could materially improve a benefit or reduce a serious risk. Use with a PR diff or Code Assist impact review, not to rescore the current PR.
4
4
  ---
5
5
 
6
6
  # PR impact opportunities
7
7
 
8
- Suggest at most two changes that build specifically on the feature in this diff and could plausibly put a revised PR in the 80–100 impact band under the same rubric, if verified. Judge the likely impact of the revised behavior as a whole, not the number of ideas or lines added. Prioritize a material benefit on an important workflow or a meaningful reduction in an existing cost; a cosmetic change or generic test does not qualify.
8
+ Suggest at most two changes that build specifically on the feature in this diff. Judge the likely impact of the revised behavior as a whole, not the number of ideas or lines added. Prioritize a material benefit on an important workflow or a meaningful reduction in an existing risk; a cosmetic change or generic test does not qualify.
9
9
 
10
10
  For each opportunity, give:
11
11
 
@@ -14,4 +14,4 @@ For each opportunity, give:
14
14
  - `verify`: an observable pass condition, measurement, or comparison against the current behavior (up to 200 characters).
15
15
  - `evidence`: a real right-side diff line where the current feature supports the idea, as `{ "path": "...", "line": 1 }`.
16
16
 
17
- Do not repeat findings, trade-off fixes, or ordinary improvement ideas. Return an empty list if the visible diff cannot support a credible high-impact idea. The band is conditional: do not give individual score predictions, invent results, modify the current score, or treat the band as a merge requirement.
17
+ Do not repeat findings, trade-off fixes, or ordinary improvement ideas. Return an empty list if the visible diff cannot support a credible high-impact idea. Do not give score predictions, invent results, modify either current estimate, or treat the opportunities as merge requirements.
@@ -78,10 +78,10 @@ function openImpactHistory(repoRoot, pr, diff, env, startedAt = Date.now()) {
78
78
  if (!value) return;
79
79
  const items = [
80
80
  ...value.drivers
81
- .filter(({ points }) => points < 0)
81
+ .filter(({ impact }) => impact === 'trade-off')
82
82
  .map((driver, i) => ({
83
83
  id: `trade-off-${i + 1}`,
84
- label: `${driver.points} · ${driver.label}`,
84
+ label: `${driver.magnitude}/100 · ${driver.label}`,
85
85
  context: driver.reason,
86
86
  check: driver.doneWhen
87
87
  })),
@@ -10,8 +10,11 @@ const AREAS = {
10
10
  maintenance: 'Maintainability & developer experience'
11
11
  };
12
12
  const IMPACTS = { benefit: 'Benefit', 'trade-off': 'Trade-off', neutral: 'Neutral' };
13
- const WEIGHTS = { none: 0, limited: 5, notable: 10, material: 25, exceptional: 50 };
14
- const BASELINE = 50;
13
+ const LIKELIHOOD = {
14
+ plausible: 'Plausible',
15
+ likely: 'Likely',
16
+ demonstrated: 'Demonstrated in diff'
17
+ };
15
18
  const opportunitySkill = readFileSync(
16
19
  join(PACKAGE_ROOT, 'skills', 'pr-impact-opportunities', 'SKILL.md'),
17
20
  'utf8'
@@ -21,13 +24,14 @@ const opportunitySkill = readFileSync(
21
24
 
22
25
  const reviewValueInstructions = [
23
26
  'Also add an advisory top-level "value" alongside "findings", even for clean diffs.',
24
- 'Estimate the net repository impact of merging this diff as written vs. not merging, not finding count or diff size. Do not return a numeric score; GitGuardex calculates it from a 50 neutral baseline.',
25
- `"value":{"drivers":[{"area":"${Object.keys(AREAS).join('|')}","impact":"${Object.keys(IMPACTS).join('|')}","weight":"${Object.keys(WEIGHTS).join('|')}","label":"short name for the effect","reason":"what changed and who or what it affects","evidence":{"path":"new/file","line":12},"suggestedFix":null,"doneWhen":null}],"improvements":[],"opportunities":[{"idea":"feature change and benefit","pilot":"small first experiment","verify":"observable check","evidence":{"path":"new/file","line":12}}]}`,
26
- 'Use none (0) only for neutral, limited (5) for a localized change, notable (10) for a meaningful effect on one workflow, material (25) for a substantial effect on an important or widespread workflow, exceptional (50) only for clear repository-wide impact. Use the same anchors for benefits and costs.',
27
- 'Give 1–3 distinct drivers, each with a short descriptive "label" (up to 48 characters) naming the effect, not its category. Do not split one outcome across areas or cherry-pick benefits while omitting a visible cost. Cite a real right-side line from a diff hunk for each driver. Return "value":null if the visible evidence cannot support the evaluation.',
27
+ 'Compare merging this diff as written with leaving the base unchanged. Evaluate benefits and regression risks independently, not by finding count or diff size. Do not return overall scores.',
28
+ `"value":{"drivers":[{"area":"${Object.keys(AREAS).join('|')}","impact":"${Object.keys(IMPACTS).join('|')}","magnitude":37,"likelihood":null,"label":"short name for the effect","reason":"what changed and who or what it affects","evidence":{"path":"new/file","line":12},"suggestedFix":null,"doneWhen":null}],"improvements":[],"opportunities":[{"idea":"feature change and benefit","pilot":"small first experiment","verify":"observable check","evidence":{"path":"new/file","line":12}}]}`,
29
+ 'Estimate an integer magnitude from 1 to 100 for each supported benefit or trade-off. For a benefit, rate observable improvement and reach. For a trade-off, rate the severity if the problem occurs, factoring in who is affected and how hard it is to recover. Rough anchors (not fixed choices): 10 small or localized, 35 meaningful for one workflow, 65 substantial for an important workflow, 90+ exceptional improvement or widespread, hard-to-recover harm. Explain what justifies that magnitude in the reason.',
30
+ `For each trade-off also set "likelihood" to ${Object.keys(LIKELIHOOD).join(' | ')}: a concrete trigger may occur; normal use is expected to trigger it; or the changed code establishes the outcome, respectively. Include the trigger in the reason. Do not claim tests were run. Omit likelihood (or use null) on other rows. Use neutral with magnitude 0 only when a cited change preserves behavior; never infer neutral when evidence is missing.`,
31
+ 'Give 1–3 distinct drivers, each with a short descriptive "label" (up to 48 characters) naming the effect, not its category. Include the strongest supported benefit and strongest supported trade-off when both exist. Do not split one outcome across areas. Cite a real right-side line from a diff hunk for each driver. Omit unsupported effects; return "value":null if none can be evaluated.',
28
32
  'For each trade-off, give a "suggestedFix": a concrete change an agent can make to address the cited cost, and "doneWhen": an observable pass condition that demonstrates the fix worked. Include the scenario and expected result. Use null if the diff does not support a specific change or check. Omit both fields for benefits and neutral drivers.',
29
33
  'Use "improvements" for at most two additional changes tied to the diff, highest impact first. For each, state the action and how to verify it with a focused test, measurement, or observable check. Prefer a stronger demonstrated benefit or an unresolved cost. Return [] if no useful follow-up is supported. Omit generic advice, findings, and changes or checks already suggested on trade-off rows.',
30
- 'Use plain text, up to 200 characters per reason, suggested fix, acceptance condition, or improvement. Do not invent benchmark results, test passes, or adoption. Do not predict point gains or promise 100/100.',
34
+ 'Use plain text, up to 200 characters per reason, suggested fix, acceptance condition, or improvement. Do not invent benchmark results, test passes, or adoption. Do not predict point gains for follow-up ideas.',
31
35
  'For the "opportunities" list, follow this skill:',
32
36
  opportunitySkill
33
37
  ];
@@ -70,36 +74,43 @@ function normalizeOpportunities(opportunities, lineMap, advice) {
70
74
  function normalizeReviewValue(value, lineMap) {
71
75
  const { drivers, improvements, opportunities } = value ?? {};
72
76
  if (!Array.isArray(drivers) || drivers.length < 1 || drivers.length > 3) return null;
73
- const normalized = [];
74
- const cited = new Set();
75
- const reasons = new Set();
77
+ const candidates = [];
76
78
  for (const driver of drivers) {
77
- const { area, impact, weight, label, reason, evidence, suggestedFix, doneWhen } = driver ?? {};
78
- if (typeof area !== 'string' || !Object.hasOwn(AREAS, area)) return null;
79
- if (typeof impact !== 'string' || !Object.hasOwn(IMPACTS, impact)) return null;
80
- if (typeof weight !== 'string' || !Object.hasOwn(WEIGHTS, weight)) return null;
81
- if ((impact === 'neutral') !== (weight === 'none')) return null;
79
+ const { area, impact, magnitude, likelihood, label, reason, evidence, suggestedFix, doneWhen } =
80
+ driver ?? {};
81
+ if (typeof area !== 'string' || !Object.hasOwn(AREAS, area)) continue;
82
+ if (typeof impact !== 'string' || !Object.hasOwn(IMPACTS, impact)) continue;
83
+ if (!Number.isInteger(magnitude) || magnitude < 0 || magnitude > 100) continue;
84
+ if ((impact === 'neutral') !== (magnitude === 0)) continue;
85
+ const risk = impact === 'trade-off';
86
+ if (risk && (typeof likelihood !== 'string' || !Object.hasOwn(LIKELIHOOD, likelihood)))
87
+ continue;
82
88
  const clean = plainText(reason);
83
89
  const anchor = normalizeEvidence(evidence, lineMap);
84
- if (!clean || !anchor) return null;
85
- const key = JSON.stringify([impact, anchor.path, anchor.line]);
86
- const reasonKey = clean.toLowerCase();
87
- if (cited.has(key) || reasons.has(reasonKey)) return null;
88
- cited.add(key);
89
- reasons.add(reasonKey);
90
- const points = impact === 'trade-off' ? -WEIGHTS[weight] : WEIGHTS[weight];
91
- const fix = points < 0 ? plainText(suggestedFix) : '';
92
- normalized.push({
90
+ if (!clean || !anchor) continue;
91
+ candidates.push({
93
92
  area,
94
93
  impact,
95
94
  label: plainText(label, 48) || AREAS[area],
96
95
  reason: clean,
97
96
  evidence: anchor,
98
- points,
99
- suggestedFix: fix,
100
- doneWhen: points < 0 ? plainText(doneWhen) : ''
97
+ magnitude,
98
+ likelihood: risk ? likelihood : null,
99
+ suggestedFix: risk ? plainText(suggestedFix) : '',
100
+ doneWhen: risk ? plainText(doneWhen) : ''
101
101
  });
102
102
  }
103
+ const reasons = new Set();
104
+ const normalized = candidates
105
+ .sort((a, b) => b.magnitude - a.magnitude)
106
+ .filter((driver) => {
107
+ const { impact, reason } = driver;
108
+ const reasonKey = JSON.stringify([impact, reason.toLowerCase()]);
109
+ if (reasons.has(reasonKey)) return false;
110
+ reasons.add(reasonKey);
111
+ return true;
112
+ });
113
+ if (!normalized.length) return null;
103
114
  const actions = new Set();
104
115
  const priorAdvice = new Set(
105
116
  normalized.flatMap(({ suggestedFix, doneWhen }) => [
@@ -122,11 +133,10 @@ function normalizeReviewValue(value, lineMap) {
122
133
  if (actions.size === 2) break;
123
134
  }
124
135
  }
125
- const net = normalized.reduce((sum, driver) => sum + driver.points, BASELINE);
126
136
  for (const action of actions) priorAdvice.add(action.toLowerCase());
127
137
  return {
128
- score: Math.max(0, Math.min(100, net)),
129
- rawScore: net,
138
+ impactScore: normalized.find(({ impact }) => impact === 'benefit')?.magnitude ?? null,
139
+ riskScore: normalized.find(({ impact }) => impact === 'trade-off')?.magnitude ?? null,
130
140
  drivers: normalized,
131
141
  improvements: [...actions],
132
142
  opportunities: normalizeOpportunities(opportunities, lineMap, priorAdvice)
@@ -139,12 +149,15 @@ function escapeValueText(text) {
139
149
  }
140
150
 
141
151
  function scoreBar(score) {
142
- const filled = score / 5;
152
+ if (score === null) return 'Not established';
153
+ const filled = Math.max(1, Math.round(score / 5));
143
154
  return `${'█'.repeat(filled)}${'░'.repeat(20 - filled)} ${score}/100`;
144
155
  }
145
156
 
146
- function signedPoints(points) {
147
- return points > 0 ? `+${points}` : String(points);
157
+ function axisLabel(axis, score, noun) {
158
+ if (score === null) return `**${axis}: not established**`;
159
+ const level = score >= 85 ? 'Very high' : score >= 60 ? 'High' : score >= 30 ? 'Moderate' : 'Low';
160
+ return `**${axis}: ${score}/100** (${level} ${noun})`;
148
161
  }
149
162
 
150
163
  function evidenceLink(escapedLabel, { path, line }, reviewDiffPath) {
@@ -154,45 +167,25 @@ function evidenceLink(escapedLabel, { path, line }, reviewDiffPath) {
154
167
  }
155
168
 
156
169
  function reviewValueLines(value, truncated, reviewDiffPath) {
157
- if (truncated) return ['**PR value: unavailable** — diff is incomplete.'];
158
- if (!value) return ['**PR value: unavailable** — no supported estimate for this diff.'];
159
- const delta = value.score - BASELINE;
160
- const movement = delta
161
- ? `${delta > 0 ? '🟢' : '🟠'} **${signedPoints(delta)} vs. neutral**`
162
- : '⚪ **At neutral**';
163
- const steps = value.drivers
164
- .filter(({ points }) => points !== 0)
165
- .map(({ points, label, evidence }) => {
166
- const step = `**${signedPoints(points)}** ${escapeValueText(label)}`;
167
- return `${points > 0 ? '🟢' : '🟠'} ${evidenceLink(step, evidence, reviewDiffPath)}`;
168
- });
169
- const bound = value.rawScore === value.score ? '' : ` (bounded from ${value.rawScore})`;
170
- const priority = value.drivers
171
- .filter(({ suggestedFix, doneWhen }) => suggestedFix && doneWhen)
172
- .sort((a, b) => a.points - b.points)[0];
170
+ if (truncated) return ['**PR impact: unavailable** — diff is incomplete.'];
171
+ if (!value) return ['**PR impact: unavailable** — no supported estimate for this diff.'];
172
+ const { impactScore, riskScore } = value;
173
+ const priority = value.drivers.find(({ suggestedFix, doneWhen }) => suggestedFix && doneWhen);
173
174
  const sourceFor = (evidence) =>
174
175
  evidenceLink(escapeValueText(`${evidence.path}:${evidence.line}`), evidence, reviewDiffPath);
175
176
  return [
176
177
  '### PR impact',
177
178
  '',
178
- `**PR value: ${value.score}/100** · Neutral baseline **${BASELINE}** · ${movement}`,
179
+ `${axisLabel('Impact', impactScore, 'benefit')} · ${axisLabel('Risk', riskScore, 'severity')}`,
179
180
  '',
180
- '```text',
181
- `Neutral ${scoreBar(BASELINE)}`,
182
- `This PR ${scoreBar(value.score)}`,
183
- '```',
184
- '',
185
- ...(steps.length
186
- ? [
187
- `**Score breakdown:** **${BASELINE}** baseline → ${steps.join(' → ')} → **${value.score}/100**${bound}`,
188
- ''
189
- ]
181
+ ...(impactScore !== null || riskScore !== null
182
+ ? ['```text', `Impact ${scoreBar(impactScore)}`, `Risk ${scoreBar(riskScore)}`, '```', '']
190
183
  : []),
191
- 'Diff-only estimate, not a merge verdict. 100/100 is the scale ceiling, not a goal for every PR.',
184
+ 'AI estimates from diff evidence, not a merge verdict. The strongest supported benefit and risk set their own scores. Risk scores show severity if the issue occurs, not likelihood. “Not established” does not mean zero.',
192
185
  '',
193
186
  ...(priority
194
187
  ? [
195
- `> **Priority fix · ${priority.points}** — ${sourceFor(priority.evidence)}`,
188
+ `> **Priority fix · risk ${priority.magnitude}/100** — ${sourceFor(priority.evidence)}`,
196
189
  '>',
197
190
  `> **Change:** ${escapeValueText(priority.suggestedFix)}`,
198
191
  '>',
@@ -202,19 +195,29 @@ function reviewValueLines(value, truncated, reviewDiffPath) {
202
195
  ''
203
196
  ]
204
197
  : []),
205
- '| Impact | Points | Evidence and rationale |',
206
- '| :--- | ---: | :--- |',
198
+ '| Driver | Magnitude | Likelihood | Evidence and rationale |',
199
+ '| :--- | ---: | :--- | :--- |',
207
200
  ...value.drivers.map((driver) => {
208
- const { area, impact, reason, evidence, points, suggestedFix, doneWhen } = driver;
201
+ const {
202
+ area,
203
+ impact,
204
+ label,
205
+ reason,
206
+ evidence,
207
+ magnitude,
208
+ likelihood,
209
+ suggestedFix,
210
+ doneWhen
211
+ } = driver;
209
212
  let advice = '';
210
213
  if (driver === priority) advice = '<br>_See priority fix above._';
211
- else if (points < 0) {
214
+ else if (impact === 'trade-off') {
212
215
  advice = suggestedFix
213
216
  ? `<br>**Suggested fix:** ${escapeValueText(suggestedFix)}`
214
217
  : '<br>_No specific fix suggested._';
215
218
  if (doneWhen) advice += `<br>**Done when:** ${escapeValueText(doneWhen)}`;
216
219
  }
217
- return `| **${IMPACTS[impact]}** · ${AREAS[area]} | **${signedPoints(points)}** | ${escapeValueText(reason)} — ${sourceFor(evidence)}${advice} |`;
220
+ return `| **${IMPACTS[impact]}** · ${AREAS[area]} | ${magnitude ? `**${magnitude}/100**` : '—'} | ${LIKELIHOOD[likelihood] ?? '—'} | **${escapeValueText(label)}:** ${escapeValueText(reason)} — ${sourceFor(evidence)}${advice} |`;
218
221
  }),
219
222
  ...(value.improvements.length
220
223
  ? [
@@ -227,9 +230,9 @@ function reviewValueLines(value, truncated, reviewDiffPath) {
227
230
  ...(value.opportunities.length
228
231
  ? [
229
232
  '',
230
- '**High-impact opportunities · 80–100 potential**',
233
+ '**High-impact opportunities**',
231
234
  '',
232
- '_Conditional on verification; not included in this PR’s score._',
235
+ '_Conditional on verification; not included in either estimate._',
233
236
  '',
234
237
  ...value.opportunities.map(
235
238
  ({ idea, pilot, verify, evidence }, i) =>
@@ -3,7 +3,12 @@ const { parseDiffLineMap } = require('./diff');
3
3
  const SOURCE =
4
4
  'https://github.com/codexstar69/bug-hunter/blob/b412f9885e3ec074625a88c862c3f5b6724ec3b4/skills/hunter/SKILL.md';
5
5
  const MAX_FINDINGS = 8;
6
- const SEVERITIES = new Set(['low', 'medium', 'high', 'critical']);
6
+ const SEVERITIES = new Map([
7
+ ['low', '🔵 Low'],
8
+ ['medium', '🟡 Medium'],
9
+ ['high', '🟠 High'],
10
+ ['critical', '🔴 Critical']
11
+ ]);
7
12
 
8
13
  function bugHunterEnabled(env = process.env) {
9
14
  return /^(1|true|yes|on)$/i.test(String(env.GUARDEX_REVIEW_BUG_HUNTER || '').trim());
@@ -62,10 +67,25 @@ function bugHunterLines(result) {
62
67
  } else if (result.status === 'clean') {
63
68
  lines.push('No behavioral findings in the supplied diff.');
64
69
  }
65
- for (const finding of result.findings) {
70
+ const count = result.findings.length;
71
+ if (count > 0) {
72
+ if (result.status === 'partial') lines.push('');
73
+ lines.push(
74
+ `**${count} behavioral finding${count === 1 ? '' : 's'}** · Expand a finding for its evidence.`
75
+ );
76
+ }
77
+ for (const [index, finding] of result.findings.entries()) {
66
78
  const path = finding.path.length > 240 ? `…${finding.path.slice(-240)}` : finding.path;
79
+ const name = path.split('/').at(-1);
80
+ const shortName = name.length > 60 ? `…${name.slice(-60)}` : name;
67
81
  lines.push(
68
- `- **${finding.severity}** · ${escapedText(path)}:${finding.line} — ${escapedText(finding.message)}`
82
+ '',
83
+ index === 0 ? '<details open>' : '<details>',
84
+ `<summary><strong>${SEVERITIES.get(finding.severity)}</strong> · <code>${escapedText(shortName)}:${finding.line}</code></summary>`,
85
+ '',
86
+ `<p>${escapedText(finding.message)}</p>`,
87
+ `<p><strong>Location:</strong> <code>${escapedText(path)}:${finding.line}</code></p>`,
88
+ '</details>'
69
89
  );
70
90
  }
71
91
  lines.push('', `[Bug Hunter methodology](${SOURCE}) · Does not affect the merge gate.`);