Skip to content

Conversation

angelacorte
Copy link
Collaborator

No description provided.

@angelacorte angelacorte added the auto-update-rebase Mergify will try to update with rebase label Nov 12, 2024
@angelacorte angelacorte changed the title feat: add timer (Block T), shared timer and time replicated functions feat(stdlib): add timer (Block T), shared timer and time replicated functions Nov 12, 2024
Copy link

codecov bot commented Nov 12, 2024

Codecov Report

❌ Patch coverage is 59.37500% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.11%. Comparing base (ac01c02) to head (af21187).

Files with missing lines Patch % Lines
...n/kotlin/it/unibo/collektive/stdlib/SharedTimer.kt 62.85% 12 Missing and 1 partial ⚠️
...monMain/kotlin/it/unibo/collektive/stdlib/Timer.kt 0.00% 11 Missing ⚠️
...tlin/it/unibo/collektive/stdlib/TimeReplication.kt 88.23% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #566      +/-   ##
==========================================
- Coverage   70.10%   65.11%   -5.00%     
==========================================
  Files          27       38      +11     
  Lines         689      943     +254     
  Branches      119      157      +38     
==========================================
+ Hits          483      614     +131     
- Misses        131      242     +111     
- Partials       75       87      +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@angelacorte angelacorte marked this pull request as ready for review November 15, 2024 11:12
@DanySK DanySK force-pushed the feat/timeReplication branch 26 times, most recently from c58689f to a53b7f0 Compare November 22, 2024 09:52
@angelacorte angelacorte added auto-update-merge Mergify will try to update with merge and removed auto-update-merge Mergify will try to update with merge labels Oct 1, 2025
@angelacorte angelacorte marked this pull request as ready for review October 21, 2025 19:57
@angelacorte angelacorte requested a review from Copilot October 21, 2025 19:57
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces timer-based functionality to the Collektive standard library, including Block T (timer), shared timer mechanisms, and time-replicated process management. The implementation enables time-aware aggregate programming by providing utilities for synchronized clocks, periodic process replication, and temporal decay mechanisms across distributed devices.

Key changes:

  • Adds core timer primitives with configurable decay rates and bounds
  • Implements shared clock synchronization across devices to prevent time drift
  • Introduces time-replicated process management with automatic replica lifecycle control

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
collektive-stdlib/src/commonMain/kotlin/it/unibo/collektive/stdlib/Timer.kt Implements basic timer primitives with decay functions
collektive-stdlib/src/commonMain/kotlin/it/unibo/collektive/stdlib/SharedTimer.kt Provides shared clock synchronization and distributed timer management
collektive-stdlib/src/commonMain/kotlin/it/unibo/collektive/stdlib/TimeReplication.kt Implements time-based process replication with automatic cleanup
collektive-stdlib/src/commonTest/kotlin/it/unibo/collektive/stdlib/test/SharedClockTest.kt Tests for shared clock synchronization behavior
collektive-stdlib/src/commonTest/kotlin/it/unibo/collektive/stdlib/test/TimeReplicatedTest.kt Tests for time-replicated process functionality
collektive-stdlib/build.gradle.kts Adds kotlinx-datetime dependency
alchemist-incarnation-collektive/src/main/kotlin/it/unibo/alchemist/collektive/device/CollektiveDevice.kt Changes in-memory flag for device implementation

* It starts from a [timeout] and decreases by [decayRate].
*/
fun <ID : Comparable<ID>> Aggregate<ID>.countDownWithDecay(timeout: Duration, decayRate: Duration): Duration =
timer(timeout, ZERO) { time -> time - decayRate }
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

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

The decay parameter in the timer call should be decayRate instead of ZERO. The current implementation will never decay the timer since it passes ZERO as the decay value while the lambda correctly uses decayRate. This should be: timer(timeout, decayRate) { time -> time - decayRate }.

Suggested change
timer(timeout, ZERO) { time -> time - decayRate }
timer(timeout, decayRate) { time -> time - decayRate }

Copilot uses AI. Check for mistakes.

@@ -0,0 +1,127 @@
/*
* Copyright (c) 2025, Danilo Pianini, Nicolas Farabegoli, Elisa Tronetti,
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

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

Corrected copyright year from 2025 to 2024 for consistency with other files in the same commit.

Suggested change
* Copyright (c) 2025, Danilo Pianini, Nicolas Farabegoli, Elisa Tronetti,
* Copyright (c) 2024, Danilo Pianini, Nicolas Farabegoli, Elisa Tronetti,

Copilot uses AI. Check for mistakes.

alignedOn(it.id) {
process()
}
}.first()
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

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

Calling .first() on an empty collection will throw NoSuchElementException if localRep is empty (which can occur when maxReplicas is 0 or on the first execution before any replicas are created). Add a check to handle the empty case or use .firstOrNull() with appropriate default handling.

Suggested change
}.first()
}.firstOrNull() ?: process()

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-update-rebase Mergify will try to update with rebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants