← Back to Pull requests

Restore persisted DSH sessions in governed Turns #9694

Open
unknown opened this pull request with 635 lines diff across 7 files
View on GitHub
unknown unknown commented on Dec 01, 2026 01:37 UTC
Author

Goal And Delivered Outcome

An ordinary governed DSH Turn can continue its native session across processes. When the native transcript goes missing, the Turn returns a concrete recovery action before requesting model input, running independent task validation, or spending a quota slot. An authorized fresh Turn can establish the replacement session and the following Turn can continue it.

普通 DSH Turn 可以跨进程续接会话。历史丢失时,Turn 在请求模型、独立验收和扣账前停止,并给出可执行的恢复动作。获准的新一轮可以建立新的会话,后续 Turn 可继续该会话。

Author Declaration

  • Written by: model_agent · OpenAI GPT-6 (Codex)
  • Implemented against

  • The Cross-Iteration Context Policy, Adapter Requirements and settlement invariants. LoopX Governed Turn v0

  • The published DeepSeek Harness Python SDK and bundled runtime 0.2.2rc2. DSH SDK restoration reference
  • | Criterion | Delivered behavior | Verification |
    | --- | --- | --- |
    | Plan and dispatch the same ordinary DSH session | The detailed built-in plan projects cold start or compatible binding without starting the SDK. The built-in and v1 stdio adapters verify native restoration at dispatch. | Cold/warm plans, native read and independent artifact validation in fresh processes. |
    | Supervise session loss and recovery | A profile-bound opaque record distinguishes a first launch from missing known history. The built-in host reports session_missing. Stdio returns iteration_failed and exposes its recovery action in JSON and Markdown. | Both transports stop on transcript loss before a provider request, writeback or debit. A fresh Turn succeeds and the following Turn observes that fresh session's prior result. |
    | Preserve original transaction recovery | Automatic session lookup keeps the cold transaction key for unchanged work. Explicit --resume-turn-key and --resume-turn-instance-id replay the original journal across a work frontier change. | Both original locators replay without additional provider input or debit. Retargeting a replay is refused. |
    | Keep authority scoped to the Work Contract | The host stores only its opaque session identity. Goal, Todo and profile boundaries still apply to dispatch. | Changed-model, corrupt-history, stopped-Goal and legacy pinned SDK cases. |

    Scope And Continuation

  • The tested SDK pair uses a Messages-compatible endpoint. The LoopX optional extra currently pins 0.1.5rc1. The pinned pair still runs a fresh governed Turn and reads a workspace file. The ordinary adapter and managed operation transport have separate session records. DSH connector guide

  • A generic plan has only the generic adapter contract. Its DSH-specific session lookup happens inside the adapter at dispatch. After known history loss, start a separately admitted Turn with --iteration-context fresh. To recover a lost Turn reply, use the original journal locator.

  • Eligibility to resume a native session only establishes local session continuity. Shared captured-file delta delivery, provider caching and live-model cost still require evidence. Host harness capability work
  • Validation

  • Tested revision: 122a203f8a492d2f1a825ac0ad45823d00d27b14 against 1bdf851e9447bc7c22ab29d10948a674bf4687c4.

  • Run state: finished.

  • Input classes: synthetic.
  • | Check kind | Result | Public-safe evidence |
    | --- | --- | --- |
    | real_entrypoint | passed | Isolated installed turn plan, turn run-once --host dsh, and the v1 stdio adapter. A subsequent model input includes the first native result and an independent file witness read using the SDK's workspace tool. Two successful Turns settle two debits. |
    | real_backend | passed | Published SDK and bundled runtime on Linux arm64 with an isolated loopback model endpoint. LoopX wheel SHA-256 f5868be4010a50c39218bdbd224036c7d839d1e8c66ae6eea77e7cd8c440f456. |
    | regression_parity | passed | Eight packaged cases cover valid continuation, loss, fresh recovery, exact replay, profile changes, corrupt history, Stop and a fresh read on the pinned SDK. The loss itself adds zero model requests and zero debits for each transport. |
    | unit | passed | 423 focused exact-head tests passed. |
    | static | passed | Local premerge and exact-scope change-quality receipt cqr_4611a532b9a192d6d1ac. One existing advisory in loopx/status.py reproduces on the unchanged base. |

    Frontend / Visual Evidence

  • UI impact: none. The affected product readback is the CLI.
  • Type And Area

  • Bug fix, documentation and regression tests. Host or runtime integration.
  • Boundary Checklist

  • Public-safe diff and description.

  • One governed DSH continuity and recovery change.

  • No paired RFC or UI changes.

  • Both commits include DCO sign-offs.
  • Diff: 635 lines (+476 / -159) across 7 files Reviewer: loopx-agent Review duration: 163m
    All Vouch review confidence checks passed
    Residual risk 0.32 = Change Risk (0.55) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.55 · 635 lines diff across 7 files
    0.55
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    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.386
    Shallow Review Depth shallow_review_depth
    0.344
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #9694"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% 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: 55.4% (MEDIUM) · Higher = larger blast radius
    55.4%
    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: 43.0% · Lower = rushed or shallow review
    43.0%
    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: 31.6% · Safe to merge
    31.6%