Prepare scene extraction and deterministic normalization in core

This commit is contained in:
2026-11-25 15:48:32 +00:00
parent 9d2674481b
commit e3ddc177ab
13 changed files with 135 additions and 101 deletions

View File

@@ -77,6 +77,9 @@ type NativeOperation[T any] struct {
Correction CorrectionBuilder
Fallback Fallback[T]
Diagnostics TerminalDiagnostics[T]
// Reuse checks and, when needed, adapts a decoded accepted value to this
// operation's current domain inputs. An error makes the cache entry unusable.
Reuse func(T) (T, error)
// Evidence is optional, lazy preparation evidence for this operation.
Evidence func() (any, error)
}

View File

@@ -100,6 +100,18 @@ func executeNative[T any](ctx context.Context, execution ExecutionContext[T], op
var err error
var cacheKey string
cache := execution.Cache
if cache != nil && cache.Decode != nil && operation.Reuse != nil {
copy := *cache
decode := cache.Decode
copy.Decode = func(content []byte) (T, error) {
value, err := decode(content)
if err != nil {
return value, err
}
return operation.Reuse(value)
}
cache = &copy
}
if execution.Execution.Capture != nil {
if err := execution.Execution.RecordEvidence("cache/selection.json", map[string]any{"mode": execution.Controls.Cache, "reuse_eligible": execution.ReuseEligible, "store_available": cache != nil && cache.Store != nil}); err != nil {
return empty, captureFailure(err, capture.Finish(nil, err, false, false))