It can be confusing to users that just because their simulation returned with a green checkmark does not mean the simulation data passes constraints.
To address this, I propose adding a setting to simulation, similar to the Force Resimulate setting, that, when enabled, automatically checks constraints after the simulation completes. The user would need to have both the "can simulate" and "can check constraints" permissions on the plan to simulate with this option enabled. The state of this flag should be stored in the database as part of the simulation dataset information.
Because Simulation and Constraints run in separate containers, I expect that this automation will need to happen in one of two ways:
- (and my recommendation) A DB listener is added to the Merlin Server that watches for "complete"d simulations with the "check constraints" flag enabled. When it finds one, it starts a constraints run on that dataset.
- The simulation workers submit a constraint request (either via Hasura or an HTTP request) under the user's name. I don't recommend this, as the token information needed to submit the constraint request is only in the Merlin Server part of the request and never passed to the workers.
- Sort of a combination of (1) and (2), but instead of an always-running DB Listener, the
simulation endpoint in the Merlin Server will start a daemon thread to await the simulation, then trigger constraints. While this would avoid the token issues with (2) (as the Server would have the token), this pattern isn't how we usually code these sorts of things.
By the by, I think the "check constraints after" flag itself can be handled in one of two ways:
- it's passed as an argument to the
simulate hasura action.
- it's stored on the simulation specification
I wrote this ticket assuming (1)
It can be confusing to users that just because their simulation returned with a green checkmark does not mean the simulation data passes constraints.
To address this, I propose adding a setting to simulation, similar to the
Force Resimulatesetting, that, when enabled, automatically checks constraints after the simulation completes. The user would need to have both the "can simulate" and "can check constraints" permissions on the plan to simulate with this option enabled. The state of this flag should be stored in the database as part of the simulation dataset information.Because Simulation and Constraints run in separate containers, I expect that this automation will need to happen in one of two ways:
simulationendpoint in the Merlin Server will start a daemon thread to await the simulation, then trigger constraints. While this would avoid the token issues with (2) (as the Server would have the token), this pattern isn't how we usually code these sorts of things.By the by, I think the "check constraints after" flag itself can be handled in one of two ways:
simulatehasura action.I wrote this ticket assuming (1)