Documentation
¶
Overview ¶
Package conflict is the FHIR-aware conflict policy library for HAIStack. It detects conflicts, classifies clinical risk, and produces FHIR Patch-based merge or rebase artifacts while keeping sync transport concerns outside.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChangeKind ¶
type ChangeKind string
ChangeKind describes the nature of a change at a FHIR element path.
const ( ChangeKindScalarReplace ChangeKind = "scalar_replace" ChangeKindArrayAppend ChangeKind = "array_append" ChangeKindArrayRemove ChangeKind = "array_remove" ChangeKindStructural ChangeKind = "structural" ChangeKindUnsupported ChangeKind = "unsupported" )
type Classification ¶
type Classification string
Classification is the conflict bucket assigned to a detect result.
const ( ClassificationNoConflict Classification = "no_conflict" ClassificationStaleBaseOnly Classification = "stale_base_only" ClassificationSameResourceNonOverlap Classification = "same_resource_non_overlapping_update" ClassificationSameResourceOverlap Classification = "same_resource_overlapping_update" ClassificationAppendOnlyCompatible Classification = "append_only_compatible" ClassificationClinicallySensitive Classification = "clinically_sensitive_conflict" ClassificationUnsupportedMerge Classification = "unsupported_merge_shape" )
type Config ¶
type Config struct {
Registry *PolicyRegistry
Clock func() time.Time
}
Config wires optional policy and clock into the engine.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is the high-level conflict detection and merge entrypoint.
func NewDefaultEngine ¶
func NewDefaultEngine() *Engine
NewDefaultEngine builds an engine with the built-in default policy.
func (*Engine) CanAutoMerge ¶
CanAutoMerge reports whether a detected conflict can be merged automatically.
func (*Engine) Detect ¶
func (e *Engine) Detect(local LocalEvent, base, current *types.ResourceEnvelope) Result
Detect evaluates a local sync event against the base and current resource states.
func (*Engine) Merge ¶
func (e *Engine) Merge(local LocalEvent, base, current *types.ResourceEnvelope) MergeResult
Merge produces a merged resource and FHIR Patch when the conflict is auto-mergeable.
type LocalEvent ¶
type LocalEvent struct {
EventID string
ResourceType string
ResourceID string
Operation string
BaseCloudVersion string
LocalVersion string
ChangedPaths []string
Patch []byte
ResourceAfter *types.ResourceEnvelope
ResourceHash string
}
LocalEvent is the mutation shape the conflict engine accepts. It mirrors sync.LocalEvent so the package can be used without importing sync.
type MergeResult ¶
type MergeResult struct {
Result Result
AutoMergeable bool
Merged *types.ResourceEnvelope
Patch []byte
Resolution Classification
Review ReviewMetadata
}
MergeResult is the output of a successful or blocked merge attempt.
type Operation ¶
type Operation struct {
Op string `json:"op"`
Path string `json:"path"`
Value any `json:"value,omitempty"`
}
Operation is one FHIR Patch (JSON Patch) operation.
type PathChange ¶
type PathChange struct {
Path []string
Kind ChangeKind
Base any
Value any
Appended []any
Removed []any
}
PathChange records one detected change between two resource snapshots.
func (PathChange) Dotted ¶
func (c PathChange) Dotted(resourceType string) string
Dotted returns the FHIR-style dotted path including the resource type.
type PolicyRegistry ¶
type PolicyRegistry struct {
// contains filtered or unexported fields
}
PolicyRegistry holds rule packs and resolves the active pack for a path.
func DefaultPolicyRegistry ¶
func DefaultPolicyRegistry() *PolicyRegistry
DefaultPolicyRegistry returns a registry with the built-in strict safe-list pack.
func (*PolicyRegistry) Match ¶
func (r *PolicyRegistry) Match(resourceType, path string) *Rule
Match returns the first rule whose resource type and path prefix match.
func (*PolicyRegistry) Register ¶
func (r *PolicyRegistry) Register(pack RulePack)
Register adds a rule pack to the registry. Registering the same name replaces it.
func (*PolicyRegistry) Select ¶
func (r *PolicyRegistry) Select(name string)
Select chooses the active rule pack by name.
type Result ¶
type Result struct {
Classification Classification
Risk RiskLevel
AutoMergeable bool
LocalChanges []PathChange
RemoteChanges []PathChange
OverlappingPaths []string
ReviewReason string
}
Result captures the classification and mergeability of a conflict.
type ReviewMetadata ¶
type ReviewMetadata struct {
Reason string
LocalPathSummary []string
RemotePathSummary []string
OverlapPaths []string
UILabels map[string]string
}
ReviewMetadata is the UI-facing summary for non-auto-mergeable conflicts.
type Rule ¶
type Rule struct {
ResourceType string
PathPrefix string
Semantics RuleSemantics
Description string
}
Rule is one resource/path-specific merge policy.
type RulePack ¶
RulePack is a named collection of rules. Packs can be registered in a PolicyRegistry and selected per engine configuration.
func DefaultRulePack ¶
func DefaultRulePack() RulePack
DefaultRulePack returns the built-in v1 strict safe-list policy.
type RuleSemantics ¶
type RuleSemantics string
RuleSemantics describes how a rule treats changes at a matched path.
const ( RuleSemanticsAutoMerge RuleSemantics = "auto_merge" RuleSemanticsAppendOnly RuleSemantics = "append_only" RuleSemanticsReviewOnly RuleSemantics = "review_only" RuleSemanticsBlock RuleSemantics = "block" )