forked from matrix-org/complement-crypto
-
Notifications
You must be signed in to change notification settings - Fork 0
chore: support sharding/parallel runs, namespace scopes via COMPLEMENT_CRYPTO_NAMESPACE
#1
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
Open
gamesguru
wants to merge
30
commits into
main
Choose a base branch
from
guru/ci/support-sharded-parallel-runs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
2c1bded
chore: support sharding/parallel runs, namespace scopes via `COMPLEME…
gamesguru ae35784
tests: validate COMPLEMENT_CRYPTO_NAMESPACE before use
gamesguru 379f122
Update tests/namespace_test.go
gamesguru 5aac0ba
fix(justfile): rebuild-rust-sdk injects real crypto feature via cargo…
gamesguru 250527b
test(crypto): retry fallback-key claim to tolerate async SDK upload
gamesguru 9277df7
Address PR review comments
gamesguru bef10d1
test: wait for spoofed event before checking state
gamesguru 579b68b
fix: run JS SDK rebuild through Corepack
gamesguru 3d5e330
chore: update `package.json` / `yarn.lock`
gamesguru aff1078
fix: handle empty sliding-sync timelines
gamesguru bb75ab8
fix: find JS events across room timelines
gamesguru 1a5e807
wip
gamesguru d5df01c
fix spoof / mitm tests
gamesguru c6e4488
fix: retry fallback-key claim until the claimed key is the fallback key
gamesguru 501dc55
fix: adapt Rust FFI wrapper to matrix-rust-sdk 26.08.25 (Element X's …
gamesguru 0db37b0
fix: widen mustClaimFallbackKey retry window to 30s
gamesguru a34b8ea
wip
gamesguru 8ba47e3
fix: make TestFallbackKeyIsUsedIfOneTimeKeysRunOut and TestChangingDe…
gamesguru 39ba8df
fix(rust): subscribe to a room before consuming its timeline
gamesguru f9b94c5
fix: parallelize TestToDeviceMessagesAreBatched setup via raw key upload
gamesguru ca6fd7a
fixup! fix: parallelize TestToDeviceMessagesAreBatched setup via raw …
gamesguru 8ddb69c
wip
gamesguru 3fbe40d
wip try this
gamesguru 41e8982
unskip flaky tests (run them all)
gamesguru f4f49ee
fix: give TestToDeviceMessagesAreProcessedInOrder's catch-up wait mor…
gamesguru b620acb
fixup! fix: give TestToDeviceMessagesAreProcessedInOrder's catch-up w…
gamesguru a745236
fix: restart Alice's sync loop after 504 storm in TestToDeviceMessage…
gamesguru 99635e6
fix: bump backpaginated-event timeout from 1s to 5s in TestOnRejoinBo…
gamesguru fe850a5
fix: TestUnprocessedToDeviceMessagesArentLostOnRestart/rust two fixes
gamesguru 1e23e41
fix: switch TestUnprocessedToDeviceMessagesArentLostOnRestart/rust to…
gamesguru File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -23,7 +23,7 @@ import ( | |||||
|
|
||||||
| // LogTarget is the name of the `target` we use in logToFile: it is in effect a fake "crate" that we tell the | ||||||
| // rust-sdk is producing the logs. | ||||||
| const LogTarget = "complement_crypto"; | ||||||
| const LogTarget = "complement_crypto" | ||||||
|
|
||||||
| func DeleteOldLogs(prefix string) { | ||||||
| // delete old log files | ||||||
|
|
@@ -39,7 +39,7 @@ func SetupLogs(prefix string) { | |||||
| // log new files | ||||||
| matrix_sdk_ffi.InitPlatform(matrix_sdk_ffi.TracingConfiguration{ | ||||||
| LogLevel: matrix_sdk_ffi.LogLevelTrace, | ||||||
| ExtraTargets: []string {LogTarget}, | ||||||
| ExtraTargets: []string{LogTarget}, | ||||||
| WriteToStdoutOrSystem: false, | ||||||
| WriteToFiles: &matrix_sdk_ffi.TracingFileConfiguration{ | ||||||
| Path: "./logs", | ||||||
|
|
@@ -104,11 +104,10 @@ func NewRustClient(t ct.TestLike, opts api.ClientCreationOpts) (api.Client, erro | |||||
| xprocessName := opts.GetExtraOption(CrossProcessStoreLocksHolderName, "").(string) | ||||||
| if xprocessName != "" { | ||||||
| t.Logf("setting cross process store locks holder name=%s", xprocessName) | ||||||
| ab = ab.CrossProcessLockConfig(matrix_sdk_ffi.CrossProcessLockConfigMultiProcess { xprocessName }) | ||||||
| ab = ab.CrossProcessLockConfig(matrix_sdk_ffi.CrossProcessLockConfigMultiProcess{xprocessName}) | ||||||
| } | ||||||
| // @alice:hs1, FOOBAR => alice_hs1_FOOBAR | ||||||
| username := strings.Replace(opts.UserID[1:], ":", "_", -1) + "_" + opts.DeviceID | ||||||
| ab = ab.Username(username) | ||||||
|
|
||||||
| sessionPath := "rust_storage/" + username | ||||||
| storeKey := []byte("my_secret_thirty-two_byte_string") | ||||||
|
|
@@ -675,11 +674,15 @@ func (c *RustClient) Type() api.ClientTypeLang { | |||||
| return api.ClientTypeRust | ||||||
| } | ||||||
|
|
||||||
| func (c *RustClient) SendMessage(t ct.TestLike, roomID, text string) (eventID string, err error) { | ||||||
| func (c *RustClient) SendMessage(t ct.TestLike, roomID, text string, timeout ...time.Duration) (eventID string, err error) { | ||||||
| c.FFISpan.Enter() | ||||||
| defer c.FFISpan.Exit() | ||||||
|
|
||||||
| t.Helper() | ||||||
| waitFor := 11 * time.Second | ||||||
| if len(timeout) > 0 { | ||||||
| waitFor = timeout[0] | ||||||
| } | ||||||
| var isChannelClosed atomic.Bool | ||||||
| ch := make(chan bool) | ||||||
| // we need a timeline listener before we can send messages, AND that listener must be attached to the | ||||||
|
|
@@ -723,8 +726,8 @@ func (c *RustClient) SendMessage(t ct.TestLike, roomID, text string) (eventID st | |||||
| } | ||||||
| timeline.Send(matrix_sdk_ffi.MessageEventContentFromHtml(text, text)) | ||||||
| select { | ||||||
| case <-time.After(11 * time.Second): | ||||||
| err = fmt.Errorf("SendMessage(rust) %s: timed out after 11s", c.userID) | ||||||
| case <-time.After(waitFor): | ||||||
| err = fmt.Errorf("SendMessage(rust) %s: timed out after %s", c.userID, waitFor) | ||||||
| return | ||||||
| case <-ch: | ||||||
| return | ||||||
|
|
@@ -829,7 +832,7 @@ func (c *RustClient) Logf(t ct.TestLike, format string, args ...interface{}) { | |||||
| func (c *RustClient) logToFile(t ct.TestLike, format string, args ...interface{}) { | ||||||
| c.FFISpan.Enter() | ||||||
| defer c.FFISpan.Exit() | ||||||
| matrix_sdk_ffi.LogEvent("rust.go", &zero, matrix_sdk_ffi.LogLevelInfo, LogTarget + "::" + t.Name(), fmt.Sprintf(format, args...)) | ||||||
| matrix_sdk_ffi.LogEvent("rust.go", &zero, matrix_sdk_ffi.LogLevelInfo, LogTarget+"::"+t.Name(), fmt.Sprintf(format, args...)) | ||||||
| } | ||||||
|
|
||||||
| func (c *RustClient) ensureListening(t ct.TestLike, roomID string) { | ||||||
|
|
@@ -863,6 +866,22 @@ func (c *RustClient) ensureListening(t ct.TestLike, roomID string) { | |||||
| return | ||||||
| } | ||||||
|
|
||||||
| // Without an explicit room subscription, the sliding sync `pos` for this room | ||||||
| // only ever advances via whatever small timeline_limit the "all rooms" list | ||||||
| // uses for previews (e.g. 1-10). That's fine when events trickle in one at a | ||||||
| // time, but under concurrent load a burst of room state (joins, membership | ||||||
| // changes) plus messages can exceed that window in a single poll; the server | ||||||
| // correctly reports `limited: true` with a `prev_batch` pointing before the | ||||||
| // gap, but nothing here ever triggers backpagination to close it, so a | ||||||
| // message that fell into the truncated portion is silently never delivered. | ||||||
| // Subscribing before we start consuming the timeline requests a much larger | ||||||
| // window (SDK default: 20) on every subsequent poll for this room, giving | ||||||
| // real headroom so this doesn't happen in the first place - this mirrors | ||||||
| // what a real client does when a room is actually open/visible. | ||||||
| if err := c.syncService.RoomListService().SubscribeToRooms([]string{roomID}); err != nil { | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: When Prompt for AI agents
Suggested change
|
||||||
| c.Logf(t, "[%s]ensureListening[%s] failed to subscribe to room: %s", c.userID, roomID, err) | ||||||
| } | ||||||
|
|
||||||
| c.Logf(t, "[%s]AddTimelineListener[%s]", c.userID, roomID) | ||||||
| // we need a timeline listener before we can send messages. Ensure we insert the initial | ||||||
| // set of items prior to handling updates. If we don't wait, we risk the listener firing | ||||||
|
|
@@ -936,6 +955,22 @@ func (c *RustClient) ensureListening(t ct.TestLike, roomID string) { | |||||
| ev := timelineItemToEvent(x.Value) | ||||||
| timeline = slices.Insert(timeline, 0, ev) | ||||||
| newEvents = append(newEvents, ev) | ||||||
| case matrix_sdk_ffi.TimelineDiffClear: | ||||||
| timeline = make([]*api.Event, 0) | ||||||
| c.logToFile(t, "[%s]_______ CLEAR", c.userID) | ||||||
| case matrix_sdk_ffi.TimelineDiffPopFront: | ||||||
| if len(timeline) > 0 { | ||||||
| timeline = slices.Delete(timeline, 0, 1) | ||||||
| } | ||||||
| case matrix_sdk_ffi.TimelineDiffPopBack: | ||||||
| if len(timeline) > 0 { | ||||||
| timeline = slices.Delete(timeline, len(timeline)-1, len(timeline)) | ||||||
| } | ||||||
| case matrix_sdk_ffi.TimelineDiffTruncate: | ||||||
| n := int(x.Length) | ||||||
| if n < len(timeline) { | ||||||
| timeline = timeline[:n] | ||||||
| } | ||||||
| default: | ||||||
| t.Logf("Unhandled TimelineDiff change %v", d) | ||||||
| } | ||||||
|
|
||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: The matrix-js-sdk dependency points at a moving branch (
#develop) instead of a pinned commit. Whileyarn.lockcurrently pins commitaa1aeed63b5ef0327f0442d63e31efca58df46b0, anyyarn add/yarn installthat regenerates the lockfile will silently resolve the latestdevelopcommit, so the SDK tested by this repo can drift under CI and produce non-reproducible/flaky test results. Consider pinning the resolved commit SHA inpackage.json(e.g....matrix-js-sdk#aa1aeed...) and periodically bumping it deliberately, keeping thedevelopbranch as the documented workflow inrebuild_js_sdk.sh.Prompt for AI agents