-
-
Notifications
You must be signed in to change notification settings - Fork 3
refactor: remove redundant jMolecules comments and improve ID extraction #293
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
Open
kamiazya
wants to merge
4
commits into
main
Choose a base branch
from
feature/jmolecules-ddd-migration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ab57cc9
feat(domain): migrate ScopeAggregate to jMolecules AggregateRoot
kamiazya ffe5feb
feat(domain): migrate Scope entity to jMolecules Entity
kamiazya f219c9c
refactor: remove redundant jMolecules comments and improve ID extraction
kamiazya 82dd403
feat(domain): complete jMolecules DDD migration
kamiazya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
apps/scopes/src/test/kotlin/io/github/kamiazya/scopes/apps/cli/test/TestDataHelper.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,23 +3,36 @@ package io.github.kamiazya.scopes.devicesync.domain.entity | |||||||||||||||
| import io.github.kamiazya.scopes.devicesync.domain.valueobject.DeviceId | ||||||||||||||||
| import io.github.kamiazya.scopes.devicesync.domain.valueobject.VectorClock | ||||||||||||||||
| import kotlinx.datetime.Instant | ||||||||||||||||
| import org.jmolecules.ddd.types.AggregateRoot | ||||||||||||||||
| import kotlin.time.Duration | ||||||||||||||||
|
|
||||||||||||||||
| /** | ||||||||||||||||
| * Represents the synchronization state between this device and another device. | ||||||||||||||||
| * | ||||||||||||||||
| * This entity encapsulates the business logic for managing synchronization state, | ||||||||||||||||
| * including state transitions, sync readiness checks, and error handling. | ||||||||||||||||
| * | ||||||||||||||||
| * Each SyncState is uniquely identified by the remote DeviceId it syncs with. | ||||||||||||||||
| */ | ||||||||||||||||
| data class SyncState( | ||||||||||||||||
| val deviceId: DeviceId, | ||||||||||||||||
| private val _deviceId: DeviceId, | ||||||||||||||||
| val lastSyncAt: Instant?, | ||||||||||||||||
| val remoteVectorClock: VectorClock, | ||||||||||||||||
| val lastSuccessfulPush: Instant?, | ||||||||||||||||
| val lastSuccessfulPull: Instant?, | ||||||||||||||||
| val syncStatus: SyncStatus, | ||||||||||||||||
| val pendingChanges: Int = 0, | ||||||||||||||||
| ) { | ||||||||||||||||
| ) : AggregateRoot<SyncState, DeviceId> { | ||||||||||||||||
|
|
||||||||||||||||
| /** | ||||||||||||||||
| */ | ||||||||||||||||
| override fun getId(): DeviceId = _deviceId | ||||||||||||||||
|
Comment on lines
+27
to
+29
Contributor
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. The KDoc for the overridden
Suggested change
|
||||||||||||||||
|
|
||||||||||||||||
| /** | ||||||||||||||||
| * Public accessor for deviceId. | ||||||||||||||||
| */ | ||||||||||||||||
| val deviceId: DeviceId | ||||||||||||||||
| get() = _deviceId | ||||||||||||||||
| init { | ||||||||||||||||
| require(pendingChanges >= 0) { "Pending changes cannot be negative" } | ||||||||||||||||
| lastSuccessfulPush?.let { push -> | ||||||||||||||||
|
|
||||||||||||||||
21 changes: 21 additions & 0 deletions
21
...zation/domain/src/main/kotlin/io/github/kamiazya/scopes/devicesync/domain/package-info.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| @file:DomainLayer | ||
|
|
||
| package io.github.kamiazya.scopes.devicesync.domain | ||
|
|
||
| import org.jmolecules.architecture.layered.DomainLayer | ||
|
|
||
| /** | ||
| * Device Synchronization domain package. | ||
| * | ||
| * This bounded context handles multi-device consistency and synchronization. | ||
| * It models vector clocks, sync states, conflicts, and the synchronization protocol. | ||
| * | ||
| * Domain Types: | ||
| * - DeviceId: Identifier for devices (jMolecules Identifier) | ||
| * - SyncState: Entity tracking synchronization state per device | ||
| * - SyncConflict: Entity representing detected conflicts | ||
| * - VectorClock: Value object for causal ordering | ||
| * | ||
| * Domain Services: | ||
| * - DeviceSynchronizationService: Core sync logic | ||
| */ |
14 changes: 14 additions & 0 deletions
14
...ain/src/main/kotlin/io/github/kamiazya/scopes/devicesync/domain/valueobject/ConflictId.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package io.github.kamiazya.scopes.devicesync.domain.valueobject | ||
|
|
||
| import io.github.kamiazya.scopes.platform.commons.id.ULID | ||
| import org.jmolecules.ddd.types.Identifier | ||
|
|
||
| /** | ||
| * Identity for SyncConflict entity. | ||
| */ | ||
| @JvmInline | ||
| value class ConflictId(val value: String) : Identifier { | ||
| companion object { | ||
| fun generate(): ConflictId = ConflictId(ULID.generate().value) | ||
| } | ||
| } |
4 changes: 3 additions & 1 deletion
4
...omain/src/main/kotlin/io/github/kamiazya/scopes/devicesync/domain/valueobject/DeviceId.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🛠️ Refactor suggestion | 🟠 Major
Add @ConsistentCopyVisibility annotation for consistency.
Similar to
AspectDefinition.kt(line 23), this data class uses a private backing field (_deviceId) for identity but lacks the@ConsistentCopyVisibilityannotation. Without it, the generatedcopy()method may expose the private constructor parameter, potentially allowing external code to modify the aggregate's identity.Apply this diff:
+@ConsistentCopyVisibility data class SyncState( private val _deviceId: DeviceId,📝 Committable suggestion
🤖 Prompt for AI Agents