Skip to content

Commit 50b389d

Browse files
rcursoragent
andcommitted
v0.42.0: eval-suite plumbing through ref-mode merge rebuild
The reference-mode merge rebuild path now propagates the user's eval suite, pipeline, and metric-retirement decisions onto the mirrored merge commit instead of leaving them as the empty placeholders sync_one_commit originally planted. Ten previously ignored acceptance specs unblock as a consequence. Added ----- - `morph_core::rebuild_merge_commit` + `MergeRebuildOpts`. After `sync_to_head_with_origin` mirrors the merge commit, the rebuild helper re-derives the commit using the MergePlan's auto-union eval suite, the user's --pipeline / --eval-suite / --metrics, and any retired metrics, then re-points the branch ref onto the rewritten hash. Same recipe the non-merge `morph commit` rewrite already used. - `MERGE_REF.json` now carries pipeline / eval_suite / retired_metrics / retire_reason across the conflict boundary so `morph merge --continue` reproduces the same plan a single-shot merge would have used. - `MergePlan::head_commit()` / `other_commit()` accessors. - `auto_detect_introduces_cases()` in `morph_core::annotate`. `morph commit` (without --new-cases) now diffs the about-to-commit eval suite against the first-parent's suite and auto-records the case-id difference as an `introduces_cases` annotation. `--new-cases ""` is the explicit opt-out; `--new-cases "manual:override"` keeps the manual override path. - `morph_core::ensure_review_node_for_retirement` is now public. Fixed ----- - `morph merge` propagates the auto-union eval suite onto the merged commit; the dominance check now finds violations on subsequent merges and rejects with the parent name on stderr (`current: acc 0.9 → 0.87`). - `morph merge --retire <metric>` writes a real review node attributing the retirement to the merge author. - `morph merge --retire` survives a textual conflict — the retire intent flows through MERGE_REF.json to `--continue`. Tests ----- Ten previously-`#[ignore]`'d specs flip green: - 3 in merge.yaml (auto-union, reject-with-explained-failure, retirement-succeeds) - 3 in merge_retire_review.yaml (synthesise/default-reason/ no-resynthesis) - 3 in merge_retire_stateful.yaml (clean-three-way, conflict- then-continue, abort-clears-breadcrumb; the latter two also rewritten for v0.40+ stderr-shaped conflict UX) - commit_auto_detects_new_cases_added_to_default_suite Run / metrics ------------- - recorded eval run: `44f34acb403f2bee…` metrics: tests_passed=1184, tests_total=1187, tests_ignored=3, pass_rate=0.997, wall_time_secs=34.31 - 3 specs remain `#[ignore]` (mixed_authorship.yaml), scheduled for v0.42.1 — mixed-authorship plumbing (human_edits diff, contributor stamping) on the rebuild path. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent c1186ab commit 50b389d

15 files changed

Lines changed: 540 additions & 210 deletions

‎CHANGELOG.md‎

Lines changed: 96 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,100 @@ metrics — see `.cursor/rules/behavioral-commits.mdc`.
1616

1717
## [Unreleased]
1818

19+
## [0.42.0] — 2026-05-01
20+
21+
The reference-mode merge rebuild path now propagates the user's
22+
eval suite, pipeline, and metric-retirement decisions onto the
23+
mirrored merge commit instead of leaving them as the empty
24+
placeholders `sync_one_commit` originally planted. Ten previously
25+
`#[ignore]`'d acceptance specs unblock as a consequence — the
26+
merge gate has real evidence to enforce on every ref-mode merge,
27+
single-shot or stateful.
28+
29+
### Added
30+
31+
- **`morph_core::rebuild_merge_commit`** + **`MergeRebuildOpts`**.
32+
After `sync_to_head_with_origin` mirrors the new merge commit,
33+
`rebuild_merge_commit` re-derives the commit object using the
34+
`MergePlan`'s auto-union eval suite, the user's `--pipeline` /
35+
`--eval-suite` / `--metrics`, and any retired metrics, then
36+
re-points the branch ref onto the rewritten hash. Same recipe
37+
the non-merge `morph commit` rewrite already used; consolidating
38+
it under one helper keeps the single-shot and `--continue` paths
39+
aligned. The original mirror commit becomes a content-addressable
40+
orphan — harmless because no ref points at it anymore.
41+
- **`MERGE_REF.json` carries merge context across the conflict
42+
boundary.** `ReferenceMergeBreadcrumb` now records the user's
43+
`--pipeline`, `--eval-suite`, `--retire`, and `--retire-reason`
44+
so `morph merge --continue` reproduces the same plan a
45+
single-shot merge would have used. Earlier versions dropped
46+
the retire intent on conflict, so resuming a textually-conflicted
47+
merge silently lost the retirement and review-node attribution.
48+
- **`MergePlan::head_commit()` / `other_commit()` accessors** on
49+
the public merge API so callers (the new rebuild helper, future
50+
inspection tooling) can read parent commit fields without the
51+
plan having to re-fetch them. Internal storage stays private;
52+
only borrows are exposed.
53+
- **`auto_detect_introduces_cases()` in `morph_core::annotate`.**
54+
`morph commit` (without `--new-cases`) now diffs the
55+
about-to-commit eval suite against the first-parent's suite and
56+
auto-records the case-id difference as an `introduces_cases`
57+
annotation. `--new-cases ""` is the explicit opt-out;
58+
`--new-cases "manual:override"` keeps the manual override path.
59+
Mirrors the merge gate's own case-attribution model so a commit
60+
that introduces a new acceptance case is auditable without the
61+
user having to type the case id twice.
62+
- **`morph_core::ensure_review_node_for_retirement` is now
63+
public** so the new rebuild helper can synthesise the same
64+
attributed review node the standalone-mode merge engine
65+
produced, attribuing the retirement to the merge author.
66+
67+
### Fixed
68+
69+
- **`morph merge` propagates the auto-union eval suite onto the
70+
merged commit.** The dominance check used to fire before
71+
`git merge` ran (correct), but the rebuild used the empty
72+
placeholder suite `sync_one_commit` planted, so the resulting
73+
merge commit had no claim. The merge gate had nothing to
74+
enforce on subsequent merges into the same branch.
75+
- **`morph merge --retire <metric>` writes a real review node.**
76+
The single-shot and `--continue` paths both now run
77+
`ensure_review_node_for_retirement` against the head pipeline
78+
(or the user's `--pipeline` override) and replace the merge
79+
commit's pipeline with the result. Retirement attribution and
80+
reason text land in the rewritten pipeline's review-node
81+
`params.reason`.
82+
- **`morph merge --retire` survives a textual conflict.** The
83+
retire intent and reason now flow through `MERGE_REF.json` to
84+
`morph merge --continue`, which applies the same rebuild a
85+
single-shot merge would have applied. Earlier versions
86+
silently dropped the retirement when the merge dropped into
87+
the conflict path.
88+
- **Weak merge metrics are rejected with the parent name on
89+
stderr.** Now that the rebuild propagates the union suite onto
90+
parents' commits, `MergePlan::check_dominance` finds the
91+
expected violations (e.g. `current: acc 0.9 → 0.87`) and
92+
surfaces them on the merge-rejection error message.
93+
94+
### Tests
95+
96+
Ten previously `#[ignore]`'d specs now run as part of the default
97+
`cargo test --workspace`. All ten flip green:
98+
- `merge.yaml`: `merge_auto_union_suite_happy_path`,
99+
`merge_rejects_with_explained_metric_failure`,
100+
`merge_with_retirement_succeeds`.
101+
- `merge_retire_review.yaml`: `merge_retire_synthesizes_review_node`,
102+
`merge_retire_default_reason_when_omitted`,
103+
`merge_retire_with_existing_review_node_no_resynthesis`.
104+
- `merge_retire_stateful.yaml`: `merge_stateful_retire_clean_three_way_synthesizes_review_node`,
105+
`merge_stateful_retire_with_textual_conflict_then_continue`,
106+
`merge_stateful_retire_abort_clears_breadcrumb` (the latter two
107+
also rewritten for v0.40+ stderr-shaped conflict UX).
108+
- `commit_auto_new_cases.yaml`: `commit_auto_detects_new_cases_added_to_default_suite`.
109+
110+
Three `#[ignore]`'d specs remain, all in the mixed-authorship
111+
plumbing bucket (`mixed_authorship.yaml`), scheduled for v0.42.1.
112+
19113
## [0.41.1] — 2026-05-01
20114

21115
Three reference-mode merge UX fixes triaged out of the v0.40 ignored
@@ -827,7 +921,8 @@ Three coordinated changes to repo setup, adoption, and migration.
827921
- 15 new YAML acceptance spec cases in the default eval suite:
828922
`init_at_latest:*` ×4, `init_in_git_dir:*` ×6, `upgrade:*` ×5.
829923

830-
[Unreleased]: https://github.com/r/morph/compare/v0.41.1...HEAD
924+
[Unreleased]: https://github.com/r/morph/compare/v0.42.0...HEAD
925+
[0.42.0]: https://github.com/r/morph/compare/v0.41.1...v0.42.0
831926
[0.41.1]: https://github.com/r/morph/compare/v0.41.0...v0.41.1
832927
[0.41.0]: https://github.com/r/morph/compare/v0.40.2...v0.41.0
833928
[0.40.2]: https://github.com/r/morph/compare/v0.40.1...v0.40.2

‎Cargo.lock‎

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ resolver = "2"
33
members = ["morph-core", "morph-cli", "morph-mcp", "morph-serve", "morph-e2e"]
44

55
[workspace.package]
6-
version = "0.41.1"
6+
version = "0.42.0"

‎morph-cli/src/main.rs‎

Lines changed: 121 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -606,14 +606,37 @@ fn run_reference_commit(
606606
}
607607
}
608608

609-
if let Some(arg) = new_cases {
610-
let cases = morph_core::parse_introduces_cases_arg(arg);
611-
let branch = morph_core::current_branch(store)?;
612-
if let Some(ann) =
613-
morph_core::build_introduces_cases_annotation(&new_morph_hash, &cases, branch)
614-
{
615-
store.put(&ann)?;
609+
// v0.42: `--new-cases` selection.
610+
// * `--new-cases "a,b"` → record exactly those ids (manual
611+
// override).
612+
// * `--new-cases ""` → explicit opt-out, skip auto-detect.
613+
// * Flag absent → diff the about-to-commit suite against the
614+
// first-parent's suite and auto-record the difference. The
615+
// diff lets the merge gate attribute new acceptance cases
616+
// to this commit without the user typing them out.
617+
let auto_cases: Vec<String> = match new_cases {
618+
Some(arg) => morph_core::parse_introduces_cases_arg(arg),
619+
None => {
620+
let parent_hash = match store.get(&new_morph_hash)? {
621+
morph_core::MorphObject::Commit(c) => c
622+
.parents
623+
.first()
624+
.and_then(|p| morph_core::Hash::from_hex(p).ok()),
625+
_ => None,
626+
};
627+
let suite = match store.get(&new_morph_hash)? {
628+
morph_core::MorphObject::Commit(c) => c.eval_contract.suite.clone(),
629+
_ => String::new(),
630+
};
631+
morph_core::auto_detect_introduces_cases(store, parent_hash.as_ref(), &suite)
632+
.unwrap_or_default()
616633
}
634+
};
635+
let branch = morph_core::current_branch(store)?;
636+
if let Some(ann) =
637+
morph_core::build_introduces_cases_annotation(&new_morph_hash, &auto_cases, branch)
638+
{
639+
store.put(&ann)?;
617640
}
618641

619642
// Clear the morph staging index after a successful reference-mode
@@ -765,11 +788,10 @@ fn run_reference_merge(
765788
eval_suite: Option<String>,
766789
metrics: Option<String>,
767790
message: Option<String>,
768-
_author: Option<String>,
791+
author: Option<String>,
769792
retire: Option<String>,
770793
retire_reason: Option<String>,
771794
) -> anyhow::Result<()> {
772-
let _ = pipeline;
773795
let version = read_repo_version(morph_dir)?;
774796
let bare_branch = branch.strip_prefix("heads/").unwrap_or(branch);
775797

@@ -785,6 +807,14 @@ fn run_reference_merge(
785807
.as_deref()
786808
.map(|s| resolve_obj_hash(store, s))
787809
.transpose()?;
810+
// Resolve the user-supplied --pipeline argument (a hash or a
811+
// short prefix) once so both the rebuild and the breadcrumb
812+
// record the canonical 64-char hex.
813+
let user_pipeline_hash: Option<String> = pipeline
814+
.as_deref()
815+
.map(|s| resolve_obj_hash(store, s))
816+
.transpose()?
817+
.map(|h| h.to_string());
788818
let retired: Option<Vec<String>> = retire
789819
.as_deref()
790820
.map(|s| s.split(',').map(|m| m.trim().to_string()).collect());
@@ -794,9 +824,20 @@ fn run_reference_merge(
794824
suite_hash_opt.as_ref(),
795825
retired.as_deref(),
796826
)?;
797-
plan.retire_reason = retire_reason;
827+
plan.retire_reason = retire_reason.clone();
798828
warn_when_no_morph_claim(store, &plan);
799829

830+
// Author drives the synthesised review-node attribution (when
831+
// `--retire` is in play). Resolve through morph's identity
832+
// chain so review nodes carry the same identity as commit
833+
// authors. Fall back to "morph-cli" only when absolutely no
834+
// identity can be established — review-node attribution is
835+
// user-visible and a meaningful identity is always preferred.
836+
let resolved_author = morph_core::resolve_author_for_repo(morph_dir, author.as_deref())
837+
.ok()
838+
.filter(|s| !s.is_empty())
839+
.unwrap_or_else(|| "morph-cli".to_string());
840+
800841
if let Some(ref obs) = observed {
801842
let dominance = plan.check_dominance(obs);
802843
if !dominance.passed {
@@ -847,12 +888,28 @@ fn run_reference_merge(
847888
"cli",
848889
Some(&version),
849890
)?;
850-
let new_morph = sync_outcome.new_commit.ok_or_else(|| {
891+
let mirrored = sync_outcome.new_commit.ok_or_else(|| {
851892
anyhow::anyhow!(
852893
"git merge {} did not produce a new morph commit",
853894
&new_head[..new_head.len().min(12)]
854895
)
855896
})?;
897+
// v0.42: rebuild the mirror commit so it carries the
898+
// user's (or auto-union'd) eval suite, pipeline, and
899+
// retired-metrics decision instead of `sync_one_commit`'s
900+
// empty placeholders. Without this, the merge gate has
901+
// nothing to enforce and metric-retirement / review-node
902+
// attribution silently disappear.
903+
let opts = morph_core::MergeRebuildOpts {
904+
user_pipeline: user_pipeline_hash.clone(),
905+
user_eval_suite: suite_hash_opt.as_ref().map(|h| h.to_string()),
906+
user_metrics: observed.clone().unwrap_or_default(),
907+
retired_metrics: retired.clone().unwrap_or_default(),
908+
retire_reason: plan.retire_reason.clone(),
909+
author: resolved_author.clone(),
910+
morph_instance: morph_core::read_instance_id(morph_dir).ok().flatten(),
911+
};
912+
let new_morph = morph_core::rebuild_merge_commit(store, &mirrored, &plan, &opts)?;
856913
if let Some(obs) = observed {
857914
let cert = morph_core::certify_commit(
858915
store, morph_dir, &new_morph, &obs, None, None,
@@ -886,6 +943,10 @@ fn run_reference_merge(
886943
other_git_sha,
887944
head_git_sha,
888945
message: merge_message.clone(),
946+
pipeline: user_pipeline_hash.clone(),
947+
eval_suite: suite_hash_opt.as_ref().map(|h| h.to_string()),
948+
retired_metrics: retired.clone().unwrap_or_default(),
949+
retire_reason: plan.retire_reason.clone(),
889950
};
890951
morph_core::write_merge_breadcrumb(morph_dir, &breadcrumb)?;
891952
eprintln!(
@@ -920,7 +981,7 @@ fn run_reference_merge_continue(
920981
repo_root: &std::path::Path,
921982
message_override: Option<String>,
922983
metrics: Option<String>,
923-
_author: Option<String>,
984+
author: Option<String>,
924985
) -> anyhow::Result<()> {
925986
let breadcrumb = morph_core::read_merge_breadcrumb(morph_dir)?
926987
.ok_or_else(|| anyhow::anyhow!(
@@ -946,6 +1007,30 @@ fn run_reference_merge_continue(
9461007
let version = read_repo_version(morph_dir)?;
9471008
let message = message_override.unwrap_or_else(|| breadcrumb.message.clone());
9481009

1010+
// v0.42: rebuild the merge plan up-front. Calling `prepare_merge`
1011+
// here (with the breadcrumb's recorded suite and retired
1012+
// metrics) reproduces the exact union suite + reference bar the
1013+
// user committed to when they started the merge, so
1014+
// `--continue`'s rewrite uses the same shape as the single-shot
1015+
// path. The plan must be computed BEFORE the git commit lands —
1016+
// afterwards HEAD has advanced and `prepare_merge` would see
1017+
// the merged commit as its own ancestor.
1018+
let suite_override_hash = match breadcrumb.eval_suite.as_deref() {
1019+
Some(s) => Some(resolve_obj_hash(store, s)?),
1020+
None => None,
1021+
};
1022+
let mut plan = morph_core::prepare_merge(
1023+
store,
1024+
&breadcrumb.other_branch,
1025+
suite_override_hash.as_ref(),
1026+
if breadcrumb.retired_metrics.is_empty() {
1027+
None
1028+
} else {
1029+
Some(&breadcrumb.retired_metrics[..])
1030+
},
1031+
)?;
1032+
plan.retire_reason = breadcrumb.retire_reason.clone();
1033+
9491034
// Drive `git commit -m <msg>` under MORPH_INTERNAL=1. Git will
9501035
// create the merge commit using `.git/MERGE_HEAD` (still in
9511036
// place since the original `git merge` left it), reusing the
@@ -957,7 +1042,7 @@ fn run_reference_merge_continue(
9571042
// Mirror the new merge commit into morph with origin = "cli".
9581043
let outcome =
9591044
morph_core::sync_to_head_with_origin(store, repo_root, "cli", Some(&version))?;
960-
let new_morph = outcome
1045+
let mirrored = outcome
9611046
.new_commit
9621047
.ok_or_else(|| {
9631048
anyhow::anyhow!(
@@ -966,6 +1051,29 @@ fn run_reference_merge_continue(
9661051
)
9671052
})?;
9681053

1054+
// Apply the same v0.42 rebuild the single-shot path uses so
1055+
// `--continue` finalizes a fully-fledged merge commit (suite,
1056+
// pipeline-with-review-node, observed_metrics, evidence_refs).
1057+
let observed_for_rebuild: std::collections::BTreeMap<String, f64> = match &metrics {
1058+
Some(m) => serde_json::from_str(m)
1059+
.map_err(|e| anyhow::anyhow!("invalid --metrics JSON: {}", e))?,
1060+
None => std::collections::BTreeMap::new(),
1061+
};
1062+
let resolved_author = morph_core::resolve_author_for_repo(morph_dir, author.as_deref())
1063+
.ok()
1064+
.filter(|s| !s.is_empty())
1065+
.unwrap_or_else(|| "morph-cli".to_string());
1066+
let opts = morph_core::MergeRebuildOpts {
1067+
user_pipeline: breadcrumb.pipeline.clone(),
1068+
user_eval_suite: breadcrumb.eval_suite.clone(),
1069+
user_metrics: observed_for_rebuild.clone(),
1070+
retired_metrics: breadcrumb.retired_metrics.clone(),
1071+
retire_reason: breadcrumb.retire_reason.clone(),
1072+
author: resolved_author,
1073+
morph_instance: morph_core::read_instance_id(morph_dir).ok().flatten(),
1074+
};
1075+
let new_morph = morph_core::rebuild_merge_commit(store, &mirrored, &plan, &opts)?;
1076+
9691077
// Optional certification — same code path as the single-shot
9701078
// merge in `run_reference_merge`.
9711079
if let Some(metrics_str) = metrics {

‎morph-cli/tests/specs/commit_auto_new_cases.yaml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
# recorded as an `introduces_cases` annotation pointing at the new
99
# commit.
1010
- name: commit_auto_detects_new_cases_added_to_default_suite
11-
# PR1 v0.40+: ref-mode commit rewrite path doesn't yet diff the
12-
# commit's eval suite against HEAD's to auto-record an
13-
# `introduces_cases` annotation. Tracked for PR2.
14-
skip: "auto-detect new-cases annotation pending PR2"
11+
# v0.42: `morph commit` (without `--new-cases`) now diffs the
12+
# about-to-commit suite against the first-parent's suite and
13+
# auto-records the case-id difference as an `introduces_cases`
14+
# annotation, mirroring the merge gate's case-attribution model.
1515
files:
1616
specs/alpha.yaml: |
1717
- name: alpha

0 commit comments

Comments
 (0)