Repository navigation
feat(storage): decouple checkpoint repository from worker roots - #6929
Conversation
Astro-Han
left a comment
There was a problem hiding this comment.
I checked the checkpoint migration and the product migration catalog at 4ef96e95876c1f6fba828864f8d82123f109aebd against the current rust-preview (7e1e0ca05de94cd20fcf4e508879d80de56a6059). The static merge succeeds, but its composed migration catalog contains two different migrations numbered 40. This is now a current integration problem because Rooms has landed.
The inline P2 identifies the conflicting declaration. In temporary SQLite databases, using the actual catalog SQL and production ledger DDL/INSERT, the current base and this PR separately passed; the merged fresh catalog failed with UNIQUE constraint failed: _sqlx_migrations.version, and upgrading a database initialized with the current base encountered the version-40 checksum mismatch. Changing only the checkpoint migration's version to 41 made both controls pass. Use the next unused version when updating the PR, and cover fresh initialization plus upgrade/reopen with the composed product catalog.
These were controlled SQL checks, not execution of Rust migration::run, RootStore, or a real Host. I did not complete the full 21-file storage review or verify multi-process publication, recovery, or platform behavior. Existing CI results on the older base do not establish that this integration works.
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.
| sql: include_str!("../migrations/0036_pending_content_release.sql"), | ||
| }, | ||
| crate::migration::Migration { | ||
| version: 40, |
There was a problem hiding this comment.
[P2] Allocate an unused version after the Rooms migration
rust-preview now includes maka_agent_state::MIGRATIONS version 40 (0040_rooms.sql). products/maka/native/src/lib.rs::root_migrations concatenates that catalog with ROOT_MIGRATIONS, so this second version 40 breaks the otherwise clean merge: a fresh database inserts 40 for the checkpoint migration and fails inserting the Rooms ledger entry; a database already initialized by the current base rejects the checkpoint migration's different checksum for 40. I reproduced both with the actual migration SQL/ledger in temporary SQLite databases; only renumbering this new migration to 41 made both controls pass. Please use the next unused number and exercise the composed fresh/upgrade/reopen paths. The PR's standalone-base tests do not include the newly landed Rooms migration.
EnglishThe core consistency and recovery model here is solid: keeping shared worker Roots free of a second Before this lands, there are a few blockers, a noticeable local hot-path I/O regression, and some layering/state cleanups worth addressing:
简体中文这个 PR 在一致性与崩溃恢复边界上的核心设计是扎实的:共享模式下 worker Root 不再维护第二个本地 在合入前,有几个阻塞问题、默认本地热路径的 I/O 退化以及模块分层/状态建模上的毛刺需要处理一下:
|
ARE404
left a comment
There was a problem hiding this comment.
I reproduced the migration collision by merging 4ef96e9 onto the current rust-preview and running the composed migration test: it fails with UNIQUE constraint failed: _sqlx_migrations.version. Please allocate the next unused migration version and cover fresh initialization plus upgrade/reopen on the current target branch.
Storage::checkout_exact also verifies object integrity without verifying that the returned Manifest belongs to the requested logical Session’s persisted Binding. A valid but swapped Head can therefore return another Session’s history. Please expose the Binding on the read path, compare the Manifest source before returning it, and add a swapped-Head regression test.
I also agree that the repeated local-path copying/hashing and the Root-private SQL ownership should be resolved before merge.
| let objects = self.objects.clone(); | ||
| let reference = head.manifest.clone(); | ||
| let (manifest, snapshot) = tokio::task::spawn_blocking(move || { | ||
| let verified = VerifiedCheckpoint::verify(objects.as_ref(), reference)?; |
There was a problem hiding this comment.
[P1] Verify the Manifest belongs to the requested logical Session
VerifiedCheckpoint::verify proves the object closure is intact, but this checkout path never compares the Manifest’s {root_id, scope, session_id} with the persisted Binding for identity. If a valid Head is associated with the wrong logical Session (for example through control-plane corruption or a faulty replaceable repository implementation), this returns another Session’s history instead of failing closed. Please have the read path expose the Binding/source, validate the Manifest against it before returning, and cover a swapped-Head case.
4ef96e9 to
d91cbae
Compare
Add stable logical Session bindings, pluggable immutable object and repository ports, and a durable independent reference adapter. Route existing checkpoint publication and reads through the selected authority, preserve original commit receipts, and cover failure, concurrency and upgrade boundaries. Generated-by: Codex
…e efficiency Return the persisted Binding with each repository Head and reject Manifest provenance mismatches on exact checkout. Separate external repository schema and connection ownership from Root storage, and allocate migration 42 after Rooms and history tool metadata in the composed product catalog. Promote verified local staging without another copy and carry its verification through fresh publication. Keep full verification on recovery and shared paths, with regressions for swapped material, corrupt deduplication and recovery. Generated-by: Codex
d91cbae to
bff94de
Compare
Astro-Han
left a comment
There was a problem hiding this comment.
I rechecked the migration numbering at bff94deb2018b9e5af7de0cd3ce6f9331b9a96bd. The collision reported in my earlier review is fixed: the checkpoint migration now uses version 42, after Rooms at 40 and history tool metadata at 41. I no longer hold that migration P2 against this revision.
I read the catalog declarations, migration SQL, product composition and migration-runner checksum/ledger logic, and extracted their exact sources from the static merge with rust-preview@074c1ebd7004ddda606613fe4529009c00c73eaf. In controlled SQLite executions, the current base, this PR alone, a fresh merged catalog, and an upgrade from the current base all succeeded. Changing only the checkpoint catalog entry back to 41 made the fresh merged database fail on the duplicate ledger version and made the upgrade fail on the previously applied checksum. This checks the actual SQL and ledger identities; I did not execute Rust migration::run, RootStore, or a real Host upgrade.
The intermediate d91cbaef revision still collided at 41 after history metadata landed. That intermediate failure does not apply to this revision. The latest range comparison moves the checkpoint SQL and declaration to 42 and includes the current history-metadata baseline.
This follow-up resolves the numbering finding. I have not completed independent verification of the full 24-file repository implementation, multi-process publication and recovery, source removal, or platform behavior. The author's Mac execution results remain the author's results. The static merge succeeds; current hosted checks are still pending completion.
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.
…identity in tests Update `checkpoint_repository` test fixtures after apache#6941 removed `WorkspaceCapture::identity`. Generated-by: Antigravity
Summary
Checkpoint objects and the authoritative Head currently live under the publishing worker Root. This adds a durable logical Session/agent binding and replaceable immutable-object and Session Repository ports, and connects the existing publisher, Head reads, exact reads and publication recovery to them.
The default local adapter retains the existing Head table and local restore behavior. Trusted bootstrap can inject a
FileRepositoryoutside worker Roots; its objects, Head and original commit receipts remain readable after the source Root is removed. Shared workers retain capture/recovery records without maintaining a second Head. Head CAS and its terminal receipt commit atomically, and lost replies recover the original result without recapture.Refs #2370. This is PR1 of the control-plane-neutral continuation work; it does not close the issue.
Implementation
authority. The independent repository has its own schema and explicit repository identity column, and uses a bounded persistent connection worker. EventLog stores one Local/Shared authority instead of duplicate agent fields and a nil UUID sentinel.Boundaries
Verification
All Rust validation ran on a Mac mini against
rust-preview@b08f13270plus this change. No Rust builds ran on the editing machine.cargo nextest run --locked -p maka-event-log -p maka-agent-state --test-threads 1 --no-fail-fast: 46 passed. The one manual performance case was skipped by the normal suite and then explicitly executed successfully.cargo clippy --locked -p maka-event-log -p maka-agent-state --all-targets --no-deps -- -D warnings: passed.cargo check --locked -p maka-agent-native --lib: passed.clippy::needless_updateinplugins/agent/provider-protocol/src/chat_completions/response.rs.Local capture measurement
The comparison below used
d317be2bc, the same Mac mini and debug/test profile; three fresh Roots, each with ten distinct 10 MiB Workspace files. The interval measures awaitedpublish_fenced; source creation and fence acquisition are outside it. Each result is subsequently checked out and verified.d317be2bcwith the same standalone fixtureRun the manual case with
cargo test --locked -p maka-event-log --test checkpoint_repository local_workspace_capture_baseline -- --ignored --nocapture. After rebasing tob08f13270and allocating migration 42, the final-head repeat measured 888 / 790 / 767 ms (median 790 ms). These measurements support removal of the local-path regression for this workload; they are not a production latency guarantee.AI use
Tool(s) and scope: OpenAI Codex assisted with implementation, adversarial review, regression tests and this description. Commits include
Generated-by: Codex.Checklist
Does this PR entail a change in behavior?