Skip to content

test duplicate evaluable configs emit twice idempotently#448

Open
thedavidmeister wants to merge 1 commit intomainfrom
2026-05-05-issue-327-duplicate-evaluable-test
Open

test duplicate evaluable configs emit twice idempotently#448
thedavidmeister wants to merge 1 commit intomainfrom
2026-05-05-issue-327-duplicate-evaluable-test

Conversation

@thedavidmeister
Copy link
Copy Markdown
Contributor

@thedavidmeister thedavidmeister commented May 5, 2026

Summary

flowInit does not de-duplicate identical evaluable configs. Two configs that produce the same (interpreter, store, expression) triple emit two FlowInitialized events and write the same registeredFlows slot twice. The registration is idempotent — the resulting clone is still functional with that evaluable.

This PR pins the current behavior so a future change cannot silently introduce dedup, suppress the second emit, or reject duplicates outright without an explicit ABI bump.

Closes #327.

Test plan

  • testFlowConstructionDuplicateEvaluablesEmitTwiceIdempotently — 100 fuzz runs

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Added test coverage for Flow construction with duplicate evaluable configurations to ensure consistent event emission behavior across identical configurations.

`flowInit` does not de-duplicate identical evaluable configs. Two
configs that produce the same (interpreter, store, expression) triple
emit two FlowInitialized events and write the same registeredFlows
slot twice. The registration is idempotent — the resulting clone is
still functional with that evaluable.

Pinning this prevents a future change from silently introducing
dedup, suppressing the second emit, or rejecting duplicates outright
without an explicit ABI bump.

Closes #327.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

Walkthrough

A new test is added to Flow.construction.t.sol that verifies duplicate evaluable configurations in Flow construction emit multiple FlowInitialized events with identical payloads, pinning the current idempotent behavior.

Changes

Test Addition: Duplicate Evaluables Behavior Verification

Layer / File(s) Summary
Imports & Extensions
test/src/concrete/Flow.construction.t.sol (lines 10–14)
Added imports for EvaluableV2 and LibLogHelper to decode emitted evaluables and filter logged events; enabled LibLogHelper as extension on Vm.Log[].
Test Implementation
test/src/concrete/Flow.construction.t.sol (lines 44–71)
New test testFlowConstructionDuplicateEvaluablesEmitTwiceIdempotently constructs a Flow with two identical EvaluableConfigV3 entries, records logs, asserts exactly two FlowInitialized events are emitted, and verifies both events carry identical evaluable payloads via keccak256 comparison.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related issues

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the test being added: verifying that duplicate evaluable configs emit FlowInitialized events twice idempotently, which matches the main changeset.
Linked Issues check ✅ Passed The PR implementation aligns with issue #327 requirements: it adds a test that records logs during Flow initialization with duplicate configs, asserts two FlowInitialized events are emitted, and verifies the registered evaluable remains callable.
Out of Scope Changes check ✅ Passed All changes are within scope: only a new test function is added to Flow.construction.t.sol with necessary imports (EvaluableV2, LibLogHelper) directly related to the test's logging and assertion requirements.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 2026-05-05-issue-327-duplicate-evaluable-test

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@test/src/concrete/Flow.construction.t.sol`:
- Around line 64-71: After asserting the two FlowInitialized logs and that ev0
and ev1 (both typed EvaluableV2) are identical, add a functional assertion that
the deployed clone is callable with that evaluable: invoke the test-suite's
existing flow execution helper (the same helper used elsewhere in this test
file) against the newly deployed clone using ev0 and assert the call succeeds
(no revert) and returns the expected result/state change; reference the decoded
ev0/ev1 values and the FlowInitialized event from vm.getRecordedLogs() when
locating where to add this execution/assertion.
🪄 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: ASSERTIVE

Plan: Pro

Run ID: 8fc94e11-ecdb-4bd2-b8b9-4d434fa8c6aa

📥 Commits

Reviewing files that changed from the base of the PR and between ceaea3c and f43a5a1.

📒 Files selected for processing (1)
  • test/src/concrete/Flow.construction.t.sol

Comment on lines +64 to +71
Vm.Log[] memory init =
vm.getRecordedLogs().findEvents(keccak256("FlowInitialized(address,(address,address,address))"));
assertEq(init.length, 2, "duplicate configs MUST emit two FlowInitialized events");

(, EvaluableV2 memory ev0) = abi.decode(init[0].data, (address, EvaluableV2));
(, EvaluableV2 memory ev1) = abi.decode(init[1].data, (address, EvaluableV2));
assertEq(keccak256(abi.encode(ev0)), keccak256(abi.encode(ev1)), "duplicate events MUST carry identical evaluable");
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Missing functional assertion after duplicate initialization.

The new test proves duplicate emits (Lines 64-70), but it does not verify the deployed clone remains callable with that evaluable. That post-condition is part of the stated objective, so please add an execution/assertion step after clone deployment using the existing flow execution helper in this test suite.

🤖 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 `@test/src/concrete/Flow.construction.t.sol` around lines 64 - 71, After
asserting the two FlowInitialized logs and that ev0 and ev1 (both typed
EvaluableV2) are identical, add a functional assertion that the deployed clone
is callable with that evaluable: invoke the test-suite's existing flow execution
helper (the same helper used elsewhere in this test file) against the newly
deployed clone using ev0 and assert the call succeeds (no revert) and returns
the expected result/state change; reference the decoded ev0/ev1 values and the
FlowInitialized event from vm.getRecordedLogs() when locating where to add this
execution/assertion.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[A01-8] [INFO] Duplicate evaluable registration in flowInit not pinned

1 participant