Extend a crash-recoverable LRU cache to support built-in containers and explicitly registered domain objects without using unsafe object serialization.
Question
Extend a crash-recoverable LRU cache to support built-in containers and explicitly registered domain objects without using unsafe object serialization.
```python
class CodecRegistry:
def register(self, tag, cls, key_fn, encode_fn, decode_fn) -> None: ...
def key_for(self, value) -> str: ...
def encode_value(self, value): ...
def decode_value(self, payload): ...
class LRU:
def __init__(self, capacity=8, log_path=None, registry=None): ...
def call(self, func, *args, **kwargs): ...
```
## Requirements
- Produce canonical, type-tagged keys for `None`, booleans, integers, finite floats, strings, bytes, lists, tuples, dictionaries, sets, frozensets, and registered objects.
- Preserve distinctions such as `True`, `1`, and `1.0`; make dictionary and set identity independent of iteration order.
- Allowlist exact classes through unique stable tags. Never dynamically import a class named by stored data.
- Encode and decode cached values through the registry and reject unknown or malformed tags.
- Append and `fsync` one versioned record on every access; replay in order and preserve recency.
- Handle capacity zero, falsey cached values, a torn final record, and corruption before the final record.
## Staged follow-ups
1. Specify and implement canonical key encoding.
2. Implement safe value encoding and registered-object reconstruction.
3. Integrate the codec with durable LRU replay.
4. Plan schema migration, codec evolution, compaction, and recovery when a registered class changes.
5. Explain the security and compatibility tradeoffs relative to general object serialization.The public brief is identical for people and crawlers. Account access changes tools, not the indexed description.