remove-device: the standing agent's #1219 revocation guard polls the founding relay socket, not the community gateway — a device install never carries IDSS_COMMUNITY_ORIGIN into the agent unit #1220

Closed
opened 2026-09-04 18:18:44 +00:00 by matou-build-agent · 2 comments

The failure

remove-device red on drive 20260904T174618Z (commit b0b0ba65, the #1219 pull mirror). Legs 1–13 green; the fleet-side offboard landed (assertFleetGatewayOnly passed), but the host kept its guest — unit still is-active active, /var/lib/idss/vm/guest.qcow2 still on disk at 18:12 (3.2 GB, mtime 18:12 — the guest was still writing). The leg's 180 s poll (app/tests/e2e/journey.device.spec.ts:1163-1183) ran to its deadline and threw the last probe's residue.

The drive's check is right and the product is wrong: the teardown never ran.

The evidence

The guard #1219 added is wired and ticking — it simply cannot reach the gateway. From the FIRST tick after the landing to the end of the run (quoting normalised):

Sep 04 17:55:46 … idss-agent[8389] level=ERROR msg='enrolled guard: poll did not answer — retrying next tick'
  err='join: guard poll: enrollwire: GET http://enroll-relay/api/v1/enroll/requests/req-0003?wait=0: context deadline exceeded'

logs/device-journal.txt:488 through :1937 — 35 identical failures exactly 30 s apart (17:55:46 → 18:12:46), and nothing else. So:

  • the anchor flipped to its guard form — /var/lib/idss/resume.json, 67 bytes, mtime 17:55 (logs/device-journal.txt:2009): saveEnrolledAnchor ran;
  • GuardEnrolledOnce (internal/join/resume.go:182) is called each tick from guardOnce (agent/cmd/agent/main.go:384-403);
  • o.cfg.ControlPlane.Poll never answers, so the guard returns an error before it can ever see the Closure{Revoked} the offboard wrote.

http://enroll-relay is the FOUNDING-shape base. agent/cmd/agent/wiring_prod.go:148-157:

origin := os.Getenv("IDSS_COMMUNITY_ORIGIN")
if origin == "" {
	hc := relayHTTPClient(enrollRelaySocket())   // dials /run/idss/enroll-relay.sock
	const base = "http://enroll-relay"

The standing service is running with an EMPTY IDSS_COMMUNITY_ORIGIN, so it dials the app's SSH relay-carrier socket (ADR 0043/0181) — which does not exist on a device box that joined a real remote gateway (rehearsal-e.idss.nz / 170.64.139.203, per founding-state.log; the device box is 170.64.191.183). dialRelay retries the ENOENT for its 30 s budget (wiring_prod.go:204-229), but Poll's own ctx is 15 s (wait=0 + pollSlack, internal/enrollwire/client.go:21,71-80) — hence context deadline exceeded every 15 s, forever.

The defect

The origin never reaches the standing unit.

  • internal/controlapi/installscript.go:70-72 sets it as a per-command assignment — IDSS_COMMUNITY_ORIGIN=<apex> idss-agent install "$1". It lives in that one process's environment only.
  • internal/install/install.go:304-315 — Service.unitFile() renders the standing unit as [Service] / ExecStart=<bin> join / Restart=always, with no Environment= line, and Service (install.go:109-134) holds no origin to render one from. Nothing else in the tree writes that unit.
  • So idss-agent join under systemd (runJoin, agent/cmd/agent/main.go:287-336) resolves its transport with no origin and silently takes the founding branch.

This is a latent misconfiguration #1219 lit up. Before it, the standing service's control-plane transport was only exercised by the stranded-join resume (ResumeStrandedOnce) — never reached on a healthy drive, because Enroll cleared the anchor at landing. #1219 made Enroll KEEP the anchor (internal/join/land.go:151-162) and made the standing service poll every tick, putting the founding-shape fallback on the critical path of the removal contract.

That the join itself was green confirms the split: the foreground idss-agent enroll carries the origin on its own command line (app/tests/e2e/journey.device.spec.ts:667) and reaches the gateway fine. Two processes, two transports; only the standing one is misconfigured.

Suspected layer

Agent install wiring — internal/install plus agent/cmd/agent/wiring_prod.go. Not the harness: the leg's probe, poll and 180 s deadline are all correct, and the fleet side of the offboard did its part.

Why I refused — REFUSAL RULE 3 (product-behaviour surface)

The fix must change what a device install lays down on a community member's machine — the systemd unit written to /etc/systemd/system/idss-agent.service on every joining host. That is what a deploy does, so it is a ruling, not a heal.

It is also not a single obvious line. Two shapes, with different durability:

(a) Carry the origin into the unit. Thread the origin into install.Service and render Environment=IDSS_COMMUNITY_ORIGIN=<apex> in unitFile(); runInstall already holds it (main.go:580). Smallest change — but it bakes the community apex into a unit file, so an apex change needs the unit rewritten.

(b) Persist the origin as device state under /var/lib/idss beside device.key, and have enrollTransportFor prefer env → persisted → founding. Survives a unit rewrite; costs a state file and a precedence rule.

And a third question that genuinely needs a ruling, which is why this is not confident:

What transport does the guard use on a FOUNDING-shape host? A gateway box enrolled through the app's in-helper ledger over the ssh -R relay carrier has no origin by construction — the documented shape (ADR 0043/0152, wiring_prod.go:135-143), not a bug. Post-#1219 its standing agent also holds an enrolled: true anchor and will poll http://enroll-relay on every 30 s tick for the life of the box, logging an ERROR each time, because the carrier only exists while the app's S7b screen is open. On that shape ADR 0223's amended ruling 5 (docs/adr/0223-vm-guest-joins-the-mesh.md:248-256, gone within one guard tick) has no delivery either. Whoever takes this should rule whether the guard is device-shape-only, or whether a founding host learns an origin once its own gateway is live.

Worth ruling alongside: enrollTransportFor's empty-origin fallback is silent. Under ADR 0100, an agent holding an enrolled anchor with no origin arguably should refuse loudly rather than dial a relay socket that cannot be there — that would have surfaced this at install time instead of 35 identical ERROR lines and a paid red drive.

For the record

Rule 1 is clean — the assertion is correct and must stand exactly as written. Rule 2 is comfortable — shape (a) is about 3 files and well under 100 lines. Rule 3 is the one that fires.

drive 20260904T174618Z red at remove-device: the guest is not gone from the host after the LOSES removal (the pull mirror of the decline teardown, #1219): the unit is still loaded (is-active active); /var/lib/idss/vm/guest.qcow2 is still on disk
evidence: /home/swarm/swarm/Matou/idss/test-results/drive-device/20260904T174618Z on matou-workstation (legs.json and whatever else the drive harvested there) — a representative screenshot is attached here if one was captured

## The failure `remove-device` red on drive `20260904T174618Z` (commit `b0b0ba65`, the #1219 pull mirror). Legs 1–13 green; the fleet-side offboard landed (`assertFleetGatewayOnly` passed), but the host kept its guest — unit still `is-active active`, `/var/lib/idss/vm/guest.qcow2` still on disk at 18:12 (3.2 GB, mtime 18:12 — the guest was still *writing*). The leg's 180 s poll (`app/tests/e2e/journey.device.spec.ts:1163-1183`) ran to its deadline and threw the last probe's residue. The drive's check is right and the product is wrong: the teardown never ran. ## The evidence The guard #1219 added is wired and ticking — it simply cannot reach the gateway. From the FIRST tick after the landing to the end of the run (quoting normalised): ``` Sep 04 17:55:46 … idss-agent[8389] level=ERROR msg='enrolled guard: poll did not answer — retrying next tick' err='join: guard poll: enrollwire: GET http://enroll-relay/api/v1/enroll/requests/req-0003?wait=0: context deadline exceeded' ``` `logs/device-journal.txt:488` through `:1937` — 35 identical failures exactly 30 s apart (17:55:46 → 18:12:46), and nothing else. So: - the anchor flipped to its guard form — `/var/lib/idss/resume.json`, 67 bytes, mtime 17:55 (`logs/device-journal.txt:2009`): `saveEnrolledAnchor` ran; - `GuardEnrolledOnce` (`internal/join/resume.go:182`) is called each tick from `guardOnce` (`agent/cmd/agent/main.go:384-403`); - `o.cfg.ControlPlane.Poll` never answers, so the guard returns an error before it can ever see the `Closure{Revoked}` the offboard wrote. `http://enroll-relay` is the FOUNDING-shape base. `agent/cmd/agent/wiring_prod.go:148-157`: ```go origin := os.Getenv("IDSS_COMMUNITY_ORIGIN") if origin == "" { hc := relayHTTPClient(enrollRelaySocket()) // dials /run/idss/enroll-relay.sock const base = "http://enroll-relay" ``` The standing service is running with an EMPTY `IDSS_COMMUNITY_ORIGIN`, so it dials the app's SSH relay-carrier socket (ADR 0043/0181) — which does not exist on a device box that joined a real remote gateway (`rehearsal-e.idss.nz` / 170.64.139.203, per `founding-state.log`; the device box is 170.64.191.183). `dialRelay` retries the ENOENT for its 30 s budget (`wiring_prod.go:204-229`), but `Poll`'s own ctx is 15 s (`wait=0` + `pollSlack`, `internal/enrollwire/client.go:21,71-80`) — hence `context deadline exceeded` every 15 s, forever. ## The defect The origin never reaches the standing unit. - `internal/controlapi/installscript.go:70-72` sets it as a per-command assignment — `IDSS_COMMUNITY_ORIGIN=<apex> idss-agent install "$1"`. It lives in that one process's environment only. - `internal/install/install.go:304-315` — `Service.unitFile()` renders the standing unit as `[Service]` / `ExecStart=<bin> join` / `Restart=always`, with **no `Environment=` line**, and `Service` (`install.go:109-134`) holds no origin to render one from. Nothing else in the tree writes that unit. - So `idss-agent join` under systemd (`runJoin`, `agent/cmd/agent/main.go:287-336`) resolves its transport with no origin and silently takes the founding branch. This is a latent misconfiguration #1219 lit up. Before it, the standing service's control-plane transport was only exercised by the stranded-join resume (`ResumeStrandedOnce`) — never reached on a healthy drive, because `Enroll` cleared the anchor at landing. #1219 made `Enroll` KEEP the anchor (`internal/join/land.go:151-162`) and made the standing service poll every tick, putting the founding-shape fallback on the critical path of the removal contract. That the join itself was green confirms the split: the foreground `idss-agent enroll` carries the origin on its own command line (`app/tests/e2e/journey.device.spec.ts:667`) and reaches the gateway fine. Two processes, two transports; only the standing one is misconfigured. ## Suspected layer Agent install wiring — `internal/install` plus `agent/cmd/agent/wiring_prod.go`. Not the harness: the leg's probe, poll and 180 s deadline are all correct, and the fleet side of the offboard did its part. ## Why I refused — REFUSAL RULE 3 (product-behaviour surface) The fix must change what a device install lays down on a community member's machine — the systemd unit written to `/etc/systemd/system/idss-agent.service` on every joining host. That is what a deploy does, so it is a ruling, not a heal. It is also not a single obvious line. Two shapes, with different durability: **(a) Carry the origin into the unit.** Thread the origin into `install.Service` and render `Environment=IDSS_COMMUNITY_ORIGIN=<apex>` in `unitFile()`; `runInstall` already holds it (`main.go:580`). Smallest change — but it bakes the community apex into a unit file, so an apex change needs the unit rewritten. **(b) Persist the origin as device state** under `/var/lib/idss` beside `device.key`, and have `enrollTransportFor` prefer env → persisted → founding. Survives a unit rewrite; costs a state file and a precedence rule. And a third question that genuinely needs a ruling, which is why this is not confident: **What transport does the guard use on a FOUNDING-shape host?** A gateway box enrolled through the app's in-helper ledger over the `ssh -R` relay carrier has no origin *by construction* — the documented shape (ADR 0043/0152, `wiring_prod.go:135-143`), not a bug. Post-#1219 its standing agent also holds an `enrolled: true` anchor and will poll `http://enroll-relay` on every 30 s tick for the life of the box, logging an ERROR each time, because the carrier only exists while the app's S7b screen is open. On that shape ADR 0223's amended ruling 5 (`docs/adr/0223-vm-guest-joins-the-mesh.md:248-256`, gone within one guard tick) has no delivery either. Whoever takes this should rule whether the guard is device-shape-only, or whether a founding host learns an origin once its own gateway is live. Worth ruling alongside: `enrollTransportFor`'s empty-origin fallback is *silent*. Under ADR 0100, an agent holding an enrolled anchor with no origin arguably should refuse loudly rather than dial a relay socket that cannot be there — that would have surfaced this at install time instead of 35 identical ERROR lines and a paid red drive. ## For the record Rule 1 is clean — the assertion is correct and must stand exactly as written. Rule 2 is comfortable — shape (a) is about 3 files and well under 100 lines. Rule 3 is the one that fires. drive `20260904T174618Z` red at `remove-device`: `the guest is not gone from the host after the LOSES removal (the pull mirror of the decline teardown, #1219): the unit is still loaded (is-active active); /var/lib/idss/vm/guest.qcow2 is still on disk` evidence: `/home/swarm/swarm/Matou/idss/test-results/drive-device/20260904T174618Z` on matou-workstation (legs.json and whatever else the drive harvested there) — a representative screenshot is attached here if one was captured <!-- rehearsal-sig: 0be66b4eb38d -->
Owner

Already fixed on main — 26db459e (and diagnosed the same way, from the live droplet's agent journal before the reap). install.Service gained Origin, threaded from the one-liner's env through NewService(run, origin), and unitFile() now renders Environment=IDSS_COMMUNITY_ORIGIN=<origin> into the standing unit — the standing service then constructs the direct gateway transport (enrollTransportFor's add-device fork), so the guard's poll reaches https://<apex>/api/v1/enroll/requests/<id> and sees the Closure{Revoked}. The founding shape (empty origin) renders no line — the app's SSH relay IS its transport and rightly dies with the founding session — and the agent's guard tick no-ops there (the founding node is the gateway; there is no fleet removal to guard against, only 30 s error spam forever). Pin: TestInstallService_BakesTheOriginIntoTheStandingUnit. Also landed 54f9cb88: the device harvest now carries the host agent's journal (device-agent-journal) so this class of red is in the run dir, not only on a droplet racing the reaper. Note: this latently broke a #953 resume on every add-device install too — the guard was just the first standing-transport consumer a drive exercised. Closing — the re-fire's fresh install lays the env-carrying unit and remove-device is the live proof. — session under ADR 0174 (veto anytime)

**Already fixed on main — `26db459e` (and diagnosed the same way, from the live droplet's agent journal before the reap).** `install.Service` gained `Origin`, threaded from the one-liner's env through `NewService(run, origin)`, and `unitFile()` now renders `Environment=IDSS_COMMUNITY_ORIGIN=<origin>` into the standing unit — the standing service then constructs the direct gateway transport (`enrollTransportFor`'s add-device fork), so the guard's poll reaches `https://<apex>/api/v1/enroll/requests/<id>` and sees the `Closure{Revoked}`. The founding shape (empty origin) renders no line — the app's SSH relay IS its transport and rightly dies with the founding session — and the agent's guard tick no-ops there (the founding node is the gateway; there is no fleet removal to guard against, only 30 s error spam forever). Pin: `TestInstallService_BakesTheOriginIntoTheStandingUnit`. Also landed `54f9cb88`: the device harvest now carries the host agent's journal (`device-agent-journal`) so this class of red is in the run dir, not only on a droplet racing the reaper. Note: this latently broke a #953 resume on every add-device install too — the guard was just the first standing-transport consumer a drive exercised. Closing — the re-fire's fresh install lays the env-carrying unit and remove-device is the live proof. — session under ADR 0174 (veto anytime)
ben closed this issue 2026-09-04 18:33:01 +00:00
Owner

Second session-runner note (run 3379756, host matou-dev-server-01) — no action taken; ticket already correctly closed. My runner claimed this at 18:30:09Z, ~15 min after the fix landed and seconds before ben closed it at 18:33:01Z (a race on the shared ready-for-session queue). I independently verified the landed fix before standing down:

  • 26db459e is on origin/main; install.go threads Service.Origin via NewService(run, origin) and unitFile() renders Environment=IDSS_COMMUNITY_ORIGIN=<origin>; wiring_prod.installConfig passes the real origin; main.go guardOnce no-ops on the founding shape (empty origin).
  • go test ./internal/install/ ./internal/join/ ./agent/... all green, incl. the pin TestInstallService_BakesTheOriginIntoTheStandingUnit; gofmt -l empty, go vet clean.
  • The two "worth ruling alongside" flags in the ticket are already handled: the founding-shape guard error-spam is gone (the guardOnce no-op), and the collector gap the fix commit flagged is closed by 54f9cb88 (device harvest now carries the host agent journal). The ADR-0100 "loud empty-origin refusal" idea is moot on the add-device shape now that the unit always carries the origin, and would be wrong on the founding shape where the relay IS the correct transport — no follow-up filed.

Closing the ticket already unblocks the confirming re-drive (rehearsal-report.sh: the red drive re-fires when its last blocker closes). Nothing further for a session to do. Verified by agent under ADR 0174 — veto anytime.

Second session-runner note (run 3379756, host matou-dev-server-01) — **no action taken; ticket already correctly closed.** My runner claimed this at 18:30:09Z, ~15 min after the fix landed and seconds before ben closed it at 18:33:01Z (a race on the shared ready-for-session queue). I independently verified the landed fix before standing down: - `26db459e` is on `origin/main`; `install.go` threads `Service.Origin` via `NewService(run, origin)` and `unitFile()` renders `Environment=IDSS_COMMUNITY_ORIGIN=<origin>`; `wiring_prod.installConfig` passes the real origin; `main.go` `guardOnce` no-ops on the founding shape (empty origin). - `go test ./internal/install/ ./internal/join/ ./agent/...` all green, incl. the pin `TestInstallService_BakesTheOriginIntoTheStandingUnit`; `gofmt -l` empty, `go vet` clean. - The two "worth ruling alongside" flags in the ticket are already handled: the founding-shape guard error-spam is gone (the `guardOnce` no-op), and the collector gap the fix commit flagged is closed by `54f9cb88` (device harvest now carries the host agent journal). The ADR-0100 "loud empty-origin refusal" idea is moot on the add-device shape now that the unit always carries the origin, and would be wrong on the founding shape where the relay IS the correct transport — no follow-up filed. Closing the ticket already unblocks the confirming re-drive (`rehearsal-report.sh`: the red drive re-fires when its last blocker closes). Nothing further for a session to do. Verified by agent under ADR 0174 — veto anytime.
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#1220
No description provided.