Skip to content

Conversation

@insipx
Copy link
Contributor

@insipx insipx commented Dec 10, 2025

Add proptest regression for ordered stream and expose crate::protocol::test during tests to validate stream ordering d14n

Add a regression seed file for the ordered stream property test and introduce a test-only re-export crate::protocol::test. Implement a proptest orders_stream_and_ices_missing in xmtp_api_d14n/src/queries/stream/ordered.rs that verifies topic clock dominance and asserts non-empty icebox when dependencies are missing.

📍Where to Start

Start with the orders_stream_and_ices_missing property test in xmtp_api_d14n/src/queries/stream/ordered.rs.


Macroscope summarized 0c8cf67.

@insipx
Copy link
Contributor Author

insipx commented Dec 10, 2025

@claude
Copy link

claude bot commented Dec 10, 2025

Claude finished @insipx's task —— View job


Code Review Complete

Review Date: December 15, 2025 21:25 UTC

Summary

This PR adds comprehensive property-based testing for the OrderedStream implementation. The proptest validates that the stream correctly orders envelopes and ices those with unsatisfied dependencies. Overall, the test is well-structured and follows proptest best practices.

✅ Strengths

  1. Excellent test strategy: Using missing_dependencies() to generate both sorted envelopes and randomly removed dependencies is a robust approach for testing offline ordering edge cases.

  2. Proper assertions: The test validates two critical properties:

    • All returned envelopes have their dependencies satisfied (lines 136-144)
    • Envelopes with missing dependencies are properly iced (lines 147-154)
  3. Good use of #[xmtp_common::test]: Follows the project's testing guidelines for cross-platform compatibility.

  4. Regression file committed: The proptest regression file ensures failed cases are re-run, preventing regressions.

💡 Minor Suggestions

  1. Test coverage gap (xmtp_api_d14n/src/queries/stream/ordered.rs:116-156): The current test only checks a single stream chunk. Consider adding a test case for multi-chunk streams to verify that the TopicCursor is correctly maintained across multiple poll_next() calls and that iced items from earlier chunks can be resolved by later chunks.

  2. Documentation clarity (xmtp_api_d14n/src/queries/stream/ordered.rs:146-154): The conditional assertion logic could benefit from a comment explaining why has_deps_on_removed is necessary—specifically that not all removed envelopes will cause icing (only those that have dependent envelopes in the stream).

  3. Export visibility (xmtp_api_d14n/src/protocol/mod.rs:29): The pub use utils::test; export makes test utilities public. Verify this is intentional for external testing—if only for internal use, consider pub(crate).

🔒 Security & Performance

  • No security concerns identified
  • Performance is appropriate for property-based testing; the test uses .now_or_never() correctly for single-chunk validation

@insipx insipx force-pushed the insipx/ordered-stream branch from 73192df to 971b4a4 Compare December 10, 2025 19:32
@insipx insipx force-pushed the insipx/ordered-stream-test branch 2 times, most recently from 3f3a58c to 6ba6ea2 Compare December 10, 2025 19:34
@insipx insipx changed the title proptest ordered stream implementation proptest d14n-ordered stream Dec 10, 2025
@insipx insipx force-pushed the insipx/ordered-stream-test branch from 6ba6ea2 to a50ee9d Compare December 10, 2025 19:39
@insipx insipx force-pushed the insipx/ordered-stream branch from 971b4a4 to 5ac4ca2 Compare December 10, 2025 19:39
@insipx insipx force-pushed the insipx/ordered-stream-test branch 2 times, most recently from b10a5c9 to 96e5bea Compare December 10, 2025 19:42
@insipx insipx force-pushed the insipx/ordered-stream branch 2 times, most recently from 5afbe75 to 0e4dc44 Compare December 10, 2025 19:52
@insipx insipx force-pushed the insipx/ordered-stream-test branch from 96e5bea to 514b134 Compare December 10, 2025 19:52
@insipx insipx force-pushed the insipx/ordered-stream branch from 0e4dc44 to b159bdc Compare December 10, 2025 20:12
@insipx insipx force-pushed the insipx/ordered-stream-test branch from 514b134 to 867ab43 Compare December 10, 2025 20:12
@insipx insipx force-pushed the insipx/ordered-stream branch from b159bdc to 254c39d Compare December 10, 2025 20:19
@insipx insipx force-pushed the insipx/ordered-stream-test branch from 867ab43 to 3b6cfb3 Compare December 10, 2025 20:19
@insipx insipx force-pushed the insipx/ordered-stream branch from 254c39d to 57b66f7 Compare December 10, 2025 20:35
@insipx insipx force-pushed the insipx/ordered-stream-test branch from 3b6cfb3 to 8a44bac Compare December 10, 2025 20:35
@insipx insipx force-pushed the insipx/ordered-stream branch from 8dda587 to d1cb961 Compare December 11, 2025 19:43
@insipx insipx force-pushed the insipx/ordered-stream-test branch 2 times, most recently from 3283454 to bc7e5c4 Compare December 11, 2025 20:42
@insipx insipx force-pushed the insipx/ordered-stream branch 2 times, most recently from 4ec3e28 to f19d0ff Compare December 11, 2025 21:02
@insipx insipx force-pushed the insipx/ordered-stream-test branch from bc7e5c4 to 82f999c Compare December 11, 2025 21:02
@insipx insipx force-pushed the insipx/ordered-stream-test branch from 82f999c to 7819787 Compare December 15, 2025 17:18
@insipx insipx force-pushed the insipx/ordered-stream branch 2 times, most recently from 189f79a to d0c293f Compare December 15, 2025 17:53
@insipx insipx force-pushed the insipx/ordered-stream-test branch from 7819787 to db2a1dc Compare December 15, 2025 17:53
@insipx insipx force-pushed the insipx/ordered-stream branch from d0c293f to cc932d2 Compare December 15, 2025 19:08
@insipx insipx force-pushed the insipx/ordered-stream-test branch 2 times, most recently from 2b01520 to cf96672 Compare December 15, 2025 19:27
@insipx insipx force-pushed the insipx/ordered-stream branch from cc932d2 to 3ec02cb Compare December 15, 2025 19:27
@insipx insipx force-pushed the insipx/ordered-stream-test branch from cf96672 to d9065e4 Compare December 15, 2025 19:27
@insipx insipx force-pushed the insipx/ordered-stream branch from 3ec02cb to 4d7d1b4 Compare December 15, 2025 19:27
@insipx insipx force-pushed the insipx/ordered-stream-test branch from d9065e4 to cbd0605 Compare December 15, 2025 19:27
@insipx insipx force-pushed the insipx/ordered-stream branch 2 times, most recently from 46e5a2a to 76e0de7 Compare December 15, 2025 20:15
@insipx insipx force-pushed the insipx/ordered-stream-test branch from cbd0605 to 75baa56 Compare December 15, 2025 20:15
@insipx insipx force-pushed the insipx/ordered-stream branch from 76e0de7 to cd80e47 Compare December 15, 2025 20:50
@insipx insipx force-pushed the insipx/ordered-stream-test branch from 75baa56 to b3948c6 Compare December 15, 2025 20:50
Base automatically changed from insipx/ordered-stream to main December 15, 2025 21:04
@insipx insipx enabled auto-merge (squash) December 15, 2025 21:04
@insipx insipx force-pushed the insipx/ordered-stream-test branch from b3948c6 to 0c8cf67 Compare December 15, 2025 21:24
@insipx insipx merged commit 28e328a into main Dec 15, 2025
16 checks passed
@insipx insipx deleted the insipx/ordered-stream-test branch December 15, 2025 21:37
rygine pushed a commit that referenced this pull request Dec 28, 2025
<!-- Macroscope's pull request summary starts here -->
<!-- Macroscope will only edit the content between these invisible
markers, and the markers themselves will not be visible in the GitHub
rendered markdown. -->
<!-- If you delete either of the start / end markers from your PR's
description, Macroscope will post its summary as a comment. -->
### Add proptest regression for ordered stream and expose
`crate::protocol::test` during tests to validate stream ordering d14n
Add a regression seed file for the ordered stream property test and
introduce a test-only re-export `crate::protocol::test`. Implement a
proptest `orders_stream_and_ices_missing` in
[xmtp_api_d14n/src/queries/stream/ordered.rs](https://github.com/xmtp/libxmtp/pull/2933/files#diff-59cd7abcfecc1658fc695f54e7da04f764862629dabf0aa0e4fafc684c6e732e)
that verifies topic clock dominance and asserts non-empty icebox when
dependencies are missing.

#### 📍Where to Start
Start with the `orders_stream_and_ices_missing` property test in
[xmtp_api_d14n/src/queries/stream/ordered.rs](https://github.com/xmtp/libxmtp/pull/2933/files#diff-59cd7abcfecc1658fc695f54e7da04f764862629dabf0aa0e4fafc684c6e732e).

----
<!-- Macroscope's review summary starts here -->

<a href="https://app.macroscope.com">Macroscope</a> summarized cbd0605.
<!-- Macroscope's review summary ends here -->
<!-- macroscope-ui-refresh -->
<!-- Macroscope's pull request summary ends here -->
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.

3 participants