-
Notifications
You must be signed in to change notification settings - Fork 32
docs: add driver client/exporter compatibility rule #782
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
Draft
mangelajo
wants to merge
1
commit into
main
Choose a base branch
from
docs/driver-compatibility-rule
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../../.cursor/rules/driver-compatibility.mdc |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| --- | ||
| description: when modifying driver client classes, exported RPC methods, client() class paths, or migrating drivers away from opendal | ||
| alwaysApply: false | ||
| --- | ||
| # Driver Client/Exporter Compatibility | ||
|
|
||
| Exporters and clients are released and upgraded independently. A lab may run an | ||
| older exporter for months while clients update weekly, or vice versa. Any change | ||
| to a driver must keep both directions working: old client ↔ new exporter and | ||
| new client ↔ old exporter. | ||
|
|
||
| ## How client classes are resolved (the critical invariant) | ||
|
|
||
| The exporter reports the string returned by the driver's `client()` classmethod | ||
| (e.g. `"jumpstarter_driver_qemu.client.QemuFlasherClient"`). The client imports | ||
| that class dynamically **from its own environment**. | ||
|
|
||
| - **NEVER change the string returned by `client()` for a released driver.** | ||
| If an old client receives a class path that does not exist in its installed | ||
| packages, it fails with `ImportError` when leasing the exporter. This breakage | ||
| is invisible to unit tests — it only appears with mixed versions in the field. | ||
| - When moving an interface ABC between packages (e.g. opendal → core), check | ||
| every driver that inherits from it: drivers that explicitly override | ||
| `client()` (qemu, esp32, pi-pico, probe-rs) are safe; drivers relying on the | ||
| ABC's default `client()` would silently start reporting a new string. | ||
| - New drivers should always explicitly override `client()` with a path in their | ||
| own package, so future refactors of shared base classes cannot change what | ||
| they report. | ||
|
|
||
| ## Wire protocol surfaces that must stay stable | ||
|
|
||
| - **RPC method names and argument shapes** used via `self.call(...)` and | ||
| `self.streamingcall(...)` (e.g. `call("flash", handle, target)`). Changes must | ||
| be additive; the driver side must keep accepting the old call shape. | ||
| - **Resource handle types**: `ClientStreamResource` (streamed from client) and | ||
| `PresignedRequestResource` (GET and PUT), handled by `Driver.resource()` in | ||
| `python/packages/jumpstarter/jumpstarter/driver/base.py`. Do not add new | ||
| resource types without confirming old exporters reject them gracefully. | ||
|
|
||
| ## Client-side Python API changes | ||
|
|
||
| Public client methods (e.g. `flash()`, `dump()`) are user-facing API consumed | ||
| by user scripts and the `j` CLI inside `jmp shell`: | ||
|
|
||
| - Prefer deprecating a parameter (warn, ignore) for at least one release before | ||
| removing it; always document removals and the migration path in release notes. | ||
| - Keep `j` CLI command names and flags stable. | ||
|
|
||
| ## Version pinning between packages | ||
|
|
||
| Released sdists exact-pin all `jumpstarter*` dependencies via the | ||
| `hatch-pin-jumpstarter` build hook, so a published driver package can never be | ||
| installed against a mismatched core. Do not add manual version bounds on | ||
| `jumpstarter*` dependencies in `pyproject.toml`; keep them unversioned. | ||
|
|
||
| ## Opendal migration series (issue #441) | ||
|
|
||
| The pattern established by PR #535 (QEMU driver) for removing the | ||
| `jumpstarter-driver-opendal` dependency from a driver: | ||
|
|
||
| 1. Use `jumpstarter.driver.flasher.FlasherInterface` (core) instead of the | ||
| opendal ABC, and `jumpstarter.client.flasher.FlasherClient` (core) instead | ||
| of the opendal client. Local files stream via `resource_async`; `http(s)://` | ||
| URLs pass through as `PresignedRequestResource` (the exporter downloads them | ||
| directly with aiohttp). | ||
| 2. Verify the driver's `client()` string is unchanged by the migration (see the | ||
| invariant above) — this is what makes the migration safe for old clients. | ||
| 3. Keep RPC names and signatures identical to the opendal-based version. | ||
| 4. The `operator=` kwarg does not exist in the core client. Users with S3 or | ||
| other authenticated backends must pre-sign URLs themselves and pass the URL | ||
| as the path. Call this out in release notes for each migrated driver. | ||
| 5. Reuse or subclass the core `FlasherClient` rather than duplicating its logic | ||
| in per-driver clients. | ||
|
|
||
| ## Testing expectations | ||
|
|
||
| When touching file-transfer paths (flash/dump/storage), mock-based routing | ||
| tests are not sufficient. Add an end-to-end test using the in-process harness | ||
| (`jumpstarter.common.utils.serve`, see existing `driver_test.py` files in qemu | ||
| or esp32) that exercises the real client → exporter resource flow: flashing | ||
| from a local file, flashing from an HTTP URL, and dumping in both directions. | ||
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
Oops, something went wrong.
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.
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 thought we defined a specific upgrade path here, not that both could be outdated?