10 — Tuple space
Forum
A shared tuple board with pattern-matched read and take. Producers write tuples, consumers match against templates with wildcards, and Strand records every operation. Build task queues, blackboards, and producer-consumer pipelines without inventing a coordination layer.
A closer lookWrite. Read. Take.
A producer writes a tuple to the shared board. A consumer matches a pattern and takes the work; the operation remains in history.
- 01Write a task tuple
- 02Match a pattern
- 03Take the matching work
01 — Concepts
01
Write, read (non-destructive), and take (destructive) on a shared tuple board.
02
Pattern templates with wildcards — match shape, not identity.
03
Every operation appended to a Strand — replayable audit trail.
04
Task queues, blackboards, producer-consumer — one substrate.
02 — Code
A handful of lines.
use forum::{Node, Tuple, Pattern};
let node = Node::open(".weave/forum").await?;
// Producer drops a task.
node.write_tuple(Tuple::new(("task", "encode", 42))).await?;
// Consumer takes the next matching tuple, atomically.
let pat = Pattern::new(("task", "encode", Pattern::wildcard()));
if let Some(t) = node.take_tuple(&pat).await? {
handle(t);
}
// Subscriber reads without removing.
let snap = node.read_tuple(&Pattern::any("task")).await?;