feat(#339): add GRACE semantic code-contract anchor eval (slice 1)#375
Conversation
Pure data + deterministic-logic layer for the GRACE eval harness. No external model calls in this slice. - grace_eval/schema.py: GraceFixture, VariantRunRecord, VariantAggregate, SweepFinding, GraceReport, aggregate_runs(), make_run_id() — six variants (baseline, inline, lex, min, inj, lie) with variant-set classification, per-run JSONL row schema, rolled-up stats, and vs-baseline delta notes (improvement/regression/tie/no_baseline). - grace_eval/sweep.py: sweep_source() / sweep_variant_sources() — heuristic stale-anchor detection via CONTRACT/ANCHOR comment patterns with 7 contradiction signal pairs and an 8-line lookahead window. - 97 tests across test_grace_eval_schema.py + test_grace_eval_sweep.py. - docs/ARCHITECTURE.md: mark #339 closed (slice 1). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011jmbBkJwJByEJGXFAihgh8
|
Warning Review limit reached
Next review available in: 52 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
src/mapify_cli/grace_eval/package implementing the data contracts and deterministic sweep logic for the GRACE semantic code-contract anchor evaluation (issue [GRACE] Add semantic code-contract anchor eval for bug-fix workflows #339, slice 1).Changes
src/mapify_cli/grace_eval/schema.pyData contracts (contract-first pattern, all consumers import from here):
GraceFixture— fixture.json schema (fixture_id, title, description, bug_summary, expected_changed_files, tags)VariantRunRecord— per-run JSONL row (success, retry_count, total_tokens, output_tokens, repeated_reads, stale_detection, error)VariantAggregate— rolled-up stats per variant with vs-baseline delta fields and trajectory_delta_note (improvement/regression/tie/no_baseline)SweepFinding— frozen dataclass for one stale/contradictory contract detection (severity, location, detail, variant)GraceReport— root report object (aggregates list, sweep_findings, schema_version, generated_at)baseline,inline,lex,min,inj,lie; classified intoCODE_LOCAL_VARIANTS,PROMPT_INJECTED_VARIANTS,NO_ANCHOR_VARIANTSaggregate_runs()— computes success_rate, mean_retries, mean_total_tokens, stale_detections, and trajectory delta vs baselinemake_run_id()— deterministic run identifiersrc/mapify_cli/grace_eval/sweep.pyHeuristic stale-anchor detection (pure, no I/O, no subprocess):
# CONTRACT: <claim>and# ANCHOR: <claim>comment patterns (case-insensitive)return None, "idempotent" +.append()sweep_source()— sweeps a single source string, returnsSweepFindinglistsweep_variant_sources()— aggregates across a{location: source}dictsrc/mapify_cli/grace_eval/__init__.pyRe-exports all public symbols.
tests/test_grace_eval_schema.py+tests/test_grace_eval_sweep.py97 tests across 16 test classes (GE1–GE9, GS1–GS7). Cover variant enumeration, all
to_dict/from_dictround-trips, JSON serialisability, validation errors,aggregate_runsstats, baseline delta computation, anchor extraction, contradiction detection, false-positive guard, multi-file sweep aggregation, and invalid-variant rejection.docs/ARCHITECTURE.mdMarks #339 closed (slice 1) with PR reference.
Closes
Resolves #339 (slice 1). Future slices: CLI entry point (
mapify grace-eval run/report), token-log replay, model-call dispatcher, HTML report viewer.Generated by Claude Code