← Back to Pull requests

feat(cli): kb remote login signs in with OAuth #67

Open
unknown opened this pull request with 215 lines diff across 2 files
View on GitHub
unknown unknown commented on Nov 29, 2026 04:42 UTC
Author

Before: to use the remote commands or a scheduled Obsidian vault sync, the owner enrolled a client on the host and pasted its 64-hex bearer into kb remote credential-set, then repeated that whenever the bearer expired.

After: kb remote login --profile work --endpoint https://memory.example.com --scope "project:demo retrieval:read status:read memory:export" prints an address, the owner approves on the host with kb-admin oauth-approve, and the command line keeps itself signed in for the grant's whole lifetime.

How:

  • remote-login.service.ts: reads kb's authorization server metadata and refuses it unless the issuer and every endpoint are on the named origin and S256 is offered; registers a public client for a random 127.0.0.1 callback path; sends PKCE, a random state and resource=<origin>/v1 (needs #66); ignores redirects with another state; checks iss; exchanges the code.

  • RemoteCredentials stores the grant under com.beaudry.kb.remote.oauth. get() returns its access token, refreshing it within two minutes of expiry under a lock in ~/.kb/remote-oauth/ and re-reading the record inside the lock, because kb ends a grant whose refresh token is used twice. A refused refresh forgets the grant; an outage keeps a token that has not expired. credential-set and login replace each other.

  • Every caller (remote, transfer, the inject hook, the MCP bridge launcher) keeps calling get(), so none of them changed.

  • Docs: remote guide, README command table, credentials runbook.
  • Not covered: kb remote mcp gets one access token at launch (at most an hour); the guide says to use OAuth on /mcp for long MCP sessions.

    ---
    _Generated by Claude Code_

    Diff: 215 lines (+161 / -54) across 2 files Reviewer: chatgpt-codex-connector[bot] Review duration: 3m
    All Vouch review confidence checks passed
    Residual risk 0.45 = Change Risk (0.60) × (1 − Review Confidence (0.25)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.60 · 215 lines diff across 2 files
    0.60
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 57% · Reviewer familiarity: 35%
    25%
    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
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.322
    Sensitive Paths sensitive_paths
    0.060
    Real PR Conversation Timeline
    1 comments
    "Review active on #67"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: medium confidence: 25.3% reviewed sensitive_module
    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: 59.8% (MEDIUM) · Higher = larger blast radius
    59.8%
    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: 25.3% · Lower = rushed or shallow review
    25.3%
    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: 44.7% · Moderate risk
    44.7%