lantern

cookie-jar

πŸͺ Cookie Jar State Machine

A stateful pipeline demonstrating the iterative pattern: loop through players until the list is empty.

Game State

players:
  - Alice
  - Bob
  - Charlie
round: 0
accused: null

The Song

initial: init

environments:
  init:
    activities:
      - type: statePoke
        args:
          key: players
          value: [Graeme, Marc, Bolawa, Aravind]
      - type: statePoke
        args:
          key: round
          value: 0
      - type: stateTransition
        args:
          to: round

  round:
    activities:
      - type: stateIncrement
        args:
          key: round
      - type: statePick
        args:
          from: players
          into: ACCUSED
          remove: true
      - type: stateEmit
        args:
          message: |
            πŸͺ Round ${round} πŸͺ
            "Who stole the cookie from the cookie jar?"
            "${ACCUSED} stole the cookie from the cookie jar!"
            "Who, me?"
            "Yes, you!"
            "Couldn't be!"
            "Then who?"
      - type: stateGate
        args:
          check: players
          empty: finale
          notEmpty: round

  finale:
    activities:
      - type: stateEmit
        args:
          message: |
            πŸ«™ The cookie jar is empty! πŸ«™
            ${round} rounds played.
            Everyone's innocent... or are they?

❌ Fence Execution Error: No provider registered for fence type: workflow (from 'workflow[run-the-song,execute=true]')

How It Works

The Cookie Jar pattern demonstrates:

  • State initialization - Players list seeded from YAML fence
  • Iterative consumption - Each round picks and removes a player
  • Template emission - Verses interpolate the accused player
  • Exit condition - Finale when players list exhausted

Run It

# Run the Cookie Jar song
loom peek @run-the-song

Related

  • @oculus project-cookie-jar - Parent project
  • @oculus loose-the-goose - Jenkins integration demo
  • @oculus karaoke-songs - Other song patterns (counter, accumulator)

Provenance

Document

  • Status: πŸ”΄ Unverified

Changelog

  • 2026-01-12 19:11: Node created by mcp - Creating Cookie Jar demo node for Loom pipeline fence testing

North

slots:
- context:
  - Linking workflow guide to cookie-jar example
  slug: loom-workflow-guide
↑ northloom-workflow-guide