l8reflect

Introspection

Model-agnostic runtime reflection and change tracking.

Overview

L8Reflect reads the blueprint of your data automatically. It can clone, compare, update, and navigate any Go data structure, even ones it has never seen before. No code generation. No manual mapping. Just pass a struct and the library figures out the rest.

Introspection

Struct analysis builds a node-based type tree with caching. A decorator system marks primary keys, unique fields, and always-overwrite semantics. The registry is thread-safe with mutex protection.

Deep Cloning

Type-safe deep clone of any Go struct including pointers, slices, maps, and nested types. Internal fields (XXX, DoNotCompare, DoNotCopy) are automatically filtered. Deep equality comparison is built in.

Property Navigation

Path-based get/set on arbitrarily nested structs using dot-delimited paths with map key syntax. For example: order.lines<key>.amount. Supports maps, slices, and struct fields. Includes Collect and ForEachValue traversal.

Change Tracking

Differential comparison between two instances of the same type. Records property-level Change objects with old and new values. Supports dry-run mode (detect changes without mutating the original), nil-is-valid semantics, and full-replacement mode.

Decorators

PrimaryKey
Identifies instances, used by the updater for matching
AlwaysOverwrite
Replace entire map instead of merging keys
Non
Exclude a field from cloning and comparison
Unique
Mark a field as unique within a collection

Time Series Support

Append-only slice semantics for time series fields. Thread-safe setters with mutex protection. Memory-leak-safe lifecycle management.

Architecture

go/reflect/introspecting/
Type introspection, L8Node tree, decorator registry
go/reflect/cloning/
Deep clone and deep equality
go/reflect/properties/
Path-based get/set, collect, traversal
go/reflect/updating/
Differential update, dry-run, change recording
go/reflect/helping/
Value extraction, filtering utilities

Testing

The test suite covers roughly 6,200 lines across 26 test files. Coverage includes introspection, cloning, property get/set, map operations, updater diffs, dry-run updates, time series setters, and boolean edge cases.