feat: persist verified graph synthesis runtime
This commit is contained in:
@@ -18,3 +18,16 @@ func TestGraphPersistenceMigrationIsRevisionScoped(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGraphSynthesisMigrationIsWorkOwnedAndAtomicInputsExist(t *testing.T) {
|
||||
data, err := os.ReadFile("../../database/migrations/036_work_graph_result_synthesis.sql")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
sql := string(data)
|
||||
for _, marker := range []string{"work.graph_result_candidates", "work.graph_conflicts", "work.graph_synthesis_candidates", "verifier_run_id", "dissent_candidate_ids", "FOREIGN KEY (graph_id, graph_revision)", "SET ROLE work_role"} {
|
||||
if !strings.Contains(sql, marker) {
|
||||
t.Fatalf("graph synthesis persistence marker missing: %s", marker)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,3 +58,26 @@ func TestGraphRuntimeSchedulesFanOutAndCompletesFanIn(t *testing.T) {
|
||||
t.Fatalf("completed=%+v err=%v", completed, err)
|
||||
}
|
||||
}
|
||||
|
||||
type graphResultStoreStub struct {
|
||||
conflict work.ConflictSet
|
||||
count int
|
||||
}
|
||||
|
||||
func (s *graphResultStoreStub) SaveGraphSynthesis(_ context.Context, conflict work.ConflictSet, candidates []work.ResultCandidate, _ work.GraphSynthesisCandidate) error {
|
||||
s.conflict = conflict
|
||||
s.count = len(candidates)
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestSynthesizeGraphPersistsVerifiedDissent(t *testing.T) {
|
||||
store := &graphResultStoreStub{}
|
||||
conflict, synthesis, err := application.SynthesizeGraph(context.Background(), store, application.GraphSynthesisRequest{
|
||||
Conflict: work.ConflictSet{ID: "conflict-1", GraphID: "graph-1", GraphRevision: 1, NodeID: "node-1", CandidateIDs: []string{"candidate-a", "candidate-b"}},
|
||||
Candidates: []work.ResultCandidate{{ID: "candidate-a", GraphID: "graph-1", GraphRevision: 1, NodeID: "node-1", AuthorRunID: "producer-a", EvidenceSummary: "a", Summary: "a"}, {ID: "candidate-b", GraphID: "graph-1", GraphRevision: 1, NodeID: "node-1", AuthorRunID: "producer-b", EvidenceSummary: "b", Summary: "b"}},
|
||||
SelectedCandidate: "candidate-a", VerifierRunID: "verifier-1", VerifierIdentity: "independent", EvidenceRefs: []work.EvidenceRef{"tests:1"}, Summary: "verified", Verified: true,
|
||||
})
|
||||
if err != nil || !conflict.Resolved || synthesis.State != work.GraphSynthesisVerified || store.count != 2 || !store.conflict.Resolved {
|
||||
t.Fatalf("unexpected runtime synthesis: conflict=%+v synthesis=%+v stored=%+v err=%v", conflict, synthesis, store.conflict, err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user