Detach version labels in prepared execution snapshots
This commit is contained in:
@@ -229,6 +229,7 @@ func clonePreparedRun(source *domain.PreparedRun) (*domain.PreparedRun, error) {
|
||||
}
|
||||
|
||||
copied := *source
|
||||
copied.PromptVersion = copyStringPointer(source.PromptVersion)
|
||||
extraParams, err := jsonvalue.CopyMap(source.EffectiveModelParams.ExtraParams)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -662,6 +662,7 @@ func TestRunnerPreparedExecutionDetachesTransferredSnapshotSources(t *testing.T)
|
||||
"properties": map[string]any{"value": map[string]any{"type": "string"}},
|
||||
}
|
||||
definition := promptDef(domain.FormatJSON, domain.ValidationJSONSchema, 0)
|
||||
wantPromptVersion := *definition.Version
|
||||
definition.Validation.SchemaPath = "schema.json"
|
||||
control := &domain.CacheControl{Type: domain.CacheControlEphemeral, TTL: "1h"}
|
||||
rendered := &domain.RenderedPrompt{Messages: []domain.RenderedMessage{{
|
||||
@@ -697,6 +698,7 @@ func TestRunnerPreparedExecutionDetachesTransferredSnapshotSources(t *testing.T)
|
||||
}
|
||||
mutateExtra(profileExtras, "mutated profile source")
|
||||
mutateExtra(requestExtras, "mutated request source")
|
||||
*definition.Version = "mutated definition label"
|
||||
rendered.Messages[0].Content = "mutated renderer source"
|
||||
control.TTL = "mutated renderer cache metadata"
|
||||
schemaDocument["properties"].(map[string]any)["value"].(map[string]any)["type"] = "integer"
|
||||
@@ -711,11 +713,21 @@ func TestRunnerPreparedExecutionDetachesTransferredSnapshotSources(t *testing.T)
|
||||
details.StructuredOutput.JSONSchema.Schema.(map[string]any)["properties"].(map[string]any)["value"].(map[string]any)["type"] != "string" {
|
||||
t.Fatalf("prepared details retained a source alias: %#v", details)
|
||||
}
|
||||
if details.PromptVersion == nil || *details.PromptVersion != wantPromptVersion {
|
||||
t.Fatalf("prepared details did not preserve the captured version: %+v", details)
|
||||
}
|
||||
*details.PromptVersion = "mutated details label"
|
||||
if again := prepared.Details(); again == nil || again.PromptVersion == nil || *again.PromptVersion != wantPromptVersion {
|
||||
t.Fatalf("details version mutation escaped into the retained snapshot: %+v", again)
|
||||
}
|
||||
|
||||
result, err := runner.RunPrepared(context.Background(), prepared)
|
||||
if err != nil || result == nil || !result.Validation.IsValid || result.InputHashes["transcript"] != "captured-input-hash" {
|
||||
t.Fatalf("run prepared snapshot=(%+v, %v)", result, err)
|
||||
}
|
||||
if result.PromptVersion == nil || *result.PromptVersion != wantPromptVersion {
|
||||
t.Fatalf("details version mutation escaped into execution metadata: %+v", result)
|
||||
}
|
||||
if len(llmClient.lastReq.Prompt.Messages) != 1 || llmClient.lastReq.StructuredOutput == nil ||
|
||||
llmClient.lastReq.StructuredOutput.JSONSchema == nil ||
|
||||
extraLabel(llmClient.lastReq.Target.ExtraParams) != wantLabel ||
|
||||
@@ -725,6 +737,7 @@ func TestRunnerPreparedExecutionDetachesTransferredSnapshotSources(t *testing.T)
|
||||
t.Fatalf("execution snapshot retained a source alias: %#v", llmClient.lastReq)
|
||||
}
|
||||
if completedDetails := prepared.Details(); completedDetails == nil ||
|
||||
completedDetails.PromptVersion == nil || *completedDetails.PromptVersion != wantPromptVersion ||
|
||||
len(completedDetails.Messages) != 1 || completedDetails.Messages[0].Content != "captured rendering" ||
|
||||
extraLabel(completedDetails.EffectiveModelParams.ExtraParams) != wantLabel {
|
||||
t.Fatalf("completed details changed after source mutation: %#v", completedDetails)
|
||||
|
||||
Reference in New Issue
Block a user