fix: bound milestone lifecycle and event ordering - #1577
Merged
1nonlypiece merged 3 commits intoAug 30, 2026
Conversation
|
@Okibe2002 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Overview
This PR hardens the milestone lifecycle and event ordering path in
src/routes/milestones.tsandsrc/repositories/milestoneRepository.ts. It introduces explicit state, data, authorization, and failure invariants; enforces bounded pagination, polling, upload, and concurrency limits; prevents redundant state transitions; and adds sanitized structured diagnostics for latency, conflicts, retries, and recovery paths.Design tradeoffs: server-side transition validation and compare-and-set repository writes add a small per-request cost but guarantee monotonic ordering and safe duplicate handling. The in-memory concurrency limiter is per-instance; multi-instance deployments should move this to shared storage such as Redis. Remaining limitations: distributed rate limiting and durable idempotency-key persistence across restarts are not included in this PR and can be layered on without API changes.
Related Issue
Refs #
Changes
🛡️ State and ordering invariants
[ADD]
src/routes/milestones.tstransition guard409 Conflictand a structured error code.[ADD]
src/repositories/milestoneRepository.tscompare-and-set writerversionmatches the expected version.🚦 Bounded resource use
[ADD] Pagination and polling limits
page[limit]clamped to1..100;page[offset]capped at10_000.30s; violations return429 Too Many RequestswithRetry-After.[ADD] Request size and concurrency bounds
1 MiB; larger requests return413 Payload Too Large.50concurrent transition/idempotent requests per account or IP.📡 Observability and client efficiency
[MODIFY]
src/routes/milestones.tsemits sanitized structured diagnosticsreq_id,account_id,transition,duration_ms; never logs auth headers, tokens, or request bodies.[MODIFY] Client/state efficiency behavior via version-aware route responses
version/ETag, allowing clients to skip redundant fetch and re-render cycles.🧪 Test coverage
src/routes/__tests__/milestones.test.tsVerification Results
Refs #<issue-number>Closes #1524