Skip to content

HermitCrab: keep final-template pruning on when only lexical entries are partial - #553

Merged
johnml1135 merged 5 commits into
masterfrom
fix-551-partial-entry-prune
Nov 3, 2026
Merged

johnml1135 merged 5 commits into
masterfrom
fix-551-partial-entry-prune

Conversation

@johnml1135

@johnml1135 johnml1135 commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Start here: src/SIL.Machine.Morphology.HermitCrab/Morpher.cs, HasPartialRules (and its doc comment): the contract the other edits follow.

Status: open since 2026-10-23. The reviewer's reply on the IsPartial removal (FieldWorks does not read it, nothing further needed) is in. Two review notes on test coverage (F5, F6: the analysis-side AlwaysEnforceFinalTemplates override, and the PruneDisagreeingCopiesTests false case) are still open for the author. CI has no red checks (the claude-review job was skipped).

Closes #551. The final-template prune from #491 (merged) is no longer skipped when only lexical entries are partial. Morpher.HasPartialRules is true only if a partial morpheme is not a LexEntry, and AnalysisAffixTemplateRule and AnalysisAffixProcessRule read it in place of Morpher.IsPartial, which is removed.

Reviewers arrive asking whether a partial root could license a derivation the prune rejects. It cannot: SynthesisAffixTemplatesRule skips every template when the root allomorph's morpheme is partial. A partial root with a non-partial LexFamily relative can still take a template, with the relative as root, but that word is non-partial, so a following non-partial rule is blocked either way. Partial rules are different: they make the word partial after the root, so they keep disabling the prune.

Where to look:

  • Morpher.HasPartialRules: the !(morpheme is LexEntry) filter over GetPartialMorphemes().
  • AffixTemplateTests.PartialLexicalEntryDoesNotDisableEarlyPruningOfFinalTemplate: prune fires at trace depth 2 with a partial entry and no partial rule, sab and sabv parse, sabd and sabdv do not; with a partial rule sagdv still parses as 32 PAST NOM. It fails with the old guard (depth 6 instead of 2).
  • Public API: Morpher.IsPartial is gone and nothing in the library read it; FieldWorks does not.

Not here: no fixture exercises ChooseInflectionalStem substitution (traced by reading only); lexical-pattern guesses were already excluded from the partial-morpheme set.

Verification: ./local_check.sh --agent-strict passed before the rebase onto master. After the rebase and the IsPartial removal only AffixTemplateTests and PruneDisagreeingCopiesTests were rerun (46/46). Not rerun: the full strict gate on the final head.

Next: author to decide on F5 and F6, then approve.


Reading this a year from now -- start here

Prune is the early rejection, during analysis, of a final template followed by a non-partial rule. #551 suspected that ignoring partial entries was unsound. The argument that it is sound is under "Decisions, and why"; the conformance evidence is under "Evidence". The fixture is in the conformance suite (it was on #480, now closed).

Decisions, and why
  • A word is partial from its root (Word copies entry.IsPartial) or from a partial rule. Synthesis lets a non-partial rule follow a final template when the input word is partial (SynthesisAffixProcessRule.cs:67). Templates never apply to a partial root, so a partial entry cannot reach that case.
  • ChooseInflectionalStem runs before the partial-root check, so the nuance above holds; the HasPartialRules doc comment states it.
  • IsPartial was removed because nothing reads it once both analysis guards use HasPartialRules. The three test preconditions that used it assert GetPartialMorphemes() directly.
Surprising findings
  • A reviewer traced one more path: a blockable template slot rule can call Word.CheckBlocking, which swaps in a partial family relative that a non-partial rule may follow. The output should match analysing the relative directly as a root, so no parse is expected to be lost. Unverified.
Deferred
  • F5: a partial rule with AlwaysEnforceFinalTemplates on, to cover the analysis-side override (for example at the end of the new test).
  • F6: a partial rule in the PruneDisagreeingCopiesTests fixture, so the false case tests copy-pruning with the final-template prune off.
Evidence
  • Fixture conformance/edge-cases/final-template-partial-root on Add a conformance suite for HermitCrab, with its adequacy argument #480 (integrate-conformance-framework at fa8d9b2; now edge-cases/final-template-partial-root in the conformance suite) has partial roots in a lower stratum and in the template's own stratum. Every final-template string on a partial root has no analysis, with non-partial controls.
  • In a scratch copy with the same guard, all 142 conformance runs over 132 fixtures (including pathological) passed, and the prune fired on the new fixture. These counts are from the earlier run and were not recomputed.
  • ./local_check.sh --agent-strict passed before the rebase; AffixTemplateTests and PruneDisagreeingCopiesTests 46/46 after.

🤖 Generated with Claude Code


This change is Reviewable

@codecov-commenter

codecov-commenter commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.89%. Comparing base (e0478ad) to head (0aaf769).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #553      +/-   ##
==========================================
+ Coverage   74.85%   74.89%   +0.03%     
==========================================
  Files         454      454              
  Lines       38456    38456              
  Branches     5309     5309              
==========================================
+ Hits        28788    28803      +15     
+ Misses       8513     8503      -10     
+ Partials     1155     1150       -5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@claude

This comment has been minimized.

@johnml1135
johnml1135 force-pushed the fix-551-partial-entry-prune branch from 57a3b7e to f1ac77e Compare October 26, 2026 11:49
johnml1135 added a commit that referenced this pull request Oct 26, 2026
PR #553 shows ignoring partial lexical entries in the final-template prune
guard is safe, so Sena gets the prune once it merges.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@claude

This comment has been minimized.

@jtmaxwell3

Copy link
Copy Markdown
Collaborator

I think that you can remove Morpher.IsPartial in the code and in the comments, since it is superceded by Morpher.HasPartialRules.

@johnml1135
johnml1135 force-pushed the fix-551-partial-entry-prune branch from f1ac77e to b507a89 Compare October 27, 2026 17:57
@johnml1135

Copy link
Copy Markdown
Collaborator Author

I think that you can remove Morpher.IsPartial in the code and in the comments, since it is superceded by Morpher.HasPartialRules.

Done in b507a89: I removed Morpher.IsPartial, its assignment and the stale comment in Morpher.cs. Nothing read it after the analysis-side checks moved to HasPartialRules. The three test preconditions that used it now assert GetPartialMorphemes() directly. csharpier passes, and AffixTemplateTests and PruneDisagreeingCopiesTests pass (46/46). The branch is also rebased onto master.

@claude

This comment has been minimized.

@claude

This comment has been minimized.

@claude

claude Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor
  1. Verdict: approve. The only change since 69edb79 is a one-line doc fix in 40491b7, and it addresses F7.
  2. Most important: nothing new. F7 is addressed at src/SIL.Machine.Morphology.HermitCrab/Morpher.cs:102: the HasPartialRules summary now names the AlwaysEnforceFinalTemplates override, which matches both analysis guards.
  3. Counts: 0 Critical, 0 Important, 0 Low new. No findings are open.
  4. Ran: git diff 69edb79c 40491b76, which is doc-only. I checked the new wording against AnalysisAffixTemplateRule.cs:47 and AnalysisAffixProcessRule.cs:83, and AlwaysEnforceFinalTemplates is a member of Morpher, so the cref resolves. I did not rerun /code-review because the last round covered the whole PR and no code changed since then. gh pr checks 553: Build on ubuntu-22.04 and windows-latest and claude-review are pending. Comment hygiene passes, but that check is advisory.
  5. Not verified: whether the CheckBlocking path from F3 loses any parse. No test covers a partial root inside a LexFamily.

Public API: Morpher.IsPartial is removed and Morpher.HasPartialRules is added. Grammars whose only partial morphemes are lexical entries now get the final-template prune during analysis. Target framework, package, and sillsdev/machine.py parity: none verified.

Findings: F1 addressed, F2 addressed, F3 addressed, F4 withdrawn, F5 accepted (deferred to #507), F6 accepted (deferred to #507), F7 addressed.

Reviewed at 40491b7

johnml1135 and others added 5 commits November 2, 2026 20:13
The analysis-side final-template prune (491) was switched off whenever Morpher.IsPartial
was true, and IsPartial counts partial lexical entries. Grammars with partial entries but
no partial rules therefore never pruned.

A partial entry cannot make the prune lose a parse. A word takes its partiality from its
root, but SynthesisAffixTemplatesRule applies no template to a word whose root morpheme is
partial, so a derivation that unapplies a final template can never end at a partial root.
Partial rules differ: they make a word partial after the template has applied, which lets
a non-partial rule follow the final template, so they still disable the prune.

Add Morpher.HasPartialRules and read it in the two analysis guards. IsPartial keeps its
meaning. Lexical-pattern guesses were already excluded from IsPartial and pruned.

Closes #551

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The summary claimed a derivation that unapplies a final template can never end
at a partial root. SynthesisAffixTemplatesRule.Apply calls ChooseInflectionalStem
before the root check, so a partial root can take a template through a
non-partial family relative. State the contract and why the prune stays sound.

The test left the partial "sab" entry in the shared Language; remove it in a
finally block.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nothing reads it now that the analysis-side final-template checks use
HasPartialRules. The three test preconditions assert GetPartialMorphemes()
directly.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
The removed reasoning claimed a substituted family relative is always
non-partial, which blocking can contradict. The contract alone is
accurate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… pruning

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@johnml1135
johnml1135 force-pushed the fix-551-partial-entry-prune branch from 40491b7 to 0aaf769 Compare November 3, 2026 01:14
@johnml1135
johnml1135 merged commit 52ef3d3 into master Nov 3, 2026
7 checks passed
@johnml1135
johnml1135 deleted the fix-551-partial-entry-prune branch November 3, 2026 01:22
johnml1135 added a commit to sillsdev/PanGloss that referenced this pull request Nov 5, 2026
…the #18 waivers are gone (#184)

* Align truncation morph attribution with corrected C# semantics

Replay copied annotation transfers before the zero-width last-node claim.
Preserve current node ownership, genuine descendant grouping and repeated
allomorph suppression using existing flat morph records and shared decoded
ranges. Keep compound descendant transfer non-recursive, matching C#.

Reuse the #480 identity, subsumption and copy-U fixtures with complete
occurrence and application histories. Add the root-boundary regression and
stage the existing #553 partial-root corpus with separate prune counters.

References: sillsdev/machine#500, sillsdev/machine#506,
sillsdev/machine#556, sillsdev/machine#480, sillsdev/machine#553.

* test: register new parser modules in harness inventory

* Match the pinned oracle on truncation identities and remove obsolete waivers.

Drop graduated fixture copies and remove the five-word and shell-runner
exceptions. Ratchet measured faithfulness failures from 24 to 11 and expose
the corrected ground truth's tuned-surface proposal gap in the scoreboard.

Co-Authored-By: Codex GPT-6.1 Sol <noreply@openai.com>

* Restore pruning coverage and document truncation proposal identities.

Count both template skip mechanisms in the clitic-state guard. Pin a
Floating annotation's later anchor-copy transition with real synthesis.
Explain the HC-Rust dependency of scoreboard ground truth and composite
FST proposal tags using before/after gau identities.

Co-Authored-By: Codex GPT-6.1 Sol <noreply@openai.com>

---------

Co-authored-by: Codex GPT-6.1 Sol <noreply@openai.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HermitCrab: partial lexical entries switch off final-template pruning for the whole grammar

3 participants