Skip to content

LT-22899: Show the required slot when Try A Word reports a pruned template - #1247

Draft
johnml1135 wants to merge 1 commit into
mainfrom
fw-machine575-trace
Draft

johnml1135 wants to merge 1 commit into
mainfrom
fw-machine575-trace

Conversation

@johnml1135

@johnml1135 johnml1135 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Start here: Src/LexText/ParserCore/FwXmlTraceManager.cs, EndUnapplyTemplate. It is the Try A Word half; HcXmlTraceManager mirrors it for HCSynthByGloss.

Status: Draft until a SIL.Machine release contains sillsdev/machine#575. CI is red until then (see below).

Fixes LT-22899. Follows sillsdev/machine#575. Related: LT-22868.

What it does. machine#575 traces each pruned affix-template partial as FailureReason.UnreachableRequiredSlot, with the AffixTemplateSlot it could not fill, and adds an object failureObj parameter to ITraceManager.EndUnapplyTemplate. Both FieldWorks trace managers take the parameter and write <FailureReason type="unreachableRequiredSlot"><Slot>slot name</Slot></FailureReason>. Both trace stylesheets show it as a reason that names the required slot and says its affixes cannot be found in what remains of the word.

Why can't this merge now? The interface change breaks the build in both directions. On 3.9.6 the five-parameter method does not implement ITraceManager, and UnreachableRequiredSlot does not exist. On the release with #575, main stops compiling. The last commit before merge bumps SilMachineVersion.

Where to look

  • Placement: a prune made after an affix was unapplied is written under that affix's MorphologicalRuleAnalysisTrace, so the "Template ... failed" row appears beneath the affix. HCTraceTransformTests.TemplateFailure_NamesUnreachableRequiredSlot pins it.
  • The message wording. Like every other failure reason in these stylesheets, it is hardcoded English; none of them is in .resx or Crowdin.

Deliberately not here

  • The SilMachineVersion bump.
  • An end-to-end HCSynthByGloss test. HCSynthByGloss never calls ParseWord, so it cannot reach a template analysis prune. Its stylesheet is updated so the two stay in step.

Verification. Built and tested against a local package packed from #575 head d3c5c06f (3.9.6-detached.gd3c5c06). The pin is not committed.

  • build.ps1 -BuildTests -CommentHygiene -TokenHygiene: 0 warnings, 0 errors; both hygiene checks clean.
  • ParserCoreTests 75/75 and HCSynthByGlossTests 4/4 passed, including the three new tests.
  • Not run: the full suite, a live Try A Word trace, and a build against 3.9.6, which fails by design. Steps to reproduce are under Evidence.

Next: review the wording of the trace message now. Once a machine release contains #575, bump SilMachineVersion and mark this ready.


Reading this a year from now

FieldWorks implements HermitCrab's ITraceManager in FwXmlTraceManager (Try A Word) and in HcXmlTraceManager (HCSynthByGloss). Each turns HermitCrab trace callbacks into XML, which FormatHCTrace.xsl or HCSynthByGlossFormatHCTrace.xsl renders as HTML. machine#575 added a template-analysis prune for required slots. An earlier revision of #575 turned the prune off while tracing. On review it was changed to run while tracing and to be traced, and that trace is what this branch displays.

Decisions
  • <Slot> holds the slot's Name. That is the slot name from the FieldWorks project, set by HCLoader. The value comes from (failureObj as AffixTemplateSlot)?.Name, so a slot without a name, or an unexpected object, writes an empty <Slot/>. It does not throw and never writes the CLR type name.
  • The wording says what HermitCrab checked. The look-ahead tests whether the slot's affixes can be unapplied from what is left of the form, in template order and at the word edges. The full message: "The required slot '' cannot be filled: no affix in this slot can be found in what remains of the word, in the order and position the template requires."
Evidence
  • obj/project.assets.json for ParserCore, ParserCoreTests, HCSynthByGlossLib and HCSynthByGlossTests resolves SIL.Machine.Morphology.HermitCrab/3.9.6-detached.gd3c5c06. The built SIL.Machine.Morphology.HermitCrab.dll reports product version 3.9.6-detached.gd3c5c06+d3c5c06f..., so the tests ran against Fix for LT-22315 #575 and not against the released package.
  • New tests: FwXmlTraceManagerTests.TemplateFailure_RecordsUnreachableRequiredSlot, HCTraceTransformTests.TemplateFailure_NamesUnreachableRequiredSlot, HCSynthByGlossTests.TraceNamesUnreachableRequiredSlot. All of them use synthetic names.
  • No checked-in test covers HCSynthByGlossFormatHCTrace.xsl. A one-off transform of synthetic XML through it rendered: "Template failed. (Reason: The required slot 'subject slot' cannot be filled: no affix in this slot can be found in what remains of the word, in the order and position the template requires.)"

To reproduce:

  1. git -C <machine> checkout d3c5c06f
  2. $env:SILMACHINE_PATH = "<machine>"; .\build.ps1 -LocalLibraries machine -BuildTests
  3. .\test.ps1 -NoBuild -TestProject Src/LexText/ParserCore/ParserCoreTests
  4. git checkout Build/SilVersions.props to drop the local pin.

🤖 Generated with Claude Code


This change is Reviewable

HermitCrab (sillsdev/machine#575) traces each affix template partial it
prunes as FailureReason.UnreachableRequiredSlot, with the slot, and
ITraceManager.EndUnapplyTemplate takes that slot as a new failureObj.

FwXmlTraceManager and HcXmlTraceManager take the new parameter and
write the slot name in an unreachableRequiredSlot FailureReason.
FormatHCTrace.xsl and HCSynthByGlossFormatHCTrace.xsl show it as a
reason that names the required slot.

This needs a SIL.Machine release that contains machine#575; it does
not compile against 3.9.6.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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