Skip to content

fix: exclude stale candidates from /by_uids batch; document backfill behavior (COW-992)#91

Closed
lgahdl wants to merge 1 commit into
developfrom
luizhatem/cow-992-f13-deployed-api-has-structural-gap-in-historical-discrete
Closed

fix: exclude stale candidates from /by_uids batch; document backfill behavior (COW-992)#91
lgahdl wants to merge 1 commit into
developfrom
luizhatem/cow-992-f13-deployed-api-has-structural-gap-in-historical-discrete

Conversation

@lgahdl

@lgahdl lgahdl commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Perf fix: Stale candidates (validTo in the past) are now excluded from the C2 unconfirmed SELECT and its /by_uids batch. These were always misses — the stale sweep path (500/block, /account/{owner}/orders fallback) already handles them. Without this, every block during post-backfill catch-up fired a large /by_uids call for all remaining aged-out UIDs, wasting API quota until the drain completed.
  • Docs: Added "Cold-Start and Backfill Behavior" section to docs/deployment.md covering cold-start duration, /ready semantics, and the historical discrete-order gap explanation for integrators.

Root cause (F13 finding)

The structural gap (COW-992) arises because C2–C5 are live-only handlers. TWAP parts precomputed during backfill land in candidate_discrete_order with past validTo dates. When live sync starts, the stale sweep promotes them using /account/{owner}/orders as fallback (added in COW-989). This PR adds the missing query optimization and documents the behavior.

Test plan

  • pnpm typecheck — passes
  • pnpm test — passes
  • After reindex: verify historical TWAP parts are promoted with correct status (not all expired)
  • Review docs/deployment.md cold-start section for accuracy

Closes COW-992

🤖 Generated with Claude Code

…nt backfill behavior (COW-992)

Prevents redundant /by_uids calls for already-expired candidates on every
block during post-backfill catch-up. The stale path (account fallback, 500/block)
already handles these — excluding them from the unconfirmed SELECT eliminates
wasted API quota until the drain completes.

Also documents cold-start duration, /ready semantics, and the historical
discrete-order gap for integrators in docs/deployment.md.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@linear-code

linear-code Bot commented Jun 9, 2026

Copy link
Copy Markdown

COW-992

@lgahdl lgahdl marked this pull request as ready for review June 10, 2026 13:24
lgahdl added a commit that referenced this pull request Jun 10, 2026
@jeffersonBastos

Copy link
Copy Markdown
Contributor

Superseded by #102 (final-qadevelop). Verified that this PR's changes (COW-992) are fully contained in the consolidated final-qa branch. Closing to merge everything through the single QA branch per the agreed plan — no work is lost.

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