Skip to content

Monthly sales report ​

A command exports the month's sales, an agent writes the report, and a command sends it to the team.

In words ​

The wishThe monthly sales report, sent to the team

Step 1 · numbers

What to doExport last month's sales to report/sales.csv.
Who does itAn algorithm runs export-sales --month last --out report/sales.csv
What proves itThe command ends without an error.If the command fails, an agent fixes what stands in the way, and the command runs again as the proof.

Step 2 · report

What to doWrite report/report.md from report/sales.csv: the total, the three best products and what changed since the month before.
Who does itAn agent
What proves it
  • These must be there: report/report.md
  • Another agent must find this true: “Every number in the report is the same as in report/sales.csv.”
  • The person answers yes to: “Is this report ready to send?”

Step 3 · send

What to doSend report/report.md to the team.
Who does itAn algorithm runs send-mail --to team --file report/report.md
What proves itThe command ends without an error.

The file ​

json
{
  "$schema": "vpf/1",
  "wish": "The monthly sales report, sent to the team",
  "limits": {
    "repeats": 2
  },
  "steps": [
    {
      "id": "numbers",
      "do": "Export last month's sales to report/sales.csv.",
      "by": "algorithm",
      "run": "export-sales --month last --out report/sales.csv",
      "on_fail": "agent"
    },
    {
      "id": "report",
      "do": "Write report/report.md from report/sales.csv: the total, the three best products and what changed since the month before.",
      "by": "agent",
      "tools": [
        "read",
        "write"
      ],
      "proof": [
        {
          "by": "algorithm",
          "needs": [
            {
              "need": "files",
              "path": "report/report.md"
            }
          ]
        },
        {
          "by": "agent",
          "check": "Every number in the report is the same as in report/sales.csv."
        },
        {
          "by": "person",
          "ask": "Is this report ready to send?"
        }
      ]
    },
    {
      "id": "send",
      "do": "Send report/report.md to the team.",
      "by": "algorithm",
      "run": "send-mail --to team --file report/report.md"
    }
  ]
}

Why it is written this way ​

Three proofs stand before the report is sent: the file is there, another agent finds every number right, and a person says it is ready. The export has an agent behind it, so a failing command gets fixed and run again.

Code, schema and examples under the Apache License 2.0. Guide text also under CC BY 4.0.