rehearsal-5 task 2/13: Agent await/land loop + real device-side adapters #843

Closed
opened 2026-08-25 20:14:28 +00:00 by ben · 3 comments
Owner

Part of the #183 phase-5 rehearsal arc (device-add + Nextcloud-on-device on a standing rented community).

  • Spec: docs/superpowers/specs/2026-08-25-183-phase-5-device-nextcloud-rehearsal-design.md
  • Plan: docs/superpowers/plans/2026-08-25-183-phase-5-device-nextcloud-rehearsal.md — this ticket is Task 2, carried verbatim below. The plan's Global Constraints apply to every step.

Task 2: Agent await/land loop + real device-side adapters

Files:

  • Modify: agent/cmd/agent/main.go (runEnroll continues: await → land / declined-teardown; honest terminal copy)
  • Modify: agent/cmd/agent/wiring_prod.go (replace unbuiltMesh/unbuiltClan/unbuiltTakeover with real adapters; keep fail-loud when the tool is absent)
  • Create: agent/internal/meshup/meshup.go + meshup_test.go (netbird adapter)
  • Create: agent/internal/trust/trust.go + trust_test.go (CA install adapter)
  • Create: agent/internal/stage/stage.go + stage_test.go (takeover stage adapter)
  • Modify: internal/join/cli.go (post-pending copy), cli_test.go
  • Modify: STATUS.md

Interfaces:

  • Consumes: the existing port contracts — join.Orchestrator.AwaitDecision (internal/join/join.go:264), join.Orchestrator.Enroll (internal/join/land.go:73-101), join.Orchestrator.Resume (resume.go:35), enroll.MeshAdmission{SetupKey, Management, TLSPin} (internal/enroll/enroll.go:248-252), the enrollwire device transport (already proven to serve await/enroll — internal/enrollwire/device_transport_integration_test.go:172,179), jointesting fakes as the behavior contract, install.NewSelfRemover (already real).

  • Produces: after "✓ connection request sent", the terminal prints waiting for the operator's decision…; on approve it walks the landing (✓ joined the community network / ✓ community trust installed / ✓ takeover staged — the wipe runs at first deploy / ✓ this machine is enrolled), exit 0; on decline it prints ✕ declined by the operator — this machine was not joined and the agent has removed itself then tears down (self-remove), exit 1. Enroll's ConfirmEnrolled call carries MeshAddress string (Task 3's wire field). Adapters: meshup.New(runner) (netbird up --setup-key <k> --management-url <m> then reads the wt0 address from netbird status --json; absent binary → the ADR 0100 named error), trust.New(runner) (writes the grant's CA to /usr/local/share/ca-certificates/idss-community.crt + update-ca-certificates), stage.New(runner) (writes the staged takeover marker + node identity under /var/lib/idss/takeover/, per the full-install-takeover-ready slice contract — stage only, never executes).

  • Step 1: Write the failing CLI test — extend internal/join/cli_test.go with TestRunTerminal_ThenAwaitApprovedWalksTheLanding and TestAwait_DeclinedPrintsAndExitsNonzero against the existing scripted fakes: assert the exact copy strings above appear in the transcript, in order.

  • Step 2: Run go test ./internal/join -run 'Await|RunTerminal' -v → FAIL.

  • Step 3: Implement the await continuation in runEnroll (poll AwaitDecision; ctx-bounded; SIGINT leaves the request pending — the standing agent join service can resume it) and the terminal copy in cli.go.

  • Step 4: Run → PASS.

  • Step 5: Write failing adapter tests — each with a scripted Runner fake (internal/install/runner.go's interface): TestMeshUp_JoinsWithSetupKeyAndReadsWt0Address, TestMeshUp_AbsentNetbirdFailsLoudNamed, TestTrust_InstallsCAAndRefreshes, TestStage_WritesStagedMarkerNeverExecutes.

  • Step 6: Run → FAIL; implement the three adapters; run → PASS.

  • Step 7: Wire wiring_prod.go: real adapters replace the three stubs (keep Brand: unbuiltBrander{} — out of scope); update wiring_test.go expectations.

  • Step 8: Run go build ./... && go vet ./... && go test ./agent/... ./internal/join/... → PASS; gofmt -l . empty.

  • Step 9: Commit — git commit -m "rehearsal-5: agent lands the enrollment — await/land loop + real mesh/trust/stage adapters (ADR 0208) (task 2 of #<ticket>)".


Global Constraints (from the plan)

  • Nothing fabricated (ADR 0100): every landed fact is read from the box; a
    failure is a named error, never a masked success. No sandbox-green claim (#377).
  • The wipe consent is given at the machine (ADR 0024) and shown-not-re-asked
    at P4-S3x; the takeover runs at provisioning's first deploy, never at join.
  • One placement deploy = device closure + gateway route in one config-repo
    commit, then two single-node clan.Deploy calls, device first (ruling: a
    route to a dead service is the honest failure, a service with no route is
    invisible).
  • Standing community: home test-results/standing-rented/; staleness gate =
    oc_bootstrap_staleness pattern over agent/ go.mod go.sum internal/; the
    reaper stays honest — renewal, not exemption (idss-rental-hold is for
    humans, the executor never sets it).
  • Do not destabilize live drives: #720 (rented confirm loop, elitebook) and
    #721/#722 (workstation) keep running; the prefix extraction (Task 10) is
    behavior-preserving and #720 must stay green across it. Never touch the
    executors' env files from a ticket.
  • Tracker gotcha: labels via POST/DELETE /issues/<n>/labels, never in an
    issue PATCH. "closes #NNN" in commit messages auto-closes — say "task N of
    #NNN" instead.
  • ADR numbers: 0207/0208/0209 assumed — re-check git ls-tree origin/main docs/adr/
    at mint (IDIP + observability swarm lanes are minting concurrently).
  • STATUS.md updated in the same commit as any project-state change;
    git pull --rebase immediately before a STATUS commit (shared checkout).
  • Go: gofmt, go vet ./..., go test ./... green; TS: pnpm -r typecheck +
    unit suites green, pre-land.
Part of the **#183 phase-5 rehearsal arc** (device-add + Nextcloud-on-device on a standing rented community). - Spec: `docs/superpowers/specs/2026-08-25-183-phase-5-device-nextcloud-rehearsal-design.md` - Plan: `docs/superpowers/plans/2026-08-25-183-phase-5-device-nextcloud-rehearsal.md` — this ticket is **Task 2**, carried verbatim below. The plan's Global Constraints apply to every step. --- ### Task 2: Agent await/land loop + real device-side adapters **Files:** - Modify: `agent/cmd/agent/main.go` (`runEnroll` continues: await → land / declined-teardown; honest terminal copy) - Modify: `agent/cmd/agent/wiring_prod.go` (replace `unbuiltMesh`/`unbuiltClan`/`unbuiltTakeover` with real adapters; keep fail-loud when the tool is absent) - Create: `agent/internal/meshup/meshup.go` + `meshup_test.go` (netbird adapter) - Create: `agent/internal/trust/trust.go` + `trust_test.go` (CA install adapter) - Create: `agent/internal/stage/stage.go` + `stage_test.go` (takeover stage adapter) - Modify: `internal/join/cli.go` (post-pending copy), `cli_test.go` - Modify: `STATUS.md` **Interfaces:** - Consumes: the existing port contracts — `join.Orchestrator.AwaitDecision` (`internal/join/join.go:264`), `join.Orchestrator.Enroll` (`internal/join/land.go:73-101`), `join.Orchestrator.Resume` (`resume.go:35`), `enroll.MeshAdmission{SetupKey, Management, TLSPin}` (`internal/enroll/enroll.go:248-252`), the enrollwire device transport (already proven to serve await/enroll — `internal/enrollwire/device_transport_integration_test.go:172,179`), `jointesting` fakes as the behavior contract, `install.NewSelfRemover` (already real). - Produces: after "✓ connection request sent", the terminal prints `waiting for the operator's decision…`; on approve it walks the landing (`✓ joined the community network` / `✓ community trust installed` / `✓ takeover staged — the wipe runs at first deploy` / `✓ this machine is enrolled`), exit 0; on decline it prints `✕ declined by the operator — this machine was not joined and the agent has removed itself` then tears down (self-remove), exit 1. `Enroll`'s `ConfirmEnrolled` call carries `MeshAddress string` (Task 3's wire field). Adapters: `meshup.New(runner)` (`netbird up --setup-key <k> --management-url <m>` then reads the wt0 address from `netbird status --json`; absent binary → the ADR 0100 named error), `trust.New(runner)` (writes the grant's CA to `/usr/local/share/ca-certificates/idss-community.crt` + `update-ca-certificates`), `stage.New(runner)` (writes the staged takeover marker + node identity under `/var/lib/idss/takeover/`, per the `full-install-takeover-ready` slice contract — stage only, never executes). - [ ] **Step 1: Write the failing CLI test** — extend `internal/join/cli_test.go` with `TestRunTerminal_ThenAwaitApprovedWalksTheLanding` and `TestAwait_DeclinedPrintsAndExitsNonzero` against the existing scripted fakes: assert the exact copy strings above appear in the transcript, in order. - [ ] **Step 2: Run** `go test ./internal/join -run 'Await|RunTerminal' -v` → FAIL. - [ ] **Step 3: Implement** the await continuation in `runEnroll` (poll `AwaitDecision`; ctx-bounded; SIGINT leaves the request pending — the standing `agent join` service can resume it) and the terminal copy in `cli.go`. - [ ] **Step 4: Run** → PASS. - [ ] **Step 5: Write failing adapter tests** — each with a scripted `Runner` fake (`internal/install/runner.go`'s interface): `TestMeshUp_JoinsWithSetupKeyAndReadsWt0Address`, `TestMeshUp_AbsentNetbirdFailsLoudNamed`, `TestTrust_InstallsCAAndRefreshes`, `TestStage_WritesStagedMarkerNeverExecutes`. - [ ] **Step 6: Run** → FAIL; **implement** the three adapters; run → PASS. - [ ] **Step 7: Wire** `wiring_prod.go`: real adapters replace the three stubs (keep `Brand: unbuiltBrander{}` — out of scope); update `wiring_test.go` expectations. - [ ] **Step 8: Run** `go build ./... && go vet ./... && go test ./agent/... ./internal/join/...` → PASS; `gofmt -l .` empty. - [ ] **Step 9: Commit** — `git commit -m "rehearsal-5: agent lands the enrollment — await/land loop + real mesh/trust/stage adapters (ADR 0208) (task 2 of #<ticket>)"`. --- ## Global Constraints (from the plan) - **Nothing fabricated (ADR 0100):** every landed fact is read from the box; a failure is a named error, never a masked success. No sandbox-green claim (#377). - **The wipe consent is given at the machine (ADR 0024)** and shown-not-re-asked at P4-S3x; the takeover runs at provisioning's first deploy, never at join. - **One placement deploy = device closure + gateway route** in one config-repo commit, then two single-node `clan.Deploy` calls, device first (ruling: a route to a dead service is the honest failure, a service with no route is invisible). - **Standing community:** home `test-results/standing-rented/`; staleness gate = `oc_bootstrap_staleness` pattern over `agent/ go.mod go.sum internal/`; the reaper stays honest — renewal, not exemption (`idss-rental-hold` is for humans, the executor never sets it). - **Do not destabilize live drives:** #720 (rented confirm loop, elitebook) and #721/#722 (workstation) keep running; the prefix extraction (Task 10) is behavior-preserving and #720 must stay green across it. Never touch the executors' env files from a ticket. - **Tracker gotcha:** labels via `POST/DELETE /issues/<n>/labels`, never in an issue PATCH. "closes #NNN" in commit messages auto-closes — say "task N of #NNN" instead. - **ADR numbers:** 0207/0208/0209 assumed — re-check `git ls-tree origin/main docs/adr/` at mint (IDIP + observability swarm lanes are minting concurrently). - **STATUS.md** updated in the same commit as any project-state change; `git pull --rebase` immediately before a STATUS commit (shared checkout). - Go: `gofmt`, `go vet ./...`, `go test ./...` green; TS: `pnpm -r typecheck` + unit suites green, pre-land.

ADR numbers ruled at mint — read 0207 → 0208, 0208 → 0209, 0209 → 0210

Task 1 (#842) has landed the phase-5 design tier. This ticket's body carries the
plan's assumed ADR numbers; they shifted by one at mint, exactly as the
Global Constraints line in your body told you to re-check.

assumed ruled ADR
0207 0208 the standing rehearsal community — staleness-gated re-found
0208 0209 device-add's landing goes live — mesh fact, fleet admission, /get
0209 0210 files on a member device — composition, OIDC split, mesh route

Why: docs/adr/0207-design-keri-stack-version-pins.md (#771, the concurrent
IDIP lane) had taken 0207 on origin/main before this arc minted.

Use the ruled numbers in your commit messages and code comments. The plan
(docs/superpowers/plans/2026-08-25-183-phase-5-device-nextcloud-rehearsal.md)
is updated and records the mapping; commit 70a3bce6.

Ruled by agent under ADR 0174 — veto anytime.

## ADR numbers ruled at mint — read 0207 → 0208, 0208 → 0209, 0209 → 0210 Task 1 (#842) has landed the phase-5 design tier. This ticket's body carries the plan's **assumed** ADR numbers; they shifted by one at mint, exactly as the Global Constraints line in your body told you to re-check. | assumed | **ruled** | ADR | |---|---|---| | 0207 | **0208** | the standing rehearsal community — staleness-gated re-found | | 0208 | **0209** | device-add's landing goes live — mesh fact, fleet admission, `/get` | | 0209 | **0210** | files on a member device — composition, OIDC split, mesh route | Why: `docs/adr/0207-design-keri-stack-version-pins.md` (#771, the concurrent IDIP lane) had taken 0207 on `origin/main` before this arc minted. Use the **ruled** numbers in your commit messages and code comments. The plan (`docs/superpowers/plans/2026-08-25-183-phase-5-device-nextcloud-rehearsal.md`) is updated and records the mapping; commit `70a3bce6`. Ruled by agent under ADR 0174 — veto anytime.

swarm-claim host=elitebook-distributed-server-03 run=10099
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=elitebook-distributed-server-03 run=10099 (automated multi-host claim — lowest live claim id works this ticket)

close-report for #843 — status success

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

envelope
{
  "issue": 843,
  "status": "success",
  "commits": [
    "789f250f46dfecfa5724ab7aa8432d0de8783de7"
  ],
  "changed_files": [
    "STATUS.md",
    "agent/cmd/agent/main.go",
    "agent/cmd/agent/wiring_prod.go",
    "agent/cmd/agent/wiring_test.go",
    "agent/internal/meshup/meshup.go",
    "agent/internal/meshup/meshup_test.go",
    "agent/internal/stage/stage.go",
    "agent/internal/stage/stage_test.go",
    "agent/internal/trust/trust.go",
    "agent/internal/trust/trust_test.go",
    "internal/join/cli.go",
    "internal/join/cli_test.go"
  ],
  "tests": [
    {
      "command": "go test ./internal/join -run 'Await|RunTerminal' -v",
      "exit_code": 0
    },
    {
      "command": "go test ./agent/internal/meshup/ ./agent/internal/trust/ ./agent/internal/stage/",
      "exit_code": 0
    },
    {
      "command": "go build ./... && go vet ./...",
      "exit_code": 0
    },
    {
      "command": "go test ./agent/... ./internal/join/...",
      "exit_code": 0
    },
    {
      "command": "gofmt -l . (empty)",
      "exit_code": 0
    },
    {
      "command": "pre-push gate: nix develop .#go-ci go test ./... (all green, pushed 39ac606..789f250)",
      "exit_code": 0
    }
  ],
  "criteria": {
    "runEnroll continues past Pending: await -> land / declined-teardown with honest terminal copy": "agent/cmd/agent/main.go runEnroll now calls Orchestrator.AwaitAndLand after RunTerminal; internal/join/cli.go AwaitAndLand prints the walk/decline copy",
    "after 'connection request sent' the terminal prints 'waiting for the operator's decision...'": "internal/join/cli.go AwaitAndLand; asserted by cli_test.go TestRunTerminal_ThenAwaitApprovedWalksTheLanding",
    "on approve it walks the landing (joined network / trust installed / takeover staged full-install / enrolled), exit 0": "cli.go AwaitAndLand prints the four lines after Enroll succeeds; takeover line gated on ModeFull; TestRunTerminal_ThenAwaitApprovedWalksTheLanding asserts order + Enrolled",
    "on decline prints the honest decline line then tears down (self-remove), exit 1": "cli.go declineLine + ErrDeclined; TestAwait_DeclinedPrintsAndExitsNonzero asserts the line, non-nil error, and f.self.Removed>0",
    "SIGINT leaves the request pending (standing agent join resumes)": "main.go runEnroll wires signal.NotifyContext; AwaitDecision returns ctx err without teardown on cancel (never runs decline branch)",
    "meshup.New(runner): netbird up --setup-key --management-url then reads wt0 from netbird status --json; absent binary -> ADR 0100 named error": "agent/internal/meshup/meshup.go; TestMeshUp_JoinsWithSetupKeyAndReadsWt0Address + TestMeshUp_AbsentNetbirdFailsLoudNamed",
    "trust.New(runner): writes grant CA to /usr/local/share/ca-certificates/idss-community.crt + update-ca-certificates": "agent/internal/trust/trust.go InstallCerts; TestTrust_InstallsCAAndRefreshes",
    "stage.New(runner): writes staged takeover marker + node identity under /var/lib/idss/takeover/, stage only never executes": "agent/internal/stage/stage.go; TestStage_WritesStagedMarkerNeverExecutes asserts marker+node written and zero commands run",
    "wiring_prod.go: real adapters replace unbuiltMesh/unbuiltClan/unbuiltTakeover, keep fail-loud when tool absent, Brand stays unbuilt": "agent/cmd/agent/wiring_prod.go joinAdapters; wiring_test.go TestProduction_LandingPortsAreRealAdapters + TestProduction_UnbuiltBranderFailsLoud",
    "ConfirmEnrolled call carries MeshAddress (Task 3's wire field)": "MeshUp.Address() reads and exposes the wt0 address off the box for Task 3/#844 to thread into ConfirmEnrolled; the enroll.go/land.go signature change is Task 3's scope per the plan"
  },
  "summary": "agent enroll now lands the enrollment end to end — AwaitAndLand walks the landing/decline out loud and the mesh/trust/stage device-side ports are real fail-loud adapters (ADR 0209).",
  "reason": "",
  "blockers": [],
  "no_code_change": ""
}
**close-report** for #843 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 843, "status": "success", "commits": [ "789f250f46dfecfa5724ab7aa8432d0de8783de7" ], "changed_files": [ "STATUS.md", "agent/cmd/agent/main.go", "agent/cmd/agent/wiring_prod.go", "agent/cmd/agent/wiring_test.go", "agent/internal/meshup/meshup.go", "agent/internal/meshup/meshup_test.go", "agent/internal/stage/stage.go", "agent/internal/stage/stage_test.go", "agent/internal/trust/trust.go", "agent/internal/trust/trust_test.go", "internal/join/cli.go", "internal/join/cli_test.go" ], "tests": [ { "command": "go test ./internal/join -run 'Await|RunTerminal' -v", "exit_code": 0 }, { "command": "go test ./agent/internal/meshup/ ./agent/internal/trust/ ./agent/internal/stage/", "exit_code": 0 }, { "command": "go build ./... && go vet ./...", "exit_code": 0 }, { "command": "go test ./agent/... ./internal/join/...", "exit_code": 0 }, { "command": "gofmt -l . (empty)", "exit_code": 0 }, { "command": "pre-push gate: nix develop .#go-ci go test ./... (all green, pushed 39ac606..789f250)", "exit_code": 0 } ], "criteria": { "runEnroll continues past Pending: await -> land / declined-teardown with honest terminal copy": "agent/cmd/agent/main.go runEnroll now calls Orchestrator.AwaitAndLand after RunTerminal; internal/join/cli.go AwaitAndLand prints the walk/decline copy", "after 'connection request sent' the terminal prints 'waiting for the operator's decision...'": "internal/join/cli.go AwaitAndLand; asserted by cli_test.go TestRunTerminal_ThenAwaitApprovedWalksTheLanding", "on approve it walks the landing (joined network / trust installed / takeover staged full-install / enrolled), exit 0": "cli.go AwaitAndLand prints the four lines after Enroll succeeds; takeover line gated on ModeFull; TestRunTerminal_ThenAwaitApprovedWalksTheLanding asserts order + Enrolled", "on decline prints the honest decline line then tears down (self-remove), exit 1": "cli.go declineLine + ErrDeclined; TestAwait_DeclinedPrintsAndExitsNonzero asserts the line, non-nil error, and f.self.Removed>0", "SIGINT leaves the request pending (standing agent join resumes)": "main.go runEnroll wires signal.NotifyContext; AwaitDecision returns ctx err without teardown on cancel (never runs decline branch)", "meshup.New(runner): netbird up --setup-key --management-url then reads wt0 from netbird status --json; absent binary -> ADR 0100 named error": "agent/internal/meshup/meshup.go; TestMeshUp_JoinsWithSetupKeyAndReadsWt0Address + TestMeshUp_AbsentNetbirdFailsLoudNamed", "trust.New(runner): writes grant CA to /usr/local/share/ca-certificates/idss-community.crt + update-ca-certificates": "agent/internal/trust/trust.go InstallCerts; TestTrust_InstallsCAAndRefreshes", "stage.New(runner): writes staged takeover marker + node identity under /var/lib/idss/takeover/, stage only never executes": "agent/internal/stage/stage.go; TestStage_WritesStagedMarkerNeverExecutes asserts marker+node written and zero commands run", "wiring_prod.go: real adapters replace unbuiltMesh/unbuiltClan/unbuiltTakeover, keep fail-loud when tool absent, Brand stays unbuilt": "agent/cmd/agent/wiring_prod.go joinAdapters; wiring_test.go TestProduction_LandingPortsAreRealAdapters + TestProduction_UnbuiltBranderFailsLoud", "ConfirmEnrolled call carries MeshAddress (Task 3's wire field)": "MeshUp.Address() reads and exposes the wt0 address off the box for Task 3/#844 to thread into ConfirmEnrolled; the enroll.go/land.go signature change is Task 3's scope per the plan" }, "summary": "agent enroll now lands the enrollment end to end — AwaitAndLand walks the landing/decline out loud and the mesh/trust/stage device-side ports are real fail-loud adapters (ADR 0209).", "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#843
No description provided.