Skip to content

Complete publication support#1795

Merged
rmunn merged 20 commits into
developfrom
feat/complete-publication-support
Jul 14, 2025
Merged

Complete publication support#1795
rmunn merged 20 commits into
developfrom
feat/complete-publication-support

Conversation

@rmunn

@rmunn rmunn commented Jul 1, 2025

Copy link
Copy Markdown
Contributor

Fixes #1491.

  • implement update publications (fwdata and crdt)
  • implement Add/Remove publication from entry (crdt)
  • implement entry sync
  • implement querying publications in crdt implementation
  • implement update publication tests
  • implement crdt publication tests (extend BasePublicationTests.cs in minilcm tests)

I can't take credit for the "implement querying publications in crdt implementation" one, because that code was already there (written by Jason) before I started this PR; I simply moved it to be closer to the other publication-related API methods so it wouldn't be so easy to overlook.

@rmunn rmunn self-assigned this Jul 1, 2025
@coderabbitai

coderabbitai Bot commented Jul 1, 2025

Copy link
Copy Markdown

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

This change set implements full CRUD and synchronization support for publications in both the CRDT and FWData APIs. It introduces new change types, validators, and synchronization helpers for publications, removes the obsolete SupportsCrdts property, and updates related tests and API methods to handle publication operations consistently across the codebase.

Changes

File(s) / Group Change Summary
FwDataMiniLcmApi.cs, UpdatePublicationProxy.cs Implemented UpdatePublication methods for FWData API, added proxy for publication updates.
UpdateEntryProxy.cs Added PublishIn property override with not implemented exception.
.../MiniLcm/SyncHelpers/PublicationSync.cs Added PublicationSync class for publication synchronization and diffing.
.../MiniLcm/SyncHelpers/EntrySync.cs Integrated publication sync into entry synchronization.
.../MiniLcm/Validators/PublicationValidator.cs Added PublicationValidator for validating publication models.
.../MiniLcm/Validators/MiniLcmValidators.cs Registered publication validator in dependency injection and added validation method.
.../MiniLcm/Models/Publication.cs Removed static SupportsCrdts property.
.../LcmCrdt/Changes/Entries/AddPublicationChange.cs
.../RemovePublicationChange.cs
.../ReplacePublicationChange.cs
Added new CRDT change types for adding, removing, and replacing publications on entries.
.../LcmCrdt/CrdtMiniLcmApi.cs Implemented publication CRUD methods and integrated publication changes into entry creation and update.
.../LcmCrdt/LcmCrdtKernel.cs Registered new publication change types with CRDT kernel.
.../LcmCrdt/Objects/JsonPatchChangeExtractor.cs Added handling for publication changes in JSON patch extraction.
.../FwLiteProjectSync/CrdtFwdataProjectSyncService.cs Synced publications between CRDT and FWData APIs.
.../MiniLcm.Tests/AutoFakerHelpers/EntryFakerHelper.cs Simplified entry publication creation logic and parameterized it.
.../FwLiteProjectSync.Tests/SyncTests.cs
.../UpdateDiffTests.cs
Updated/simplified test logic to remove conditional exclusions based on publication CRDT support.
.../LcmCrdt.Tests/Changes/RegressionDeserializationData.json
.../LcmCrdt.Tests/Changes/UseChangesTests.cs
.../LcmCrdt.Tests/DataModelSnapshotTests.VerifyChangeModels.verified.txt
Added/updated test data and tests to cover new publication change types.

Assessment against linked issues

Objective Addressed Explanation
Implement update publications (fwdata and crdt) (#1491)
Implement Add/Remove publication from entry (crdt) (#1491)
Implement entry sync (#1491)
Implement querying publications in crdt implementation (#1491)
Implement update publication tests, implement crdt publication tests, remove SupportsCrdts property (#1491)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

Possibly related PRs

Suggested reviewers

  • myieye

Poem

In the warren of code where the publications grow,
Rabbits hop with joy, for CRDTs now flow.
Add, remove, and update—no more NotImplemented sighs,
Validators nibble carrots, tests multiply.
The garden’s in sync, both FWData and CRDT,
With every hop, a bug-free jubilee!
🐇✨


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions Bot added the 💻 FW Lite issues related to the fw lite application, not miniLcm or crdt related label Jul 1, 2025
@argos-ci

argos-ci Bot commented Jul 1, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) 📭 Waiting for screenshots - Jul 1, 2025, 9:52 AM

@argos-ci

argos-ci Bot commented Jul 1, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - Jul 14, 2025, 6:46 AM

@github-actions

github-actions Bot commented Jul 1, 2025

Copy link
Copy Markdown
Contributor

UI unit Tests

  1 files  ±0   38 suites  ±0   20s ⏱️ -1s
 80 tests ±0   80 ✅ ±0  0 💤 ±0  0 ❌ ±0 
111 runs  ±0  111 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit f23cd88. ± Comparison against base commit f446de6.

♻️ This comment has been updated with latest results.

@rmunn rmunn force-pushed the feat/complete-publication-support branch from a0c221c to 08d4c7f Compare July 3, 2025 06:58
@rmunn rmunn marked this pull request as ready for review July 3, 2025 09:05
@rmunn rmunn requested a review from hahn-kev July 3, 2025 09:05

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
backend/FwLite/FwDataMiniLcmBridge/Api/UpdateProxy/UpdatePublicationProxy.cs (1)

7-25: Consider documenting the setter restriction.

The proxy class follows the established pattern, but the NotImplementedException in the Name setter might be confusing without context. Consider adding a comment explaining why direct setting is not supported or what the intended update mechanism is.

 public override MultiString Name
 {
     get => new UpdateMultiStringProxy(_lcmPublication.Name, _lexboxLcmApi);
-    set => throw new NotImplementedException();
+    set => throw new NotImplementedException("Use the proxy's methods to update the publication name");
 }
backend/FwLite/LcmCrdt/CrdtMiniLcmApi.cs (1)

229-232: Consider improving error clarity for missing publications

I noticed that AddPublication uses SingleAsync(pub => pub.Id == publicationId), which throws an InvalidOperationException if no publication is found. This pattern is also used elsewhere in CrdtMiniLcmApi (e.g., lines 297 and 362 for complex form types), so it’s consistent across the codebase.

If you’d like to provide more descriptive errors, you could:

  • Switch to SingleOrDefaultAsync(...) and throw a custom exception (e.g. PublicationNotFoundException) when the result is null.
  • Or catch the InvalidOperationException and rethrow a clearer exception message.

Otherwise, if the default exception is handled suitably at a higher level, no changes are strictly necessary.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 10d8832 and dff608d.

📒 Files selected for processing (21)
  • backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs (1 hunks)
  • backend/FwLite/FwDataMiniLcmBridge/Api/UpdateProxy/UpdateEntryProxy.cs (1 hunks)
  • backend/FwLite/FwDataMiniLcmBridge/Api/UpdateProxy/UpdatePublicationProxy.cs (1 hunks)
  • backend/FwLite/FwLiteProjectSync.Tests/SyncTests.cs (0 hunks)
  • backend/FwLite/FwLiteProjectSync.Tests/UpdateDiffTests.cs (1 hunks)
  • backend/FwLite/FwLiteProjectSync/CrdtFwdataProjectSyncService.cs (1 hunks)
  • backend/FwLite/LcmCrdt.Tests/Changes/RegressionDeserializationData.json (1 hunks)
  • backend/FwLite/LcmCrdt.Tests/Changes/UseChangesTests.cs (1 hunks)
  • backend/FwLite/LcmCrdt.Tests/DataModelSnapshotTests.VerifyChangeModels.verified.txt (1 hunks)
  • backend/FwLite/LcmCrdt/Changes/Entries/AddPublicationChange.cs (1 hunks)
  • backend/FwLite/LcmCrdt/Changes/Entries/RemovePublicationChange.cs (1 hunks)
  • backend/FwLite/LcmCrdt/Changes/Entries/ReplacePublicationChange.cs (1 hunks)
  • backend/FwLite/LcmCrdt/CrdtMiniLcmApi.cs (5 hunks)
  • backend/FwLite/LcmCrdt/LcmCrdtKernel.cs (1 hunks)
  • backend/FwLite/LcmCrdt/Objects/JsonPatchChangeExtractor.cs (1 hunks)
  • backend/FwLite/MiniLcm.Tests/AutoFakerHelpers/EntryFakerHelper.cs (1 hunks)
  • backend/FwLite/MiniLcm/Models/Publication.cs (0 hunks)
  • backend/FwLite/MiniLcm/SyncHelpers/EntrySync.cs (3 hunks)
  • backend/FwLite/MiniLcm/SyncHelpers/PublicationSync.cs (1 hunks)
  • backend/FwLite/MiniLcm/Validators/MiniLcmValidators.cs (3 hunks)
  • backend/FwLite/MiniLcm/Validators/PublicationValidator.cs (1 hunks)
💤 Files with no reviewable changes (2)
  • backend/FwLite/MiniLcm/Models/Publication.cs
  • backend/FwLite/FwLiteProjectSync.Tests/SyncTests.cs
🧰 Additional context used
🧠 Learnings (12)
📓 Common learnings
Learnt from: hahn-kev
PR: sillsdev/languageforge-lexbox#1760
File: backend/FwLite/LcmCrdt/CrdtMiniLcmApi.cs:274-277
Timestamp: 2025-06-27T09:24:39.507Z
Learning: In the CrdtMiniLcmApi class, the user prefers to keep the current AddChanges method signature (IEnumerable<IChange>) rather than modifying it to support IAsyncEnumerable for streaming, even when it means materializing collections into memory for bulk operations.
backend/FwLite/LcmCrdt.Tests/DataModelSnapshotTests.VerifyChangeModels.verified.txt (1)
Learnt from: hahn-kev
PR: sillsdev/languageforge-lexbox#1609
File: backend/FwLite/LcmCrdt/CompiledModels/ComplexFormComponentEntityType.cs:138-182
Timestamp: 2025-04-17T02:52:44.986Z
Learning: Files in the LcmCrdt.CompiledModels namespace contain auto-generated Entity Framework Core model code that should be ignored during code reviews since they shouldn't be manually modified.
backend/FwLite/LcmCrdt/LcmCrdtKernel.cs (1)
Learnt from: hahn-kev
PR: sillsdev/languageforge-lexbox#1760
File: backend/FwLite/LcmCrdt/CrdtMiniLcmApi.cs:274-277
Timestamp: 2025-06-27T09:24:39.507Z
Learning: In the CrdtMiniLcmApi class, the user prefers to keep the current AddChanges method signature (IEnumerable<IChange>) rather than modifying it to support IAsyncEnumerable for streaming, even when it means materializing collections into memory for bulk operations.
backend/FwLite/LcmCrdt.Tests/Changes/UseChangesTests.cs (1)
Learnt from: hahn-kev
PR: sillsdev/languageforge-lexbox#1760
File: backend/FwLite/LcmCrdt/CrdtMiniLcmApi.cs:274-277
Timestamp: 2025-06-27T09:24:39.507Z
Learning: In the CrdtMiniLcmApi class, the user prefers to keep the current AddChanges method signature (IEnumerable<IChange>) rather than modifying it to support IAsyncEnumerable for streaming, even when it means materializing collections into memory for bulk operations.
backend/FwLite/LcmCrdt/Changes/Entries/AddPublicationChange.cs (1)
Learnt from: hahn-kev
PR: sillsdev/languageforge-lexbox#1760
File: backend/FwLite/LcmCrdt/CrdtMiniLcmApi.cs:274-277
Timestamp: 2025-06-27T09:24:39.507Z
Learning: In the CrdtMiniLcmApi class, the user prefers to keep the current AddChanges method signature (IEnumerable<IChange>) rather than modifying it to support IAsyncEnumerable for streaming, even when it means materializing collections into memory for bulk operations.
backend/FwLite/LcmCrdt/Changes/Entries/ReplacePublicationChange.cs (1)
Learnt from: hahn-kev
PR: sillsdev/languageforge-lexbox#1760
File: backend/FwLite/LcmCrdt/CrdtMiniLcmApi.cs:274-277
Timestamp: 2025-06-27T09:24:39.507Z
Learning: In the CrdtMiniLcmApi class, the user prefers to keep the current AddChanges method signature (IEnumerable<IChange>) rather than modifying it to support IAsyncEnumerable for streaming, even when it means materializing collections into memory for bulk operations.
backend/FwLite/LcmCrdt/Objects/JsonPatchChangeExtractor.cs (1)
Learnt from: hahn-kev
PR: sillsdev/languageforge-lexbox#1760
File: backend/FwLite/LcmCrdt/CrdtMiniLcmApi.cs:274-277
Timestamp: 2025-06-27T09:24:39.507Z
Learning: In the CrdtMiniLcmApi class, the user prefers to keep the current AddChanges method signature (IEnumerable<IChange>) rather than modifying it to support IAsyncEnumerable for streaming, even when it means materializing collections into memory for bulk operations.
backend/FwLite/MiniLcm/SyncHelpers/EntrySync.cs (1)
Learnt from: hahn-kev
PR: sillsdev/languageforge-lexbox#1760
File: backend/FwLite/LcmCrdt/CrdtMiniLcmApi.cs:274-277
Timestamp: 2025-06-27T09:24:39.507Z
Learning: In the CrdtMiniLcmApi class, the user prefers to keep the current AddChanges method signature (IEnumerable<IChange>) rather than modifying it to support IAsyncEnumerable for streaming, even when it means materializing collections into memory for bulk operations.
backend/FwLite/MiniLcm/SyncHelpers/PublicationSync.cs (1)
Learnt from: hahn-kev
PR: sillsdev/languageforge-lexbox#1760
File: backend/FwLite/LcmCrdt/CrdtMiniLcmApi.cs:274-277
Timestamp: 2025-06-27T09:24:39.507Z
Learning: In the CrdtMiniLcmApi class, the user prefers to keep the current AddChanges method signature (IEnumerable<IChange>) rather than modifying it to support IAsyncEnumerable for streaming, even when it means materializing collections into memory for bulk operations.
backend/FwLite/LcmCrdt/Changes/Entries/RemovePublicationChange.cs (1)
Learnt from: hahn-kev
PR: sillsdev/languageforge-lexbox#1760
File: backend/FwLite/LcmCrdt/CrdtMiniLcmApi.cs:274-277
Timestamp: 2025-06-27T09:24:39.507Z
Learning: In the CrdtMiniLcmApi class, the user prefers to keep the current AddChanges method signature (IEnumerable<IChange>) rather than modifying it to support IAsyncEnumerable for streaming, even when it means materializing collections into memory for bulk operations.
backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs (1)
Learnt from: hahn-kev
PR: sillsdev/languageforge-lexbox#1760
File: backend/FwLite/LcmCrdt/CrdtMiniLcmApi.cs:274-277
Timestamp: 2025-06-27T09:24:39.507Z
Learning: In the CrdtMiniLcmApi class, the user prefers to keep the current AddChanges method signature (IEnumerable<IChange>) rather than modifying it to support IAsyncEnumerable for streaming, even when it means materializing collections into memory for bulk operations.
backend/FwLite/LcmCrdt/CrdtMiniLcmApi.cs (1)
Learnt from: hahn-kev
PR: sillsdev/languageforge-lexbox#1760
File: backend/FwLite/LcmCrdt/CrdtMiniLcmApi.cs:274-277
Timestamp: 2025-06-27T09:24:39.507Z
Learning: In the CrdtMiniLcmApi class, the user prefers to keep the current AddChanges method signature (IEnumerable<IChange>) rather than modifying it to support IAsyncEnumerable for streaming, even when it means materializing collections into memory for bulk operations.
🧬 Code Graph Analysis (5)
backend/FwLite/FwDataMiniLcmBridge/Api/UpdateProxy/UpdateEntryProxy.cs (2)
backend/FwLite/MiniLcm/Models/Publication.cs (1)
  • Publication (3-27)
backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs (1)
  • Publication (301-310)
backend/FwLite/LcmCrdt/Changes/Entries/AddPublicationChange.cs (3)
backend/FwLite/MiniLcm/Models/Publication.cs (2)
  • Guid (7-10)
  • Publication (3-27)
backend/FwLite/LcmCrdt/Changes/Entries/RemovePublicationChange.cs (1)
  • ValueTask (10-14)
backend/FwLite/LcmCrdt/Changes/Entries/ReplacePublicationChange.cs (1)
  • ValueTask (12-20)
backend/FwLite/FwLiteProjectSync/CrdtFwdataProjectSyncService.cs (1)
backend/FwLite/MiniLcm/SyncHelpers/PublicationSync.cs (1)
  • PublicationSync (6-61)
backend/FwLite/LcmCrdt/Objects/JsonPatchChangeExtractor.cs (3)
backend/FwLite/LcmCrdt/Changes/Entries/AddPublicationChange.cs (1)
  • AddPublicationChange (7-17)
backend/FwLite/LcmCrdt/Changes/Entries/RemovePublicationChange.cs (1)
  • RemovePublicationChange (7-15)
backend/FwLite/LcmCrdt/Changes/Entries/ReplacePublicationChange.cs (1)
  • ReplacePublicationChange (7-21)
backend/FwLite/LcmCrdt/Changes/Entries/RemovePublicationChange.cs (2)
backend/FwLite/LcmCrdt/Changes/Entries/AddPublicationChange.cs (1)
  • ValueTask (12-16)
backend/FwLite/LcmCrdt/Changes/Entries/ReplacePublicationChange.cs (1)
  • ValueTask (12-20)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (csharp)
  • GitHub Check: Build FW Lite and run tests
🔇 Additional comments (34)
backend/FwLite/FwDataMiniLcmBridge/Api/UpdateProxy/UpdateEntryProxy.cs (1)

66-70: LGTM! Property follows established pattern.

The PublishIn property implementation is consistent with other collection properties in the UpdateEntryProxy class, appropriately throwing NotImplementedException for both getter and setter as expected for this proxy pattern.

backend/FwLite/LcmCrdt/LcmCrdtKernel.cs (1)

234-236: LGTM! Publication change types properly registered.

The three new publication change types (AddPublicationChange, RemovePublicationChange, ReplacePublicationChange) are correctly added to the CRDT kernel configuration and follow the established naming and placement patterns for entity change types.

backend/FwLite/FwLiteProjectSync.Tests/UpdateDiffTests.cs (1)

23-28: LGTM! Test logic simplified appropriately.

The removal of conditional logic for PublishIn exclusion correctly reflects that publications now have full CRDT support, eliminating the need for feature-flag-based conditional test logic.

backend/FwLite/LcmCrdt.Tests/DataModelSnapshotTests.VerifyChangeModels.verified.txt (1)

127-138: LGTM! Test snapshot correctly updated.

The snapshot file has been properly updated with the three new publication change types, maintaining consistency with the existing format and naming conventions for change type discriminators.

backend/FwLite/FwLiteProjectSync/CrdtFwdataProjectSyncService.cs (1)

75-77: LGTM! Publication sync implementation follows established pattern.

The publication synchronization logic correctly follows the bidirectional sync pattern used for other entity types, ensuring consistency between CRDT and FWData APIs while properly accumulating change counts.

backend/FwLite/LcmCrdt.Tests/Changes/RegressionDeserializationData.json (1)

241-272: LGTM! Test data structure is consistent.

The new publication-related change entries follow the established JSON structure pattern and provide comprehensive coverage for the three publication change types. The test data includes proper GUIDs, multilingual names, and all required fields.

backend/FwLite/MiniLcm/Validators/MiniLcmValidators.cs (3)

15-15: LGTM! Validator parameter addition follows established pattern.

The PublicationValidator parameter is correctly added to the record constructor, maintaining consistency with other validator parameters.


53-57: LGTM! ValidateAndThrow method follows established pattern.

The async ValidateAndThrow method for Publication maintains consistency with the existing validation methods, properly delegating to the PublicationValidator.


76-76: LGTM! Service registration follows established pattern.

The transient service registration for IValidator<Publication> is consistent with other validator registrations in the extension method.

backend/FwLite/LcmCrdt/Changes/Entries/AddPublicationChange.cs (2)

7-11: LGTM! Constructor and property implementation follows established patterns.

The class properly inherits from EditChange<Entry>, implements ISelfNamedType<AddPublicationChange>, and uses a clean constructor pattern with immutable property initialization.


12-17: LGTM! ApplyChange implementation includes proper deletion check.

The method correctly checks if the publication is deleted before adding it to the entry's PublishIn collection, which is good defensive programming practice. The async pattern is used appropriately.

backend/FwLite/LcmCrdt.Tests/Changes/UseChangesTests.cs (2)

168-175: LGTM! Publication creation follows established test patterns.

The test creates two distinct publications with proper IDs and names, providing good coverage for replacement scenarios. The naming ("Main" and "Second") is clear and descriptive.


176-183: LGTM! Publication change dependency chain is correctly established.

The dependency relationships are properly defined:

  • AddPublicationChange depends on publication creation
  • ReplacePublicationChange depends on all prerequisite changes
  • RemovePublicationChange depends on the replacement

This ensures proper ordering and comprehensive testing of the publication change lifecycle.

backend/FwLite/LcmCrdt/Changes/Entries/ReplacePublicationChange.cs (1)

7-11: LGTM! Constructor and property implementation follows established patterns.

The class properly inherits from EditChange<Entry>, implements ISelfNamedType<ReplacePublicationChange>, and uses a clean constructor pattern with immutable properties for both the new publication and old publication ID.

backend/FwLite/MiniLcm.Tests/AutoFakerHelpers/EntryFakerHelper.cs (2)

13-14: LGTM!

The addition of the createPublications parameter with a default value of true maintains backward compatibility while providing flexibility for test scenarios.


21-21: LGTM!

The simplified logic directly calls CreatePublications when enabled, which is cleaner than the previous conditional check on Publication.SupportsCrdts. This aligns with the PR's objective to remove the SupportsCrdts flag.

backend/FwLite/LcmCrdt/Objects/JsonPatchChangeExtractor.cs (1)

146-172: LGTM!

The publication change handling follows the established pattern for other collections in the same method. The implementation correctly:

  • Handles all three operation types (Add, Remove, Replace)
  • Performs null checks for Add and Replace operations
  • Defaults to existing publication for Remove operations when new value is null
  • Provides clear error messages for unsupported operations
  • Uses the appropriate change classes (AddPublicationChange, RemovePublicationChange, ReplacePublicationChange)

The code is consistent with the existing collection handling patterns in the file.

backend/FwLite/LcmCrdt/Changes/Entries/RemovePublicationChange.cs (1)

10-14: LGTM!

The implementation is straightforward and follows the established pattern. The use of Where().ToList() to filter out the publication by ID is correct and consistent with the ReplacePublicationChange class shown in the relevant code snippets.

Note: Unlike AddPublicationChange which checks context.IsObjectDeleted(), this class doesn't perform context checks, which is appropriate since we're removing the publication regardless of its state.

backend/FwLite/MiniLcm/Validators/PublicationValidator.cs (1)

11-12: LGTM!

The validation rules are appropriate:

  • Ensuring DeletedAt is null prevents validation of soft-deleted publications
  • Using NoEmptyValues ensures the publication name contains meaningful content
backend/FwLite/MiniLcm/SyncHelpers/EntrySync.cs (3)

27-27: LGTM! Consistent integration pattern.

The addition of publication synchronization follows the established pattern used for other entry components like senses and complex form types.


36-45: LGTM! Follows established synchronization pattern.

The SyncPublications method correctly implements the same diff-based synchronization pattern used throughout the class for other collections.


144-162: LGTM! Consistent implementation with other diff APIs.

The PublicationsDiffApi class follows the exact same pattern as ComplexFormTypesDiffApi, with proper async/await usage and consistent return values. The Replace method correctly returns 0 since publications don't have mutable properties beyond the name, which is handled via the update API.

backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs (2)

314-325: LGTM! Follows established update pattern.

The implementation correctly follows the same pattern as other update methods in the class:

  • Retrieves the LCM publication with proper null checking
  • Uses UndoableUnitOfWorkHelper for transactional consistency
  • Applies updates via UpdatePublicationProxy
  • Returns the updated publication object

327-331: LGTM! Consistent async update implementation.

The method correctly implements the before/after update pattern using PublicationSync.Sync within an async unit of work, consistent with other similar methods in the class. The error handling for missing publications is appropriate.

backend/FwLite/MiniLcm/SyncHelpers/PublicationSync.cs (4)

6-16: LGTM! Well-designed sync utility following established patterns.

The PublicationSync class correctly implements the standard synchronization pattern used throughout the codebase, with array-based sync using DiffCollection.Diff and a custom diff API implementation.


18-27: LGTM! Efficient individual publication sync implementation.

The single publication sync method correctly:

  • Uses patch-based updates for efficiency
  • Only performs API calls when changes exist
  • Returns appropriate change counts
  • Follows the established async pattern

29-40: LGTM! Appropriate focus on Name property for publications.

The DiffToUpdate method correctly focuses only on the Name property using MultiStringDiff, which is appropriate since publications are simple entities with just an ID and multilingual name. The patch document generation follows the established pattern.


42-60: LGTM! Consistent diff API implementation.

The PublicationsDiffApi class correctly implements the required interface methods:

  • Add and Remove methods properly use the API and return change counts
  • Replace method delegates to the single publication sync method
  • All methods follow async/await patterns consistently
backend/FwLite/LcmCrdt/CrdtMiniLcmApi.cs (6)

192-200: LGTM: Method relocation is clean

The GetPublications() and GetPublication(Guid id) methods have been moved within the class without any implementation changes. The relocation improves code organization by grouping publication-related methods together.


217-222: LGTM: Proper async implementation with validation

The UpdatePublication method has been correctly converted from a stub to a fully async implementation. The implementation follows the established pattern used by other similar methods in the class, using PublicationSync.Sync for synchronization and proper error handling.


234-237: LGTM: Simple and correct implementation

The RemovePublication method correctly creates a RemovePublicationChange with the provided IDs. The implementation is straightforward and follows the expected pattern.


543-546: LGTM: Consistent with existing patterns

The addition of publication handling in CreateEntryChanges follows the same pattern as complex form types and maintains consistency with the method's existing logic.


577-577: LGTM: Proper integration with entry creation

The integration of publication changes into the CreateEntry method is clean and consistent with how other related collections are handled.


644-660: LGTM: Thorough validation with proper error handling

The ToPublications local method implements comprehensive validation:

  • Checks for default (empty) publication IDs
  • Verifies publication existence in the database
  • Provides clear error messages for invalid operations

The implementation mirrors the validation pattern used in ToComplexFormTypes, ensuring consistency across the codebase.

Comment thread backend/FwLite/LcmCrdt/Changes/Entries/ReplacePublicationChange.cs Outdated
Comment thread backend/FwLite/MiniLcm/Validators/PublicationValidator.cs
@rmunn rmunn changed the title WIP: Complete publication support Complete publication support Jul 4, 2025
@rmunn rmunn mentioned this pull request Jul 7, 2025
@rmunn

rmunn commented Jul 8, 2025

Copy link
Copy Markdown
Contributor Author

This is going to have merge conflicts if #1804 is merged first. If this is merged first, then #1804 will need to watch out that the UpdatePublication, etc., methods get moved to the correct file(s).

@rmunn rmunn force-pushed the feat/complete-publication-support branch from 0feff68 to eaf2db9 Compare July 8, 2025 03:36
@rmunn

rmunn commented Jul 8, 2025

Copy link
Copy Markdown
Contributor Author

Rebased on top of current develop to fix the (very minor) merge conflict in UseChangesTests.cs.

rmunn added 3 commits July 8, 2025 11:24
The merge algorithm naturally couldn't know that you now have to use
repoFactory and that the Publications property is now on the repo.

@rmunn rmunn left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review completed, found just one place where the code might be improvable. Kevin, what do you think?

@rmunn

rmunn commented Jul 9, 2025

Copy link
Copy Markdown
Contributor Author

This is going to have merge conflicts if #1804 is merged first. If this is merged first, then #1804 will need to watch out that the UpdatePublication, etc., methods get moved to the correct file(s).

Merge conflicts solved, and all tests passing. Ready for review.

@rmunn

rmunn commented Jul 9, 2025

Copy link
Copy Markdown
Contributor Author

Self-review completed, found just one place where the code might be improvable. Kevin, what do you think?

Weird; my self-review comment didn't get added. Maybe I forgot to click the submit button on the comment? Anyway, it was in reference to the ReplacePublicationChange code being maybe a bit too complex for the tiny performance benefit that that complexity would carry, and wondering if I should model it more after the way the ReplaceComplexFormTypeChange code works. And I just decided that yes, I should. Commit incoming, at which point my self-review comment that got lost would have become redundant anyway.

This was removed before, but the git merge added it back in.
@rmunn

rmunn commented Jul 9, 2025

Copy link
Copy Markdown
Contributor Author

Self-review completed, found just one place where the code might be improvable. Kevin, what do you think?

The comment that got lost was asking if I should make the change that I ended up making in commit 27d755b.

@hahn-kev hahn-kev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me, just a couple minor changes.

One odd thing I noticed is that github thinks backend/FwLite/LcmCrdt.Tests/MiniLcmTests/PublicationsTests.cs is a binary file in the Files changed tab. Maybe check there's nothing weird going on with it, encoding, bom etc.

Comment thread backend/FwLite/LcmCrdt/CrdtMiniLcmApi.cs Outdated
Comment thread backend/FwLite/LcmCrdt/Objects/JsonPatchChangeExtractor.cs Outdated
Comment thread backend/FwLite/MiniLcm.Tests/PublicationsTestsBase.cs Outdated
@rmunn

rmunn commented Jul 9, 2025

Copy link
Copy Markdown
Contributor Author

One odd thing I noticed is that github thinks backend/FwLite/LcmCrdt.Tests/MiniLcmTests/PublicationsTests.cs is a binary file in the Files changed tab. Maybe check there's nothing weird going on with it, encoding, bom etc.

I copied that file from another one (don't remember which now) and didn't notice that it was encoded in UTF-16LE for some reason. Maybe Jason created the file I copied from in Visual Studio, and Visual Studio still doesn't default to UTF-8? At any rate, the encoding of that file is now UTF-8 (with no BOM).

Incidentally, Kevin, your Rider config seems to be set up to create UTF-8 files with a BOM, which is mildly annoying when I try to work with them on Linux. The BOM is almost always invisible, but it shows up (at least for me) in git diff listings as <U+FEFF> at the top of the file if a using statement near the top of the file was changed. If you could change your Rider defaults to write UTF-8 with no BOM it would be a small help to me.

Anyway, that file is fixed now.

@rmunn rmunn requested a review from hahn-kev July 9, 2025 07:20
Comment thread backend/FwLite/LcmCrdt/Changes/Entries/RemovePublicationChange.cs Outdated
Comment thread backend/FwLite/MiniLcm/SyncHelpers/EntrySync.cs

@hahn-kev hahn-kev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

rmunn added 2 commits July 14, 2025 13:41
…ication-support

Fixes merge conflict in backend/FwLite/LcmCrdt/CrdtMiniLcmApi.cs
@rmunn

rmunn commented Jul 14, 2025

Copy link
Copy Markdown
Contributor Author

Running tests again to make sure the merge from develop (fixing the merge conflict with PR #1816) didn't screw anything up, then I'll squash and merge this PR since it's been approved.

@rmunn rmunn merged commit 8f80e94 into develop Jul 14, 2025
19 checks passed
@rmunn rmunn deleted the feat/complete-publication-support branch July 14, 2025 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💻 FW Lite issues related to the fw lite application, not miniLcm or crdt related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Complete publication support

3 participants