enroll + broker: RENT A DEVICE from the control panel — GET /enroll/places, GET /enroll/server-offer, POST /enroll/rent (the broker rents, the box enrols itself with a code minted for it) #1397

Closed
opened 2026-09-11 20:09:33 +00:00 by ben · 3 comments
Owner

Parent

Control-panel UI pass, Ben 2026-09-10/11 (branch founding-ui-two-colour-rail-ceremony, unmerged at filing). Device-add spec #13 (ADRs 0053–0057, DDR 0109); founding Access step P1-S4/S4a (ADR 0189 / DDR 0190). The dashboard half is BUILT on the branch: dashboard/src/components/device-add/{PlaceScreen,RentServerScreen,RentedScreen}.vue, DeviceAddSurface.vue (stages place → rent → rented | form), shell/DeviceAddDialog.vue, seam dashboard/src/lib/deviceAdd.ts (DevicePlaceOption, ServerOffer, RentServerRequest, RentedServer; OPTIONAL placeOptions/serverOffer/rentServer on DeviceAddSource), fake dashboard/tests/fakes/deviceAdd.ts, browser harness cd dashboard && pnpm harness → http://localhost:5198/panel.html?scenario=steady.

What to build

The dialog's rented path has no live half. enroll's Operator face gains the founding Access step's three verbs, device-shaped:

  1. GET /api/v1/enroll/places → the place list (founding's AccessOptions() minus private, worded for a device joining a standing fleet — the wording in dashboard/tests/fakes/deviceAdd.ts placeOptions() is the contract: rented · recommended, own-vps, self-hosted).
  2. GET /api/v1/enroll/server-offer → the broker's offer (internal/founding/access.go Broker.Offer — the SAME broker client, moved or shared so founding and enroll read one offer): preset, provider, region, regions[], presets[] {slug,label,specs,mem_mb,price} (the sizes/prices half lands in #1393 — this ticket is BLOCKED by it).
  3. POST /api/v1/enroll/rent {name?, region?, preset?} → {name, ip, preset, region}. The op: mint a code server-side (intended role server — a rented box hosts services — carrying name, kind: server, location: <region label>, see #1396), then Broker.Rent the droplet from the generic gateway image with cloud-init user-data that runs the agent's enrol with that code against the community's domain (the equivalent of curl -sSf https://<domain>/get | sh -s -- <code>, ADR 0054) — so the box CALLS IN by itself. Fail loud, nothing recorded, on any broker fault (ADR 0047: no half-rented device; the minted code is revoked on failure).
  4. Ruling (two-way door, ADR 0174 — ruled by the agent unless vetoed): a device the operator rented from their own panel is AUTO-APPROVED at call-in (the rent IS the operator's approval), so the box never sits on the pending list. Record it in the DDR #1395 writes.
  5. The broker (broker/internal/broker/broker.go) needs nothing new if #1393's offer/rent already take a preset + region and accept user-data; if the rent endpoint has no user-data hook, add one (cloud_init field on the rent request, passed to provider_do.go's droplet-create).
  6. docs/GOTCHAS.md entry if the generic image needs a first-boot agent unit to read the code from user-data (ADR 0160).

Acceptance criteria

  • Given GET /api/v1/enroll/places, when called by an operator, then three places in the order rented (recommended), own-vps, self-hosted; private never appears.
  • Given GET /api/v1/enroll/server-offer, when the broker is reachable, then the offer's presets[] and regions[] are the broker's own (no list invented in Go); when unreachable, then a fail-loud 502 with the broker's stage + message.
  • Given POST /api/v1/enroll/rent {"name":"kōwhai","region":"sgp1","preset":"s-4vcpu-8gb"}, when the broker provisions, then the response carries the droplet's IP, the picked size's specs and "Singapore", and the enroll ledger shows one active code minted for it with intended role server.
  • Given the rented box boots, when its agent calls in with that code, then the device is approved without an operator click and GET /api/v1/fleet lists kōwhai with kind: server, location: Singapore.
  • Given the broker refuses the rent, when the op returns, then the code is revoked, no device is pending, and the error names the broker's stage.
  • Given the seam tests with a fake broker, when run, then all of the above; the live proof is #1400.

Blocked by

#1393 (offer sizes + prices; the rent honours the pick) and #1396 (the mint carries name/kind/location).

Why agent

Additive ops over existing seams (enroll ledger, founding's broker client, the broker's rent) — two-way door, provable by seam tests with a fake broker; the live half is proven by #1400.

## Parent Control-panel UI pass, Ben 2026-09-10/11 (branch `founding-ui-two-colour-rail-ceremony`, unmerged at filing). Device-add spec #13 (ADRs 0053–0057, DDR 0109); founding Access step P1-S4/S4a (ADR 0189 / DDR 0190). The dashboard half is BUILT on the branch: `dashboard/src/components/device-add/{PlaceScreen,RentServerScreen,RentedScreen}.vue`, `DeviceAddSurface.vue` (stages place → rent → rented | form), `shell/DeviceAddDialog.vue`, seam `dashboard/src/lib/deviceAdd.ts` (`DevicePlaceOption`, `ServerOffer`, `RentServerRequest`, `RentedServer`; OPTIONAL `placeOptions/serverOffer/rentServer` on `DeviceAddSource`), fake `dashboard/tests/fakes/deviceAdd.ts`, browser harness `cd dashboard && pnpm harness` → `http://localhost:5198/panel.html?scenario=steady`. ## What to build The dialog's rented path has no live half. enroll's Operator face gains the founding Access step's three verbs, device-shaped: 1. **`GET /api/v1/enroll/places`** → the place list (founding's `AccessOptions()` minus `private`, worded for a device joining a standing fleet — the wording in `dashboard/tests/fakes/deviceAdd.ts` `placeOptions()` is the contract: rented · recommended, own-vps, self-hosted). 2. **`GET /api/v1/enroll/server-offer`** → the broker's offer (`internal/founding/access.go` `Broker.Offer` — the SAME broker client, moved or shared so founding and enroll read one offer): `preset`, `provider`, `region`, `regions[]`, `presets[] {slug,label,specs,mem_mb,price}` (the sizes/prices half lands in #1393 — this ticket is BLOCKED by it). 3. **`POST /api/v1/enroll/rent`** `{name?, region?, preset?}` → `{name, ip, preset, region}`. The op: mint a code server-side (intended role `server` — a rented box hosts services — carrying `name`, `kind: server`, `location: <region label>`, see #1396), then `Broker.Rent` the droplet from the generic gateway image with cloud-init user-data that runs the agent's enrol with that code against the community's domain (the equivalent of `curl -sSf https://<domain>/get | sh -s -- <code>`, ADR 0054) — so the box CALLS IN by itself. Fail loud, nothing recorded, on any broker fault (ADR 0047: no half-rented device; the minted code is revoked on failure). 4. **Ruling (two-way door, ADR 0174 — ruled by the agent unless vetoed): a device the operator rented from their own panel is AUTO-APPROVED** at call-in (the rent IS the operator's approval), so the box never sits on the pending list. Record it in the DDR #1395 writes. 5. The broker (`broker/internal/broker/broker.go`) needs nothing new if #1393's offer/rent already take a preset + region and accept user-data; if the rent endpoint has no user-data hook, add one (`cloud_init` field on the rent request, passed to `provider_do.go`'s droplet-create). 6. `docs/GOTCHAS.md` entry if the generic image needs a first-boot agent unit to read the code from user-data (ADR 0160). ## Acceptance criteria - [ ] Given `GET /api/v1/enroll/places`, when called by an operator, then three places in the order rented (recommended), own-vps, self-hosted; `private` never appears. - [ ] Given `GET /api/v1/enroll/server-offer`, when the broker is reachable, then the offer's `presets[]` and `regions[]` are the broker's own (no list invented in Go); when unreachable, then a fail-loud 502 with the broker's stage + message. - [ ] Given `POST /api/v1/enroll/rent {"name":"kōwhai","region":"sgp1","preset":"s-4vcpu-8gb"}`, when the broker provisions, then the response carries the droplet's IP, the picked size's specs and "Singapore", and the enroll ledger shows one active code minted for it with intended role server. - [ ] Given the rented box boots, when its agent calls in with that code, then the device is approved without an operator click and `GET /api/v1/fleet` lists kōwhai with `kind: server`, `location: Singapore`. - [ ] Given the broker refuses the rent, when the op returns, then the code is revoked, no device is pending, and the error names the broker's stage. - [ ] Given the seam tests with a fake broker, when run, then all of the above; the live proof is #1400. ## Blocked by #1393 (offer sizes + prices; the rent honours the pick) and #1396 (the mint carries name/kind/location). ## Why agent Additive ops over existing seams (enroll ledger, founding's broker client, the broker's rent) — two-way door, provable by seam tests with a fake broker; the live half is proven by #1400.

swarm-claim host=matou-dev-server-01 run=21978
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=matou-dev-server-01 run=21978 (automated multi-host claim — lowest live claim id works this ticket)

Ruled by agent under ADR 0174 — veto anytime.

Two rulings on this ticket, both two-way doors:

  1. Auto-approve (ticket point 4, already recorded). A device the operator rented from their own panel is auto-approved at call-in — the rent IS the approval, so it never sits on the pending list. Implemented as a MintRequest/code AutoApprove flag that makes Pair approve the instant the request reaches Pending (Redeemed → Pending → Approved in one call), best-effort with fail-loud parity (an unready CA/mesh leaves it Pending for the operator). A later Decline/Abandon still tears it down. Recorded in DDR 0237 decision 8 (amends decision 4) as the ticket instructed ("Record it in the DDR #1395 writes"). Provable by TestEnroll_AutoApprove_* + TestEnrollRent_RentMintsAutoApprovedThenBoxCallsInApproved.

  2. Scope split — the Go + broker-primitive halves this iteration; the live half is #1400. The ticket designates #1400 the live proof and acceptance #6 stipulates all clauses are proven by seam tests with a fake broker. So this lands: the three enroll endpoints + WithEnrollDeviceRent (proven by TestEnrollRent_* against a fake EnrollDeviceBroker), the enroll auto-approve, and the broker's additive CreateRequest.UserData → DO user_data primitive (TestDO_CreatePassesCloudInitUserData). Not wired into production main.go: the brokerclient device-rent adapter, a broker device-rent HTTP route + rented-device lease semantics, the openapi contract for the three routes, and the generic image's first-boot user-data unit (GOTCHAS #222) — all #1400's live half, mirroring how #1393/#1396 split their live halves. The dashboard consumer rides the unmerged founding-ui-two-colour-rail-ceremony branch, so there is no live consumer to strand.

Why two-way: additive, reversible seam + a single additive broker field; the seam behaviour is proven at the unit tier; #1400 proves it live. Landed in a575406b.

**Ruled by agent under ADR 0174 — veto anytime.** Two rulings on this ticket, both two-way doors: 1. **Auto-approve (ticket point 4, already recorded).** A device the operator rented from their own panel is auto-approved at call-in — the rent IS the approval, so it never sits on the pending list. Implemented as a `MintRequest`/code `AutoApprove` flag that makes `Pair` approve the instant the request reaches Pending (Redeemed → Pending → Approved in one call), best-effort with fail-loud parity (an unready CA/mesh leaves it Pending for the operator). A later Decline/Abandon still tears it down. Recorded in **DDR 0237 decision 8** (amends decision 4) as the ticket instructed ("Record it in the DDR #1395 writes"). Provable by `TestEnroll_AutoApprove_*` + `TestEnrollRent_RentMintsAutoApprovedThenBoxCallsInApproved`. 2. **Scope split — the Go + broker-primitive halves this iteration; the live half is #1400.** The ticket designates #1400 the live proof and acceptance #6 stipulates all clauses are proven by seam tests with a fake broker. So this lands: the three enroll endpoints + `WithEnrollDeviceRent` (proven by `TestEnrollRent_*` against a fake `EnrollDeviceBroker`), the enroll auto-approve, and the broker's additive `CreateRequest.UserData` → DO `user_data` primitive (`TestDO_CreatePassesCloudInitUserData`). **Not** wired into production `main.go`: the `brokerclient` device-rent adapter, a broker device-rent HTTP route + rented-device lease semantics, the openapi contract for the three routes, and the generic image's first-boot user-data unit (GOTCHAS #222) — all #1400's live half, mirroring how #1393/#1396 split their live halves. The dashboard consumer rides the unmerged `founding-ui-two-colour-rail-ceremony` branch, so there is no live consumer to strand. Why two-way: additive, reversible seam + a single additive broker field; the seam behaviour is proven at the unit tier; #1400 proves it live. Landed in a575406b.

close-report for #1397 — status success

✅ close-report gates passed — every claim verified against main; issue closed.

envelope
{
  "issue": 1397,
  "status": "success",
  "commits": [
    "a575406b158a96aecd4502626a34fddb2b981c90"
  ],
  "changed_files": [
    "STATUS.md",
    "broker/internal/broker/provider.go",
    "broker/internal/broker/provider_do.go",
    "broker/internal/broker/provider_do_test.go",
    "docs/GOTCHAS.md",
    "docs/adr/0237-design-device-add-dialog-and-place-screen.md",
    "internal/enroll/enroll.go",
    "internal/enroll/enroll_test.go",
    "internal/enroll/ledger.go",
    "internal/controlapi/enroll_rent.go",
    "internal/controlapi/enroll_rent_integration_test.go"
  ],
  "tests": [
    {
      "command": "go test ./internal/enroll/ ./internal/controlapi/ git.matou.nz/Matou/idss/broker/internal/broker/",
      "exit_code": 0
    },
    {
      "command": "go build ./...",
      "exit_code": 0
    },
    {
      "command": "go vet ./internal/enroll/ ./internal/controlapi/ git.matou.nz/Matou/idss/broker/internal/broker/",
      "exit_code": 0
    },
    {
      "command": "gofmt -l internal/ broker/",
      "exit_code": 0
    }
  ],
  "criteria": {
    "GET /api/v1/enroll/places → three places rented(recommended)/own-vps/self-hosted; private never appears": "internal/controlapi/enroll_rent.go devicePlaces(); TestEnrollRent_PlacesAreThreeMinusPrivate (asserts order + no private)",
    "GET /api/v1/enroll/server-offer → the broker's own presets[]/regions[]; unreachable → 502 with the broker's stage+message": "internal/controlapi/enroll_rent.go registerEnrollDeviceRent (offer echoed verbatim; broker error → 502 broker_unreachable); TestEnrollRent_ServerOfferIsTheBrokersOwn + TestEnrollRent_ServerOfferUnreachableIs502",
    "POST /api/v1/enroll/rent {name,region,preset} → response carries IP + picked size specs + Singapore; ledger shows one active code with intended role server": "enroll_rent.go rent handler mints role server + name/kind/location and returns {name,ip,preset,specs,region-label}; TestEnrollRent_RentMintsAutoApprovedThenBoxCallsInApproved (asserts ip 203.0.113.9, specs '4 vCPU · 8 GB · 160 GB', region Singapore, one active server code)",
    "rented box boots + agent calls in → device approved without an operator click; fleet lists it kind:server location:Singapore": "internal/enroll/ledger.go Pair auto-approves an AutoApprove code (Redeemed→Pending→Approved); TestEnroll_AutoApprove_RentedDeviceApprovesOnPair + TestEnrollRent_...BoxCallsInApproved assert view Approved w/ grant, kind server, location Singapore, never awaiting a click. Fleet-row kind/location projection off the enrolled request is #1396's (TestProjection_DeviceFacts)",
    "broker refuses the rent → code revoked, no device pending, error names the broker's stage": "enroll_rent.go revokes the minted code + 502 rent_failed on any broker fault (err.Error() names the stage); TestEnrollRent_BrokerRefusalRevokesCodeNoDevicePending (asserts 502 names 'provision', code revoked, pending empty)",
    "seam tests with a fake broker prove all of the above; the live proof is #1400": "TestEnrollRent_* run against fakeDeviceBroker; broker cloud-init primitive proven by TestDO_CreatePassesCloudInitUserData. Live droplet round-trip + production wiring deferred to #1400 (per ticket + acceptance 6; ruled ADR 0174, comment on issue)"
  },
  "summary": "Landed the enroll rent-a-device seam (places/server-offer/rent) + auto-approve-at-call-in + the broker cloud-init primitive, proven at the seam with a fake broker; the live half is #1400.",
  "blockers": []
}
**close-report** for #1397 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 1397, "status": "success", "commits": [ "a575406b158a96aecd4502626a34fddb2b981c90" ], "changed_files": [ "STATUS.md", "broker/internal/broker/provider.go", "broker/internal/broker/provider_do.go", "broker/internal/broker/provider_do_test.go", "docs/GOTCHAS.md", "docs/adr/0237-design-device-add-dialog-and-place-screen.md", "internal/enroll/enroll.go", "internal/enroll/enroll_test.go", "internal/enroll/ledger.go", "internal/controlapi/enroll_rent.go", "internal/controlapi/enroll_rent_integration_test.go" ], "tests": [ { "command": "go test ./internal/enroll/ ./internal/controlapi/ git.matou.nz/Matou/idss/broker/internal/broker/", "exit_code": 0 }, { "command": "go build ./...", "exit_code": 0 }, { "command": "go vet ./internal/enroll/ ./internal/controlapi/ git.matou.nz/Matou/idss/broker/internal/broker/", "exit_code": 0 }, { "command": "gofmt -l internal/ broker/", "exit_code": 0 } ], "criteria": { "GET /api/v1/enroll/places → three places rented(recommended)/own-vps/self-hosted; private never appears": "internal/controlapi/enroll_rent.go devicePlaces(); TestEnrollRent_PlacesAreThreeMinusPrivate (asserts order + no private)", "GET /api/v1/enroll/server-offer → the broker's own presets[]/regions[]; unreachable → 502 with the broker's stage+message": "internal/controlapi/enroll_rent.go registerEnrollDeviceRent (offer echoed verbatim; broker error → 502 broker_unreachable); TestEnrollRent_ServerOfferIsTheBrokersOwn + TestEnrollRent_ServerOfferUnreachableIs502", "POST /api/v1/enroll/rent {name,region,preset} → response carries IP + picked size specs + Singapore; ledger shows one active code with intended role server": "enroll_rent.go rent handler mints role server + name/kind/location and returns {name,ip,preset,specs,region-label}; TestEnrollRent_RentMintsAutoApprovedThenBoxCallsInApproved (asserts ip 203.0.113.9, specs '4 vCPU · 8 GB · 160 GB', region Singapore, one active server code)", "rented box boots + agent calls in → device approved without an operator click; fleet lists it kind:server location:Singapore": "internal/enroll/ledger.go Pair auto-approves an AutoApprove code (Redeemed→Pending→Approved); TestEnroll_AutoApprove_RentedDeviceApprovesOnPair + TestEnrollRent_...BoxCallsInApproved assert view Approved w/ grant, kind server, location Singapore, never awaiting a click. Fleet-row kind/location projection off the enrolled request is #1396's (TestProjection_DeviceFacts)", "broker refuses the rent → code revoked, no device pending, error names the broker's stage": "enroll_rent.go revokes the minted code + 502 rent_failed on any broker fault (err.Error() names the stage); TestEnrollRent_BrokerRefusalRevokesCodeNoDevicePending (asserts 502 names 'provision', code revoked, pending empty)", "seam tests with a fake broker prove all of the above; the live proof is #1400": "TestEnrollRent_* run against fakeDeviceBroker; broker cloud-init primitive proven by TestDO_CreatePassesCloudInitUserData. Live droplet round-trip + production wiring deferred to #1400 (per ticket + acceptance 6; ruled ADR 0174, comment on issue)" }, "summary": "Landed the enroll rent-a-device seam (places/server-offer/rent) + auto-approve-at-call-in + the broker cloud-init primitive, proven at the seam with a fake broker; the live half is #1400.", "blockers": [] } ``` </details>
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Matou/idss#1397
No description provided.