Skip to content

v0.20.0

Latest

Choose a tag to compare

@Ikepeeee Ikepeeee released this 02 Dec 14:24
47284e3

Lask shows what a run did, and declares values and functions alike.

v0.20.0 makes a run observable after the fact. --summary ends a run with one row per command and how it ended. --otlp-endpoint, or the standard OTEL_EXPORTER_OTLP_* variables, sends the run's trace and logs to any OpenTelemetry backend: each declared function call and each command is a span, and each log line belongs to its span. lask otel serve starts Grafana on your machine to look at them. In the language, a declaration written as a value and one written as a function now go everywhere the other does: a class method can be a value, a value takes within, and a block can declare a function. Access constraints join with &, so a named one is refined where it is used. The language server is now lask lsp serve.

Breaking changes

None that a program which ran on 0.19.0 meets. Two things behave differently:

  • TRACEPARENT is adopted when no --trace-id is given (spec 12.5). A run inside a traced CI job takes the job's trace id instead of a new one, in its JSON Lines as in its trace, and its root span continues the job's span.
  • A class method referenced as a value with no expected type, inside a declaration whose type parameter has the same name, is E-TYPE-MISMATCH when the program is checked. It used to pass the check and fail at run time with "cannot call a value of type Null".

Lask is pre-1.0 and every feature is experimental until 1.0, so breaking changes remain possible; see compatibility.md.

Deprecated

  • lask serve is now lask lsp serve (spec 11.13). lask serve still starts the language server, so an editor set up for it keeps working, but it is no longer listed in help or offered by completion. It will be removed in a later release (#291). The VS Code extension starts lask lsp serve from 0.3.0, and lask serve with an older Lask.

Seeing what ran

  • --summary (run, eval, cmd) ends the run with a summary on stderr: how it ended, how long it took, and one row per command execution with its environment, its command, how long it ran and how it ended (spec 12.9). It is written however the run ends, failed or interrupted too, does not change the exit code, and is masked as the log is. Under --log-format json it is one JSON Lines object with a summary field.
  • The trace of a run over OTLP (spec 12.10). With --otlp-endpoint <url>, or OTEL_EXPORTER_OTLP_ENDPOINT or OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, a run sends its trace over OTLP/HTTP with JSON: a root span for the run, a span for each call of a declared function inside the call it was made from, and a span for each command inside the function that ran it, so calls started with async show side by side. A span ends in error when its command exits non-zero or its function fails. OTEL_EXPORTER_OTLP_HEADERS, OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES are read, which is how a CI job authenticates and attaches its own identifiers.
  • The logs of a run over OTLP (spec 12.11). Alongside the trace, a run sends what stderr shows: each command's start line, output and exit line, the lines of log, and the diagnostic a failed run ends with, each record with its trace, its span and its level as the severity. OTEL_EXPORTER_OTLP_LOGS_ENDPOINT and OTEL_LOGS_EXPORTER=none act on the logs alone.
  • Everything exported is masked first, as stderr is. A failure to send never fails a run: it is reported once, at the end, as the new advisory W-OBS-EXPORT.
  • The JSON Lines of --log-format json carry the span ids of calls and commands whether or not anything is exported, so the logs and a trace can be read against each other.
  • lask otel serve runs a local viewer on the container engine: Grafana, Tempo, Loki and an OpenTelemetry collector in one container (grafana/otel-lgtm, pinned), on 127.0.0.1 only, with Grafana on port 3000 and OTLP on 4318 (--ui-port, --otlp-port). It prints where to look and how to send a run there. --detach leaves it running, and lask otel stop stops and removes it; nothing is kept. See Seeing what ran.

Values and functions alike

  • A class method may be written as a value, m: Function<T, R>, with a default that is any function value of its type, such as modify: Function<T, T> = destroy >> deploy (spec 4.6). An instance may define a method as m = e.
  • A value declaration takes within, as a function declaration does (spec 5). It bounds what a call of a lambda does, or what evaluating any other value does: status: String within { outbound: false } = $[open] curl ....
  • A block may declare a function, g(x: Number): Number = x + 1, binding what g = \(x: Number): Number -> x + 1 binds, a generic one included (spec 6.5). Like every binding of a block, it is in scope after its statement, so it does not call itself.
  • (f >> g)(x) is checked as g(f(x)), and (f << g)(x) as f(g(x)), so a composition of class methods applied to an argument resolves their instances.

Access constraints

  • Constraints join with & (spec 5, 10.11). What a declaration reaches is within A & B when it is within both, and each part is checked and reported as written: within Offline & { files: "ro" } refines a named constraint without copying it.
  • access Name = ... takes a whole bound, names included: access Sealed = Offline & Contained. A declaration that leads back to itself is E-TYPE-WITHIN-SPEC at each name of the cycle.
  • A line-final & continues the bound, and the formatter keeps the break.
  • lask envs access <fn> shows the bound as written (A & B), and the language server offers access names and fields after &.

Examples