Skip to content

Validate safeWriteJson replacement and recovery with native Windows file handles #2178

Open

Description

@edelauna

The JSON persistence caller audit identified a Windows validation gap.

Source: src/utils/safeWriteJson.ts.

The writer commits with one rename and enters a two-rename fallback only for EPERM. Fault-injection tests exercise that branch. They do not establish the error codes or replacement behavior produced by real Windows file handles.

Proposed scope:

  • Run native Windows tests with a reader that has explicit handle-sharing flags.
  • Record OS and Node versions and the observed rename errors.
  • Check both direct replacement and the fallback.
  • Check interruption between fallback renames, backup restoration, and lock handling.
  • Decide whether EBUSY or EACCES require changes only after collecting platform evidence.

Acceptance:

  • Previously committed content remains readable or recoverable after each injected interruption.
  • Failed restoration preserves committed backups.
  • Tests identify when Windows permits or rejects replacement.
  • The documented fallback matches observed platform behavior.
  • CI or an equivalent reproducible Windows run records the result.

This is a validation gap, not a claim that an additional error code must trigger the fallback.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions