Skip to content

Pips buy their own food, and no workplace conjures it - #9

Closed
teceer wants to merge 1 commit into
feat/purchases-gated-by-the-corefrom
feat/pips-buy-their-own-food
Closed

teceer wants to merge 1 commit into
feat/purchases-gated-by-the-corefrom
feat/pips-buy-their-own-food

Conversation

@teceer

@teceer teceer commented Aug 6, 2026

Copy link
Copy Markdown
Owner

ADR 0006 step 7 — the point the whole ADR was written for. Stacked on #8.

What changes

Until now a shift handed the worker food out of nothing. farm.go gave +5 a tick, the tavern +3, and both files said in a comment that it was conjured. The economy from #4 and #8 ran alongside that, decorative: money moved, but nothing depended on it.

Now the loop closes:

work → wage → walk to the shop → buy a meal → live

A pip that cannot afford food starves. That is the first death in this simulation caused by economics rather than by a missing building.

The interesting part: a pip decides something

A pip gains an errand — somewhere it is going of its own accord, which outranks the commute. It is the first thing in this simulation a pip decides for itself; everything else about it was decided by a service or by the world.

Two choices worth reviewing:

It lives in the core. Same reason wander does: the browser predicts with this identical code, so a decision taken in a driver or a client would make prediction and truth disagree about what happens next.

It is not a plan. No goal queue, no stored intention. A pip is hungry or it is not, and it re-decides every tick — so a shop that raises its price, or a wage that arrives late, changes its mind with nothing to invalidate. A plan would need to be cancelled; a standing preference does not.

An errand also has to be physical, per invariant 5: the pip walks there, goes inside (taking a place, briefly), buys, and leaves in the same tick.

Prices reach the core the way capacity already does (ADR 0004) — the workplace owns the number, the gateway carries it on the registration intent, the core enforces it. A pip deciding inside a tick whether it can afford lunch cannot make a network call to ask.

The proof

One test runs 4,000 ticks of the whole loop: a pip is hired, paid in batches the way the gateway pays it, decides for itself when to stop working and eat, and is alive at the end with money left and total_money == 0 throughout. Two more pin the other side — a penniless pip starves standing next to food it cannot afford, and hunger outranks the commute while employment survives the errand.

need_deltas is deprecated, not reserved

Step 7 asked for reserved. That turns out to be impossible, and the ADR is wrong about it:

Previously present field "2" with name "need_deltas" on message "WorkResponse" was deleted.

make proto-lint runs buf breaking, and that rule is load-bearing — a topic with a week's retention holds messages that must still decode. So the field stays on the wire, marked deprecated, and dies by disuse. Nothing populates it.

The farm and the tavern no longer have any opinion about hunger. That is what makes the tavern's old food_per_tick = -1 — the number that starved everyone it employed — unrepresentable rather than merely fixed.

Test plan

  • cargo test -p sim — 32 pass, 3 new (survival over 4,000 ticks, starving next to unaffordable food, errand outranks commute)
  • mix test in tavern — 32 pass; its shift test now asserts a shift reports only what it produced and paid
  • go test ./... in farm, conformance, bank, world-gateway — pass; farm and conformance re-pinned onto wage and produce
  • cargo clippy --all-targets -- -D warnings clean, cargo fmt --check clean
  • buf lint / buf breaking clean — WorkplaceOffer, RegisterWorkplaceIntent.sells, Workplace.sells all additive
  • make gen regenerated for Go, TS and Elixir
  • Not exercised: a live world. The loop is proven deterministically in the core, but the numbers (wage 6/tick, meal 50, +200 food) have never faced a running cluster — that is what to watch first after deploy

Balance, and what to watch

A meal restores 200 food; a working pip burns 2 a tick, so one meal buys ~100 ticks of work — 600 in wages against 50 at the till. Employment is comfortably survivable on purpose: if it were marginal, the only failure anyone would ever see is "everyone dies", and the interesting ones (a wage that cannot cover food, a shop nobody can reach) would be invisible underneath it.

Unemployment is now fatal, since nothing else feeds a pip. That is the intended scarcity, but it makes hiring throughput a survival mechanism rather than an optimisation — worth watching on the first live run.

🤖 Generated with Claude Code

This is ADR 0006 step 7, and the point the whole ADR was written for. Until
now a shift handed the worker food out of nothing: `farm.go` gave +5 a tick,
the tavern +3, and both files said in a comment that it was conjured. The
economy ran alongside that, decorative — money moved but nothing depended
on it.

Now the loop closes. Work pays a wage, the farm sells meals, and a hungry pip
walks to a shop and buys one. A pip that cannot afford food starves, which is
the first death in this simulation caused by economics rather than by a
missing building.

The behaviour lives in the core because every rule about how pips behave
does: the browser predicts with this same code, so a decision taken anywhere
else would make the client and the server disagree about what happens next.
Concretely a pip gains an *errand* — somewhere it is going of its own accord,
which outranks the commute. That is the first thing in this simulation a pip
decides for itself; everything else about it was decided by a service or by
the world.

Deliberately not a plan or a queue of goals. A pip is hungry or it is not, and
it re-decides every tick, so a shop that raises its price or a wage that
arrives late changes its mind with nothing to invalidate.

Prices reach the core the way capacity already does (ADR 0004): the workplace
owns the number, the gateway carries it on the registration intent, the core
enforces it. A pip deciding inside a tick whether it can afford lunch cannot
make a network call to ask.

`need_deltas` is deprecated rather than reserved. Step 7 asked for reserved
and that turns out to be impossible: `buf breaking` refuses the deletion, and
that rule is load-bearing, so the field stays on the wire and dies by disuse.
Nothing populates it. The farm and the tavern no longer have any opinion about
hunger — which is what makes the tavern's old food_per_tick = -1 bug
unrepresentable rather than merely fixed.

Covered by a test that runs 4,000 ticks of the full loop: a pip is hired, paid
in batches the way the gateway pays it, decides for itself when to stop
working and eat, and is still alive at the end with money in the bank and the
supply still closed.
@teceer
teceer deleted the branch feat/purchases-gated-by-the-core August 6, 2026 15:27
@teceer teceer closed this Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant