@@ -174,6 +174,37 @@ contract FlowConstructionTest is FlowTest {
174174 assertEq (keccak256 (abi.encode (flowConfig)), keccak256 (abi.encode (config)), "wrong compare Structs " );
175175 }
176176
177+ /// `flowInit` does not de-duplicate identical evaluable configs: two
178+ /// configs that produce the same `(interpreter, store, expression)`
179+ /// triple emit two `FlowInitialized` events and write the same
180+ /// `registeredFlows` slot twice. The registration is idempotent so
181+ /// the resulting clone is still functional with that evaluable.
182+ /// forge-config: default.fuzz.runs = 100
183+ function testFlowConstructionDuplicateEvaluablesEmitTwiceIdempotently (
184+ address expression ,
185+ bytes memory bytecode ,
186+ uint256 [] memory constants
187+ ) external {
188+ expressionDeployerDeployExpression2MockCall (bytecode, constants, expression, bytes (hex "0007 " ));
189+
190+ EvaluableConfigV3[] memory flowConfig = new EvaluableConfigV3 [](2 );
191+ flowConfig[0 ] = EvaluableConfigV3 (DEPLOYER, bytecode, constants);
192+ flowConfig[1 ] = EvaluableConfigV3 (DEPLOYER, bytecode, constants);
193+
194+ vm.recordLogs ();
195+ I_CLONE_FACTORY.clone (deployFlowImplementation (), abi.encode (flowConfig));
196+
197+ Vm.Log[] memory init =
198+ vm.getRecordedLogs ().findEvents (keccak256 ("FlowInitialized(address,(address,address,address)) " ));
199+ assertEq (init.length , 2 , "duplicate configs MUST emit two FlowInitialized events " );
200+
201+ (, EvaluableV2 memory ev0 ) = abi.decode (init[0 ].data, (address , EvaluableV2));
202+ (, EvaluableV2 memory ev1 ) = abi.decode (init[1 ].data, (address , EvaluableV2));
203+ assertEq (
204+ keccak256 (abi.encode (ev0)), keccak256 (abi.encode (ev1)), "duplicate events MUST carry identical evaluable "
205+ );
206+ }
207+
177208 /// `flowInit` MUST emit one `FlowInitialized(sender, evaluable)` per
178209 /// registered config, with `sender` equal to the clone-factory caller
179210 /// and `evaluable` equal to the deployer-returned `(interpreter, store,
0 commit comments