Skip to content

feat(checkpoint): export and inspect portable Session archives - #6748

Merged
M4n5ter merged 4 commits into
apache:rust-previewfrom
MicroGery:codex/portable-session-checkpoint
Nov 11, 2026
Merged

M4n5ter merged 4 commits into
apache:rust-previewfrom
MicroGery:codex/portable-session-checkpoint

Conversation

@MicroGery

@MicroGery MicroGery commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Export a published Session checkpoint as a portable archive and inspect its conversation, tool results, attachments (including inherited Fork history) and captured Workspace with the source Root and project offline.

maka checkpoint export --root /path/to/host --session "$SESSION_ID" --revision "$REVISION" --output session.tar.gz
maka checkpoint open session.tar.gz --output inspection

Export verifies the exact retained Head and referenced objects before completing. Open validates archive framing, lengths, digests and canonical history before publishing a new inspection directory without replacing existing output. Inspection preserves the publisher’s Workspace consistency declaration and does not transfer execution authority. Digests verify integrity; source authentication depends on the channel used to obtain the archive.

Metadata is parsed from readers without a separate byte ceiling or a full encoded-JSON buffer. Export re-reads and verifies metadata when writing it into the archive; --max-bytes controls inspection output size.

Refs #2370.

Verification

  • cargo test --locked -p maka-event-log --lib portable -- --nocapture — 3 passed. Covers archive integrity, complete object closure, exact members, truncation, output budgets and a 33 MiB inventory producing 18 bytes of history and Workspace output.
  • cargo test --locked -p maka-event-log --test checkpoint_restore -- --nocapture — 1 passed. Prepared Workspace restore survives process death and commits its receipt atomically.
  • cargo test --locked -p maka-cli --no-default-features --test mainline_reopen -- --nocapture — 4 passed. Real CLI coverage includes source-offline inspection, inherited Fork attachments, Head changes during export, process interruption, publication races, exact output budgets and Host death during Workspace restore.
  • cargo clippy --locked -p maka-event-log --lib -- -D warnings — passed.
  • Formatting of the four affected crates and git diff --check — passed.

Full workspace and cross-platform test matrices were not run.

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: OpenAI Codex — implementation, review and focused validation of archive transport, CLI inspection and tests.

Checklist

  • Tests cover the change and fail without it
  • Format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — the CLI exports and opens published Session checkpoints.
  • No

@MicroGery
MicroGery requested review from M4n5ter and me2seeks and removed request for M4n5ter November 10, 2026 12:09
@MicroGery
MicroGery requested a review from M4n5ter November 10, 2026 12:10

@Astro-Han Astro-Han left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I reviewed the complete 20-file author change at 556bbfdc0c6e60e9a84486120e380cdbc6ea439a, including the added Host-death fixture. I found no demonstrated P0–P2 defect. An actual merge into inspected Rust 228d8ed9c310b94c8e9375ba62b3615ccd06c296 succeeds.

The exporter reads the selected retained checkpoint, verifies workspace objects against their size and digest, then rechecks the retained head, scope and Root identity before publishing. The reader consumes fixed regular-file archive members without extracting their paths. It validates metadata and content digests, namespace and workspace paths, expanded byte budgets, missing/extra members and compressed-stream termination before materializing the workspace. The CLI stages privately, imports canonical history into a temporary Root, writes paginated history/artifacts under the output budget, removes its scratch Root, and publishes without replacing an existing destination. I followed pinned snapshot-content authorization, recursive snapshot/artifact enumeration and cursor progress checks. The archive does not transfer live Host execution or provider credentials.

On Linux, the original 11 event-log library tests and the existing checkpoint crash/reopen integration test pass. Three additional temporary tests pass across eight adversarial scenarios: six unsafe workspace paths, a case-alias inventory and trailing compressed data. A separate probe executes the production Linux directory-publication helper against an occupied file, an occupied directory and two concurrent publishers; existing sentinels survive and exactly one racing publisher succeeds. These executions used the prior de35dc1fdf001660ac1f7bf138d71976a6cd12de head; the two-file update to this head changes only the CLI integration fixtures, leaving all exercised implementation and library-test blobs unchanged. Formatting checks pass at the final head.

I inspected the new fixture's injected pre-commit interruption, SIGKILL, original-operation receipt recovery and explicit subsequent restore checks, but did not run that fixture or the complete CLI/Host build. The library crash/reopen test and standalone publication probe do not constitute a cross-process CLI export/open acceptance run. The author's macOS results remain attributed to the author. I did not independently validate native Windows/macOS, a large real database or the packaged product. Integration update: an actual merge into inspected Rust e35d4ac9cc894f463893f961a55772872686eca0 still conflicts in plugins/agent/state/src/session_history/snapshot/ingest/inventory.rs; the successful merge into 228d8ed9 above describes the earlier baseline. The latest run API reports CI 42813095868 as queued on attempt 1, while both completed native platform jobs report failure. I have not established the reason for that run-state change. I read their logs. On macOS, all 12 mainline tests pass, including both the clean-reopen portable-archive path and the new Host-death restore fixture. The following terminal-native selection stops at eight passed and one failed, with three not run: the offscreen-window assertion observes two native windows instead of one. The desktop suite is not reached. On Windows, desktop reports 17 passed and three failed: Continue and Goal produce missing-state diagnostics, and steering times out. This PR's entire NSH tree and the failed macOS fixture match parent f3411e7f; that parent's CI 42799531106 is still queued, so it does not provide a completed platform control. I have not established PR causation or successful platform acceptance. Dependency audit 42813095901 has succeeded. There is no database migration or strict Host wire-schema change.


Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.

@me2seeks me2seeks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed commit 556bbfd. No actionable production defect found.

The portable archive reuses immutable checkpoint objects, canonical history validation and history rendering, and publishes inspection output without replacing an existing destination. It preserves the capture's consistency declaration and does not grant execution authority.

I also reviewed the added tests for removal opportunities. I found no justified whole-test deletion: the CLI cases cover offline inspection, inherited Fork attachments, exclusive publication and output budgets; the Host crash case covers application-operation recovery and unchanged Session binding, which the existing event-log crash test does not cover.

Independent Linux verification: all 11 maka-event-log library tests, the checkpoint_restore integration test, formatting for the four affected crates, and diff whitespace checks passed. The CLI mainline_reopen suite is still compiling, and hosted audit checks remain queued; those are not claimed as passed.

AI-assisted review performed by OpenAI Codex at the user's explicit request.

@M4n5ter M4n5ter left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Reviewed commit 556bbfd; no actionable correctness or design blocker found in static review. The archive reuses canonical snapshot validation and history projection, verifies immutable objects, stages privately, and publishes inspection output without replacement or transferring execution authority.

I did not run the Rust tests in this review. The observed merge conflict against the inspected Rust baseline and the remaining CI checks need to be addressed before merging.

Automated review disclosure: Maka (OpenAI ChatGPT) performed this static review and posted the approval at the explicit request of M4n5ter. This is AI-assisted review, not an independent human review.

Package an exact published revision with its history and Workspace objects. Verify the archive and render it into an independent inspection directory, preserving attachment contents and source consistency.

Generated-by: OpenAI Codex
Interrupt a real Host after the checkpoint files are durable and before the Session binding commits. Reopen the same Root, recover the original receipt, and verify an explicit restore can continue the Session.

Generated-by: OpenAI Codex
@MicroGery
MicroGery force-pushed the codex/portable-session-checkpoint branch from 556bbfd to abb60c0 Compare November 10, 2026 18:52

@Astro-Han Astro-Han left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I compared the complete 20-file author scope at abb60c0bed688a244ae6d1fd647ee1da1dbae407 with the previously reviewed 556bbfdc0c6e60e9a84486120e380cdbc6ea439a, separating the rebase onto af9d01b796e7a2b1581fb5374978811a2b472b6e. I found no new demonstrated P0–P2 defect in this increment. The earlier inventory merge conflict is resolved: an actual merge into that current Rust target succeeds. CI status is updated below.

Nineteen author patches are unchanged. The remaining resolution is in plugins/agent/state/src/session_history/snapshot/ingest/inventory.rs: Filter::All keeps the incoming paged inventory_page reader, while ArtifactsAndMarkers retains the archive's indexed media/ancestor query. I read the combined query, authorization, limit/cursor handling and page reader. The scoped artifact branches keep their previous queries. Archive production code and the portable/SIGKILL fixture contents remain identical to the reviewed version; the large raw old-to-new diff also includes unrelated incoming changes.

My earlier event-log, checkpoint recovery, controlled archive and Linux publication-helper results remain evidence from their original commits. I did not rerun those tests, compile the complete CLI/Host or execute archive export/open and crash recovery at this rebased head. The author's macOS results remain attributed to the author. This author change adds no database schema migration or strict wire-format change.

The old 556bbfdc CI run 42813095868 has now ended as cancelled, with completed failed native jobs preserved: its macOS mainline slice passed all 12 tests, including portable open and the new SIGKILL restore case, then NSH failed the secondary-window assertion (eight passes, one failure, three not run); its Windows desktop slice had 17 passes and three failures. I also read completed parent f3411e7f run 42799531106: macOS failed the same NSH assertion after 11 mainline passes, while Windows failed the earlier pipe-drain process test (12 passes, one failure, one not run), before product-desktop acceptance. These historical observations do not establish that every failure has the same cause, and they do not establish native acceptance of this new head.

Hosted follow-up at the same head: run 42879516966 has completed with failure, attempt 1. I read the completed native logs. macOS recovery has seven passes and five failures. host_crash_after_workspace_copy_preserves_binding_and_allows_explicit_restore passes; the failures are the two Cell waiting-state JSON assertions on authorityUnavailable: false, external transcript recovery (external_task_unobservable), and Goal/scheduler recovery observing failed original Runs. This prevents subsequent native-window/product-desktop checks in that job. Windows reaches desktop with 17 passes and three failures: Continue observes no provider message, the finished-Goal UI observation is null, and steering times out. Current base af9d01b7 has the same observed five recovery failures and three desktop failures; this does not establish that every failure has the same cause.

I also read all four failed Linux CLI shards: JavaScript and Python fail the same waiting-state JSON comparison; Goal and scheduler observe failed original Runs. The tooling failure remains a stale Rust dependency inventory, also reported on current base. This PR changes two manifests and lockfile dependency edges; I have not run the generator locally or isolated their effect on that failure. The added versions already appear in the base inventory, which alone does not prove the generated inventory is correct. These jobs supply partial hosted evidence, not complete native acceptance or a demonstrated new archive defect. No additional local runtime tests were run.


Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.

@github-actions github-actions Bot added the effort/XL Under 2500 readable lines label Nov 11, 2026
}
fn metadata(source: impl Read, bytes: u64) -> Result<Vec<u8>, StoreError> {
if bytes > MAX_METADATA {
return Err(invalid("portable checkpoint metadata exceeds 32 MiB"));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

English

[P2] Avoid a portable-only 32 MiB metadata limit

This adds a new rejection condition for otherwise valid retained checkpoints. Workspace capture and workspace::read_inventory accept inventories larger than 32 MiB, but both portable export and open pass the inventory through this helper and reject them. Increasing --max-bytes cannot help because this ceiling is independent of the inspection output budget.

I reproduced the mismatch with 100,000 empty files beneath four 50-character directory components: the serialized inventory is 35,700,643 bytes, passes the existing workspace inventory validator, and is rejected here with portable checkpoint metadata exceeds 32 MiB. The file contents total zero bytes, so this can fail because of file count and path lengths alone.

Please remove this independent hard-coded ceiling. Parse and validate metadata through a reader where practical to avoid retaining an extra copy of the encoded JSON, while preserving length/digest checks and the explicit output budget. If a separate metadata resource limit is necessary, it needs a concrete resource/workload basis and a way to handle legitimate checkpoints; an arbitrary 32 MiB cutoff makes valid checkpoints impossible to export or inspect.

中文

[P2] 不应新增 portable 路径独有的 32 MiB metadata 上限

这里给原本合法的 retained checkpoint 新增了拒绝条件。Workspace capture 和 workspace::read_inventory 都接受超过 32 MiB 的 inventory,但 portable export 和 open 都会经过这个 helper,因此直接拒绝。这个上限独立于 inspection 的输出预算,调大 --max-bytes 也无法解决。

我用四层、每层 50 个字符的目录路径下的 10 万个空文件复现了这个差异:序列化后的 inventory 为 35,700,643 字节,能通过现有 workspace inventory 校验,却在这里报 portable checkpoint metadata exceeds 32 MiB。文件内容总量为零,仅文件数量和路径长度就足以触发失败。

建议移除这个独立的硬编码上限;能通过 reader 解析、校验的 metadata 就直接读取,避免额外保留整份编码后的 JSON,同时保留长度、digest 校验和显式输出预算。如果确实需要单独限制 metadata 资源消耗,应给出具体资源或真实工作负载依据,并让合法 checkpoint 有可用的处理路径,而不是用任意的 32 MiB 阈值让它们无法导出或查看。

Parse metadata through buffered readers while retaining object length and digest verification. Re-read verified metadata during export instead of buffering its encoded JSON. Keep the inspection output budget independent of metadata size.

Generated-by: OpenAI Codex
@M4n5ter
M4n5ter merged commit 13e1919 into apache:rust-preview Nov 11, 2026
3 checks passed

@Astro-Han Astro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I reviewed the two-file production/test increment from abb60c0bed688a244ae6d1fd647ee1da1dbae407 to final head 555c474dc7156496ddefe3cc36f4cd91b68177b7. I found no new demonstrated P0–P2 defect in that increment. The earlier two ordinary author commits are unchanged in range-diff; this adds reader-based metadata parsing and re-verifies metadata when writing the archive. Another contributor has merged it as 13e1919655e2644c2dd5fe7678e39d0c6bbe9e59; an actual merge of its parent and this PR head reproduces that landing tree.

On Linux at the exact final head, I ran the three original maka-event-log portable tests: all passed. With only the production portable.rs replaced by the preceding version, the added 33 MiB metadata test fails with portable checkpoint metadata exceeds 32 MiB, while the other two pass. Restoring final-head production code makes all three pass again. The original checkpoint_restore integration test also passes, including process death during prepared Workspace restore and atomic receipt publication. Package formatting and git diff --check pass, and the working tree is restored to the exact source.

The implementation retains digest/length checks, exact archive members and framing, complete Workspace object closure, and the expanded inspection-output budget. Reader parsing avoids keeping a separate encoded-JSON buffer; it still constructs structured metadata and a Workspace entry collection in memory. The large regression fixture pads a small inventory with whitespace and produces 18 output bytes; it does not establish memory or performance behavior for millions of real entries.

This supplements the preceding review of the 20-file change with the bounded increment and tests above. I did not compile or run the full CLI/Host archive suite, execute all four CLI reopen tests, measure a large real Workspace, or perform macOS/Windows/native UI acceptance. The PR author's CLI and macOS results remain attributed to the author. These results do not establish complete cross-platform acceptance.


Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/XL Under 2500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants