Summary
np.frombuffer is used to reconstruct numpy arrays and numeric DataFrame/Series columns. The returned arrays are writeable=False, owndata=False, and alias the source bytes. On an L1 hit they alias the live L1-cached bytes.
Evidence
src/cachekit/serializers/auto_serializer.py:642 (numpy), :705 (numeric DataFrame col), :766 (numeric Series)
- Empirically:
np.frombuffer(...).reshape(...) → flags.writeable=False; mutation raises ValueError: assignment destination is read-only
Impact
- Behavioral regression: a caller who mutates a returned array/frame gets a crash that an uncached call would not produce.
- Aliasing risk: on L1 hits the returned array shares memory with the cached entry; mutating-by-copy patterns can be surprising. DATA-IS-SACRED adjacency.
Fix
Return a writable copy (np.array(frombuffer(...))) or document the read-only contract explicitly and copy-on-return for the L1 path.
Summary
np.frombufferis used to reconstruct numpy arrays and numeric DataFrame/Series columns. The returned arrays arewriteable=False,owndata=False, and alias the source bytes. On an L1 hit they alias the live L1-cached bytes.Evidence
src/cachekit/serializers/auto_serializer.py:642(numpy),:705(numeric DataFrame col),:766(numeric Series)np.frombuffer(...).reshape(...)→flags.writeable=False; mutation raisesValueError: assignment destination is read-onlyImpact
Fix
Return a writable copy (
np.array(frombuffer(...))) or document the read-only contract explicitly and copy-on-return for the L1 path.