Skip to content

fix(snapshot): preserve counters on resume#1835

Merged
chaliy merged 1 commit into
mainfrom
2026-06-02-fix-session-limit-counter-reset-on-snapshot-resume
Jun 2, 2026
Merged

fix(snapshot): preserve counters on resume#1835
chaliy merged 1 commit into
mainfrom
2026-06-02-fix-session-limit-counter-reset-on-snapshot-resume

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Jun 2, 2026

Motivation

  • Prevent fresh-instance snapshot resume from resetting session-level budgets when snapshots (including keyed/HMAC-protected ones) contain nonzero session counters.
  • Keep protection against tampered/untrusted snapshot bytes lowering live counters while allowing authenticated snapshots to carry forward consumed budget.

Description

  • Merge serialized session counters during restore by calling restore_session_counters from restore_snapshot_inner after validated shell/VFS restore so counters are applied atomically with state.
  • Change Interpreter::restore_session_counters to be monotonic (use max) so restoring never reduces already-consumed session_commands or session_exec_calls.
  • Update public Bash::restore_session_counters docstring to reflect monotonic merge semantics.
  • Add integration tests covering keyed (HMAC) snapshot resume: keyed_snapshot_restore_carries_session_exec_budget_forward and from_snapshot_keyed_restores_session_counters to assert authenticated resumes carry counters forward.

Testing

  • Ran the integration snapshot test binary: cargo test -p bashkit --test integration snapshot_tests:: -- --nocapture and all snapshot-related tests passed (40 passed, 0 failed).
  • Ran cargo fmt --all -- --check to ensure formatting is clean and it passed.
  • Verified the newly added snapshot integration tests execute and succeed as part of the snapshot test suite.

Codex Task

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Jun 2, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit d3db6d8 Commit Preview URL Jun 02 2026, 09:33 AM

@chaliy chaliy force-pushed the 2026-06-02-fix-session-limit-counter-reset-on-snapshot-resume branch from 044750b to d3db6d8 Compare June 2, 2026 09:19
@chaliy chaliy merged commit cbedcdb into main Jun 2, 2026
34 checks passed
@chaliy chaliy deleted the 2026-06-02-fix-session-limit-counter-reset-on-snapshot-resume branch June 2, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant