Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions api/proto/sysml.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions api/proto/sysml.proto
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,10 @@ message Value {
Vector vector = 13; // numeric components, never a sequence
VectorQuantity vector_quantity = 14; // components each with their unit
MeasurementRef measurement_ref = 15; // a unit by itself, no magnitude
// The unbounded value `*`, which is no number and no string: ordered above
// every finite magnitude and refused by arithmetic. Always true when set,
// as DocumentValue.infinity is.
bool infinity = 16;
}
}

Expand Down
9 changes: 9 additions & 0 deletions changes/unreleased/infinity-and-metadata-values.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- **`*` is a value.** In an expression position `*` evaluates to the unbounded value: it exceeds
every finite Integer, Real and Natural, equals itself, prints as `*` in the REPL and in traces,
and crosses gRPC on its own `Value.infinity` arm under the `infinity_value` capability — never
as the ordinary string `"*"`. Arithmetic over it is refused with a typed error naming the
operation rather than an infinity or a NaN.
- **`elem.metadata` reads an element's metadata.** `ref.metadata` yields the metadata annotating
the element as a sequence of metadata instances, in declaration order, with the feature values
the annotation body binds and the metadata type's own defaults where it binds none. An element
with no metadata yields the empty sequence, and reading metadata off a value is a typed error.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public final class Capabilities {
/** A bare measurement unit ({@code SI::m}, {@code m / s}) travels as itself rather than as an unsupported null. */
public static final String MEASUREMENT_REFS = "measurement_refs";

/** The unbounded value {@code *} travels as itself rather than as an unsupported null. */
public static final String INFINITY_VALUE = "infinity_value";

/** The {@code ApplyEdits} RPC edits a parsed model's own source. */
public static final String APPLY_EDITS = "apply_edits";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ record NullValue() implements Value {}
*/
record UnsetValue() implements Value {}

/**
* The unbounded value {@code *}: no number, ordered above every finite magnitude.
*
* <p>Only a service advertising the {@code infinity_value} capability reports it as itself rather
* than as an unsupported {@link NullValue}.
*/
record InfinityValue() implements Value {}

/**
* A reference to a runtime instance, by the id the service assigned it.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public static Optional<Value> value(org.openmbee.opensysml.proto.Value value) {
case QUANTITY -> Optional.of(new Value.QuantityValue(quantity(value.getQuantity())));
case ENUM_LITERAL -> Optional.of(new Value.EnumerationValue(literal(value.getEnumLiteral())));
case UNSET -> Optional.of(new Value.UnsetValue());
case INFINITY -> Optional.of(infinity(value));
case ARRAY -> Optional.of(array(value.getArray()));
case VECTOR -> Optional.of(vector(value.getVector()));
case VECTOR_QUANTITY -> Optional.of(vectorQuantity(value.getVectorQuantity()));
Expand All @@ -62,6 +63,17 @@ public static Optional<Value> value(org.openmbee.opensysml.proto.Value value) {
};
}

/** Only an asserted arm carries the unbounded value. */
private static Value infinity(org.openmbee.opensysml.proto.Value value) {
if (!value.getInfinity()) {
throw new TransportException(
"the service answered a malformed value: the infinity arm states no value unless it is"
+ " true",
null);
}
return new Value.InfinityValue();
}

private static Value array(org.openmbee.opensysml.proto.Array array) {
List<Value> elements = new ArrayList<>(array.getElementsCount());
for (org.openmbee.opensysml.proto.Value element : array.getElementsList()) {
Expand Down
Loading
Loading