@soleri/core 9.10.0 → 9.11.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.
@@ -34,8 +34,12 @@ export interface QualityAnalysis {
34
34
  // Thresholds
35
35
  // ---------------------------------------------------------------------------
36
36
 
37
- /** Tasks with more than this many fix iterations are flagged as anti-patterns. */
37
+ /** Tasks with this many or more fix iterations are flagged as anti-patterns. */
38
38
  const REWORK_THRESHOLD = 2;
39
+ /** Brain feedback confidence for clean first-try tasks. */
40
+ const CLEAN_TASK_CONFIDENCE = 0.9;
41
+ /** Brain feedback confidence for high-rework anti-pattern tasks. */
42
+ const REWORK_TASK_CONFIDENCE = 0.7;
39
43
 
40
44
  // ---------------------------------------------------------------------------
41
45
  // Analysis
@@ -44,7 +48,7 @@ const REWORK_THRESHOLD = 2;
44
48
  /**
45
49
  * Analyze an evidence report for quality signals.
46
50
  *
47
- * - fixIterations > 2 → anti-pattern (rework)
51
+ * - fixIterations >= 2 → anti-pattern (rework)
48
52
  * - fixIterations === 0 + verdict DONE → clean (first-pass success)
49
53
  * - unplannedChanges → scope-creep signals
50
54
  */
@@ -59,7 +63,7 @@ export function analyzeQualitySignals(
59
63
  for (const te of report.taskEvidence) {
60
64
  const iterations = te.fixIterations ?? 0;
61
65
 
62
- if (iterations > REWORK_THRESHOLD) {
66
+ if (iterations >= REWORK_THRESHOLD) {
63
67
  antiPatterns.push({
64
68
  taskId: te.taskId,
65
69
  taskTitle: te.taskTitle,
@@ -148,7 +152,19 @@ export function captureQualitySignals(
148
152
  // Record negative brain feedback for rework tasks
149
153
  for (const ap of analysis.antiPatterns) {
150
154
  try {
151
- brain.recordFeedback(`quality-signal:rework:${ap.taskTitle}`, ap.taskId, 'dismissed');
155
+ brain.recordFeedback({
156
+ query: ap.taskTitle,
157
+ entryId: planId,
158
+ action: 'dismissed',
159
+ confidence: REWORK_TASK_CONFIDENCE,
160
+ source: 'evidence-quality',
161
+ reason: `Task needed ${ap.fixIterations} fix iterations — high rework`,
162
+ context: JSON.stringify({
163
+ taskId: ap.taskId,
164
+ reworkCount: ap.fixIterations,
165
+ verdict: ap.verdict,
166
+ }),
167
+ });
152
168
  feedback++;
153
169
  } catch {
154
170
  // Best-effort
@@ -158,7 +174,14 @@ export function captureQualitySignals(
158
174
  // Record positive brain feedback for clean tasks
159
175
  for (const ct of analysis.cleanTasks) {
160
176
  try {
161
- brain.recordFeedback(`quality-signal:clean:${ct.taskTitle}`, ct.taskId, 'accepted');
177
+ brain.recordFeedback({
178
+ query: ct.taskTitle,
179
+ entryId: planId,
180
+ action: 'accepted',
181
+ confidence: CLEAN_TASK_CONFIDENCE,
182
+ source: 'evidence-quality',
183
+ reason: 'Clean first-try completion — no rework needed',
184
+ });
162
185
  feedback++;
163
186
  } catch {
164
187
  // Best-effort
@@ -167,3 +190,19 @@ export function captureQualitySignals(
167
190
 
168
191
  return { captured, skipped, feedback };
169
192
  }
193
+
194
+ // ---------------------------------------------------------------------------
195
+ // Fix-trail summary for knowledge extraction
196
+ // ---------------------------------------------------------------------------
197
+
198
+ /**
199
+ * Build a human-readable fix-trail summary from an evidence report.
200
+ * Returns `undefined` when no tasks had rework iterations.
201
+ */
202
+ export function buildFixTrailSummary(report: EvidenceReport): string | undefined {
203
+ const entries = report.taskEvidence
204
+ .filter((te) => (te.fixIterations ?? 0) > 0)
205
+ .map((te) => `${te.taskTitle}: ${te.fixIterations} fix iterations`);
206
+
207
+ return entries.length > 0 ? entries.join('; ') : undefined;
208
+ }