Follow-up from the test-suite review (batches merged as #92–#96).
Gap
DataModel.AddManyChanges is a public bulk-write entry point with its own chunking (changesPerCommitMax, one commit per chunk) and empty-input early return (if (commits is []) return). No test calls it — the chunk-splitting math and per-chunk commit flow are entirely unverified.
|
public async Task AddManyChanges(Guid clientId, |
|
IEnumerable<IChange> changes, |
|
Func<CommitMetadata?> commitMetadata, |
|
int changesPerCommitMax = 100) |
|
{ |
|
await using var repo = await _crdtRepositoryFactory.CreateRepository(); |
|
var commits = changes |
|
.Chunk(changesPerCommitMax) |
|
.Select(chunk => NewCommit(clientId, commitMetadata(), chunk)) |
|
.ToArray(); |
|
if (commits is []) return; |
|
using var locked = await repo.Lock(); |
|
repo.ClearChangeTracker(); |
|
|
|
await using var transaction = await repo.BeginTransactionAsync(); |
|
var updatedCommits = await repo.AddCommits(commits); |
|
await UpdateSnapshots(repo, updatedCommits); |
|
await ValidateCommits(repo); |
|
await transaction.CommitAsync(); |
|
} |
Suggested tests
AddManyChanges_SplitsChangesIntoCommitsOfMaxSize
AddManyChanges_WithNoChangesDoesNothing
Why it matters
It is a distinct write path with its own transaction/lock/validate flow; a bug in the chunking could silently mis-group changes into the wrong commits.
Follow-up from the test-suite review (batches merged as #92–#96).
Gap
DataModel.AddManyChangesis a public bulk-write entry point with its own chunking (changesPerCommitMax, one commit per chunk) and empty-input early return (if (commits is []) return). No test calls it — the chunk-splitting math and per-chunk commit flow are entirely unverified.harmony/src/SIL.Harmony/DataModel.cs
Lines 61 to 80 in 03f609f
Suggested tests
AddManyChanges_SplitsChangesIntoCommitsOfMaxSizeAddManyChanges_WithNoChangesDoesNothingWhy it matters
It is a distinct write path with its own transaction/lock/validate flow; a bug in the chunking could silently mis-group changes into the wrong commits.