Skip to content

ui-server: deleting unused journal objects scans every checkout receipt #4445

Open

Description

@schlessera

Part of #4426 (follow-ups from #4278). Deferred from the combined review of PR #4444; the code came from #4362.

Context

turn_journal_code_receipts.pack_hash references turn_journal_objects(hash) with no child index (packages/ui-server/migrations/096_code_change_receipts.journal.sql:6). collect deletes objects one by one (packages/ui-server/src/brain/journal-store.ts:124-131) during finish, while workers are held. Each delete's foreign-key check therefore scans the receipts table. The reviewer measured 243 ms against 2.8 ms for 2,000 deletes at 5,000 receipts.

Scope

Add an index on pack_hash, admitted within quota like the other derived journal indexes. No change to receipt semantics.

Acceptance criteria

  • EXPLAIN QUERY PLAN for the object delete's foreign-key check uses an index, not SCAN turn_journal_code_receipts.
  • A near-cap store keeps accepting writes when the index cannot be admitted.
  • A test with a mutation receipt covers both.

Activity

  1. added
    type: fixSomething is broken and must behave the way it is documented.
    area: ui-serverHono app factory: turn coordinator, auth, session catalog, routes, cron.
    priority: p3Someday. Needs a driving use case before it starts.
    agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.
    on Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.area: ui-serverHono app factory: turn coordinator, auth, session catalog, routes, cron.priority: p3Someday. Needs a driving use case before it starts.type: fixSomething is broken and must behave the way it is documented.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions