Bound concurrent section work and finalize proposal identities in order
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/core/reporting"
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/framework/llm"
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/framework/runner"
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/framework/structuredoutput"
|
||||
)
|
||||
|
||||
@@ -94,3 +95,30 @@ func BuildLLMExecution(snapshot llm.ObservationSnapshot) any {
|
||||
Events []executionEvent `json:"events"`
|
||||
}{llm.Summarize(snapshot), calls, events}
|
||||
}
|
||||
|
||||
// IndexLLMObservations assigns the same proposal identities used by the ledger.
|
||||
func IndexLLMObservations(snapshot llm.ObservationSnapshot, units []runner.WorkUnitOutcome) llm.ObservationSnapshot {
|
||||
type sectionKey struct {
|
||||
module string
|
||||
section int
|
||||
}
|
||||
offsets := make(map[sectionKey]int)
|
||||
for _, unit := range units {
|
||||
if unit.ProposalIndexOffset != 0 {
|
||||
offsets[sectionKey{unit.ModuleInstance, unit.Section.Index}] = unit.ProposalIndexOffset
|
||||
}
|
||||
}
|
||||
index := func(context *structuredoutput.DiagnosticContext) {
|
||||
if context.SectionIndex != nil && context.ProposalIndex != nil {
|
||||
offset := offsets[sectionKey{context.ModuleInstance, *context.SectionIndex}]
|
||||
context.ProposalIndex = structuredoutput.OffsetProposalIndex(context.ProposalIndex, offset)
|
||||
}
|
||||
}
|
||||
for i := range snapshot.Calls {
|
||||
index(&snapshot.Calls[i].Context)
|
||||
}
|
||||
for i := range snapshot.Events {
|
||||
index(&snapshot.Events[i].Context)
|
||||
}
|
||||
return snapshot
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user