Repository navigation
tsp: make transaction conversion reusable by WASI hosts - #5436
yeonwooson wants to merge 2 commits into
Conversation
A WASI type-server guest needs the native transaction-backed conversion without depending on the native LSP server or duplicating the algorithm. Extract the existing converter and source resolvers into a shared module, preserve native request delegation and import context, and cover re-exported declarations across Python platform contexts. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Hi @yeonwooson! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
kinto0
left a comment
There was a problem hiding this comment.
looks great! just a few changes.
I wonder at what point we should put a cargo check --target wasm32-wasip1 step in CI. I don't think we have any wasm tests running in CI right now.
| // does for cross-module lookups) so the function's module is found under | ||
| // the same `SysInfo` the transaction computed it with; re-deriving a | ||
| // config-default `SysInfo` would miss the module in a multi-`SysInfo` | ||
| // transaction and silently collapse the range to zero. |
| use crate::test::util::TestEnv; | ||
|
|
||
| #[test] | ||
| fn converted_reexports_keep_declarations_and_source_sysinfo() { |
There was a problem hiding this comment.
this test seems very similar to test_resolve_export_location_inherits_source_sysinfo
can we put it next to that test? or just make sure that test covers everything you want tested?
| /// `source_handle`'s `SysInfo` — the one whose `Stdlib` this transaction already | ||
| /// computed. That keeps the export lookup on the warm `get_stdlib` path: | ||
| /// re-deriving the handle from the module path would pick a config-derived | ||
| /// `SysInfo` that was never computed, panicking in `get_stdlib` whenever the |
There was a problem hiding this comment.
maybe we keep this part of the comment in the body of the new function?
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
|
|
||
| //! Convert analyzed types without depending on the native LSP server. |
There was a problem hiding this comment.
any reason we didn't put this function in tsp/type_conversion.rs?
There was a problem hiding this comment.
I've moved it under tsp/type_conversion.rs
This comment has been minimized.
This comment has been minimized.
Keep transaction-backed conversion with the existing converter and place its regression beside the related state test. Preserve the analysis-context invariants in comments and check WASI compilation in CI to catch portability regressions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Added a dedicated Linux CI job running |
|
This pull request has been imported. If you are a Meta employee, you can view this in D128197670. (Because this pull request was imported automatically, there will not be any future comments.) |
kinto0
left a comment
There was a problem hiding this comment.
looks great! just waiting on the workflow to complete on github before merging
This comment has been minimized.
This comment has been minimized.
|
This pull request has been merged in e852c70. |
|
@yeonwooson I'm actually reverting this unfortunately. It broke our |
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
|
This pull request has been reverted by 4b1547c. |
Summary
Contributor motivation:
AI-assisted technical summary and validation:
Extract the existing transaction-backed converter into a shared module and
compile it for WebAssembly, without the native LSP server. Native declared,
computed, and expected-type requests call the same helper. Declaration ranges,
re-export resolution, and the query's warm stdlib and Python environment are
preserved.
This is the first enabling piece for the WASI Worker integration, not the
complete guest. It adds no transport, Worker host, filesystem policy, protocol
change, or type-checking behavior. No existing issue or prior maintainer
coordination is claimed; feedback on this shared boundary is welcome.
No issue closure is claimed.
Test Plan
cargo test -p pyrefly --lib tsp:: --locked --offline— passed, 195 tests.Includes native declared/computed/expected-type request coverage and a new
transaction-level regression for re-exported class/function declarations,
exact source ranges, and two non-default Python platform contexts.
cargo test -p pyrefly --lib test::state:: --locked --offline -- --test-threads=4— passed, 21 tests, including the existing warm-stdlib/import-context
regression after moving its resolver to the shared module.
cargo check -p pyrefly --lib --target wasm32-wasip1 --locked --offline— passed with the shared conversion enabled and native RPC/server modules
excluded. This is target-compilation evidence, not a complete WASI Worker
runtime or end-to-end TSP qualification.
python .\test.py --no-test --no-tensor-shapes --no-conformance --no-jsonschema --no-extension— passed in an isolated exact-base checkout. Formatting left the five
candidate files unchanged and produced no unrelated changes.
The extracted conversion and export-resolution bodies are mechanically identical
to the native implementation apart from comments and whitespace. The new
regression exercises their use without a
Serverinstance. No protocol schema,dependency, manifest, or lockfile change is included.
Validation ran on Windows ARM64 using public Rust 1.99.1; the WASI target check
used the official WASI SDK 34 for C dependencies. Existing warnings in unchanged
platform-specific code remain. Host-specific bundled-source URI mapping, a
portable document session, and the guest command/Worker transport are follow-up
integration work rather than claims of this PR.