fix: make scaling_decisions cumulative via Redis sorted set history#24
Merged
Conversation
…ision_history_max) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ecentDecisions) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…luster summary Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
SystemMetrics::limits()->availableCpuCores() returns int, not float. Correcting the property type eliminates a PHPStan property.unusedType error. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Batch zadd, zremrangebyscore, and zremrangebyrank into a single eval round-trip to reduce Redis latency per decision recording.
CPU cores are fractional (0.5, 1.8, etc.) — the ?float type is correct. Add property.unusedType to the PHPStan baseline instead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves #23 —
scaling_decisions[]in the cluster summary was per-cycle (rebuilt every ~5s evaluation tick, lost when activity stops). Dashboard cards like "Total Decisions" showed0on idle clusters that had been scaling for hours.zadd'd toqueue-autoscale:cluster:{app-id}:decisions:historywithmicrotime(true)as scorezremrangebyscore, default 1 hour) + count-based (zremrangebyrank, default 10k entries) prevents unbounded growthevalto minimize Redis round-tripsbuildClusterSummarynow reads fromrecentDecisions()instead of the ephemeral per-cycle arraydecision_history_secondsanddecision_history_maxconfig keys with env var supportNo API break.
scaling_decisions[]keeps the same structure, just gains arecorded_atfloat and historical entries. queue-monitor dashboard cards will populate immediately on upgrade — no consumer-side changes needed.Test plan
ClusterStore::recordDecision()/recentDecisions()(record, retrieve, empty state, timestamp, accumulation, time pruning, count pruning, key pattern, score range, malformed JSON, Lua atomicity)buildClusterSummary🤖 Generated with Claude Code