feat: transactional & recoverable workspace ops (issue #59, Tasks 1-3) - #66
Closed
nicksenap wants to merge 1 commit into
Closed
feat: transactional & recoverable workspace ops (issue #59, Tasks 1-3)#66nicksenap wants to merge 1 commit into
nicksenap wants to merge 1 commit into
Conversation
…sue #59 Tasks 1-3) Foundation for transactional, crash-recoverable workspace operations. Task 1 - Serialize state mutations across processes: - state.Store.WithMutation: one flock-backed advisory lock (30s timeout, retryable STATE_LOCK_TIMEOUT), caller-owned Mutation handle with Get/Add/Update/Remove/Commit, non-reentrant, invalidated after callback. - Durable writes: unique temp file, fsync, atomic rename, parent dir fsync. - Removed raw Save; deterministic same-name conflicts. Subprocess/race tests. Task 2 - Recovery records: - state.OperationStore under ~/.grove/operations/: versioned, operation-specific records (create/add/remove/delete/sync/rename) with resource-ownership enums, per-repo coded errors, commit status, typed rename identity + source. - Instance-scoped fault seams: mutationBackend (git/fs), withMutation commit seam, journalStore. doctor reports stranded records read-only; pending/corrupt records suppress destructive legacy fixes. Task 3 - Transactional & recoverable create: - Typed OperationResult/RepoOutcome; CLI renders per-repo outcomes and exits non-zero on partial/pending. Write-ahead ownership journaling before each git mutation; reverse-order idempotent compensation touching only operation-created resources (worktree compensation reconciles against git worktree registration, not just filesystem). Per-workspace + per-branch reservation locks. Ambiguous commit reconciled by identity. Resume of stale records; setup/post_create failures are partial after commit; inputs validated before cloning. All gates: go test ./..., go test -race, vet, gofmt, staticcheck, gocyclo<20, darwin/linux cross-build.
Owner
Author
|
Close, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Foundation for transactional and recoverable workspace operations (issue #59) — Tasks 1–3 of
tasks/plan.md. Keeps~/.grove/state.json, workspace paths, git worktree registrations, and branches consistent across failures and concurrentgwprocesses.This is a draft: Tasks 4–15 (add-repo, remove/delete, doctor reconciliation & repair, sync/rename, CI/e2e gates, docs) are still to come on this branch.
What's included
Task 1 — Serialize state mutations across processes
state.Store.WithMutation: one flock-backed advisory lock (30s timeout, retryableSTATE_LOCK_TIMEOUT), caller-owned non-reentrantMutationhandle (Get/Add/Update/Remove/Commit), invalidated after the callback.Saveremoved; deterministic same-name conflicts.-racetests.Task 2 — Persist and surface recovery records
OperationStoreunder~/.grove/operations/(create/add/remove/delete/sync/rename) with resource-ownership enums, per-repo coded errors, commit status, and typed rename identity + source provenance.mutationBackendfor git/fs,withMutationcommit seam,journalStore) that cannot be enabled in release binaries.gw doctorreports stranded records read-only; pending/corrupt records suppress destructive legacy fixes.Task 3 — Transactional & recoverable create
OperationResult/RepoOutcome; CLI renders per-repo outcomes and exits non-zero on partial/pending.git worktree list(not just the filesystem).post_createfailures are partial after commit; inputs validated before cloning.Verification
go test ./...,go test -race(state + workspace),go vet,gofmt,staticcheck,gocyclo -over 20, and darwin/linux cross-build all pass. Includes cross-process, fault-injection, and real-git tests plus a real-binary CLI exit/clone-retention test.Notes
--format jsonis intentionally out of scope (issue Epic: Replace MCP with an agent-native CLI #63).doctor --jsonremains a bare array (backward compatible).