Skip to content

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

Merged
vuneum merged 1 commit intomainfrom
fix/identity-race-condition
Mar 18, 2026
Merged

fix(identity): resolve race conditions in identity file generation#8
vuneum merged 1 commit intomainfrom
fix/identity-race-condition

Conversation

@vuneum
Copy link
Owner

@vuneum vuneum commented Mar 18, 2026

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

@vuneum vuneum merged commit 56d131c into main Mar 18, 2026
8 checks passed
@vuneum vuneum 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