Documentation
¶
Index ¶
- Constants
- func Acknowledgement(from, to, knownAs, targetShape string) string
- func SamePlan(expected string, fresh Preview) bool
- func ScopeKey(cred *models.DriverCredentials) string
- func ShapeOf(fromRel, toRel string) string
- func SnapshotDrift(expected []DatabaseSnapshot, fresh DatabaseSnapshot) error
- func StorageChanging(fromRel, toRel, targetFrom, targetTo string) bool
- func WithExpectedSnapshots(ctx context.Context, snaps []DatabaseSnapshot) context.Context
- type Counts
- type DatabaseSnapshot
- type Pair
- type Preview
- type Receipt
- type Request
Constants ¶
const ( ShapeOneToOne = "1:1" ShapeOneToMany = "1:N" ShapeManyToOne = "N:1" ShapeManyToMany = "N:N" ShapeUnknown = "unknown" )
const ( KindNoOp = "no_op" KindWidenToNN = "widen_to_nn" KindNarrowFromNN = "narrow_from_nn" KindNarrowTo11 = "narrow_to_11" KindOwnershipFlip = "ownership_flip" KindOneToOneToFK = "one_to_one_to_fk" KindUnknown = "unknown" )
const ( SafetyLosslessWidening = "lossless_widening" SafetyConditionalNarrowing = "conditional_narrowing" SafetyOwnershipFlip = "ownership_flip" SafetyBlocked = "blocked" SafetyNoOp = "no_op" SafetyUnsupported = "unsupported_driver" )
const ( RevNow = "reversible_now" RevConditional = "conditionally_reversible" RevNotBySchema = "not_reversible_by_schema" RevBlocked = "blocked" )
const ( CapabilitySQL = "sql" CapabilityMetadataOnly = "metadata_only" CapabilityUnsupported = "unsupported_driver" )
const ConflictPolicyAbort = "abort"
ConflictPolicyAbort is the only version-one conflict policy. The engine never keeps an arbitrary link when several cannot fit.
Variables ¶
This section is empty.
Functions ¶
func Acknowledgement ¶
Acknowledgement is the exact string Console and MCP must send back.
func ScopeKey ¶
func ScopeKey(cred *models.DriverCredentials) string
ScopeKey identifies a database without including secrets.
func ShapeOf ¶
ShapeOf classifies one directed endpoint pair. 1:N means from has_many and to has_one, so the FK lives on to.
func SnapshotDrift ¶
func SnapshotDrift(expected []DatabaseSnapshot, fresh DatabaseSnapshot) error
SnapshotDrift reports when a fresh database preflight no longer matches the staged plan.
func StorageChanging ¶
StorageChanging reports whether the two shapes use different physical link storage.
func WithExpectedSnapshots ¶
func WithExpectedSnapshots(ctx context.Context, snaps []DatabaseSnapshot) context.Context
WithExpectedSnapshots attaches the staged per-database preflight to a publish context.
Types ¶
type Counts ¶
type Counts struct {
SourcePairs int `json:"source_pairs"`
ValidPairs int `json:"valid_pairs"`
Dangling int `json:"dangling"`
Conflicts int `json:"conflicts"`
Contradictory int `json:"contradictory"`
ProjectedDestination int `json:"projected_destination"`
}
Counts are decisive preflight numbers for one database.
type DatabaseSnapshot ¶
type DatabaseSnapshot struct {
ScopeKey string `json:"scope_key"`
Capability string `json:"capability,omitempty"`
Counts Counts `json:"counts"`
Blocked bool `json:"blocked"`
Error string `json:"error,omitempty"`
}
DatabaseSnapshot is one physical database's preflight. ScopeKey is stable for that database (file path or host/database/schema), never a secret.
func ExpectedSnapshots ¶
func ExpectedSnapshots(ctx context.Context) []DatabaseSnapshot
ExpectedSnapshots returns the staged preflight, if the publish worker set one.
type Preview ¶
type Preview struct {
PlanHash string `json:"plan_hash"`
TransitionKind string `json:"transition_kind"`
SafetyClass string `json:"safety_class"`
Reversibility string `json:"reversibility"`
InversePassesNow bool `json:"inverse_passes_now"`
SourceShape string `json:"source_shape"`
TargetShape string `json:"target_shape"`
SourceStorage string `json:"source_storage"`
TargetStorage string `json:"target_storage"`
Steps []string `json:"steps,omitempty"`
SourcePairs int `json:"source_pairs"`
ValidPairs int `json:"valid_pairs"`
Dangling int `json:"dangling"`
Conflicts int `json:"conflicts"`
Contradictory int `json:"contradictory"`
ProjectedDestination int `json:"projected_destination"`
AffectedDatabases int `json:"affected_databases"`
Warnings []string `json:"warnings,omitempty"`
Blockers []string `json:"blockers,omitempty"`
Disclaimers []string `json:"disclaimers,omitempty"`
ConflictReport []string `json:"conflict_report,omitempty"`
BackupRequired bool `json:"backup_required"`
CodegenImpact bool `json:"codegen_impact"`
RequiresTypedConfirmation bool `json:"requires_typed_confirmation"`
RequiredAcknowledgement string `json:"required_acknowledgement"`
Blocked bool `json:"blocked"`
ConflictPolicy string `json:"conflict_policy"`
ExecutionActions []string `json:"execution_actions,omitempty"`
Capability string `json:"capability,omitempty"`
Databases []DatabaseSnapshot `json:"databases,omitempty"`
}
Preview is the shared Console and MCP contract.
func BuildPreview ¶
func BuildPreview(req Request, sourceStorage, targetStorage string, snaps []DatabaseSnapshot) Preview
BuildPreview folds shape rules and per-database counts into the shared contract. It does not touch a database.
func MetadataOnlyPreview ¶
MetadataOnlyPreview is for drivers whose relation storage does not change with cardinality.
func UnsupportedPreview ¶
UnsupportedPreview blocks the transition instead of pretending SQL ran.
type Receipt ¶
type Receipt struct {
ScopeKey string `json:"scope_key,omitempty"`
Status string `json:"status"`
SourcePairs int `json:"source_pairs"`
CopiedPairs int `json:"copied_pairs"`
DestinationPairs int `json:"destination_pairs"`
Dangling int `json:"dangling"`
Conflicts int `json:"conflicts"`
Dropped []string `json:"dropped,omitempty"`
Error string `json:"error,omitempty"`
Idempotent bool `json:"idempotent,omitempty"`
}
Receipt is persisted per database after a physical attempt.
type Request ¶
type Request struct {
ProjectID string `json:"project_id,omitempty"`
SchemaVersion int `json:"schema_version,omitempty"`
FromModel string `json:"from_model"`
ToModel string `json:"to_model"`
KnownAs string `json:"known_as,omitempty"`
FromRelation string `json:"from_relation"`
ToRelation string `json:"to_relation"`
TargetFromRelation string `json:"target_from_relation"`
TargetToRelation string `json:"target_to_relation"`
ConflictPolicy string `json:"conflict_policy"`
AffectedDatabases int `json:"affected_databases,omitempty"`
}
Request is one directed cardinality change for a single edge.
func (Request) CurrentConnections ¶
func (r Request) CurrentConnections() (from, to *models.ConnectionType)
Connections builds the forward/backward connection pair the SQL drivers already use.
func (*Request) Normalized ¶
func (Request) TargetConnections ¶
func (r Request) TargetConnections() (from, to *models.ConnectionType)