deploy: member-device routable-port removal and gateway co-host FILES removal fall to bare DetachService (sibling of #1348) #1349

Closed
opened 2026-09-09 06:15:02 +00:00 by matou-build-agent · 3 comments

Split out of #1348. That fix added the removal mirror (clan.DetachPort + detachCohostPort) for a routable forward-auth port removed from a GATEWAY CO-HOST. Two sibling paths in deployServicesOnly's removed loop (internal/provision/deploy.go) still fall to bare Config().DetachService, which edits only the inventory JSON and leaves the <slug>.nix module on disk — the same defect class #1348 documents (GOTCHAS #207):

  1. A routable PORT removed from a real MEMBER DEVICE (mesh address + gateway). attachRoutablePort composes the member entry module + front-door mesh route on attach, but the removed loop only DetachServices it — the module stays imported and routed, and machineServices keeps reporting it. Needs a detachMemberPort mirror (DetachPort + composeMemberEntry without it + front-door rewrite), analogous to detachMemberFilesPlacement.

  2. FILES removed from a GATEWAY CO-HOST. The files block only handles the member-device case; a gateway co-host files untick falls to bare DetachService. Its mirror is more involved (Nextcloud + the EnableGatewayNextcloudExport control-plane export whose generator lives in files.nix — dropping files.nix without unwinding the export is a Nix eval error), so it needs its own design, not detachCohostPort.

The brand-reach drive only exercises gateway co-host routable ports, so these are latent but real. Prove each with a red-first provision-layer test mirroring TestDeploy_GatewayCohostPortRemovalDropsTheModule.

Split out of #1348. That fix added the removal mirror (`clan.DetachPort` + `detachCohostPort`) for a routable forward-auth port removed from a GATEWAY CO-HOST. Two sibling paths in `deployServicesOnly`'s removed loop (`internal/provision/deploy.go`) still fall to bare `Config().DetachService`, which edits only the inventory JSON and leaves the `<slug>.nix` module on disk — the same defect class #1348 documents (GOTCHAS #207): 1. **A routable PORT removed from a real MEMBER DEVICE** (mesh address + gateway). `attachRoutablePort` composes the member entry module + front-door mesh route on attach, but the removed loop only DetachServices it — the module stays imported and routed, and `machineServices` keeps reporting it. Needs a `detachMemberPort` mirror (DetachPort + `composeMemberEntry` without it + front-door rewrite), analogous to `detachMemberFilesPlacement`. 2. **FILES removed from a GATEWAY CO-HOST.** The files block only handles the member-device case; a gateway co-host files untick falls to bare DetachService. Its mirror is more involved (Nextcloud + the `EnableGatewayNextcloudExport` control-plane export whose generator lives in `files.nix` — dropping `files.nix` without unwinding the export is a Nix eval error), so it needs its own design, not `detachCohostPort`. The brand-reach drive only exercises gateway co-host routable ports, so these are latent but real. Prove each with a red-first provision-layer test mirroring `TestDeploy_GatewayCohostPortRemovalDropsTheModule`.
Author
Member

This was generated by AI during triage.

Agent Brief

Category: bug
Summary: Two sibling removal paths in the services-only deploy loop fall to bare DetachService, leaving the removed service's module on disk (still imported, routed, and running) — the same defect class #1348 fixed for gateway co-host routable ports (GOTCHAS #207).

Current behavior:
In the provisioning orchestrator's services-only removal loop (deployServicesOnly), only two removal cases have a full mirror of their attach path:

  • Files removed from a member device → detachMemberFilesPlacement.
  • A routable forward-auth port removed from a gateway co-host → detachCohostPort (the #1348 fix).

Every other removal falls to Config().DetachService, which edits only the inventory JSON. A routable port's render and a files placement both land a module FILE / import, so a DetachService-only removal leaves <slug>.nix on disk — still imported, still routed, still reported by machineServices as deployed. Two such paths are still latent:

  1. A routable PORT removed from a real MEMBER DEVICE (mesh address + gateway front-door route). attachRoutablePort composes the member entry module + front-door mesh route on attach, but the removed loop only DetachServices it.
  2. FILES removed from a GATEWAY CO-HOST. The files branch only handles the member-device case; a gateway co-host files untick falls through to bare DetachService.

The brand-reach drive only exercises gateway co-host routable ports, so both are latent but real.

Desired behavior:
Each of the two removals fully unwinds what its attach path composed, mirroring the two existing detach helpers:

  1. Member-device routable port removal — add a detachMemberPort mirror analogous to detachMemberFilesPlacement: drop the port module (DetachPort), recompose the member entry module (composeMemberEntry) without it, and rewrite the gateway front door WITHOUT the route. After removal, machineServices no longer reports the slug and the guest stops serving it.

  2. Gateway co-host files removal — this one needs its own unwind design, not detachCohostPort: the files block wires Nextcloud plus the EnableGatewayNextcloudExport control-plane export whose generator lives in files.nix. Dropping files.nix without first unwinding the export is a Nix eval error, so the removal must unwind the export before/with dropping the module. Design and build the correct co-host files detach so removal leaves no dangling module or export.

Key interfaces:

  • The removal branch of deployServicesOnly (the removed/deselected loop) — currently routes member-files and cohost-routable-port through dedicated detach helpers and everything else through Config().DetachService. Add the two missing routes.
  • detachMemberFilesPlacement / detachCohostPort — the existing mirrors to model the new helpers on (DetachPort/DetachService + composeMemberEntry + front-door rewrite).
  • attachRoutablePort (member-device branch) and the files/EnableGatewayNextcloudExport attach path — the compose steps each detach must reverse.

Acceptance criteria:

  • A red-first provision-layer test (mirroring TestDeploy_GatewayCohostPortRemovalDropsTheModule) proves that removing a routable port from a member device drops the module, the front-door route, and the import — and that machineServices no longer reports the slug. It fails before the fix and passes after.
  • A red-first provision-layer test proves that removing files from a gateway co-host unwinds the Nextcloud module AND the EnableGatewayNextcloudExport export with no Nix eval error and no <slug>.nix left on disk. It fails before the fix and passes after.
  • No behavioral change to the two removal paths that already have mirrors (member-device files, gateway co-host routable port) or to plain inventory-only detaches.

Out of scope:

  • The interrupted-run persistence/resume gap (that is #1350).
  • Strengthening the brand-reach drive's remove legs to reach the guest (that is #1351).
  • Any change to the attach paths.
> *This was generated by AI during triage.* ## Agent Brief **Category:** bug **Summary:** Two sibling removal paths in the services-only deploy loop fall to bare `DetachService`, leaving the removed service's module on disk (still imported, routed, and running) — the same defect class #1348 fixed for gateway co-host routable ports (GOTCHAS #207). **Current behavior:** In the provisioning orchestrator's services-only removal loop (`deployServicesOnly`), only two removal cases have a full mirror of their attach path: - Files removed from a **member device** → `detachMemberFilesPlacement`. - A routable forward-auth port removed from a **gateway co-host** → `detachCohostPort` (the #1348 fix). Every other removal falls to `Config().DetachService`, which edits only the inventory JSON. A routable port's render and a files placement both land a module FILE / import, so a DetachService-only removal leaves `<slug>.nix` on disk — still imported, still routed, still reported by `machineServices` as deployed. Two such paths are still latent: 1. **A routable PORT removed from a real MEMBER DEVICE** (mesh address + gateway front-door route). `attachRoutablePort` composes the member entry module + front-door mesh route on attach, but the removed loop only `DetachService`s it. 2. **FILES removed from a GATEWAY CO-HOST.** The files branch only handles the member-device case; a gateway co-host files untick falls through to bare `DetachService`. The brand-reach drive only exercises gateway co-host routable ports, so both are latent but real. **Desired behavior:** Each of the two removals fully unwinds what its attach path composed, mirroring the two existing detach helpers: 1. **Member-device routable port removal** — add a `detachMemberPort` mirror analogous to `detachMemberFilesPlacement`: drop the port module (`DetachPort`), recompose the member entry module (`composeMemberEntry`) without it, and rewrite the gateway front door WITHOUT the route. After removal, `machineServices` no longer reports the slug and the guest stops serving it. 2. **Gateway co-host files removal** — this one needs its own unwind design, not `detachCohostPort`: the files block wires Nextcloud plus the `EnableGatewayNextcloudExport` control-plane export whose generator lives in `files.nix`. Dropping `files.nix` without first unwinding the export is a Nix eval error, so the removal must unwind the export before/with dropping the module. Design and build the correct co-host files detach so removal leaves no dangling module or export. **Key interfaces:** - The removal branch of `deployServicesOnly` (the `removed`/deselected loop) — currently routes member-files and cohost-routable-port through dedicated detach helpers and everything else through `Config().DetachService`. Add the two missing routes. - `detachMemberFilesPlacement` / `detachCohostPort` — the existing mirrors to model the new helpers on (`DetachPort`/`DetachService` + `composeMemberEntry` + front-door rewrite). - `attachRoutablePort` (member-device branch) and the files/`EnableGatewayNextcloudExport` attach path — the compose steps each detach must reverse. **Acceptance criteria:** - [ ] A red-first provision-layer test (mirroring `TestDeploy_GatewayCohostPortRemovalDropsTheModule`) proves that removing a routable port from a **member device** drops the module, the front-door route, and the import — and that `machineServices` no longer reports the slug. It fails before the fix and passes after. - [ ] A red-first provision-layer test proves that removing **files** from a **gateway co-host** unwinds the Nextcloud module AND the `EnableGatewayNextcloudExport` export with no Nix eval error and no `<slug>.nix` left on disk. It fails before the fix and passes after. - [ ] No behavioral change to the two removal paths that already have mirrors (member-device files, gateway co-host routable port) or to plain inventory-only detaches. **Out of scope:** - The interrupted-run persistence/resume gap (that is #1350). - Strengthening the brand-reach drive's remove legs to reach the guest (that is #1351). - Any change to the attach paths.
Author
Member

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

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

close-report for #1349 — status success

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

envelope
{
  "issue": 1349,
  "status": "success",
  "commits": [
    "884b3130"
  ],
  "changed_files": [
    "STATUS.md",
    "control-plane/cmd/control-plane/resting_composition.go",
    "docs/GOTCHAS.md",
    "internal/clan/clan.go",
    "internal/clan/files_attach.go",
    "internal/clan/files_detach_test.go",
    "internal/clan/gateway_attach.go",
    "internal/clan/gateway_attach_test.go",
    "internal/clan/portroute.go",
    "internal/clan/testing/fake.go",
    "internal/provision/deploy.go",
    "internal/provision/deploy_ports_test.go",
    "internal/provision/deploy_test.go"
  ],
  "tests": [
    {
      "command": "go test ./internal/clan/... ./internal/provision/...",
      "exit_code": 0
    },
    {
      "command": "go test ./internal/rescue/... ./internal/monitor/... ./control-plane/...",
      "exit_code": 0
    },
    {
      "command": "go vet ./internal/clan/... ./internal/provision/...",
      "exit_code": 0
    },
    {
      "command": "go build ./...",
      "exit_code": 0
    }
  ],
  "criteria": {
    "A red-first provision-layer test (mirroring TestDeploy_GatewayCohostPortRemovalDropsTheModule) proves that removing a routable port from a member device drops the module, the front-door route, and the import — and that machineServices no longer reports the slug. It fails before the fix and passes after.": "TestDeploy_MemberDevicePortRemovalDropsTheModule (internal/provision/deploy_ports_test.go): per routable port asserts one DetachPort on the member device (drops the <slug>.nix module the deployed-set signal keys on), a front-door rewrite WITHOUT the mesh route, and a member entry-module recompose WITHOUT the module. Verified red before fix (DetachPortCalls empty → fail) via a stash of deploy.go, green after — commit 884b3130.",
    "A red-first provision-layer test proves that removing files from a gateway co-host unwinds the Nextcloud module AND the EnableGatewayNextcloudExport export with no Nix eval error and no <slug>.nix left on disk. It fails before the fix and passes after.": "TestDeploy_GatewayCohostFilesRemovalUnwindsTheModuleAndExport (internal/provision/deploy_ports_test.go): asserts one DisableGatewayNextcloudExport (drops the IDSS_NEXTCLOUD_ADMIN export) that runs BEFORE the DetachFiles module drop (so files.nix's nextcloud-admin generator is never dangling — the Nix eval error is avoided), plus a routeless front-door rewrite and a ComposeGatewayCohost recompose. Verified red before fix (DetachFilesCalls empty → fail). Clan-seam TestDetachFiles_RemovesModuleFromDeployedSet proves files.nix is deleted (ReadDeployedServices loses files, file gone on disk) and TestDisableGatewayNextcloudExport_DropsTheExport proves the surface stops dereferencing the nextcloud-admin generator while keeping every founding export. Commit 884b3130.",
    "No behavioral change to the two removal paths that already have mirrors (member-device files, gateway co-host routable port) or to plain inventory-only detaches.": "The existing member-device-files branch (detachMemberFilesPlacement) and gateway-co-host routable-port branch (detachCohostPort) are unchanged; the new branches are added ahead of the unchanged bare-DetachService default. TestDeploy_GatewayCohostPortRemovalDropsTheModule still passes unchanged; full internal/provision + internal/clan suites green. DetachPort behaviour is preserved by the shared detachModuleFile refactor (TestDetachPort_* still pass)."
  },
  "summary": "Added detachMemberPort and detachCohostFiles removal mirrors (backed by new clan.DetachFiles + clan.DisableGatewayNextcloudExport) so a member-device routable-port removal and a gateway-co-host files removal drop the module and unwind the export instead of falling to bare DetachService.",
  "reason": "Closes the two sibling removal gaps GOTCHAS #207 named as follow-ups; both ruled two-way under ADR 0174 (bugs against ADR 0210 ruling 5's stated removal-mirror contract), proven red-first at the provision seam.",
  "blockers": []
}
**close-report** for #1349 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 1349, "status": "success", "commits": [ "884b3130" ], "changed_files": [ "STATUS.md", "control-plane/cmd/control-plane/resting_composition.go", "docs/GOTCHAS.md", "internal/clan/clan.go", "internal/clan/files_attach.go", "internal/clan/files_detach_test.go", "internal/clan/gateway_attach.go", "internal/clan/gateway_attach_test.go", "internal/clan/portroute.go", "internal/clan/testing/fake.go", "internal/provision/deploy.go", "internal/provision/deploy_ports_test.go", "internal/provision/deploy_test.go" ], "tests": [ { "command": "go test ./internal/clan/... ./internal/provision/...", "exit_code": 0 }, { "command": "go test ./internal/rescue/... ./internal/monitor/... ./control-plane/...", "exit_code": 0 }, { "command": "go vet ./internal/clan/... ./internal/provision/...", "exit_code": 0 }, { "command": "go build ./...", "exit_code": 0 } ], "criteria": { "A red-first provision-layer test (mirroring TestDeploy_GatewayCohostPortRemovalDropsTheModule) proves that removing a routable port from a member device drops the module, the front-door route, and the import — and that machineServices no longer reports the slug. It fails before the fix and passes after.": "TestDeploy_MemberDevicePortRemovalDropsTheModule (internal/provision/deploy_ports_test.go): per routable port asserts one DetachPort on the member device (drops the <slug>.nix module the deployed-set signal keys on), a front-door rewrite WITHOUT the mesh route, and a member entry-module recompose WITHOUT the module. Verified red before fix (DetachPortCalls empty → fail) via a stash of deploy.go, green after — commit 884b3130.", "A red-first provision-layer test proves that removing files from a gateway co-host unwinds the Nextcloud module AND the EnableGatewayNextcloudExport export with no Nix eval error and no <slug>.nix left on disk. It fails before the fix and passes after.": "TestDeploy_GatewayCohostFilesRemovalUnwindsTheModuleAndExport (internal/provision/deploy_ports_test.go): asserts one DisableGatewayNextcloudExport (drops the IDSS_NEXTCLOUD_ADMIN export) that runs BEFORE the DetachFiles module drop (so files.nix's nextcloud-admin generator is never dangling — the Nix eval error is avoided), plus a routeless front-door rewrite and a ComposeGatewayCohost recompose. Verified red before fix (DetachFilesCalls empty → fail). Clan-seam TestDetachFiles_RemovesModuleFromDeployedSet proves files.nix is deleted (ReadDeployedServices loses files, file gone on disk) and TestDisableGatewayNextcloudExport_DropsTheExport proves the surface stops dereferencing the nextcloud-admin generator while keeping every founding export. Commit 884b3130.", "No behavioral change to the two removal paths that already have mirrors (member-device files, gateway co-host routable port) or to plain inventory-only detaches.": "The existing member-device-files branch (detachMemberFilesPlacement) and gateway-co-host routable-port branch (detachCohostPort) are unchanged; the new branches are added ahead of the unchanged bare-DetachService default. TestDeploy_GatewayCohostPortRemovalDropsTheModule still passes unchanged; full internal/provision + internal/clan suites green. DetachPort behaviour is preserved by the shared detachModuleFile refactor (TestDetachPort_* still pass)." }, "summary": "Added detachMemberPort and detachCohostFiles removal mirrors (backed by new clan.DetachFiles + clan.DisableGatewayNextcloudExport) so a member-device routable-port removal and a gateway-co-host files removal drop the module and unwind the export instead of falling to bare DetachService.", "reason": "Closes the two sibling removal gaps GOTCHAS #207 named as follow-ups; both ruled two-way under ADR 0174 (bugs against ADR 0210 ruling 5's stated removal-mirror contract), proven red-first at the provision seam.", "blockers": [] } ``` </details>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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#1349
No description provided.