Skip to content

bug(polymarket): recover closed-lane Gamma discovery after bounded 500 #624

Description

@proerror77

Problem Statement

The production Polymarket reference collector cannot recover its fresh health record because Gamma returns HTTP 500 for the closed-market discovery request that combines the crypto tag with both end-date bounds. The collector exhausts its bounded HTTP retries, becomes stale, and systemd restarts it. This blocks the immutable baseline Gate and therefore the already-merged async uploader rollout.

Solution

Keep the existing tagged, bounded discovery request as the primary path. If and only if the closed-lane request exhausts its bounded retries with Gamma HTTP 500, retry the same closed date window without tag_id; retain the existing target-market eligibility checks and fail closed on every other error or an unsuccessful fallback.

User Stories

  1. As the data operator, I want the reference collector to survive Gamma's known closed-lane 500 response so that fresh reference data can resume.
  2. As a researcher, I want the fallback to retain the configured crypto 5-minute and 15-minute market eligibility rules so that unrelated market data is not admitted.
  3. As a runtime controller, I want authorization, client, and decoding failures to remain terminal so that a fallback cannot hide an integrity problem.
  4. As a deployer, I want a deterministic local proof of the primary 500 and fallback success path so that the production Gate remains evidence-driven.

Implementation Decisions

  • Keep the current tagged Gamma keyset query unchanged for normal closed-lane discovery.
  • Limit fallback activation to the observed exhausted HTTP 500 condition in the closed lane; do not broaden it to 4xx, authentication, timeout, decoding, or completeness failures.
  • Preserve both date bounds in the fallback query. Remove only the server-side tag parameter that participates in the failing combination.
  • Reuse the existing target-market eligibility rule as the admission boundary after discovery.
  • Keep collector configuration, uploader behavior, data retention, and the production Gate contract unchanged.

Testing Decisions

Out of Scope

  • Changing Gamma APIs, accepting partial discovery, loosening the stale-health/Gate policy, changing collection symbols or time windows, uploader changes, data deletion, and deploying the fix.

Further Notes

Live ECS readback on 2026-08-03 showed closed=true, tag_id=21, end_date_min, and end_date_max returning 500; open with the same bounds and closed without the tag returned 200. #533 remains the separate runtime-control issue.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingready-for-humanHuman implementation or judgment is requiredtrackingParent or PRD tracking issue; exclude from execution queues

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions