Otter Workflows Otter Upstream Composition Verified

Collection Analytics and Persistence Workflow

Demonstrates 4-pack composition: deduplicates and sums numeric collections with otter-official/list-utils, clamps bounds with otter-official/math-utils, formats output via number_to_text and otter-official/text-utils, and persists structured JSON with otter-official/file-helpers.

ID: workflow/collection-analytics-persistence Version: 1.0.0 License: MIT Framework: Otter Composition Planner (Phase 11)

Architecture & Runtime Preview

Otter Composition Planner (Phase 11)

Deterministic 6-step multi-pack DAG composing 4 Schema v2 Packs with explicit port bindings and side-effect ordering.

  1. 1step1_dedupe: otter-official/list-utils::dedupeList()
  2. 2step2_sum: otter-official/list-utils::calcListSum()
  3. 3step3_clamp: otter-official/math-utils::clamp()
  4. 4step4_pad: otter-official/text-utils::padLeft() [adapter: number_to_text]
  5. 5step5_persist: otter-official/file-helpers::writeJsonObject() [adapter: json_object_wrap_value] [after: step4_pad]
  6. 6step6_verify: otter-official/file-helpers::readJsonObjectSafe() [after: step5_persist]

Source Code (1 file)

collection-analytics-persistence.workflow.json · json
{
  "$schema": "../schema/workflow-spec.schema.json",
  "workflowVersion": 1,
  "id": "collection-analytics-persistence",
  "name": "Collection Analytics and Persistence Workflow",
  "description": "Demonstrates 4-pack composition: deduplicates and sums numeric collections with otter-official/list-utils, clamps bounds with otter-official/math-utils, formats output via number_to_text and otter-official/text-utils, and persists structured JSON with otter-official/file-helpers.",
  "target": "console",
  "composedPacks": [
    "otter-official/list-utils",
    "otter-official/math-utils",
    "otter-official/text-utils",
    "otter-official/file-helpers"
  ],
  "pipelineInputs": [
    {
      "name": "rawNumbers",
      "type": "list",
      "default": [10, 20, 10, 30, 20],
      "description": "Numeric list with duplicates to deduplicate, sum, clamp, and persist"
    },
    {
      "name": "reportPath",
      "type": "text",
      "default": "analytics_report.json",
      "description": "Destination JSON file path for formatted analytics output"
    }
  ],
  "steps": [
    {
      "id": "step1_dedupe",
      "pack": "otter-official/list-utils",
      "operation": "dedupeList",
      "inputs": {
        "items": { "fromInput": "rawNumbers" }
      }
    },
    {
      "id": "step2_sum",
      "pack": "otter-official/list-utils",
      "operation": "calcListSum",
      "inputs": {
        "items": { "fromStep": "step1_dedupe", "port": "returns" }
      }
    },
    {
      "id": "step3_clamp",
      "pack": "otter-official/math-utils",
      "operation": "clamp",
      "inputs": {
        "value": { "fromStep": "step2_sum", "port": "returns" },
        "minLimit": { "value": 0 },
        "maxLimit": { "value": 100 }
      }
    },
    {
      "id": "step4_pad",
      "pack": "otter-official/text-utils",
      "operation": "padLeft",
      "inputs": {
        "text": {
          "fromStep": "step3_clamp",
          "port": "returns",
          "adapter": "number_to_text"
        },
        "targetLen": { "value": 6 },
        "padChar": { "value": "0" }
      }
    },
    {
      "id": "step5_persist",
      "pack": "otter-official/file-helpers",
      "operation": "writeJsonObject",
      "inputs": {
        "filePath": { "fromInput": "reportPath" },
        "obj": {
          "fromStep": "step4_pad",
          "port": "returns",
          "adapter": "json_object_wrap_value"
        }
      },
      "orderAfter": [
        "step4_pad"
      ]
    },
    {
      "id": "step6_verify",
      "pack": "otter-official/file-helpers",
      "operation": "readJsonObjectSafe",
      "inputs": {
        "filePath": { "fromInput": "reportPath" },
        "fallbackValue": { "value": null }
      },
      "orderAfter": [
        "step5_persist"
      ]
    }
  ],
  "output": {
    "fromStep": "step5_persist",
    "port": "returns"
  }
}

Installation & Usage

otter compose plan --workflow library/workflows/collection-analytics-persistence.workflow.json --explain
otter compose plan --workflow library/workflows/collection-analytics-persistence.workflow.json --apply --yes

Apply into a fresh Otter console project with 'otter compose plan --workflow ... --apply --yes', verify with 'otter check src/main.ot', and execute with 'otter run src/main.ot'.