diff --git a/docs/roadmap/implementation.md b/docs/roadmap/implementation.md index 0a707b6..6a20a39 100644 --- a/docs/roadmap/implementation.md +++ b/docs/roadmap/implementation.md @@ -1,6 +1,6 @@ # Library Adoption Implementation Plan -**Status:** Implementation complete; [review remediation](remediation.md) is in progress. +**Status:** Implementation complete; [review remediation](remediation.md) is complete. Planning baseline: `12fd2fba6b88e30eb482227ac786201caa84616b`. diff --git a/docs/roadmap/library-upgrades.md b/docs/roadmap/library-upgrades.md index a5766ac..d0f8395 100644 --- a/docs/roadmap/library-upgrades.md +++ b/docs/roadmap/library-upgrades.md @@ -1,6 +1,6 @@ # ConfigKit, PromptKit, and CommandKit Upgrade -**Status:** Implementation complete; [review remediation](remediation.md) is in progress. +**Status:** Implementation complete; [review remediation](remediation.md) is complete. The [implementation plan](implementation.md) records the completed stages. **Reviewed:** 2026-11-23, against Audita commit diff --git a/docs/roadmap/remediation.md b/docs/roadmap/remediation.md index a4a272c..bccdc4a 100644 --- a/docs/roadmap/remediation.md +++ b/docs/roadmap/remediation.md @@ -1,7 +1,7 @@ # Library Adoption Remediation **Status:** Findings from the implementation, integration, and algorithm -reviews; remediation is in progress. +reviews; all five issues are complete. **Reviewed source:** `338e93a7ebda9a86593069d63f9d5a7fe23ccaf5` (`Complete library adoption validation and cleanup`). @@ -17,7 +17,7 @@ The intended architecture is substantially in place. The initial review found test-maintenance and documentation gaps; the follow-up integration review also confirmed an output-safety gap involving operator-owned schema files. The algorithm review adds a debug-assembly memory opportunity and a diagnostic -ordering defect. R1–R3 remain outstanding. +ordering defect. Completion markers below record the fixes. ## R1: Remove the Test Fixtures' Implicit YAML Layout Requirement @@ -226,6 +226,10 @@ limit, benchmark gate, or change to the debug artifact schema. ## R5: Order Native Group Members at the Debug Presentation Boundary +**Complete.** The diagnostic serializer sorts detached native membership lists +for invocation and per-call summaries. Deterministic permutation tests pass +and verify original snapshot ownership, native facts, and event order. + **Priority:** P3 — deterministic diagnostic presentation. **Affected code:** @@ -327,3 +331,11 @@ performance data and made no application-code changes. Existing tests for `internal/framework/llm`, `internal/framework/processreport`, and `internal/framework/runner` passed; remediation links and whitespace checks also passed. + +## Remediation Validation + +All five issues are complete. With Go 1.27.4, `go test -race ./...`, +`go vet ./...`, and `go mod tidy -diff` passed on the completed code. +Linux amd64 and arm64 builds succeeded. Changed Go files are formatted; +affected local documentation links and whitespace checks passed. Each issue +was addressed in its own commit with the completion marker recorded above. diff --git a/internal/framework/processreport/llm.go b/internal/framework/processreport/llm.go index 6e28eed..2e09495 100644 --- a/internal/framework/processreport/llm.go +++ b/internal/framework/processreport/llm.go @@ -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. diff --git a/internal/framework/processreport/llm_test.go b/internal/framework/processreport/llm_test.go index 360e883..45a7238 100644 --- a/internal/framework/processreport/llm_test.go +++ b/internal/framework/processreport/llm_test.go @@ -160,3 +160,43 @@ func TestPerCallGroupsRetainCoverageAndDeduplicateTerminals(t *testing.T) { t.Fatalf("complete: %+v", complete) } } + +func TestNativeMembersHaveStableDetachedPresentation(t *testing.T) { + members := []pk.ExecutionGroupMember{{RunID: "z", TerminalObserved: true}, {RunID: "a"}} + snapshot := llm.ObservationSnapshot{ + Calls: []llm.LogicalCall{{CallID: 1}}, + Group: &pk.ExecutionGroupSummary{Members: members, Attempts: 7}, + Events: []llm.ExecutionObservation{ + {CallID: 1, PromptKit: pk.ExecutionEvent{RunID: "z", Kind: pk.ExecutionFinished, Attempts: 2}}, + {CallID: 1, PromptKit: pk.ExecutionEvent{RunID: "a", Kind: pk.ExecutionAttempt}}, + }, + } + raw, err := json.Marshal(BuildLLMExecution(snapshot)) + if err != nil { + t.Fatal(err) + } + var report struct { + Summary llm.ExecutionSummary + Calls []executionCall + Events []llm.ExecutionObservation + } + if err := json.Unmarshal(raw, &report); err != nil { + t.Fatal(err) + } + for _, summary := range []pk.ExecutionGroupSummary{report.Summary.PromptKit, report.Calls[0].PromptKit} { + if len(summary.Members) != 2 || summary.Members[0].RunID != "a" || summary.Members[1].RunID != "z" || summary.Members[0].TerminalObserved || !summary.Members[1].TerminalObserved { + t.Fatalf("members: %+v", summary.Members) + } + } + if members[0].RunID != "z" || report.Summary.PromptKit.Attempts != 7 || report.Calls[0].PromptKit.Attempts != 2 || report.Events[0].PromptKit.RunID != "z" { + t.Fatal("rendering changed evidence or input") + } + snapshot.Group.Members = []pk.ExecutionGroupMember{members[1], members[0]} + again, err := json.Marshal(BuildLLMExecution(snapshot)) + if err != nil { + t.Fatal(err) + } + if string(raw) != string(again) { + t.Fatal("membership permutation changed presentation") + } +}