Documentation
¶
Overview ¶
Package reposync diffs a local model's identity-carrying RDF graph against a repository-side graph of the same project scope, keyed by effective element id, so a rename or a move is an update to the existing element rather than a delete plus a create.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrTwoBranches = errors.New("one document cannot sync against two branches at once")
ErrTwoBranches reports elements of one document naming two branches at once: a branch selects one version, so one sync reads from exactly one.
Functions ¶
func MintUUID ¶
MintUUID returns a random RFC 4122 version 4 UUID, the id minted for an element that needs addressing but declares none.
func StatePath ¶
StatePath is the default state file for a model: its path with .sync.json appended, so two models beside each other keep separate sync state.
func WriteBack ¶
WriteBack rewrites a local graph so each minted element declares its minted id: subjects and references move to the minted IRI, satellites re-derive, and the declaredId marker is set so converting the graph back to notation re-materializes the @ElementId annotation. It never runs implicitly: the caller asked to write annotations back into the model.
Types ¶
type Change ¶
type Change struct {
Kind Kind
ID string // effective id: the subject IRI's local name
Subject string // full subject IRI
QualifiedName string
Metaclass string
Declared bool // the id was declared by an @ElementId annotation
MintedID string // UUID minted for an unannotated create, when minting is on
Deltas []PropertyDelta
Conflict ConflictKind
// RequiresConfirmation marks a delete the options did not confirm.
RequiresConfirmation bool
}
Change is one entry of a change set, keyed by the subject's effective id.
type ChangeSet ¶
ChangeSet is what a diff produced for one project scope.
func Diff ¶
Diff compares the local graph against the repository graph of the same project scope and returns the change set keyed by effective element id.
func (*ChangeSet) Appliable ¶
Appliable reports whether the set can be applied as computed: conflicts and unconfirmed deletes refuse an apply until a person decides them.
func (*ChangeSet) Mints ¶
Mints returns the minted ids of a change set, keyed by the derived id each one replaces.
func (*ChangeSet) Text ¶
Text renders the change set for a dry run: one line per entry, deltas indented under updates and conflicts, and a closing summary.
func (*ChangeSet) UnconfirmedDeletes ¶
UnconfirmedDeletes counts the deletes the options did not confirm.
type ConflictKind ¶
type ConflictKind string
ConflictKind says what a conflict entry disagrees about.
const ( // ConflictMissingID: the annotation names an id the repository branch no // longer has. ConflictMissingID ConflictKind = "missing-id" // ConflictRepositoryChanged: the repository element changed since the // last-seen commit, so writing over it would lose someone else's change. ConflictRepositoryChanged ConflictKind = "repository-changed" )
type Kind ¶
type Kind string
Kind classifies one entry of a change set.
const ( // KindCreate is an element the repository does not have yet. KindCreate Kind = "create" // KindUpdate is an element both sides have, with differing properties. KindUpdate Kind = "update" // KindDelete is an element only the repository has. Applying it needs // explicit confirmation; the diff reports it either way. KindDelete Kind = "delete" // KindConflict is a disagreement the sync must not resolve on its own. KindConflict Kind = "conflict" )
type Options ¶
type Options struct {
// Base is the repository graph at the last-seen commit. With it, an element
// the repository changed since then surfaces as a conflict rather than
// being written over, and a declared id the branch never had is a create
// rather than a missing-id conflict.
Base *rdf.Graph
// ConfirmDeletes confirms repository-side deletes; off, the diff still
// reports them but Appliable refuses.
ConfirmDeletes bool
// MintIDs mints a UUID for each unannotated element being created, so the
// repository can address it stably.
MintIDs bool
// NewID overrides the UUID source, for deterministic tests.
NewID func() (string, error)
}
Options steer a diff. Deletes and id minting are explicit opt-ins; neither ever happens silently.
type PropertyDelta ¶
PropertyDelta is one property whose values differ between the two sides.
type Scope ¶
Scope is the project a graph belongs to. Org and project identify it; branch selects the version being synced against, not a different identity space.
func GraphScope ¶
GraphScope reads a graph's provenance triples into the single scope it syncs under. Two projects or two branches in one graph is an error, never a guess.
type State ¶
type State struct {
Org string `json:"org,omitempty"`
ProjectID string `json:"projectId"`
Branch string `json:"branch,omitempty"`
LastSeenCommit string `json:"lastSeenCommit,omitempty"`
}
State is the sync tool's record of what a sync last saw. Commit ids are tool state, never model content: they live in this JSON file — <model>.sync.json beside the model by default — and are never written into the notation.
func LoadState ¶
LoadState reads a state file, returning nil without error when the file does not exist yet: a first sync has no last-seen commit.