Skip to content

Add implement outcome scoring to compare - #413

Merged
mohanagy merged 1 commit into
mainfrom
issue-408-implement-outcome-scoring
May 29, 2026
Merged

mohanagy merged 1 commit into
mainfrom
issue-408-implement-outcome-scoring

Conversation

@mohanagy

@mohanagy mohanagy commented May 29, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • add compare task plumbing and benchmark-suite task propagation for implement-mode runs
  • score native-agent implement compares with isolated per-arm workspaces, touched-file evidence, validation results, and implement_outcome reporting
  • add issue-408 regressions for compare CLI, benchmark suite, and implement outcome classification

Testing

  • npm run typecheck
  • npm run build
  • CI=1 npm run test:run

Closes #408

Summary by CodeRabbit

  • New Features
    • Added "implement" task type for benchmark suite
    • Added --task option to compare command for selecting task type (defaults to "explain")
    • Implement task includes validation checks for code modifications, test coverage, and risk assessment

Review Change Stack

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented May 29, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR adds implement-task outcome scoring to the native-agent compare pipeline. The change introduces CLI support for --task implement, extends the benchmark suite with task mapping, updates the report schema with implement-specific outcome types, implements workspace-based execution with file fingerprinting and validation, and includes comprehensive test coverage across CLI, suite, and execution layers.

Changes

Implement Task Outcome Measurement

Layer / File(s) Summary
CLI option and argument parsing for --task
src/cli/parser.ts, src/cli/main.ts
CompareCliOptions gains task?: ContextPackTaskKind; parseCompareArgs validates and parses --task / --task= arguments; formatHelp() documents the new flag with allowed values and default.
Benchmark suite task mapping and plumbing
docs/benchmarks/suite/tasks.json, src/infrastructure/benchmark/suite.ts
suiteTaskKind() maps benchmark task IDs (explain-runtime, implement, etc.) to ContextPackTaskKind values. Task is conditionally included in both legacy and SPI compare inputs. Manifest marks implement task as ready with nestjs-mid prompt.
Report schema types for implement outcomes
src/infrastructure/compare.ts (types: lines 2485–2505, 2523, 2552, 2621)
Adds NativeAgentImplementCheckStatus, NativeAgentImplementValidationStatus, and NativeAgentImplementOutcome exported types. Extends NativeAgentCompareReport with optional task and implement_outcome fields. Adds workspaceRoot to NativeAgentRunnerInput to enable isolated workspace execution.
Workspace-based implement task execution
src/infrastructure/compare.ts (lines 2985–3294, 3975–4460)
For task === 'implement', creates temporary workspace copies with symlinked node_modules, fingerprints file state before/after baseline and madar runs to detect touched files, runs validation commands inside isolated workspaces, and computes NativeAgentImplementOutcome from file overlap and validation results. Cleans up temporary workspaces after execution. Non-implement tasks skip workspace creation.
Native-agent summary formatting for implement outcomes
src/infrastructure/compare.ts (lines 4582–4702)
formatNativeAgentImplementOutcomeLine() renders implement checks and evidence. formatNativeAgentCompareSummary conditionally includes formatted implement outcome when present in report.
Test coverage for implement task mode
tests/unit/cli.test.ts, tests/unit/benchmark-suite.test.ts, tests/unit/compare-native-agent.test.ts
CLI tests verify --task parsing, help text, invalid args, and routing. Benchmark suite tests expect implement task in manifest and verify task propagation. Native-agent tests add makeImplementFixtureProject() fixture builder and classifies implement outcomes test that simulates baseline/madar workspace runs with different touched-file outcomes and validates report consistency.

Sequence Diagram

sequenceDiagram
  participant CLI
  participant Parser
  participant Suite
  participant ExecuteCompare
  participant Workspace
  participant Validator
  participant Report

  CLI->>Parser: --task implement
  Parser->>Parser: parseContextPackTask
  Parser->>Suite: options.task
  Suite->>Suite: suiteTaskKind(taskId)
  Suite->>ExecuteCompare: compareInput.task
  ExecuteCompare->>ExecuteCompare: task === 'implement'
  ExecuteCompare->>Workspace: create baseline copy
  ExecuteCompare->>Workspace: create madar copy
  Workspace->>Workspace: fingerprint baseline
  ExecuteCompare->>Validator: run baseline command in workspace
  Validator->>Workspace: snapshot baseline state
  Validator->>Validator: run validation checks
  Workspace->>Workspace: fingerprint madar
  ExecuteCompare->>Validator: run madar command in workspace
  Validator->>Workspace: snapshot madar state
  Validator->>Validator: run validation checks
  ExecuteCompare->>Report: compute implement_outcome
  Report->>Report: score edit_targeting, test_coverage, risk_boundary_respect
  ExecuteCompare->>Workspace: cleanup temporary copies
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

The PR introduces substantial new logic across multiple subsystems: workspace-based execution with file fingerprinting, temporary directory management, validation command execution with timeouts, and conditional task-dependent report scoring. The core executeNativeAgentCompare function gains significant complexity with parallel baseline/madar workspace handling, file change detection, and cleanup. Mixed complexity in imports, type definitions, condition branches, and test fixtures requires careful review of workspace isolation guarantees, file handling correctness, and outcome scoring logic.

Possibly related PRs

  • mohanagy/madar#279: Adds buildImplementationPackGuidance to the context-pack pipeline, providing the implementation guidance that this PR's native-agent flow consumes during implement-task execution.
  • mohanagy/madar#392: Also extends executeNativeAgentCompare and NativeAgentCompareReport by adding benchmark-readiness preflight gating; overlaps at the same compare execution and reporting schema level.
  • mohanagy/madar#366: Modifies the native-agent compare pipeline with per-arm timeouts/heartbeats, overlapping at the runtime wiring and types used by this PR's workspace runner.

🐰 A task for tracking touched files and checking tests
With workspaces isolated and validated deeds,
The implementation measure now proceeds—
Edit targeting, coverage, risk respect complete,
Madar's promises now have proof to greet! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add implement outcome scoring to compare' accurately captures the main change: introducing implement_outcome scoring functionality to the compare infrastructure.
Description check ✅ Passed The description provides a clear summary of changes, testing instructions, and closes #408. It covers key aspects: task plumbing, scoring implementation, and test coverage.
Linked Issues check ✅ Passed The PR successfully addresses all acceptance criteria from #408: implements --task implement support with implement_outcome block containing edit_targeting/test_coverage/risk_boundary_respect dimensions, populates benchmark suite tasks, adds fixture tests, and scores using touched-file overlap and validation results.
Out of Scope Changes check ✅ Passed All changes directly support implement-task outcome scoring and benchmark suite integration. Updates to JSON task definitions, CLI parsing, infrastructure code, and tests are all within scope of adding implement outcome measurement.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-408-implement-outcome-scoring

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 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 `@tests/unit/benchmark-suite.test.ts`:
- Around line 515-622: The test "passes implement tasks through to native-agent
compare inputs" currently places the assertion inside the
executeNativeAgentCompare callback after a return, making it unreachable;
extract the expectation so it runs after runBenchmarkSuite completes. Keep the
seenTasks array and the executeNativeAgentCompare stub as-is to collect calls,
but move the expect(seenTasks).toEqual([...]) out of the callback and
immediately after the awaited runBenchmarkSuite(...) call so the assertion
executes; reference symbols: seenTasks, runBenchmarkSuite,
executeNativeAgentCompare, and the "passes implement tasks through to
native-agent compare inputs" it block.
🪄 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: 1e05fafd-d715-4e5a-87e0-ef5a697d6688

📥 Commits

Reviewing files that changed from the base of the PR and between 672dd10 and c765e54.

📒 Files selected for processing (8)
  • docs/benchmarks/suite/tasks.json
  • src/cli/main.ts
  • src/cli/parser.ts
  • src/infrastructure/benchmark/suite.ts
  • src/infrastructure/compare.ts
  • tests/unit/benchmark-suite.test.ts
  • tests/unit/cli.test.ts
  • tests/unit/compare-native-agent.test.ts

Comment thread tests/unit/benchmark-suite.test.ts Resolved
@mohanagy
mohanagy merged commit cb86360 into main May 29, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P2] No implement-task outcome scoring or populated implement cells (follow-up to #332)

1 participant