Projects and Workspaces
Two Questions That Sound Alike
In Chapter 4, you organized model elements into packages and made names visible across package boundaries with import. In Chapter 14, you saw that a large share of the language’s meaning lives in standard libraries your model draws on. Both chapters kept quiet about a practical question: when you write private import BeverageTypes::*, how does a tool know where BeverageTypes lives – which file, which directory, which version?
The honest answer is that these are two different questions, and only one of them belongs to SysML v2.
- “What does this name mean here?” is a language question. KerML defines name resolution precisely: resolution starts in the local namespace and searches outward through containing namespaces (KerML §7.2.5.1), and
importmakes another namespace’s visible members available under shorter names (KerML §7.2.5.4). Every conformant tool must answer this question the same way. - “Which files and projects should be loaded so those names exist at all?” is a tooling question. The specification defines resolution over the elements a tool has loaded; it does not say how the tool decides what to load. Manifests, dependency declarations, version pins, lock files, and workspace layouts are each tool’s own answer, and they differ between tools.
Keep the two apart and this chapter is short. An import is part of your model and travels with it. A dependency declaration is part of your project setup and does not.
import Is Language; a Dependency Is Not
Here is the boundary in one example. The model side is SysML v2 and means the same thing in every conformant tool:
package BeverageTypes {
item def Water;
item def CoffeeBeans;
}
package CoffeeParts {
private import BeverageTypes::*;
part def WaterTank {
item water : Water;
}
}
The import says: inside CoffeeParts, the visible members of BeverageTypes may be used by their unqualified names. It says nothing about disk layout. BeverageTypes could be in the same file, another file, another project, or an archive fetched from a server – the import is equally correct in all four cases, and equally meaningless if no loaded element provides the name.
The project side is about which inputs OpenSysML loads. In the beverage workspace the library and its consumer are separate files. From the edition root:
sysml -strict -validate src/examples/beverage-workspace/beverage-types/src/types.sysml src/examples/beverage-workspace/coffee-machine/src/parts.sysml
Loading the consumer alone does not make the other project’s declarations available. Loading the two directories instead of the two files is another way to supply the same model elements. The text in the import stays the same.
The practical rule: if removing a line changes what your model means, it is language. If removing it changes what your tool can find, it is tooling.
Projects, Commits, and Interchange
The language stops at name resolution, but OMG does standardize two things above the level of a single file, and both are worth knowing at concept level.
Projects and commits. The SysML v2 specification suite includes a standard API for model repositories, organized around a small set of concepts: a project is a top-level container for a model, a branch is a named line of development within it, and a commit is an immutable snapshot of the model at a point in time. These are interchange notions – they let two tools talk about “the same model at the same version” without sharing an implementation. Appendix C covers the API surface itself.
Interchange artifacts. As Chapter 1 noted, model interchange is normative: a project travels as a .kpar archive, and the textual files inside it use the .sysml extension. A .kpar bundles model files with .project.json (project identity and dependencies) and .meta.json (archive metadata, including the model index). These are artifacts tools produce and consume so that models can cross tool boundaries; in day-to-day modelling you author .sysml files and let your toolchain generate the interchange form when you publish.
That is the whole standardized story: names resolve by KerML’s rules, projects and commits identify model versions, and .kpar carries a project between tools. Everything else – how dependencies are declared, how versions are pinned and cached, how several projects are grouped into a workspace – is toolchain territory.
Working with projects in OpenSysML
For this book the workspace is simply the set of input files. OpenSysML accepts a directory and walks it; it loads the named sources together before resolving names. Do not pass the whole book: independent exercises deliberately reuse package names. To share the coffee machine, share src/examples/coffee-machine/; -library-root is for locating installed dependency projects, not importing an arbitrary sibling package into scope.
For project interchange, use KerML project metadata and .kpar, not a tool-specific workspace manifest. OpenSysML’s -bundle takes a project directory, -o selects the archive and -unbundle restores a project to a new or empty directory. Try the beverage project in a new scratch directory:
out=$(mktemp -d)
sysml -bundle src/examples/beverage-workspace -o "$out/beverage.kpar"
sysml -unbundle "$out/beverage.kpar" -o "$out/restored"
sysml -strict -validate "$out/restored"
OpenSysML generates archive metadata when the source directory does not supply it. A repository commit, a package namespace and a directory are distinct: changing the way you load the files need not change a single model name.
What travels and what does not
A public import still re-exports the same members in a receiving tool. A local dependency search path does not travel inside that declaration. Pin the exact model and library releases along with the command used to check them. Chapter 16 uses the same project for several different runs.
Model context: chapter listings and shared vocabulary. From the edition root: sysml -strict -validate src/examples/lessons/vocabulary.sysml src/examples/lessons/ch15.sysml.