fix(checkpointing): skip checkpoint when cwd is the home directory #1294
main fromrefs/pull/1294/head·opened View on GitHubShowing 1 changed file with 14 additions and 0 deletions.
path.resolve(input.cwd) and homedir() are synchronous/non-throwing; wrapping them in Effect.try(() => …) unnecessarily introduces an UnknownException failure path (and can widen the effect error type beyond CheckpointStoreError). Prefer computing these values directly (or use Effect.sync / Effect.succeed), and if you want to guard against unexpected exceptions, map them into a CheckpointInvariantError so the service’s typed error channel stays consistent.
The home-directory check compares resolvedCwd (normalized via path.resolve) against the raw homedir() string. To avoid false negatives due to trailing separators, normalization differences, or platform-specific casing, resolve/normalize the home path via the same Path service before comparing (and consider realpath if symlinks are common).
This introduces a new behavioral branch (skipping checkpoint capture when cwd is the home directory) but there’s no direct regression test covering it. Consider adding a test that sets cwd to os.homedir() and asserts captureCheckpoint fails with CheckpointInvariantError (and that no git commands are executed), so this guard doesn’t regress.