← Back to Pull requests

Add Client.Unenroll and host ephemeral metadata #61

Closed
unknown closed this pull request without merging on Nov 25, 2026 16:28 UTC
View on GitHub
unknown unknown commented on Nov 20, 2026 22:50 UTC
Author

Summary

Client support for dnclient unenroll (server side: DefinedNet/api#2432).

Client.Unenroll(ctx, creds)
  POST /v1/dnclient  "Unenroll" {}
    200 signed by the network CA, message {"hostID": creds.HostID}  -> nil (host deleted)
    200 unsigned, bad signature, or another host's ID               -> error
    401                                                             -> ErrInvalidCredentials
    403 with ERR_UNENROLL_NOT_EPHEMERAL among the errors            -> ErrNotEphemeral
    other                                                           -> error (body truncated to 256 bytes)

Merge order: don't merge until DefinedNet/api#2466 is deployed. Until then the API answers unsigned, and every unenroll fails verification.

Also:

 postDNClient / streamingPostDNClient, non-200 response
-  JSON without an errors array -> nil error (stream: Store(nil) panics)
+  JSON without an errors array -> "bad status code" error

 HostHostMetadata
+  Ephemeral bool `json:"ephemeral"`
 ConfigMeta.Host.Ephemeral set from Enroll, DoUpdate, DoConfigUpdate

The API sends host.ephemeral once DefinedNet/api#2459 ships. A response without it reads as false, which dnclient treats like any non-ephemeral host: the API decides through the 403.

Evidence

  • Before: a 503 {} from a proxy made Unenroll return nil, which dnclient read as "deleted". The same body on a log-streaming response panics with sync/atomic: store of nil value into Value.

  • After: TestUnenroll covers 200, 401, 403, 500, 503 proxy bodies ({}, null, {"message":...}) and 200 non-API bodies; TestStreamCommandResponse covers 503 {}. Both fail (the stream test panics) on main's client.go.
  • TestUnenroll also covers unsigned, wrong-signature and other-host 200 responses.

  • Exercised end to end against api.defined.net through the dnclient PR before signing: real 200 delete accepted, 401 after delete mapped to ErrInvalidCredentials. To re-run once api#2466 deploys. The 403 path was not live-tested (unit test only).
  • Merge Danger

    Door: two-way

    Blast Radius: small

    The non-200 change affects every dnclient endpoint call: a proxy JSON page that used to yield a nil error (then a signature failure, or a panic when streaming) now yields a status error. No caller relied on the nil.

    Diff: 294 lines (+220 / -74) across 3 files Reviewer: brad-defined Review duration: 6817m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 294 lines diff across 3 files
    0.40
    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.340
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #61"
    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: 39.9% (MEDIUM) · Higher = larger blast radius
    39.9%
    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: 15.8% · Safe to merge
    15.8%