Skip to content

fix(convex): a work pool's completion handler writes through the app's triggers - #1618

Merged
sickerine merged 2 commits into
devfrom
fix/screening-counts-from-pool
Nov 28, 2026
Merged

sickerine merged 2 commits into
devfrom
fix/screening-counts-from-pool

Conversation

@sickerine

Copy link
Copy Markdown
Collaborator

Found by the cross-family review of #1617. This needs to merge, and its repair needs to run on dev, before #1617 switches Papers' counts to read the aggregate.

defineOnComplete builds its handler with Convex's own mutation builder, so its writes skip every trigger in convex/lib/triggers.ts. Three things go stale as a result:

Changes

  • withAppWrites in lib/functions.ts gives such a handler the same writes the app's builders give a mutation: through the triggers and the caps, with its counts queued when it ends. The three defineOnComplete handlers use it:
    • screening/readings:done
    • screening/files:done
    • screening/mutations:handleScreeningComplete
  • A model's vote is cast before bookkeeping works out its decision. Until then it counts under its own cast key, so the total of cast votes includes it, as the old query's did.
  • migrations/screeningFacets:readVotes removes the waiting counts such readings left and counts each vote as it stands. verify now finds those stale counts as well as missing ones.

After merging: push, then run npx convex run migrations/screeningFacets:run. Only readVotes is new; the earlier steps are already done. Wait for verify to return 0, then merge #1617 rebased on this.

Checks

  • tsc, check:convex-rules, check:module-weight and check:user-actions pass.
  • Vitest on screening, migrations, sharing and extraction: 685 pass.
  • New in convex/screening/facets.test.ts:
    • A model's readings come back failed or read, and its counts agree with its votes and the cards read whole. This fails without the wrapper.
    • A vote left counted as waiting is repaired by recountVote, after which verify finds nothing.

…s triggers

From the cross-family review of #1617. `defineOnComplete` builds its handler with Convex's own mutation builder, so
its writes skipped every trigger: a model's reading that came back left its vote counted as waiting in the
screening counts kept since #1616, and the pool's other completions skipped the cards and list counts the same way.

- `withAppWrites` (lib/functions.ts) runs such a handler with the writes the app's builders give a mutation:
  through the triggers and the caps, its counts queued when it ends. The three completion handlers use it.
- A model's vote is cast before the bookkeeping works out its decision: until then it counts as `cast`, so every
  vote cast is counted.
- migrations/screeningFacets:readVotes takes out the waiting counts such readings left, and counts each vote as it
  stands; `verify` now finds those stale counts too.
- facets.test.ts: a model's readings coming back failed or read keep its counts (fails without the wrapper), and the
  repair takes out what was left (verify 0).
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-28T08:46:25.097222Z 5b90920 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e8e7ce74-8cb7-4374-9c8f-18de2b9a0464
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

…tes that have waited again too

From the cross-family review of #1618: a vote left counted as waiting can wait again later (a new criterion asks
the model to read its paper once more), by when its paper may stand elsewhere, and then it counts twice. The repair
and verify skipped waiting votes. Both now look at every vote, and keep only the waiting count it should have.
@sickerine
sickerine merged commit 6849914 into dev Nov 28, 2026
6 checks passed
sickerine added a commit that referenced this pull request Nov 28, 2026
…a model's vote not yet decided

As the old count did: a model's vote is cast before the bookkeeping works out its decision, and is counted under
`cast` until then (#1618).
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.

1 participant