Skip to content

fix(identity): resolve race conditions in identity file generation - #8

Merged
vuneumaaa merged 1 commit into
mainfrom
fix/identity-race-condition
Mar 18, 2026
Merged

vuneumaaa merged 1 commit into
mainfrom
fix/identity-race-condition

Conversation

@vuneumaaa

Copy link
Copy Markdown
Collaborator

Summary

Fixes race conditions in identity file generation by implementing:

  • Atomic file writes using tempfile + os.replace
  • Advisory file locking (fcntl on Unix, msvcrt on Windows)
  • Safe Windows locking with position preservation
  • IdentityCorruptedError for corrupted identity detection
  • AAIP_IDENTITY_PATH environment variable support

Motivation

Concurrent access to identity files could lead to:

  • Corrupted files
  • Lost identities
  • Failed PoE verification

This fix ensures safe concurrent behavior across platforms.

Validation

  • mypy: PASS
  • pytest: PASS (38 tests)

Notes

Closes #3

@vuneumaaa
vuneumaaa merged commit 56d131c into main Mar 18, 2026
8 checks passed
@vuneumaaa
vuneumaaa deleted the fix/identity-race-condition branch March 18, 2026 22:39
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.

Race Condition Identity

2 participants