Expand description
Capability Change Diffs (CAP-DIFF) for Phase 4B.
This module provides:
DiffOp- Individual diff operations (add/remove tags, models, tools, etc.)CapabilityDiff- Versioned diff message with operationsDiffEngine- Generate and apply diffs between capability sets
§Performance Targets
- Diff generation: < 1µs for typical changes
- Diff application: < 500ns
- Diff size (1 op): < 50 bytes
- Bandwidth savings: > 90% vs full CAP-ANN
Structs§
- Capability
Diff - Capability diff message
- Diff
Engine - Engine for generating and applying capability diffs
Enums§
- Diff
Error - Error during diff application
- DiffOp
- Individual diff operation
- Diff
Size Error - Error returned by
CapabilityDiff::try_to_byteswhen the diff would exceed the wire-format caps the receiver enforces.
Constants§
- MAX_
DIFF_ BYTES - Maximum byte length for a wire-format
CapabilityDiff. Chosen at 64 KiB — generous against real diffs (estimated_size()for a busy capability set with several model and tag changes is well under 4 KiB) while blocking a balloon-DoS vector where a peer ships a 100 MB JSON to makefrom_sliceallocate that much heap. - MAX_
DIFF_ OPS - Maximum number of operations per
CapabilityDiff. A real announcement-driven diff has O(changed-fields) ops (typically well under 50); 1024 is far past that and still bounds the cost ofapplyto a constant rather than O(peer-controlled). Chosen so a fully-packed op-flood payload (each op is the smallest JSON encoding, e.g.{"AddTag":"t0"}) stays well underMAX_DIFF_BYTES, keeping both caps coherent: byte cap guards heap during parsing, op cap guards CPU duringapply.