Skip to content

desk: provisioning keys — reusable enrollment keys, a machine's own enrollment, the offline sweep - #97

Merged
SSFSKIM merged 22 commits into
masterfrom
desk-provisioning-keys
Oct 21, 2026
Merged

SSFSKIM merged 22 commits into
masterfrom
desk-provisioning-keys

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Oct 21, 2026 •

Copy link
Copy Markdown
Owner

The hub and web side of the desk's provisioning keys: a reusable, revocable credential that lets an automated VM (devcloud) enroll at the desk with no human step. It extends DX7's enrollment as a child of the desk composite.

What changes

Hub (M1, ccbb539b0, fix 0602580be)

  • Keys: POST, GET and DELETE /api/provisioning-keys. An admin creates and revokes; a member lists. Each key carries:
    • a label and a name prefix;
    • an expiry, 1 h to 1 year, 90 days by default;
    • an optional max_uses;
    • an optional offline_revoke_s.
      The secret is shown once and stored as a hash.
  • Redemption: POST /machine/enroll takes a key's secret as token.
    • It checks §2's refusals in order: key-revoked, key-expired, prefix-mismatch, busy, a same-key rotation, name-taken, then key-exhausted.
    • uses is counted in the same synchronous step as the reservation, so it holds under a race.
    • A key-made enrollment is an ordinary pending row from then on, with its alarm set before the mint.
  • A machine's own record: GET /machine/enrollment returns it. DELETE /machine/enrollment is the machine's self-revoke.
  • One revoker: admin removal, self-revoke and the offline sweep all run the same revocation, bound to the enrollment it read, so a name revoked and re-enrolled in between is left alone.
  • Offline sweep: the alarm revokes a key's machines once they have been offline past the key's time. A failed revocation backs off per enrollment.
  • Storage: the new provisioning_keys table and the enrollments.key column, through CREATE TABLE IF NOT EXISTS and ADDED_COLUMNS. The owner approved this.
  • Access: unchanged. The redemption keeps its path.
  • Local stand-in:
    • It answers a service token it does not hold as production Access does: 401, an HTML page naming Cloudflare Access.
    • New helper: POST /standin/provisioning-code.

Web (M2, be133c3a3, fix d6195c5ce, lint fix 040a9a8a5)

  • Machines gains a Provisioning keys section:
    • Create goes through the org key's confirm step, and the code is shown once with the boot line.
    • The list shows uses over cap, prefix, expiry and the machines enrolled through each key.
    • Revoke confirms first and names the machines that stay.
    • Machine rows show via <label>.
  • The confirm and code steps are shared with the one-time flow.
  • A confirmation the owner left asks the hub for nothing.

Whole-branch panel fix wave

  • 44a1909e4: a sweep revocation whose fence was placed but whose answer was lost is retried until it completes, whatever the machine reads after.
  • f992aeb81: the sweep re-reads its retry record at dispatch, so overlapping sweeps keep the per-enrollment wait.
  • reviewer-medium found the issue f992aeb81 fixes in its review of 44a1909e4, and its re-review was clean.

Other commits on this branch

Validation Evidence

  • Gate before the panel fixes, scripts/ci-gate.sh … --gates static,unit,e2e:desk-web on 027c290a9: success. Static, unit and e2e:desk-web are all green: https://github.com/SSFSKIM/MAWS/actions/runs/39549579112.
  • After the panel fix wave: run 39551931473 on 44a1909e4 was success; ce0b8407a (the last code head): success, https://github.com/SSFSKIM/MAWS/actions/runs/39553101895; the final head 36dbd056d adds only the spec and report (static: success, run 39554704822).
  • An earlier gate on 9296313e7 (run 39544247573) was green on unit and e2e:desk-web. Its static job failed on react-hooks/purity in ProvisioningKeys.tsx, which 040a9a8a5 fixed. That is the run above.
  • Acceptance walk (M4) against pnpm --filter desk-hub local, with doperpowers d358c760's sminos. Items 1–8, 10 and 11 pass as written:
    • a key created on the web, its code shown once;
    • two machines enrolled through one key, uses: 2, via devcloud;
    • the prefix, cap and race bounds;
    • key revocation stops new enrollments only;
    • leave, and admin-revoked and lost-200 credentials, learned through the stand-in's 401;
    • an older sminos refuses the code before any request;
    • one-time codes are untouched;
    • stop, revoke, reboot and re-enroll with no human step.
      Items 6 (the offline sweep) and 11 (the revoke-and-replace race between resolve and leave) are hub-suite tests, run focused: 6/6 and 1/1.
  • Focused suites:
    • desk-hub covering suites: 90/90.
    • desk-web: 792/792, plus the machines dialog at 18/18.
    • Typecheck and pnpm lint: clean.
  • Reviews: M1 was reviewed by the SDE task-reviewer and reviewer-high. M2 was reviewed by the task-reviewer. Every finding was fixed and re-reviewed clean (details in the report).

Unresolved Review Findings

  • A Registry restart between a lost revocation answer and its retry (apps/desk-hub/src/objects/registry.ts, the offline sweep's unfinished record, kept in memory). If the Registry restarts after the sweep has placed a machine's fence but lost the answer, and before the retry runs, the retry is forgotten. The machine then takes the ordinary path. The gap is bounded: the fence refuses new streams, so the machine's lease lapses and the sweep completes the revocation one offline_revoke_s later. A durable record would need a new storage key, and the orchestrator ruled it not worth asking the owner for, given how rarely a restart lands in that window.
  • The upgrade path from stored state is untested (apps/desk-hub/src/objects/registry.ts, ADDED_COLUMNS.enrollments). No suite starts from a Registry stored before this change. The mechanism is the one earlier deployed columns used, and the orchestrator checks it at deploy.
  • A cross-view import and a coarse expiry label (apps/desk-web/src/views/machines/ProvisioningKeys.tsx).
    • It imports useDayClock from views/conversation/StreamView.tsx. That is the codebase's existing in-render clock, reused rather than duplicated.
    • A key row's expired label follows the day clock (midnight and visibility), not the second. The hub refuses an expired key whatever the label says.
  • An unused key can be left behind (apps/desk-web/src/views/machines/CodeSteps.tsx). Closing the whole dialog while the hub mints leaves an unused key at 0 / ∞, where it can be revoked. This is by design, since a key the hub made can't be unmade from the browser, and a test pins it.

Residue

Sminos-Session: smns-erb-71#b4948247 (doperpowers on macbook)

…osite's entry

A reusable, revocable key with a name prefix, an expiry, an optional cap on
uses and an optional offline auto-revoke, whose code `smns-provision-v1.` an
admin's browser builds around the key's secret and the org key; redeemed at
the same unguarded path as a one-time token and turned into an ordinary
pending enrollment, so DX7's lifecycle carries over; a machine's self-revoke
(`DELETE /machine/enrollment`, `sminos hub leave`); the Registry's offline
sweep through the revocation path. Milestones across MAWS (hub, web) and
doperpowers (sminos CLI and the parity vectors); the devcloud boot's
interface pinned, the step itself out of scope.

Sminos-Session: smns-erb-71#b4948247 (doperpowers on macbook)
… key file (the owner's ruling)

Sminos-Session: smns-erb-71#b4948247 (doperpowers on macbook)
The self-revoke and the offline sweep bind to the enrollment, not the name
(a check before the first fence; the replacement of a reused name survives).
Access's denial is an explicit outcome: the stand-in answers a token it no
longer holds as production does (401, a page naming Cloudflare Access), and
the CLI reads that and the Worker's not-enrolled as "rejected", distinct from
an outage. `sminos hub check` (GET /machine/enrollment, nothing written) with
four exits, and the boot's reboot rule on them. The security rationale
corrected: stdin-only keeps the key out of disk artifacts, not out of a VM
that holds project-owner ADC; the recovery path written. Buildability: the
parity adapter, the proof's exit status, the web build before the local hub,
the name-taken walk. The four forks settled as written.

Sminos-Session: smns-erb-71#b4948247 (doperpowers on macbook)
… and a recheck; exit 4 is the boot's to retry

The fix wave's re-review, two findings ruled by the orchestrator: a marked 401
is a rejection only 600 s past enrollment and when it holds on a recheck 90 s
later (the Worker's not-enrolled stays one at once); hub check's exit 4 means
undecided, which the boot asks again with backoff until 0, 1 or 3.

Sminos-Session: smns-erb-71#b4948247 (doperpowers on macbook)
…sweep (provisioning keys M1)

An admin makes a reusable, revocable provisioning key (POST/GET/DELETE
/api/provisioning-keys): a name prefix, an expiry, an optional cap on
uses and an optional offline auto-revoke; its secret is answered once
and kept as a hash. Its secret is redeemed at /machine/enroll as a
one-time token is, through the spec's checks in order (key-revoked,
key-expired, prefix-mismatch, busy, a rotation of the key's own pending
name, name-taken, key-exhausted), all in the Registry's one synchronous
step with the reservation, so uses hold under a race; the enrollment row
it makes is an ordinary pending one bound to the key (enrollments.key).

A machine reads its own record (GET /machine/enrollment) and revokes
itself (DELETE). Revocation is one private path with three callers (an
admin, the machine, the offline sweep), the latter two bound to the
enrollment they read, so a name revoked and enrolled anew between two
of their steps is left be. The alarm revokes a key's machine offline
past the key's offline time; refreshOnline schedules it when a machine
goes offline.

The protocol module gains the provisioning code (smns-provision-v1.)
and decodeCode over both prefixes. The stand-in answers a service token
it does not hold as production Access does (401, a page naming
Cloudflare Access), and its code helpers (one-time and provisioning)
move to local/helpers.ts, served by the local command and the suites.

Sminos-Session: smns-erb-71#b4948247 (doperpowers on macbook)
Sminos-Session: smns-erb-71#b4948247 (doperpowers on macbook)
…int, the offline retry enforced, one reservation

- A redemption's mint sets the pending enrollment's alarm before calling
  Cloudflare's API (the enrollment already busy), so a Registry reset
  during the calls still leaves a wakeup that expires it; a key-made
  row had none until the mint's finally.
- A failed offline revocation waits its minute per enrollment in
  sweepOffline itself, not only in the alarm's time, so a redemption's
  sweep inside the window no longer retries it at once.
- The token path and the key path reserve the name through one
  synchronous helper (`reserve`), each inside its own transaction.

Sminos-Session: smns-erb-71#b4948247 (doperpowers on macbook)
Sminos-Session: smns-erb-71#b4948247 (doperpowers on macbook)
…#91's test, MAWS #88)

The mixed-run case waited only for the pending list, then asserted the
browser's presence frames at once; under load the frame may not have
arrived. Wait for it the same way. The other cases #91 added assert on a
POST's answer or wait on the exact frame (m.next), so they are unchanged.

Sminos-Session: smns-erb-71#b4948247 (doperpowers on macbook)
The Machines dialog gains a Provisioning keys section under the machine list:
every member sees each key's prefix, uses over cap, expiry and the machines
enrolled through it (revoked keys last), and machine rows say 'via <label>'.
An admin holding the org key creates a key from a form checked in the browser
(prefixProblem, fixed expiry and offline-revoke choices), confirms it with one
of the org key's methods, and sees its code once with the boot line; revoking
confirms on a step naming the machines that stay.

The confirm and code steps are generalized into CodeSteps.tsx, shared by the
one-time enrollment and the key. The machines double serves the three key
endpoints; e2e-hub proves the flow against the local hub, and its machine
removal test now expects Access's 401, which M1's stand-in answers.

Sminos-Session: smns-erb-71#b4948247 (doperpowers on macbook)
…r nothing (provisioning keys M2, review fix)

ConfirmStep, shared by the one-time enrollment and the provisioning key, now
knows whether the owner is still on it. Cancelled or closed while the org key
opens, it asks the hub for nothing; once the hub has been asked (a made key
cannot be unmade), Cancel is off and the step says the code is on its way; an
answer after the dialog closed is drawn nowhere. The key's bytes are wiped on
every path. Tests hold the key's opening and the hub's answer to prove each.

Sminos-Session: smns-erb-71#b4948247 (doperpowers on macbook)
Sminos-Session: smns-erb-71#b4948247 (doperpowers on macbook)
… meanwhile, exit 1

Sminos-Session: smns-erb-71#b4948247 (doperpowers on macbook)
… Date.now() in render (provisioning keys M2, lint fix)

react-hooks/purity refused the call to Date.now() in KeyRow's render. The keys
section now reads useDayClock(), the clock the stream's day labels and the
project view already use, and passes it to each row; a test pins the expired
and expires wordings.

Sminos-Session: smns-erb-71#b4948247 (doperpowers on macbook)
…in; the e2e-hub failures predate the branch

Sminos-Session: smns-erb-71#b4948247 (doperpowers on macbook)
Sminos-Session: smns-erb-71#b4948247 (doperpowers on macbook)
… execution report

Sminos-Session: smns-erb-71#b4948247 (doperpowers on macbook)
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T05:46:21.728422Z 027c290 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

…tever the machine reads after

The sweep's retry of a failed offline revocation was keyed to the
machine still reading offline and overdue: when the Machine object's
answer was lost after it fenced the credential, a reconnect's in-flight
lease report could mark the machine online (or reset its deadline), and
the retry was dropped, leaving a fenced credential whose record and
Access token stayed held and whose own GET /machine/enrollment still
answered active. A revocation the sweep began is now kept as unfinished
and tried again a minute on until it completes, whatever the machine's
online state or offline deadline; the alarm is scheduled for that retry,
and a bound retry of a name enrolled anew ends as "already gone".

Sminos-Session: smns-erb-71#b4948247 (doperpowers on macbook)
…n at dispatch

A sweep builds its candidate lists before awaiting the first. Meanwhile
another sweep (a redemption's) may begin, fail or finish one of them,
so each candidate's live entry is read again just before it is
dispatched: one whose retry is not yet due, or which another sweep is
revoking now, is skipped, as is a retry whose entry another sweep
cleared on completion.

Sminos-Session: smns-erb-71#b4948247 (doperpowers on macbook)
Sminos-Session: smns-erb-71#b4948247 (doperpowers on macbook)
Sminos-Session: smns-erb-71#b4948247 (doperpowers on macbook)
@SSFSKIM
SSFSKIM merged commit 4326f0a into master Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant