Skip to content

feat(blaze): capture sandbox checkpoints - #2472

Open
WeissonHan wants to merge 1 commit into
alibaba:mainfrom
WeissonHan:feature/blaze/checkpoint-restore-draft-v1
Open

feat(blaze): capture sandbox checkpoints#2472
WeissonHan wants to merge 1 commit into
alibaba:mainfrom
WeissonHan:feature/blaze/checkpoint-restore-draft-v1

Conversation

@WeissonHan

@WeissonHan WeissonHan commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Why

Blaze can persist sandbox lifecycle state, but it does not provide an API that
captures a complete checkpoint and exposes it only after every required
artifact is durable. A failed or cancelled capture must also retain truthful
ownership information so restart recovery does not report success or delete an
uncertain result.

What changed

  • Add POST /v1/sandboxes/{id}/checkpoint to capture a running sandbox.
  • Add GET /v1/sandboxes/{id}/checkpoints to list committed history and identify
    the current checkpoint head.
  • Capture backend state, guest memory, and the storage provider's writable root
    in a self-contained, integrity-checked checkpoint.
  • Journal preparation, pause, publication, head movement, state persistence,
    and backend resume so interrupted work can be reconciled after restart.
  • Require explicit checkpoint support from both the backend and storage
    provider; unsupported combinations return 501 before sandbox mutation.
  • Keep catalog and artifact operations bound to retained directory identities,
    publish with no-replace renames, and clean an owned staging directory when
    its parent synchronization fails.
  • Remove committed checkpoint history during sandbox destruction. Destruction
    remains recoverable when cleanup or its durability cannot be proven.
  • Document the API, supported capabilities, failure outcomes, storage ownership,
    and restart behavior in English and Chinese.

Checkpoint restore, checkpoint deletion or pruning, and capture support for
Firecracker, Bubblewrap, and process backends are outside this change.

Related issue

Closes #2444

User / Agent impact

Users and agents can create and inspect full checkpoints through the two sandbox
endpoints above. Capture currently succeeds with the built-in mock backend and
file storage provider. Other built-in backends fail with 501 before pausing or
changing the sandbox until their capture adapters are implemented.

Successful capture pauses the backend, writes and verifies all artifacts,
publishes the manifest and checkpoint head, resumes the backend, and returns the
committed checkpoint record. Listing returns validated committed records with
parentage, logical size, head status, and head reachability.

Risk and compatibility

  • Public CLI, API, configuration, or documented behavior changed
  • Privileged or security-sensitive behavior changed
  • Cross-component contract changed
  • Migration or rollback guidance is needed

This adds two HTTP endpoints and a daemon-owned checkpoint namespace below the
configured state directory. Existing backend and storage implementations remain
fail-closed because checkpoint capability defaults to unsupported. New
lifecycle journal and last-checkpoint fields have deserialization defaults for
records written by earlier versions.

Filesystem risk is limited by retained directory descriptors, owner-only modes,
no-replace publication, identity revalidation, and explicit parent-directory
synchronization. Uncertain publication or cleanup retains recovery ownership
instead of deleting by pathname.

Validation

Exact revisions:

  • head commit: 345dc429bee66b42e0611dabd8b332dc86d4da7e
  • head tree: 0fa38b3b283efbf37ebb311fa67a8d8a08e34581
  • parent: 385a098b136b8fb3e2ddc414ae83e71258ab50bd
  • GitHub merge candidate: 9636c4bd660aafb27eff396b9e8beee18665c39d
  • merge parents: 385a098b136b8fb3e2ddc414ae83e71258ab50bd,
    345dc429bee66b42e0611dabd8b332dc86d4da7e
  • merge tree: 0fa38b3b283efbf37ebb311fa67a8d8a08e34581

The head and GitHub merge candidate have the same tree. Validation used a fresh
Linux x86_64 source tree, Rust and Cargo 1.88.0, locked offline dependencies, a
fresh Cargo home, and a separate empty target directory for every major stage.

Passed:

  • formatting;
  • locked metadata with default and all features;
  • workspace all-target builds with default and all features;
  • strict Clippy with -D warnings and no unused production checkpoint entry
    points, with default and all features;
  • serial workspace tests: 353 default and 399 with all features;
  • strict rustdoc with default and all features;
  • documentation naming, bilingual-tree, and relative-link checks;
  • commit message, trailer, source identity, and tree identity checks;
  • 43 exact checkpoint, routing, capability, cancellation, recovery, catalog,
    storage, backend, destruction, and durability-boundary regression tests. Each
    named test was required to exist and pass exactly once.

Evidence archive SHA-256:
088145de7e0f5504c7d6814de78e2564cd39e74d5cd781cebf25ee9322e5df6f.

The exact-head Blaze, documentation, pull-request metadata, commit-message,
website-build, and CLA checks all passed.

Documentation and rollback

The English and Chinese Blaze README, runtime user guide, lifecycle consistency
design, and storage synchronization design now describe checkpoint capture,
listing, persistence, cleanup, and recovery.

To roll back, stop the Blaze daemon and verify that no sandbox has an unfinished
checkpoint operation or RecoveryRequired state before reverting this commit.
Checkpoint directories created by this version are not consumed by an older
binary; preserve or archive them before starting that binary. Do not remove
checkpoint state while the daemon is running.

Copy link
Copy Markdown
Collaborator Author

@codex review Please review the generic full-checkpoint capture and listing workflow, with particular attention to durable publication boundaries, cancellation and restart recovery, and retained filesystem ownership.

@WeissonHan
WeissonHan force-pushed the feature/blaze/checkpoint-restore-draft-v1 branch from c7aa317 to 56bc391 Compare August 13, 2026 13:43

Copy link
Copy Markdown
Collaborator Author

@codex review Please review the updated exact head. The only change since the previous request is a test-only feature gate required by the default-feature Rust 1.88 Clippy job; please focus on the generic checkpoint capture/list workflow and its durable publication, cancellation, restart, and retained-ownership behavior.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 56bc391ed7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/blaze/crates/blazed/src/api.rs Outdated
Comment thread src/blaze/crates/blazed/src/checkpoint_store.rs
@WeissonHan
WeissonHan force-pushed the feature/blaze/checkpoint-restore-draft-v1 branch from 56bc391 to 995bab7 Compare August 13, 2026 14:06

Copy link
Copy Markdown
Collaborator Author

@codex review Please review exact head 995bab7e, which addresses both prior P1 findings by preserving the established checkpoint response fields and removing snapshot-payload rehashing from list requests while retaining full hashing at mutation and explicit verification boundaries.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 995bab7ebb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/blaze/crates/blazed/src/checkpoint_store.rs Outdated
@WeissonHan
WeissonHan force-pushed the feature/blaze/checkpoint-restore-draft-v1 branch from 995bab7 to 93cbdb9 Compare August 13, 2026 15:26

Copy link
Copy Markdown
Collaborator Author

Addressed the exact-head Codex permission finding in 93cbdb994d76c30dbe3eb813fc79d43f477c3e64.

Checkpoint catalog, sandbox, staging, and committed directories are now created with owner-only 0700 permissions. Daemon-created metadata and HEAD files use 0600. Before publication, all three backend-produced artifacts are opened relative to the retained stage, validated as regular files owned by the daemon user with one link, and only then restricted to 0600, synchronized, and hashed. Validation completes for every artifact before any mode change, so a linked artifact fails without modifying another file or an external alias.

Focused coverage verifies the complete tree under a permissive umask, rejects external hard links without permission side effects, and preserves cleanup of an interrupted internal rootfs link. The two storage artifact synchronization documents remain unchanged. Exact-head hosted and native Linux validation are running now.

Copy link
Copy Markdown
Collaborator Author

@codex review Verify that checkpoint directories and published artifacts remain private under the packaged service defaults, including hard-link failure behavior.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 93cbdb994d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@WeissonHan
WeissonHan marked this pull request as ready for review August 13, 2026 15:32
@WeissonHan
WeissonHan requested a review from casparant as a code owner August 13, 2026 15:32

@qoderai qoderai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[P1] 沙箱检查点生命周期和 journal 设计整体合理,当前审查重点是并发保护与补偿路径是否始终与持久化边界一致。下面三点是本次审查中相对更重要的细节建议,均已通过行内评论标注。

  1. 检查点操作在并发下对 operation journal 的保护需要严格约束所有调用路径使用同一锁,并在 API 层明确拒绝重复 checkpoint 请求。
  2. 失败补偿与恢复路径目前主要根据状态和 staging id 区分,建议进一步利用 OperationPhase 的 durable 边界信息,以保证 journal 与目录真实状态持续同步。
  3. 文件存储检查点目标目录在 Linux 与其他平台的 retained adapter 语义存在差异,建议在能力探测和错误处理上做显式约束,并在设计文档中标明跨平台行为差异。

🤖 Generated by QoderView workflow run

Comment thread src/blaze/crates/blaze-core/src/lifecycle.rs
Comment thread src/blaze/crates/blazed/src/sandbox/checkpoint.rs
Comment thread src/blaze/crates/blazed/src/file_provider.rs

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 93cbdb994d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/blaze/crates/blazed/src/sandbox/checkpoint.rs Outdated
Comment thread src/blaze/crates/blaze-core/src/lifecycle.rs Outdated
@WeissonHan
WeissonHan marked this pull request as draft August 13, 2026 15:57
@WeissonHan
WeissonHan force-pushed the feature/blaze/checkpoint-restore-draft-v1 branch from 93cbdb9 to 39b9446 Compare August 13, 2026 16:14
@WeissonHan
WeissonHan marked this pull request as ready for review August 13, 2026 16:17

Copy link
Copy Markdown
Collaborator Author

@codex review Add generic full-checkpoint capture and listing with durable publication boundaries and retained staging ownership.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 39b9446d7b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/blaze/crates/blazed/src/file_provider.rs Outdated
Comment thread src/blaze/crates/blazed/src/checkpoint_store.rs
@WeissonHan
WeissonHan marked this pull request as draft August 13, 2026 16:24
@WeissonHan
WeissonHan force-pushed the feature/blaze/checkpoint-restore-draft-v1 branch from 39b9446 to dcc2284 Compare August 13, 2026 17:02
@WeissonHan
WeissonHan marked this pull request as ready for review August 13, 2026 17:05

Copy link
Copy Markdown
Collaborator Author

@codex review Add generic full-checkpoint capture and listing while preserving sparse storage and bounded capture-time lineage validation.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dcc2284322

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/blaze/crates/blazed/src/checkpoint_store.rs
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: f53312f4ee

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@WeissonHan
WeissonHan force-pushed the feature/blaze/checkpoint-restore-draft-v1 branch 5 times, most recently from c951f78 to caa05a1 Compare August 16, 2026 16:47

Copy link
Copy Markdown
Collaborator Author

@codex review Please review exact head caa05a1a07280576609e9c488488288e1b152e94 and the checkpoint implementation commit relative to parent e0ebb106b963ba4784c0daba7a3370b1ddf3e508. Focus on the two supported sandbox checkpoint routes, absence of every /v1/instances route, durable capture and publication ordering, cancellation and restart recovery, complete checkpoint-namespace removal during sandbox destruction with RecoveryRequired on uncertain cleanup, removal of unused production entry points, and consistent English/Chinese documentation. Please report any P1 or P2 issue.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: caa05a1a07

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/blaze/crates/blazed/src/checkpoint_store.rs Outdated
@WeissonHan
WeissonHan force-pushed the feature/blaze/checkpoint-restore-draft-v1 branch 2 times, most recently from c115f2c to 6f2234d Compare August 16, 2026 17:00

Copy link
Copy Markdown
Collaborator Author

@codex review Please review exact head 6f2234d998658727bd20b27ece2e857dfff7dcbf and the checkpoint implementation commit relative to parent e0ebb106b963ba4784c0daba7a3370b1ddf3e508. Focus on the two supported sandbox checkpoint routes, absence of every /v1/instances route, durable capture and publication ordering, cancellation and restart recovery, complete checkpoint-namespace removal during sandbox destruction, retry of the catalog durability boundary when the namespace is already absent, RecoveryRequired on uncertain cleanup, removal of unused production entry points, and consistent English/Chinese documentation. Please report any P1 or P2 issue.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6f2234d998

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/blaze/crates/blazed/src/state_store.rs Outdated
@WeissonHan
WeissonHan force-pushed the feature/blaze/checkpoint-restore-draft-v1 branch 2 times, most recently from 5264a1d to 922af12 Compare August 16, 2026 17:18

Copy link
Copy Markdown
Collaborator Author

@codex review Please review exact head 922af12f97f930469f92a7e1d5cd1b260a6db5e5 and its parent e0ebb106b963ba4784c0daba7a3370b1ddf3e508. Please verify that only POST /v1/sandboxes/{id}/checkpoint and GET /v1/sandboxes/{id}/checkpoints are added, the former /v1/instances namespace remains unavailable, state-root and checkpoint-catalog durability retries cannot bypass parent synchronization, sandbox destruction removes committed checkpoint history or remains recoverable, cancellation retains serialization ownership, and no unused production checkpoint code remains.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 922af12f97

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/blaze/crates/blazed/src/sandbox/manager.rs Outdated
@WeissonHan
WeissonHan force-pushed the feature/blaze/checkpoint-restore-draft-v1 branch 2 times, most recently from b2e403a to d3295ee Compare August 16, 2026 17:33

Copy link
Copy Markdown
Collaborator Author

@codex review Please review exact head d3295eee7a32c63f0b43817dad476588c3a68f96 and parent e0ebb106b963ba4784c0daba7a3370b1ddf3e508. Please verify that only the two documented sandbox checkpoint routes are added; /v1/instances remains unavailable; state-root, catalog, and namespace-removal retries preserve their parent durability boundaries; checkpoint deletion runs on the blocking pool while retaining per-sandbox serialization; failed cleanup remains recoverable; cancellation retains ownership; and no unused production checkpoint code remains.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d3295eee7a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/blaze/crates/blazed/src/sandbox/manager.rs
@WeissonHan
WeissonHan force-pushed the feature/blaze/checkpoint-restore-draft-v1 branch 3 times, most recently from f16f667 to 80db550 Compare August 16, 2026 17:51

Copy link
Copy Markdown
Collaborator Author

@codex review Please review exact head 80db55082238a5b5a5c739527965594135b346e6 and parent e0ebb106b963ba4784c0daba7a3370b1ddf3e508. Please verify that only the two documented sandbox checkpoint routes are added; /v1/instances remains unavailable; every state-root and checkpoint-catalog durability retry preserves the required parent synchronization; checkpoint deletion runs on the blocking pool; client cancellation cannot release per-sandbox ownership before deletion converges; failed cleanup remains recoverable; and no unused production checkpoint code remains.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 80db550822

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@WeissonHan
WeissonHan marked this pull request as ready for review August 17, 2026 00:09
@WeissonHan

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 80db550822

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

let staging_name = format!(".{id}{STAGING_SUFFIX}");
match create_child_directory(&sandbox, &staging_name) {
Ok(directory) => {
sync_directory(&sandbox)?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Clean up the stage when its parent sync fails

When sync_directory(&sandbox) fails after create_child_directory succeeds—for example, due to a transient filesystem fsync error—the ? returns without aborting the newly created .ckpt-*.tmp directory or recording an operation journal. Each retry therefore creates another orphaned stage, and nothing removes these entries until the entire sandbox is destroyed; clean up the owned stage on this error or retain a recovery record rather than silently leaking catalog entries.

AGENTS.md reference: src/blaze/AGENTS.md:L32-L36

Useful? React with 👍 / 👎.

This commit exposes checkpoint creation and history queries under the
sandbox API. It captures backend state, guest memory, and the
provider-owned writable root in a self-contained, integrity-checked catalog.

Each durable boundary is journaled so cancellation and restart retain
ownership until publication, HEAD movement, state persistence, and backend
resume have converged. Unsupported providers fail before mutation. Failed
stage synchronization removes the owned scratch directory before returning.

Restore, checkpoint deletion, pruning, and Firecracker capture remain outside
this change.

Signed-off-by: Jing Zhang <renyu.zj@linux.alibaba.com>
Signed-off-by: Weisson <Weisson@linux.alibaba.com>
@WeissonHan
WeissonHan force-pushed the feature/blaze/checkpoint-restore-draft-v1 branch from 80db550 to 345dc42 Compare August 17, 2026 03:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[blaze] feat: capture and list sandbox checkpoints

1 participant