← Back to Pull requests

fix(controller): correlate model results by call ID #299

Open
unknown opened this pull request with 506 lines diff across 6 files
View on GitHub
unknown unknown commented on Nov 28, 2026 08:06 UTC
Author

Summary

  • correlate durable provider-result OUTPUT records with their MODEL_CALL IDs

  • keep direct harness output uncorrelated so handled provider fallback is never replayed as model success

  • preserve pre-v11 positional journals behind an explicit per-call compatibility mode and stamp SQLite schema v11
  • Fixes #93.

    Problem

    MODEL_CALL already had an ID, but its durable completion was an ordinary OUTPUT correlated only by position. Direct EventSink.Output produced the same shape.

    An in-process harness could therefore handle a provider error, emit fallback output, and crash before END. Replay or Resume would consume that fallback as the successful model response and enter a control-flow branch the original execution never took.

    Durable format

    New journaled calls carry:

    MODEL_CALL { id: C, result_correlation: BY_ID }
    OUTPUT     { model_call_id: C, message: ... }
    

    Direct harness output leaves Event.model_call_id absent. The field is proto-optional so absent and explicitly empty remain distinguishable; present-empty is malformed evidence.

    ModelCall.result_correlation is the compatibility discriminator. Markerless calls retain legacy positional behavior, because old calls already had nonempty IDs and absence of an output ID alone cannot distinguish an old completion from new direct output.

    Replay and recovery

    A shared matcher enforces:

  • BY_ID calls consume only an immediately adjacent OUTPUT with the exact nonempty ID

  • absent output ID after BY_ID is direct output and remains unconsumed

  • wrong, empty, or unknown correlation evidence is sticky ErrReplayDiverged

  • direct Output cannot consume a correlated model result

  • a trailing unanswered call is re-driven once and its completion reuses the original durable ID

  • markerless calls accept an old ID-less positional completion or an exact upgraded result
  • A failed re-drive of a pre-v11 positional call cannot immediately append direct fallback output: that would create a newly ambiguous journal. The host fails closed before the fallback append. A fresh model-call retry is still allowed because it records a new BY_ID call first.

    Compatibility

    SQLite schema v11 is stamp-only:

  • no table or event is rewritten

  • old records preserve bytes, hashes, and positional behavior

  • old binaries reject v11 cleanly at Open instead of dropping the new hash-bound fields

  • operators must stop older writers/embedded clients and back up the database and WAL before first v11 open

  • rollback requires restoring the backup
  • Tests

    Coverage includes:

  • provider failure + direct fallback + crash, with zero provider calls during Resume/Replay

  • exact, empty, wrong, and unknown correlation evidence in Replay and Resume

  • sticky divergence after a harness swallows the first error

  • direct output refusing correlated result evidence

  • trailing re-drive retaining the original call ID

  • same-run retry producing a distinct BY_ID call and result

  • pre-v11 positional replay

  • failed pre-v11 re-drive refusing immediate fallback while permitting a fresh correlated retry

  • optional-field wire presence and hash binding

  • Go/Python canonical interop vectors for correlated calls and results

  • v10-to-v11 stamp-only migration preserving raw event rows and schema
  • Verification

  • go test -race -shuffle=on ./controller ./wire ./canon ./sqlitelog

  • go test -race -shuffle=on ./session ./placement ./conformance ./harnesswire

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

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

  • go build ./...

  • go vet ./...

  • buf lint

  • buf breaking --against ".git#tag=v0.4.0,subdir=api"

  • go run ./hack/doccheck

  • ./hack/verify_chain.sh

  • gofmt -l .

  • git diff --check
  • The repository-wide root test command still reaches the pre-existing Python 3.9 portability failure in internal/agentsessionsd.TestDocumentedPythonExecutorLogsStorageFailureWithoutPayload; all changed and dependent packages pass, including race-enabled tests.

    Diff: 506 lines (+379 / -127) across 6 files Reviewer: aramase Review duration: 1242m
    All Vouch review confidence checks passed
    Residual risk 0.25 = Change Risk (0.48) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 506 lines diff across 6 files
    0.48
    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%
    46%
    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.373
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #299"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% 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.6% (MEDIUM) · Higher = larger blast radius
    47.6%
    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: 46.7% · Lower = rushed or shallow review
    46.7%
    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: 25.4% · Safe to merge
    25.4%