lib/cmetrics/docs/ai/memory-safety-review.md
Validate allocation, ownership, lifetime, and cleanup changes in this C library.
Use for constructors/destructors, containers, codecs, arenas, metadata, submodule allocator changes, and crash or leak reports.
First run the focused test normally. For AddressSanitizer, use a separate build with compiler/linker sanitizer flags and execute CTest with leak detection. For Valgrind, use a non-sanitized debug build and treat definite leaks/errors as failures. Record the exact compiler, flags, commands, and test count; sanitizer and Valgrind runs are complementary, not interchangeable.
Report the ownership model, confirmed defect, cleanup coverage, sanitizer and Valgrind results, allocation-failure coverage, and untested paths.
Stop when ownership cannot be established from callers, allocator injection is required but unavailable, or a proposed lifetime change affects a public structure without compatibility review.