Skip to content

Separate JSON and hash file operations are inevitably not atomic #515

Open

Description

@arkjedrz

What

#503 now contains atomic file operations, but it is not possible to store two files in an atomic manner.
Proposal: store checksum at the beginning of the file, followed by JSON data.
Maybe there's another solution to that.

Acceptance Criteria (DoD)

File store operations are fully atomic.

How

No response

Activity

  1. added theissue type on Oct 16, 2026
  2. self-assigned this
    on Oct 20, 2026
  3. arkjedrz commented on Oct 21, 2026

    @arkjedrz
    ContributorAuthor

    File format proposal

    I propose the following, sizes are in bytes.

    [ header : 4 | version : 4 | checksum : 4 | data : n ]

    • header: file header containing a magic number, I propose SKVS == 0x534B5653. File format detection only.
      • Should be a constant, always.
    • version: representation version.
      • Should be changed on data representation or file format change.
      • It is not a version of consumers data!
    • checksum: checksum of data that follows. Size might be increased in the future, then a bump to a version should occur.
    • data: data stored continuously.

    header and version layout should always be the same.
    The rest can be modified with a version bump and either ensured compatibility or reported version mismatch.
    E.g., version 2 might introduce CRC64, which makes checksum part 8 bytes long. Version 3 might introduce a new flags section placed before checksum.

    I'm not certain if additional data length field should be added to avoid unrestricted read.

  4. arkjedrz commented on Oct 22, 2026

    @arkjedrz
    ContributorAuthor

    Discussed and agreed 22.10.2026

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions