Documentation
¶
Overview ¶
Package flexo drives a running Flexo MMS stack — the Layer 1 service and the SysML v2 API in front of it — so the RDF this project writes can be measured against what that service can actually read back. It is a test-support package: nothing in the compiler, the REPL or the LSP depends on it.
The stack is external and opt-in; see .agents/skills/flexo-interop for how to bring it up and what the gate reports.
Index ¶
- Constants
- func Status(err error) int
- type Client
- func (c *Client) Commits(ctx context.Context, project string) ([]Commit, error)
- func (c *Client) Config() Config
- func (c *Client) CreateProject(ctx context.Context, id, name, branch string) (Project, error)
- func (c *Client) ElementByID(ctx context.Context, project, commit, id string) (Element, error)
- func (c *Client) Elements(ctx context.Context, project, commit string, pageSize int) (Listing, error)
- func (c *Client) EnsureOrg(ctx context.Context) error
- func (c *Client) LoadTurtle(ctx context.Context, project, branch string, turtle []byte, message string) error
- func (c *Client) PostChanges(ctx context.Context, project string, changes []byte) error
- func (c *Client) Reachable(ctx context.Context) error
- func (c *Client) Roots(ctx context.Context, project, commit string) ([]Element, error)
- type Commit
- type Config
- type Element
- type ElementStat
- type GraphStats
- type Listing
- type Project
- type PropertyStat
- type Report
- type SideReport
Constants ¶
const ( EnvGate = "FLEXO_INTEROP" EnvLayer1URL = "FLEXO_LAYER1_URL" EnvSysMLV2URL = "FLEXO_SYSMLV2_URL" EnvToken = "FLEXO_INTEROP_TOKEN" // #nosec G101 -- a variable name, not a credential EnvOrg = "FLEXO_SYSMLV2_ORG" )
Environment variables read by ConfigFromEnv. FLEXO_INTEROP is the gate: the live test skips unless it is set, exactly as the corpus gates skip on an absent corpus.
const ( DefaultLayer1URL = "http://localhost:8080" DefaultSysMLV2URL = "http://localhost:8083" DefaultOrg = "sysmlv2" )
Defaults matching flexo-mms-sysmlv2/docker-compose/docker-compose.yml, so a stack brought up from that file needs no configuration beyond the token.
const BranchID = "main"
BranchID is the default branch the harness asks for when it creates a project, so the graph endpoint's path is known rather than generated.
const PageSize = 10
PageSize is the page the harness asks the element listing for. It is smaller than the fixture, so a service that pages answers in more than one response.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to one stack. It is safe for sequential use by one test.
func (*Client) Commits ¶
Commits lists a project's commits, newest first as the service returns them.
func (*Client) CreateProject ¶
CreateProject creates a project through the SysML v2 API, which also creates its default branch and the queries scratch. The id doubles as the Layer 1 repo id, so it must satisfy the service's id rules; the default branch is named rather than left to the service, which would otherwise mint a uuid the graph endpoint's path needs.
func (*Client) ElementByID ¶
ElementByID reads one element directly. A non-2xx answer is returned as the error, with Status(err) carrying the code: a rejected id is a finding, not a harness failure.
func (*Client) Elements ¶
func (c *Client) Elements(ctx context.Context, project, commit string, pageSize int) (Listing, error)
Elements reads a commit's elements a page at a time. A page that overruns pageSize or repeats an element is a service ignoring paging; the repeat is dropped rather than counted twice.
func (*Client) EnsureOrg ¶
EnsureOrg creates the Layer 1 org the SysML v2 service keeps its projects under. A freshly initialized cluster does not have it, and every project creation fails until it does.
func (*Client) LoadTurtle ¶
func (c *Client) LoadTurtle(ctx context.Context, project, branch string, turtle []byte, message string) error
LoadTurtle replaces a branch's model graph with the given Turtle through Layer 1's Graph Store Protocol endpoint. ModelLoad.kt requires a precondition on the branch etag: If-Match with the current etag, or If-Match * to accept whatever is there.
func (*Client) PostChanges ¶
PostChanges commits SysML v2 JSON changes through the service's own commit path, which is the ground truth the loaded graph is compared against.
type Config ¶
type Config struct {
Layer1URL string // Layer 1 service, which owns orgs, repos, branches and graphs
SysMLV2URL string // SysML v2 API, which owns projects, commits and elements
Token string // bearer token accepted by both services
Org string // Layer 1 org the SysML v2 service keeps its projects under
Timeout time.Duration
}
Config addresses one running stack.
func ConfigFromEnv ¶
ConfigFromEnv reads the stack's addresses from the environment, defaulting to the published compose file's ports. The token has no default: it is a credential and is never written to the repository.
type Element ¶
type Element map[string]json.RawMessage
Element is one element as the SysML v2 API delivers it: property name to raw JSON value, kept raw so a value's shape — reference, literal, array — is observable rather than normalized away by decoding into a Go type.
type ElementStat ¶
type ElementStat struct {
ID string
Type string // metaclass as written
Listed bool // the paged element listing returned it
Direct string // "ok", or "rejected(400)" / "absent(404)" for a direct read
Written int // properties written for it, rdf:type excluded
Delivered int // properties returned for it, @type excluded
Lost []string // written properties the read path did not return
Shape []string // "sysml:type: reference written, string delivered"
}
ElementStat is one element's fate: whether the paged listing saw it, whether it can be read directly, and which of its properties came back.
type GraphStats ¶
type GraphStats struct {
Subjects int
Triples int
Bytes int
ByNamespace []PropertyStat // one entry per prefix, Written holding its triple count
}
GraphStats describes the Turtle this project produced, before any service saw it: the denominator of the measurement.
type Listing ¶
Listing is one element listing: the elements it delivered, the number of responses it took, and whether the service ignored the paging parameters.
type PropertyStat ¶
type PropertyStat struct {
Property string // "sysml:declaredName" written, "declaredName" delivered
Written int // elements that carried it
Delivered int // elements that returned it
MultiValued int // elements that carried more than one value for it
MultiDelivered int // of those, the elements that returned it
}
PropertyStat is one predicate's fate across a whole side of the measurement: how many elements carried it, and on how many it came back.
type Report ¶
type Report struct {
Fixture string
Graph GraphStats
Load SideReport
Reference SideReport
Findings []string
}
Report is a whole run.
func Measure ¶
func Measure(ctx context.Context, c *Client, fixture string, model, reference []byte) (*Report, error)
Measure loads model into the stack as Turtle and as JSON changes, reads both back, and reports what each side delivered. The reference argument is the JSON commit request; only its "change" array is posted.
type SideReport ¶
type SideReport struct {
Name string // "graph-load" or "json-commit"
Accepted bool // the service took the payload
Commits int // commits the project has after the write
Written int // elements in the payload
Listed int // written elements the listing returned
Extra int // elements the listing returned that were not written
Pages int // responses the listing took, at the harness page size
IgnoredPaging bool // the listing repeated or overran what the page size asked for
Direct int // elements a direct read returned
Roots int // elements the roots endpoint returned
RootsInModel int // elements the payload itself gives no owner
Elements []ElementStat
Properties []PropertyStat
}
SideReport is one direction of the comparison: the graph this project loads, or the same model committed through the service's own JSON path.