- 
                Notifications
    
You must be signed in to change notification settings  - Fork 557
 
feat(directory): Add oracle for event testing #25477
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
base: main
Are you sure you want to change the base?
feat(directory): Add oracle for event testing #25477
Conversation
8d2e3c3    to
    5daccaf      
    Compare
  
    ea3e5d1    to
    6ae2993      
    Compare
  
    6ae2993    to
    85c3d42      
    Compare
  
    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.
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 
SharedDirectoryOracleclass 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)) { | 
    
      
    
      Copilot
AI
    
    
    
      Sep 24, 2025 
    
  
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.
Function call has a typo: 'hasSharedDirectroyOracle' should be 'hasSharedDirectoryOracle'
| 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)) { | 
    
      
    
      Copilot
AI
    
    
    
      Sep 24, 2025 
    
  
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.
Function call has a typo: 'hasSharedDirectroyOracle' should be 'hasSharedDirectoryOracle'
| 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"); | 
    
      
    
      Copilot
AI
    
    
    
      Sep 24, 2025 
    
  
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.
Use a string literal for the assert error message instead of a descriptive string
| } | ||
| 
               | 
          ||
| // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
| const newVal = this.sharedDir.get(fullPath); | 
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.
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()) { | 
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.
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
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.
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...
e441069    to
    2ba78e1      
    Compare
  
    
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: