Cache final typed producer artifacts under the initial native request hash

This commit is contained in:
2026-11-22 02:10:05 +00:00
parent 3ef55b1cf0
commit 36906cb3d1
15 changed files with 878 additions and 15 deletions

View File

@@ -30,6 +30,27 @@ type ArtifactCache interface {
Store(context.Context, CacheMode, string, []byte) error
}
// CacheObservation is transient operation evidence, not a persisted record or
// public report format. Prepared details are available even when lookup hits
// and native execution (and its OnPrepared callback) never happens.
type CacheObservation struct {
Decision string
MessageContentHash string
Prepared *promptkit.PreparedRun
Err error
ChunkID string
ChunkIndex *int
}
// ProducerCache binds the expected artifact codec and ordinary source usability
// to a store. Decode must not invoke the configured semantic validator chain.
type ProducerCache[T any] struct {
Store ArtifactCache
Encode func(T) ([]byte, error)
Decode func([]byte) (T, error)
Observe func(context.Context, CacheObservation) error
}
// ProducerControls is resolved before execution; modules do not inherit settings.
type ProducerControls struct {
Mode ExecutionMode `json:"mode"`
@@ -78,6 +99,7 @@ type ProducerOperation[T any] struct {
Assess CandidateAssessor[T] `json:"-"`
Execution ExecutionOptions
ReuseEligible bool
Cache *ProducerCache[T] `json:"-"`
}
type ProducerDisposition string