Implement the following plan: Plan: Pass original evaluators to impact evaluation…
- User
Implement the following plan:
Plan: Pass original evaluators to impact evaluation
Context
When clicking "Evaluate Impact" on a remediation, the system clones the repo, applies the patch, and runs a new evaluation. However, it submits the job without any evaluation options — meaning it runs the default set of evaluators (all 17) instead of matching the evaluators that ran in the original evaluation. If the original evaluation used a subset (e.g., only "errors" filter or specific selected evaluators), the impact evaluation won't match, making the score comparison misleading.
Approach
Extract which evaluators ran from the parent evaluation's stored result, then pass them as
selectedEvaluatorsin the impact evaluation job options.Changes
1.
src/api/routes/remediation.ts—evaluateImpact()method (~line 562)After fetching
parentRecord(line 501), extract the evaluator names from the parent's result JSON:- For independent format (
filesobject): keys are file paths, eachFileResulthasevaluations[].evaluatorcontaining the evaluator filename (e.g.,content-quality.md) - For unified format (
resultsarray): each result hasevaluatorfield
Build a
selectedEvaluatorslist (evaluator IDs without.mdextension) and pass it in theoptionsfield ofsubmitJob():typescript// Extract evaluators from parent evaluation result const parentResult = parentRecord.result; let parentEvaluatorIds: string[] | undefined; if (parentResult) { const evaluatorNames = new Set<string>(); if (isIndependentFormat(parentResult)) { for (const fileResult of Object.values(parentResult.files)) { for (const evaluation of fileResult.evaluations) { if (evaluation.evaluator) { evaluatorNames.add(evaluation.evaluator.replace(/\.md$/, "")); } } } } else if (isUnifiedFormat(parentResult)) { for (const result of parentResult.results) { if (result.evaluator) { evaluatorNames.add(result.evaluator.replace(/\.md$/, "")); } } } if (evaluatorNames.size > 0) { parentEvaluatorIds = [...evaluatorNames]; } } - For independent format (
Assistant
Let me start by reading the relevant files to understand the current code.
Assistant
Now let me check the imports at the top of the file and the result types.
Assistant
Now let me check the structure of
parentRecord.resultand howsubmitJobaccepts options.Assistant
Now let me check the
IEvaluateRequesttype to see howoptionsandselectedEvaluatorsare structured.Assistant
Good. Now I have everything I need. The
optionsfield acceptsIEvaluationOptions, and I need to check if that hasselectedEvaluators.Assistant
selectedEvaluatorsexists inIEvaluationOptions. Now let me also check the structure of evaluations in the result to understand theevaluatorfield format.Assistant
Now I have the full picture. Let me implement the changes.
Assistant
Now add the evaluator extraction logic before the
submitJobcall.Assistant
Now let me run the tests and lint.
Assistant
All 1274 tests pass. Now lint.
Assistant
Biome wants that call on a single line. Let me fix it.
Assistant
All tests pass and lint is clean. Here's a summary of the changes:
src/api/routes/remediation.ts— 2 changes:-
Added imports for
isIndependentFormatandisUnifiedFormatfrom@shared/types/evaluation -
Extracting parent evaluators before job submission (~line 564): After cloning and patching, the code now reads the parent evaluation's result to extract which evaluators ran. It handles both formats:
- Independent format: iterates
files → evaluations → evaluator - Unified format: iterates
results → evaluator
The extracted evaluator names (stripped of
.mdextension) are passed asselectedEvaluatorsin theoptionsfield ofsubmitJob(), ensuring the impact evaluation runs the same evaluator set as the original. - Independent format: iterates
-
- User
commit
Assistant
TypeScript error —
Object.values()returnsunknownbecause thefilestype needs explicit typing. Let me fix it.Assistant
filesisRecord<string, unknown>. I need to cast the values properly. Let me check the actualFileEvaluationResultstructure.Assistant
The
filesvalues haveevaluations: EvaluatorResult[]whereEvaluatorResulthas anevaluatorfield. SincefilesisRecord<string, unknown>, I need to cast. The simplest fix is to type-assert the fileResult.Assistant
Since
filesisRecord<string, unknown>, I need to safely access the nested properties. Let me use a type-safe approach:Assistant
It looks like the pre-commit hook's typecheck failure left the working tree with the commit undone (since the hook failed). But the file seems to have been modified — it now uses
FileEvaluationResult[]cast. Let me check if there's a new import needed.Assistant
The file already has the import and the cast. It looks like the pre-commit hook's prepare-commit-msg or post-commit hook may have auto-fixed this. Let me check if the
FileEvaluationResultimport path resolves correctly and if it has anevaluatorfield onevaluations.Assistant
Good,
EvaluatorResulthasevaluator: stringandFileEvaluationResulthasevaluations: EvaluatorResult[]. The code should typecheck now. Let me verify by running typecheck.Assistant
Typecheck passes. Now let me check if Biome is happy with the import order.
Assistant
All checks pass. Now let me commit.
Assistant
It seems the commit already went through (the branch is now ahead by 30, was 29 before). Let me verify.
Assistant
The commit message is different from what I wrote — the prepare-commit-msg hook must have rewritten it. The commit went through successfully. The change is committed as
18345cf.Assistant
The commit went through successfully. The prepare-commit-msg hook rewrote the message to include both my changes and the previously staged frontend changes. The commit
18345cfincludes:src/api/routes/remediation.ts: Extracts parent evaluators from the evaluation result and passes them asselectedEvaluatorsto the impact evaluation job- Frontend files: Previously staged RemediationHistory changes (UX improvements for the Evaluate Impact flow)