Repository navigation
fix(runtime): hold a namespace-level feature read in its effective multiplicity - #1585
Merged
Merged
Conversation
…ltiplicity 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>
6 tasks done
…-multiplicity Co-Authored-By: jason.han <hanhuijun@gmail.com> # Conflicts: # docs/project/spec-compliance.md
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
A feature read at namespace (model) level now holds its value in the feature's effective multiplicity, the way the same feature read on an object already does. On
develop, withsysml -e P::xsprinted= 4whilesysml -e P::d.xsprinted= [4](same in the REPL): a[0..*]feature holding exactly one value read bare at model level and as a one-element sequence on an object.P::ys = (1, 2)→[1, 2]and an empty[0..*]→[]were already right, so the one-value case was escaping the shape rule: a declared value was evaluated and returned as written, anddeclaredCollectiononly reshaped values that were already collections.Found while triaging #1575; this is a separate, small inconsistency and does not address that issue.
The fix is in the runtime read path, not the formatter (
runtime.FormatValueand the REPL'sformatValueare untouched):Context.admitted's shape logic is extracted intoContext.heldShape(feat, val)— one predicate: an at-most-one feature holds a one-element collection's element bare, a multi-valued feature holds a collection however the value was written, with the element charging and set/sequence canonicalisationadmittedalready did.Context.declaredCollection(the namespace-level read of a declared value, reached fromconformHeldanddenotedValue) now builds theEffectiveFeaturefor the declaration and applies that sameheldShape, so-e, REPL bare expressions and%eval, gRPCEvaluateand MCP all read[4].[0..*](semantics.EffectiveParameterRange), so a calc-typed parameter's default (in calc f = twice, the library'sin calc :>> eval = evaluationFunction) is now a one-element sequence holding the function. A call applies the one function such a feature holds:boundFunctionanddeclaredFunctiontakesoleElementof the read, asevalChainInvocationandinvokeFunctionalready did.Arithmetic and comparison over such a read are unchanged (
P::xs + 1→5,P::xs == 4→true).Specification basis
KerML 1.0 §7.3.4.1 and §7.4.12: the values of a feature are a sequence its multiplicity constrains. SysML v2 §7.6.3: a parameter stating no multiplicity has no implied
1..1. The "performed action's parameter" row ofdocs/project/spec-compliance.mdis extended with the namespace-level read (implementation and tests); its status is unchanged.How it was verified
Fixture first, both failing on
developwith4/int_valueand passing here:internal/frontend/repl/namespace_shape_test.goTestEvalNamespaceReadHoldsEffectiveMultiplicity:%evaland the bare expression agree for[0..*]valued4([4]), the same feature on an object ([4]),(1, 2)([1, 2]), empty[0..*]([]),[1],[0..1]and bareattribute x : Integer(4),[2]([4, 5]),[0..*]valued(4)([4]),P::xs + 1(5),P::xs == 4(true).tests/grpcevaluate_namespace_feature_multiplicity(P::xs→sequence[int_value 4]) besideevaluate_object_feature_multiplicity(P::d.xs, same).Moved expectations, each adjudicated:
internal/exec/runtime/robustness_usage_members_test.go(Probe::rig.fits.limit, a constraint's barein limit : Real = 100.0)100.0→[100.0][0..*], as the existing performed-pin rule holds)No golden, trace or
expected.jsonfile moved:go test -count=1 ./internal/exec/runtimeis green without re-recording (the trade-study conformance cases andfunction_value_qualified_default, which call a calc-typed parameter by name, pass through thesoleElementconsumer fix above, with their recorded traces unchanged). No codegen target is touched.Gate, all local on this head:
go build ./...,go vet ./...,gofmt -l .empty,go test -count=1 -timeout 40m ./...green (122 packages, with the training and pilot corpora downloaded soTestTrainingExamplesandTestPilotCorporaran rather than skipped;tests/grpc,tests/codegenand the docs transcript checks are in that run),python3 scripts/changelog.py check,python3 scripts/check-doc-links.py(0 broken links). The quick CI tier's runtime, model/export/graph, static, WebAssembly, conformance and documentation jobs are green.Merged
develop(e19d9beb3) in with merge commits, never a rebase; thedocs/project/spec-compliance.mdconflict took develop's refreshed citation column and kept this PR's row content, so the file differs from develop by that one row alone. Re-ran the gate on the merged head:go build ./...,go vet ./...,gofmt -l .empty,go test -count=1 -timeout 40m ./...green (123 packages, corpora present),go test -C toolsover the census and referee packages,check-doc-links,check-doc-ids,check-doc-figures,changelog.py check,mkdocs_census-test.py;sysml -validate -format sarif examplesover the tracked examples exits 0 on this head.Dry-merged clean against the open runtime siblings #1571 and #1572 and against #1580.
Checklist
make testandmake lintpass locallychanges/unreleased/<slug>.<section>.md, not as an edit toCHANGELOG.mdmake docs-countsrun if a gate count moved (compliance rows need nothing: the census is counted at docs build) — no gate count movedF4,K5) in the body, docs, or changelogLink to Devin session: https://nasa-jpl-demo.devinenterprise.com/sessions/4b614bc5d6204ee693145e91142acb0f
Open in Devin Desktop: https://nasa-jpl-demo.devinenterprise.com/desktop/session/4b614bc5d6204ee693145e91142acb0f?variant=devin
Requested by: @HuiJun