← Back to Pull requests

Revoke and restore install codes from the operator page #158

Closed
unknown closed this pull request without merging on Nov 30, 2026 19:43 UTC
View on GitHub
unknown unknown commented on Nov 30, 2026 19:27 UTC
Author

Adds Revoke and Restore buttons for install codes on the operator page (backup.uncloud.life/admin, Install codes tab). Follows #157.

What changed


  • Page: each row has a Revoke link next to Copy. It asks for confirmation first, and the dialog names the code and who it's for. A revoked row has its code struck through and a red "Revoked <date>" line; its link becomes Restore. The summary line adds "· N revoked".

  • Backup service:

  • - Migration 007_install_code_revoked adds revoked_at.
    - PATCH /api/operator/install-codes {id, revoked} revokes or restores a code (operator only). Revoking a code twice keeps the first revocation date.
    - The ledger's used endpoint now answers {recorded, revoked}. A revoked code isn't counted as a use.
  • Website: /api/install-code reads that answer and returns {valid: false} for a revoked code.
  • Behaviour to know


  • Existing Macs aren't affected. The app only asks for the code at setup, so revoking stops new setups with it. A Mac already set up keeps working.

  • Fails open. If the backup service doesn't answer within 3s, or answers with an error, the code is accepted. A buyer setting up is never blocked by the backup service being down. The cost is that a revoked code works during that window.

  • Message the app shows. A revoked code gets the same "That isn't an Uncloud install code" message as a mistyped one. The app hasn't changed, so the published Mac app needs nothing new. A clearer "this code was turned off" message would need an app update.
  • Testing


  • node --test "api/*.test.js": 72 pass. Adds: revoked → valid: false; missing, odd or failed ledger answers → valid: true.

  • services/backup tests: 70 pass. Adds: revoke/restore, uses not counted while revoked, purchase codes revocable, input validation, 404 for an unknown id, operator-only PATCH, and an end-to-end case where the website's real handle() turns a revoked code down and accepts it again once restored.

  • scripts/check.sh: passes in full (including the 536 .NET tests).

  • Revoke flow clicked through with Playwright against a mocked API (confirm dialog, PATCH body, re-rendered rows, summary).
  • ---
    _Generated by Claude Code_

    Diff: 280 lines (+210 / -70) across 3 files Reviewer: ethanteng Review duration: 15m
    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 · 280 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.337
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #158"
    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.6% (MEDIUM) · Higher = larger blast radius
    39.6%
    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.7% · Safe to merge
    15.7%