Skip to content

Trace HermitCrab failure reasons and template slot outcomes - #534

Open
johnml1135 wants to merge 1 commit into
masterfrom
fix/hc-trace-reasons
Open

johnml1135 wants to merge 1 commit into
masterfrom
fix/hc-trace-reasons

Conversation

@johnml1135

@johnml1135 johnml1135 commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

HermitCrab computes several facts that Try A Word cannot display because they do not reach the trace or are discarded by the trace manager. This change passes the available facts through an optional IDetailedTraceManager capability and retains them in Machine's TraceManager, without rerunning linguistic checks.

  • Analysis affix rejection now carries the first failed gate and its operand: maximum applications, output/required syntactic features, realizational features, or no pattern match.
  • Template slots report applied, optional skipped, and required unfilled branches, with the template, slot index, input, output, and direction. Optional slots can report both an applied and a skipped branch. Sequential and parallel analysis and synthesis are covered.
  • Partial parses retain the completion cause: realizational feature mismatch, pending morphological rules (including the next rule), a non-final template applied last, or applicable templates not applied.
  • Completed lexical lookups report yielded Word-candidate counts and whether the lookup was a guess. Zero candidates is explicit; an interrupted lookup remains unknown. Synthesis nodes stay attached to the corresponding lookup when inputs interleave.
  • Compounding analysis emits the existing rejection callback for the computed limit, feature, non-head lookup, productivity, and pattern gates, with the subrule index and available operand.
  • Blocking already passes the replacement HermitCrab Word through the existing callback. Machine's trace now retains the blocking lexical entry from that Word's root allomorph.
  • Environment failure already passes the allomorph and all failed alternatives. Machine's trace now retains both, along with existing failure operands elsewhere.
  • Phonological non-unapplication remains reasonless because that analysis path does not compute a reason. A regression test ensures no reason is invented.

ITraceManager has no new members. Existing implementations keep the original callbacks; detailed consumers opt into IDetailedTraceManager. Enum additions preserve existing values, and morphological analyses remain unchanged in tracing-on/off and sequential/parallel tests.

Validation: ./local_check.sh --agent-strict passed on Windows (full solution build and every test project). In WSL, all 151 tests in SIL.Machine.Morphology.HermitCrab.Tests passed in a fresh WSL Release run, including 45 synthetic TraceReasonTests covering the facts above, legacy callbacks, interrupted/interleaved lookups, and analysis equivalence. Strict comment hygiene passed and CSharpier checked 724 files. Both ./local_check.sh and ./local_check.sh --agent-strict exited at the solution build because WSL lacks cmake for SentencePiece; the standard rerun also reported MSBuild child-node shutdown errors. The full solution test suite has not passed on this tree. These local checks do not collect CI-equivalent coverage.

FieldWorks follow-up (outside this PR):

  • Implement IDetailedTraceManager in FwXmlTraceManager: add the reason-bearing MorphologicalRuleNotUnapplied overload, TemplateSlotProcessed, and LexicalLookupCompleted. Serialize the new operands, branch outcomes, and completed counts. Keep lookup/synthesis associations correct in LexicalLookup and SynthesizeWord when other trace nodes are inserted.
  • Implement Blocked to serialize the replacement Word's root entry. Extend CompoundingRuleNotUnapplied to handle each reason rather than only productivity restrictions.
  • In Failed, serialize PartialParseFailure.Cause and its pending rule; for Environments, serialize each failed alternative alongside the supplied allomorph instead of passing the collection directly to XElement. Existing NonFinalTemplateAppliedLast and ApplicableTemplatesNotApplied callbacks already distinguish those two template completion failures.
  • In MorphologicalRuleNotApplied, fix the prefixEnv/suffixEnv branches at FwXmlTraceManager.cs:299-302: they currently write env instead of their respective values.
  • Update FormatHCTrace.xsl's ShowAnyFailure (environment branch around line 597 and partial-parse branch around line 661) and ShowCompoundingRuleFailure (around line 1149) to display the detailed facts. Extend ShowTracePath (around line 1237), which selects synthesis children of LexLookupTrace but excludes the lookup node itself, to include empty lookup, slot, and blocking events; adjust DetermineIfMoreToShow for the added nodes. Display unknown phonological causes as unknown.

🤖 Generated with Claude Code


This change is Reviewable

Add optional detailed trace callbacks for analysis rejections, slot branches,
and completed lexical lookup counts. Retain failure operands, blocking entries,
and partial-parse causes in TraceManager without replaying linguistic checks.

Preserve the ITraceManager member contract and verify legacy callbacks,
parallel slot outcomes, interrupted lookups, and morphological analyses.

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

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.70124% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.97%. Comparing base (c7146cd) to head (3734461).

Files with missing lines Patch % Lines
...rab/MorphologicalRules/AnalysisAffixProcessRule.cs 75.00% 7 Missing and 1 partial ⚠️
...Crab/MorphologicalRules/AnalysisCompoundingRule.cs 85.00% 6 Missing ⚠️
.../SIL.Machine.Morphology.HermitCrab/TraceManager.cs 91.66% 3 Missing and 2 partials ⚠️
src/SIL.Machine.Morphology.HermitCrab/Word.cs 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #534      +/-   ##
==========================================
+ Coverage   74.34%   74.97%   +0.62%     
==========================================
  Files         456      458       +2     
  Lines       38261    38470     +209     
  Branches     5242     5274      +32     
==========================================
+ Hits        28445    28842     +397     
+ Misses       8666     8505     -161     
+ Partials     1150     1123      -27     

☔ 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.

@jtmaxwell3

Copy link
Copy Markdown
Collaborator

@johnml1135 Did you ask Beth about this? I'm worried that this will make it harder to find a needle in a haystack because the haystack will be so much bigger. It may also slow Try A Word down.

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.

3 participants