Validate pending state against service history - #28148
Validate pending state against service history#28148Alex Villarreal (alexvy86) wants to merge 9 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Hi! Thank you for opening this PR. Want me to review it? Based on the diff (688 lines, 6 files), I've queued these reviewers:
How this works
|
There was a problem hiding this comment.
🟡 Changes recommended
Checkpoint normalization can prevent valid regression telemetry from being emitted.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds telemetry for service checkpoint sequence number regressions.
Changes:
- Emits
CheckpointSequenceNumberRegressiondiagnostics. - Adds regression telemetry coverage.
The telemetry currently reads a normalized checkpoint, which can conceal a lower service-provided checkpoint when initial messages advance it. Preserve the raw checkpoint or compare before normalization, and test this scenario.
File summaries
| File | Description |
|---|---|
packages/loader/container-loader/src/test/deltaManager.spec.ts |
Tests checkpoint regression telemetry. |
packages/loader/container-loader/src/deltaManager.ts |
Detects and logs checkpoint regressions. |
Review details
Suppressed comments (1)
packages/loader/container-loader/src/deltaManager.ts:530
- This comparison can run before sequence tracking is initialized.
Container.loadstarts the delta connection before fetching the snapshot/pending state (container.ts:1640-1670), whileattachOpHandlerassignslastProcessedSequenceNumberlater. If connection wins that race, this compares checkpoint 5 with the default 0, then attachment sets the value to 13 without rechecking, so the regression is never logged. Run the check after handler initialization as well (or defer it until then), with per-connection deduplication.
if (
checkpointSequenceNumber !== undefined &&
checkpointSequenceNumber < this.lastProcessedSequenceNumber
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6647abf5-9683-4d3e-b409-361125c99008
There was a problem hiding this comment.
🟡 Changes recommended
Two moderate test coverage gaps must be addressed before approval.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 2
- Review effort level: Balanced
|
Deep Review: For pending state, load-mode setup forces |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6647abf5-9683-4d3e-b409-361125c99008
|
Addressed the Container-level deep-review feedback in a0e39f5. The new local-server test drives the production pending-state load path, blocks the anchor fetch, verifies Container.load returns while validation is still pending, then releases a mismatched anchor and verifies the returned container closes. Validation remains deliberately asynchronous so pending-state rehydration does not acquire a network dependency before returning. |
|
Deep Review: Confirmed — the new local-server test ( |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6647abf5-9683-4d3e-b409-361125c99008
|
Deep Review: A live socket op can abort the anchor-validation storage fetch before the persisted anchor is re-read, so the overwritten-history check silently does not run on the common online-reconnect path.
The new integration test ( Fix options: fetch the anchor with a bounded range (e.g. Question for the author: is the anchor-validation fetch expected to survive a concurrent live-op reconnect, or is the online case intentionally allowed to skip overwritten-history validation? If the latter, that tradeoff should be documented. |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6647abf5-9683-4d3e-b409-361125c99008
|
[Agent-generated] Addressed in 53a7ab8. Live socket ops can cancel normal catch-up only after pendingStateAnchor has been re-read and compared, so the existing unbounded fetch remains cancellable without skipping the integrity check. The DeltaManager test now emits a live socket op while the anchor storage read is blocked, verifies the fetch signal remains active, then releases a mismatched anchor and verifies the overwrite error still closes the DeltaManager. |
|
Deep Review: Confirmed — the new |
Validate deferred pending-state connections against storage and detect content-only rewrites without including operation contents in telemetry. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6647abf5-9683-4d3e-b409-361125c99008
|
Deep Review: Confirmed — |
|
Deep Review: Confirmed — the anchor comparison now includes normalized |
Clear stale anchor validation state after an authoritative fetch cannot validate it, then continue catch-up from the next sequence number. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6647abf5-9683-4d3e-b409-361125c99008
Process socket-buffered ops before clearing an anchor that storage could not validate, preserving overwrite detection during connection-before-attachment races. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6647abf5-9683-4d3e-b409-361125c99008
Bundle size comparisonBase commit: Pending — |
Deep ReviewReviewed commit Readiness: 6/10 — MAKING PROGRESS Not ready for sign-off, but genuine forward progress: two of the three correctness bugs from the last review are resolved at this commit — the never-returned-anchor cleanup-before-drain false negative, and the Path to Ready
Context for Reviewers
For human reviewer
Review history (6 prior reviews)
|
Description
Pending-state rehydration previously restored the last processed sequence number but discarded the corresponding saved message and its minimum sequence number. As a result, it could not use DeltaManager's existing overwritten-history validation and only validated future minimum sequence numbers against the older base snapshot.
Pass the last saved op into DeltaManager so it:
This replaces the standalone checkpoint-regression telemetry because service checkpoints may legitimately lag and therefore are not independently actionable. The overlap validation remains deliberately asynchronous: pending-state rehydration does not wait for network access, but a mismatch closes the returned container once detected.
Tests cover matching and conflicting serialized saved-op anchors, raw checkpoint normalization with connection-before-attachment ordering, malformed saved-op minimum sequence numbers, and the production Container path that returns while validation is blocked and later closes on mismatch.
AB#82434
Reviewer Guidance
The review process is outlined in the pull request guidelines.
Please focus on using the last persisted op as the rehydration baseline for both overlap validation and minimum-sequence-number monotonicity, including the deliberately optimistic asynchronous validation behavior.