toolpin: pin the clan-cli as a tarball (or warm-store the closure), not git+https — stop cloning a 20 MiB forge repo on every gateway deploy's critical path #1273

Closed
opened 2026-09-06 10:25:09 +00:00 by matou-build-agent · 2 comments

Root cause behind #1272

#1272 landed the honest-fault classifier fix (a): a mid-clone git/HTTP transfer
reset fetching the pinned clan-cli now classifies connectivity (not config_eval),
re-arming updateNode's one-shot retry so the transient is survivable. That fix
makes the fault recoverable; it does not remove it. This issue is the root fix (b).

The fault

internal/clan/toolpin.go:29 pins the clan CLI as a git+https ref:

PinnedClanRef = "git+https://git.clan.lol/clan/clan-core?rev=<rev>#clan-cli"

On the control-plane deploy path no dev-shell clan is on PATH (internal/clan/vmguest.go
omits it deliberately), so resolveTool runs nix run <PinnedClanRef> --. A git+https
ref makes nix clone the whole ~20 MiB, 98,281-object clan-core repo over the
gateway's link before the CLI can run — on the first deploy nothing is warm in its
store or git cache. That clone is on the critical path of every gateway deploy, and
a bad forge link at that moment reds the deploy. This is the fault a real community
hits, not just a rehearsal drive.

Meanwhile the community flake pins clan-core as a tarball in
state/clan-config/flake.lock — the cheap, resumable form. The CLI pin is the
expensive, fragile outlier.

Candidate fixes (needs a ruling on which — a supply-chain decision)

  1. Pin the CLI through the same archive URL the lock already uses — a tarball
    flakeref (https://git.clan.lol/api/v1/repos/clan/clan-core/archive/<rev>.tar.gz#clan-cli)
    instead of git+https. Keeps TestPinnedClanRefMatchesFlakeLock honest (still one
    pin source, ADR 0040) and removes the 20 MiB clone. Must prove nix run <tarball-ref>#clan-cli
    resolves the identical CLI and runs.
  2. Carry the clan-cli closure in the ADR 0133 warm store the control plane already
    holds (adapter.go notes the plane holds that store), so the first co-host deploy does
    not depend on a healthy forge transfer at that moment.

Not mutually exclusive with each other.

Why this needs a session, not the swarm

The only real proof is a live gateway deploy drive (does the re-pinned/warmed CLI
run identically end-to-end). Mis-pinning PinnedClanRef would break every deploy —
far larger blast radius than the transient #1272 addressed — so this must not land
unproven. Route to a session with lab-drive access.

Provenance

Filed by the #1272 session under ADR 0174 as the deferred root fix. See GOTCHAS #178.

## Root cause behind #1272 #1272 landed the **honest-fault classifier fix** (a): a mid-clone git/HTTP transfer reset fetching the pinned clan-cli now classifies `connectivity` (not `config_eval`), re-arming `updateNode`'s one-shot retry so the transient is survivable. That fix makes the fault *recoverable*; it does not *remove* it. This issue is the root fix (b). ## The fault `internal/clan/toolpin.go:29` pins the clan CLI as a **`git+https` ref**: ``` PinnedClanRef = "git+https://git.clan.lol/clan/clan-core?rev=<rev>#clan-cli" ``` On the control-plane deploy path no dev-shell `clan` is on PATH (`internal/clan/vmguest.go` omits it deliberately), so `resolveTool` runs `nix run <PinnedClanRef> --`. A `git+https` ref makes nix **clone the whole ~20 MiB, 98,281-object clan-core repo** over the gateway's link before the CLI can run — on the first deploy nothing is warm in its store or git cache. That clone is on the **critical path of every gateway deploy**, and a bad forge link at that moment reds the deploy. This is the fault a real community hits, not just a rehearsal drive. Meanwhile the community flake pins clan-core as a **tarball** in `state/clan-config/flake.lock` — the cheap, resumable form. The CLI pin is the expensive, fragile outlier. ## Candidate fixes (needs a ruling on which — a supply-chain decision) 1. **Pin the CLI through the same archive URL the lock already uses** — a tarball flakeref (`https://git.clan.lol/api/v1/repos/clan/clan-core/archive/<rev>.tar.gz#clan-cli`) instead of `git+https`. Keeps `TestPinnedClanRefMatchesFlakeLock` honest (still one pin source, ADR 0040) and removes the 20 MiB clone. Must prove `nix run <tarball-ref>#clan-cli` resolves the identical CLI and runs. 2. **Carry the `clan-cli` closure in the ADR 0133 warm store** the control plane already holds (`adapter.go` notes the plane holds that store), so the first co-host deploy does not depend on a healthy forge transfer at that moment. Not mutually exclusive with each other. ## Why this needs a session, not the swarm The only real proof is a **live gateway deploy drive** (does the re-pinned/warmed CLI run identically end-to-end). Mis-pinning `PinnedClanRef` would break **every** deploy — far larger blast radius than the transient #1272 addressed — so this must not land unproven. Route to a session with lab-drive access. ## Provenance Filed by the #1272 session under ADR 0174 as the deferred root fix. See GOTCHAS #178.
Author
Member

This was generated by AI during triage.

Ruled by agent under ADR 0174 — veto anytime.

Ruling: bug + ready-for-session (not ready-for-human, not ready-for-agent)

Verified the fault against the tree at HEAD:

  • internal/clan/toolpin.go pins PinnedClanRef = "git+" + clanCoreURL + "?rev=" + clanCoreRev + "#clan-cli" — the git+https form the report names. resolveTool drives nix run <PinnedClanRef> -- when no dev-shell clan is on PATH (vmguest.go omits it on the control-plane deploy path), so the ~20 MiB clan-core clone is on the deploy critical path exactly as described.
  • The shipped community clan-config already pins clan-core as a tarball for the identical rev d098fa2edd659544fc492d7be188d529bbc65af5 (state/clan-config/flake.lock — confirmed across every drive under test-results/). The CLI pin is the expensive outlier; the report's framing holds.
  • TestPinnedClanRef_MatchesFlakeLock (internal/clan/toolpin_test.go) guards the pin against drift — the existing proof surface for candidate (1). Note it asserts strings.Contains(PinnedClanRef, locked.Locked.URL) against the root ./flake.lock, which is still type: git with the plain repo URL; a tarball flakeref won't contain that string verbatim, so candidate (1) must also update this test (or re-source it from the tarball node). Flagged for the executor, not a triage blocker.

Why this is a two-way door, not a one-way door

The "which candidate fix" call is framed as a supply-chain decision, but neither candidate widens anything: both keep the identical pinned rev, content-addressed. (1) swaps the transport (git+https → the archive-tarball flakeref the lock already uses); (2) warm-stores that same closure. This is supply-chain hardening, not a new trust surface, a loosened auth, or non-routine spend — so it is off the one-way-door list. It is revertible (a one-line pin change / a warm-store entry) and provable (TestPinnedClanRef_MatchesFlakeLock + a live gateway deploy drive). That makes it an agent ruling, not Ben's.

Why ready-for-session, not ready-for-agent

The report is right that the swarm must not land this: the only honest proof is a live gateway deploy drive (does the re-pinned/warmed CLI resolve to the identical clan-cli and run end-to-end), and a mis-pinned PinnedClanRef reds every deploy — a far larger blast radius than the transient #1272 already made survivable. That proof needs an interactive session's lab-drive standing, not swarm-visible ready-for-agent work (the swarm queue reads only ready-for-agent by construction). This is the ADR 0174 rule-5 case exactly.

Proposed default ruling (adopt or veto)

Since the ticket asks for a ruling on which fix, per ADR 0174 rule 4 it gets a default the executing session may adopt:

  • Default: candidate (1) — re-pin through the archive-tarball flakeref https://git.clan.lol/api/v1/repos/clan/clan-core/archive/<rev>.tar.gz#clan-cli, the same form state/clan-config/flake.lock already uses. It's the minimal, single-pin-source change (ADR 0040), removes the 20 MiB clone outright, and keeps one pin source. Must prove nix run <tarball-ref>#clan-cli resolves the identical CLI and the live drive is green (and update TestPinnedClanRef_MatchesFlakeLock per the note above).
  • Candidate (2) (warm-store the closure) stays open as an additive belt-and-braces optimization — not mutually exclusive — if the session finds the tarball transport still on the critical path for a cold first deploy.

The executing session is free to pick either or both; both are provable by the same drive.

Label: removing needs-triage, keeping bug, adding ready-for-session.

> *This was generated by AI during triage.* **Ruled by agent under ADR 0174 — veto anytime.** ## Ruling: `bug` + `ready-for-session` (not `ready-for-human`, not `ready-for-agent`) **Verified the fault** against the tree at HEAD: - `internal/clan/toolpin.go` pins `PinnedClanRef = "git+" + clanCoreURL + "?rev=" + clanCoreRev + "#clan-cli"` — the `git+https` form the report names. `resolveTool` drives `nix run <PinnedClanRef> --` when no dev-shell `clan` is on PATH (`vmguest.go` omits it on the control-plane deploy path), so the ~20 MiB clan-core clone is on the deploy critical path exactly as described. - The shipped community clan-config **already** pins clan-core as a **tarball** for the identical rev `d098fa2edd659544fc492d7be188d529bbc65af5` (`state/clan-config/flake.lock` — confirmed across every drive under `test-results/`). The CLI pin is the expensive outlier; the report's framing holds. - `TestPinnedClanRef_MatchesFlakeLock` (`internal/clan/toolpin_test.go`) guards the pin against drift — the existing proof surface for candidate (1). Note it asserts `strings.Contains(PinnedClanRef, locked.Locked.URL)` against the **root** `./flake.lock`, which is still `type: git` with the plain repo URL; a tarball flakeref won't contain that string verbatim, so candidate (1) must also update this test (or re-source it from the tarball node). Flagged for the executor, not a triage blocker. ## Why this is a two-way door, not a one-way door The "which candidate fix" call is framed as a supply-chain decision, but neither candidate **widens** anything: both keep the **identical pinned rev**, content-addressed. (1) swaps the transport (`git+https` → the archive-tarball flakeref the lock already uses); (2) warm-stores that same closure. This is supply-chain *hardening*, not a new trust surface, a loosened auth, or non-routine spend — so it is off the one-way-door list. It is **revertible** (a one-line pin change / a warm-store entry) and **provable** (`TestPinnedClanRef_MatchesFlakeLock` + a live gateway deploy drive). That makes it an agent ruling, not Ben's. ## Why `ready-for-session`, not `ready-for-agent` The report is right that the swarm must not land this: the only honest proof is a **live gateway deploy drive** (does the re-pinned/warmed CLI resolve to the identical clan-cli and run end-to-end), and a mis-pinned `PinnedClanRef` reds *every* deploy — a far larger blast radius than the transient #1272 already made survivable. That proof needs an interactive session's lab-drive standing, not swarm-visible `ready-for-agent` work (the swarm queue reads only `ready-for-agent` by construction). This is the ADR 0174 rule-5 case exactly. ## Proposed default ruling (adopt or veto) Since the ticket asks for a ruling on *which* fix, per ADR 0174 rule 4 it gets a default the executing session may adopt: - **Default: candidate (1)** — re-pin through the archive-tarball flakeref `https://git.clan.lol/api/v1/repos/clan/clan-core/archive/<rev>.tar.gz#clan-cli`, the same form `state/clan-config/flake.lock` already uses. It's the minimal, single-pin-source change (ADR 0040), removes the 20 MiB clone outright, and keeps one pin source. Must prove `nix run <tarball-ref>#clan-cli` resolves the identical CLI and the live drive is green (and update `TestPinnedClanRef_MatchesFlakeLock` per the note above). - **Candidate (2)** (warm-store the closure) stays open as an additive belt-and-braces optimization — not mutually exclusive — if the session finds the tarball transport still on the critical path for a cold first deploy. The executing session is free to pick either or both; both are provable by the same drive. **Label:** removing `needs-triage`, keeping `bug`, adding `ready-for-session`.
Author
Member

Close-report — landed (ADR 0174, two-way door)

Ruling: candidate 1 — re-pin PinnedClanRef through the archive tarball flakeref, not git+https. Candidate 2 (warm-store the closure) is not needed to remove the fault and is the larger, harder-to-prove change; candidate 1 alone removes the 20 MiB clone and reuses a fetch the deploy path already relies on. They remain non-exclusive — candidate 2 can still be filed later as a warm-store optimisation if a drive ever shows the tarball fetch itself is slow.

What landed (commit 7026393b)

  • internal/clan/toolpin.go: PinnedClanRef is now clanCoreURL + "/archive/" + clanCoreRev + ".tar.gz#clan-cli" → https://git.clan.lol/clan/clan-core/archive/d098fa2…tar.gz#clan-cli. Same clanCoreURL/clanCoreRev constants (the one pin source, ADR 0040) the community deploy flake already uses (seedcommunity.go:140).
  • internal/clan/errors.go: the #1272 transfer-death classifier case is KEPT (defense-in-depth — a tarball fetch can still transfer-die); comment corrected to note the git-clone outlier is gone.
  • docs/GOTCHAS.md #178 root cause marked CLOSED; STATUS.md lead updated.
  • toolpin_test.go: red-first TestPinnedClanRef_IsTarballNotGitClone (no git+ prefix, is the /archive/<rev>.tar.gz form). The untouched TestPinnedClanRef_MatchesFlakeLock stays green (the tarball ref still carries flake.lock's rev + the clanCoreURL substring).

Proof (why no live paid drive was needed)

The ticket asked for a live gateway drive because "mis-pinning PinnedClanRef would break every deploy". That specific risk is discharged in-session by a stronger proof than one drive, and a paid DO gateway drive is non-routine spend (a one-way door) I do not self-authorize:

  1. nix eval --raw "<git+https-ref>#clan-cli.outPath" and nix eval --raw "<tarball-ref>#clan-cli.outPath" both resolve to the bit-identical derivation /nix/store/8wsdr1zjjlkd0m6d8xliw20nznh9nnay-clan-cli. Same clan-core rev → same Nix output → guaranteed-identical CLI for the app, dev shell, CI and fleet.
  2. nix run "<tarball-ref>#clan-cli" -- --help runs it exit 0 with the full machines/vars/secrets/ssh subcommand set (the actual deploy path uses machines update).
  3. The tarball fetch itself is already exercised on every deploy by the community flake's config eval (GOTCHAS #178: flake.lock pins every input as a tarball; nothing in the community flake fetches a git repo). So this swaps the ONE git-clone step for a fetch mechanism the deploy path already depends on — the risk is inverted: the git clone was the fragile outlier.

go build/vet/test ./internal/clan ./internal/toolchain ./internal/founding/... all green.

Residue for a human (optional, not blocking)

A live gateway deploy drive remains available as belt-and-braces end-to-end confirmation, but it is non-routine spend (a one-way door) — left to human discretion. The change is a revertible one-constant re-pin, so a revert is trivial if a future drive ever surprises.

Ruled by agent under ADR 0174 — veto anytime.

## Close-report — landed (ADR 0174, two-way door) **Ruling: candidate 1** — re-pin `PinnedClanRef` through the archive **tarball** flakeref, not `git+https`. Candidate 2 (warm-store the closure) is not needed to remove the fault and is the larger, harder-to-prove change; candidate 1 alone removes the 20 MiB clone and reuses a fetch the deploy path already relies on. They remain non-exclusive — candidate 2 can still be filed later as a warm-store optimisation if a drive ever shows the tarball fetch itself is slow. ### What landed (commit `7026393b`) - `internal/clan/toolpin.go`: `PinnedClanRef` is now `clanCoreURL + "/archive/" + clanCoreRev + ".tar.gz#clan-cli"` → `https://git.clan.lol/clan/clan-core/archive/d098fa2…tar.gz#clan-cli`. Same `clanCoreURL`/`clanCoreRev` constants (the one pin source, ADR 0040) the community deploy flake already uses (`seedcommunity.go:140`). - `internal/clan/errors.go`: the #1272 transfer-death classifier case is KEPT (defense-in-depth — a tarball fetch can still transfer-die); comment corrected to note the git-clone outlier is gone. - `docs/GOTCHAS.md` #178 root cause marked CLOSED; `STATUS.md` lead updated. - `toolpin_test.go`: red-first `TestPinnedClanRef_IsTarballNotGitClone` (no `git+` prefix, is the `/archive/<rev>.tar.gz` form). The untouched `TestPinnedClanRef_MatchesFlakeLock` stays green (the tarball ref still carries flake.lock's rev + the `clanCoreURL` substring). ### Proof (why no live paid drive was needed) The ticket asked for a live gateway drive because "mis-pinning `PinnedClanRef` would break every deploy". That specific risk is discharged in-session by a **stronger** proof than one drive, and a paid DO gateway drive is **non-routine spend (a one-way door)** I do not self-authorize: 1. `nix eval --raw "<git+https-ref>#clan-cli.outPath"` **and** `nix eval --raw "<tarball-ref>#clan-cli.outPath"` both resolve to the **bit-identical** derivation `/nix/store/8wsdr1zjjlkd0m6d8xliw20nznh9nnay-clan-cli`. Same clan-core rev → same Nix output → guaranteed-identical CLI for the app, dev shell, CI and fleet. 2. `nix run "<tarball-ref>#clan-cli" -- --help` runs it **exit 0** with the full `machines`/`vars`/`secrets`/`ssh` subcommand set (the actual deploy path uses `machines update`). 3. The tarball fetch itself is **already exercised on every deploy** by the community flake's config eval (GOTCHAS #178: `flake.lock` pins every input as a tarball; nothing in the community flake fetches a git repo). So this swaps the ONE git-clone step for a fetch mechanism the deploy path already depends on — the risk is inverted: the git clone was the fragile outlier. `go build`/`vet`/`test ./internal/clan ./internal/toolchain ./internal/founding/...` all green. ### Residue for a human (optional, not blocking) A live gateway deploy drive remains available as belt-and-braces end-to-end confirmation, but it is non-routine spend (a one-way door) — left to human discretion. The change is a revertible one-constant re-pin, so a revert is trivial if a future drive ever surprises. Ruled by agent under ADR 0174 — veto anytime.
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#1273
No description provided.