← Back to Pull requests

Read OpenCode v2 with separate schema readers and shared inventories #131

Closed
unknown closed this pull request without merging on Nov 24, 2026 01:22 UTC
View on GitHub
unknown unknown commented on Nov 10, 2026 18:15 UTC
Author

OpenCode v2 histories in session_v2 / session_message are currently absent from SessionWiki's SQLite inventory. Add a dedicated v2 reader while retaining one opencode adapter to coordinate discovery and stable keys across v1, v2 and mixed databases.

This is an alternative to #85, based on AlexZander85's v2 parser and synthetic v2.1.1 fixture. It addresses the maintainer's outstanding review requests without changing the original branch:

  • Move existing v1 SQLite and legacy JSON decoding into a private v1 module without changing their parsing behavior. The existing tool-name, input-path and error-state rules are preserved; the new v2 shapes stay in a separate module.

  • Read each database inventory in one read-only SQLite transaction. Prefer v2 for duplicate session IDs, include unmigrated v1-only sessions, and keep the existing database/session keys and tool name.

  • Honor OpenCode's native migration state and descending-ID cursor, so retained legacy copies cannot resurrect sessions deleted in v2. Unknown or unreadable migration state keeps discovery partial; tests cover completed and in-progress migrations.

  • Retain SQL preparation, query and row failures in had_error, so incomplete discovery cannot authorize archival. Fall back to v1 only when the session is absent from v2 and remains eligible under native migration state; failed v2 reads remain errors even if a valid legacy copy exists.

  • Tag cache tokens with the selected schema while keeping real activity dates separate through the same optional Adapter::modified_at hook introduced in #130. This invalidates cached content on migrations with unchanged timestamps without changing session identity. Activity metadata is retained on the reader from its latest inventory, avoiding per-session database opens during scan reports. Bounded sync and scan use real activity dates; a separate regression verifies old tagged sessions remain outside the cutoff.

  • Keep the synthetic fixture as auditable SQL that tests materialize into temporary databases. Add v1, v2, mixed-store, separate-database, malformed-row/JSON and completed/failed tool evidence, structured errors and shell-command coverage, plus real CLI regressions showing partial SQL scans preserve cached live sessions and clean deletions still archive. Another CLI regression switches between schemas with identical timestamps and confirms that content refreshes while IDs and notes survive.
  • Validation: all 378 Rust tests pass (cargo test --all-targets), Clippy with warnings denied and rustfmt pass. The new opencode_v2_sqlite_session fixture test fails on unchanged upstream main with no such table: session and passes on this branch. Tests use temporary databases and indexes; no live user data is touched. Based on current upstream main 8925005.

    Diff: 350 lines (+262 / -88) across 4 files Reviewer: youdie006 Review duration: 19147m
    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 · 350 lines diff across 4 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.351
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #131"
    general weight: 0.35
    Reviewers
    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.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: 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%