Merge pull request 'fix: serialize graph synthesis request fields' (#163) from codex/wp-403-graph-persistence into main
CI / test (push) Successful in 1m17s

This commit was merged in pull request #163.
This commit is contained in:
m
2026-08-22 23:10:08 +00:00
3 changed files with 41 additions and 28 deletions
+26 -26
View File
@@ -53,23 +53,23 @@ type WorkGraph struct {
}
type ResultCandidate struct {
ID string
GraphID string
GraphRevision int64
NodeID GraphNodeID
AuthorRunID AgentRunID
ArtifactRefs []EvidenceRef
EvidenceSummary string
Summary string
ID string `json:"id"`
GraphID string `json:"graph_id"`
GraphRevision int64 `json:"graph_revision"`
NodeID GraphNodeID `json:"node_id"`
AuthorRunID AgentRunID `json:"author_run_id"`
ArtifactRefs []EvidenceRef `json:"artifact_refs"`
EvidenceSummary string `json:"evidence_summary"`
Summary string `json:"summary"`
}
type ConflictSet struct {
ID string
GraphID string
GraphRevision int64
NodeID GraphNodeID
CandidateIDs []string
Resolved bool
ID string `json:"id"`
GraphID string `json:"graph_id"`
GraphRevision int64 `json:"graph_revision"`
NodeID GraphNodeID `json:"node_id"`
CandidateIDs []string `json:"candidate_ids"`
Resolved bool `json:"resolved"`
}
type GraphSynthesisState string
@@ -80,16 +80,16 @@ const GraphSynthesisVerified GraphSynthesisState = "VERIFIED"
// independently verified selection. It is a candidate, not an external action
// or authority grant.
type GraphSynthesisCandidate struct {
ID string
GraphID string
GraphRevision int64
NodeID GraphNodeID
CandidateIDs []string
SelectedCandidateID string
DissentCandidateIDs []string
VerifierRunID AgentRunID
VerifierIdentity string
EvidenceRefs []EvidenceRef
Summary string
State GraphSynthesisState
ID string `json:"id"`
GraphID string `json:"graph_id"`
GraphRevision int64 `json:"graph_revision"`
NodeID GraphNodeID `json:"node_id"`
CandidateIDs []string `json:"candidate_ids"`
SelectedCandidateID string `json:"selected_candidate_id"`
DissentCandidateIDs []string `json:"dissent_candidate_ids"`
VerifierRunID AgentRunID `json:"verifier_run_id"`
VerifierIdentity string `json:"verifier_identity"`
EvidenceRefs []EvidenceRef `json:"evidence_refs"`
Summary string `json:"summary"`
State GraphSynthesisState `json:"state"`
}
@@ -6,10 +6,10 @@
"risk_tier": "E",
"intent": "Persist Work Graph result candidates, conflicts and independently verified synthesis through the work owner and expose the governed synthesis runtime path.",
"requirement_ids": ["WP-403", "Durable graph result evidence", "Durable conflict resolution", "Synthesis runtime endpoint"],
"allowed_change_scope": {"modules": ["work-agent-execution", "work-storage", "work-graph-runtime"], "paths": ["database/migrations/036_work_graph_result_synthesis.sql", "adapters/postgres/work_repository.go", "modules/work/ports/graph.go", "modules/work/application/graph_runtime.go", "cmd/work-graph-runtime/main.go", "tests/agent_execution/graph_persistence_sql_test.go", "tests/agent_execution/graph_runtime_test.go", "dev/ACTIVE_TASK.json", "dev/tasks/DEV-000189-durable-graph-synthesis-runtime.json"]},
"allowed_change_scope": {"modules": ["work-agent-execution", "work-storage", "work-graph-runtime"], "paths": ["contracts/work/graph.go", "database/migrations/036_work_graph_result_synthesis.sql", "adapters/postgres/work_repository.go", "modules/work/ports/graph.go", "modules/work/application/graph_runtime.go", "cmd/work-graph-runtime/main.go", "tests/agent_execution/graph_persistence_sql_test.go", "tests/agent_execution/graph_runtime_test.go", "dev/ACTIVE_TASK.json", "dev/tasks/DEV-000189-durable-graph-synthesis-runtime.json"]},
"forbidden_change_scope": {"paths": ["architecture/**", "security/**", "contracts/authority/**", "modules/epistemics/**", "deploy/**", ".gitea/**"]},
"allowed_architecture_delta": {"new_cross_module_dependencies": 0, "new_canonical_owners": 0, "new_privileges": 0, "new_third_party_dependencies": 0, "new_database_owner_roles": 1},
"contracts": {"consume": ["Existing Work Graph ResultCandidate/ConflictSet/GraphSynthesisCandidate contracts", "WP-403 independent verifier gate"], "may_change": ["GraphStore persistence port"]},
"contracts": {"consume": ["Existing Work Graph ResultCandidate/ConflictSet/GraphSynthesisCandidate contracts", "WP-403 independent verifier gate"], "may_change": ["GraphResult JSON serialization tags", "GraphStore persistence port"]},
"semantic_owner": "work-agent-execution",
"canonical_state": ["work.graph_result_candidates", "work.graph_conflicts", "work.graph_synthesis_candidates"],
"state_transitions": ["result candidate append -> conflict append -> independently verified synthesis append", "failed verification does not persist a resolved synthesis"],
@@ -2,7 +2,9 @@ package agent_execution_test
import (
"context"
"encoding/json"
"strconv"
"strings"
"testing"
"git.cin.su/m/Assistant/contracts/work"
@@ -81,3 +83,14 @@ func TestSynthesizeGraphPersistsVerifiedDissent(t *testing.T) {
t.Fatalf("unexpected runtime synthesis: conflict=%+v synthesis=%+v stored=%+v err=%v", conflict, synthesis, store.conflict, err)
}
}
func TestGraphSynthesisJSONUsesStableSnakeCaseContract(t *testing.T) {
payload, err := json.Marshal(application.GraphSynthesisRequest{Conflict: work.ConflictSet{ID: "c", GraphID: "g", GraphRevision: 1, NodeID: "n", CandidateIDs: []string{"a", "b"}}, SelectedCandidate: "a", VerifierRunID: "v", VerifierIdentity: "independent", EvidenceRefs: []work.EvidenceRef{"e"}, Summary: "s", Verified: true})
if err != nil || !strings.Contains(string(payload), `"graph_id":"g"`) || !strings.Contains(string(payload), `"selected_candidate_id":"a"`) {
t.Fatalf("unexpected synthesis JSON: %s err=%v", payload, err)
}
var decoded application.GraphSynthesisRequest
if err := json.Unmarshal(payload, &decoded); err != nil || decoded.Conflict.GraphID != "g" || decoded.SelectedCandidate != "a" || !decoded.Verified {
t.Fatalf("snake_case request did not round-trip: %+v err=%v", decoded, err)
}
}