Skip to content

Prevent clients from setting CommitId#73

Merged
hahn-kev merged 3 commits into
sillsdev:mainfrom
hahn-kev:prevent-client-commit-id-5045124005170139736
Jun 12, 2026
Merged

Prevent clients from setting CommitId#73
hahn-kev merged 3 commits into
sillsdev:mainfrom
hahn-kev:prevent-client-commit-id-5045124005170139736

Conversation

@hahn-kev

@hahn-kev hahn-kev commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

This change implements issue #70 by preventing clients from setting the CommitId when adding changes. Commit IDs are now always generated internally to avoid potential synchronization issues where multiple clients might use the same ID with different timestamps.

Key changes:

  • DataModel.AddChange and AddChanges no longer accept a commitId.
  • IChange.CommitId property was removed.
  • ToChangeEntity was updated to accept the commitId explicitly.
  • Relevant tests were updated to declare variables correctly or remove obsolete tests.

PR created automatically by Jules for task 5045124005170139736 started by @hahn-kev

Summary by CodeRabbit

  • Refactor
    • Simplified the data model's change-addition API by removing the requirement to manually specify commit IDs. Commit identification is now generated and managed internally, reducing API complexity and streamlining integration.

- Removed commitId parameter from DataModel.AddChange and AddChanges
- Removed CommitId property from IChange interface and implementations
- Updated tests to match the new API
- Removed tests that relied on client-provided commitId

Co-authored-by: hahn-kev <4575355+hahn-kev@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1ff56eea-5160-4c9f-b22d-fdfd80c04e0f

📥 Commits

Reviewing files that changed from the base of the PR and between 31dc78b and 8c876ee.

📒 Files selected for processing (7)
  • src/SIL.Harmony.Tests/CommitTests.cs
  • src/SIL.Harmony.Tests/DataModelIntegrityTests.cs
  • src/SIL.Harmony.Tests/DataModelPerformanceTests.cs
  • src/SIL.Harmony.Tests/DataModelTestBase.cs
  • src/SIL.Harmony.Tests/PersistExtraDataTests.cs
  • src/SIL.Harmony/Changes/Change.cs
  • src/SIL.Harmony/DataModel.cs
💤 Files with no reviewable changes (2)
  • src/SIL.Harmony.Tests/DataModelIntegrityTests.cs
  • src/SIL.Harmony/Changes/Change.cs

📝 Walkthrough

Walkthrough

The PR removes CommitId from the IChange contract and refactors how commit identity is assigned. The DataModel API no longer accepts explicit commit IDs at call sites; instead, commits generate their own identity, and ChangeEntity objects receive the CommitId from the owning Commit object. Tests are updated to reflect the new construction patterns and obsolete commit-id-passing logic is removed.

Changes

CommitId Removal and Commit-ID Assignment Refactor

Layer / File(s) Summary
Remove CommitId from IChange contract
src/SIL.Harmony/Changes/Change.cs
IChange interface and Change<T> class no longer declare the CommitId property, eliminating the ability for individual changes to store or carry commit identity.
Refactor DataModel commit-creation API
src/SIL.Harmony/DataModel.cs
AddChange and AddChanges methods remove the commitId parameter; NewCommit no longer accepts explicit commit ID and instead relies on Commit object creation. ToChangeEntity now receives the owning commitId and assigns it directly to the change entity rather than reading from the change itself.
Update test commit and change-entity construction
src/SIL.Harmony.Tests/CommitTests.cs, src/SIL.Harmony.Tests/DataModelTestBase.cs
Test methods now build Commit objects using empty initializers and populate ChangeEntities via Add/AddRange methods with the generated Commit.Id, instead of inline collection initializers that relied on change.CommitId.
Test cleanup and property updates
src/SIL.Harmony.Tests/DataModelIntegrityTests.cs, src/SIL.Harmony.Tests/DataModelPerformanceTests.cs, src/SIL.Harmony.Tests/PersistExtraDataTests.cs
Remove obsolete test method CanAddTheSameCommitMultipleTimes, fix HybridDateTime formatting, and rename ExtraDataModel.CommitId to LastCommitId with corresponding updates to the Copy() method and test assertions.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • sillsdev/harmony#71: Adjusts EditChange.NewEntity's exception message to reference CommitId, which is now removed from the contract and affects how this message can be constructed.
  • sillsdev/harmony#43: Also modifies DataModel.AddChanges and commit/change-entity construction logic; overlaps with this PR's refactoring of commit-id assignment and ChangeEntity creation.

Suggested reviewers

  • myieye

Poem

🐰 No more CommitId in Change,
Commit now owns the range!
Tests adjust their dance,
IDs find their stance—
A cleaner contract, clear and strange.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.38% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'Prevent clients from setting CommitId' directly and clearly describes the main change: removing the ability for clients to provide CommitId values when adding changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands and usage tips.

…24005170139736

# Conflicts:
#	src/SIL.Harmony/DataModel.cs

@myieye myieye left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good, except:

  • I feel like we should hold onto the deleted test
  • It kind of looks like you were maybe considering totally removing the Commit constructor that accepts a Guid? If you used it, a bunch of your diffs could shrink, but that's just a question of code style.

Comment thread src/SIL.Harmony.Tests/DataModelIntegrityTests.cs
Comment thread src/SIL.Harmony.Tests/DataModelPerformanceTests.cs
Comment thread src/SIL.Harmony/DataModel.cs
@hahn-kev hahn-kev merged commit bfb23a1 into sillsdev:main Jun 12, 2026
3 checks passed
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.

2 participants