Skip to content

gardener: pull the project root before the checks (pull: true) - #1267

Merged
scuttletoby merged 3 commits into
mainfrom
gardener-pull
Nov 29, 2026
Merged

scuttletoby merged 3 commits into
mainfrom
gardener-pull

Conversation

@scuttletoby

@scuttletoby scuttletoby commented Nov 29, 2026 •

Copy link
Copy Markdown
Owner

Refs #1064.

The daily gardener reads each project's root, but nothing brings that checkout up to date, so its checks drift behind main (the t3-fork root is pulled by hand today).

A project may now set "pull": true:

  • Before the checks, the root is checked first. If it is not a folder, it is named as such. If it has uncommitted changes to tracked files (git status --porcelain --untracked-files=no), it is not pulled at all, not even moved under edits a new commit leaves alone. Untracked files do not count: a fast-forward never changes them, and git refuses one that would.
  • The pull itself is git -c merge.autoStash=false -c rebase.autoStash=false pull --ff-only --no-rebase --no-autostash, so the user's git config can never stash, merge or rebase. It runs with no prompt (GIT_TERMINAL_PROMPT=0), in its own process group, with a 5-minute limit per git call (a hanging git is stopped along with its children).
  • If anything goes wrong (a missing folder, not a git checkout, a dirty root, local commits, no upstream branch, a missing or hanging git), you get one warning finding, gardener.root-not-pulled, and the local report says why. The checks then read the root as it was, and the run still finishes and still writes its report.
  • A dry run never pulls.
  • pull without root is refused. The default is off, so existing machine files keep working.

State question:

  • Running again after a skipped or failed pull: nothing is retried within the day unless you pass --force. The next day's run (or a --force) checks again from scratch. It pulls once the cause is gone; until then it gives the same one warning every day. No pull state is kept: the checkout itself is the state.
  • A pull stopped half-way by the 5-minute limit: git and its children are killed. A fast-forward that was still fetching leaves the checkout untouched (at most new objects or a fetch lock under .git). One killed while updating files can leave .git/index.lock, or the tree half moved. In that case the next run's git status either fails on the lock, or shows the half-moved files as uncommitted changes. Both give the warning naming why, and nothing is pulled over them until someone fixes it by hand. It is never hidden and never "fixed" by the gardener.
  • An old config without pull: it defaults to false, and the run behaves exactly as before.
  • An empty or non-git root: an empty root with pull: true is refused when the config is read. A folder that is not a git checkout gives the warning with git's own words ("not a git repository"). A root folder that does not exist gives the warning "the root … is not a folder". The checks still run in each case.

Tests: Pull class in fork-kit/gardener/tests/run.test.py (9 tests). Fix round 1 added: auto-stash in the root's config (both through the status check, and with that check bypassed so the pull's own flags are tested), a dirty root whose edits do not touch the new commit, an untracked file that does not block, and a missing or non-git root. There are 8 RedCheck mutations for the pull. The whole file passes locally (47 tests, git 2.43). --no-rebase is hardening for git before 2.33 only, and there is no test for it: git 2.43 already refuses with pull.rebase=true.

🤖 Generated with Claude Code

The daily gardener reads a project root that nothing brings up to date, so
its checks drift behind main. A project may now set "pull": true: before the
checks the root is pulled fast-forward only, without a prompt and with a
5-minute limit. Any failure (local commits, no upstream, a missing or hanging
git) is one warning finding, gardener.root-not-pulled, and the checks read the
root as it was. A dry run never pulls.

Refs #1064

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@scuttletoby

Copy link
Copy Markdown
Owner Author

Fix

What failed: the daily gardener reads each project's root, and nothing brought that checkout up to date. Its checks would read an old tree and report on code that main has already changed (the t3-fork root is pulled by hand today).
Why: the kit had no step to bring the root up to date. "pull": true adds a fast-forward-only pull with a time limit. Any failure becomes one warning finding, and the run never stops for it.

The red check's copy of cli.py without the kill ('a hanging pull is
stopped with its children') waits for the fake git and its child to
end, so their 30 s sleep put 30 s on run.test.py and took it past its
CI weight. 10 s still fails that copy (the test wants under 8 s) and
the real run stops it after 1 s.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@scuttletoby

Copy link
Copy Markdown
Owner Author

lens: code · reviewer: Claude Opus 5.5 (code lens, round 1) · read at: 8f56696

major: a git config with merge.autoStash=true (repo or global) makes the pull change a dirty checkout and still report success. Reproduced with git 2.43: a root one commit behind, with an uncommitted edit to a file the new commit also changes, gives pull() -> None (no gardener.root-not-pulled finding) and leaves the root at the new commit with UU a (an unresolved conflict) and stash@{0}: autostash. The checks then read a conflicted tree and the report says nothing. Fix: pin git's behaviour on the command line instead of trusting the user's config, e.g. git -c merge.autoStash=false -c rebase.autoStash=false pull --ff-only --no-rebase --no-autostash --quiet, and add a test with merge.autoStash=true in the root's config.
minor: even without autostash, a dirty root whose edits do not touch the incoming files is fast-forwarded under the edits (reproduced: HEAD moves, M b stays, no finding). Nothing is lost, but the brief said a dirty checkout is never changed, and the checks then read upstream plus local edits. Simplest: git status --porcelain --untracked-files=no first; non-empty = the warning finding, no pull. If moving under edits is wanted, say so in the README instead.
minor: --no-rebase is also worth adding for older git: before git 2.33-ish, pull.rebase=true plus --ff-only rebased local commits. With git 2.43 a diverged root with pull.rebase=true is refused correctly ("Not possible to fast-forward"), so this is hardening only.
minor: a missing root folder shows as "git could not start (FileNotFoundError)", which reads as git missing; naming the folder would help whoever reads report.md.

Checked and fine: diverged root (local commit) is refused and named, never merged or rebased (git 2.43, with and without pull.rebase=true); 300 s limit with its own session and a process-group kill; no prompt (GIT_TERMINAL_PROMPT=0, stdin closed, no tty); dry run never pulls; missing pull defaults to false and pull without root is refused; git's own words go to the local report only (the issue text is fixed words).

State question: runs again: a second pull is a no-op, and --force pulls again, both after the lock and the done-day check, so two runs never pull at once. Stops half-way: a killed git can leave index.lock; every later pull then fails and is named each day until someone removes it (named, not hidden: fine). Existing/old/empty state: old machine files have no pull and behave as before; a root that is not a git checkout, detached, or without upstream gives the one warning. The gap is existing local state the user's git config acts on (the major above).

🤖 Generated with Claude Code

A root with uncommitted changes to tracked files is no longer pulled
(git status first; untracked files do not count). The pull itself pins
merge.autoStash and rebase.autoStash off and passes --no-rebase and
--no-autostash, so a user's git config cannot stash, re-apply and leave
a conflicted tree behind a pull reported as fine. A missing root folder
is named as such instead of as git failing to start.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@scuttletoby

Copy link
Copy Markdown
Owner Author

lens: code · reviewer: Claude Opus 5.5 (code lens, round 2) · read at: de1a488

blocker: none
major: none
minor: an untracked file at a path the incoming commit adds is refused correctly (root left at the old commit, file kept, one warning), but the finding's detail is just Aborting (git's last stderr line), so report.md does not say which file or why. The same happens for an index.lock ("remove the file manually to continue.") and for an assume-unchanged or skip-worktree edit (also only Aborting). Fix: use the first error:/fatal: line instead of the last line, or add the file name. There is also no test for this clash: the untracked case in the tests is a file the new commit does not touch.
minor: the README says untracked files are safe because "git refuses one that would" change them. That is not true for an ignored file: reproduced with git 2.43, a root with new in .git/info/exclude and a local new, and an upstream commit that adds new: the pull succeeds, no finding, and the local file is replaced by the upstream one. This is git's normal behaviour and fine for a gardener-only clone, but the sentence should say "untracked, not ignored" (or say ignored files can be overwritten).

Round 1, fixed: autostash. With merge.autoStash=true, rebase.autoStash=true and pull.rebase=true in the root's config, and separately in a global config, plus a clashing edit: the dirty check refuses, HEAD stays put, the edit is kept, no stash. With the dirty check bypassed (_dirty stubbed to ''), the pull's own -c ... --no-autostash flags refuse ("Aborting"), the edit is kept and there is no stash entry.
Round 1, fixed: a dirty root whose edits do not touch the new commit (unstaged or staged only) is no longer moved. An unrelated untracked file still pulls. Round 1, fixed: --no-rebase added. Round 1, fixed: a missing root reads "the root … is not a folder", and a non-git folder gives git's "not a git repository".
Checked and fine: a local commit is refused ("Not possible to fast-forward"), and an up-to-date root returns no finding. The _git argument order (what then -c before pull) builds git -c merge.autoStash=false -c rebase.autoStash=false pull --ff-only --no-rebase --no-autostash --quiet.

State question:

  • Runs again after a skipped or failed pull: nothing is kept. The next day, or --force, runs status and pull from scratch, after the lock and the done-day check, so two runs never pull at once. It gives the same one warning until the cause is gone, then pulls.
  • Killed by the 5-minute limit: the process group is killed. A killed fetch leaves the tree as it was. A killed checkout leaves either an index.lock, which the next status/pull names (with the poor wording above), or half-moved files, which the next status counts as dirty, so nothing is pulled over them. It is never fixed silently.
  • Old config without pull: defaults to false, so it behaves as before.
  • Empty root: pull without root is refused when the config is read. A missing folder and a non-git folder each give the one warning, and the checks still run.

🤖 Generated with Claude Code

@scuttletoby scuttletoby added the fork:merge-ready Merge conveyor: lenses done, merge when green (PRs) label Nov 29, 2026
@scuttletoby
scuttletoby merged commit 16d3c30 into main Nov 29, 2026
29 checks passed
scuttletoby added a commit that referenced this pull request Nov 29, 2026
A refused pull's warning in report.md now says why, from git's first
error:/fatal: line and the files it lists (an untracked file where the
new commit adds one, a left-over index.lock, a skip-worktree edit),
not git's closing "Aborting". git's words stay out of the issue.

The README no longer says untracked files are always safe: an ignored
file at a path the new commit adds is replaced, as plain git pull does
(pinned by a test).

Co-authored-by: Claude Opus 5.5 <[email protected]>
@scuttletoby
scuttletoby deleted the gardener-pull branch November 29, 2026 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork:merge-ready Merge conveyor: lenses done, merge when green (PRs)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant