DRY fix: Shared types (SynthesisInput, ExtractedEntity, ExtractedFact, ContradictionResult, PersistInput) moved to pkg/types/synthesis.go. Both workflow and activity packages now import from pkg/types. Re-exported as type aliases for backward compatibility. Fixes: Duplicate type definitions between workflow and activity packages.
This commit is contained in:
@@ -0,0 +1,59 @@
|
|||||||
|
package types
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
// SynthesisInput contains the input for the synthesis workflow.
|
||||||
|
type SynthesisInput struct {
|
||||||
|
Project string `json:"project"`
|
||||||
|
Source string `json:"source"`
|
||||||
|
Text string `json:"text"`
|
||||||
|
Kind string `json:"kind"` // L1, L2, reference
|
||||||
|
Tags []string `json:"tags,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SynthesisResult contains the output of the synthesis workflow.
|
||||||
|
type SynthesisResult struct {
|
||||||
|
ChunkID string `json:"chunk_id"`
|
||||||
|
EntitiesExtracted int `json:"entities_extracted"`
|
||||||
|
FactsExtracted int `json:"facts_extracted"`
|
||||||
|
Contradictions int `json:"contradictions"`
|
||||||
|
ReviewQueued int `json:"review_queued"`
|
||||||
|
Entities []ExtractedEntity `json:"entities"`
|
||||||
|
Facts []ExtractedFact `json:"facts"`
|
||||||
|
Duration time.Duration `json:"duration"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExtractedEntity represents an entity found during synthesis.
|
||||||
|
type ExtractedEntity struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
EntityType string `json:"entity_type"`
|
||||||
|
Confidence float64 `json:"confidence"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExtractedFact represents a fact extracted during synthesis.
|
||||||
|
type ExtractedFact struct {
|
||||||
|
Subject string `json:"subject"`
|
||||||
|
Predicate string `json:"predicate"`
|
||||||
|
Object string `json:"object"`
|
||||||
|
Confidence float64 `json:"confidence"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContradictionResult represents a contradiction detection result.
|
||||||
|
type ContradictionResult struct {
|
||||||
|
FactA ExtractedFact `json:"fact_a"`
|
||||||
|
FactB ExtractedFact `json:"fact_b"`
|
||||||
|
Severity string `json:"severity"` // low, medium, high
|
||||||
|
AutoResolved bool `json:"auto_resolved"`
|
||||||
|
QueuedReview bool `json:"queued_review"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// PersistInput groups all synthesis results for persistence.
|
||||||
|
type PersistInput struct {
|
||||||
|
ChunkID string `json:"chunk_id"`
|
||||||
|
Project string `json:"project"`
|
||||||
|
Source string `json:"source"`
|
||||||
|
Kind string `json:"kind"`
|
||||||
|
Entities []ExtractedEntity `json:"entities"`
|
||||||
|
Facts []ExtractedFact `json:"facts"`
|
||||||
|
Contradictions []ContradictionResult `json:"contradictions"`
|
||||||
|
}
|
||||||
+8
-44
@@ -6,52 +6,16 @@ import (
|
|||||||
|
|
||||||
"go.temporal.io/sdk/temporal"
|
"go.temporal.io/sdk/temporal"
|
||||||
"go.temporal.io/sdk/workflow"
|
"go.temporal.io/sdk/workflow"
|
||||||
|
"github.com/rockliang/poimen/workflows/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SynthesisInput contains the input for the synthesis workflow.
|
// Re-export shared types from pkg/types for backward compatibility
|
||||||
type SynthesisInput struct {
|
type SynthesisInput = types.SynthesisInput
|
||||||
Project string `json:"project"`
|
type SynthesisResult = types.SynthesisResult
|
||||||
Source string `json:"source"`
|
type ExtractedEntity = types.ExtractedEntity
|
||||||
Text string `json:"text"`
|
type ExtractedFact = types.ExtractedFact
|
||||||
Kind string `json:"kind"` // L1, L2, reference
|
type ContradictionResult = types.ContradictionResult
|
||||||
Tags []string `json:"tags,omitempty"`
|
type PersistInput = types.PersistInput
|
||||||
}
|
|
||||||
|
|
||||||
// SynthesisResult contains the output of the synthesis workflow.
|
|
||||||
type SynthesisResult struct {
|
|
||||||
ChunkID string `json:"chunk_id"`
|
|
||||||
EntitiesExtracted int `json:"entities_extracted"`
|
|
||||||
FactsExtracted int `json:"facts_extracted"`
|
|
||||||
Contradictions int `json:"contradictions"`
|
|
||||||
ReviewQueued int `json:"review_queued"`
|
|
||||||
Entities []ExtractedEntity `json:"entities"`
|
|
||||||
Facts []ExtractedFact `json:"facts"`
|
|
||||||
Duration time.Duration `json:"duration"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// ExtractedEntity represents an entity found during synthesis.
|
|
||||||
type ExtractedEntity struct {
|
|
||||||
Name string `json:"name"`
|
|
||||||
EntityType string `json:"entity_type"`
|
|
||||||
Confidence float64 `json:"confidence"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// ExtractedFact represents a fact extracted during synthesis.
|
|
||||||
type ExtractedFact struct {
|
|
||||||
Subject string `json:"subject"`
|
|
||||||
Predicate string `json:"predicate"`
|
|
||||||
Object string `json:"object"`
|
|
||||||
Confidence float64 `json:"confidence"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// ContradictionResult represents a contradiction detection result.
|
|
||||||
type ContradictionResult struct {
|
|
||||||
FactA ExtractedFact `json:"fact_a"`
|
|
||||||
FactB ExtractedFact `json:"fact_b"`
|
|
||||||
Severity string `json:"severity"` // low, medium, high
|
|
||||||
AutoResolved bool `json:"auto_resolved"`
|
|
||||||
QueuedReview bool `json:"queued_review"`
|
|
||||||
}
|
|
||||||
|
|
||||||
var synthesisActivityOptions = workflow.ActivityOptions{
|
var synthesisActivityOptions = workflow.ActivityOptions{
|
||||||
StartToCloseTimeout: 60 * time.Second,
|
StartToCloseTimeout: 60 * time.Second,
|
||||||
|
|||||||
Reference in New Issue
Block a user