Skip to content

Flag pre-Madar broad exploration in native compare traces - #372

Merged
mohanagy merged 1 commit into
mainfrom
issue-369-pre-madar-exploration
May 28, 2026
Merged

mohanagy merged 1 commit into
mainfrom
issue-369-pre-madar-exploration

Conversation

@mohanagy

@mohanagy mohanagy commented May 28, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • classify traces as madar_invoked_after_broad_exploration when broad tools run before the first Madar MCP call
  • persist first-Madar-turn and pre-Madar broad exploration counts in trace artifacts
  • include the new outcome in native-agent and aggregate compare summaries

Closes #369

Verification

  • npm run test:run -- tests/unit/compare-native-agent.test.ts tests/unit/compare.test.ts
  • npm run typecheck
  • npm run build
  • CI=1 npm run test:run

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced exploration analysis to distinguish scenarios where broad exploration precedes Madar invocation, with improved tool usage tracking and sequence reporting.
  • Tests

    • Added coverage for new exploration pattern analysis scenarios.

Review Change Stack

Closes #369

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

coderabbitai Bot commented May 28, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 8d09ba75-9c78-473a-b0ab-3eccb01cf013

📥 Commits

Reviewing files that changed from the base of the PR and between 55b5849 and 0e6c110.

📒 Files selected for processing (3)
  • src/infrastructure/compare.ts
  • tests/unit/compare-native-agent.test.ts
  • tests/unit/compare.test.ts

📝 Walkthrough

Walkthrough

This PR extends the Madar trace analysis system to detect and surface broad-exploration tool calls that occur before the first Madar MCP invocation. It adds new fields to the trace model to record the first Madar turn and pre-phase tool counts, introduces a new outcome classification (madar_invoked_after_broad_exploration), and updates test fixtures and assertions to verify the behavior.

Changes

Pre-Madar Exploration Detection

Layer / File(s) Summary
Data model for pre-Madar exploration tracking
src/infrastructure/compare.ts
CompareMadarTraceOutcome adds literal 'madar_invoked_after_broad_exploration'; CompareMadarTrace adds optional fields first_madar_turn, pre_madar_broad_exploration_tool_call_count, and pre_madar_broad_exploration_tool_calls_by_name.
Core analysis state and turn/count tracking
src/infrastructure/compare.ts
analyzeMadarTraceExploration initializes state to track the first Madar turn and pre-Madar broad-exploration totals. When a Madar MCP tool is first encountered, its turn is recorded. Broad-exploration tools before that first turn increment pre-phase counters and per-tool maps, which are sorted deterministically.
Trace object construction and outcome classification
src/infrastructure/compare.ts
All return paths spread the new pre-phase fields via baseTraceFields. A new conditional branch handles the madar_invoked_after_broad_exploration outcome when pre-Madar exploration is present, extending the exploration_summary with before-phase details.
Summary formatting for new outcome
src/infrastructure/compare.ts
formatCompareMadarTraceSummary aggregates and displays the run count for the new outcome and includes its label in the final outcome parts.
Unit tests and test fixtures
tests/unit/compare-native-agent.test.ts, tests/unit/compare.test.ts
Fixtures are reshaped to model pre-Madar broad exploration. New test cases verify correct detection of broad exploration before the first Madar MCP call, asserting first_madar_turn, pre-phase tool counts by name, the derived outcome, and corresponding summary text.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • mohanagy/madar#347: Modifies src/infrastructure/compare.ts's Madar trace classification and related fixtures to detect broad exploration relative to Madar invocation in a similar pattern.
  • mohanagy/madar#343: Extends src/infrastructure/compare.ts's Madar trace fields and derives install/measurement-validity from the same exploration analysis.
  • mohanagy/madar#321: Introduces the exploration-outcome classification machinery in the trace system that this PR extends.

Poem

🐰 Broad before the Madar call—we've caught you now,
Your exploration sequence reveals the how!
First turns recorded, tool counts aligned,
No hidden detours left behind.

🚥 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 'Flag pre-Madar broad exploration in native compare traces' clearly and specifically describes the main change: detecting and surfacing broad exploration that occurs before the first Madar MCP call.
Description check ✅ Passed The PR description includes a clear summary of changes, lists specific verification steps (test commands, typecheck, build, CI), and references the closed issue #369.
Linked Issues check ✅ Passed All primary coding requirements from issue #369 are met: detecting pre-Madar broad exploration, recording first_madar_turn, pre_madar_broad_exploration_tool_call_count, pre_madar_broad_exploration_tool_calls_by_name, new exploration_outcome variant, and updating summaries.
Out of Scope Changes check ✅ Passed All changes directly support the PR objectives: type updates to CompareMadarTraceOutcome and CompareMadarTrace, tracking logic in analyzeMadarTraceExploration, summary formatting in formatCompareMadarTraceSummary, and comprehensive test coverage.

✏️ 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-369-pre-madar-exploration

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.

@mohanagy
mohanagy merged commit be9ff8f into main May 28, 2026
12 of 13 checks passed
mohanagy added a commit that referenced this pull request May 28, 2026
* Prepare 0.27.0 release

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

* Finish 0.27.0 release punchlist

Closes #358

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

* Relax pipeline fixture timeout on Windows

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

* Fix degraded compare attribution

Closes #361

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

* Handle no-trace degraded compare runs

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

* Improve summary runtime path scoring

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

* Admit worker runtime starts

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

* Handle metadata-less runtime starts

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

* Add compare timeouts and heartbeats

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

* Prepare 0.27.1 release (#367)

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

* Clarify native-agent trace attribution (#371)

Add trace_status to native-agent compare reports so non-verbose Claude runs are distinguishable from trace-backed MCP attribution. Surface the missing --verbose requirement in summaries, help, and proof docs.\n\nCloses #368\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Flag pre-Madar broad exploration (#372)

Closes #369

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

* Separate native compare routing wins from token proof (#373)

* Separate native compare token proof claims

Closes #370

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

* Assert native compare latency improvement

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

---------

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

* Prepare 0.27.2 release (#374)

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

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

native_agent compare should flag broad exploration before first Madar MCP call

1 participant