Enchantrix/pkg/crypt
google-labs-jules[bot] 7c2949a939 fix(crypt): resolve race condition in service initialization
A data race was identified in the lazy initialization of the RSA and PGP services within the `crypt` package. The non-thread-safe `if s.service == nil` check could lead to multiple initializations when accessed concurrently.

This commit resolves the race condition by using `sync.Once` to ensure that the initialization for each service is performed exactly once, making the `Service` struct safe for concurrent use.

Additionally, a new test file, `race_test.go`, has been added to provide a regression test for this specific scenario.

A new file, `AUDIT-CONCURRENCY.md`, has been created to document the findings of the concurrency audit, the remediation steps taken, and the verification process.

Co-authored-by: Snider <631881+Snider@users.noreply.github.com>
2026-02-02 01:20:31 +00:00
..
std docs: add examples for checksum algorithms, hashing, PGP operations, and .trix container format 2026-01-13 16:10:30 +00:00
crypt.go fix(crypt): resolve race condition in service initialization 2026-02-02 01:20:31 +00:00
crypt_internal_test.go feat: Add Good, Bad, and Ugly tests 2025-11-13 21:27:38 +00:00
crypt_test.go feat: Add Good, Bad, and Ugly tests 2025-11-13 21:27:38 +00:00
examples_test.go feat: add 100% docstring coverage 2025-11-14 14:39:45 +00:00
race_test.go fix(crypt): resolve race condition in service initialization 2026-02-02 01:20:31 +00:00