Implement canonical projection and detached copies
This commit is contained in:
@@ -101,8 +101,39 @@ tokens become indices only in a sequence. Sequence indices cannot have leading
|
||||
zeroes; fixed-array indices are bounds checked. Dynamic `any` and inline-map entries
|
||||
remain schema-valid for application-defined descendants.
|
||||
|
||||
Descriptors do not yet decode documents, clone defaults, or project application
|
||||
values. Those operations will reuse this graph as their implementation lands.
|
||||
Descriptors do not yet decode documents. Document decoding will reuse this graph as
|
||||
its implementation lands.
|
||||
|
||||
## Typed projection and ownership
|
||||
|
||||
ConfigKit can internally project a schema-valid application value directly into its
|
||||
owned canonical tree without YAML serialization. Projection includes every bound
|
||||
field, including ordinary zero values; `omitempty` has no effect. Struct fields keep
|
||||
binding order, dynamic map keys sort by decoded string, and sequences keep their
|
||||
order. Integers retain exact base-10 values, finite floats use their destination
|
||||
precision, durations use `time.Duration.String`, and paired text scalars use their
|
||||
canonical marshaled text.
|
||||
|
||||
Nil pointers, maps, slices, and dynamic values project as null. Non-nil empty maps
|
||||
and slices remain empty containers, preserving the distinction. Recursive acyclic
|
||||
objects are supported. Cyclic values, non-finite floats, unsupported dynamic concrete
|
||||
types, invalid codec output, and depth/node-limit violations fail with safe schema
|
||||
classifications that omit codec error text.
|
||||
|
||||
The same descriptor graph creates detached typed copies. Pointers, maps, slices,
|
||||
arrays, nested dynamic values, and shared references are recursively copied; shared
|
||||
pointer identity is not preserved as configuration meaning. Paired text scalars are
|
||||
rebuilt by unmarshaling their canonical text into fresh values, detaching private
|
||||
backing storage. Ignored and unexported struct fields are zeroed rather than copied.
|
||||
|
||||
Private structural comparison operates on canonical trees. Mapping additions,
|
||||
removals, and descendant replacements retain semantic paths. A sequence is atomic:
|
||||
any sequence change reports the sequence path and never invents correspondence
|
||||
between old and new indices. Cross-kind and null/container changes replace the
|
||||
affected path.
|
||||
|
||||
These mechanisms currently support later decoding, resolution auditing, metadata,
|
||||
and rendering. They are not a public generic conversion or cloning API.
|
||||
|
||||
## Safe failures
|
||||
|
||||
|
||||
Reference in New Issue
Block a user