Skip to content

Next - #395

Merged
mohanagy merged 20 commits into
mainfrom
next
May 28, 2026
Merged

Next#395
mohanagy merged 20 commits into
mainfrom
next

Conversation

@mohanagy

@mohanagy mohanagy commented May 28, 2026 •

Copy link
Copy Markdown
Owner

Summary

Testing

  • npm run test:run
  • npm run typecheck
  • npm run build
  • npm pack --dry-run (if packaging or install behavior changed)

Checklist

  • I updated docs for any user-visible change
  • I added or updated tests when behavior changed
  • This PR does not include private corpora, secrets, credentials, proprietary prompts, sensitive raw logs, or accidental generated artifacts
  • I kept this PR focused on a single change or tightly related set of changes

Related issues

Summary by CodeRabbit

  • New Features
    • Added answer-ready summaries with structured outlines and must-cite citations for explain tasks.
    • Introduced benchmark readiness assessment with optional strict-mode enforcement.
    • Extended compare command with timeout, heartbeat interval, and strictness flags (--per-arm-timeout, --heartbeat-interval-ms, --strict-madar-first, --strict-benchmark-readiness) for native-agent execution control.
    • Enhanced evidence confidence scoring with explicit reasoning and detailed assessment logic.

Review Change Stack

mohanagy and others added 18 commits May 28, 2026 12:16
* 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>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Bind native-agent compare to pack contract
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add benchmark-readiness preflight for native-agent compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Tighten runtime pack confidence gating
- Add ContextPackExplainAnswerReadySummary interface with answer_outline, must_cite, stop_condition, and allowed_followups fields
- Add comprehensive unit tests for the new interface structure
- Verify typecheck passes and tests green

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add optional answer_ready field to CompiledContextPack interface
- Add test verifying CompiledContextPack can contain answer_ready data
- Verify all tests passing and typecheck clean

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add optional answer_ready field to ContextPackSchemaV1 interface
- Add test verifying ContextPackSchemaV1 can include answer_ready
- Verify all tests passing and typecheck clean

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add generateAnswerReadyFromExecutionSlice() helper to generate answer-ready summaries
- Generate answer_outline from execution slice steps
- Extract must_cite from primary path steps
- Add stop_condition and allowed_followups fields
- Add comprehensive tests for generator with various scenarios
- Verify all tests passing (9 tests green)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Fix fallback logic to check primary_path.steps length (not just nullability)
- Add edge-case tests for empty primary_path.steps fallback
- Add edge-case test for empty evidence suppression
- Improve answer generation stability when steps are unavailable
- All 2309 tests passing

Addresses CodeRabbit feedback on PR #394

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
fix(issue-389): Add answer-ready summary and stop condition to explain packs
@coderabbitai

coderabbitai Bot commented May 28, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@mohanagy, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 5 minutes and 48 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 5c9c074e-a2ad-4e0d-a119-6f9bd4d3de81

📥 Commits

Reviewing files that changed from the base of the PR and between db1cfa9 and b8b530e.

📒 Files selected for processing (8)
  • README.md
  • docs/proof-workflows.md
  • src/infrastructure/compare.ts
  • src/runtime/mcp-response-evidence.ts
  • tests/unit/answer-ready-explain-pack.test.ts
  • tests/unit/compare-native-agent.test.ts
  • tests/unit/compare.test.ts
  • tests/unit/mcp-response-evidence.test.ts
📝 Walkthrough

Walkthrough

This PR extends native-agent compare with benchmark-readiness pre-flights, Madar trace attribution, answer-ready explain summaries, and a refactored confidence-scoring pipeline for runtime-generation evidence. New CLI options control per-arm timeouts, heartbeats, and strict Madar-first/benchmark-readiness enforcement. GraphPath threading enables scope-aware confidence assessment.

Changes

Native-agent compare and evidence scoring enhancements

Layer / File(s) Summary
CLI options for native-agent compare configuration
src/cli/parser.ts, src/cli/main.ts, tests/unit/cli.test.ts
Adds --per-arm-timeout, --heartbeat-interval-ms, --strict-madar-first, and --strict-benchmark-readiness flags to compare command. Parser defines defaults, parses arguments, wires into runCompareCommand. BenchmarkReadinessError is imported and mapped to UsageError on execution.
Context pack and compare types for answer-ready and readiness
src/contracts/context-pack.ts, src/infrastructure/compare.ts
Adds ContextPackExplainAnswerReadySummary schema with answer_outline, must_cite citations, stop_condition, and allowed_followups; optional answer_ready field to CompiledContextPack and ContextPackSchemaV1. Imports execution-phase type and defines benchmark-readiness, prompt-contract, and trace-status types in compare contracts.
Evidence assessment pipeline with confidence capping
src/runtime/mcp-response-evidence.ts, tests/unit/mcp-response-evidence.test.ts
Refactors evidence scoring to introduce assessMadarResponseEvidence(...) that computes numeric scores, derives confidence caps from scope quality/workflow locality/phase completeness/answer-containedness assessments, produces detailed confidence_reasons, and returns enhanced agent_directive aware of answer containedness. Updates agentDirectiveForEvidence to accept answerContained hint.
Answer-ready explain pack generation and tests
src/runtime/context-pack.ts, tests/unit/answer-ready-explain-pack.test.ts
Adds generateAnswerReadyFromExecutionSlice(...) that conditionally returns answer-ready summaries for high-confidence explain tasks, deriving answer_outline from execution slice steps (with fallback to primary_path), building citations from first/last steps, and populating allowed_followups from confidence_reasons. Tests validate schema shape, field presence, and behavior across confidence/task-kind/primary-path scenarios.
Thread graphPath through prompt and evidence builders
src/infrastructure/context-prompt-command.ts, src/infrastructure/benchmark/runner.ts, src/infrastructure/context-pack-command.ts, src/runtime/stdio/tools.ts
Extends buildMadarPromptPack and evidenceFor*Payload helpers to accept and forward graphPath for scope-aware confidence assessment. Updates all callers (context_pack, pr_impact, retrieve, context_prompt, relevant_files, feature_map, risk_map, implementation_checklist) to supply graphPath. Modifies buildExplainPackPayloadCore and buildPackSchemaV1 to wire graphPath into evidence assessment, and enhances whyExplanation to append confidence_reasons.
Benchmark readiness assessment and strict enforcement
src/infrastructure/compare.ts, tests/unit/compare.test.ts
Adds assessBenchmarkReadinessFromRetrieveResult(...) that evaluates runtime-generation readiness (not_ready/degraded/ready) and suggests narrower graph scopes based on missing critical phases and SPI evidence detection. Exports BenchmarkReadinessError exception carrying computed readiness for strict-mode gating. Tests assert readiness outcomes and suggested_graph_scope behavior across non-SPI root, SPI root, and backend SPI paths.
Native-agent prompt contract enforcement and assessment
src/infrastructure/compare.ts, tests/unit/compare-native-agent.test.ts
Adds buildNativeAgentPrompt(question) returning native-agent contract prompt text with answer prefix and constraints. Introduces NativeAgentPromptContractAssessment and assessNativeAgentPromptContract validating first Madar MCP call is context_pack, checking strict Madar-first compliance, producing assessment with summary markers. Unit tests verify prompt text contract and prompt-contract-violation scenarios.
Native-agent compare execution with timeouts, readiness checks, and measurement validity
src/infrastructure/compare.ts, tests/unit/compare-native-agent.test.ts
Refactors executeNativeAgentCompare to compute per-arm timeout/heartbeat, assess and enforce benchmark readiness (with strict-mode early failure), write native-agent prompts, support AbortSignal timeout control with heartbeat logging, compute measurement_validity accounting for install verification/Madar MCP-call count/strict Madar-first/broad-exploration timing, and assess prompt_contract. Extends NativeAgentCompareReport with optional benchmark_readiness and prompt_contract. Updates summary formatting to include readiness and prompt-contract lines. Tests cover readiness gating, prompt enforcement, broad-exploration before first Madar call, timeouts, and heartbeat emissions.
Runtime-generation context pack evidence test coverage
tests/unit/context-pack-command.test.ts, tests/unit/stdio-slice-surface.test.ts
Adds comprehensive test cases for runContextPackCommand with runtime-generation explain packs, asserting evidence reflects scope quality (non-SPI root vs SPI root vs backend SPI), execution completeness, answer-containedness, and missing-phases impact. Verifies confidence_reasons mention scope/answer/phase. Introduces createBackendRuntimeGraphPath test helper generating backend-scoped graph with AuthServiceSpi linkage, then verifies scope-quality evidence includes graph path in markers.

Sequence Diagram(s)

sequenceDiagram
  participant CLI as CLI Parser
  participant Compare as executeNativeAgentCompare
  participant Readiness as Readiness Check
  participant PromptCheck as Prompt Contract
  participant Baseline as Baseline Arm
  participant NativeAgent as Native Agent Arm
  participant Summary as Summary Formatting
  CLI->>Compare: pass perArmTimeoutSeconds, strictBenchmarkReadiness
  Compare->>Readiness: assess or check benchmark readiness
  alt strictBenchmarkReadiness and not_ready
    Readiness-->>Compare: BenchmarkReadinessError
    Compare->>Compare: write reports, throw error
  else pass readiness check
    Compare->>PromptCheck: validate context_pack first and strict Madar-first
    Compare->>Baseline: run with timeout/heartbeat
    Compare->>NativeAgent: run with AbortSignal timeout/heartbeat
    Baseline-->>Compare: results
    NativeAgent-->>Compare: results
    Compare->>Compare: compute measurement_validity, prompt_contract
    Compare->>Summary: format readiness + prompt_contract lines
    Summary-->>CLI: summary with assessment markers
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • mohanagy/madar#393: Reuses the same graphPath-threaded, confidence-reason-based runtime pack evidence/assessment flow (assessMadarResponseEvidence in context-pack-command.ts and mcp-response-evidence.ts).
  • mohanagy/madar#392: Adds the same benchmark-readiness preflight plumbing for native_agent compare—BenchmarkReadinessError, assessBenchmarkReadinessFromRetrieveResult, and strict-readiness CLI wiring.
  • mohanagy/madar#394: Implements the same "answer-ready explain pack" contract additions—ContextPackExplainAnswerReadySummary and generateAnswerReadyFromExecutionSlice(...).

Poem

🐰 We've shuffled the cards and dealt a new hand,
With readiness checks and evidence grand,
Answer outlines polished to shine,
GraphPaths threaded through the design,
Timeouts taming the native-agent sand! 🕐

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is completely empty except for the template structure; no summary, testing details, or rationale for changes are provided. Fill in the Summary section explaining what changed and why, add specific testing verification steps, and reference related issues if applicable.
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.
Title check ❓ Inconclusive The title 'Next' is vague and generic, providing no meaningful information about the changeset's primary purpose or scope. Use a descriptive title summarizing the main change, such as 'Add benchmark readiness checks and answer-ready feature for explain packs' or 'Implement native-agent compare enhancements with readiness assessment'.
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch next

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: 9

🧹 Nitpick comments (1)
tests/unit/compare-native-agent.test.ts (1)

638-638: ⚡ Quick win

Avoid hard-coded run-directory names in the strict-readiness test.

Line 638 assumes an exact timestamp folder format, which makes this assertion brittle if output naming changes (e.g., with/without trailing Z). Resolve the generated run directory dynamically from outputDir before reading report.json.

Proposed test-hardening change
-      const reportPath = join(outputDir, '2026-05-01T00-00-00', 'report.json')
+      const runDirs = readdirSync(outputDir).sort()
+      expect(runDirs.length).toBeGreaterThan(0)
+      const reportPath = join(outputDir, runDirs[0]!, 'report.json')
🤖 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 `@tests/unit/compare-native-agent.test.ts` at line 638, The test currently
builds a brittle hard-coded reportPath using a fixed timestamp folder; instead
locate the generated run directory dynamically under outputDir (e.g., read
entries in outputDir, select the single run directory or the most recent
directory), then construct reportPath by joining outputDir, that discovered run
folder name, and 'report.json'; update the code that references reportPath to
use this dynamically discovered path (referencing the existing variables
reportPath and outputDir in the test).
🤖 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 `@docs/benchmarks/regression/0.27.0-next.4-govalidate-explain/report.json`:
- Around line 192-193: The report.json contains machine-specific absolute paths
in baseline.result_path and madar.result_path; update the serializer used by the
compare pipeline (see src/infrastructure/compare.ts) to emit
share-safe/normalized paths (e.g., relative or canonicalized artifact IDs)
instead of full user-local absolute paths, then regenerate docs/benchmarks/*
report.json via the CLI output pipeline rather than manual edits so the
published artifact contains sanitized, portable paths; ensure the compare.ts
serialization branch that produces baseline.result_path and madar.result_path is
the one changed and tested.

In `@docs/proof-workflows.md`:
- Line 63: Update the artifact list entry for run-state.json to indicate it is
produced only on timeout (i.e., make `run-state.json` timeout-conditional) so
the docs match the description on line 47 that it is written on timeout; locate
the artifact list where `run-state.json` is currently listed unconditionally and
change the wording to something like "run-state.json (created on timeout)" or
add a conditional note next to `run-state.json`.

In `@README.md`:
- Around line 91-98: Update the README “What’s new” heading and changelog link
to reflect the new release version: change the heading text "## What's new in
0.27.1" to "## What's new in 0.27.2" and update the changelog link text and
anchor from `CHANGELOG.md#0271---2026-05-28` (and any other occurrences of
0.27.1 in this block, e.g. the second occurrence at lines ~105-106) to the
corresponding `0.27.2` entry (e.g. `CHANGELOG.md#0272---<date>`) so the heading
and link consistently point to the 0.27.2 release notes.

In `@src/infrastructure/compare.ts`:
- Around line 1621-1636: The function suggestBenchmarkGraphScope fails for
absolute or Windows paths; normalize both graphPath and each sourceFile to
repo-relative POSIX-style paths before extracting the scope and comparing
suffixes. In suggestBenchmarkGraphScope, for each sourceFile use
path.relative(process.cwd(), sourceFile) (or path.relative(repoRoot, ...)) and
replace backslashes with forward slashes, then split that normalized value to
get the scope; likewise normalize graphPath to a POSIX-style path (convert
backslashes and make it relative if absolute) before testing
graphPath.endsWith(`/${suggested}`) so scope inference works for absolute and
Windows paths.
- Around line 3057-3089: The timeout handler in runNativeAgentArmWithTimeout
currently aborts the runner and resolves immediately, causing reporting to
proceed before the arm process has actually exited; change the timeout branch so
that after controller.abort() you wait for the runnerPromise to settle (use
runnerPromise.then/.catch or await inside an async helper) before calling
cleanup() and resolveExecution({ kind: 'timed_out' }); keep the existing settled
flag and ensure any errors from runnerPromise are swallowed or logged but do not
cause a different resolution.
- Around line 3312-3355: The assessment in assessNativeAgentPromptContract
currently treats any post-pack broad exploration
(report.madar_trace.broad_exploration_tool_call_count > 0) as an automatic
violation; instead, if the trace model doesn’t capture the justification (e.g.,
directives like 'missing_context' or 'coverage_gap' in
report.madar_trace.agent_directive_seen), return 'not_measured' rather than
'violated'. Update the logic around
report.madar_trace.broad_exploration_tool_call_count (and the directives Set) in
assessNativeAgentPromptContract so that post-pack broad searches only produce a
violation when there is explicit evidence they were disallowed, otherwise mark
them not_measured (or skip adding violation evidence) to avoid false failures.

In `@src/runtime/mcp-response-evidence.ts`:
- Around line 128-145: coveredWorkflowOwners may contain absolute paths so the
current logic in the candidateScopes mapping misclassifies scopes by taking the
first split segment; update the mapping in the candidateScopes computation (the
block using normalizeSourcePath, GENERIC_SCOPE_WRAPPERS and
GENERIC_SCOPE_SEGMENTS) to detect and skip absolute path prefixes: ignore empty
first segments created by leading slashes and ignore Windows drive-letter
segments like "C:" before selecting the scope segment (still applying the
GENERIC_SCOPE_WRAPPERS rule to the next segment), thereby ensuring the chosen
scope is the true subproject directory rather than "repo" or "C:".

In `@tests/unit/answer-ready-explain-pack.test.ts`:
- Around line 203-219: Rename the test description to reflect that
generateAnswerReadyFromExecutionSlice returns a defined fallback structure (not
undefined); update the test title string from
"generateAnswerReadyFromExecutionSlice returns undefined when no citeable steps
exist" to something like "generateAnswerReadyFromExecutionSlice returns fallback
outline with empty must_cite when no citeable steps exist" so it matches the
assertions checking result is defined, must_cite length is 0, and answer_outline
equals ['Flow execution traced'].

In `@tests/unit/compare-native-agent.test.ts`:
- Around line 1388-1390: The test uses a very short 100ms fallback Promise (new
Promise<{ kind: 'hung' }>((resolve) => setTimeout(() => resolve({ kind: 'hung'
}), 100))) which can flake on slow CI; increase the hang-sentinel timeout to a
larger value (e.g., 500–1000ms) in both occurrences (the Promise at the snippet
and the similar one around lines 1454-1456) so the race has a wider window and
CI stability improves.

---

Nitpick comments:
In `@tests/unit/compare-native-agent.test.ts`:
- Line 638: The test currently builds a brittle hard-coded reportPath using a
fixed timestamp folder; instead locate the generated run directory dynamically
under outputDir (e.g., read entries in outputDir, select the single run
directory or the most recent directory), then construct reportPath by joining
outputDir, that discovered run folder name, and 'report.json'; update the code
that references reportPath to use this dynamically discovered path (referencing
the existing variables reportPath and outputDir in the test).
🪄 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: 2103b756-c5c3-4483-ab34-0bf9d34b89f7

📥 Commits

Reviewing files that changed from the base of the PR and between 1f27d5b and 7528044.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (32)
  • CHANGELOG.md
  • README.md
  • docs/benchmarks/regression/0.27.0-next.4-govalidate-explain/baseline-answer.txt
  • docs/benchmarks/regression/0.27.0-next.4-govalidate-explain/madar-answer.txt
  • docs/benchmarks/regression/0.27.0-next.4-govalidate-explain/native_agent-prompt.txt
  • docs/benchmarks/regression/0.27.0-next.4-govalidate-explain/report.json
  • docs/benchmarks/regression/0.27.0-next.4-govalidate-explain/report.share-safe.json
  • docs/claims-and-evidence.md
  • docs/proof-workflows.md
  • examples/why-madar.md
  • package.json
  • src/cli/main.ts
  • src/cli/parser.ts
  • src/contracts/context-pack.ts
  • src/infrastructure/benchmark/runner.ts
  • src/infrastructure/compare.ts
  • src/infrastructure/context-pack-command.ts
  • src/infrastructure/context-prompt-command.ts
  • src/runtime/context-pack.ts
  • src/runtime/graph-summary.ts
  • src/runtime/mcp-response-evidence.ts
  • src/runtime/stdio/tools.ts
  • tests/unit/answer-ready-explain-pack.test.ts
  • tests/unit/benchmark-suite.test.ts
  • tests/unit/cli.test.ts
  • tests/unit/compare-native-agent.test.ts
  • tests/unit/compare.test.ts
  • tests/unit/context-pack-command.test.ts
  • tests/unit/graph-summary.test.ts
  • tests/unit/mcp-response-evidence.test.ts
  • tests/unit/pipeline.test.ts
  • tests/unit/stdio-slice-surface.test.ts

Comment on lines +192 to +193
"result_path": "/Users/mohammednaji/Desktop/projects/works/govalidate/backend/out/compare/2026-05-27T17-11-56/baseline-answer.txt"
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Avoid committing machine-specific absolute paths in published benchmark receipts.

baseline.result_path and madar.result_path include local absolute paths (including username), which leaks host-specific data and makes the artifact non-portable. Please emit docs-published report.json from the share-safe serialization path and regenerate this artifact from the CLI output pipeline.

Based on learnings: benchmark artifacts under docs/benchmarks/ should be regenerated from serializer behavior changes in src/infrastructure/compare.ts, not manually edited in-place.

Also applies to: 233-234

🤖 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 `@docs/benchmarks/regression/0.27.0-next.4-govalidate-explain/report.json`
around lines 192 - 193, The report.json contains machine-specific absolute paths
in baseline.result_path and madar.result_path; update the serializer used by the
compare pipeline (see src/infrastructure/compare.ts) to emit
share-safe/normalized paths (e.g., relative or canonicalized artifact IDs)
instead of full user-local absolute paths, then regenerate docs/benchmarks/*
report.json via the CLI output pipeline rather than manual edits so the
published artifact contains sanitized, portable paths; ensure the compare.ts
serialization branch that produces baseline.result_path and madar.result_path is
the one changed and tested.

Comment thread docs/proof-workflows.md Resolved
Comment thread README.md Resolved
Comment thread src/infrastructure/compare.ts Resolved
Comment thread src/infrastructure/compare.ts Resolved
Comment thread src/infrastructure/compare.ts Resolved
Comment thread src/runtime/mcp-response-evidence.ts Resolved
Comment thread tests/unit/compare-native-agent.test.ts Resolved
Resolve conflicts between v0.27.3 release features and next branch features.
- Keep next's strictMadarFirst, strictBenchmarkReadiness, prompt_contract, benchmark_readiness features
- Keep main's v0.27.3 additions: NativeAgentBenchmarkCheckStatus, benchmarkMetricStatus, buildAnswerReadyPackSchema, claim_assessment, benchmark_outcome
- Merge CHANGELOG.md with both sets of entries
- Add createBackendRuntimeGraphPath helper to stdio-slice-surface.test.ts

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

@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: 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/context-pack-command.ts (1)

1250-1267: ⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Keep compact answer-ready JSON opt-in.

--format json now stops returning the full ContextPackSchemaV1 shape for explain unless callers also know to pass --verbose. That is a breaking contract change for existing machine consumers, because fields disappear under the same json mode. Please gate the compact shape behind an explicit format/flag instead of overloading the default JSON output.

🤖 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/context-pack-command.ts` around lines 1250 - 1267,
renderContextPackOutput currently returns a compact answer-ready JSON for
'explain' when called with --format json unless --verbose is passed, which
breaks callers; change the logic so 'json' always returns the full
PackSchemaEnvelope, and introduce an explicit format (e.g. 'json-compact' or
'compact-json') or a dedicated option flag to produce the compact shape. Update
ContextPackFormat to include the new token, add a new case in the switch (e.g.
case 'json-compact': return JSON.stringify(buildAnswerReadyPackSchema(schema,
schema.budget))) and keep the existing buildAnswerReadyPackSchema(schema,
schema.budget) usage; leave the 'json' and undefined case to always stringify
the full schema (or respect options.verbose when true). Ensure callers can opt
into compact output via the new format/flag.
🧹 Nitpick comments (1)
src/infrastructure/context-pack-command.ts (1)

300-344: ⚡ Quick win

Trim the remaining top-level guidance lists in the over-budget path.

Once plan and coverage are gone, non-empty likely_edit_files, likely_test_files, public_contracts, risk_boundaries, and validation_commands still stay unbounded. A large implementation-guidance section can therefore keep serialized_budget.enforced=false even after most of the expensive graph data has been dropped.

♻️ Suggested tightening
   for (const field of [
     'claims',
     'expandable',
     'likely_edit_files',
     'likely_test_files',
     'public_contracts',
     'risk_boundaries',
     'validation_commands',
   ]) {
     deleteEmptyArrayField(payload, field, trimmedFields)
   }
   attachSerializedBudget(payload, maxTokens, trimmedFields)
   if (estimatedJsonTokens(payload) <= maxTokens) {
     return payload
   }

+  trimArrayField(payload, 'likely_edit_files', 3, trimmedFields)
+  trimArrayField(payload, 'likely_test_files', 3, trimmedFields)
+  trimArrayField(payload, 'public_contracts', 4, trimmedFields)
+  trimArrayField(payload, 'risk_boundaries', 4, trimmedFields)
+  trimArrayField(payload, 'validation_commands', 4, trimmedFields)
+
   if (pack) {
     trimArrayField(pack, 'matched_nodes', 4, trimmedFields)
     trimArrayField(pack, 'relationships', 4, trimmedFields)
     trimArrayField(pack, 'community_context', 3, trimmedFields)
   }
🤖 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/context-pack-command.ts` around lines 300 - 344, The
over-budget fallback still leaves large top-level guidance arrays
(likely_edit_files, likely_test_files, public_contracts, risk_boundaries,
validation_commands) untrimmed; update the over-budget branch in the function
where trimArrayField, attachSerializedBudget, estimatedJsonTokens, payload,
pack, and trimmedFields are used to additionally call trimArrayField on those
five fields (e.g., trimArrayField(payload, 'likely_edit_files', 3,
trimmedFields) etc.) before the final attachSerializedBudget/return so those
lists are bounded when estimating tokens.
🤖 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/context-pack-command.ts`:
- Around line 1250-1267: renderContextPackOutput currently returns a compact
answer-ready JSON for 'explain' when called with --format json unless --verbose
is passed, which breaks callers; change the logic so 'json' always returns the
full PackSchemaEnvelope, and introduce an explicit format (e.g. 'json-compact'
or 'compact-json') or a dedicated option flag to produce the compact shape.
Update ContextPackFormat to include the new token, add a new case in the switch
(e.g. case 'json-compact': return
JSON.stringify(buildAnswerReadyPackSchema(schema, schema.budget))) and keep the
existing buildAnswerReadyPackSchema(schema, schema.budget) usage; leave the
'json' and undefined case to always stringify the full schema (or respect
options.verbose when true). Ensure callers can opt into compact output via the
new format/flag.

---

Nitpick comments:
In `@src/infrastructure/context-pack-command.ts`:
- Around line 300-344: The over-budget fallback still leaves large top-level
guidance arrays (likely_edit_files, likely_test_files, public_contracts,
risk_boundaries, validation_commands) untrimmed; update the over-budget branch
in the function where trimArrayField, attachSerializedBudget,
estimatedJsonTokens, payload, pack, and trimmedFields are used to additionally
call trimArrayField on those five fields (e.g., trimArrayField(payload,
'likely_edit_files', 3, trimmedFields) etc.) before the final
attachSerializedBudget/return so those lists are bounded when estimating tokens.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 9f9a9bdd-bffd-4210-b67c-c4e4787f2464

📥 Commits

Reviewing files that changed from the base of the PR and between 7528044 and db1cfa9.

📒 Files selected for processing (9)
  • src/cli/parser.ts
  • src/contracts/context-pack.ts
  • src/infrastructure/compare.ts
  • src/infrastructure/context-pack-command.ts
  • src/runtime/stdio/tools.ts
  • tests/unit/compare-native-agent.test.ts
  • tests/unit/compare.test.ts
  • tests/unit/context-pack-command.test.ts
  • tests/unit/stdio-slice-surface.test.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • tests/unit/stdio-slice-surface.test.ts
  • src/contracts/context-pack.ts
  • tests/unit/context-pack-command.test.ts
  • src/runtime/stdio/tools.ts
  • tests/unit/compare-native-agent.test.ts
  • src/infrastructure/compare.ts

- Fix suggestBenchmarkGraphScope to normalize absolute source_file paths
  before extracting scope segment, preventing misclassification on
  backend-runtime fixtures and Windows paths
- Fix runNativeAgentArmWithTimeout to wait for runner to settle after abort
  (200ms grace period); prevents reporting before arm process exits, while
  still resolving for runners that ignore the abort signal
- Fix assessNativeAgentPromptContract to return not_measured instead of
  violated when post-pack broad exploration is detected, since the trace
  model does not capture whether missing_context justified it
- Fix mcp-response-evidence.ts candidateScopes to handle absolute and
  Windows-style source_file paths using GENERIC_SCOPE_SEGMENTS detection
- Mark run-state.json as timeout-conditional in docs/proof-workflows.md
- Update README What's new version label from 0.27.1 to 0.27.3
- Fix non-null assertion for input.signal in compare-native-agent.test.ts

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mohanagy
mohanagy merged commit f4d9ae7 into main 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