shesmu

Guided Meditations

Once you have a production facility, stuff goes sideways and since Shesmu can be integrated with other systems, it can be a tool to help diagnose problems. The guided meditations feature allows developing debugging procedures where Shesmu can integrate data it has from different sources to help humans figure out what’s going on. It works a bit like a mechanics flow chart: asking questions and suggesting things to check. To make this process easier, it can also pull the information it recommends the user analyse using action searches, alert searches, downloadable files, and simulations.

Each meditation can serve a different purpose and is stored in a .meditation file. Once available on the server, they will appear under Tools, Guided Meditations.

A meditation begins with information to be displayed followed by a next step. Meditations are written in a modified form of the olive language, so all the expressions available to olives are usable in meditations. Unfortunately, meditations run in the browser, so they cannot make use of functions and constants from the plugins or olive files. The standard functions and constants (i.e., std::…) are available.

Displays

There are several displays supported.

Text

Text can be displayed to the user. expr is an expression that provides a string containing text. There are additional formatting options.

Hyperlinks can also be displayed:

Action Searches

The actions currently present in Shesmu can be searched using the advanced action search language. For details, see the Actions page in Advanced mode. A search for actions might look something like:

Actions type = "sftp-symlink"

The action queries can also include olive expressions using {}:

Actions type = "sftp-symlink" and tag = {active_projects}

This only applies to values, not the variables. For example, this is not allowed:

Actions {If something Then "type" Else "tag"} = "whatever"

Lists versus single items are more forgiving than in the regular action queries. For instance, the following is allowed:

Actions status = {
  If std::date::now - start_time < 3hours
    Then [WAITING, THROTTLED]
    Else [THROTTLED]}
  and tag in (research, {project})

Alert Searches

The alerts currently present in Shesmu can also be searched. There is no alert search language, so it will be described below:

Alerts project = * & LIVE

The supported operations are:

File Downloads

A meditation can provide prepared text to download to feed into another program:

This will create a button to download contents as a file with the name filename and the MIME type mimetype. Both filename and mimetype must be strings and contents can be a string or JSON value. If the MIME type is omitted, text/plain will be used for strings and application/json will be used for JSON values.

Repeated Information

Repeated information can be displayed either in a list or a table. Much like For expressions, there are different collectors that produce different results.

The source and transforms are as exactly as For expressions. The collectors that can be used are:

The display elements between Begin and End will be displayed multiple times as if they had been written out repeatedly.

The items will be placed in rows in a table. Each column starts with a string header and then the text display information to fill that cell in value.

Simulations

To gather more information about the state of Shesmu, it is also possible to run a simulation from a script, just as with the Olive Simulator, and to rerun an existing olive script present on the server. The meditation is capable of passing values into the simulation.

Next Steps

As the meditation is run, the user can select the next step along the way and this will determine the behaviour of the rest of the meditation.

User-Interactive

Form Entries

To collect data from the user, a form entry will display a prompt that is stored in a variable.

Type Display Variable Type
Text a free-form text input box string
Number a number spinner box integer
Offset a number box + time unit selector integer as milliseconds
Checkbox a check box boolean

Automatic Flow Control

If there is information provided that can be used to determine what decision to make next, the Switch and Match steps allow selecting it. They are structured similarly to Switch and Match expressions. These cannot be preceded by information to display.

Computes the value testexpr, which must be a Boolean, and, if it is true, truestep will be performed; otherwise, falsestep is performed.

Computes the algebraic value returned by refexpr and access its contents. A When branch can be provided for every possible algebraic type returned by refexpr. If all possible types are matched, the matching is exhaustive. If the matching is not exhaustive, the remaining cases can be access to the case being handled.

For details on algebraic type matching, see Algebraic Values without Algebra.

Computes the value refexpr and if it is equal to any textexpr, the matching step will be performed. If no value match, altstep is performed instead.

Splits the journey into several parallel journeys. source and transforms are as exactly as For expressions. Each resulting item will be split into a new path handled by step. They will be labelled to avoid confusion, using title, which must be a string.

Gathering Server Data

The information blocks can display information from the server, but this information isn’t available to make decision. The Fetch element allows gathering data from the server to make decisions.

Each of the items described in data is fetched from the server and then is available for decision making.

Server Data Collection Methods

The following sources of data can be collected from the server:

Counts the number of actions that match the provided query (see Actions Searches for details on the query format). The resulting count will be available as an integer stored in name .

Copies all the identifiers of actions that match the provided query (see Actions Searches for details on the query format). The resulting identifiers will be available as a list of strings stored in name .

Copies all the tags of actions that match the provided query (see Actions Searches for details on the query format). The resulting tags will be available as a list of strings stored in name .

This runs an olive and collects the output of that olive into a list. This uses the Olive Simulator and so has access to all functions and constants on the server. The values defined are passed in to the simulation in the shesmu::simulated:: namespace and the this namespace is imported, same as the Simulate information display (i.e., if you have previous set Entry ... To foo, then you can use foo and/or shesmu::simulated::foo in this olive). format specifies the input format that should be used (normally in the Input line of an olive script). A list of clauses can be specified. The data from the last clause will be converted into a list of objects and stored in the variable name.

This operation can download large amounts of data to the client. If used directly, it could download the entire dataset into the browser and the browser may not appreciate that. There are three important things to do:

Access a constant on the server. The constants and functions available to guided meditations are limited since they must run in the browser, but this allows fetching the value of a constant, just like the Definitions page.

Running a function on the server. The constants and functions available to guided meditations are limited since they must run in the browser, but this allows executing a function, just like the Definitions page.

This allows doing a collection of related fetch operations. The source and transforms are as exactly as For expressions. The collector is one of the following:

Collector Behaviour
List fetch Performs the fetch for each input value and turns the results into a list.
Fetch fetch Performs the fetch, which must return a list, for each input value and turns the results into a list.
Dict key = fetch Performs the fetch for each input value and turns the results into the values of a dictionary. key is an expression that provides the corresponding key.

Define and Go-to

It can be useful to reuse steps in different contents. At the beginning of a file, a reusable step can be defined:

This creates a definition for a step that can then be referenced elsewhere as:

Only previously declared steps are available, so they must be declared in dependency order and cycles are not permitted.

An Example

There is a functional, though somewhat useless meditation:

Start
  Print "Hello. How do you feel?"
  Choice
    When "I am tired" Stop
    When "I am confused"
      Actions type = "sftp-symlink"
      Stop
    When "I am anxious"
      Fetch
        count = ActionCount type = "sftp-symlink"
      Then
      Print "There are {count} symlink actions."
      Stop
    When "I'm looking for something more conventional"
      Form
        name = Text With Label "What is your name?"
      Then
        Download "Hello, {name}! Does this meet your expectations"
          To "example.txt" MimeType "text/plain"
        Stop
    When "I have so many things"
      Form
        things = Paste /[A-Z]\d{3,}/ With Label "Can you list all the things?"
      Then
        RepeatFor thing In things: Table
            Column "A Thing" "Try not to let {thing} bother you."
        Stop
    When "I yearn for knowledge"
      Simulate
        Refiller type = string, count = integer As action_stats
          Version 1;
          Input shesmu;
          Olive
            Group By type Into count = Count
            Refill action_stats With type = type, count = count;
      Stop;