← Back to Pull requests

feat(client): get_layer and find_layer for snapshot export and owner lookup (0.11.0) #82

Closed
unknown closed this pull request without merging on Oct 10, 2026 21:11 UTC
View on GitHub
unknown unknown commented on Oct 10, 2026 20:36 UTC
Author

Summary


Adds two LedgerClient reads that the harness needs to treat the Ledger database as the authority and keep LLM sessions on files. Release 0.11.0.

  • get_layer(layer_id) returns the complete, schema-valid layer document (events, review queue, signed metadata) through the existing load_layer handler, and raises LedgerError when the layer is missing. Engine uses it to export a read-only snapshot of the authoritative DB layer before a session, so the LLM reads a file and never holds ledger credentials.

  • find_layer(product_repo_id) returns the layer owned by a product_repo, or None (there is at most one per owner). In-process callers resolve the layer by owner instead of deriving it from a path; it matches GET /v1/ledger/layers?product_repo_id=.
  • Context


    The harness reads and writes its local *-findings-layer.json, so countersigns written to the DB (for example from SCI) never reach the next run, and harness writes never reach the DB. The planned Engine change makes scripts the only Ledger writers: they pull a snapshot, the LLM works on files and reports, then the scripts append to the DB and refresh the snapshot. This PR is the Ledger half of that.

    Validation


  • New test on an opaque corpus:layer:… DB layer: find_layer with an owned and an unowned product_repo, a countersign, then get_layer returns the same document as the backend with the new event and Merkle size; a missing layer raises LedgerError.

  • make lint-fix, make test (1038 passed), make check-release.
  • Diff: 193 lines (+144 / -49) across 2 files Reviewer: gurnben Review duration: 35m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.41) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.41 · 193 lines diff across 2 files
    0.41
    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.315
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #82"
    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: 41.0% (MEDIUM) · Higher = larger blast radius
    41.0%
    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: 16.2% · Safe to merge
    16.2%