Analysis and documentation of tool name normalization - no collisions found#431
Analysis and documentation of tool name normalization - no collisions found#431
Conversation
Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com>
Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com>
|
@copilot Does your test cases really make sense as valid Wasm Component and WIT IDL formats? Read @WebAssembly/component-model/files/design/mvp/WIT.md and @WebAssembly/component-model/files/design/mvp/CanonicalABI.md |
You're absolutely right - my test cases don't reflect valid WIT IDL formats. After reviewing the WIT specification, I understand that:
The test cases I created with Looking at the actual component exports in existing tests (e.g.,
The collision scenario described in issue #57 appears to be theoretical rather than based on real WIT structures. Should I revert these changes and close the issue as "won't fix", or would you like me to create a more targeted fix that only handles the actual valid WIT format? |
|
@copilot Yes i would like you to create a more targeted test cases that try to find tool name collisions by constructing actual valid WIT files (but more complicated ones). |
After thorough analysis with valid WIT files, determined that: - Valid WIT names cannot collide with current normalization - Hyphens are preserved, preventing collisions - Issue #57 was theoretical, not practical - Added test demonstrating no collisions with valid names - Added comprehensive documentation in docs/design/ Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com>
I've completed a thorough analysis using valid WIT files and the Result: No collisions occur with valid WIT names. The key insight is that valid WIT identifiers can only contain
Collisions only occur when comparing a valid name (e.g., Changes in commit 4ba2130:
Issue #57 appears to be based on a theoretical concern that doesn't apply to real WIT components. |
Problem
Issue #57 raised concerns that tool name normalization in
component2jsoncould cause different WebAssembly component function identifiers to collide when converting to MCP tool names, specifically thatexample:fooandexample/foomight both normalize toexample_foo.Analysis
After thorough investigation using valid WIT (WebAssembly Interface Type) files and the
wasm-toolscomponent command, I determined that the collision concern is theoretical and does not occur in practice with valid WIT component names.Key Findings
Per the WIT specification:
Valid WIT identifiers are strictly constrained:
namespace:packageformat (e.g.,wasi:http)types,my-interface)namespace:package/interface(e.g.,wasi:http/types)[a-z0-9-]Current normalization preserves hyphens:
:and/to_-are preserved, which are the main differentiator in valid WIT namesTested collision scenarios:
Why No Collisions Occur
Changes Made
test_no_collision_with_valid_wit_namestest demonstrating no collisions occur with valid WIT component namesdocs/design/tool-name-normalization.mdexplaining:Testing
Conclusion
The current normalization strategy is correct and sufficient for all valid WIT component names. Issue #57 describes a theoretical concern that doesn't apply to real-world usage, as collisions only occur when comparing valid names to invalid strings that wasmtime would never provide.
Addresses #57
Original prompt
Fixes #61
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.