Skip to content

Conversation

@sonalideshpandemsft
Copy link
Contributor

@sonalideshpandemsft sonalideshpandemsft commented Sep 17, 2025

This change introduces a new oracle SharedDirectoryOracle, which provides an snapshot and validation mechanism for ISharedDirectory. The oracle tracks the state of the directory and its subdirectories to help ensure consistency.

Key features:

  • Maintains an internal Map representing the current state of the shared directory.
  • Subscribes to ISharedDirectory events: valueChanged, containedValueChanged, clear, subDirectoryCreated, subDirectoryDeleted.
  • Validates the state of the shared directory against the internal model using the validate() method.
  • Automatically updates its internal model when directory changes occur
  • Supports cleanup through the dispose() method, unsubscribing from events and clearing the model

@github-actions github-actions bot added area: dds Issues related to distributed data structures base: main PRs targeted against main branch labels Sep 17, 2025
@sonalideshpandemsft sonalideshpandemsft marked this pull request as ready for review September 24, 2025 19:15
Copy link
Contributor

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 introduces the SharedDirectoryOracle class for testing ISharedDirectory implementations. The oracle provides state tracking and validation by maintaining an internal Map that mirrors the directory structure and validates consistency during fuzz testing.

  • Adds a new SharedDirectoryOracle class that subscribes to directory events and maintains an internal model
  • Integrates the oracle into fuzz testing framework with client creation hooks and validation checks
  • Updates type definitions and utility functions to support directory oracle functionality

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 13 comments.

File Description
packages/dds/map/src/test/directoryOracle.ts New oracle implementation with event handling and validation logic
packages/dds/map/src/test/mocha/oracleUtils.ts Type definitions and guard functions for directory oracle integration
packages/dds/map/src/test/mocha/fuzzUtils.ts Updates fuzz model to include oracle validation in consistency checks
packages/dds/map/src/test/mocha/directoryFuzzTests.spec.ts Integrates oracle creation and validation into fuzz test suites

reducer: makeDirReducer({ clientIds: ["A", "B", "C"], printConsoleLogs: false }),
validateConsistency: async (a, b) => assertEquivalentDirectories(a.channel, b.channel),
validateConsistency: async (a, b) => {
if (hasSharedDirectroyOracle(a.channel)) {
Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

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

Function call has a typo: 'hasSharedDirectroyOracle' should be 'hasSharedDirectoryOracle'

Copilot uses AI. Check for mistakes.
reducer: makeDirReducer({ clientIds: ["A", "B", "C"], printConsoleLogs: false }),
validateConsistency: async (a, b) => assertEquivalentDirectories(a.channel, b.channel),
validateConsistency: async (a, b) => {
if (hasSharedDirectroyOracle(a.channel)) {
Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

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

Function call has a typo: 'hasSharedDirectroyOracle' should be 'hasSharedDirectoryOracle'

Copilot uses AI. Check for mistakes.
public validate(): void {
for (const [pathKey, value] of this.model.entries()) {
const parts = pathKey.split("/").filter((p) => p.length > 0);
assert(parts.length > 0, "Invalid path, cannot extract key");
Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

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

Use a string literal for the assert error message instead of a descriptive string

Copilot generated this review using guidance from repository custom instructions.
}

// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const newVal = this.sharedDir.get(fullPath);
Copy link
Contributor

Choose a reason for hiding this comment

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

this seems wrong. i don't think you can call get a full path like this, i think you need to find the directory with getWorkingDirectory, and then get the specific key off that sub-directory

};

public validate(): void {
for (const [pathKey, value] of this.model.entries()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

i'm not sure this is correct. i think entries just returns the keys of the directory and you have to use subdirectories to get the subdirectories

Copy link
Contributor Author

@sonalideshpandemsft sonalideshpandemsft Sep 29, 2025

Choose a reason for hiding this comment

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

model map stores subdirectories as separate keys, so each subdirectory has its own entry

nvm - subdirs are not pushed to the snapshot. looking into it...

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