Skip to content
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

Add bpmn:InclusiveGateway support #110

Merged
merged 4 commits into from
Nov 30, 2023
Merged

Conversation

barmac
Copy link
Member

@barmac barmac commented Feb 5, 2022

Screen.Recording.2022-02-05.at.15.55.52.mov
  • Outgoing sequence flow enable/disable
  • Default flow handling
  • Sync join

Closes #88

@bpmn-io-tasks bpmn-io-tasks bot added the in progress Currently worked on label Feb 5, 2022
@barmac
Copy link
Member Author

barmac commented Feb 5, 2022

Screen.Recording.2022-02-05.at.17.22.55.mov

I've added default flow handling. You cannot select it manually but it will be selected when you disable remaining flows.

@barmac
Copy link
Member Author

barmac commented Feb 5, 2022

Currently, we don't allow to synchronize the tokens. As a result, a converging inclusive gateway is equal to a converging exclusive gateway, i.e. tokens of the same execution don't wait one for another.

I checked how Camunda Platform handles the synchronization (which is enforced) and it seems to count tokens waiting at the gateway and traverse the graph in order to count possible paths to the gateway. If there are no more tokens which can reach the gateway, the execution is resumed. Cf. https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/InclusiveGatewayActivityBehavior.java#L141

If I am to implement it in a similar way (which sounds reasonable), I need to find out how to access the currently active tokens within the execution. Any hints will be appreciated.

@barmac barmac force-pushed the 88-implement-inclusive-gateway-support branch from a30d5e7 to cd10989 Compare February 6, 2022 00:41
@barmac
Copy link
Member Author

barmac commented Feb 6, 2022

Screen.Recording.2022-02-06.at.01.25.38.mov

Now we enforce synchronization on join. It waits for any tokens which can possibly reach the inclusive gateway.

Via a30d5e7 I added Camunda Platform-like behavior that when there are enough tokens waiting at the gateway as the number of incoming flows. I removed it afterwards, because this leads sometimes to a deadlock when there is a fake-join or a parallel gateway is not joined. Not sure if we should account for bad practices. Still, I'd rather avoid deadlock in the simulation when it's possible.

Is it how it's defined in the spec? There's no real specification on the inclusive gateway. Therefore, I can't determine the correct behavior from the PDF.

I will add a couple of test cases later and then I think we can initiate the review.

@barmac barmac force-pushed the 88-implement-inclusive-gateway-support branch from cd10989 to 075f686 Compare February 18, 2022 15:20
@barmac barmac changed the title wip: add bpmn:InclusiveGateway support Add bpmn:InclusiveGateway support Feb 18, 2022
@barmac barmac force-pushed the 88-implement-inclusive-gateway-support branch from 075f686 to 31db2c4 Compare February 18, 2022 21:11
@barmac barmac marked this pull request as ready for review February 18, 2022 21:14
@bpmn-io-tasks bpmn-io-tasks bot added needs review Review pending and removed in progress Currently worked on labels Feb 18, 2022
@barmac barmac requested a review from nikku February 18, 2022 21:14
@barmac
Copy link
Member Author

barmac commented Feb 18, 2022

I've added the following changes:

  • Join is now handled as in Camunda Platform, i.e. we wait for at most as many tokens as there are incoming sequence flows; this is similar to how we handle the parallel gateway. If there are no more tokens which have a direct route to the gateway, the join is performed with smaller number of tokens.
  • For fork, when user deactivates the last active sequence flow and there is no default flow, another flow is activated. This is to prevent an error when no outgoing flows are active. We could roll this back if there is a way to notify incidents in the simulation.

There is one problem for which we'd need to add more changes to the library. The switch to activate/deactivate a sequence flow is attached to the connection. Then, the context pads module does not allow to set the position of the overlay. As a result, when there are multiple sequence flows starting from the same point, the switches overlap. Have a look at the screenshot:

image

@barmac
Copy link
Member Author

barmac commented Feb 22, 2022

There is a bug when running multiple simulations at once. We don't properly check the parent context.

Also, we should avoid a non-spec-compliant deadlock when a boundary event is triggered after other tokens arrived.

@barmac barmac marked this pull request as draft February 22, 2022 12:53
@bpmn-io-tasks bpmn-io-tasks bot added in progress Currently worked on and removed needs review Review pending labels Feb 22, 2022
@nikku nikku added the backlog Queued in backlog label May 5, 2022 — with bpmn-io-tasks
@nikku nikku removed the in progress Currently worked on label May 5, 2022
@nikku
Copy link
Member

nikku commented May 5, 2022

Moving this back to backlog. Let us await further feedback before actually merging a 🪄 🎉 👾 element behavior.

@barmac
Copy link
Member Author

barmac commented May 5, 2022

Sure, let's wait for Gandalf the White to figure this out ^^

vpanfilov pushed a commit to vpanfilov/bpmn-js-token-simulator-test that referenced this pull request Sep 23, 2022
vpanfilov pushed a commit to vpanfilov/bpmn-js-token-simulator-test that referenced this pull request Sep 23, 2022
vpanfilov pushed a commit to vpanfilov/bpmn-js-token-simulator-test that referenced this pull request Sep 23, 2022
@JaySmith
Copy link

How can I get this functionality? I would love to have this.

@nikku
Copy link
Member

nikku commented Jan 20, 2023

@JaySmith Please refer to #88 (comment).

What is your practical use of inclusive gateway support within this tool?

@barmac
Copy link
Member Author

barmac commented Jan 23, 2023

How can I get this functionality? I would love to have this.

Feel free to fix the remaining issues of this implementation: #110 (comment)

@JaySmith
Copy link

@JaySmith Please refer to #88 (comment).

What is your practical use of inclusive gateway support within this tool?

I am documenting our project lifecycle process and at the end our project managers need to perform several activities. For example if they have a open purchase order they need to close it, if they have a capital expenditure request they need to close that as well, if they have implemented a new software solution that needs budget for future maintenance and licensing they need to have that added to the next years budget.

Not all of these will apply. Is there a different way to do that?

Jay

@barmac
Copy link
Member Author

barmac commented Nov 20, 2023

I've fixed the remaining issues. I believe this is now BPMN-compliant.

Screen.Recording.2023-11-20.at.18.20.56.mov

@barmac barmac force-pushed the 88-implement-inclusive-gateway-support branch from 622e6ef to 5634e68 Compare November 20, 2023 17:29
@nikku
Copy link
Member

nikku commented Nov 28, 2023

@barmac This looks great! 🤩

Will give it a comprehensive review tomorrow.

@nikku nikku force-pushed the 88-implement-inclusive-gateway-support branch from 56dd291 to c31478c Compare November 29, 2023 19:21
Copy link
Member

@nikku nikku left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution. It is great:

  • It uses the batteries included facilities the engine already offers (waiting for scopes changing and more ❤️)
  • It is really simple at the core
  • It even supports default flows in a convenient manner 🎉

Please check a bunch of improvements I'd put on top, namely a simplified (and unified) join behavior, and re-using the activityBehavior to advance execution after a join + a bunch of extra tests.

@barmac
Copy link
Member Author

barmac commented Nov 30, 2023

Thanks for the review and the improvements to the PR. I think the changes make sense.

There is still a CI job failing and it complains about CSS file not being present: https://github.com/bpmn-io/bpmn-js-token-simulation/actions/runs/7038213433/job/19154806002?pr=110 I will check if we can fix it easily.

@nikku
Copy link
Member

nikku commented Nov 30, 2023

#110 (comment)

This we can ignore, as it is a non-lethal change. In fact the actual test failure is due to a shaky test case:

image

Unfortunately I was not able to further stabilize the test cases as things work just fine locally for me.

@nikku nikku force-pushed the 88-implement-inclusive-gateway-support branch from de5ad73 to 7096ba0 Compare November 30, 2023 09:06
@nikku
Copy link
Member

nikku commented Nov 30, 2023

Squashed the changes on this branch (where it makes sense).

@nikku nikku force-pushed the 88-implement-inclusive-gateway-support branch from 7096ba0 to 59b5234 Compare November 30, 2023 09:06
@barmac
Copy link
Member Author

barmac commented Nov 30, 2023

I can reproduce the CSS issue but not the test failing. Do we really need to support bpmn-js@8 though? @nikku

@barmac
Copy link
Member Author

barmac commented Nov 30, 2023

Sorry, I missed your comments above. Still, I think we could safely move to bpmn-js@11 or even higher at no cost.

@barmac barmac requested a review from nikku November 30, 2023 10:06
@nikku
Copy link
Member

nikku commented Nov 30, 2023

Sorry, I missed your comments above. Still, I think we could safely move to bpmn-js@11 or even higher at no cost.

We're testing against both legacy and new versions, and I think that is fine. Or do you propose to ditch our legacy tests? We'll want to do that at some point, yes.

@barmac
Copy link
Member Author

barmac commented Nov 30, 2023

Given that the legacy test fails for no meaningful reason, the failure is not reproducible locally, and the version the test runs against is 2 years old and 7 major versions behind, my suggestion is to leave v8 behind and test against a version closer to the current one. Or we find out why the tests fail.

@nikku
Copy link
Member

nikku commented Nov 30, 2023

@barmac The test failure is non-deterministic, and can happen on the current version of bpmn-js, too.

@nikku
Copy link
Member

nikku commented Nov 30, 2023

I dropped the legacy tests via c8bc118, however the build instabilities will likely remain. 👀

@nikku
Copy link
Member

nikku commented Nov 30, 2023

@nikku nikku merged commit e875490 into main Nov 30, 2023
2 of 4 checks passed
@nikku nikku deleted the 88-implement-inclusive-gateway-support branch November 30, 2023 15:46
@bpmn-io-tasks bpmn-io-tasks bot removed the needs review Review pending label Nov 30, 2023
@nikku
Copy link
Member

nikku commented Nov 30, 2023

Merged, as all test failures are unrelated to this PR.

@barmac
Copy link
Member Author

barmac commented Nov 30, 2023

Oh, that's terrible :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
spring cleaning Could be cleaned up one day
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inclusive Gateways support
4 participants