Context
Discovered during review of epic #271 (graphify parity closeout).
Description
In codegraph/semantic_extract.py:96-103, SemanticCache.put() writes to {key}.tmp then atomically replaces the target. But if two processes index concurrently with the same cache dir, they both write to the same .tmp path, causing data corruption or an OSError on Windows.
Suggested approach
Use tempfile.NamedTemporaryFile(dir=cache_dir, delete=False) instead of a deterministic .tmp suffix, then os.replace() the tempfile into place. This is the standard atomic-write-to-unique-tmp pattern.
Context
Discovered during review of epic #271 (graphify parity closeout).
Description
In
codegraph/semantic_extract.py:96-103,SemanticCache.put()writes to{key}.tmpthen atomically replaces the target. But if two processes index concurrently with the same cache dir, they both write to the same.tmppath, causing data corruption or an OSError on Windows.Suggested approach
Use
tempfile.NamedTemporaryFile(dir=cache_dir, delete=False)instead of a deterministic.tmpsuffix, thenos.replace()the tempfile into place. This is the standard atomic-write-to-unique-tmp pattern.