Skip to content

hydrator: narrow EventsRepo.listUsageEvents to payload type in (turn_en… - #1195

Merged
warren-auto-merge[bot] merged 6 commits into
mainfrom
warren/run_g6scmbhhewqn
Sep 3, 2026
Merged

warren-auto-merge[bot] merged 6 commits into
mainfrom
warren/run_g6scmbhhewqn

Conversation

@warren-run-bot

Copy link
Copy Markdown
Collaborator

Summary

warren-5dd5: narrow EventsRepo.listUsageEvents to payload type in (turn_end, result)

Run

  • Warren run: run_g6scmbhhewqn
  • Agent: pi
  • Cost: $0.251 (34.7k in / 6.5k out / 1.2M cache-r)

Seeds

  • warren-5dd5 — hydrator: narrow EventsRepo.listUsageEvents to payload type in (turn_end, result) on both dialects and stop selecting agent_end transcripts; add a regression test pinning the row set

Commits (2)

  • ce3081a warren-5dd5: narrow EventsRepo.listUsageEvents to payload type in (turn_end, result)
  • 1e3da2e mulch: update expertise

Files changed

src/core/usage-shape.ts     |  9 ++++++++
 src/db/repos/events.test.ts | 51 +++++++++++++++++++++++++++++++++++++++++++++
 src/db/repos/events.ts      | 16 ++++++++++++++
 3 files changed, 76 insertions(+)

Prompt

Show prompt
Work seeds issue warren-5dd5. First run `sd show warren-5dd5 --json` from the repo root; the issue body is the spec, this is only a digest.

Context: plan pl-6076 (Outgrow Supabase). The sibling hydrator step warren-b33e (persist derived cost back to runs) is in PR #1194 on branch warren/run_2p5vxqthybqk and may merge before you finish; it changes src/runs/usage-hydrate.ts and the RunsRepo, not events.ts. Nothing else from the plan touches your files. Keep this change inside src/db/repos/events.ts (both dialects), src/core/usage-shape.ts (export the envelope type list once, import it into the repo), and tests.

Scope: add a payload-type predicate to EventsRepo.listUsageEvents so it returns only the usage envelopes the aggregator reads: Postgres `payload_json->>'type' IN ('turn_end','result')`, SQLite `json_extract(payload_json,'$.type') IN (...)`; source the list from usage-shape.ts so they never drift. Keep the EventRow shape unless trimming columns is trivially safe. Do not add an index speculatively. Regression test on both dialects: seed a run with one of each envelope type (turn_start, turn_end, tool_execution_start, tool_execution_end, message_*, agent_end, result) and assert exactly the two usage envelopes come back.

Quality gates are terminal: `bun run check:all` must be green before you commit and report done. Close the issue with `sd close <id> --reason "<what you did, citing files>"` (substitute the issue id), then commit everything (including .seeds/). Do not push to any branch other than your workspace branch; warren opens the PR.


🤖 Opened by warren run run_g6scmbhhewqn

…rn_end, result)

- src/core/usage-shape.ts: export USAGE_ENVELOPE_TYPES derived from the
  declared shapes so the SQL predicate and the in-process readers share
  one list
- src/db/repos/events.ts: add the dialect-branched payload-type predicate
  (pg payload_json->>'type', sqlite json_extract) to listUsageEvents; row
  shape unchanged, no speculative index
- src/db/repos/events.test.ts: regression test seeding one of each
  envelope type plus off-carrier decoys, asserting exactly the two usage
  envelopes return
@warren-auto-merge
warren-auto-merge Bot enabled auto-merge (squash) September 3, 2026 05:19
@warren-auto-merge
warren-auto-merge Bot merged commit 032a67f into main Sep 3, 2026
8 of 9 checks passed
@warren-auto-merge
warren-auto-merge Bot deleted the warren/run_g6scmbhhewqn branch September 3, 2026 05:27
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.

2 participants