Skip to content

feat: transactional & recoverable workspace ops (issue #59, Tasks 1-3) - #66

Closed
nicksenap wants to merge 1 commit into
masterfrom
feat/transactional-workspace-ops
Closed

feat: transactional & recoverable workspace ops (issue #59, Tasks 1-3)#66
nicksenap wants to merge 1 commit into
masterfrom
feat/transactional-workspace-ops

Conversation

@nicksenap

Copy link
Copy Markdown
Owner

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 concurrent gw processes.

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, retryable STATE_LOCK_TIMEOUT), caller-owned non-reentrant Mutation handle (Get/Add/Update/Remove/Commit), invalidated after the callback.
  • Durable writes: unique temp file → fsync → atomic rename → parent-dir fsync. Raw Save removed; deterministic same-name conflicts.
  • Cross-process subprocess + -race tests.

Task 2 — Persist and surface recovery records

  • Versioned OperationStore under ~/.grove/operations/ (create/add/remove/delete/sync/rename) with resource-ownership enums, per-repo coded errors, commit status, and typed rename identity + source provenance.
  • Instance-scoped fault seams (mutationBackend for git/fs, withMutation commit seam, journalStore) that cannot be enabled in release binaries.
  • gw 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 list (not just the filesystem).
  • Per-workspace + per-branch reservation locks; identity-aware ambiguous-commit reconciliation; stale-record resume; setup/post_create failures 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

…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.
@nicksenap nicksenap closed this Jul 31, 2026
@nicksenap

Copy link
Copy Markdown
Owner Author

Close,
we might need to rethink about the approach

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants