Apiary: a living starter hive fed by your habits #8

Merged
alex merged 13 commits from feat/apiary into feat/habit-management 2026-10-31 08:59:23 +01:00
Owner

Stacked on #7.

The first playable slice of the game: keep habits, the day closes, Rewards credits it, and the Apiary turns it into resources and a livelier colony.

Apiary context (backend):

  • Keeper (stores of nectar, pollen and honey in grams; items; vitality) and Hive (a queen with a six-trait genome and recognised species, colony strength, honey, capacity).
  • Hives settle lazily from elapsed time with ColonyPolicy v1. Honey depends on workers, productivity and vitality; the colony grows towards what vitality sustains. Nothing ticks on the server.
  • GetApiary settles stored figures to now with the policy (a pure function), without loading or saving aggregates.
  • OpenApiary (idempotent). A same-context handler of ApiaryOpened builds the starter hive: Andalusia, an Iberian queen.
  • Harvest takes 50% plus 5% per gentleness point of the hive's honey; a handler of HoneyHarvested credits the keeper once.
  • An anti-corruption layer consumes RewardGrantedV1 (stores, items) and VitalityChangedV1 (keeper, and every hive after settling at the old value).
  • Settlement rule vectors (11 cases), with expected values from an independent Python implementation, run by the server and the client.

Web (apiary feature):

  • The page opens the apiary on first visit and shows stores, the hive scene, honey and colony meters, production, harvest, and the queen's traits.
  • Honey rises on screen every second through the client copy of the colony rule.
  • Harvest is predicted at once (the hive empties by its share, the stores fill) and works offline.
  • Phaser 4.2.1 scene, drawn in code until there is art: sky and sun, hills, lavender rows, a straw skep, a honey jar. The bees fly hive-to-flower routes: more bees with more workers, faster with higher vitality. Tapping the hive harvests, with a floating "+N g".
  • The scene follows ARCHITECTURE 12.6: a host component owns the game; a bridge passes snapshots in and harvest intents out; no rules in the scene.
  • Phaser lives only in ui/src/game (new lint rule) and only in the apiary route's lazy chunk (about 300 kB transferred). The initial bundle is unchanged.
  • Design system: a hab-meter atom.

Fix: the dev proxy matched /api as a prefix, so the /apiary page went to the API. It now matches /api/ only (pitfall recorded in TOOLING).

Checked:

  • Browser: the scene animates; honey ticks up; tapping the hive harvested 793 g, which the server confirmed (3,913 g in stores).
  • Full chain for a new user: a kept habit, days closed by the job, Rewards credited 10 nectar and 15 pollen, which reached the apiary stores; vitality 47.15 reached the keeper and the hive.
  • All 37 projects pass lint, typecheck, test and build; integration tests pass for 6.

Not yet: breeding, biomes, spells, threats; rewards granted before this context existed are not replayed.

🤖 Generated with Claude Code

Stacked on #7. The first playable slice of the game: keep habits, the day closes, Rewards credits it, and the Apiary turns it into resources and a livelier colony. **Apiary context (backend):** - `Keeper` (stores of nectar, pollen and honey in grams; items; vitality) and `Hive` (a queen with a six-trait genome and recognised species, colony strength, honey, capacity). - Hives settle lazily from elapsed time with `ColonyPolicy v1`. Honey depends on workers, productivity and vitality; the colony grows towards what vitality sustains. Nothing ticks on the server. - `GetApiary` settles stored figures to now with the policy (a pure function), without loading or saving aggregates. - `OpenApiary` (idempotent). A same-context handler of `ApiaryOpened` builds the starter hive: Andalusia, an Iberian queen. - Harvest takes 50% plus 5% per gentleness point of the hive's honey; a handler of `HoneyHarvested` credits the keeper once. - An anti-corruption layer consumes `RewardGrantedV1` (stores, items) and `VitalityChangedV1` (keeper, and every hive after settling at the old value). - Settlement rule vectors (11 cases), with expected values from an independent Python implementation, run by the server and the client. **Web (apiary feature):** - The page opens the apiary on first visit and shows stores, the hive scene, honey and colony meters, production, harvest, and the queen's traits. - Honey rises on screen every second through the client copy of the colony rule. - Harvest is predicted at once (the hive empties by its share, the stores fill) and works offline. - **Phaser 4.2.1 scene**, drawn in code until there is art: sky and sun, hills, lavender rows, a straw skep, a honey jar. The bees fly hive-to-flower routes: more bees with more workers, faster with higher vitality. Tapping the hive harvests, with a floating "+N g". - The scene follows ARCHITECTURE 12.6: a host component owns the game; a bridge passes snapshots in and harvest intents out; no rules in the scene. - Phaser lives only in `ui/src/game` (new lint rule) and only in the apiary route's lazy chunk (about 300 kB transferred). The initial bundle is unchanged. - Design system: a `hab-meter` atom. **Fix:** the dev proxy matched `/api` as a prefix, so the `/apiary` page went to the API. It now matches `/api/` only (pitfall recorded in TOOLING). **Checked:** - Browser: the scene animates; honey ticks up; tapping the hive harvested 793 g, which the server confirmed (3,913 g in stores). - Full chain for a new user: a kept habit, days closed by the job, Rewards credited 10 nectar and 15 pollen, which reached the apiary stores; vitality 47.15 reached the keeper and the hive. - All 37 projects pass lint, typecheck, test and build; integration tests pass for 6. **Not yet:** breeding, biomes, spells, threats; rewards granted before this context existed are not replayed. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Keeper (stores, items, vitality from Rewards) and Hive (queen genome, colony,
honey) aggregates. Hives settle lazily from elapsed time with ColonyPolicy v1,
shared as rule vectors; harvesting takes the gentleness share and a handler
credits the keeper. Rewards' credited days and vitality arrive through an
anti-corruption layer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The apiary page opens the keeper's apiary on first visit and shows the stores,
a Phaser scene of the starter hive in Andalusia (bees by colony strength,
pace by vitality, a jar filling with honey, tap to harvest), the hive's honey
and colony meters, and the queen's traits. Honey rises on screen between
loads through the client copy of the colony rule, checked against the
Apiary's rule vectors. Phaser loads only with the apiary route and is kept
in ui/src/game by lint. The dev proxy now matches /api/ only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
alex added 11 commits 2026-10-31 08:59:16 +01:00
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Identity context wraps better-auth inside the API: email and password
accounts, external OpenID Connect providers from configuration, cookie
sessions, ULID user ids, tables in the identity schema planned by better-auth
and applied by our migrate step, telemetry off. A session actor resolver
feeds the existing ActorGuard; AUTH_MODE=dev keeps the header for scripts.
The web app gains sign-in, sign-up and account pages, guarded routes, a
session loaded before the first route, and refuses to sign out while changes
wait in the offline queue.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Breeding costs 15 pollen and raises a queen from a mother colony on an open
flight (Andalusia's wild drones) or a controlled one: half of each trait from
each side, seeded mutations, reproducible from the breeding's id. Queens wait
in a reserve and can head the hive; the replaced queen returns to the reserve.
New species are discovered along the way. Each step is its own transaction,
chained by the apiary's own events. The app breeds, installs, waits for the
server to catch up, and tints the bees with their queen's colours.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The hive scene becomes a floating voxel island in Andalusia: grass, dirt and
stone blocks, an olive tree, a lavender crop, and a wooden hive whose workers
beat their wings in their queen's colours. Every texture is painted at start-up
from pixel maps and scaled up without smoothing.

The whole Apiary page wears a new pixel skin from the design system: bevelled
panels, inventory slots, segmented bars, pixel buttons and notes, and the
Pixelify Sans font. A bee codex shows the species found so far. The look takes
after the Minecraft bee mods that inspired the game, with art of our own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The voxel island now fills the page at the largest whole-number scale that
still shows it, under a sky with distant islets. A heads-up display sits over
the scene: the hive and its harvest, the stores, a hotbar of menus, and the
biome. The queen, breeding, reserve and codex open as pixel drawers that slide
in from the left or the right; Escape closes them.

The design system gains hab-game-layout, hab-pixel-drawer and hab-slot-button,
and the pixel panel can go without a heading or with compact padding.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reviewed-on: https://git.selene.acl.sh/Habitea/App/pulls/12
Reviewed-on: https://git.selene.acl.sh/Habitea/App/pulls/11
Reviewed-on: https://git.selene.acl.sh/Habitea/App/pulls/10
Reviewed-on: https://git.selene.acl.sh/Habitea/App/pulls/9
alex merged commit 8841b79e35 into feat/habit-management 2026-10-31 08:59:23 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Habitea/App!8
No description provided.