is_annotation_shapes

Annotation shapes for intersyntactic: a comment, a correction to a node's value, an approval and a mark that a node was seen. An annotation is a node an actor writes beside another node: it points at that node and never changes it, as in the W3C Web Annotation model. A module needs them when actors annotate its nodes. A module that only declares shapes needs is_shapes alone.

A shape is a Dart type, and binding an offering to an acceptor is the analyzer checking that one type can be assigned to the other (#1069). A Dart class is its declaration, so if two modules each declared a NodeApproval, they would hold two types, and one module's approval could never bind where the other waits for one. They are declared once, here, for every module whose nodes are annotated (#1073).

import 'package:is_annotation_shapes/is_annotation_shapes.dart';
import 'package:is_shapes/is_shapes.dart';

/// A forecast's value: what a correction may change.
final class Outlook extends Value {
  const Outlook(this.weather, this.reason);
  final Weather weather;
  final String reason;
}

/// A forecast is about its day; a later forecast for that day may change its
/// outlook.
final class Forecast {
  const Forecast({required this.day, required this.outlook});
  @identity
  final String day;
  final Outlook outlook;
}

// An acceptor that applies corrections to forecasts takes
// NodeCorrection<Outlook>.

What is here

  • NodeComment: a thought on a node, by an actor, proposing no change to it.
  • NodeCorrection<V extends Value>: a proposed new value for a node, of that node's own value type. An acceptor for NodeCorrection<Outlook> refuses a correction to any other value type at composition, even one with the same fields. It proposes; the corrected node is never rewritten.
  • NodeApproval: an approval of a node, by an actor. It is never changed once written; it is taken back by a later Withdrawal<NodeApproval> from its author.
  • NodeSeenMark: a mark, by an actor, that they have seen a node and considered that version. A version they have seen and not approved is one they looked at and held off on.
  • VerdictOnShownMessage: a person's call on something shown to them, made before anyone knows which node it was, such as a Teams card press or a Slack button: ApprovedVerdict, HeldOffVerdict, or ProposedCorrectionVerdict with the text fields their client sent, by id. It has no target and no author, and a proposal carries text rather than a Value, because which value type it needs depends on the node. Whoever learns which node the message showed builds the annotations from it: a NodeApproval; a NodeSeenMark and a Withdrawal<NodeApproval> of each of their approvals that stands; or a NodeCorrection<V>, if the fields its shape names parse as that node's value type V, and otherwise nothing. It travels as JSON in a node's map form, {"shape": "ProposedCorrectionVerdict", "inputs": {...}}: toJson() writes it, and VerdictOnShownMessage.fromJson reads it strictly, refusing an unknown shape and a field missing, extra or of the wrong type.

A node is named three ways, as is_shapes sets out: its anchor, what it is about; its version, what it says, its shape and all its fields; and its exact id, which one exactly, naming its whole history. A node is never changed. A later node at its anchor has a new exact id, whatever made it, and is a new version only if it says something different. An annotation is of the version at its target's exact id, and holds for a later node at its anchor with the same version. Whatever an actor has written of a version, at any exact id and withdrawn or not, shows they considered it.

A comment, a correction or an approval is Withdrawable: its author can take it back with a Withdrawal, and a withdrawal is final. A NodeSeenMark is not: what has been seen stays seen. What they point at (Target), who wrote them (ActorId), the Value a correction proposes, and the Withdrawal<T> that takes one back all come from is_shapes. Value is there, not here, because it is @identity's other half: every field a shape doesn't mark as identity is its value.

The pure list

A shape file may import only what import admission's pure list allows (#1046). This package imports only is_shapes and checked_json, and all three have to be on that list. test/pure_list_test.dart holds it to the list, reading every branch of every import and export from the parse tree.

Depending on it

A module that annotates also names Target and ActorId, so it depends on is_shapes too:

dependencies:
  is_annotation_shapes: ^0.3.1
  is_shapes: ^0.5.0

Libraries

is_annotation_shapes
Annotation shapes: a comment, a correction, an approval and a mark that a node was seen. An annotation is a node an actor writes beside another node: it points at that node and never changes it, as in the W3C Web Annotation model (https://www.w3.org/TR/annotation-model/). A module needs them when actors annotate its nodes.