-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathsurfaces.sysml
More file actions
560 lines (484 loc) · 23.4 KB
/
Copy pathsurfaces.sysml
File metadata and controls
560 lines (484 loc) · 23.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
// What sits on top of the pipeline: the interactive surfaces, the client
// libraries that reach the service, and the artifacts the tool writes out.
package OpenSysMLSurfaces {
private import ScalarValues::*;
private import OpenSysMLArtifacts::*;
private import OpenSysMLPipeline::*;
abstract part def Interface :> CodeUnit {
attribute entrypoint : String;
attribute protocol : String;
port pipeline : RequestPort;
}
// A surface that asks questions of the model puts every one through the
// analysis framework, choosing the engines and the width of the fleet.
abstract part def AskingInterface :> Interface {
attribute engineSelector : String;
attribute jobsSetting : String;
attribute engineListing : String;
port questions : RequestPort;
}
#Surface part def Repl :> AskingInterface {
attribute :>> goPackage = "internal/frontend/repl";
attribute :>> entrypoint = "cmd/sysml";
attribute :>> protocol = "terminal";
attribute :>> engineSelector = "%engine";
attribute :>> jobsSetting = "%jobs";
attribute :>> engineListing = "%engines";
attribute stateful : Boolean = true;
attribute adoptsInstancesOnReanalysis : Boolean = true;
}
// Every capability the server announces in its initialize result; the
// rendering requests are the experimental extension the VS Code client uses.
#Surface part def LanguageServer :> Interface {
attribute :>> goPackage = "internal/frontend/lsp";
attribute :>> entrypoint = "cmd/sysml-lsp";
attribute :>> protocol = "lsp-stdio";
attribute incrementalSync : Boolean = true;
attribute publishesQuickFixes : Boolean = true;
attribute hover : Boolean = true;
attribute definition : Boolean = true;
attribute findReferences : Boolean = true;
attribute documentSymbols : Boolean = true;
attribute workspaceSymbols : Boolean = true;
attribute completion : Boolean = true;
attribute formatting : Boolean = true;
attribute rename : Boolean = true;
attribute semanticTokens : Boolean = true;
attribute experimentalRendering : Boolean = true;
in item findings : Diagnostic;
out item tokens : SemanticToken;
out item fixes : QuickFix;
}
// The schema every transport and every client is generated from. Only the
// Go stubs are checked in beside it; the other stubs live with their clients.
part def ApiSchema :> CodeUnit {
attribute :>> goPackage = "api/proto";
attribute schemaFile : String = "api/proto/sysml.proto";
attribute service : String = "SysMLService";
attribute rpcCount : Integer = 22;
attribute rpcs : String = "GetServerInfo, ParseFile, ParseSources, GetSymbol, GetDiagnostics, Evaluate, Instantiate, ExecuteAction, ExecuteState, Convert, ApplyEdits, VerifyConstraint, VerifyRequirement, VerifySatisfaction, ValidateInstance, EvaluateCalc, RunAnalysis, RunSweep, ListEngines, Query, RunDocumentQuery, RenderDocument";
attribute generatedGo : String = "api/proto/sysml.pb.go, api/proto/sysml_grpc.pb.go, api/proto/protoconnect/sysml.connect.go";
attribute generator : String = "buf";
}
// One hand-written service behind two generated transports: gRPC over
// HTTP/2 with reflection, and Connect over plain HTTP for browsers.
#Surface part def ModelService :> AskingInterface {
attribute :>> goPackage = "internal/frontend/grpc";
attribute :>> entrypoint = "cmd/sysml-grpc";
attribute :>> protocol = "grpc, connect";
attribute :>> engineSelector = "engine";
attribute :>> jobsSetting = "OPENSYSML_JOBS";
attribute :>> engineListing = "ListEngines";
attribute enginesCapability : String = "engines";
attribute reflectionEnabled : Boolean = true;
attribute handWrittenService : Boolean = true;
attribute connectAdapter : String = "internal/frontend/grpc/connect.go";
attribute stdioTransport : String = "internal/frontend/stdiorpc";
part schema : ApiSchema;
}
// The same service over a pipe: a process that embeds the binary talks to
// it without a network listener.
#Surface part def StdioService :> Interface {
attribute :>> goPackage = "internal/frontend/stdiorpc";
attribute :>> entrypoint = "cmd/sysml-grpc";
attribute :>> protocol = "stdio";
}
// The non-interactive side of the REPL binary: convert, query, render.
#Surface part def CommandLine :> AskingInterface {
attribute :>> goPackage = "internal/frontend/repl";
attribute :>> entrypoint = "cmd/sysml";
attribute :>> protocol = "flags";
attribute :>> engineSelector = "-engine";
attribute :>> jobsSetting = "-jobs";
attribute :>> engineListing = "-engines";
attribute exitStatusIsContract : Boolean = true;
}
// A client library: hand-written idiomatic code over stubs generated from
// the schema, the stubs checked in at generatedStubs.
abstract part def Client :> CodeUnit {
attribute implementationLanguage : String;
attribute generatedFrom : String = "api/proto";
attribute generatedStubs : String;
port service : RequestPort;
}
part def PythonClient :> Client {
attribute :>> goPackage = "client/python";
attribute :>> implementationLanguage = "python";
attribute :>> generatedStubs = "client/python/opensysml/proto";
}
part def NodeClient :> Client {
attribute :>> goPackage = "client/node";
attribute :>> implementationLanguage = "typescript";
attribute :>> generatedStubs = "client/node/src/generated";
}
part def RustClient :> Client {
attribute :>> goPackage = "client/rust";
attribute :>> implementationLanguage = "rust";
attribute :>> generatedStubs = "client/rust/opensysml/src/proto";
}
part def JavaClient :> Client {
attribute :>> goPackage = "client/java";
attribute :>> implementationLanguage = "java";
attribute :>> generatedStubs = "client/java/opensysml-client/src/main/java/org/openmbee/opensysml/proto";
}
// In the same process by default, over the wire on request: the Go client
// wraps the generated Go stubs rather than being generated itself.
part def GoClient :> Client {
attribute :>> goPackage = "client/opensysml";
attribute :>> implementationLanguage = "go";
attribute :>> generatedStubs = "api/proto";
attribute inProcess : Boolean = true;
}
part def VsCodeExtension :> CodeUnit {
attribute :>> goPackage = "editors/vscode";
attribute speaksTo : String = "sysml-lsp";
port languageClient : RequestPort;
}
// --- What an editor reaches ------------------------------------------
// Semantic-token classes, in the order the LSP legend lists them.
part def Highlighter :> CodeUnit {
attribute :>> goPackage = "internal/semantic/highlight";
attribute tokenClasses : Integer = 15;
in item tree : SyntaxTree;
out item tokens : SemanticToken;
}
// A fix carries the edit that applies it and points at the diagnostic it
// answers; a diagnostic with no unambiguous repair offers none.
part def QuickFixer :> CodeUnit {
attribute :>> goPackage = "internal/syntax/diag";
attribute editsAttached : Boolean = true;
in item findings : Diagnostic;
out item fixes : QuickFix;
}
// The nearest declared names for one that did not resolve.
part def Suggester :> CodeUnit {
attribute :>> goPackage = "internal/semantic/suggest";
attribute rankedByDistance : Boolean = true;
in item findings : Diagnostic;
}
// Span-based rewriting of source text. The result is re-parsed and
// re-analysed, and an edit that would leave the model unreadable is refused.
part def SourceEditor :> CodeUnit {
attribute :>> goPackage = "internal/check/edit";
attribute operations : String = "set value, rename, add member, delete";
attribute preservesUntouchedText : Boolean = true;
attribute reanalysesResult : Boolean = true;
in item text : SourceText;
out item edits : SourceEdit;
}
// Re-indents the token stream, so comments and error nodes survive a save.
part def Formatter :> CodeUnit {
attribute :>> goPackage = "internal/syntax/format";
attribute worksOnTokens : Boolean = true;
in item text : SourceText;
}
// A document name and a span, carried from a declaration to whatever is
// derived from it; a synthetic artifact carries the unlocated origin.
part def Provenance :> CodeUnit {
attribute :>> goPackage = "internal/semantic/symbols";
attribute keyedByDocumentAndSpan : Boolean = true;
attribute consumers : String = "internal/doc/docir, internal/ir/view, internal/ir/queryplan";
out item origins : SourceSpan;
}
// Diagnostics feed fixes and suggestions; edits go back in as source text.
part def EditorPipeline {
part highlighter : Highlighter;
part fixes : QuickFixer;
part suggestions : Suggester;
part editor : SourceEditor;
part formatter : Formatter;
port findingsIn : DiagnosticPort;
port textOut : ArtifactPort;
flow of Diagnostic from fixes.findings to suggestions.findings;
flow of SourceEdit from editor.edits to formatter.text;
}
// --- What the tool writes out ----------------------------------------
// A rendering kind the standard view definitions name.
part def RenderingKind {
attribute kind : String;
attribute supported : Boolean default = true;
}
// Every kind in StandardViewDefinitions is recognized, so a view stating
// one that is not produced is told so rather than rendered as another.
part def ViewEngine :> CodeUnit {
attribute :>> goPackage = "internal/ir/view";
attribute recognizedKinds : Integer = 8;
attribute supportedKinds : Integer = 6;
part tree : RenderingKind { attribute :>> kind = "tree"; }
part interconnection : RenderingKind { attribute :>> kind = "interconnection"; }
part stateDiagram : RenderingKind { attribute :>> kind = "state"; }
part actionDiagram : RenderingKind { attribute :>> kind = "action"; }
part textual : RenderingKind {
attribute :>> kind = "textual";
attribute :>> supported = false;
}
part table : RenderingKind { attribute :>> kind = "table"; }
part sequence : RenderingKind { attribute :>> kind = "sequence"; }
part geometry : RenderingKind {
attribute :>> kind = "geometry";
attribute :>> supported = false;
}
in item types : TypeTable;
in item origins : SourceSpan;
out item diagram : DocumentTree;
}
part def QueryCompiler :> CodeUnit {
attribute :>> goPackage = "internal/ir/queryplan";
attribute immutablePlans : Boolean = true;
}
part def QueryExecutor :> CodeUnit {
attribute :>> goPackage = "internal/doc/queryexec";
attribute orderedRows : Boolean = true;
out item rows : QueryRows;
}
// A document is written in the notation, not in a template language: the
// planner compiles a document definition into an immutable plan holding
// compiled query programs.
part def DocumentPlanner :> CodeUnit {
attribute :>> goPackage = "internal/ir/docplan";
attribute libraryFile : String =
"internal/workspace/libs/stdlib/OpenSysML Libraries/DocumentQueries.sysml";
attribute immutablePlans : Boolean = true;
attribute contentKinds : String = "section, paragraph, table, list, diagram";
in item rows : QueryRows;
out item plan : DocumentPlan;
}
// Evaluating a plan gives one tree, carrying provenance on every node and
// knowing nothing about the backend that will write it out.
part def DocumentIR :> CodeUnit {
attribute :>> goPackage = "internal/doc/docir";
attribute backendAgnostic : Boolean = true;
attribute provenancePerNode : Boolean = true;
attribute resolvesCrossDocumentRefs : Boolean = true;
in item plan : DocumentPlan;
in item origins : SourceSpan;
out item tree : DocumentTree;
}
part def MarkdownBackend :> CodeUnit {
attribute :>> goPackage = "internal/doc/docrender";
attribute form : String = "markdown";
attribute needsExternalTool : Boolean = false;
in item tree : DocumentTree;
}
// The only stage that leaves the process: the tree becomes prepared
// Markdown, its diagrams become images, and a converter makes the PDF.
part def PdfBackend :> CodeUnit {
attribute :>> goPackage = "internal/doc/docpdf";
attribute form : String = "pdf";
attribute engines : String = "weasyprint, pandoc, prince";
attribute diagramTool : String = "mmdc";
attribute needsExternalTool : Boolean = true;
attribute reportsMissingTool : Boolean = true;
in item tree : DocumentTree;
}
// Textual notation both ways, the experimental RDF and API element form,
// SysML v1 XMI read and migrated, and FMI model descriptions imported as
// calc defs. Five formats, twelve names: kerml and text are the notation,
// turtle and rdf are Turtle, api-json and json are the API's element form,
// uml is XMI as Eclipse UML2 writes it, mdzip is XMI in a zip archive and
// fmu is an FMI package.
part def Exporter :> CodeUnit {
attribute :>> goPackage = "internal/translate/export";
attribute formats : String = "api-json, fmu, sysml, ttl, xmi";
attribute formatNames : String = "api-json, fmu, json, kerml, mdzip, rdf, sysml, text, ttl, turtle, uml, xmi";
attribute roundTrips : Boolean = true;
out item graph : RdfGraph;
}
part def OslcQuery :> CodeUnit {
attribute :>> goPackage = "internal/semantic/query";
attribute dialect : String = "oslc";
}
// The document path, from a query in the model to a rendered artifact.
// One plan, one tree, two backends: the form is chosen at the end, so
// Markdown and PDF cannot disagree about the document's content.
part def DocumentPipeline {
part provenance : Provenance;
part views : ViewEngine;
part queries : QueryCompiler;
part rows : QueryExecutor;
part plans : DocumentPlanner;
part ir : DocumentIR;
part markdown : MarkdownBackend;
part pdf : PdfBackend;
port modelIn : ArtifactPort;
port artifactOut : ArtifactPort;
flow of SourceSpan from provenance.origins to views.origins;
flow of SourceSpan from provenance.origins to ir.origins;
flow of QueryRows from rows.rows to plans.rows;
flow of DocumentPlan from plans.plan to ir.plan;
flow of DocumentTree from ir.tree to markdown.tree;
flow of DocumentTree from ir.tree to pdf.tree;
flow of DocumentTree from views.diagram to pdf.tree;
}
// One document rendered, and the one branch in it: the form.
action def RenderDocument {
attribute form : String = "markdown";
attribute toolsPresent : Boolean = true;
in item model : SourceText;
out item artifact : DocumentTree;
first start;
action runQueries;
action compilePlan;
action evaluatePlan;
action writeMarkdown;
action renderDiagrams;
action convertPdf;
action reportMissingTool;
succession first start then runQueries;
succession first runQueries then compilePlan;
succession first compilePlan then evaluatePlan;
succession first evaluatePlan then formGate;
decide formGate;
if form == "markdown" then writeMarkdown;
else renderDiagrams;
// A missing converter is reported, never a half-written document.
succession first renderDiagrams then toolGate;
decide toolGate;
if toolsPresent then convertPdf;
else reportMissingTool;
}
requirement def DocumentsCarryTheirProvenance {
doc /* Every rendered node can be traced back to the element it came from,
* and both backends read the same tree. */
subject documents : DocumentPipeline;
require constraint {
documents.ir.provenancePerNode and documents.ir.backendAgnostic
and documents.plans.immutablePlans
}
}
// --- Conformance oracles ---------------------------------------------
// Harnesses that referee this implementation against a reference; each
// holds a committed baseline that must move deliberately. An advisory
// oracle reports drift; a gating one fails the build on it.
abstract part def ConformanceOracle :> CodeUnit {
attribute reference : String;
attribute baseline : String;
attribute gating : Boolean default = false;
}
#Oracle part def RejectionOracle :> ConformanceOracle {
attribute :>> goPackage = "tools/referee/reject";
attribute :>> reference = "pilot validator";
attribute :>> baseline = "docs/project/pilot-rejection-baseline.json";
}
#Oracle part def DifferentialOracle :> ConformanceOracle {
attribute :>> goPackage = "tools/referee/diff";
attribute :>> reference = "pilot validator";
attribute :>> baseline = "docs/project/pilot-differential-baseline.json";
}
#Oracle part def XpectOracle :> ConformanceOracle {
attribute :>> goPackage = "tools/referee/xpect";
attribute :>> reference = "pilot Xpect suites";
attribute :>> baseline = "docs/project/pilot-xpect-baseline.json";
}
#Oracle part def ExecutionReferee :> ConformanceOracle {
attribute :>> goPackage = "tools/referee/exec";
attribute :>> reference = "pilot expression evaluator";
attribute :>> baseline = "docs/project/pilot-execution-referee.md";
}
#Oracle part def GrammarCoverage :> ConformanceOracle {
attribute :>> goPackage = "tools/census/grammar";
attribute :>> reference = "OMG Xtext grammars";
attribute :>> baseline = "docs/project/grammar-coverage-baseline.json";
}
#Oracle part def DocCounts :> ConformanceOracle {
attribute :>> goPackage = "tools/census/doccounts";
attribute :>> reference = "the measured repository";
attribute :>> baseline = "docs/project/spec-compliance.md";
}
// The bundled standard library must parse clean; the gate is in the suite.
#Oracle part def StdlibConformanceGate :> ConformanceOracle {
attribute :>> goPackage = "internal/workspace/libs";
attribute :>> reference = "OMG standard library release";
attribute :>> baseline = "internal/workspace/libs/stdlib";
attribute :>> gating = true;
}
// The committed library snapshot must be the one a fresh build writes.
#Oracle part def StdlibSnapshotGate :> ConformanceOracle {
attribute :>> goPackage = "tools/gen/snapshot";
attribute :>> reference = "the bundled library files";
attribute :>> baseline = "internal/workspace/libs/stdlib.snapshot";
attribute :>> gating = true;
}
// What the oracles lean on: a pinned reference, an errata overlay for the
// defects in OMG-published material, and the census the status page reads.
part def OraclePin :> CodeUnit {
attribute :>> goPackage = "tools/oracle/baseline";
attribute recordsPin : Boolean = true;
attribute recordsBridgeSource : Boolean = true;
attribute recordsCorpusProvenance : Boolean = true;
}
part def Errata :> CodeUnit {
attribute :>> goPackage = "tools/oracle/errata, internal/workspace/libs/errata";
attribute overlaysPublishedMaterial : Boolean = true;
}
part def StatusCensus :> CodeUnit {
attribute :>> goPackage = "tools/census/doccounts";
attribute countsStatusMarkers : Boolean = true;
}
part def ConformanceInfrastructure {
part pins : OraclePin;
part errata : Errata;
part census : StatusCensus;
}
// --- The whole tool ---------------------------------------------------
part def Toolchain {
part pipeline : AnalysisPipeline;
part documents : DocumentPipeline;
part editing : EditorPipeline;
part repl : Repl;
part lsp : LanguageServer;
part service : ModelService;
part stdio : StdioService;
part cli : CommandLine;
part goClient : GoClient;
part python : PythonClient;
part node : NodeClient;
part rust : RustClient;
part java : JavaClient;
part vscode : VsCodeExtension;
part exporter : Exporter;
part oslc : OslcQuery;
part rejection : RejectionOracle;
part differential : DifferentialOracle;
part xpect : XpectOracle;
part execution : ExecutionReferee;
part grammar : GrammarCoverage;
part counts : DocCounts;
part stdlib : StdlibConformanceGate;
part snapshotGate : StdlibSnapshotGate;
part conformance : ConformanceInfrastructure;
connection replDrives : ArtifactChannel connect repl.pipeline to pipeline.textIn;
connection lspDrives : ArtifactChannel connect lsp.pipeline to pipeline.textIn;
connection serviceDrives : ArtifactChannel connect service.pipeline to pipeline.textIn;
connection cliDrives : ArtifactChannel connect cli.pipeline to pipeline.textIn;
connection replAsks : RequestChannel connect repl.questions to pipeline.questionsIn;
connection serviceAsks : RequestChannel connect service.questions to pipeline.questionsIn;
connection cliAsks : RequestChannel connect cli.questions to pipeline.questionsIn;
connection goCalls : ArtifactChannel connect goClient.service to service.pipeline;
connection pythonCalls : ArtifactChannel connect python.service to service.pipeline;
connection nodeCalls : ArtifactChannel connect node.service to service.pipeline;
connection rustCalls : ArtifactChannel connect rust.service to service.pipeline;
connection javaCalls : ArtifactChannel connect java.service to service.pipeline;
connection editorSpeaksLsp : ArtifactChannel connect vscode.languageClient to lsp.pipeline;
connection documentsRead : ArtifactChannel connect pipeline.textIn to documents.modelIn;
connection findingsToEditors : DiagnosticChannel connect pipeline.diagnosticsOut to editing.findingsIn;
connection editsBack : ArtifactChannel connect editing.textOut to pipeline.textIn;
}
part opensysml : Toolchain;
requirement documentsAreTraceable : DocumentsCarryTheirProvenance {
subject documents = opensysml.documents;
}
requirement def ViewsSayWhatTheyCannotRender {
doc /* Every standard rendering kind is recognized, and the ones not
* produced say so instead of being drawn as something else. */
subject views : ViewEngine;
require constraint {
views.recognizedKinds == 8 and views.supportedKinds == 6
and not views.textual.supported and not views.geometry.supported
and views.sequence.supported
}
}
requirement viewsAreHonest : ViewsSayWhatTheyCannotRender {
subject views = opensysml.documents.views;
}
}