-
-
Notifications
You must be signed in to change notification settings - Fork 6
Normalize user CRDT writes to NFD #2146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
4e3f075
045204e
661375f
7d4bd5d
4d9248e
9e758d8
117ba88
ea0fe49
9546e2f
de0fbe0
b5cb3d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,10 +19,11 @@ public class MiniLcmJsInvokable( | |
| ILogger<MiniLcmJsInvokable> logger, | ||
| MiniLcmApiNotifyWrapperFactory notificationWrapperFactory, | ||
| MiniLcmApiValidationWrapperFactory validationWrapperFactory, | ||
| MiniLcmApiStringNormalizationWrapperFactory normalizationWrapperFactory | ||
| MiniLcmApiStringNormalizationWrapperFactory readNormalizationWrapperFactory, | ||
| MiniLcmWriteApiNormalizationWrapperFactory writeNormalizationWrapperFactory | ||
| ) : IDisposable | ||
| { | ||
| private readonly IMiniLcmApi _wrappedApi = api.WrapWith([normalizationWrapperFactory, validationWrapperFactory, notificationWrapperFactory], project); | ||
| private readonly IMiniLcmApi _wrappedApi = api.WrapWith([writeNormalizationWrapperFactory, readNormalizationWrapperFactory, validationWrapperFactory, notificationWrapperFactory], project); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # Find WrapWith implementation
find backend -name "*.cs" -type f | xargs grep -l "WrapWith" | head -5Repository: sillsdev/languageforge-lexbox Length of output: 4552 🏁 Script executed: # Search for WrapWith extension method definition
rg -B2 -A10 "public static.*WrapWith" backend/ --type csRepository: sillsdev/languageforge-lexbox Length of output: 1073 🏁 Script executed: # Examine MiniLcmApiHubBase.cs to see the comparison
find backend -name "MiniLcmApiHubBase.cs" -type fRepository: sillsdev/languageforge-lexbox Length of output: 123 🏁 Script executed: # Check the context around line 26 in MiniLcmJsInvokable.cs
cat -n backend/FwLite/FwLiteShared/Services/MiniLcmJsInvokable.cs | head -40Repository: sillsdev/languageforge-lexbox Length of output: 2127 🏁 Script executed: cat -n backend/FwLite/FwLiteWeb/Hubs/MiniLcmApiHubBase.cs | head -40Repository: sillsdev/languageforge-lexbox Length of output: 1648 🏁 Script executed: # Check for any tests or documentation about wrapper order
rg -B2 -A5 "WrapWith|wrapper.*order" backend/FwLite/MiniLcm.Tests/ --type csRepository: sillsdev/languageforge-lexbox Length of output: 712 🏁 Script executed: # Look for wrapper factory implementations to understand their purpose
rg -B1 -A8 "class MiniLcmApiValidationWrapperFactory|class MiniLcmWriteApiNormalizationWrapperFactory|class MiniLcmApiStringNormalizationWrapperFactory" backend/ --type csRepository: sillsdev/languageforge-lexbox Length of output: 3182 🏁 Script executed: # Check for comments in the MiniLcmJsInvokable file explaining the wrapper order
cat -n backend/FwLite/FwLiteShared/Services/MiniLcmJsInvokable.cs | head -30Repository: sillsdev/languageforge-lexbox Length of output: 1523 🏁 Script executed: # Look for any tests that validate the wrapper order or provide insights
rg -B3 -A10 "writeNormalization|readNormalization" backend/FwLite/MiniLcm.Tests/ --type cs | head -50Repository: sillsdev/languageforge-lexbox Length of output: 55 🏁 Script executed: # Search for any git blame or comments explaining the wrapper order choice
rg -B5 -A5 "notificationWrapperFactory" backend/FwLite/FwLiteShared/Services/MiniLcmJsInvokable.cs --type csRepository: sillsdev/languageforge-lexbox Length of output: 1048 🏁 Script executed: # Check if there's a README or documentation explaining wrapper order
find backend -name "README*" -o -name "*wrapper*readme*" -o -name "*normalization*readme*" | xargs cat 2>/dev/nullRepository: sillsdev/languageforge-lexbox Length of output: 17006 🏁 Script executed: # Look for issue discussions or comments about wrapper ordering
rg -i "wrapper.*order|order.*wrapper|validation.*before|normalization.*order" backend/FwLite/ --type csRepository: sillsdev/languageforge-lexbox Length of output: 55 🏁 Script executed: # Check the notification wrapper to understand what it does
rg -B2 -A15 "class MiniLcmApiNotifyWrapper" backend/ --type cs | head -40Repository: sillsdev/languageforge-lexbox Length of output: 2562 Fix wrapper application order to match documented architecture. The
However, the documented architecture in
This means validation is currently running before write normalization, causing validation to see un-normalized input. The correct factory order should be:
This aligns with 🤖 Prompt for AI Agents |
||
|
|
||
| public record MiniLcmFeatures(bool? History, bool? Write, bool? OpenWithFlex, bool? Feedback, bool? Sync, bool? Audio); | ||
| private bool SupportsSync => project.DataFormat == ProjectDataFormat.Harmony && api is CrdtMiniLcmApi; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrapper order inconsistency for CRDT API.
The CRDT API wrapper order here differs from
MiniLcmApiHubBase:Here (line 67):
writeNormalization(readNormalization(validation(crdtApi)))→ Call flow: Client → WriteNorm → ReadNorm → Validation → API
In MiniLcmApiHubBase (lines 14-20):
writeNormalization(validation(api))→ Call flow: Client → WriteNorm → Validation → API
The hub applies write normalization before validation, while this sync service applies validation before write normalization. If validators expect normalized data, this inconsistency could cause validation to behave differently between the two code paths.
🔧 Proposed fix to align wrapper order
📝 Committable suggestion
🤖 Prompt for AI Agents