Detect and emit any post-listing edit to a market's resolution rule.
3. Why This Bot Matters
Resolution rule edited under an open position
If a market's rule changes after a strategy entered, the basis for that trade may no longer exist. Without monitoring, the position is held through the change without anyone on the team being told.
Cosmetic vs semantic edits not distinguished
Many edits are punctuation or formatting; a few are substantive. Treating all edits the same either floods operators with false alarms or misses the one that matters.
Audit trail of rule history missing
Compliance and dispute reviews require a full history of every rule change with timestamps. Polymarket's UI does not expose this; the monitor builds the record the team needs.
Strategies can't auto-pause on rule change
A strategy that reads a rule-change event can decide to flatten or hold automatically. Without the event, the team is the only line of defence and must catch every edit by hand.
4. Required Polymarket Inputs
Input
Source
Required?
Use
Active market resolution_rules and question text from Gamma API
gamma
Yes
Fetch current rule text for comparison against stored snapshot hashes.
5. Required Internal Inputs
Input
Source
Required?
Use
KillSwitch active flag
KillSwitch
Yes
Suppress all emissions when KillSwitch is active.
Last known rule snapshots from Postgres
Postgres
Yes
Baseline for hash comparison to detect rule changes.
6. Parameter Guide
Parameter
Default
Warning
Hard
What it controls
poll_interval_s
300
900
3600
Seconds between full market rule snapshot comparison cycles.
max_markets_per_cycle
500
800
1000
Maximum number of active markets to compare per poll cycle to bound Gamma API load.
7. Detailed Parameter Instructions
poll_interval_s
What it means
Seconds between full market rule snapshot comparison cycles.
Default
{ "poll_interval_s": 300 }
Why this default matters
300 s provides timely detection of rule changes on live markets without overloading Gamma.
Threshold logic
Condition
Action
interval <= 300 s
Normal
300–900 s
WARN — reduced detection speed for rule changes
> 3600 s
Reject — PARAMETER_CHANGE_REQUIRES_APPROVAL
Developer check
if (p.poll_interval_s > p.hard) throw ConfigError('PARAMETER_CHANGE_REQUIRES_APPROVAL');
User-facing English
Resolution rules are monitored regularly to catch any changes to active markets.
max_markets_per_cycle
What it means
Maximum number of active markets to compare per poll cycle to bound Gamma API load.
Default
{ "max_markets_per_cycle": 500 }
Why this default matters
500 covers all active Polymarket markets without risking API rate limits.
Threshold logic
Condition
Action
count <= 500
Normal
500–800
WARN — approaching API rate limit
> 1000
Reject — PARAMETER_CHANGE_REQUIRES_APPROVAL
Developer check
if (p.max_markets_per_cycle > p.hard) throw ConfigError('PARAMETER_CHANGE_REQUIRES_APPROVAL');
User-facing English
Rule monitoring is designed to scale with the number of active markets.
The resolution conditions for this market were updated. The system flagged this change and paused new entries until the update was acknowledged.
No rule change detected during routine monitoring
All active market rules were verified to be unchanged in the latest monitoring cycle.
18. Failure-Mode Block
main_failure_mode
Gamma API outage prevents rule comparison for active markets, causing strategy layer to operate with potentially outdated resolution rule awareness during the outage window.
false_positive_risk
Minor non-substantive formatting changes (whitespace, punctuation) to rule text cause a rules_hash change and trigger a false rule-change alert.
false_negative_risk
Gamma API returns a cached stale response during a legitimate rule change, causing RuleChangeMonitor to miss the change until the cache expires.
safe_fallback
If Gamma API is unavailable for > poll_interval_s * 2, emit STALE_DATA WARN and suspend rule comparisons. Retain all last known snapshots in Postgres. Resume on next successful poll.
required_dependencies
Polymarket Gamma API, KillSwitch active flag, Postgres for rule snapshot and audit log
19. Failure-Injection Recipes
Scenario
How to inject
Expected behaviour
Recovery
GAMMA_API_DOWN
Block Gamma API for 30 min
Automatic on Gamma recovery; full comparison on first successful poll
RULE_CHANGE_INJECTION
Modify resolution_rules in mock Gamma for a live condition_id
Automatic once change acknowledged; snapshot updated
KILL_SWITCH_ON
Set killswitch.active=true during active monitoring
Automatic on KillSwitch reset
20. State & Persistence
Cold-start recovery
On cold start, reload all snapshots from Postgres; run full comparison on first cycle.
Adversary manipulates Gamma API response to inject false rule-change signals
High-frequency rule updates flood RuleChangeMonitor with WARN events
Mitigations
Postgres audit log provides tamper-evident record of all rule changes
Alert thresholds prevent single-event paging from minor text edits
24. Polymarket V2 Compatibility
Aspect
Value
CLOB version
v2
Collateral asset
pUSD
EIP-712 Exchange domain version
2
Aware of builderCode field
no
Aware of negative-risk markets
no
Multi-chain ready
no
SDK used
py-clob-client-v2
Settlement contract
CTFExchangeV2
Notes
Monitors Gamma API for resolution rule and question text changes across active markets. Read-only. No order signing.
API surfaces declared
gammainternal
Networks supported
polygon
25. Versioning & Migration
Field
Value
spec
2.0.0
implementation
0.1.0
schema
2
released
None
planned_release
Q3-2026
Migration history
Date
From
To
Reason
Action taken
2026-04-28
n/a
v2-spec
Spec drafted post-CLOB-V2 cutover; bot not yet implemented
Designed against V2 schema (pUSD, builder codes, V2 EIP-712 domain)
26. Acceptance Tests
Unit Tests
Test
Setup
Expected result
Rule change detected and ObservationReport emitted
rules_hash changes between two consecutive polls for the same condition_id
ObservationReport emitted with change_type=resolution_rules, old_hash, new_hash
No change: no ObservationReport emitted
rules_hash identical between polls
No ObservationReport; no alert
KillSwitch suppresses emission
killswitch.active=true; rule change present
No ObservationReport; KILL_SWITCH_ACTIVE logged
Integration Tests
Test
Expected result
Rule change detected, emitted, consumed by strategy layer for re-evaluation
Strategy receives ObservationReport with change_detected=true and affected condition_id
Gamma API down: STALE_DATA emitted; snapshots retained in Postgres
STALE_DATA WARN; all last-known snapshots preserved; monitoring resumes on recovery
Property Tests
Property
Required behaviour
RuleChangeMonitor never submits or signs orders
Always true
Postgres audit log receives an entry for every detected rule change
Always true
27. Operational Runbook
RuleChangeMonitor alerts on resolution rule or question changes. Any rule change during a live position must be reviewed immediately. Postgres audit log is the compliance record.
On-call actions
Alert
First step
Diagnosis
Mitigation
Escalate to
RuleChangeMonitorRuleChanged
Identify condition_id from alert payload. Verify rule change on Polymarket.com. Notify strategy team if positions are open on this market.
Intelligence pod lead immediately; market operations if change is unexpected
RuleChangeMonitorStale
Check Gamma API health. Verify Postgres connectivity. Trigger manual resync if API is healthy.
Intelligence pod lead if stale > 30 min
Manual overrides
force_resync — POST /internal/rulechangemonitor/resync to force full snapshot comparison on all active markets — After Gamma API recovery or suspected missed changes
Healthcheck
Endpoint: /internal/health/rulechangemonitor | Green: Last poll < 30 min ago AND Postgres reachable AND Gamma API returning 200 | Red: No poll for > 1 h OR Postgres unreachable
28. Promotion Gates
A bot does not advance to the next readiness state until every gate below is green. Gates are observable from production data — no subjective sign-off.
Promote to Shadow
Gate
How measured
Threshold
Unit tests pass for rule change, question change, and KillSwitch suppression
CI test run
100% pass
Promote to Limited live
Gate
How measured
Threshold
Full snapshot comparison of 500 active markets completes in < 20 s on staging
Integration test
Completion time < 20 s
Promote to General live
Gate
How measured
Threshold
100% detection of synthetic rule changes over 7-day soak