Skip to content

feat(python): add snapshot restore support#1298

Merged
chaliy merged 2 commits intoeverruns:mainfrom
oliverlambson:python-snapshots
Apr 15, 2026
Merged

feat(python): add snapshot restore support#1298
chaliy merged 2 commits intoeverruns:mainfrom
oliverlambson:python-snapshots

Conversation

@oliverlambson
Copy link
Copy Markdown
Contributor

Closes #1256

Summary

  • add snapshot(), restore_snapshot(), and from_snapshot() to the Python Bash and BashTool bindings
  • preserve constructor kwargs when restoring into a fresh instance from snapshot bytes
  • add Python tests, stubs, and docs for round-trip, reset/restore, empty snapshot, and invalid snapshot cases

Testing

  • cargo test -p bashkit-python --no-run
  • cargo fmt --check
  • .uv-venv-bashkit/bin/python -m pytest crates/bashkit-python/tests/test_bashkit.py
  • .uv-venv-bashkit/bin/ruff check crates/bashkit-python
  • cargo clippy -p bashkit-python --all-targets --no-deps -- -D warnings

Notes

  • full cargo clippy -p bashkit-python --all-targets -- -D warnings still hits pre-existing dead-code warnings in crates/bashkit unrelated to this change

@oliverlambson oliverlambson marked this pull request as draft April 14, 2026 21:29
@oliverlambson oliverlambson force-pushed the python-snapshots branch 4 times, most recently from 76e1f6b to 136de95 Compare April 14, 2026 21:53
@oliverlambson oliverlambson marked this pull request as ready for review April 14, 2026 21:55
@chaliy chaliy requested a review from Copilot April 14, 2026 22:54
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds snapshot/restore support to the Python bindings to match existing Node API parity, enabling serializing interpreter state and restoring it into the same or a new configured instance.

Changes:

  • Add snapshot(), restore_snapshot(), and from_snapshot() to Python Bash and BashTool bindings (PyO3).
  • Add pytest coverage for snapshot round-trip and reset→restore flows.
  • Update Python type stubs and documentation/examples to describe the new API.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
specs/013-python-package.md Documents snapshot/restore usage for BashTool and Bash.
crates/bashkit-python/tests/test_bashkit.py Adds tests for Bash and BashTool snapshot/restore behavior and error handling (partially).
crates/bashkit-python/src/lib.rs Implements snapshot/restore methods and shared helper functions in the PyO3 bindings.
crates/bashkit-python/examples/bash_basics.py Adds an example demonstrating snapshot/restore usage.
crates/bashkit-python/bashkit/_bashkit.pyi Updates stubs to include the new methods and signatures.
crates/bashkit-python/README.md Adds a Snapshot/Restore section and updates the API method list.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread specs/013-python-package.md Outdated
Comment thread crates/bashkit-python/src/lib.rs
Comment thread crates/bashkit-python/src/lib.rs
Comment thread crates/bashkit-python/tests/test_bashkit.py
@chaliy
Copy link
Copy Markdown
Contributor

chaliy commented Apr 15, 2026

LGTM,

@oliverlambson pls assign PR to me when you feel it ready for merge.

@oliverlambson
Copy link
Copy Markdown
Contributor Author

@chaliy great!

I don't have permissions to assign PRs on this repo, but I'm happy for you to self-assign & merge 👍

@chaliy chaliy merged commit 7c6e1e2 into everruns:main Apr 15, 2026
13 checks passed
@chaliy
Copy link
Copy Markdown
Contributor

chaliy commented Apr 15, 2026

Thank you!

@oliverlambson oliverlambson deleted the python-snapshots branch April 15, 2026 02:27
chaliy added a commit that referenced this pull request Apr 15, 2026
## Summary

- bump workspace and JS package versions from 0.1.18 to 0.1.19
- add release notes for changes since v0.1.18, keeping external contribution credit for @oliverlambson in #1298
- update Cargo.lock to pull rustls-webpki 0.103.12 and clear the current cargo-audit blocker on main

## Verification

- cargo fmt --check
- cargo clippy --all-targets --all-features -- -D warnings
- cargo audit --ignore RUSTSEC-2023-0071
- cargo deny check
- cargo run -p bashkit-cli -- --version

## Notes

- cargo test --all-features still hits the existing bash_comparison_tests parity mismatch set already present on main (114 mismatches), unchanged by this branch
chaliy added a commit that referenced this pull request Apr 15, 2026
## Summary

- bump Bashkit release metadata from `0.1.18` to `0.1.19`
- add the `0.1.19` changelog entry, including explicit external
contribution credit for @oliverlambson in #1298
- update `Cargo.lock` to pull `rustls-webpki 0.103.12` so the current
cargo-audit failure on `main` is cleared for this release

## Why

- `main` is currently blocked from shipping because the Audit job fails
on `RUSTSEC-2026-0098` and `RUSTSEC-2026-0099` in `rustls-webpki
0.103.10`
- the release PR needs that dependency remediation or it inherits the
same red CI state and cannot publish

## Verification

- `cargo fmt --check`
- `cargo clippy --all-targets --all-features -- -D warnings`
- `cargo audit --ignore RUSTSEC-2023-0071`
- `cargo deny check`
- `cargo run -p bashkit-cli -- --version`

## Notes

- `cargo test --all-features` still hits the existing
`bash_comparison_tests` parity mismatch set already present on `main`
(114 mismatches), unchanged by this branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(python): add snapshot/restore support

3 participants