knowledge: remove the redundant concurrent boot-time pull that races with reset --hard, and clean -fd untracked drift too

This commit is contained in:
damocles 2026-08-24 14:30:54 +02:00 committed by mara
commit 30067cbcb2
2 changed files with 30 additions and 18 deletions

View file

@ -254,20 +254,30 @@ pub async fn pull(coord: &Coordinator) -> Result<()> {
.args(["-C", LOCAL_DIR, "remote", "set-url", "origin", &plain])
.output()
.await;
// Discard any local modifications before pulling. Nothing in this
// codebase writes to `LOCAL_DIR` after the initial clone (`seed_readme`
// runs once, at creation, before any pull) — this working tree exists
// to mirror `origin/main`, not to be edited in place. A tracked file
// left dirty by any other means (a stray manual edit on the host, an
// interrupted prior operation) would otherwise abort the `--ff-only`
// merge below with "local changes would be overwritten", wedging
// every future pull the same way until someone notices and resets it
// by hand. Best-effort: a reset failure surfaces through the pull's
// own error below rather than needing its own branch here.
// Discard any local drift before pulling — both tracked (`reset --hard`)
// and untracked (`clean -fd`). Nothing in this codebase writes to
// `LOCAL_DIR` after the initial clone (`seed_readme` runs once, at
// creation, before any pull) — this working tree exists to mirror
// `origin/main`, not to be edited in place. A tracked file left dirty
// by any other means (a stray manual edit on the host, an interrupted
// prior operation, or — the actual root cause here — two unsynchronized
// boot-time pull callers racing on this same working tree, since fixed
// in `main.rs`) would otherwise abort the `--ff-only` merge below with
// "local changes would be overwritten"; an untracked file left behind
// the same ways aborts it with "untracked working tree files would be
// overwritten" instead — same wedge, just `clean`'s failure message
// rather than `reset`'s. Either way it wedges every future pull
// identically until someone notices and resets it by hand. Best-effort:
// a failure here surfaces through the pull's own error below rather
// than needing its own branch.
let _ = crate::lifecycle::git_command()
.args(["-C", LOCAL_DIR, "reset", "--hard", "HEAD"])
.output()
.await;
let _ = crate::lifecycle::git_command()
.args(["-C", LOCAL_DIR, "clean", "-fd"])
.output()
.await;
let before = head_sha().await;
// The repo is public (`ensure_knowledge_repo` makes it so), so an