CHANGELOG.md

# Changelog

## Master

### Changes

## 11.0.0

### Changes

- Add documentation for asset types and IDs
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/37))
- Add Simple scenario runtime
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/35),
   [#6694](https://altworx.plan.io/issues/6694))
- Add incident actors to Event Output Action
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/36),
   [#6591](https://altworx.plan.io/issues/6591))

## 10.0.0

### Changes

- Update the Livebook example
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/30))
- Require unit ID to be explicitly set when creating the Unit struct
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/31),
   [#6609](https://altworx.plan.io/issues/6609))
- Improve the documentation
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/34),
   [#6195](https://altworx.plan.io/issues/6195))
- Use peer instead of deprecated slave module for scenario's nodes
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/33),
   [#5918](https://altworx.plan.io/issues/5918))

## 9.0.0

### Warnings

- Notifications specifications are no longer retrieved from `spec.exs` file but
  are now part of Manifest, all scenarios should now define their notifications
  specifications directly in scenario manifest.

### Changes

- Improve docs for `Runbox.Scenario.OutputAction.Event`
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/26))
- Move notification specification to scenario manifest
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/28),
   [#6569](https://altworx.plan.io/issues/6569))
- Better separate scenario runtimes
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/29),
   [#6665](https://altworx.plan.io/issues/6665))

## 8.0.0

### Changes

- Add additional event parameters to Incident History OA
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/27),
   [#6592](https://altworx.plan.io/issues/6592))

## 7.0.1

### Changes

- Anticipate errors from scenario manifest
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/23),
   [#6312](https://altworx.plan.io/issues/6312))
- Explicitly propagate altworx root dir to slave
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/24),
   [#6331](https://altworx.plan.io/issues/6331))

## 7.0.0

### Warnings

- Scenarios are now built with Elixir 1.15.7 and OTP 26.2.1. There may be some breaking
  changes for your code (see https://hexdocs.pm/elixir/1.15/changelog.html and
  https://www.erlang.org/downloads/26). It is recommended to update your `.tool-versions`
  to match these versions.

### Changes

- Forbid slashes in IDs contained in asset/incident creation OAs
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/22),
   [#6327](https://altworx.plan.io/issues/6327))
- Build scenarios with Elixir 1.15 and OTP 26 (to be compatible with Altworx 24.3)
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/21),
   [#6285](https://altworx.plan.io/issues/6285))

## 6.0.0

### Breaking Changes

- All output actions have changed. The following snippet shows how should be
  the output actions updated from the old format to the new one.
  ```elixir
  alias Runbox.Scenario.OutputAction, as: OA

  # Create Asset
  # old
  OA.new_create_asset_action("/asset/camera/1", 1, %{"a" => 1})
  # new
  %OA.UpsertAssetAttributes{type: "/asset/camera", id: "1", attributes: %{"a" => 1}}

  # Update Asset
  # old - deletes and updates attributes via a single action
  OA.new_update_asset_action("/asset/camera/1", 1, %{"a" => 1}, %{"b" => true})
  # new - one action for delete, another one for upsert
  %OA.DeleteAssetAttributes{type: "/asset/camera", id: "1", attributes: %{"b" => true}}
  %OA.UpsertAssetAttributes{type: "/asset/camera", id: "1", attributes: %{"a" => 1}}

  # Upsert Asset
  # old
  OA.new_upsert_asset_action("/asset/camera/1", 1, %{"a" => 1})
  # new
  %OA.UpsertAssetAttributes{type: "/asset/camera", id: "1", attributes: %{"a" => 1}}

  # Delete Asset
  # old
  OA.new_delete_asset_action("/asset/camera/1", 1)
  # new
  %OA.DeleteAllAssetAttributes{type: "/asset/camera", id: "1"}

  # Create Edge
  # old
  OA.new_create_edge_action(1, "/asset/camera/1", "/asset/room/A", "observes")
  # new
  %OA.UpsertEdge{
    from_type: "/asset/camera",
    from_id: "1",
    to_type: "/asset/room",
    to_id: "A",
    type: "observes"
  }

  # Upsert Edge
  # old
  OA.new_upsert_edge_action(1, "/asset/camera/1", "/asset/room/A", "observes")
  # new
  %OA.UpsertEdge{
    from_type: "/asset/camera",
    from_id: "1",
    to_type: "/asset/room",
    to_id: "A",
    type: "observes"
  }

  # Delete Edge
  # old
  OA.new_delete_edge_action(1, "/asset/camera/1", "/asset/room/A", "observes")
  # new
  %OA.DeleteEdge{
    from_type: "/asset/camera",
    from_id: "1",
    to_type: "/asset/room",
    to_id: "A",
    type: "observes"
  }

  # Notification
  # old
  OA.new_notification_action(1, %{type: "created_incident", data: %{"a" => 1}})
  # new
  %OA.Notification{type: "created_incident", data: %{"a" => 1}}

  # Event
  # old
  OA.new_event_action(1, %{
    type: "event_type",
    template: "${actors.wagon}",
    actors: %{"wagon" => %{asset_type: "/assets/wagon", asset_id: "123"}}
  })
  # new
  %OA.Event{
    type: "event_type",
    template: "${actors.wagon}",
    actors: %{"wagon" => %{asset_type: "/assets/wagon", asset_id: "123"}}
  }

  # Execute SQL
  # old
  OA.execute_sql_action(1, %{
    db_connection: db_connection,
    sql_query: "SELECT 1",
    data: [],
    type: :postgresql
  })
  # new
  %OA.ExecuteSQL{
    db_connection: db_connection,
    sql_query: "SELECT 1",
    data: [],
    type: :postgresql
  }

  # Create Incident
  # old
  OA.new_create_incident_action(1, %OA.Incident{
    type: "type",
    id: "id",
    subject: "subject",
    status: "status",
    resolved: false,
    severity: 1,
    future: [],
    history: [%OA.IncidentHistory{
      status: "status",
      severity: 1,
      timestamp: 1,
      description: "description"
    }]
  })
  # new
  %OA.Incident{
    type: "type",
    id: "id",
    subject: "subject",
    status: "status",
    resolved: false,
    severity: 1,
    future: [],
    history: [%OA.IncidentHistory{
      status: "status",
      severity: 1,
      timestamp: 1,
      description: "description"
    }]
  }

  # Update Incident
  # old
  OA.new_update_incident_action(1, %OA.IncidentPatch{
    type: "type,
    id: "id",
    severity: 2
  })
  # new
  %OA.IncidentPatch{
    type: "type,
    id: "id",
    severity: 2
  }
  ```

  Refer to the documentation in `Runbox.Scenario.OutputAction` for details.

  There is also a helper `Runbox.Scenario.Asset.split_id/1`. It splits the full
  asset ID to asset type and asset ID.

- The sandbox tests have changed the format of the produced output action.
  Previously it was a struct

  ```elixir
  %Runbox.Scenario.OutputAction{
    type: type,
    timestamp: ts,
    body: body
  }
  ```

  Now the `:type` is gone and `:body` always contains a struct with the output
  action parameters, e.g.

  ```elixir
  %Runbox.Scenario.OutputAction{
    timestamp: ts,
    body: %Runbox.Scenario.OutputAction.UpsertAssetAttributes{type: type, id: id, attributes: attrs}
  }
  ```

### Changes

- New output actions for asset and edge.
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/19),
   [#6129](https://altworx.plan.io/issues/6129))
- Rework of output action creation and handling.
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/20),
   [#6177](https://altworx.plan.io/issues/6177))

## 5.0.0

### Changes

- Remove deprecation for '/incident' type.
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/18),
   [#5999](https://altworx.plan.io/issues/6066))

### Breaking changes

- Removed code which separated "/incident" prefix from params's type

## 4.0.0

### Changes

- New output actions for incidents. Also remove/update obsolete code.
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/17),
   [#5999](https://altworx.plan.io/issues/5999))

### Breaking changes

- Removed code, which is likely not used anywhere, but check the scenarios.
  - `Runbox.Scenario.OutputAction.new_incident_action/2`
  - `%Runbox.Scenario.OutputAction.Incident{}`
  - `%Runbox.Scenario.OutputAction.IncidentState{}`

- New output actions of types `:create_incident` and `:update_incident`.
  Altworx has to know how to handle those when depending on this version.

## 3.0.0

### Changes

- Move certain modules from Toolbox to Runbox
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/16),
   [#5848](https://altworx.plan.io/issues/5848))

### Breaking changes
- Many modules were moved from Toolbox to Runbox (some kept their name, but the majority
  of them was also renamed to be under the Runbox "namespace"), here are the ones that
  affect scenario authors (for a complete list, see the task):
  - Modules that will require changes in aliases (just replace `Toolbox` with `Runbox`)
    - `Toolbox.Notifications.TemplateHelper` → `Runbox.Notifications.TemplateHelper`
    - `Toolbox.Runtime.RuntimeInstruction` → `Runbox.Runtime.RuntimeInstruction`
    - `Toolbox.Utils.Path` → `Runbox.Utils.Path`
    - `Toolbox.Scenario.Config` → `Runbox.Scenario.Config`
    - `Toolbox.Scenario.Helper` → `Runbox.Scenario.Helper`
    - `Toolbox.Scenario.Manifest` → `Runbox.Scenario.Manifest`
  - A module that requires change of `@behaviour` (just replace `Toolbox` with `Runbox`)
    - `Toolbox.Scenario.Template.StageBased`→ `Runbox.Scenario.Template.StageBased`
  - Configuration key move
    - `:scenario_config_dir` config key was moved from `:toolbox` to `:runbox`,
      you may have to change this in your `config/test.exs`

## 2.1.0

### Changes

- Remove runbox version check
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/15),
   [#5828](https://altworx.plan.io/issues/5828))

## 2.0.0

### Changes

- Build scenarios with Elixir 1.14 and OTP 25 (to be compatible with Altworx 23.3+)
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/14),
   [#5799](https://altworx.plan.io/issues/5907))

## 1.4.1

### Changes

- Bump toolbox dependency to 2.0.0

## 1.4.0

### Changes

- Start slave VM as a hidden node
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/11),
   [#5799](https://altworx.plan.io/issues/5799))
- Check that scenario timeouts are not registered to the past.
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/10),
   [#5827](https://altworx.plan.io/issues/5827))
- Use timeout message timestamp to register scenario timeouts.
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/10),
   [#5827](https://altworx.plan.io/issues/5827))
- Check input messages order prior sandbox run execution.
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/10),
   [#5827](https://altworx.plan.io/issues/5827))

### Breaking changes
- API function to register timeouts `Toolbox.Runtime.RuntimeInstruction.register_timeout/2`
  was removed, update scenarios to use `Toolbox.Runtime.RuntimeInstruction.register_timeout/1`
  instead.
- Field `timeout` was removed from `Toolbox.Runtime.RuntimeInstruction.Timeout`

## 1.3.0

### Changes

- Remove `Runbox.Scenario.Template` and use only `Runbox.ScenarioTemplate`.
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/9))

## 1.2.0

### Changes

- Default mode is `:slave`. Scenario repositories do not need to set this
  anymore. Altworx needs to set the `:master` mode explicitly.
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/8),
   [#5714](https://altworx.plan.io/issues/5714))
- Find scenario modules for sandbox testing from the current mix app. Scenario
  repositories do not need to set `:scenario_app` app env anymore even for
  testing.
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/8),
   [#5714](https://altworx.plan.io/issues/5714))

## 1.1.0

### Changes

- Mix task for building scenario releases
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/5),
   [#5713](https://altworx.plan.io/issues/5713))

### Additional info

- There is no need to set `:runbox, scenario_app: :app_name` in the scenario app
  anymore. New task `mix altworx.scenario_release` does it automatically.

- There is no need to set `releases` key in the `project/1` of `mix.exs` in the
  scenario app. In fact, the `release` key is ignored when using the new mix
  task `mix altworx.scenario_release`.

## 1.0.0

### Changes

- Relax runbox version check
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/7),
   [#5817](https://altworx.plan.io/issues/5817))

## 0.1.3

### Changes

- Add support for start_from in Sandbox
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/4),
   [#5821](https://altworx.plan.io/issues/5821))
- Explicitly load modules when checking if a function is exported
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/6)
   [#5784](https://altworx.plan.io/issues/5784))
- Run slaves in interactive mode
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/6)
   [#5784](https://altworx.plan.io/issues/5784))

## 0.1.2

- Bump toolbox dependency to 1.0.0

## 0.1.1

### Changes

- Use runbox from hex in demo livebook
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/2))
- Fix load topic in Sandbox
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/3))

## 0.1.0

### Changes

- Runbox is in separate repository
  ([PR](https://gitlab.dev.altworx.com/erlang/product/runbox/-/merge_requests/1),
   [PR](https://gitlab.dev.altworx.com/erlang/product/altworx/-/merge_requests/1853),
   [#5711](https://altworx.plan.io/issues/5711))