Repository navigation
HermitCrab: prune copy-agreement matches with an empty copy - #645
Open
johnml1135 wants to merge 3 commits into
Open
johnml1135 wants to merge 3 commits into
johnml1135 wants to merge 3 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #645 +/- ##
=======================================
Coverage 75.53% 75.53%
=======================================
Files 455 455
Lines 38933 38937 +4
Branches 5428 5429 +1
=======================================
+ Hits 29407 29411 +4
Misses 8376 8376
Partials 1150 1150 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
johnml1135
marked this pull request as ready for review
November 13, 2026 13:08
…other is not Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t does not reduplicate Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s the optional-node test keeps Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
johnml1135
force-pushed
the
fix/634-empty-copy-prune
branch
from
November 20, 2026 15:36
b8fe5b4 to
ae2dbb1
Compare
Contributor
Public API, target framework, package, and Findings: F1 addressed; F2 addressed. Reviewed at ae2dbb1 |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Start here: the copy-agreement prune now treats an empty capture as a zero-length copy, so a match whose copies are "whole word" and "empty" is refused instead of kept. Closes #634.
A non-empty copy cannot equal an empty one, because synthesis writes every copy from one input. Before this,
TryGetSegmentCopiesreturned false on!capture.Success(an empty group isRange.Null), so FieldWorks' full reduplicationX => X X(a zero-or-more variable copied twice) re-ran the whole remaining search under a spurious candidate at every reachable point. Parses are unchanged: synthesis already rejected those candidates.The fix is in
AnalysisMorphologicalTransform.TryGetSegmentCopies. If the word holds any optional node (an unapplied deletion), the match stays undecidable, because a restored deletion might fill the empty copy. Only optional-free words are pruned; that is the conservative reading of the issue's soundness note. PanGloss made the same change in sillsdev/PanGloss#247.Tests (
PruneDisagreeingCopiesTests):EmptyCopyIsNeverPrunedencoded the leak and is replaced byEmptyCopyAgainstANonEmptyCopyIsPruned(red before the fix, green after) andEmptyCopyIsKeptWhenTheWordHasAnOptionalNode.ZeroOrMoreCopyRuleAddsNoSynthesisWorkForAWordItDoesNotReduplicateis the work-count regression test #634 asked for: with tracing on, five words parse with the same 15 lexical lookups and 3 word syntheses with and without a zero-or-more copy rule. On master it counts 20 lookups against 15. The whole HermitCrab test project passes: 186 passed, 0 failed. csharpier 1.2.6 reports both changed files clean.Leak case from #634 (39 non-reduplicated words, tracing on, the issue's synthetic grammar with
min="0", rule unapplication trace nodes include the two suffix rules): master 316 unapplications, 211 lexical lookups, 128 word syntheses; this branch 184, 79, 43. The no-rule andmin="1"controls give 105/79/43 and 184/79/43 on both builds, so the branch returns the leak case to themin="1"baseline. Parse output for all 43 words is identical.No lost parses: all 154 conformance grammars (6 languages, 132 edge cases, 16 stress; 2,211 words, 2,755 parses on master) were parsed with the HermitCrab tool on master and on this branch. Parse sets are identical for 153 grammars. The 154th,
truncate-morphotactic-identity, orders and glosses equivalent empty-morph parses differently from run to run on master itself (three master runs differ from each other); its per-word parse counts are identical in all six runs. This used the tool, not thehc-conformancerunner, which is not in this checkout.Optional nodes: kept conservative on purpose. PanGloss #247 also aligns copies that hold optional nodes and places an empty copy next to its neighbour, which needs the empty group's position; C# gives
Range.Null, so the position is not available here. Its own notes report that a verbatim port of the alignment loses valid analyses. That is a separate, larger change (#635 territory), not safe to fold in here.Next: review.
🤖 Generated with Claude Code
This change is