Repository navigation
Add benchmark-readiness preflight for native-agent compare - #392
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
📝 WalkthroughWalkthroughThe PR adds a benchmark-readiness assessment feature that evaluates whether a native-agent compare run is likely to produce reliable results, considering graph scope, SPI support, execution phases, and confidence metrics. It introduces a new ChangesBenchmark Readiness Assessment & CLI Integration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/infrastructure/compare.ts (1)
3515-3590:⚠️ Potential issue | 🟠 Major | 🏗️ Heavy liftRun strict benchmark-readiness as a full preflight before any arm execution.
strictBenchmarkReadinessis enforced inside the question execution loop. That means earlier questions may already consume runner resources before a later question fails strict readiness, and the failing question’s readiness is not persisted before throwing. This undermines fail-fast behavior for suite runs.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/infrastructure/compare.ts` around lines 3515 - 3590, The strict benchmark-readiness check is currently performed inside the questions loop (when building reportShell) which lets earlier questions consume resources before a later question fails; fix by preflighting all questions before any execution: iterate over questions and compute readiness using assessBenchmarkReadiness or assessBenchmarkReadinessFromRetrieveResult (calling retrieveCompareContext when graph is present) to populate a map of question -> readiness, persist those readiness results, and if input.strictBenchmarkReadiness is true throw BenchmarkReadinessError immediately for any non-'ready' readiness; then in the per-question loop set reportShell.benchmark_readiness from the precomputed map instead of recomputing.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/infrastructure/compare.ts`:
- Around line 1638-1641: The SPI detection in retrievalHasSpiEvidence is missing
top-level "spi/" paths; update the predicate (which iterates
collectBenchmarkReadinessSourceFiles(retrieval)) to also detect "spi" as a path
segment at the start or between slashes. Replace the current includes checks
with a single regex test such as /(^|\/)spi(\/|$)|\.spi\./ (or equivalent
startsWith('/spi')/startsWith('spi/') plus existing ".spi." check) so files like
"spi/runtime.ts", "/spi/foo", "lib/spi/bar" and dotted names are all detected.
---
Outside diff comments:
In `@src/infrastructure/compare.ts`:
- Around line 3515-3590: The strict benchmark-readiness check is currently
performed inside the questions loop (when building reportShell) which lets
earlier questions consume resources before a later question fails; fix by
preflighting all questions before any execution: iterate over questions and
compute readiness using assessBenchmarkReadiness or
assessBenchmarkReadinessFromRetrieveResult (calling retrieveCompareContext when
graph is present) to populate a map of question -> readiness, persist those
readiness results, and if input.strictBenchmarkReadiness is true throw
BenchmarkReadinessError immediately for any non-'ready' readiness; then in the
per-question loop set reportShell.benchmark_readiness from the precomputed map
instead of recomputing.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: df2d24c1-1b76-4679-9aec-84545f798f87
📒 Files selected for processing (6)
src/cli/main.tssrc/cli/parser.tssrc/infrastructure/compare.tstests/unit/cli.test.tstests/unit/compare-native-agent.test.tstests/unit/compare.test.ts
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/infrastructure/compare.ts (1)
1620-1641:⚠️ Potential issue | 🟠 Major | ⚡ Quick winNormalize source-file paths before SPI/scope checks.
Line 1640 and the scope derivation logic rely on
/-separated paths. Windows-style\paths (or mixed-caseSPI) can be misclassified, causing false degraded/not_ready readiness and incorrectsuggested_graph_scopeunder strict mode.💡 Proposed fix
function suggestBenchmarkGraphScope(graphPath: string, sourceFiles: readonly string[]): string | null { const scopes = new Set<string>() for (const sourceFile of sourceFiles) { - const [scope] = sourceFile.split('/', 1) + const normalized = sourceFile.replaceAll('\\', '/') + const [scope] = normalized.split('/', 1) if (scope && !['src', 'test', 'tests', 'docs'].includes(scope)) { scopes.add(scope) } } @@ function retrievalHasSpiEvidence(retrieval: RetrieveResult): boolean { - return collectBenchmarkReadinessSourceFiles(retrieval).some((sourceFile) => - /(^|\/)spi(\/|$)|\.spi\./.test(sourceFile), - ) + return collectBenchmarkReadinessSourceFiles(retrieval).some((sourceFile) => { + const normalized = sourceFile.replaceAll('\\', '/').toLowerCase() + return /(^|\/)spi(\/|$)|\.spi\./.test(normalized) + }) }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/infrastructure/compare.ts` around lines 1620 - 1641, Both suggestBenchmarkGraphScope and retrievalHasSpiEvidence assume POSIX '/' paths and case-sensitive "spi"; normalize source-file paths and graphPath by replacing backslashes with '/' and lowercasing before checks. In suggestBenchmarkGraphScope, compute scope from sourceFile.replace(/\\/g,'/').toLowerCase() before split('/') and use a normalized graphPath (replace backslashes and lowercase) when doing graphPath.endsWith. In retrievalHasSpiEvidence (and any use of collectBenchmarkReadinessSourceFiles), run each sourceFile through the same replace(/\\/g,'/').toLowerCase() normalization and then test for /(^|\/)spi(\/|$)|\.spi\./ to make SPI detection robust across Windows paths and mixed casing.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/infrastructure/compare.ts`:
- Around line 1620-1641: Both suggestBenchmarkGraphScope and
retrievalHasSpiEvidence assume POSIX '/' paths and case-sensitive "spi";
normalize source-file paths and graphPath by replacing backslashes with '/' and
lowercasing before checks. In suggestBenchmarkGraphScope, compute scope from
sourceFile.replace(/\\/g,'/').toLowerCase() before split('/') and use a
normalized graphPath (replace backslashes and lowercase) when doing
graphPath.endsWith. In retrievalHasSpiEvidence (and any use of
collectBenchmarkReadinessSourceFiles), run each sourceFile through the same
replace(/\\/g,'/').toLowerCase() normalization and then test for
/(^|\/)spi(\/|$)|\.spi\./ to make SPI detection robust across Windows paths and
mixed casing.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: f6255c07-f8c4-47b4-97d5-f7324ff49bc3
📒 Files selected for processing (3)
src/infrastructure/compare.tstests/unit/compare-native-agent.test.tstests/unit/compare.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- tests/unit/compare-native-agent.test.ts
- tests/unit/compare.test.ts
Summary
madar compare --strict/--strict-benchmark-readinessCloses #387
Summary by CodeRabbit
New Features
--strict/--strict-benchmark-readinessflag to the compare command to enforce benchmark-readiness checks.Documentation
--strict / --strict-benchmark-readinessflag and usage string.Tests