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: nullThe 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-songRelated
- @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