Problem
FileTokenMetadataStore performs read-modify-write cycles on tokens.json without file-level locking. When the CLI and server are running concurrently (e.g. during rotate-key), one process can clobber the other's changes.
This was pre-existing but becomes materially more likely now that rotate-key is a hot path that triggers both CLI writes (mint new admin token) and server writes (ongoing token operations).
Proposed fix
Add flock-based advisory file locking around all tokens.json and revocations.json read-modify-write operations in FileTokenMetadataStore and FileRevocationStore.
Context
Surfaced during review of #324.
Problem
FileTokenMetadataStoreperforms read-modify-write cycles ontokens.jsonwithout file-level locking. When the CLI and server are running concurrently (e.g. duringrotate-key), one process can clobber the other's changes.This was pre-existing but becomes materially more likely now that
rotate-keyis a hot path that triggers both CLI writes (mint new admin token) and server writes (ongoing token operations).Proposed fix
Add
flock-based advisory file locking around alltokens.jsonandrevocations.jsonread-modify-write operations inFileTokenMetadataStoreandFileRevocationStore.Context
Surfaced during review of #324.