buffa: charging buffered Any payloads against the memory limit

Merged into buffa, a Rust protobuf implementation with JSON serialization and zero-copy views. Reflective JSON deserialization charged a google.protobuf.Any payload against the element memory limit only at replay, so an arbitrarily large Any could be buffered first and slip past the budget. I added charging variants that meter the budget as the JSON tree is built, so the limit holds while the payload is still buffered. I reported the issue and sent the fix.

October 3, 2026

What was wrong

A reflective JSON Any is buffered as it deserializes and replayed later, once its type is known. Memory charging happened at replay, so the bytes held while the payload was buffered were never counted against the element memory limit. A large enough Any could sit in the buffer under the limit the limit existed to enforce.

The change

New ChargingObject and ChargingValue variants account for memory as the JSON tree is built, rather than waiting for replay. The budget is consumed while the payload buffers, so an oversized Any is rejected at the point it would otherwise be accepted. It closes issue #493.

anthropics/buffa #507, merged