Skip to content

Add strict Madar-first compare mode - #390

Merged
mohanagy merged 2 commits into
nextfrom
issue-385-madar-first-compliance
May 28, 2026
Merged

mohanagy merged 2 commits into
nextfrom
issue-385-madar-first-compliance

Conversation

@mohanagy

@mohanagy mohanagy commented May 28, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • add a --strict-madar-first compare flag and thread it through the CLI
  • degrade native-agent compare runs when broad exploration happens before the first Madar MCP call in strict mode
  • suppress attributable reductions for those strict-mode traces and cover the behavior with CLI and native-agent tests

Testing

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

Closes #385

Summary by CodeRabbit

  • New Features

    • Added a --strict-madar-first option to the compare CLI, enabling stricter validity assessment in native_agent runs; when enabled, runs where broad exploration precedes the first Madar call are marked degraded and reductions are suppressed with explanatory assessment text.
  • Tests

    • Updated and added unit tests to cover the new flag, help text, parsing, and degraded-measurement behavior.

Review Change Stack

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: 060775c1-187f-4ac1-a0bb-3f14abaa6419

📥 Commits

Reviewing files that changed from the base of the PR and between 485d9f9 and 65f881f.

📒 Files selected for processing (2)
  • src/cli/parser.ts
  • tests/unit/cli.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/cli/parser.ts
  • tests/unit/cli.test.ts

📝 Walkthrough

Walkthrough

This PR adds a --strict-madar-first CLI option to the compare command that enforces Madar-first invocation order in native-agent mode. When enabled, runs where broad exploration (ToolSearch, Glob, Grep, Bash, Read, or subagent dispatch) occurs before the first Madar MCP call are downgraded from valid to degraded measurement validity, reductions are suppressed, and claims are marked not_measured.

Changes

Strict Madar-First Enforcement

Layer / File(s) Summary
CLI option definition and wiring
src/cli/parser.ts, src/cli/main.ts, tests/unit/cli.test.ts
CompareCliOptions gains strictMadarFirst: boolean; COMPARE_USAGE documents --strict-madar-first; parseCompareArgs recognizes the flag and defaults it to false; the option is wired through runCompareCommand, help text updated, and CLI tests updated to cover the flag.
Measurement validity assessment and attribution gap evidence
src/infrastructure/compare.ts, tests/unit/compare-native-agent.test.ts
GenerateCompareArtifactsInput accepts optional strictMadarFirst; new helpers strictMadarFirstViolated, assessNativeAgentMeasurementValidity, and nativeAgentAttributionGapEvidence classify validity as invalid, degraded, or valid based on install verification, Madar MCP presence, and (when strict) pre-Madar exploration; measurement validity assignment and formatting updated; attribution-gap evidence replaces hardcoded message; regression test verifies strict-mode downgrade when broad exploration precedes first Madar MCP call.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • mohanagy/madar#364: Modifies native-agent attribution logic to suppress reductions and update attribution messaging when outcomes are non-attributable.
  • mohanagy/madar#373: Modifies claim_assessment and measurement-validity logic in native-agent compare, overlapping with the strict-mode downgrade surface.
  • mohanagy/madar#347: Refactors exploration-outcome taxonomy and counting logic in src/infrastructure/compare.ts, which this PR uses to detect pre-Madar broad exploration.

"🐰 A flag so strict, a path so clear,
Madar must come first — no tools to steer,
If searches roam before the call,
The verdict lowers, reductions fall,
Hop, test, and log — let order stand sincere."

🚥 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 strict Madar-first compare mode' is clear, specific, and directly summarizes the main change of adding a new --strict-madar-first CLI option.
Description check ✅ Passed The description covers all required sections: Summary explains changes, Testing lists verification commands, and Checklist items are addressed. Related issues section includes issue closure reference.
Linked Issues check ✅ Passed Changes implement all acceptance criteria from #385: adds --strict-madar-first option, degrades runs when broad exploration precedes first Madar call, suppresses reductions, preserves non-strict behavior, and includes required tests.
Out of Scope Changes check ✅ Passed All code changes are directly related to implementing the --strict-madar-first feature and its integration across CLI, parser, infrastructure, and tests. No extraneous changes detected.

✏️ 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-385-madar-first-compliance

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 `@src/cli/parser.ts`:
- Line 193: The COMPARE_USAGE string constant used to display compare command
help is missing the --why flag while parseCompareArgs accepts it; update the
COMPARE_USAGE constant (where it's defined) to include "--why" in the usage text
so the displayed usage matches parseCompareArgs's accepted options and help
output.
🪄 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: cdd7dc5e-3e9f-4f25-bc82-b8cd07a4e514

📥 Commits

Reviewing files that changed from the base of the PR and between 41fc2d5 and 485d9f9.

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

Comment thread src/cli/parser.ts Resolved
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown

Actionable comments posted: 0

@mohanagy
mohanagy merged commit cce4187 into next May 28, 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.

1 participant