Repository navigation
tsp: prototype filesystem-backed sessions for WASI - #5599
Draft
yeonwooson wants to merge 1 commit into
Draft
yeonwooson wants to merge 1 commit into
yeonwooson wants to merge 1 commit into
Conversation
Let a host-owned filesystem present editor contents through ordinary module identities, then reuse the existing type converter to answer computed-type requests against a committed snapshot. Expose a small serialized session for architectural feedback. Keep native transports separate and verify real type-query and stale-snapshot behavior without introducing engine source overlays or a production WASI ABI. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
This pull request has been imported. If you are a Meta employee, you can view this in D130755466. (Because this pull request was imported automatically, there will not be any future comments.) |
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
1 task
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Experimental architecture draft. Not for landing. This is a user-directed, AI-assisted prototype for feedback on the filesystem-backed WASI session boundary, not a finished Pylance backend. The human-understanding checklist remains unchecked pending the contributor's code review.
Contributor-provided intent
The contributor requested this draft, verbatim:
Project context supplied by the contributor:
AI-assisted proposal
Following the host-written filesystem discussion in #5565, keep unsaved contents in the host filesystem rather than adding source overrides to Pyrefly State. This draft does not claim that in-process calls are faster; it establishes a small query/snapshot boundary to review before adding transport and packaging.
FilesystemSessionwith configuration, checked-file selection, filesystem invalidation,getSnapshotand onegetComputedTypeendpoint.GetTypeParams, protocolTypeoutput,snapshotChangedshape andServerCancelled/InvalidParamserrors. Queries convert types against the same warm transaction and reject stale snapshots before and after answering.Relationship to existing work: the minimal shared-conversion extraction is included so the prototype can compile and be reviewed independently. It overlaps #5436 and must be reconciled or split into that prerequisite before landing. This is not a second shared-conversion PR. Neither that PR nor the source-overlay PR is changed or closed by this draft. The PR5565 filesystem implementation and the local Wasm validation adapter are not included here.
Architectural feedback requested
Not implemented or claimed
The caller must serialize filesystem writes, events and queries. Empty change batches are no-ops; nonempty duplicate notifications may still advance generation, so the host should avoid redundant events. Search paths are import roots, not filesystem-access boundaries.
No issue closure is requested.
Test Plan
AI-assisted validation report: Windows ARM64 using public Rust 1.99.1, WASI SDK 34 and Node 24.15.0. The source is based on
cf67d00701e5b4c12756e8dac15033f566aad2b6; these local results do not claim validation of subsequent upstream changes or merge readiness.cargo test -p pyrefly --lib --locked --offline -- test::tsp:: test::state:: tsp::type_conversion::tests:: tsp::validation::tests:: --test-threads=2cargo clippy -p pyrefly --all-targets --locked --offline --message-format=jsonpython test.py --mode cargo --no-test --no-tensor-shapes --no-conformance --no-jsonschema --no-extensioncargo check -p pyrefly --lib --target wasm32-wasip1 --locked --offlinepyrefly_wasm:cargo build -p pyrefly_wasm --lib --target wasm32-wasip1 --locked --offlineThe six session tests cover unsaved imported edits (
int -> str -> restored int), old-snapshot rejection, stable repeated queries, new/deleted imports, function declaration ranges/call results, invalid URI/path/range inputs, UTF-16 boundaries and explicit configuration errors. Existing native TSP/converter/State tests remain in the selected run; the moved converter/resolver algorithms are unchanged.A separate local validation adapter was built with
cargo build --manifest-path <adapter>/Cargo.toml --target wasm32-wasip1 --locked --offlineand executed withnode <harness>/run-node.mjs <artifact.wasm> <result.json>: 29 checks passed, including a fresh draft rerun. The same Wasm artifact previously passed 29 checks in a real Chromium/Electron browser. The checks exercise actual session queries, protocol-shaped outputs and stale errors through Wasm, not merely a generation-counter mock. They also cover invalid requests and disposed adapter handles.The adapter, host filesystem from PR5565, and runtime harness are out-of-tree experimental validation, not a shipped interface or part of this diff. Native/WASI behavior differs for materialized bundled-stub paths; no full navigation parity or Pylance-to-WASI test is claimed.
Existing unrelated warnings remain; no added-line diagnostics were introduced. The full native suite, local Linux/macOS execution, a cross-browser matrix, production packaging and performance comparisons were not run. Remote CI results are separate from these local checks. The draft must remain not merge-ready until human code review and the architectural questions are resolved.