Skip to content

fix(pm-gate): real-market preflight budget too small for tick-level segments #586

Description

@proerror77

Summary

REAL_MARKET_PREFLIGHT_BUDGET_SECONDS = 1200 in polymarket-raw-ops-shadow-gate.sh was sized when the largest observed hourly market segment was ~109MiB. Tick-level recording (quote_sample_ms = 0) produces 7.7–18GB hourly segments, and the preflight's full-file passes (jq quote count + recorded-hours scan + candidate validate/compress/upload/readback) exceed 1200s, so the worker is SIGKILLed and the gate dies with candidate rejected a real production closed market segment before shadow startup — a timeout, not a validation rejection.

Observed 2026-08-02, gate invocation 7c44f5f1b00041b48f21315e4bf7ed2b (candidate 5aa208a1): 20min10s wall ≈ exactly the 1200s budget, 10m58s CPU, no preflight upload reached OSS.

Context / workaround used

Gate was unblocked operationally by parking the multi-GB segments (/data/monday/spool/polymarket-parked/) and producing a small recorder-closed segment (~1.4GB, two bounded recorder restarts) so the preflight fits the budget. The parked segments return to the spool after cutover; the fixed uploader (#584) retries them.

Change contract (proposal)

The market preflight must prove candidate upload correctness on a real segment without scaling cost with tick volume. Options:

  • Bound the preflight scan (e.g., validate a deterministic head+tail window of the segment plus full-file cheap checks) — strongest fix, keeps coverage meaningful;
  • Or pick the smallest closed segment instead of the latest;
  • Or scale the budget from the picked segment's size with an explicit upper bound (weakest — a 20GB hour still costs 30+ min of gate time).

Any option needs a counterexample test: a >1200s-budget-sized synthetic segment must not make the preflight exceed its deadline.

Out of scope

Acceptance

  • Gate passes with a multi-GB latest closed segment in the spool, without manual parking.
  • Counterexample test for the budget/scan bound.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingready-for-agentFully specified and safe for an autonomous agent

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions