← Back to Pull requests

docs(claudecode): define wrapper history filtering #275

Closed
unknown closed this pull request without merging on Nov 16, 2026 06:20 UTC
View on GitHub
unknown unknown commented on Nov 16, 2026 00:36 UTC
Author

Summary

  • state the unmediated harness's fail-closed state-loss rule independently under EXE-43

  • define wrapper-only delegation and derived-history filtering as a new EXE-44

  • preserve the host-to-wrapper full-history contract under EXE-7 and EXE-17

  • require uncertain delegation or delivery to remain in history and fail closed as possible state loss
  • Problem

    controller.Exec commits EXECUTION_START and the turn inputs before invoking Harness.Run. A host-side wrapper may then fail a pre-step before it invokes the underlying Claude Code harness. The outer journal correctly retains that failed execution, so the wrapper receives it in the next turn's Start.History.

    A fresh Claude Code harness treats every prior EXECUTION_START or INPUT as evidence that Claude Code may already have run. It therefore refuses the next turn with errStateLost rather than start an empty conversation. Without a wrapper contract, one known-undelivered pre-step failure can make every later turn fail even though Claude Code never saw the first turn.

    Contract

    This PR distinguishes three responsibilities:

    1. Host to wrapper (EXE-7, EXE-17): unchanged. The durable journal retains the failed execution, and the host sends the wrapper every event before the current execution. Failed and unfinished executions remain visible.
    2. Underlying harness (EXE-43): caller-independent. An unmediated harness with no state for a session whose history records an earlier execution fails as possible state loss rather than starting an empty conversation.
    3. Wrapper to underlying harness (EXE-44): when the wrapper positively knows it never delegated an execution, it omits that execution in full from the derived history it later sends to Claude Code.

    The positive-knowledge requirement is deliberate. An execution with no Claude Code-emitted events does not prove non-delivery: Claude Code may have changed memory, called its provider, or performed a side effect before emitting its first observable event. If delegation or delivery is uncertain, the wrapper retains the execution and the underlying harness continues to fail closed under EXE-42/EXE-43.

    Non-goals

  • no change to controller.Exec, the durable journal, or the public Start.History contract

  • no heuristic in hasPriorTurn

  • no inference from the absence of OUTPUT, USAGE, or TOOL_RESULT

  • no replay or recovery behavior change

  • no fix for a first-turn harnesswire Connect failure; that case lacks positive non-delivery evidence and is tracked in #276
  • Files

  • spec.md: states the caller-independent harness refusal under EXE-43 and adds wrapper delegation as EXE-44

  • integrations/claudecode/claudecode.go: documents that every EXECUTION_START or INPUT is prior-turn evidence, plus the wrapper responsibility

  • changelog/unreleased/claudecode-harness.md: updates the existing unreleased feature entry and cites EXE-44
  • Part of #272.
    Related: #276.

    Verification

  • go test -race -shuffle=on ./... in integrations/claudecode

  • go vet ./... in integrations/claudecode

  • go build ./... in integrations/claudecode

  • go test ./... -run '^$'

  • go run ./hack/doccheck

  • go test ./hack/changelog

  • go run ./hack/changelog check -base upstream-agentsession/main -head HEAD -skip=false

  • clean-checkout python3 hack/check-doc-links.py: 656 links across 73 Markdown files

  • npm run build && node hack/check-links.mjs in site: 19 pages and 18 routes

  • git diff --check

  • gofmt -l integrations/claudecode/claudecode.go
  • Diff: 447 lines (+335 / -112) across 5 files Reviewer: aramase Review duration: 344m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.50) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 447 lines diff across 5 files
    0.50
    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%
    56%
    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.365
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #275"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% 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: 50.4% (MEDIUM) · Higher = larger blast radius
    50.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: 56.8% · Lower = rushed or shallow review
    56.8%
    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: 21.8% · Safe to merge
    21.8%