Keep native execution membership presentation stable

This commit is contained in:
2026-11-23 16:58:46 +00:00
parent 59f353348b
commit c554eecaec
5 changed files with 73 additions and 6 deletions

View File

@@ -1,6 +1,8 @@
package processreport
import (
"slices"
"strings"
"time"
"gitea.maximumdirect.net/eric/audita/v4/internal/framework/llm"
@@ -49,14 +51,27 @@ func BuildLLMExecution(snapshot llm.ObservationSnapshot) any {
RequestedPromptID: call.RequestedPromptID, CallID: call.CallID, Context: call.Context,
Prompt: call.Prompt, Started: call.Started, Finished: finished,
ElapsedMS: call.WallDuration.Milliseconds(), Failure: call.Failure,
PromptKit: group.Snapshot(),
PromptKit: orderedMembers(group.Snapshot()),
})
}
return struct {
Summary llm.ExecutionSummary `json:"summary"`
Calls []executionCall `json:"calls"`
Events []llm.ExecutionObservation `json:"events"`
}{llm.Summarize(snapshot), calls, events}
}{orderedExecutionSummary(snapshot), calls, events}
}
// orderedMembers changes only the detached diagnostic presentation.
func orderedMembers(summary pk.ExecutionGroupSummary) pk.ExecutionGroupSummary {
summary.Members = slices.Clone(summary.Members)
slices.SortFunc(summary.Members, func(a, b pk.ExecutionGroupMember) int { return strings.Compare(a.RunID, b.RunID) })
return summary
}
func orderedExecutionSummary(snapshot llm.ObservationSnapshot) llm.ExecutionSummary {
summary := llm.Summarize(snapshot)
summary.PromptKit = orderedMembers(summary.PromptKit)
return summary
}
// IndexLLMObservations assigns the same proposal identities used by the ledger.