← Back to Pull requests

fix(core/agent)!: make the driver's store contract true, and drop Task.History #789

Closed
unknown closed this pull request without merging on Nov 24, 2026 13:10 UTC
View on GitHub
unknown unknown commented on Nov 24, 2026 13:05 UTC
Author

Two claims that the code did not keep

agent.Saver was not the driver's contract. It was documented as "the narrow half of Store, so a driver cannot compact the log or delete a task", and RunTurn derived it from Request.Store. But Request.Store also handed the whole Store to every driver: the graph saves its own sections and compacts through TruncateThrough, and nothing prevented a driver from List, Delete or TruncateEvents. A claim enforced only by a comment is a claim a third-party driver gets wrong.

Task.History was a field nothing could fill. Every store nilled it on save and on load; the event log is documented as the transcript's only source, and carrying it in the projection is what made a save cost O(n²) bytes. Since #787 the decorator also writes message records, so the honest answer to "where is the conversation?" exists and the field was answering it with a lie.

The change

// core/agent
type DriverStore interface {
    Save(ctx, Checkpoint, []EventRecord, ...SaveOption) (first, last int64, err error)
    Load(ctx, taskID string) (Checkpoint, error)
    LatestForSession(ctx, sessionID string) (Checkpoint, error)
    EventsAfter(ctx, taskID string, after int64) ([]EventRecord, error)
    PutBlob(ctx, data []byte) (string, error)
    GetBlob(ctx, ref string) ([]byte, error)
}
func DriverStoreOf(store Store) DriverStore

  • Request.Store carries it; Request.Saver and agent.Saver are gone, so there is one field and one answer.

  • What is deliberately absent is what no driver may do: Events, List, Delete, TruncateEvents, SetServerVersion.

  • LatestForSession is included: the graph carries declared state keys from the session's previous task, so a driver bound to one conversation needs its own resume point.

  • DriverStoreOf is the adapter the host applies — the narrowing happens where the full store lives. Stores that already satisfy both (agenttest.MemStore, checkpoint.SQLite) are handed over directly, and each now asserts it.

  • Task.History and every reference to it are removed; the conformance suite, the SQLite test and docs/guides/checkpoint.md now say the projection carries where the run stands and the log carries the transcript.
  • Side effect in agent/a2a: the round-trip record moves into the same Save as the peer's identity. One commit per proxied call instead of two, and no window where the peer task exists without the record of the call. Its old path appended through a fresh projection, which would have clobbered the task state the decorator writes last.

    Breaking changes

  • agent.Saver removed; Request.Saver removed; Request.Store is agent.DriverStore

  • Task.History removed

  • graph.WithStore takes agent.DriverStore
  • Callers holding a full store pass agent.DriverStoreOf(store), or the store itself when it already satisfies the narrow contract.

    Tests

  • TestDriverStoreOfIsTheDriversHalf: the adapter delegates Save (including the compaction option that is the reason Save takes options), EventsAfter, LatestForSession and both blob calls, and a nil store narrows to nil.

  • Compile-time assertions for both in-tree stores.

  • The SQLite "projection does not grow with the transcript" test keeps its property without the removed field: 50 message records, body size unchanged, Load returns the projection.

  • The conformance suite's projection test now asserts what a projection is (identity + the facts in the log) instead of that history is empty.
  • docs/guides/checkpoint.md gets the two lines this change makes wrong — the Task.History claim and a paragraph on the driver's half — and nothing else (the rest of the guide is still pre-rewrite and wants its own pass).

    Verification

    make ci (vet + tests + GOWORK=off consumer build), make lint (0 issues), make release-check, git diff --check. No release changeset: nothing is being tagged here.

    Diff: 493 lines (+369 / -124) across 6 files Reviewer: github-actions[bot] Review duration: 4m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.47) × (1 − Review Confidence (0.41)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.47 · 493 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: 40% · Reviewer familiarity: 35%
    41%
    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.371
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #789"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 41% 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.4% (MEDIUM) · Higher = larger blast radius
    47.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: 41% · Lower = rushed or shallow review
    41%
    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: 28.0% · Safe to merge
    28.0%