feat(edit): expose connection authoring through ApplyEdits and the clients - #609
Merged
Merged
Conversation
Co-Authored-By: jason.han <hanhuijun@gmail.com>
…e attribute Co-Authored-By: jason.han <hanhuijun@gmail.com>
Contributor
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Closes #599 and #601. The edit layer already writes connection-like usages (
edit.OpAddConnection, used by the LSP), butApplyEditshad no operation for them, so the Python, Go and Java clients couldn't author an allocation or a flow.add_member(kind="allocate")was never the right path: an allocation or flow is a connection between two feature ends, not a named member.This PR exposes the existing operation. The edit-layer writer is unchanged.
add_connectionmaps toedit.AddConnection(owner, kind, from, to, name)withType. It requiresauthoringplus a newconnection_authoringcapability. An older service advertisesauthoringbut can't decode oneof arm 6, so the extra capability lets a client refuse locally instead of gettingINVALID_ARGUMENTfor an unset operation. The Go, Python and Java clients check both before sending.Editor.add_connection(owner, kind, from_, to, name=None, type=None), plusadd_allocation(owner, from_, to, ...)andadd_flow(owner, from_, to, ...). The fields arefrom_end/to_endbecausefromis a Python keyword.opensysml.AddConnection{Owner, Kind, From, To, Name, Type}. Java:Edit.AddConnection.of(owner, kind, from, to).withName(..).withType(..).make proto.Example:
model.edit().add_allocation("Demo::System", "a", "b", name="alloc1").apply()insertsallocation alloc1 allocate a to b;, andadd_flow("Demo::System", "tank.fuelOut", "engine.fuelIn")insertsflow from tank.fuelOut to engine.fuelIn;.Specification basis
The written forms are the ones the edit layer already produces, and each is a production of the pinned SysML v2 grammar:
AllocationUsage(allocation [decl] allocate a to b),FlowConnectionUsage(flow [decl] from a to b),ConnectionUsage/InterfaceUsage(connect a to b),BindingConnectorAsUsage(bind a = b),SuccessionAsUsage(first a then b), plus the KerMLConnector/BindingConnector/ItemFlow/Successionforms. A type is accepted only for kinds whose declaration admits one, sosuccessionwith a type is refused as an illegal kind. Every edit is re-parsed and re-analysed, and an edit that introduces errors (for example an unresolved end) is refused. No spec-compliance rows move.How it was verified
go test ./internal/frontend/grpc/... ./internal/check/edit/... ./client/opensysml/... ./tests/grpc/...andgo test -C tools ./cmd/conformance/.... New tests: allocation, flow and typed-connection round trips; refusals for an unknown kind, a type on a succession and an unresolved end; theauthoringandconnection_authoringgates (the service refusesadd_connectionwithoutconnection_authoringwhileadd_memberstill works, and each client refuses before sending); a goldenadd_connectioncase.test_edit.py/test_wire_compat.py(100 passed), including a live allocation round trip againstsysml-grpc.EditProtosTestand build. Java conformance: 260 passed, 0 failed, 10 skipped, including the newapply_edits/an_allocation_is_written_between_two_featuresscenario. Node and Rust runners skipApplyEditsscenarios, as before.make lint,make docs-check,python3 scripts/changelog.py check,make proto-lint proto-breaking(additive only),git diff --check.Checklist
make testandmake lintpass locally (make lintand the focused suites above; the fullmake testis left to CI)changes/unreleased/<slug>.<section>.md, not as an edit toCHANGELOG.mdmake docs-countsrun if a gate count moved (no gate count moved)F4,K5) in the body, docs, or changelog