Skip to content

fix(merge): make --allow-plausible actually control track matching#26

Merged
geoffmcc merged 1 commit into
mainfrom
fix/merge-option-contract
Jul 19, 2026
Merged

fix(merge): make --allow-plausible actually control track matching#26
geoffmcc merged 1 commit into
mainfrom
fix/merge-option-contract

Conversation

@geoffmcc

Copy link
Copy Markdown
Owner

Summary

Fixes three defects in the three-way merge option contract. The headline one is that --allow-plausible did nothing.

1. --allow-plausible was inert

_analyze_tracks in src/alscan/merge/analysis.py hardcoded exact_only=False when building its internal matches, then separately computed an exact_only=True set and returned that. Two consequences:

  • Plausible track matching was effectively always on for the analysis body, regardless of the flag.
  • The returned match set (consumed by _analyze_track_order) was a stricter, different set than the one the rest of the analysis used.

Both the CLI and the GUI already exposed the option — src/alscan/gui/workers.py carries an allow_plausible field and the three-way page has a checkbox — so the setting appeared functional at both surfaces while having no effect.

Now a single match set is computed with exact_only=not inputs.allow_plausible and returned consistently. allow_plausible is threaded through ThreeWayInput and validate_three_way.

Behaviour change: default matching is now exact-only. Six tests in tests/test_merge_phase2.py now pass allow_plausible=True to retain their previous assertions.

2. Input role mislabel

validate_three_way iterated [(base_p, "base"), (ours_p, "theirs"), (theirs_p, "theirs")], so a malformed ours snapshot produced an error blaming theirs.

3. --output corrupted argument parsing

In _merge_guide, the --output branch was a bare pass that did not set skip_next. The output filename therefore fell through into clean_args and was parsed as a positional snapshot input. The value is now captured and the following argument skipped.

Also adds unknown-option rejection and a too-many-positional-args guard to both merge guide and merge plan, and removes a dead allow_unrelated_val assignment that was never read.

Tests

Adds tests/test_merge_option_contract.py (504 lines) covering exact-vs-plausible matching, input role labels, and guided-merge argument parsing.

Local verification mirroring ci.yml exactly, including -W error:

  • pytest -W error --ignore=tests/gui — 791 passed
  • QT_QPA_PLATFORM=offscreen pytest -W error -x --timeout=120 --timeout_method=thread tests/gui/ tests/test_services.py — 267 passed

Known gap

--output on merge guide is now parsed correctly but still never used — the value is captured and ignored, so no file is written. This is an improvement on the previous behaviour, which corrupted positional parsing, but the flag remains inert. Tracked separately in #25.

- Gate _match_branch on inputs.allow_plausible in _analyze_tracks; the flag
  was inert because internal matching hardcoded exact_only=False while the
  function returned a separate exact-only match set
- Thread allow_plausible through ThreeWayInput and validate_three_way into
  the CLI merge guide and plan subcommands
- Fix input role label in validate_three_way: a bad ours input reported
  itself as theirs in snapshot validation errors
- Capture the --output value in _merge_guide so the filename is no longer
  parsed as a positional snapshot argument
- Reject unknown options and more than three positional args in merge
  guide and plan
- Add tests/test_merge_option_contract.py covering the option contract,
  input role labels, and guided-merge argument parsing

Default matching is now exact-only; six tests in test_merge_phase2.py
pass allow_plausible=True to retain their prior assertions.
@geoffmcc
geoffmcc merged commit 71901a3 into main Jul 19, 2026
8 checks passed
@geoffmcc
geoffmcc deleted the fix/merge-option-contract branch July 19, 2026 15:41
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