Skip to content

Conversation

dannimad
Copy link
Contributor

@dannimad dannimad commented Sep 10, 2025

This PR contains a few non related changes:

  • Fixing TrackableSharedArray tracking of available entryIds. If other operations besides insert and move happened, we didn't track such changes in insertIds and moveIds sets. Now doing the corresponding operations to have correct list of available entryIds.
  • Adding value fields to fuzz operations for better debugging, since some operations are not descriptive (based on entryIds)
  • Enable toggleMove on base model and consolidate array fuzz tests to one suite were everything is enabled (rollback/ stashing)
  • Bug fix: stashing move ops were adding one to the incorrect liveEntry (new entry id instead of old one as move op does)
  • Bug fix: move op generator was choosing a different entryId among moveIds that didn't correspond to the move op format (it's supposed to be [oldEntry, newEntry]).
  • Bug fix: Do not process remote toggle moves if moved element was deleted

TODO: being able to toggle back from remove items.

@Copilot Copilot AI review requested due to automatic review settings September 10, 2025 17:06
@github-actions github-actions bot added area: dds Issues related to distributed data structures base: main PRs targeted against main branch labels Sep 10, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes several bugs in the SharedArray fuzz testing infrastructure and enables toggleMove operations in the base model. The changes primarily focus on improving tracking of available entry IDs for operations and fixing bugs in operation handling.

  • Fix TrackableSharedArray to properly track available entry IDs across all operation types (insert, delete, move, toggle, toggleMove)
  • Add value fields to fuzz operations for better debugging capabilities
  • Enable toggle and toggleMove operations in the base model and consolidate array fuzz tests into a single comprehensive suite

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
fuzzUtils.ts Fixes entry ID tracking bugs, adds value fields to operations, and enables toggle operations
arrayFuzzTests.spec.ts Consolidates multiple fuzz test suites into a single comprehensive test
array.rollback.spec.ts Adds test coverage for toggle and toggleMove rollback operations
sharedArray.ts Implements missing toggle and toggleMove rollback functionality and fixes move operation stashing bug
Comments suppressed due to low confidence (1)

packages/dds/legacy-dds/src/array/sharedArray.ts:1

  • The moveIds mapping is inconsistent. Line 151 sets moveIds.set(op.changedToEntryId, op.entryId) but this should be moveIds.set(op.entryId, op.changedToEntryId) to maintain the correct old->new mapping convention used elsewhere in the code.
/*!

index: random.integer(0, Math.max(0, client.channel.get().length - 1)),
});
}: DDSFuzzTestState<SharedArrayFactory<string>>): SharedArrayDelete => {
const index = random.integer(0, Math.max(0, client.channel.get().length - 1));
Copy link
Contributor

Choose a reason for hiding this comment

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

use random.pick

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any reason behind this? other fuzz utils use the exact same pattern. Also pick does not seem to be a particularly good option here cause I would need to create an array with all valid indexes which is kinda unnecessary.

Comment on lines +115 to +117
channel.insertIds = new Map<string, unknown>();
channel.moveIds = new Map<string, string>();
channel.toggleIds = new Map<string, unknown>();
Copy link
Contributor

@anthony-murphy anthony-murphy Sep 12, 2025

Choose a reason for hiding this comment

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

i wonder if we can simplify this, potentially in a follow up, and just keep a single set of ids, and randomly try operations, or only keep track of ids not in sharedarray.get, so basically removed ids. i suggest this, as i'm a little worried about the stress test becoming over structured, which can negatively affect coverage. Stress is especially good for catching hard to predict scenarios, and over-structuring stress can reduce its ability to find those hard to predict scenarios.

Copy link
Contributor

Choose a reason for hiding this comment

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

this also seems related to the todo you have in the pr description

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree. And precisely this is related to the todo.

@@ -40,6 +41,7 @@ export interface SharedArrayInsert<T> {
export interface SharedArrayDelete {
type: "delete";
index: number;
value: unknown;
Copy link
Contributor

Choose a reason for hiding this comment

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

why does delete need the value?

Copy link
Contributor

Choose a reason for hiding this comment

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

same for the below. i don't see them used

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it was just for debugging purposes. Given how toggle ops only had entryIds, it was hard to back track what was going on. Had to add value to all ops to make some failing seed scenarios more clear. I think there is value keeping value as a field if there are failures in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: dds Issues related to distributed data structures base: main PRs targeted against main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants