Files
gastown/internal
Julian Knutsen 4bbf97ab82 fix(costs): query all beads locations for session events (#374)
* test(costs): add failing test for multi-location session event query

Add integration test that verifies querySessionEvents finds session.ended
events from both town-level and rig-level beads databases.

The test demonstrates the bug: events created by rig-level agents (polecats,
witness, etc.) are stored in the rig's .beads database, but querySessionEvents
only queries the town-level beads, missing rig-level events.

Test setup:
- Creates town with gt install
- Adds rig with gt rig add (separate beads DB)
- Creates session.ended event in town beads (simulating mayor)
- Creates session.ended event in rig beads (simulating polecat)
- Verifies querySessionEvents finds both events

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(costs): query all beads locations for session events

querySessionEvents previously only queried the town-level beads database,
missing session.ended events created by rig-level agents (polecats, witness,
refinery, crew) which are stored in each rig's own .beads database.

The fix:
- Load rigs from mayor/rigs.json
- Query each rig's beads location in addition to town-level beads
- Merge and deduplicate results by session ID + timestamp

This ensures `gt costs` finds all session cost events regardless of which
agent's beads database they were recorded in.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: julianknutsen <julianknutsen@users.noreply.github>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 23:03:50 -08:00
..