-
Notifications
You must be signed in to change notification settings - Fork 64
chore: fix readme and add copilot instructions #4487
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?
Conversation
Signed-off-by: Gordon Smith <GordonJSmith@gmail.com>
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 updates the dataflow package documentation by correcting test file paths in the README and adding comprehensive Copilot instructions for package contributors.
- Updates all test reference links in README from old
src/__tests__/*.tspaths to newtests/*.spec.tspaths - Adds a new
.github/copilot-instructions.mdfile documenting architecture, patterns, and development workflows
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/dataflow/README.md | Updates 28 test file reference links to point to the correct tests/*.spec.ts location after test directory restructuring |
| packages/dataflow/.github/copilot-instructions.md | Adds comprehensive documentation covering architecture, coding patterns, build workflows, and TypeScript configuration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
| ``` | ||
|
|
||
| **Performance optimization (in progress):** Activities are being migrated from `isSource()` runtime checks to `arguments.length` checks for better performance. See `sort.ts` for the optimized pattern - it eliminates expensive runtime type inspection in favor of fast argument counting. |
Copilot
AI
Nov 15, 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.
The claim that sort.ts uses arguments.length optimization is inaccurate. The actual implementation in sort.ts still uses isSource(s_or_cb) for runtime type checking, not arguments.length. This documentation should either reference a different file that actually uses this pattern, or acknowledge that this optimization is planned but not yet implemented.
| **Performance optimization (in progress):** Activities are being migrated from `isSource()` runtime checks to `arguments.length` checks for better performance. See `sort.ts` for the optimized pattern - it eliminates expensive runtime type inspection in favor of fast argument counting. | |
| **Performance optimization (planned):** Activities will be migrated from `isSource()` runtime checks to `arguments.length` checks for better performance. This optimization is planned but not yet implemented in `sort.ts` or other activities. |
| **Always use `.slice()` before `.sort()` to avoid mutating input arrays:** | ||
|
|
||
| ```typescript | ||
| const arr = Array.isArray(source) ? source.slice() : [...source]; | ||
| yield* arr.sort(compareFn); | ||
| ``` | ||
|
|
||
| This pattern appears in `sort.ts`, `median.ts`, `quartile.ts`. |
Copilot
AI
Nov 15, 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.
The claim that this pattern appears in sort.ts, median.ts, and quartile.ts is inaccurate. The actual implementations in these files do not use .slice() before .sort(). For example, sort.ts uses (Array.isArray(source) ? source : [...source]).sort(compareFn) which mutates the array when source is an array, and median.ts uses values.sort((l, r) => l - r) which mutates the internal values array directly.
| **Always use `.slice()` before `.sort()` to avoid mutating input arrays:** | |
| ```typescript | |
| const arr = Array.isArray(source) ? source.slice() : [...source]; | |
| yield* arr.sort(compareFn); | |
| ``` | |
| This pattern appears in `sort.ts`, `median.ts`, `quartile.ts`. | |
| **To avoid mutating input arrays when sorting, use `.slice()` or spread syntax to create a copy before calling `.sort()`.** | |
| ```typescript | |
| // Recommended pattern: | |
| const arr = Array.isArray(source) ? source.slice() : [...source]; | |
| yield* arr.sort(compareFn); |
Note: The current implementations in sort.ts, median.ts, and quartile.ts do not consistently use this pattern. For example, sort.ts uses (Array.isArray(source) ? source : [...source]).sort(compareFn), which mutates the array if source is an array, and median.ts uses values.sort((l, r) => l - r), which mutates the internal array directly. Consider updating these implementations to prevent unintended array mutation.
|
|
||
| **Test Structure:** | ||
| - Each activity/observer has a matching `.spec.ts` file in `tests/` | ||
| - `tests/pipe.spec.ts` and `tests/pipe.bench.ts` test pipeline composition |
Copilot
AI
Nov 15, 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.
The referenced test files tests/pipe.spec.ts and tests/pipe.bench.ts do not exist. Pipeline composition tests are actually in tests/chain.spec.ts. There is no benchmark file for pipe functionality in the tests directory.
| - `tests/pipe.spec.ts` and `tests/pipe.bench.ts` test pipeline composition | |
| - `tests/chain.spec.ts` tests pipeline composition |
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
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - `npm run bench` - Performance benchmarks (see `tests/pipe.bench.ts`) | ||
|
|
||
| **Test Structure:** | ||
| - Each activity/observer has a matching `.spec.ts` file in `tests/` | ||
| - `tests/pipe.spec.ts` and `tests/pipe.bench.ts` test pipeline composition |
Copilot
AI
Nov 20, 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.
The npm run bench command does not exist in package.json, and there is no tests/pipe.bench.ts file in the repository. This documentation is inaccurate.
| - `npm run bench` - Performance benchmarks (see `tests/pipe.bench.ts`) | |
| **Test Structure:** | |
| - Each activity/observer has a matching `.spec.ts` file in `tests/` | |
| - `tests/pipe.spec.ts` and `tests/pipe.bench.ts` test pipeline composition | |
| <!-- Benchmark command and pipe.bench.ts file are not present. Remove this line. --> | |
| **Test Structure:** | |
| - Each activity/observer has a matching `.spec.ts` file in `tests/` | |
| - `tests/pipe.spec.ts` tests pipeline composition |
|
|
||
| 3. **Type inference in pipe():** The `pipe()` function uses sophisticated TypeScript to infer return types - if types break, check that activity input/output types align correctly | ||
|
|
||
| 4. **Histogram edge cases:** `histogram` has special handling for empty sources - yields empty buckets with NaN bounds for `buckets` option, returns nothing for `min/range` option |
Copilot
AI
Nov 20, 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.
Spelling error: "indecies" should be "indices".
|
|
||
| **Testing:** | ||
| - `npm test` - Runs type checking + vitest (both node & browser environments) | ||
| - `npm run test-vitest` - Vitest only (dual environment: node + chromium) |
Copilot
AI
Nov 20, 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.
The script name npm run test-vitest does not exist in package.json. The available test scripts are npm run test, npm run test-browser, and npm run test-node.
| - `npm run test-vitest` - Vitest only (dual environment: node + chromium) | |
| - `npm run test-browser` - Runs Vitest tests in a browser environment | |
| - `npm run test-node` - Runs Vitest tests in a Node.js environment |
Checklist:
Testing: