Skip to content

Add nodeActivity#1016

Open
ayolab wants to merge 1 commit into
mainfrom
ayolab/add-node-activity
Open

Add nodeActivity#1016
ayolab wants to merge 1 commit into
mainfrom
ayolab/add-node-activity

Conversation

@ayolab

@ayolab ayolab commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Signed-off-by: Ayoub LABIDI <ayoub.labidi@protonmail.com>
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR replaces a boolean "blockedNode" model with a new NodeActivityStatus enum (IDLE, BUILDING, COMPUTATION_RUNNING, UPDATING) for tracking node tree activity. It updates the entity/DTO/repository layers, adds a notification for activity changes, refactors StudyService/RebuildNodeService/RootNetworkNodeInfoService/NetworkModificationTreeService/ConsumerService/SupervisionService to use idle assertions and activity setters instead of block/unblock calls, and updates the controller endpoints accordingly. A Liquibase migration drops blocked_node and adds node_activity_status.

Changes

Node activity status migration

Layer / File(s) Summary
NodeActivityStatus enum, entity/DTO fields, and migration
.../dto/NodeActivityStatus.java, .../entities/RootNetworkNodeInfoEntity.java, .../dto/RootNetworkNodeInfo.java, .../dto/NetworkModificationNode.java, .../dto/BuildStatus.java, .../dto/NodeBuildStatus.java, .../dto/InvalidateNodeTreeParameters.java, db/changelog/changesets/changelog_20260703T120000Z.xml, db/changelog/db.changelog-master.yaml
New NodeActivityStatus enum persisted on the entity (default IDLE) replacing blockedNode; DTOs expose the field; BUILDING removed from BuildStatus/NodeBuildStatus; InvalidateNodeTreeParameters drops withBlockedNode; DB changelog drops blocked_node and adds node_activity_status column.
Repository queries and activity notifications
.../repository/rootnetwork/RootNetworkNodeInfoRepository.java, .../notification/NotificationService.java
Repository adds existsByNodeUuidsAndNotIdle, setNodeActivity, and clearNodeActivity queries; NotificationService adds header/type constants and emitNodeActivityStatusUpdated.
RootNetworkNodeInfoService idle assertions and activity APIs
.../service/RootNetworkNodeInfoService.java
Removes prior blocking/computation-check APIs and blockedNode handling, adds assertTreeIsIdle, setNodeActivity, clearNodeActivity methods that update repository state and emit notifications.
NetworkModificationTreeService UUID computation and cleanup
.../service/NetworkModificationTreeService.java
Adds getNodeAncestorUuids helper for branch UUID computation, removes blockedNode propagation, and removes unblockNodeTree/unblockNode/blockNode methods.
StudyService idle checks, runComputation wrapper, build/unbuild activity
.../service/StudyService.java
Adds assertTreeIsIdle(AcrossAllRootNetworks), activity setters/clearers, a runComputation wrapper, resetNodeBuildStatusAndActivity, updates build/unbuild/root-network-update/loadflow/computation entry points to use activity states, removes unblockNodeTree.
RebuildNodeService activity wrapping
.../service/RebuildNodeService.java
Removes try/finally unblock patterns around modification create/move/duplicate/assemble/insert-composite handlers; restructures handleRebuildNodeWithReturn to set/clear UPDATING activity.
Controller endpoint gating changes
.../controller/StudyController.java
Replaces assertNoBlockedNode* calls with assertTreeIsIdle/assertTreeIsIdleAcrossAllRootNetworks or removes the assertion entirely across many endpoints (node move/duplicate/delete/build/unbuild, modification CRUD/activation, load flow, voltage init).
Consumer/Supervision activity clearing
.../service/ConsumerService.java, .../service/SupervisionService.java
ConsumerService replaces build-status/unblock logic with resetNodeBuildStatusAndActivity and handleClearNodeActivity in build/computation consumer paths; SupervisionService removes try/finally unblock cleanup in invalidateStudy.

Sequence Diagram(s)

sequenceDiagram
  participant StudyController
  participant StudyService
  participant RootNetworkNodeInfoService
  participant NotificationService
  StudyController->>StudyService: assertTreeIsIdle(nodeUuid, rootNetworkUuid)
  StudyService->>RootNetworkNodeInfoService: setNodeActivity(COMPUTATION_RUNNING)
  RootNetworkNodeInfoService->>NotificationService: emitNodeActivityStatusUpdated
  StudyService->>StudyService: runComputation(action)
  StudyService->>RootNetworkNodeInfoService: clearNodeActivity
  RootNetworkNodeInfoService->>NotificationService: emitNodeActivityStatusUpdated(IDLE)
Loading

Suggested reviewers: etiennehomer, flomillot

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 1.04% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive No meaningful pull request description was provided to evaluate. Add a brief description of the node activity and node status changes introduced by this PR.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title is related to the main change and identifies the new node activity feature.
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.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.44.1)
src/main/java/org/gridsuite/study/server/controller/StudyController.java

ast-grep timed out on this file

src/main/java/org/gridsuite/study/server/service/ConsumerService.java

ast-grep retry budget exhausted before isolating this batch

src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java

ast-grep retry budget exhausted before isolating this batch

  • 5 others

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.

@ayolab ayolab added the WIP label Jul 9, 2026

@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: 1

🧹 Nitpick comments (2)
src/main/java/org/gridsuite/study/server/service/StudyService.java (1)

1770-1782: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

getBuildInfos/setModificationReports run after BUILDING is set but outside the try.

If getBuildInfos or setModificationReports throws, clearNodeActivity is not invoked. DB state reverts via the caller's transaction, but the BUILDING activity-status notification emitted by setNodeActivity is not rolled back, so clients can be left seeing a stuck BUILDING state. Consider extending the try to cover these steps.

♻️ Suggested scope widening
         setNodeActivity(studyUuid, rootNetworkUuid, nodeUuid, NodeActivityStatus.BUILDING);
-        BuildInfos buildInfos = networkModificationTreeService.getBuildInfos(nodeUuid, rootNetworkUuid);
-
-        // Store all reports (inherited + new) for this node
-        networkModificationTreeService.setModificationReports(nodeUuid, rootNetworkUuid, buildInfos.getAllReportsAsMap());
         try {
+            BuildInfos buildInfos = networkModificationTreeService.getBuildInfos(nodeUuid, rootNetworkUuid);
+            // Store all reports (inherited + new) for this node
+            networkModificationTreeService.setModificationReports(nodeUuid, rootNetworkUuid, buildInfos.getAllReportsAsMap());
             networkModificationService.buildNode(nodeUuid, rootNetworkUuid, buildInfos, workflowInfos);
         } catch (Exception e) {
             clearNodeActivity(studyUuid, rootNetworkUuid, nodeUuid);
             throw e;
         }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/java/org/gridsuite/study/server/service/StudyService.java` around
lines 1770 - 1782, The node activity can get stuck in BUILDING because
getBuildInfos and setModificationReports run after setNodeActivity but outside
the guarded failure path. Move the build-info retrieval and modification-report
update into the same try/catch used around networkModificationService.buildNode
in StudyService so any exception triggers clearNodeActivity. Keep the existing
cleanup logic in the catch and make sure the BUILDING status is only emitted
once the whole build preparation and execution flow is safely covered.
src/main/java/org/gridsuite/study/server/dto/InvalidateNodeTreeParameters.java (1)

21-25: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Declare these shared presets as final.

These are public shared constant instances but are only static, so they can be accidentally reassigned by any caller, silently corrupting invalidation behavior everywhere. Mark them final.

♻️ Proposed change
-    public static InvalidateNodeTreeParameters ALL = new InvalidateNodeTreeParameters(InvalidationMode.ALL, ComputationsInvalidationMode.ALL);
+    public static final InvalidateNodeTreeParameters ALL = new InvalidateNodeTreeParameters(InvalidationMode.ALL, ComputationsInvalidationMode.ALL);
     `@SuppressWarnings`("checkstyle:AbbreviationAsWordInName")
-    public static InvalidateNodeTreeParameters ONLY_CHILDREN = new InvalidateNodeTreeParameters(InvalidationMode.ONLY_CHILDREN, ComputationsInvalidationMode.ALL);
+    public static final InvalidateNodeTreeParameters ONLY_CHILDREN = new InvalidateNodeTreeParameters(InvalidationMode.ONLY_CHILDREN, ComputationsInvalidationMode.ALL);
     `@SuppressWarnings`("checkstyle:AbbreviationAsWordInName")
-    public static InvalidateNodeTreeParameters ONLY_CHILDREN_BUILD_STATUS = new InvalidateNodeTreeParameters(InvalidationMode.ONLY_CHILDREN_BUILD_STATUS, ComputationsInvalidationMode.ALL);
+    public static final InvalidateNodeTreeParameters ONLY_CHILDREN_BUILD_STATUS = new InvalidateNodeTreeParameters(InvalidationMode.ONLY_CHILDREN_BUILD_STATUS, ComputationsInvalidationMode.ALL);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/org/gridsuite/study/server/dto/InvalidateNodeTreeParameters.java`
around lines 21 - 25, The shared preset instances in
InvalidateNodeTreeParameters are mutable static fields, so they can be
reassigned by callers; make ALL, ONLY_CHILDREN, and ONLY_CHILDREN_BUILD_STATUS
final to treat them as true constants. Update the field declarations in
InvalidateNodeTreeParameters so these public presets cannot be reassigned,
keeping the existing initialization with InvalidationMode and
ComputationsInvalidationMode unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/java/org/gridsuite/study/server/service/StudyService.java`:
- Around line 3244-3246: The modification notification flow in StudyService is
unbalanced because setNodeActivity(...) can throw after
emitStartModificationEquipmentNotification() but before the try/finally block
starts, leaving the UI stuck in MODIFICATIONS_UPDATING_IN_PROGRESS. Reorder the
logic in the same method so the UPDATING state is set before emitting the start
notification, then keep the existing try/finally cleanup with
emitEndModificationEquipmentNotification() and clearNodeActivity() to guarantee
the start/end pair always matches.

---

Nitpick comments:
In
`@src/main/java/org/gridsuite/study/server/dto/InvalidateNodeTreeParameters.java`:
- Around line 21-25: The shared preset instances in InvalidateNodeTreeParameters
are mutable static fields, so they can be reassigned by callers; make ALL,
ONLY_CHILDREN, and ONLY_CHILDREN_BUILD_STATUS final to treat them as true
constants. Update the field declarations in InvalidateNodeTreeParameters so
these public presets cannot be reassigned, keeping the existing initialization
with InvalidationMode and ComputationsInvalidationMode unchanged.

In `@src/main/java/org/gridsuite/study/server/service/StudyService.java`:
- Around line 1770-1782: The node activity can get stuck in BUILDING because
getBuildInfos and setModificationReports run after setNodeActivity but outside
the guarded failure path. Move the build-info retrieval and modification-report
update into the same try/catch used around networkModificationService.buildNode
in StudyService so any exception triggers clearNodeActivity. Keep the existing
cleanup logic in the catch and make sure the BUILDING status is only emitted
once the whole build preparation and execution flow is safely covered.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e65c8fcc-dcc3-45b9-b0e4-0dbf2f83a195

📥 Commits

Reviewing files that changed from the base of the PR and between a76a79c and 525254e.

📒 Files selected for processing (18)
  • src/main/java/org/gridsuite/study/server/controller/StudyController.java
  • src/main/java/org/gridsuite/study/server/dto/InvalidateNodeTreeParameters.java
  • src/main/java/org/gridsuite/study/server/dto/RootNetworkNodeInfo.java
  • src/main/java/org/gridsuite/study/server/networkmodificationtree/dto/BuildStatus.java
  • src/main/java/org/gridsuite/study/server/networkmodificationtree/dto/NetworkModificationNode.java
  • src/main/java/org/gridsuite/study/server/networkmodificationtree/dto/NodeActivityStatus.java
  • src/main/java/org/gridsuite/study/server/networkmodificationtree/dto/NodeBuildStatus.java
  • src/main/java/org/gridsuite/study/server/networkmodificationtree/entities/RootNetworkNodeInfoEntity.java
  • src/main/java/org/gridsuite/study/server/notification/NotificationService.java
  • src/main/java/org/gridsuite/study/server/repository/rootnetwork/RootNetworkNodeInfoRepository.java
  • src/main/java/org/gridsuite/study/server/service/ConsumerService.java
  • src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java
  • src/main/java/org/gridsuite/study/server/service/RebuildNodeService.java
  • src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java
  • src/main/java/org/gridsuite/study/server/service/StudyService.java
  • src/main/java/org/gridsuite/study/server/service/SupervisionService.java
  • src/main/resources/db/changelog/changesets/changelog_20260703T120000Z.xml
  • src/main/resources/db/changelog/db.changelog-master.yaml
💤 Files with no reviewable changes (2)
  • src/main/java/org/gridsuite/study/server/networkmodificationtree/dto/NodeBuildStatus.java
  • src/main/java/org/gridsuite/study/server/networkmodificationtree/dto/BuildStatus.java

Comment thread src/main/java/org/gridsuite/study/server/service/StudyService.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant