Destroy community 1/9 — broker: a community can LEAVE in one act (release every rental, free the name last, tombstone) #1785

Closed
opened 2026-09-23 18:06:29 +00:00 by ben · 2 comments
Owner

Parent

#1784 (spec) — from #1781.

What to build

A community holding its claim secret can leave IDSS in one broker act. leave authenticates the claim secret the same way release/offboard do (ADR 0135), then:

  1. releases the community's gateway rental and every device rental under the host through the existing release path. A provider refusal becomes release-owed, and the reaper finishes it (#756);
  2. deletes the host's records and frees the slug, last;
  3. records a tombstone: host, secret hash, outcome, time.

It answers {released | release_owed, name_freed, at}. A host with no rental (a home or own-VPS gateway) leaves with just the name freed. release and offboard are unchanged; leave composes them. The ledger change is additive, following the release_owed precedent. The shared broker client gains a Leave call that returns this outcome and passes a refusal's own words through verbatim (ADR 0100).

Why one act: two sequential calls strand something whichever way round they run (DDR 0274 §3).

Acceptance criteria

  • leave with a valid claim secret releases the gateway rental and every device rental under that host, spares every other host, frees the slug, deletes the host's records and answers with the outcome (spec #1784 story 47)
  • missing secret → 401, wrong secret → 403, empty host → 400; nothing changes in any case (47a)
  • a provider refusal on any rental lands as release_owed in the answer, and the reaper finishes it without waiting for the TTL
  • a zone-delete failure → 502 with the name not freed and the host record + secret intact, while rentals stay released/owed; a retry with the same secret authenticates and completes the leave (47b)
  • a retry after a completed leave, with the secret that left, returns the recorded tombstone outcome and re-asks any owed teardown; after the name has been claimed again it answers 410 "this community already left; the name has since been claimed" (48)
  • a host with no rental leaves with name_freed only
  • the ledger survives a broker restart with tombstones intact; an existing ledger with no tombstones loads unchanged
  • the broker client's Leave parses the outcome and surfaces 401/403/410/502 refusals in the broker's own words
  • broker HTTP tests in the style of the existing rent/release, offboard-frees-slug and release-owed/reaper tests; go test for the broker module and the broker client green

On landing: this lives in the broker tree, so it goes deploy-pending until the broker on the mail droplet carries it. Ticket 9's live proof needs that deploy.

Blocked by

None — can start immediately.

## Parent #1784 (spec) — from #1781. ## What to build A community holding its claim secret can leave IDSS in **one broker act**. `leave` authenticates the claim secret the same way `release`/`offboard` do (ADR 0135), then: 1. releases the community's gateway rental and **every device rental under the host** through the existing release path. A provider refusal becomes release-owed, and the reaper finishes it (#756); 2. deletes the host's records and frees the slug, **last**; 3. records a **tombstone**: host, secret hash, outcome, time. It answers `{released | release_owed, name_freed, at}`. A host with no rental (a home or own-VPS gateway) leaves with just the name freed. `release` and `offboard` are unchanged; `leave` composes them. The ledger change is additive, following the `release_owed` precedent. The shared broker client gains a `Leave` call that returns this outcome and passes a refusal's own words through verbatim (ADR 0100). Why one act: two sequential calls strand something whichever way round they run (DDR 0274 §3). ## Acceptance criteria - [ ] `leave` with a valid claim secret releases the gateway rental **and** every device rental under that host, spares every other host, frees the slug, deletes the host's records and answers with the outcome (spec #1784 story 47) - [ ] missing secret → 401, wrong secret → 403, empty host → 400; nothing changes in any case (47a) - [ ] a provider refusal on any rental lands as `release_owed` in the answer, and the reaper finishes it without waiting for the TTL - [ ] a zone-delete failure → 502 with the name **not** freed and the host record + secret intact, while rentals stay released/owed; a retry with the same secret authenticates and completes the leave (47b) - [ ] a retry after a completed leave, with the secret that left, returns the recorded tombstone outcome and re-asks any owed teardown; after the name has been claimed again it answers 410 "this community already left; the name has since been claimed" (48) - [ ] a host with no rental leaves with `name_freed` only - [ ] the ledger survives a broker restart with tombstones intact; an existing ledger with no tombstones loads unchanged - [ ] the broker client's `Leave` parses the outcome and surfaces 401/403/410/502 refusals in the broker's own words - [ ] broker HTTP tests in the style of the existing rent/release, offboard-frees-slug and release-owed/reaper tests; `go test` for the broker module and the broker client green **On landing:** this lives in the broker tree, so it goes `deploy-pending` until the broker on the mail droplet carries it. Ticket 9's live proof needs that deploy. ## Blocked by None — can start immediately.

swarm-claim host=bens-mac-04 run=30973
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=bens-mac-04 run=30973 (automated multi-host claim — lowest live claim id works this ticket)

close-report for #1785 — status success

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

envelope
{
  "issue": 1785,
  "status": "success",
  "commits": [
    "0244d08b"
  ],
  "changed_files": [
    "STATUS.md",
    "broker/internal/broker/broker.go",
    "broker/internal/broker/http.go",
    "broker/internal/broker/http_leave_test.go",
    "broker/internal/broker/leave.go",
    "broker/internal/broker/leave_test.go",
    "broker/internal/broker/reservation_ttl_test.go",
    "broker/internal/broker/store.go",
    "broker/internal/broker/store_test.go",
    "internal/brokerclient/client.go",
    "internal/brokerclient/client_test.go"
  ],
  "tests": [
    {
      "command": "cd broker && go test ./...",
      "exit_code": 0
    },
    {
      "command": "go test ./internal/brokerclient/",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci -c golangci-lint run (broker) — 0 issues",
      "exit_code": 0
    }
  ],
  "criteria": {
    "leave with a valid claim secret releases the gateway rental AND every device rental under that host, spares every other host, frees the slug, deletes the host's records and answers with the outcome (story 47)": "leave.go Issuer.Leave + performLeave + Rentals.Leave; TestAPI_LeaveReleasesEveryRentalFreesTheNameAndSparesOtherHosts (http_leave_test.go)",
    "missing secret -> 401, wrong secret -> 403, empty host -> 400; nothing changes (47a)": "http.go /v1/gateways/leave switch (ErrSecretRequired->401, ErrSecretMismatch->403, empty host->400); TestAPI_LeaveRejectsUnauthenticatedWrongSecretAndEmptyHost",
    "a provider refusal on any rental lands as release_owed in the answer, and the reaper finishes it without waiting for the TTL": "Rentals.Leave reports owed from final ledger state; TestAPI_LeaveProviderRefusalIsReleaseOwedAndReaperFinishes (asserts release_owed then Reap tears it down with a fresh 24h lease)",
    "a zone-delete failure -> 502 with the name NOT freed and the host record + secret intact, rentals stay released/owed; retry with same secret completes (47b)": "performLeave releases rentals first, DeleteRecords last; TestAPI_LeaveZoneDeleteFailureKeepsTheNameHeldThenRetryCompletes",
    "a retry after a completed leave returns the recorded tombstone outcome and re-asks owed teardown; after re-claim answers 410 (48)": "Issuer.Leave free-slug tombstone-replay branch + ErrAlreadyLeft (410); TestAPI_LeaveRetryReturnsTombstoneOutcomeThen410AfterReclaim",
    "a host with no rental leaves with name_freed only": "Rentals.Leave hadAny=false -> released=false owed=false; TestAPI_LeaveHostWithNoRentalFreesTheNameOnly",
    "the ledger survives a broker restart with tombstones intact; an existing ledger with no tombstones loads unchanged": "store.go additive tombstones field on reservationDoc (no version bump), broker.go OpenRegistry/persistLocked thread them; TestLeave_TombstoneSurvivesRestartAndReplaysTheRecordedOutcome + TestLeave_ExistingLedgerWithNoTombstonesLoadsUnchanged",
    "the broker client's Leave parses the outcome and surfaces 401/403/410/502 refusals in the broker's own words": "brokerclient/client.go Client.Leave + LeaveOutcome; TestClient_LeaveParsesTheOutcome, TestClient_LeaveParsesReleaseOwed, TestClient_LeaveSurfacesRefusalsVerbatim",
    "broker HTTP tests in the style of rent/release, offboard-frees-slug and release-owed/reaper; go test for the broker module and the broker client green": "http_leave_test.go (7 cases) + leave_test.go (2 cases) + brokerclient Leave (3 cases); go test broker + brokerclient exit 0, gofmt/vet/golangci-lint clean"
  },
  "summary": "Added the broker leave verb — free the name and release every rental under the host in one claim-secret-gated act, with a durable tombstone for truthful retries — plus the brokerclient Leave call.",
  "reason": "",
  "blockers": [],
  "no_code_change": ""
}
**close-report** for #1785 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 1785, "status": "success", "commits": [ "0244d08b" ], "changed_files": [ "STATUS.md", "broker/internal/broker/broker.go", "broker/internal/broker/http.go", "broker/internal/broker/http_leave_test.go", "broker/internal/broker/leave.go", "broker/internal/broker/leave_test.go", "broker/internal/broker/reservation_ttl_test.go", "broker/internal/broker/store.go", "broker/internal/broker/store_test.go", "internal/brokerclient/client.go", "internal/brokerclient/client_test.go" ], "tests": [ { "command": "cd broker && go test ./...", "exit_code": 0 }, { "command": "go test ./internal/brokerclient/", "exit_code": 0 }, { "command": "nix develop .#go-ci -c golangci-lint run (broker) — 0 issues", "exit_code": 0 } ], "criteria": { "leave with a valid claim secret releases the gateway rental AND every device rental under that host, spares every other host, frees the slug, deletes the host's records and answers with the outcome (story 47)": "leave.go Issuer.Leave + performLeave + Rentals.Leave; TestAPI_LeaveReleasesEveryRentalFreesTheNameAndSparesOtherHosts (http_leave_test.go)", "missing secret -> 401, wrong secret -> 403, empty host -> 400; nothing changes (47a)": "http.go /v1/gateways/leave switch (ErrSecretRequired->401, ErrSecretMismatch->403, empty host->400); TestAPI_LeaveRejectsUnauthenticatedWrongSecretAndEmptyHost", "a provider refusal on any rental lands as release_owed in the answer, and the reaper finishes it without waiting for the TTL": "Rentals.Leave reports owed from final ledger state; TestAPI_LeaveProviderRefusalIsReleaseOwedAndReaperFinishes (asserts release_owed then Reap tears it down with a fresh 24h lease)", "a zone-delete failure -> 502 with the name NOT freed and the host record + secret intact, rentals stay released/owed; retry with same secret completes (47b)": "performLeave releases rentals first, DeleteRecords last; TestAPI_LeaveZoneDeleteFailureKeepsTheNameHeldThenRetryCompletes", "a retry after a completed leave returns the recorded tombstone outcome and re-asks owed teardown; after re-claim answers 410 (48)": "Issuer.Leave free-slug tombstone-replay branch + ErrAlreadyLeft (410); TestAPI_LeaveRetryReturnsTombstoneOutcomeThen410AfterReclaim", "a host with no rental leaves with name_freed only": "Rentals.Leave hadAny=false -> released=false owed=false; TestAPI_LeaveHostWithNoRentalFreesTheNameOnly", "the ledger survives a broker restart with tombstones intact; an existing ledger with no tombstones loads unchanged": "store.go additive tombstones field on reservationDoc (no version bump), broker.go OpenRegistry/persistLocked thread them; TestLeave_TombstoneSurvivesRestartAndReplaysTheRecordedOutcome + TestLeave_ExistingLedgerWithNoTombstonesLoadsUnchanged", "the broker client's Leave parses the outcome and surfaces 401/403/410/502 refusals in the broker's own words": "brokerclient/client.go Client.Leave + LeaveOutcome; TestClient_LeaveParsesTheOutcome, TestClient_LeaveParsesReleaseOwed, TestClient_LeaveSurfacesRefusalsVerbatim", "broker HTTP tests in the style of rent/release, offboard-frees-slug and release-owed/reaper; go test for the broker module and the broker client green": "http_leave_test.go (7 cases) + leave_test.go (2 cases) + brokerclient Leave (3 cases); go test broker + brokerclient exit 0, gofmt/vet/golangci-lint clean" }, "summary": "Added the broker leave verb — free the name and release every rental under the host in one claim-secret-gated act, with a durable tombstone for truthful retries — plus the brokerclient Leave call.", "reason": "", "blockers": [], "no_code_change": "" } ``` </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#1785
No description provided.