@nerviq/cli 1.8.5 → 1.8.7

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.
@@ -1,286 +1,286 @@
1
- /**
2
- * OpenCode Repeat-Usage Surfaces — 6 repeat-usage surfaces
3
- *
4
- * Adapts the shared activity/snapshot backend for OpenCode platform.
5
- * Provides: history, compare, trend, watch, feedback, insights.
6
- *
7
- * OpenCode snapshots are stored alongside Claude snapshots in
8
- * .nerviq/snapshots/ (legacy: .claude/claudex-setup/snapshots/) but filtered by platform='opencode'.
9
- */
10
-
11
- const path = require('path');
12
- const {
13
- readSnapshotIndex,
14
- writeSnapshotArtifact,
15
- exportTrendReport: sharedExportTrendReport,
16
- recordRecommendationOutcome,
17
- readOutcomeIndex,
18
- summarizeOutcomeEntries,
19
- } = require('../activity');
20
- const { version } = require('../../package.json');
21
-
22
- // --- History ---
23
-
24
- function getOpenCodeHistory(dir, limit = 20) {
25
- const entries = readSnapshotIndex(dir);
26
- return entries
27
- .filter(e => e.snapshotKind === 'audit' && (e.platform === 'opencode' || e.summary?.platform === 'opencode'))
28
- .sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt))
29
- .slice(0, limit);
30
- }
31
-
32
- function formatOpenCodeHistory(dir) {
33
- const history = getOpenCodeHistory(dir, 10);
34
- if (history.length === 0) {
35
- return 'No OpenCode snapshots found. Run `npx nerviq --platform opencode --snapshot` to save one.';
36
- }
37
-
38
- const lines = ['OpenCode Score History (most recent first):', ''];
39
- for (const entry of history) {
40
- const date = entry.createdAt?.split('T')[0] || 'unknown';
41
- const score = entry.summary?.score ?? '?';
42
- const passed = entry.summary?.passed ?? '?';
43
- const total = entry.summary?.checkCount ?? '?';
44
- lines.push(` ${date} ${score}/100 (${passed}/${total} passing)`);
45
- }
46
-
47
- const comparison = compareOpenCodeLatest(dir);
48
- if (comparison) {
49
- lines.push('');
50
- const sign = comparison.delta.score >= 0 ? '+' : '';
51
- lines.push(` Trend: ${comparison.trend} (${sign}${comparison.delta.score} since previous)`);
52
- if (comparison.improvements.length > 0) lines.push(` Fixed: ${comparison.improvements.join(', ')}`);
53
- if (comparison.regressions.length > 0) lines.push(` New gaps: ${comparison.regressions.join(', ')}`);
54
- }
55
-
56
- return lines.join('\n');
57
- }
58
-
59
- // --- Compare ---
60
-
61
- function compareOpenCodeLatest(dir) {
62
- const audits = getOpenCodeHistory(dir, 2);
63
- if (audits.length < 2) return null;
64
-
65
- const current = audits[0];
66
- const previous = audits[1];
67
-
68
- const delta = {
69
- score: (current.summary?.score || 0) - (previous.summary?.score || 0),
70
- organic: (current.summary?.organicScore || 0) - (previous.summary?.organicScore || 0),
71
- passed: (current.summary?.passed || 0) - (previous.summary?.passed || 0),
72
- };
73
-
74
- const regressions = [];
75
- const improvements = [];
76
- const prevKeys = new Set(previous.summary?.topActionKeys || []);
77
- const currKeys = new Set(current.summary?.topActionKeys || []);
78
- for (const key of currKeys) { if (!prevKeys.has(key)) regressions.push(key); }
79
- for (const key of prevKeys) { if (!currKeys.has(key)) improvements.push(key); }
80
-
81
- return {
82
- platform: 'opencode',
83
- current: { date: current.createdAt, score: current.summary?.score, passed: current.summary?.passed },
84
- previous: { date: previous.createdAt, score: previous.summary?.score, passed: previous.summary?.passed },
85
- delta,
86
- regressions,
87
- improvements,
88
- trend: delta.score > 0 ? 'improving' : delta.score < 0 ? 'regressing' : 'stable',
89
- };
90
- }
91
-
92
- // --- Trend ---
93
-
94
- function exportOpenCodeTrendReport(dir) {
95
- const history = getOpenCodeHistory(dir, 50);
96
- if (history.length === 0) return null;
97
-
98
- const comparison = compareOpenCodeLatest(dir);
99
- const lines = [
100
- '# OpenCode Setup Trend Report',
101
- '',
102
- `**Project:** ${path.basename(dir)}`,
103
- '**Platform:** OpenCode',
104
- `**Generated:** ${new Date().toISOString().split('T')[0]}`,
105
- `**Snapshots:** ${history.length}`,
106
- '',
107
- '## Score History',
108
- '',
109
- '| Date | Score | Passed | Checks |',
110
- '|------|-------|--------|--------|',
111
- ];
112
-
113
- for (const entry of history) {
114
- const date = entry.createdAt?.split('T')[0] || '?';
115
- lines.push(`| ${date} | ${entry.summary?.score ?? '?'}/100 | ${entry.summary?.passed ?? '?'} | ${entry.summary?.checkCount ?? '?'} |`);
116
- }
117
-
118
- if (comparison) {
119
- lines.push('');
120
- lines.push('## Latest Comparison');
121
- lines.push('');
122
- lines.push(`- **Previous:** ${comparison.previous.score}/100 (${comparison.previous.date?.split('T')[0]})`);
123
- lines.push(`- **Current:** ${comparison.current.score}/100 (${comparison.current.date?.split('T')[0]})`);
124
- lines.push(`- **Delta:** ${comparison.delta.score >= 0 ? '+' : ''}${comparison.delta.score} points`);
125
- lines.push(`- **Trend:** ${comparison.trend}`);
126
- if (comparison.improvements.length > 0) lines.push(`- **Fixed:** ${comparison.improvements.join(', ')}`);
127
- if (comparison.regressions.length > 0) lines.push(`- **New gaps:** ${comparison.regressions.join(', ')}`);
128
- }
129
-
130
- if (history.length >= 3) {
131
- lines.push('');
132
- lines.push('## Trend Chart');
133
- lines.push('');
134
- lines.push('```');
135
- const scores = history.slice().reverse().map(e => e.summary?.score ?? 0);
136
- const max = Math.max(...scores, 100);
137
- const chartHeight = 10;
138
- for (let row = chartHeight; row >= 0; row--) {
139
- const threshold = (row / chartHeight) * max;
140
- const rowLabel = String(Math.round(threshold)).padStart(3);
141
- const bar = scores.map(s => s >= threshold ? '#' : ' ').join('');
142
- lines.push(`${rowLabel} |${bar}`);
143
- }
144
- lines.push(` +${'─'.repeat(scores.length)}`);
145
- lines.push('```');
146
- }
147
-
148
- lines.push('');
149
- lines.push('---');
150
- lines.push(`*Generated by nerviq v${version} for OpenCode*`);
151
- return lines.join('\n');
152
- }
153
-
154
- // --- Feedback ---
155
-
156
- function recordOpenCodeFeedback(dir, payload) {
157
- return recordRecommendationOutcome(dir, {
158
- ...payload,
159
- source: payload.source || 'opencode-cli',
160
- platform: 'opencode',
161
- });
162
- }
163
-
164
- function getOpenCodeFeedbackSummary(dir) {
165
- const entries = readOutcomeIndex(dir)
166
- .filter(e => e.source === 'opencode-cli' || e.platform === 'opencode');
167
- return summarizeOutcomeEntries(entries);
168
- }
169
-
170
- function formatOpenCodeFeedback(dir) {
171
- const summary = getOpenCodeFeedbackSummary(dir);
172
- if (!summary || Object.keys(summary).length === 0) {
173
- return 'No OpenCode feedback recorded yet.';
174
- }
175
-
176
- const lines = ['OpenCode Recommendation Feedback:', ''];
177
- const entries = Array.isArray(summary) ? summary : Object.values(summary);
178
- for (const entry of entries) {
179
- const key = entry.key || 'unknown';
180
- const accepted = entry.accepted || 0;
181
- const rejected = entry.rejected || 0;
182
- const total = entry.total || 0;
183
- lines.push(` ${key}: ${accepted} accepted, ${rejected} rejected (${total} total)`);
184
- }
185
- return lines.join('\n');
186
- }
187
-
188
- // --- Insights ---
189
-
190
- function generateOpenCodeInsights(dir) {
191
- const history = getOpenCodeHistory(dir, 50);
192
- const feedback = getOpenCodeFeedbackSummary(dir);
193
- const insights = [];
194
-
195
- if (history.length >= 3) {
196
- const recentFailKeys = new Map();
197
- for (const entry of history.slice(0, 5)) {
198
- for (const key of (entry.summary?.topActionKeys || [])) {
199
- recentFailKeys.set(key, (recentFailKeys.get(key) || 0) + 1);
200
- }
201
- }
202
- for (const [key, count] of recentFailKeys) {
203
- if (count >= 3) {
204
- insights.push({
205
- type: 'persistent-failure',
206
- severity: 'high',
207
- key,
208
- message: `Check ${key} has failed in ${count} of the last ${Math.min(history.length, 5)} audits.`,
209
- });
210
- }
211
- }
212
- }
213
-
214
- if (history.length >= 2) {
215
- const scores = history.map(e => e.summary?.score ?? 0);
216
- if (scores[0] < scores[1]) {
217
- insights.push({
218
- type: 'regression-pattern',
219
- severity: 'medium',
220
- message: `Score dropped from ${scores[1]} to ${scores[0]} in the most recent audit.`,
221
- delta: scores[0] - scores[1],
222
- });
223
- }
224
- }
225
-
226
- if (history.length >= 5) {
227
- const recentScores = history.slice(0, 5).map(e => e.summary?.score ?? 0);
228
- const range = Math.max(...recentScores) - Math.min(...recentScores);
229
- if (range <= 2) {
230
- insights.push({
231
- type: 'velocity-stall',
232
- severity: 'low',
233
- message: `Score has been flat (range: ${range} points) over the last 5 audits.`,
234
- });
235
- }
236
- }
237
-
238
- const feedbackEntries = Array.isArray(feedback) ? feedback : Object.values(feedback || {});
239
- for (const entry of feedbackEntries) {
240
- if (entry.rejected > entry.accepted && entry.total >= 2) {
241
- insights.push({
242
- type: 'feedback-signal',
243
- severity: 'medium',
244
- key: entry.key,
245
- message: `Recommendation ${entry.key} has been rejected more than accepted (${entry.rejected}/${entry.total}).`,
246
- });
247
- }
248
- }
249
-
250
- return {
251
- platform: 'opencode',
252
- generatedAt: new Date().toISOString(),
253
- snapshotCount: history.length,
254
- feedbackCount: feedbackEntries.length,
255
- insights,
256
- summary: insights.length === 0
257
- ? 'No actionable insights detected. Keep running audits to build pattern data.'
258
- : `${insights.length} insight(s) detected across ${history.length} snapshots.`,
259
- };
260
- }
261
-
262
- function formatOpenCodeInsights(dir) {
263
- const result = generateOpenCodeInsights(dir);
264
- if (result.insights.length === 0) return result.summary;
265
-
266
- const lines = ['OpenCode Insights:', ''];
267
- for (const insight of result.insights) {
268
- const severity = insight.severity.toUpperCase();
269
- lines.push(` [${severity}] ${insight.message}`);
270
- }
271
- lines.push('');
272
- lines.push(result.summary);
273
- return lines.join('\n');
274
- }
275
-
276
- module.exports = {
277
- getOpenCodeHistory,
278
- formatOpenCodeHistory,
279
- compareOpenCodeLatest,
280
- exportOpenCodeTrendReport,
281
- recordOpenCodeFeedback,
282
- getOpenCodeFeedbackSummary,
283
- formatOpenCodeFeedback,
284
- generateOpenCodeInsights,
285
- formatOpenCodeInsights,
286
- };
1
+ /**
2
+ * OpenCode Repeat-Usage Surfaces — 6 repeat-usage surfaces
3
+ *
4
+ * Adapts the shared activity/snapshot backend for OpenCode platform.
5
+ * Provides: history, compare, trend, watch, feedback, insights.
6
+ *
7
+ * OpenCode snapshots are stored alongside Claude snapshots in
8
+ * .nerviq/snapshots/ (legacy: .claude/nerviq-cli/snapshots/) but filtered by platform='opencode'.
9
+ */
10
+
11
+ const path = require('path');
12
+ const {
13
+ readSnapshotIndex,
14
+ writeSnapshotArtifact,
15
+ exportTrendReport: sharedExportTrendReport,
16
+ recordRecommendationOutcome,
17
+ readOutcomeIndex,
18
+ summarizeOutcomeEntries,
19
+ } = require('../activity');
20
+ const { version } = require('../../package.json');
21
+
22
+ // --- History ---
23
+
24
+ function getOpenCodeHistory(dir, limit = 20) {
25
+ const entries = readSnapshotIndex(dir);
26
+ return entries
27
+ .filter(e => e.snapshotKind === 'audit' && (e.platform === 'opencode' || e.summary?.platform === 'opencode'))
28
+ .sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt))
29
+ .slice(0, limit);
30
+ }
31
+
32
+ function formatOpenCodeHistory(dir) {
33
+ const history = getOpenCodeHistory(dir, 10);
34
+ if (history.length === 0) {
35
+ return 'No OpenCode snapshots found. Run `npx nerviq --platform opencode --snapshot` to save one.';
36
+ }
37
+
38
+ const lines = ['OpenCode Score History (most recent first):', ''];
39
+ for (const entry of history) {
40
+ const date = entry.createdAt?.split('T')[0] || 'unknown';
41
+ const score = entry.summary?.score ?? '?';
42
+ const passed = entry.summary?.passed ?? '?';
43
+ const total = entry.summary?.checkCount ?? '?';
44
+ lines.push(` ${date} ${score}/100 (${passed}/${total} passing)`);
45
+ }
46
+
47
+ const comparison = compareOpenCodeLatest(dir);
48
+ if (comparison) {
49
+ lines.push('');
50
+ const sign = comparison.delta.score >= 0 ? '+' : '';
51
+ lines.push(` Trend: ${comparison.trend} (${sign}${comparison.delta.score} since previous)`);
52
+ if (comparison.improvements.length > 0) lines.push(` Fixed: ${comparison.improvements.join(', ')}`);
53
+ if (comparison.regressions.length > 0) lines.push(` New gaps: ${comparison.regressions.join(', ')}`);
54
+ }
55
+
56
+ return lines.join('\n');
57
+ }
58
+
59
+ // --- Compare ---
60
+
61
+ function compareOpenCodeLatest(dir) {
62
+ const audits = getOpenCodeHistory(dir, 2);
63
+ if (audits.length < 2) return null;
64
+
65
+ const current = audits[0];
66
+ const previous = audits[1];
67
+
68
+ const delta = {
69
+ score: (current.summary?.score || 0) - (previous.summary?.score || 0),
70
+ organic: (current.summary?.organicScore || 0) - (previous.summary?.organicScore || 0),
71
+ passed: (current.summary?.passed || 0) - (previous.summary?.passed || 0),
72
+ };
73
+
74
+ const regressions = [];
75
+ const improvements = [];
76
+ const prevKeys = new Set(previous.summary?.topActionKeys || []);
77
+ const currKeys = new Set(current.summary?.topActionKeys || []);
78
+ for (const key of currKeys) { if (!prevKeys.has(key)) regressions.push(key); }
79
+ for (const key of prevKeys) { if (!currKeys.has(key)) improvements.push(key); }
80
+
81
+ return {
82
+ platform: 'opencode',
83
+ current: { date: current.createdAt, score: current.summary?.score, passed: current.summary?.passed },
84
+ previous: { date: previous.createdAt, score: previous.summary?.score, passed: previous.summary?.passed },
85
+ delta,
86
+ regressions,
87
+ improvements,
88
+ trend: delta.score > 0 ? 'improving' : delta.score < 0 ? 'regressing' : 'stable',
89
+ };
90
+ }
91
+
92
+ // --- Trend ---
93
+
94
+ function exportOpenCodeTrendReport(dir) {
95
+ const history = getOpenCodeHistory(dir, 50);
96
+ if (history.length === 0) return null;
97
+
98
+ const comparison = compareOpenCodeLatest(dir);
99
+ const lines = [
100
+ '# OpenCode Setup Trend Report',
101
+ '',
102
+ `**Project:** ${path.basename(dir)}`,
103
+ '**Platform:** OpenCode',
104
+ `**Generated:** ${new Date().toISOString().split('T')[0]}`,
105
+ `**Snapshots:** ${history.length}`,
106
+ '',
107
+ '## Score History',
108
+ '',
109
+ '| Date | Score | Passed | Checks |',
110
+ '|------|-------|--------|--------|',
111
+ ];
112
+
113
+ for (const entry of history) {
114
+ const date = entry.createdAt?.split('T')[0] || '?';
115
+ lines.push(`| ${date} | ${entry.summary?.score ?? '?'}/100 | ${entry.summary?.passed ?? '?'} | ${entry.summary?.checkCount ?? '?'} |`);
116
+ }
117
+
118
+ if (comparison) {
119
+ lines.push('');
120
+ lines.push('## Latest Comparison');
121
+ lines.push('');
122
+ lines.push(`- **Previous:** ${comparison.previous.score}/100 (${comparison.previous.date?.split('T')[0]})`);
123
+ lines.push(`- **Current:** ${comparison.current.score}/100 (${comparison.current.date?.split('T')[0]})`);
124
+ lines.push(`- **Delta:** ${comparison.delta.score >= 0 ? '+' : ''}${comparison.delta.score} points`);
125
+ lines.push(`- **Trend:** ${comparison.trend}`);
126
+ if (comparison.improvements.length > 0) lines.push(`- **Fixed:** ${comparison.improvements.join(', ')}`);
127
+ if (comparison.regressions.length > 0) lines.push(`- **New gaps:** ${comparison.regressions.join(', ')}`);
128
+ }
129
+
130
+ if (history.length >= 3) {
131
+ lines.push('');
132
+ lines.push('## Trend Chart');
133
+ lines.push('');
134
+ lines.push('```');
135
+ const scores = history.slice().reverse().map(e => e.summary?.score ?? 0);
136
+ const max = Math.max(...scores, 100);
137
+ const chartHeight = 10;
138
+ for (let row = chartHeight; row >= 0; row--) {
139
+ const threshold = (row / chartHeight) * max;
140
+ const rowLabel = String(Math.round(threshold)).padStart(3);
141
+ const bar = scores.map(s => s >= threshold ? '#' : ' ').join('');
142
+ lines.push(`${rowLabel} |${bar}`);
143
+ }
144
+ lines.push(` +${'─'.repeat(scores.length)}`);
145
+ lines.push('```');
146
+ }
147
+
148
+ lines.push('');
149
+ lines.push('---');
150
+ lines.push(`*Generated by nerviq v${version} for OpenCode*`);
151
+ return lines.join('\n');
152
+ }
153
+
154
+ // --- Feedback ---
155
+
156
+ function recordOpenCodeFeedback(dir, payload) {
157
+ return recordRecommendationOutcome(dir, {
158
+ ...payload,
159
+ source: payload.source || 'opencode-cli',
160
+ platform: 'opencode',
161
+ });
162
+ }
163
+
164
+ function getOpenCodeFeedbackSummary(dir) {
165
+ const entries = readOutcomeIndex(dir)
166
+ .filter(e => e.source === 'opencode-cli' || e.platform === 'opencode');
167
+ return summarizeOutcomeEntries(entries);
168
+ }
169
+
170
+ function formatOpenCodeFeedback(dir) {
171
+ const summary = getOpenCodeFeedbackSummary(dir);
172
+ if (!summary || Object.keys(summary).length === 0) {
173
+ return 'No OpenCode feedback recorded yet.';
174
+ }
175
+
176
+ const lines = ['OpenCode Recommendation Feedback:', ''];
177
+ const entries = Array.isArray(summary) ? summary : Object.values(summary);
178
+ for (const entry of entries) {
179
+ const key = entry.key || 'unknown';
180
+ const accepted = entry.accepted || 0;
181
+ const rejected = entry.rejected || 0;
182
+ const total = entry.total || 0;
183
+ lines.push(` ${key}: ${accepted} accepted, ${rejected} rejected (${total} total)`);
184
+ }
185
+ return lines.join('\n');
186
+ }
187
+
188
+ // --- Insights ---
189
+
190
+ function generateOpenCodeInsights(dir) {
191
+ const history = getOpenCodeHistory(dir, 50);
192
+ const feedback = getOpenCodeFeedbackSummary(dir);
193
+ const insights = [];
194
+
195
+ if (history.length >= 3) {
196
+ const recentFailKeys = new Map();
197
+ for (const entry of history.slice(0, 5)) {
198
+ for (const key of (entry.summary?.topActionKeys || [])) {
199
+ recentFailKeys.set(key, (recentFailKeys.get(key) || 0) + 1);
200
+ }
201
+ }
202
+ for (const [key, count] of recentFailKeys) {
203
+ if (count >= 3) {
204
+ insights.push({
205
+ type: 'persistent-failure',
206
+ severity: 'high',
207
+ key,
208
+ message: `Check ${key} has failed in ${count} of the last ${Math.min(history.length, 5)} audits.`,
209
+ });
210
+ }
211
+ }
212
+ }
213
+
214
+ if (history.length >= 2) {
215
+ const scores = history.map(e => e.summary?.score ?? 0);
216
+ if (scores[0] < scores[1]) {
217
+ insights.push({
218
+ type: 'regression-pattern',
219
+ severity: 'medium',
220
+ message: `Score dropped from ${scores[1]} to ${scores[0]} in the most recent audit.`,
221
+ delta: scores[0] - scores[1],
222
+ });
223
+ }
224
+ }
225
+
226
+ if (history.length >= 5) {
227
+ const recentScores = history.slice(0, 5).map(e => e.summary?.score ?? 0);
228
+ const range = Math.max(...recentScores) - Math.min(...recentScores);
229
+ if (range <= 2) {
230
+ insights.push({
231
+ type: 'velocity-stall',
232
+ severity: 'low',
233
+ message: `Score has been flat (range: ${range} points) over the last 5 audits.`,
234
+ });
235
+ }
236
+ }
237
+
238
+ const feedbackEntries = Array.isArray(feedback) ? feedback : Object.values(feedback || {});
239
+ for (const entry of feedbackEntries) {
240
+ if (entry.rejected > entry.accepted && entry.total >= 2) {
241
+ insights.push({
242
+ type: 'feedback-signal',
243
+ severity: 'medium',
244
+ key: entry.key,
245
+ message: `Recommendation ${entry.key} has been rejected more than accepted (${entry.rejected}/${entry.total}).`,
246
+ });
247
+ }
248
+ }
249
+
250
+ return {
251
+ platform: 'opencode',
252
+ generatedAt: new Date().toISOString(),
253
+ snapshotCount: history.length,
254
+ feedbackCount: feedbackEntries.length,
255
+ insights,
256
+ summary: insights.length === 0
257
+ ? 'No actionable insights detected. Keep running audits to build pattern data.'
258
+ : `${insights.length} insight(s) detected across ${history.length} snapshots.`,
259
+ };
260
+ }
261
+
262
+ function formatOpenCodeInsights(dir) {
263
+ const result = generateOpenCodeInsights(dir);
264
+ if (result.insights.length === 0) return result.summary;
265
+
266
+ const lines = ['OpenCode Insights:', ''];
267
+ for (const insight of result.insights) {
268
+ const severity = insight.severity.toUpperCase();
269
+ lines.push(` [${severity}] ${insight.message}`);
270
+ }
271
+ lines.push('');
272
+ lines.push(result.summary);
273
+ return lines.join('\n');
274
+ }
275
+
276
+ module.exports = {
277
+ getOpenCodeHistory,
278
+ formatOpenCodeHistory,
279
+ compareOpenCodeLatest,
280
+ exportOpenCodeTrendReport,
281
+ recordOpenCodeFeedback,
282
+ getOpenCodeFeedbackSummary,
283
+ formatOpenCodeFeedback,
284
+ generateOpenCodeInsights,
285
+ formatOpenCodeInsights,
286
+ };
@@ -367,15 +367,32 @@ function hasRuntimeVerificationSignal(technique) {
367
367
  return /experiment(?:ally)? confirmed|confirmed by (?:live )?experiment|current runtime|runtime evidence|runtime-verified|validated in current runtime|observed in current runtime|measured in live experiment|reproduced in runtime|confirmed by experiment/i.test(haystack);
368
368
  }
369
369
 
370
+ // Stack categories where checks are generated/adapted rather than individually verified
371
+ const STACK_CATEGORIES = new Set([
372
+ 'python', 'go', 'rust', 'java', 'ruby', 'dotnet', 'php', 'flutter', 'swift', 'kotlin',
373
+ ]);
374
+
370
375
  function resolveConfidence(platform, technique) {
371
376
  if (STALE_CONFIDENCE_IDS.has(technique.id)) {
372
377
  return 0.3;
373
378
  }
374
379
 
380
+ // Runtime-verified: highest confidence
375
381
  if (RUNTIME_CONFIDENCE_IDS[platform]?.has(technique.id) || hasRuntimeVerificationSignal(technique)) {
376
382
  return 0.9;
377
383
  }
378
384
 
385
+ // Has fix template: author wrote specific remediation → higher confidence
386
+ if (technique.template) {
387
+ return 0.8;
388
+ }
389
+
390
+ // Stack-specific checks: generated per-language, less individually verified
391
+ if (STACK_CATEGORIES.has(technique.category)) {
392
+ return 0.6;
393
+ }
394
+
395
+ // Default: documented but not individually experiment-verified
379
396
  return 0.7;
380
397
  }
381
398
 
@@ -396,7 +413,7 @@ function attachSourceUrls(platform, techniques) {
396
413
  }
397
414
 
398
415
  technique.sourceUrl = technique.sourceUrl || resolved;
399
- technique.confidence = technique.confidence ?? resolveConfidence(platform, technique);
416
+ technique.confidence = resolveConfidence(platform, technique);
400
417
  technique.lastVerified = technique.lastVerified || LAST_VERIFIED[platform] || LAST_VERIFIED.default;
401
418
  }
402
419