← Back to Pull requests

remote_fw_dram: re-send a refused start_write once with metadata (fixes #51) #52

Closed
unknown closed this pull request without merging on Oct 20, 2026 19:54 UTC
View on GitHub
unknown unknown commented on Sep 30, 2026 07:52 UTC
Author

Fixes #51

Problem

After a Guard promotion (or a replacement re-attaching at the same control endpoint) the first peer transfer from that endpoint is refused: the target still has the endpoint in _metadata_acked_sources, so its start_write omits target_agent_metadata; the new peer has no peer table for it, _remote_agent raises missing target agent metadata, the Guard sends write_refused, and the request misses (one full recomputation per peer after every takeover or replacement). _handle_write_refused already un-acked the endpoint so the next request republishes metadata — recovery was designed in, one request late.

Change

  • remote_fw_dram._handle_write_refused: after invalidating the endpoint, if the refused _TargetPullOp has not been retried yet, is still WAITING_WRITE_DONE and inside its deadline, put it back into START_WRITE. The progress loop re-sends the same start_write, now carrying target_agent_metadata (the endpoint is no longer acked), and the operation completes. A second refusal of the same operation is terminal as before (republished flag).

  • Guard's write_refused carries reason: "missing_target_agent_metadata".

  • Tests: new test_refused_start_write_is_resent_once_with_metadata; test_only_a_refusal_from_this_operation_s_source_finishes_it updated for the one retry.
  • Validation

    Unit: tests/unit/test_kvcr_remote_target.py, test_guard_integration.py, test_kvcr_service.py — 90 passed. test_promoted_guard_serves_real_nixl_transfers[1-False] fails on the test box identically without this change (pre-existing, real-NIXL local-pool read in the replacement phase), [2-True] passes.

    End to end (Guard takeover scenario: worker 0 commits a prefix, its engine is SIGKILLed, the Guard takes over its pool, worker 1 then requests the same prefix; Qwen3-0.6B, Guard mode, Dynamo --router-mode kv + kv_state_agent, this branch's src/kvcr on PYTHONPATH over image kvcr main 317e62f / Dynamo 8c226c9 / vLLM PR 53624 7015687c, dynamo-aws-dev-02, Linux 6.17):

    | Layout | Before | After |
    | --- | --- | --- |
    | single node, 2×H100, kvcr_service sidecar containers | first request to worker 1 after the takeover misses (cached_tokens=0, remote_deliver failed) | hit: first request cached_tokens=1408, 22 blocks / 161 MB delivered |
    | two nodes, 1×H100 each, etcd discovery, cross-node NIXL | same miss | hit, same |
    | Kill → first correct Guard-served hit | 5.7 s | 1.3 s (promotion itself 1.0 s, unchanged) |

    Before-fix numbers reproduce on every Guard run since 2026-09-25 across dlcluster single-container, dlcluster separate containers, and both Kubernetes layouts.

    Update (2026-10-13, rebased on main dbb832d)

    Review feedback addressed:

  • Re-send happens in poll_progress after this cycle's notifications are read, so a terminal write_done for the same op outranks the refusal (completed write kept, not retried).

  • Re-send only when write_refused carries reason: "missing_target_agent_metadata"; any other refusal stays terminal.

  • DCO sign-off, E501.
  • Relation to #73: #73 reloads NIXL peer metadata on the source side after a typed disconnect. This PR covers the target side after an endpoint takeover (first start_write sent without metadata). Re-verified on main dbb832d (which includes #73), Qwen3-0.6B, Guard mode, 2×H100. Scenario: worker 0 serves and commits a prefix, its engine is SIGKILLed, the Guard takes over its pool, then worker 1 receives a request with the same prefix.

    | | main | main + this PR |
    | --- | --- | --- |
    | First request to worker 1 after the takeover | miss (cached_tokens=0, remote_deliver failed) | hit (cached_tokens=1472, 23 blocks) |
    | Kill → first correct Guard-served hit | 2 attempts, 5.6 s | 1 attempt, 1.3 s |

    Diff: 480 lines (+360 / -120) across 6 files Reviewer: rishabhsinha17 Review duration: 29521m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.47) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.47 · 480 lines diff across 6 files
    0.47
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.369
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #52"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.3% (MEDIUM) · Higher = larger blast radius
    47.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.7% · Safe to merge
    18.7%
    Repository