modelsync

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2026 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package modelsync is what `sysml -sync` and the REPL's repository commands share above reposync: reading a model as the graph a sync compares, cutting the graph rooted in one element, stamping a graph with the project branch it came from so its notation declares a ProjectRef, and applying a change set while advancing the sync state. Neither client diffs or applies on its own.

Index

Constants

This section is empty.

Variables

View Source
var ErrAmbiguousName = errors.New("ambiguous project name")

ErrAmbiguousName is a name several projects share.

Functions

func Baseline

func Baseline(ctx context.Context, repo Repository, state *reposync.State) (*rdf.Graph, error)

Baseline reads the repository as the state's last-seen commit left it: the graph a diff tells repository changes since then apart against. Nil when the state names no commit.

func Notation

func Notation(graph *rdf.Graph, warn func(string)) ([]byte, error)

Notation writes a graph as SysML notation, each warning the writer raises passed to warn.

func Rooted

func Rooted(graph *rdf.Graph, qualifiedName string) (*rdf.Graph, error)

Rooted cuts the graph down to the element of the given qualified name and everything it owns, directly or through its relationships. The element becomes a root: the triples tying it to its own owner are dropped, as a project's root element has none. Elements the cut references but does not own stay references.

func RootedAt

func RootedAt(graph *rdf.Graph, root rdf.Term) *rdf.Graph

RootedAt is Rooted at a given element. An element the graph does not hold cuts to an empty graph.

func Roots

func Roots(graph *rdf.Graph) []rdf.Term

Roots lists the elements the graph declares and nothing in it owns, in the graph's subject order: the elements a document's namespace would hold.

func Scoped

func Scoped(graph *rdf.Graph, scope reposync.Scope) *rdf.Graph

Scoped returns graph with scope stamped on every root element — each element of the graph that nothing in it owns and that is not a library reference — in place of any scope it carried, so the notation written from it declares the ProjectRef a later sync finds the branch by.

func WithoutDerived

func WithoutDerived(graph *rdf.Graph) *rdf.Graph

WithoutDerived returns graph without the sysml: properties the metamodel derives on each subject's metaclass, readerDerived aside: what a publish without derived properties sends. The pilot's sends none of them; this writer's reader needs most, so only the ones it recomputes are left out.

Types

type AmbiguousNameError

type AmbiguousNameError struct {
	Name string
	IDs  []string
}

AmbiguousNameError names the projects that share one name, so the caller can pick one by id.

func (*AmbiguousNameError) Error

func (e *AmbiguousNameError) Error() string

func (*AmbiguousNameError) Is

func (e *AmbiguousNameError) Is(target error) bool

type Applied

type Applied struct {
	Commit                    string
	Created, Updated, Deleted int
	Result                    *reposync.Result
}

Applied is what one apply left behind: the commit it ended on and how many changes of each kind landed. Commit is empty when the repository already agreed with the model.

func Apply

func Apply(ctx context.Context, repo Repository, set *reposync.ChangeSet, state *reposync.State, message string) (*Applied, error)

Apply writes an appliable change set and advances the state: to the last commit written, or, when nothing needed writing, to the head the repository was read at. A partial apply returns the result with the error.

type NotFoundError

type NotFoundError struct {
	QualifiedName string
}

NotFoundError is a qualified name no element of the graph carries.

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

type Repository

type Repository interface {
	reposync.Committer
	// Head is the branch's current head commit, empty for a branch no commit
	// has reached yet.
	Head(ctx context.Context) (string, error)
	// Seen is the head the last read stood at or the last commit written.
	Seen() string
	// Resume records the last-seen commit a saved state carries.
	Resume(commit string)
	// Graph reads the branch at its head.
	Graph(ctx context.Context) (*rdf.Graph, error)
	// GraphAt reads the branch as one commit left it.
	GraphAt(ctx context.Context, commit string) (*rdf.Graph, error)
}

Repository is a project branch a sync reads and writes: the surface sysmlapi.Repository and flexo.Repository both offer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL