Conversation
01c5ac4 to
b03cf20
Compare
|
@Caleb-T-Owens I think this is what I've brought up in the past, would be great if you could have a look? |
b03cf20 to
d8a238b
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Critical failure paths can leave persistence layers inconsistent and Git ref changes unapplied to rollback.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
This PR preserves workspace stack ordering and flushes transaction metadata before completion.
Changes:
- Preserves graph edge traversal order during worktree projection.
- Adds explicit metadata flushing for TOML-backed stores.
- Adds regression tests for ordering, persistence, dry runs, and rollback.
The review found critical failure paths that can leave metadata layers inconsistent or apply Git ref changes despite a returned error.
File summaries
| File | Description |
|---|---|
crates/but-transaction/src/tests.rs |
Tests persisted ordering and transaction behavior. |
crates/but-transaction/src/lib.rs |
Flushes metadata before returning transaction state. |
crates/but-meta/tests/meta/ref_metadata_legacy.rs |
Tests flushing and continued writes. |
crates/but-meta/src/legacy/mod.rs |
Implements metadata-store flushing. |
crates/but-graph/tests/graph/init/with_workspace.rs |
Tests cached and fresh graph ordering. |
crates/but-graph/tests/fixtures/scenarios.sh |
Adds a linked-worktree ordering fixture. |
crates/but-graph/src/init/post.rs |
Preserves edge order during retargeting. |
crates/but-core/src/lib.rs |
Defines the metadata flush contract. |
Review details
- Files reviewed: 8/8 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Preserve stack order when separating worktree branches. - Save workspace metadata before a transaction returns.
The refs are already updated when metadata is flushed, so returning an error reported a completed change as failed and skipped its undo entry. - Log the failure, as the TOML store does on drop, and return the workspace state. - Test with a store whose save always fails: the reword lands and stays undoable.
d8a238b to
a2faf15
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Metadata may be flushed before fallible workspace-state construction, allowing failed transactions to partially commit.
Get a fresh assessment by requesting another Copilot review.
Review details
- Files reviewed: 9/10 changed files
- Comments generated: 1
- Review effort level: Lite
Stacks could change order on refresh for two unrelated reasons. One commit each, and each has a test that failed before its fix.
1. Moving a graph connection put its stack at the front
move_incoming_edgesre-added the one connection it moved, so that stack jumped to the front. It runs after stacks are ordered.2.
but commitsaved the stack order after releasing its lockbut commitre-binds its lock guard aftermeta, so the lock goes first and the TOML lands a moment later. The other seven transaction commands drop in the safe order.but commit -b <new>asks for position 0, so the new stack showed up last and then jumped to the front.RefMetadata::flush(no-op by default, the TOML store overrides it) now runs inside the transaction, once the refs have moved. Drop order no longer matters.lets incommit.rswould fix today's case. Flush also coverswith_transaction, which always releases its own lock before the caller's handle drops.Not covered
Verified