enroll-configure: stop handing clan's flake ingest the live .git — swap path:<dir> for git+file://<dir> at the nine call sites (deeper fix behind #923) #925

Closed
opened 2026-08-28 06:12:13 +00:00 by matou-build-agent · 2 comments

Follow-up to #923 (settle-retry landed; this is the deeper, structural fix — option 1 in the #923 diagnosis).

Problem

flakeRef(dir, "") returns path:<dir>, which makes nix ingest the config repo's WHOLE tree — its live .git included (verified: nix flake prefetch --json path:/tmp/heal-cold copied 117 loose-object fanout dirs into the store). So every clan invocation copies the entire git history — mutable state the same command is concurrently writing — and any git housekeeping (a repack) mid-ingest reds the read. #923 absorbs the race with a bounded settle-retry + a gc.auto=0 pin; this issue removes the hazard entirely.

The change

Swap path:<dir> for git+file://<dir> (no ?rev=), which excludes .git and honours the working tree, at the nine call sites: internal/clan/vars.go:161, :229; internal/clan/enrollment.go (the generate ref), :1006, :1256; internal/clan/supply.go:55, :79; internal/clan/seedcommunity.go:109; internal/clan/store_count.go:155.

Why this needs a session / live clan run (not a swarm two-way door)

clan writes files and commits them mid-run (its CLAN_NO_COMMIT / --intent-to-add dance exists for exactly this). git+file:// without a rev honours the working tree, but untracked-file visibility has to be proven against a real clan run before the swap — an untracked generated .nix or a staged-but-uncommitted flake.lock that path: currently sees could vanish from the ingest and break vars generate/machines update. So this is not a seam-provable two-way door; it needs a clan-lab drive on both the rented and self-hosted paths.

Filed under ADR 0174 as the residue #923 could not prove in a headless session.

Follow-up to #923 (settle-retry landed; this is the deeper, structural fix — option 1 in the #923 diagnosis). ## Problem `flakeRef(dir, "")` returns `path:<dir>`, which makes nix ingest the config repo's WHOLE tree — its live `.git` included (verified: `nix flake prefetch --json path:/tmp/heal-cold` copied 117 loose-object fanout dirs into the store). So every clan invocation copies the entire git history — mutable state the same command is concurrently writing — and any git housekeeping (a repack) mid-ingest reds the read. #923 absorbs the *race* with a bounded settle-retry + a `gc.auto=0` pin; this issue removes the *hazard* entirely. ## The change Swap `path:<dir>` for `git+file://<dir>` (no `?rev=`), which excludes `.git` and honours the working tree, at the nine call sites: `internal/clan/vars.go:161`, `:229`; `internal/clan/enrollment.go` (the generate ref), `:1006`, `:1256`; `internal/clan/supply.go:55`, `:79`; `internal/clan/seedcommunity.go:109`; `internal/clan/store_count.go:155`. ## Why this needs a session / live clan run (not a swarm two-way door) clan writes files and commits them mid-run (its `CLAN_NO_COMMIT` / `--intent-to-add` dance exists for exactly this). `git+file://` without a rev honours the working tree, but **untracked-file visibility has to be proven against a real clan run** before the swap — an untracked generated `.nix` or a staged-but-uncommitted `flake.lock` that `path:` currently sees could vanish from the ingest and break `vars generate`/`machines update`. So this is not a seam-provable two-way door; it needs a clan-lab drive on both the rented and self-hosted paths. Filed under ADR 0174 as the residue #923 could not prove in a headless session.
Author
Member

This was generated by AI during triage.

Agent Brief

Category: bug
Summary: Swap path:<dir> for git+file://<dir> (no ?rev=) at the clan flake-ingest call sites so nix stops ingesting the config repo's live .git

Current behavior:
flakeRef(dir, "") returns path:<dir>, which makes nix ingest the config repo's whole working tree — its live .git included (verified: nix flake prefetch --json path:/tmp/heal-cold copied 117 loose-object fanout dirs into the store). Every clan invocation copies the entire git history — mutable state the same command is concurrently writing — so any git housekeeping (a repack) mid-ingest reds the read. #923/#924 absorbed the race (bounded settle-retry + gc.auto=0 pin); the hazard remains.

Desired behavior:
Clan flake ingest uses git+file://<dir> without a ?rev=, which excludes .git and honours the working tree — at the flake-ref call sites that pass a config-repo dir to clan (the flakeRef(dir, "") uses in the vars, enrollment/generate, machines-update, supply/archive, seed-community lock, and store-count paths). The store no longer ingests the live .git; vars generate/machines update still see every file they need, including untracked generated .nix and staged-but-uncommitted flake.lock.

Key interfaces:

  • flakeRef(dir, revision string) — the revision == "" (working-tree) case must emit git+file://<dir> rather than path:<dir>. Confirm every caller that passes a config-repo dir gets the working-tree form; leave any ?rev=-pinned uses (if any) as-is.
  • Preserve untracked/uncommitted-file visibility — clan writes and commits files mid-run (its CLAN_NO_COMMIT/--intent-to-add dance). This is the risk the drive must prove.

Acceptance criteria:

  • Clan flake ingest no longer copies the config repo's .git into the store (probe: nix flake prefetch --json <ref> shows no loose-object fanout dirs).
  • A live clan-lab drive on both the rented and self-hosted paths is green through vars generate and machines update — proving untracked generated .nix and a staged-but-uncommitted flake.lock remain visible after the swap.
  • No regression in the #923/#924 config_eval settle-retry behaviour.

Out of scope:

  • The settle-retry / gc.auto=0 pin from #923/#924 (keep as defence-in-depth).
  • The other three drive-20260828T051317Z defects (#926, #927, #928).

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

The swap's safety hinges on untracked-file visibility under a real clan run — an untracked generated .nix or a staged-but-uncommitted flake.lock that path: currently sees could vanish from a git+file:// ingest and silently break vars generate/machines update. That is not seam-provable offline; the issue body itself scopes it to "a clan-lab drive on both the rented and self-hosted paths." A live clan-lab drive is an interactive session's standing (live infra doors), so a swarm worker must not pick it up.

Ruled by agent under ADR 0174 — veto anytime.
Ruling: ready-for-session (not ready-for-human). This is a two-way door — the swap is revertible by a single commit, and it is provable, but only by a live clan-lab drive, which needs a session's live-infrastructure standing, not Ben's. It is not on the one-way-door list: no personal credentials, no security-posture widening, no member-facing trust accept, no data destruction, no non-routine spend, no physical hardware. There is no human residue — hence ready-for-session, so the swarm queue (ready-for-agent-only) correctly skips it while an interactive session can run the drive.

> *This was generated by AI during triage.* ## Agent Brief **Category:** bug **Summary:** Swap `path:<dir>` for `git+file://<dir>` (no `?rev=`) at the clan flake-ingest call sites so nix stops ingesting the config repo's live `.git` **Current behavior:** `flakeRef(dir, "")` returns `path:<dir>`, which makes nix ingest the config repo's **whole** working tree — its live `.git` included (verified: `nix flake prefetch --json path:/tmp/heal-cold` copied 117 loose-object fanout dirs into the store). Every clan invocation copies the entire git history — mutable state the same command is concurrently writing — so any git housekeeping (a repack) mid-ingest reds the read. #923/#924 absorbed the *race* (bounded settle-retry + `gc.auto=0` pin); the *hazard* remains. **Desired behavior:** Clan flake ingest uses `git+file://<dir>` without a `?rev=`, which excludes `.git` and honours the working tree — at the flake-ref call sites that pass a config-repo dir to clan (the `flakeRef(dir, "")` uses in the vars, enrollment/generate, machines-update, supply/archive, seed-community lock, and store-count paths). The store no longer ingests the live `.git`; `vars generate`/`machines update` still see every file they need, including untracked generated `.nix` and staged-but-uncommitted `flake.lock`. **Key interfaces:** - `flakeRef(dir, revision string)` — the `revision == ""` (working-tree) case must emit `git+file://<dir>` rather than `path:<dir>`. Confirm every caller that passes a config-repo dir gets the working-tree form; leave any `?rev=`-pinned uses (if any) as-is. - Preserve untracked/uncommitted-file visibility — clan writes and commits files mid-run (its `CLAN_NO_COMMIT`/`--intent-to-add` dance). This is the risk the drive must prove. **Acceptance criteria:** - [ ] Clan flake ingest no longer copies the config repo's `.git` into the store (probe: `nix flake prefetch --json <ref>` shows no loose-object fanout dirs). - [ ] A live clan-lab drive on **both** the rented and self-hosted paths is green through `vars generate` and `machines update` — proving untracked generated `.nix` and a staged-but-uncommitted `flake.lock` remain visible after the swap. - [ ] No regression in the #923/#924 config_eval settle-retry behaviour. **Out of scope:** - The settle-retry / `gc.auto=0` pin from #923/#924 (keep as defence-in-depth). - The other three drive-`20260828T051317Z` defects (#926, #927, #928). ## Why this is `ready-for-session`, not `ready-for-agent` The swap's safety hinges on **untracked-file visibility under a real clan run** — an untracked generated `.nix` or a staged-but-uncommitted `flake.lock` that `path:` currently sees could vanish from a `git+file://` ingest and silently break `vars generate`/`machines update`. That is **not** seam-provable offline; the issue body itself scopes it to "a clan-lab drive on both the rented and self-hosted paths." A live clan-lab drive is an interactive session's standing (live infra doors), so a swarm worker must not pick it up. Ruled by agent under ADR 0174 — veto anytime. **Ruling:** `ready-for-session` (not `ready-for-human`). This is a two-way door — the swap is revertible by a single commit, and it is provable, but **only by a live clan-lab drive**, which needs a session's live-infrastructure standing, not Ben's. It is not on the one-way-door list: no personal credentials, no security-posture widening, no member-facing trust accept, no data destruction, no non-routine spend, no physical hardware. There is no human residue — hence `ready-for-session`, so the swarm queue (`ready-for-agent`-only) correctly skips it while an interactive session can run the drive.
Author
Member

Close-report — landed + proven on a real clan run (ADR 0174)

Ruled by agent under ADR 0174 — veto anytime. This ran as a session (not a swarm two-way door) exactly because the ticket's premise had to be proven against a live clan, which it was.

What landed

Commit 131e1854 on main.

flakeRef(dir, "") now returns git+file://<dir> (no ?rev=) instead of path:<dir>, swapping the ingest at eight of the nine call sites — every enrollment/eval/supply site (vars generate @enrollment.go:752 & vars.go:161, vars set @enrollment.go:771, vars get @vars.go:229, machines update @enrollment.go:1038 & :1288, flake archive @supply.go:55 & :79, the store-count toplevel eval @store_count.go:155). One flakeRef edit covers all eight — it was the sole producer of path:. So nix no longer copies the config repo's live .git into the store, removing #923's hazard at source (path: snapshotted the whole .git/objects/** while the single writer was committing into it — ADR 0102 — which is what a mid-run repack raced).

What the real clan run proved (why this was ready-for-session)

  1. nix 2.35.1 dirty-tree fetcher semantics (scratch nix flake prefetch --json git+file://… probe): .git excluded; committed files included with working-tree content; staged and git add -N intent-to-add files included; only purely-untracked, unstaged files fall out.
  2. Both enrollment paths green end-to-end — TestOwnVPSGateway_EvalSmoke (self-hosted) and TestRentedGateway_EvalSmoke (rented), IDSS_EVAL_SMOKE=1, against real clan-core + nixpkgs: each drove clan vars generate --flake git+file://<dir> --no-sandbox (sealed kanidm-tls vars, committed by clan itself) then a real toplevel nix eval — passed.

The one site that must NOT swap (caught by the live run)

SeedCommunity's seed-leg nix flake lock (seedcommunity.go) locks a flake.nix it wrote but has not yet committed (pre-commit, inside the single-writer closure, to land both in one commit). Those files are purely untracked, so under git+file:// the lock reds Path 'flake.nix' … is not tracked by Git — reproduced on both the own-VPS and rented eval-smokes before the fix. That call site keeps path: deliberately, with an inline note carrying the evidence; #925's hazard cannot reach it (the seed runs once, single-threaded, with git gc pinned off per #924). This is precisely the untracked-file residue the ticket said needed a live clan run to settle.

Defense-in-depth retained, comments corrected

#923's generateRepackAttempts settle-retry and #924's gc pins stay — nix's dirty-tree fetcher still reads .git via git plumbing (ls-files/status + HEAD-tree read) during ingest, so the repack race is narrowed, not eliminated. GOTCHAS #111 and the four now-stale path:<dir> comments (adapter.go×2, configrepo.go, enrollment.go) updated.

Proof / discipline

  • go build ./..., go vet, go test ./... — all green.
  • TestSeedCommunity_LocksTheFlakeItWrites assertion updated to expect the seed lock's deliberate path: (with rationale).
  • STATUS.md header updated in the same commit.

Out-of-scope observation, filed not smuggled

The private + own-VPS eval-smokes also trip a pre-existing assertDrvPathBaseline drift (the toplevel eval itself passes). Confirmed on stock main with #925 stashed → not caused by this change. Filed as #935 (likely a non-deterministic generated cert embedded at eval); not touched here (the test forbids blind re-baselining).

## Close-report — landed + proven on a real clan run (ADR 0174) **Ruled by agent under ADR 0174 — veto anytime.** This ran as a session (not a swarm two-way door) exactly because the ticket's premise had to be proven against a live clan, which it was. ### What landed Commit `131e1854` on `main`. `flakeRef(dir, "")` now returns **`git+file://<dir>`** (no `?rev=`) instead of `path:<dir>`, swapping the ingest at **eight** of the nine call sites — every enrollment/eval/supply site (`vars generate` @enrollment.go:752 & vars.go:161, `vars set` @enrollment.go:771, `vars get` @vars.go:229, `machines update` @enrollment.go:1038 & :1288, `flake archive` @supply.go:55 & :79, the store-count `toplevel` eval @store_count.go:155). One `flakeRef` edit covers all eight — it was the sole producer of `path:`. So nix no longer copies the config repo's live `.git` into the store, removing #923's hazard at source (`path:` snapshotted the whole `.git/objects/**` while the single writer was committing into it — ADR 0102 — which is what a mid-run repack raced). ### What the real clan run proved (why this was `ready-for-session`) 1. **nix 2.35.1 dirty-tree fetcher semantics** (scratch `nix flake prefetch --json git+file://…` probe): `.git` **excluded**; committed files **included with working-tree content**; **staged** and **`git add -N` intent-to-add** files **included**; only **purely-untracked, unstaged** files fall out. 2. **Both enrollment paths green end-to-end** — `TestOwnVPSGateway_EvalSmoke` (self-hosted) and `TestRentedGateway_EvalSmoke` (rented), `IDSS_EVAL_SMOKE=1`, against real clan-core + nixpkgs: each drove `clan vars generate --flake git+file://<dir> --no-sandbox` (sealed kanidm-tls vars, committed by clan itself) then a real toplevel `nix eval` — **passed**. ### The one site that must NOT swap (caught by the live run) `SeedCommunity`'s seed-leg `nix flake lock` (seedcommunity.go) locks a `flake.nix` it wrote **but has not yet committed** (pre-commit, inside the single-writer closure, to land both in one commit). Those files are **purely untracked**, so under `git+file://` the lock reds `Path 'flake.nix' … is not tracked by Git` — reproduced on both the own-VPS and rented eval-smokes before the fix. That call site **keeps `path:` deliberately**, with an inline note carrying the evidence; #925's hazard cannot reach it (the seed runs once, single-threaded, with git gc pinned off per #924). This is precisely the untracked-file residue the ticket said needed a live clan run to settle. ### Defense-in-depth retained, comments corrected #923's `generateRepackAttempts` settle-retry and #924's gc pins stay — nix's dirty-tree fetcher still reads `.git` via git plumbing (ls-files/status + HEAD-tree read) during ingest, so the repack race is **narrowed, not eliminated**. `GOTCHAS #111` and the four now-stale `path:<dir>` comments (adapter.go×2, configrepo.go, enrollment.go) updated. ### Proof / discipline - `go build ./...`, `go vet`, `go test ./...` — all green. - `TestSeedCommunity_LocksTheFlakeItWrites` assertion updated to expect the seed lock's deliberate `path:` (with rationale). - `STATUS.md` header updated in the same commit. ### Out-of-scope observation, filed not smuggled The private + own-VPS eval-smokes also trip a **pre-existing** `assertDrvPathBaseline` drift (the toplevel eval itself passes). Confirmed on **stock main** with #925 stashed → not caused by this change. Filed as **#935** (likely a non-deterministic generated cert embedded at eval); not touched here (the test forbids blind re-baselining).
matou-build-agent 2026-08-28 08:04:18 +00:00
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#925
No description provided.