broker: stop TTL-reaping rented community gateways — keep release-owed retries and rehearsal TTLs (amends ADR 0189 ruling 1) #2202

Closed
opened 2026-11-19 14:47:44 +00:00 by ben · 4 comments
Owner

What

Ben ruled 2026-11-19: a rented community gateway is never destroyed because its lease lapsed. The broker's reaper (Rentals.Reap, broker/internal/broker/rentals.go, run every 5 min from cmd/broker/main.go) destroys every unreleased rental whose Expires has passed — so a founder who closes the operator app for more than the 24h default TTL (ADR 0189 ruling 1) loses their gateway, mid-founding or after. Stop that.

Ruling (Ben, 2026-11-19 — this amends ADR 0189 ruling 1)

  1. A lapsed lease on a community gateway or device lease is not reaped. The reaper keeps its other duty unchanged: a lease whose teardown is owed (ReleaseOwed, #756 — the member already gave it up and the provider refused the destroy) is still retried every pass.
  2. Rehearsal boxes keep the TTL. A lease on an idss-gateway-rehearsal-* / rehearsal host this repo's own drives rent is still reaped on lapse — the same class scripts/rental-reap.sh is already allowed to destroy. Real-community rentals are reported, never deleted (that sweep already behaves this way; the broker now matches it).
  3. An explicit abandon still releases. Re-rent, switching Access, and the walk's release leg (ADR 0189 ruling 4 / DDR 0142 §4) are untouched — they call Release, not the TTL.
  4. A lapsed community lease is reported, not destroyed: one structured log line per pass per lapsed host (host, server id, IP, how long lapsed), so the monthly manual sweep (Ben, 2026-11-19) has a list to work from. No page, no automatic action.
  5. The droplet's idss-rental-expires-<epoch> tag and the renew heartbeat stay — the lease is still the record of "is anyone still here", it just no longer kills the box.

Why

The founder may legitimately step away for longer than a day (registrar DNS, #2184/#2186; a weekend). Until operator email is verified (ticket filed alongside this one) there is no way to reach a founder whose box was reaped, and nothing in the app explains it. Ben accepts the cost: an abandoned box with no heartbeat bills until the monthly manual sweep.

Task manifest

task: no-ttl-reap-for-community-rentals
interface: |
  Rentals.Reap: targets = ReleaseOwed  OR  (lapsed AND isRehearsalHost(host))
  a lapsed, unreleased, non-rehearsal rental is logged ("lapsed lease — kept, manual sweep") and left live
  isRehearsalHost: the same prefix class scripts/rental-reap.sh may destroy (idss-gateway-rehearsal-* hosts)
binds:
  - symbol: Rentals.Reap
    defined_in: broker/internal/broker/rentals.go
seam: broker/internal/broker rentals_expiry_test.go + rentals_release_owed_test.go (fake provider, injected clock)
unproven_by_seam: a real DigitalOcean droplet surviving past its lease (no live leg; the fake provider records Destroy calls)
acceptance:
  - given: an unreleased community gateway rental whose lease lapsed an hour ago
    when: Reap runs
    then: Destroy is not called, the rental stays unreleased, its DNS records are untouched, and one lapsed-lease line is logged naming the host
  - given: an unreleased rehearsal-host rental whose lease lapsed
    when: Reap runs
    then: it is destroyed and marked released exactly as today
  - given: a community rental with ReleaseOwed set
    when: Reap runs
    then: Destroy is retried exactly as today (#756)
  - given: a community device lease (deviceRentalKey) past its lease
    when: Reap runs
    then: it is kept and reported like a gateway lease
depends_on: []
out_of_scope: [operator-email-verification, rental-billing, automatic-abandoned-box-cleanup, rental-reap.sh-changes, renew-heartbeat-changes]
needs_human_decision: []

The same commit amends ADR 0189 (an Amended 2026-11-19 note under ruling 1 citing this ticket), updates STATUS.md, and touches any docs/architecture/ diagram that encodes the TTL reap. broker/** is a deployed-service tree: once merged this goes deploy-pending until the broker install carries it.

Related: ADR 0189, #741, #756, #758, scripts/rental-reap.sh, #2184, #2186.

## What Ben ruled 2026-11-19: **a rented community gateway is never destroyed because its lease lapsed.** The broker's reaper (`Rentals.Reap`, `broker/internal/broker/rentals.go`, run every 5 min from `cmd/broker/main.go`) destroys every unreleased rental whose `Expires` has passed — so a founder who closes the operator app for more than the 24h default TTL (ADR 0189 ruling 1) loses their gateway, mid-founding or after. Stop that. ## Ruling (Ben, 2026-11-19 — this amends ADR 0189 ruling 1) 1. **A lapsed lease on a community gateway or device lease is not reaped.** The reaper keeps its other duty unchanged: a lease whose teardown is **owed** (`ReleaseOwed`, #756 — the member already gave it up and the provider refused the destroy) is still retried every pass. 2. **Rehearsal boxes keep the TTL.** A lease on an `idss-gateway-rehearsal-*` / rehearsal host this repo's own drives rent is still reaped on lapse — the same class `scripts/rental-reap.sh` is already allowed to destroy. Real-community rentals are reported, never deleted (that sweep already behaves this way; the broker now matches it). 3. **An explicit abandon still releases.** Re-rent, switching Access, and the walk's release leg (ADR 0189 ruling 4 / DDR 0142 §4) are untouched — they call `Release`, not the TTL. 4. **A lapsed community lease is reported, not destroyed:** one structured log line per pass per lapsed host (host, server id, IP, how long lapsed), so the **monthly manual sweep** (Ben, 2026-11-19) has a list to work from. No page, no automatic action. 5. The droplet's `idss-rental-expires-<epoch>` tag and the renew heartbeat stay — the lease is still the record of "is anyone still here", it just no longer kills the box. ## Why The founder may legitimately step away for longer than a day (registrar DNS, #2184/#2186; a weekend). Until operator email is verified (ticket filed alongside this one) there is no way to reach a founder whose box was reaped, and nothing in the app explains it. Ben accepts the cost: an abandoned box with no heartbeat bills until the monthly manual sweep. ## Task manifest ```yaml task: no-ttl-reap-for-community-rentals interface: | Rentals.Reap: targets = ReleaseOwed OR (lapsed AND isRehearsalHost(host)) a lapsed, unreleased, non-rehearsal rental is logged ("lapsed lease — kept, manual sweep") and left live isRehearsalHost: the same prefix class scripts/rental-reap.sh may destroy (idss-gateway-rehearsal-* hosts) binds: - symbol: Rentals.Reap defined_in: broker/internal/broker/rentals.go seam: broker/internal/broker rentals_expiry_test.go + rentals_release_owed_test.go (fake provider, injected clock) unproven_by_seam: a real DigitalOcean droplet surviving past its lease (no live leg; the fake provider records Destroy calls) acceptance: - given: an unreleased community gateway rental whose lease lapsed an hour ago when: Reap runs then: Destroy is not called, the rental stays unreleased, its DNS records are untouched, and one lapsed-lease line is logged naming the host - given: an unreleased rehearsal-host rental whose lease lapsed when: Reap runs then: it is destroyed and marked released exactly as today - given: a community rental with ReleaseOwed set when: Reap runs then: Destroy is retried exactly as today (#756) - given: a community device lease (deviceRentalKey) past its lease when: Reap runs then: it is kept and reported like a gateway lease depends_on: [] out_of_scope: [operator-email-verification, rental-billing, automatic-abandoned-box-cleanup, rental-reap.sh-changes, renew-heartbeat-changes] needs_human_decision: [] ``` The same commit amends ADR 0189 (an **Amended 2026-11-19** note under ruling 1 citing this ticket), updates `STATUS.md`, and touches any `docs/architecture/` diagram that encodes the TTL reap. `broker/**` is a deployed-service tree: once merged this goes `deploy-pending` until the broker install carries it. Related: ADR 0189, #741, #756, #758, `scripts/rental-reap.sh`, #2184, #2186.
Author
Owner

Siblings filed together from the #2184/#2186 design interview (Ben, 2026-11-19): #2202 (no TTL reap), #2203 (verify the operator email at S2), #2204 (congratulations + 30-day invoice email, blocked by #2203).

Siblings filed together from the #2184/#2186 design interview (Ben, 2026-11-19): #2202 (no TTL reap), #2203 (verify the operator email at S2), #2204 (congratulations + 30-day invoice email, blocked by #2203).

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

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

⏩ independent reviewer for #2202 — verdict unauthenticated

review JSON
{
  "verdict": "unauthenticated",
  "findings": []
}
:fast_forward: **independent reviewer** for #2202 — verdict `unauthenticated` <details><summary>review JSON</summary> ```json { "verdict": "unauthenticated", "findings": [] } ``` </details>

close-report for #2202 — status success

✅ close-report gates passed — every claim verified against the pushed worker branch sandcastle/worker/20261119145335-2652841 (pre-land — the host promotes it to main only after its post-run verify, #193/#283); issue closed.

envelope
{
  "issue": 2202,
  "status": "success",
  "commits": [
    "b0682ca77218f163f4ca53cdcd6a840acfcd0402"
  ],
  "changed_files": [
    "STATUS.md",
    "broker/internal/broker/http_device_test.go",
    "broker/internal/broker/rentals.go",
    "broker/internal/broker/rentals_no_ttl_reap_test.go",
    "broker/internal/broker/rentals_test.go",
    "broker/internal/broker/rentals_zone_cleanup_test.go",
    "docs/adr/0189-rented-gateways-free-while-alpha-ttl-reaped-pubkey-in-release-on-abandon.md",
    "docs/architecture/01-system-context.md",
    "docs/architecture/02-containers.md"
  ],
  "tests": [
    {
      "command": "go test ./... (broker module)",
      "exit_code": 0
    },
    {
      "command": "go vet ./internal/broker/ (broker module)",
      "exit_code": 0
    },
    {
      "command": "gofmt -l (changed Go files) — clean",
      "exit_code": 0
    },
    {
      "command": "pre-push nix develop .#go-ci gate (go test ./... + golangci-lint '0 issues', both tiers) — passed on push",
      "exit_code": 0
    }
  ],
  "criteria": {
    "given an unreleased community gateway rental whose lease lapsed an hour ago, when Reap runs, then Destroy is not called, the rental stays unreleased, its DNS records are untouched, and one lapsed-lease line is logged naming the host": "rentals.go Reap now routes a lapsed non-rehearsal lease into `kept` (logged, never destroyed); proven by TestReap_KeepsLapsedCommunityGateway_AndReports in rentals_no_ttl_reap_test.go (asserts destroyed==0, Destroyed empty, rec.Released==false, zone.records unchanged, exactly one 'lapsed lease — kept, manual sweep' line naming kahui.idss.nz)",
    "given an unreleased rehearsal-host rental whose lease lapsed, when Reap runs, then it is destroyed and marked released exactly as today": "new isRehearsalHost (slug prefix 'rehearsal-') keeps the lapse reap for drive boxes; proven by TestReap_StillReapsLapsedRehearsalDriveBox (rehearsal-b.idss.nz destroyed + released + DNS cleared) and the retargeted TestReap_DestroysLapsedUnreleasedOnly / TestReap_ClearsRecordsNamingTheDestroyedIP",
    "given a community rental with ReleaseOwed set, when Reap runs, then Destroy is retried exactly as today (#756)": "Reap's ReleaseOwed branch is unchanged (retried every pass, any class); proven by TestReap_StillRetriesAReleaseOwedCommunityRental plus the pre-existing TestReap_TearsDownAReleaseOwedRentalWithoutWaitingForItsTTL / http_leave reaper-finishes test",
    "given a community device lease (deviceRentalKey) past its lease, when Reap runs, then it is kept and reported like a gateway lease": "device key's slug (via slugOfHost) is non-rehearsal for a real community, so it routes to `kept`; proven by TestReap_KeepsLapsedCommunityDeviceLease_AndReports (destroyed==0, lease kept unreleased, one reported line naming the device key) and the retargeted TestDevice_RentThreadsUserDataAndRecordsReapableRental"
  },
  "binds": [
    {
      "symbol": "Rentals.Reap",
      "defined_in": "broker/internal/broker/rentals.go"
    }
  ],
  "summary": "Rentals.Reap no longer TTL-reaps a lapsed real community gateway/device lease — it keeps and reports it (monthly manual sweep), while still reaping lapsed rehearsal drive boxes and retrying owed teardowns; amends ADR 0189 ruling 1.",
  "blockers": []
}
**close-report** for #2202 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against the pushed worker branch `sandcastle/worker/20261119145335-2652841` (pre-land — the host promotes it to `main` only after its post-run verify, #193/#283); issue closed. <details><summary>envelope</summary> ```json { "issue": 2202, "status": "success", "commits": [ "b0682ca77218f163f4ca53cdcd6a840acfcd0402" ], "changed_files": [ "STATUS.md", "broker/internal/broker/http_device_test.go", "broker/internal/broker/rentals.go", "broker/internal/broker/rentals_no_ttl_reap_test.go", "broker/internal/broker/rentals_test.go", "broker/internal/broker/rentals_zone_cleanup_test.go", "docs/adr/0189-rented-gateways-free-while-alpha-ttl-reaped-pubkey-in-release-on-abandon.md", "docs/architecture/01-system-context.md", "docs/architecture/02-containers.md" ], "tests": [ { "command": "go test ./... (broker module)", "exit_code": 0 }, { "command": "go vet ./internal/broker/ (broker module)", "exit_code": 0 }, { "command": "gofmt -l (changed Go files) — clean", "exit_code": 0 }, { "command": "pre-push nix develop .#go-ci gate (go test ./... + golangci-lint '0 issues', both tiers) — passed on push", "exit_code": 0 } ], "criteria": { "given an unreleased community gateway rental whose lease lapsed an hour ago, when Reap runs, then Destroy is not called, the rental stays unreleased, its DNS records are untouched, and one lapsed-lease line is logged naming the host": "rentals.go Reap now routes a lapsed non-rehearsal lease into `kept` (logged, never destroyed); proven by TestReap_KeepsLapsedCommunityGateway_AndReports in rentals_no_ttl_reap_test.go (asserts destroyed==0, Destroyed empty, rec.Released==false, zone.records unchanged, exactly one 'lapsed lease — kept, manual sweep' line naming kahui.idss.nz)", "given an unreleased rehearsal-host rental whose lease lapsed, when Reap runs, then it is destroyed and marked released exactly as today": "new isRehearsalHost (slug prefix 'rehearsal-') keeps the lapse reap for drive boxes; proven by TestReap_StillReapsLapsedRehearsalDriveBox (rehearsal-b.idss.nz destroyed + released + DNS cleared) and the retargeted TestReap_DestroysLapsedUnreleasedOnly / TestReap_ClearsRecordsNamingTheDestroyedIP", "given a community rental with ReleaseOwed set, when Reap runs, then Destroy is retried exactly as today (#756)": "Reap's ReleaseOwed branch is unchanged (retried every pass, any class); proven by TestReap_StillRetriesAReleaseOwedCommunityRental plus the pre-existing TestReap_TearsDownAReleaseOwedRentalWithoutWaitingForItsTTL / http_leave reaper-finishes test", "given a community device lease (deviceRentalKey) past its lease, when Reap runs, then it is kept and reported like a gateway lease": "device key's slug (via slugOfHost) is non-rehearsal for a real community, so it routes to `kept`; proven by TestReap_KeepsLapsedCommunityDeviceLease_AndReports (destroyed==0, lease kept unreleased, one reported line naming the device key) and the retargeted TestDevice_RentThreadsUserDataAndRecordsReapableRental" }, "binds": [ { "symbol": "Rentals.Reap", "defined_in": "broker/internal/broker/rentals.go" } ], "summary": "Rentals.Reap no longer TTL-reaps a lapsed real community gateway/device lease — it keeps and reports it (monthly manual sweep), while still reaping lapsed rehearsal drive boxes and retrying owed teardowns; amends ADR 0189 ruling 1.", "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.

Dependencies

No dependencies set.

Reference
Matou/idss#2202
No description provided.