← Back to Pull requests

feat(cli,daemon): say which bearer checks the running daemon started with #4183

Closed
unknown closed this pull request without merging on Nov 29, 2026 21:22 UTC
View on GitHub
unknown unknown commented on Nov 29, 2026 18:38 UTC
Author

Refs #4181.

A daemon's bearer tokens come from whatever starts it: a supervisor's unit, or the shell that runs rig daemon start (or rig up, rig start or rig context when one of them starts the daemon). Nothing said which ones the running daemon had, so a daemon restarted from a shell without them looked the same as one its supervisor started, and a request to /healthz or /api/views (neither checks a bearer token) succeeded either way.

What a person or their agent sees now

rig daemon start, rig daemon status and rig status --json (daemon.bearerChecks) say what each of the daemon's two bearer checks had when it started, never the token:

$ rig daemon start --no-kernel
Daemon started on port 41192 (pid 3590335)
Bearer checks, from this start's environment: operator not configured, terminal not configured (a check with no token lets its routes' requests through this check).

$ rig daemon status
Daemon running on port 41192 (pid 3590158)
  Bearer checks it started with: operator configured, terminal not configured (a check with no token lets its routes' requests through this check)

(Captured from a test-machine walk at the first head; the second head changed only the parenthesis's last words.)

  • operator is configured, empty (set to an empty or blank value: the check still runs, so a request with no bearer gets 401) or absent.

  • terminal is configured, operator (an explicit bind outside loopback and tailnet with no terminal token, which checks the operator token) or absent.

  • Both read unknown when no daemon.json record of them is confirmed for the daemon described: a record an earlier version wrote, one whose PID /healthz doesn't name, a /healthz that didn't answer, or a daemon reached through OPENRIG_URL.
  • The change

  • One derivation (resolveBearerChecks in middleware/auth-bearer-token.ts) gives the daemon its two tokens and their labels, so a label can't disagree with what the daemon checks. The empty and unset handling is the daemon's existing handling, unchanged.

  • rig daemon start records the labels from the environment it gives the child, in daemon.json and in the start reservation. A later start that finishes a pending one publishes the labels that launch recorded, not its own environment's. The daemon entry run directly, as a supervisor runs it, writes its own.

  • Status shows a record's labels only when /healthz names that record's PID; otherwise they read unknown.

  • Docs: getting-started.md (set the tokens in the supervisor's unit; a daemon started any other way gets that shell's environment), daemon-http-clients.md ("Bearer tokens"), the command reference, and the rigs skill's start step (restart a supervised daemon through its supervisor).
  • Unchanged

    Every route's bearer check, the explicit-bind startup check, the bind plan, /healthz and every endpoint. There's no new refusal or error code, and no token value or fingerprint in any record or output.

    Tests

    On Linux (Node 22) on a test machine, at 80e2735c.

  • Against main's source, the new cases and the updated status expectations fail: 10 in the daemon and 20 in the CLI.

  • With the change:

  • - 7 daemon files pass (261 tests): the bearer middleware and its new derivation cases, the daemon entry's own record (a real daemon: its record's labels, a guarded route answering 401 without the token and passing with it, /healthz and /api/views answering 200 either way), the entry, terminal-bearer and seat-auth files, and restore-check;
    - 15 CLI files pass (587 tests, 1 skipped): start and status records, the finished pending start, the person offer, status JSON and the start, up and restore-check paths;
    - both packages' tsc --noEmit, the daemon build, mirror-skills --check, check-docs-guard and generate-context-packs --check pass.
  • A walk with the built CLI and daemon (scratch home, distinct random tokens): starts with the operator token, both tokens and none; a refused second start; the daemon entry run directly; a record without the field; OPENRIG_URL; and a start that ended pending, finished by a start from a shell without the token. Each output said what's listed above, the guarded route agreed with the label, and no token value appeared in any output, record, log or reservation.

  • The second head (an empty operator token reads empty): against the first head, its new and changed cases fail, 2 in the daemon and 7 in the CLI. With it, the same 7 daemon files pass (262 tests) and the same 15 CLI files (589 tests, 1 skipped), with both tsc runs and the three repository checks. The checks also pass on the tree merged with current main.

  • Not run live: the terminal operator case (an explicit bind outside loopback and tailnet). It's covered by unit tests only.
  • Cost

    Source +160/−41 (net 119), tests +217/−7, docs and skill text +41/−9.

    🤖 Generated with Claude Code

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->
    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    New Features
    rig daemon start, rig daemon status, and rig status --json report the daemon’s operator and terminal bearer-check states, including configured, absent, empty, or unknown, without exposing token values.
    For external binds, the operator token can also serve as the terminal check when no terminal token is set.
    Documentation
    Updated setup and reference guidance to explain how startup environments and supervisor settings affect bearer checks, and how to restart supervised daemons.
    Clarified that successful health or views requests do not reveal whether bearer checks are active.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: mvschwarz Review duration: 164m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    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.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #4183"
    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: 52% (MEDIUM) · Higher = larger blast radius
    52%
    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: 20.5% · Safe to merge
    20.5%