economylisted
Install: claude install-skill C-Aniruddh/lattice
# Economy
The whole package is one idea: **everything is linear between commits.** Gates, milestones,
purchases, nightfall and a stock hitting zero are the discontinuities, and every one of them is a
*boundary* — an instant at which the caller re-enters. That is what makes one integration of
fourteen hours equal to fifty thousand integrations of one second, and it is why offline progress
and live play are the same code path rather than two that drift.
**There is no tick, no clock and no state of its own.** Every call that moves the anchor takes a
required epoch timestamp, so a frame delta has nowhere to go — and a builder who sees `dt` in
`update()` and reaches for it will find no signature to put it in. That refusal is the design.
---
## A whole economy
```ts
import { asEpochMillis } from '@latticekit/core';
import {
advance, buildFlow, costOfNext, createFlow, defineEconomy,
elapsedSeconds, maxBuyable, project, zeroStocks,
} from '@latticekit/sim';
import type { CostCurve, Ledger } from '@latticekit/sim';
type Node = 'lamp' | 'coin';
type Gate = 'night';
let reach = 1; // a banked total: it changes only when the player acts
const eco = defineEconomy<Node, Gate>({
// `nodes` is the SAVE'S FIELD ORDER and it never changes. Append in v4 and every v1 save
// still deserializes with its fields where they were.
nodes: ['lamp', 'coin'],
gates: ['night'],
edges: [
// A SOURCE — no `from`. This is what an idle game's headline rate usually