Skip to content
This repository was archived by the owner on Dec 3, 2026. It is now read-only.

feat: meta git clone-missing, clone-prune and clone-sync; tips and warnings where Matt's run went red [[tasks/harmony-3037]] - #157

Merged
gold-silver-copper merged 2 commits into
mainfrom
feat/meta-clone-cmds
Nov 3, 2026
Merged

gold-silver-copper merged 2 commits into
mainfrom
feat/meta-clone-cmds

Conversation

@gold-silver-copper

@gold-silver-copper gold-silver-copper commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Task: [[tasks/harmony-3037]]. Matt used the new meta on 2026-11-02 and hit three things: the change in meta git update (#151), meta git pull --recursive failing with git's usage text in every repo, and meta -r git pull ending red over projects not cloned yet. This is the first step the owner and Matt agreed: no change to the plugin model, update stays as #151 made it.

What changes for users

Command What it does
meta git update Pull the workspace repo, fast-forward every cloned repo (git pull --ff-only), clone the missing ones (unchanged)
meta git clone-missing Clone the projects the .meta.yaml files on disk list that aren't cloned; change no repo that is (no pull, fetch or checkout)
meta git clone-prune Remove the repos no .meta.yaml lists that hold nothing unpushed; keep and name the others
meta git clone-sync clone-missing, then clone-prune

All three new commands take -r (or meta's --recursive) and --depth the way update -r does, --dry-run, --json ({"dry_run", "repos": [{"path", "action", "reason"?}]}, action being cloned, removed, kept or failed), and --include/--exclude/--tag (the projects cloned, and the meta repos searched for leftovers; with a selection, -r goes to meta, meta -r --include x git clone-missing, because meta makes the selection before the command runs). They refuse inside a worktree set, as update does. They're in meta-git's plugin info, meta git --help and their own --help.

clone-prune deletes a repo only when all of these hold, and otherwise keeps it and says why:

  • it is a real folder in a meta repo's folder (not a link), inside the workspace, and no .meta.yaml read lists it or a project inside it;
  • its git directory is inside it;
  • meta_git_lib::worktree::safety::repo_holds finds nothing: no uncommitted or untracked files, stashes, commits on no remote, linked worktrees;
  • no other git repository is inside it, not even an ignored or bare one. This is my addition: an old meta repo left behind keeps its children gitignored, and repo_holds doesn't see them, so deleting it would delete their unpushed work too.

A removal that fails midway is reported as Not removed x: it was removed only in part (…), as failed in the JSON, and makes the command exit 1.

Ignored files are not checked (decision 3 defines "holds nothing" by repo_holds). See "Choices left to the owner".

Before / after

meta git pull --recursive (git rejects --recursive in every repo):

  • before: three copies of git's usage text, then Summary: ✗ 3 out of 3 commands failed.
  • after: the same, then one line:
    tip: --recursive is an option of meta itself: it goes before the command, as in meta --recursive git pull

meta reads this only from the tool's own error: git's unknown option `recursive', unknown switch `r' and unrecognized argument: --json, clap's unexpected argument '--x', GNU's unrecognized option '--x', and the --x=value form of each. The command still runs exactly as typed (#148), and the tip shows only when every repo failed. With --sequential, meta doesn't capture the output, so no tip is shown: the exit code alone can't tell which option was rejected (git status -s --no-such-option exits 129 too, and -s is also one of meta's options).

meta -r git pull with a project not cloned yet:

  • before: ✗ group-b/b2: not cloned (run 'meta git update'), counted as a failed command, exit 1.
  • after: warning: group-b/b2 is not cloned; meta git clone-missing clones it, then the pulls; exit 0 when they all worked. --strict makes it an error. meta exec still fails there, now naming meta git clone-missing.

meta git update progress:

  • before: [1/1] Pulled open-source (+17 nested), then [2/18] …
  • after: [1/7] … [7/7], the workspace first. The total is the repos the .meta.yaml files on disk list, and it grows only if a pull adds projects.

meta git update, for a repo no .meta.yaml lists:

  • before: warning: swe-marathon-bench is not in .meta.yaml; it has no uncommitted or untracked files, stashes, worktrees, or commits on a branch, tag or HEAD that its remote branches lack (ignored files and the reflog not checked)
  • after: warning: swe-marathon-bench isn't in .meta.yaml (nothing unpushed; meta git clone-prune removes it). When it holds work: warning: frontend isn't in .meta.yaml; it holds 1 file untracked: scratch.txt; 1 commit on no remote: …, with no mention of prune. After update -r it names meta -r git clone-prune.

make build-plugins: no change. On main the binaries are meta-git, meta-project and meta-cargo (meta_rust_cli/Cargo.toml names it meta-cargo since #144), and those are the names the Makefile copies. If Matt saw a failure there, it came from something else; I didn't reproduce one.

Docs: README and the meta-git/meta-plugins skills get the table above; the FAQ and meta project hints that told people to clone with meta git update now name meta git clone-missing. No doc in this repo says meta git pull --recursive (grep finds none); it came from #135's PR text, which isn't in the repo.

Internals

  • CloneQueue (meta_git_lib) records leftovers for every .meta.yaml it reads, not only when pulling, and drops one that another .meta.yaml lists or that holds a listed project (libs around libs/x). New: only(dirs) (a selection), expect(n)/found() (progress total). Repos entered as already cloned no longer count as tasks. Outcome.cloned is now the list of folders cloned.
  • update.rs shares workspace() (the worktree-set refusal), run() (SSH masters and the worker pool) and Leftover::of (the one judgement used by update's warning and by prune) with the new clone_missing.rs.
  • loop_lib::Outer: the calling program's name and options, which meta builds from its own clap definition (Cli::command()), so the option list isn't written out twice.

Verified

  • cargo nextest run --workspace: 630/630. cargo clippy --workspace --all-targets clean.
  • bats: git exec dry_run project_list help url_credentials: 226/226. New tests in tests/git.bats:
    • clone-missing changes no cloned repo (heads, origin/main and a dirty file unchanged);
    • clone-missing clones only the selected projects, and refuses a selection with its own -r;
    • clone-prune keeps one leftover for each kind of held work (untracked, modified, stash, unpushed, worktree, nested repo, bare repo, link), removes a clean one, and never touches a plain folder;
    • clone-sync does both (--json), and refuses in a worktree set;
    • --json names a failed clone and a refused folder by their paths;
    • the tip fires for --recursive, --tag=v1 and git log --json, and not for --no-such-option, -s --no-such-option or a failed checkout;
    • an uncloned project during meta git pull is warned about once, the real pull advances, exit 0; it is an error under --strict and a failure in meta exec.
  • A clone_queue unit test: a repo that holds a listed project is no leftover.
  • A real run in a sandbox (own HOME, XDG_*, GIT_CONFIG_GLOBAL, META_DATA_DIR, local bare remotes), shaped like harmony: a root, two group meta repos, nested projects, group-b/b2 missing, a clean leftover and one with an unpushed commit. One pass:
$ meta -r git clone-missing
Clone completed (1 cloned)
[exit 0]

$ meta -r --dry-run git clone-prune
Would keep held-leftover: it holds 1 commit on no remote: 1de35fb unpushed work
Would remove safe-leftover (nothing unpushed)
[exit 0]

$ meta -r git clone-prune
Kept held-leftover: it holds 1 commit on no remote: 1de35fb unpushed work
Removed safe-leftover (nothing unpushed)
Prune completed (1 removed, 1 kept)
[exit 0]

$ meta -r git clone-sync
Kept held-leftover: it holds 1 commit on no remote: 1de35fb unpushed work
Removed safe-leftover (nothing unpushed)
Sync completed (1 cloned, 1 removed, 1 kept)
[exit 0]

$ meta -r git update
warning: held-leftover isn't in .meta.yaml; it holds 1 commit on no remote: 1de35fb unpushed work
Update completed (7 pulled, 0 cloned)
[exit 0]

$ meta git pull --recursive

✗ . (ws):
error: unknown option `recursive'
usage: git pull [<options>] [<repository> [<refspec>...]]
    … (git's usage text) …

✗ ./group-a:
error: unknown option `recursive'
usage: git pull [<options>] [<repository> [<refspec>...]]
    … (git's usage text) …

✗ ./group-b:
error: unknown option `recursive'
usage: git pull [<options>] [<repository> [<refspec>...]]
    … (git's usage text) …


Summary: ✗ 3 out of 3 commands failed

✗ . (ws): git pull --recursive (exit code 129) 

✗ ./group-a: git pull --recursive (exit code 129) 

✗ ./group-b: git pull --recursive (exit code 129) 

tip: --recursive is an option of meta itself: it goes before the command, as in meta --recursive git pull
[exit 1]

$ meta -r git pull
warning: group-b/b2 is not cloned; `meta git clone-missing` clones it

✓ . (ws):
Already up to date.

✓ ./group-a:
Already up to date.

✓ ./group-a/a1:
Already up to date.

✓ ./group-a/a2:
Already up to date.

✓ ./group-b:
Already up to date.

✓ ./group-b/b1:
Already up to date.

6 commands complete
[exit 0]

(clone-sync ran after b2 was deleted again and the clean leftover re-cloned. The progress bars are on stderr and don't show off a terminal; on a pty, update -r shows [1/7] … [7/7].)

Review

Round 1 at 1bff5b3. Opus (simplicity, user-facing, correctness): yes. Codex Sol (correctness, data safety): no, with 5 blocking findings, all fixed in 85eec86: a bare repo inside a leftover, a selection with the command's own -r, the --sequential tip guess, JSON paths for failures, a test of a real pull. From Opus's notes I also took: a partial removal is reported as such, the update hint carries -r, git's unrecognized argument form, and the clone hints in the FAQ and meta project. CodeRabbit: --option=value in the tip, fixed.

Not verified

  • Windows and macOS: not run locally (CI covers them). Deleting a repo on Windows depends on std::fs::remove_dir_all removing git's read-only pack files.
  • make build-plugins: not run (release build); the names were checked against the [[bin]] entries.
  • No run against the real harmony workspace: clone-prune deletes, so it ran only in the sandbox.

Choices left to the owner

  • clone-prune deletes ignored files in a leftover (.env, build output), as decision 3 says. Checking them would keep nearly every repo that has ever been built.
  • clone-prune exits 0 when it keeps a repo; it names it on stdout.

Try it

The sandbox scripts are in the owner's notes; this builds the PR head in a worktree of its own and runs the pass above:

cd ~/code/gitkb-dev/harmony/open-source/meta && git fetch origin && git worktree add --detach ~/code/gitkb-dev/harmony/.worktrees/try-157 origin/feat/meta-clone-cmds && cd ~/code/gitkb-dev/harmony/.worktrees/try-157 && cargo build --workspace && export META_BIN_DIR=$PWD/target/debug && ~/code/notes/projects/gitkb/meta-clone-cmds/sandbox.sh setup && ~/code/notes/projects/gitkb/meta-clone-cmds/run.sh

…rnings where Matt's run went red [[tasks/harmony-3037]]

- `meta git clone-missing` clones the projects the .meta.yaml files on disk
  list that aren't cloned and changes no repo that is (the old `update`).
  `meta git clone-prune` removes the repos no .meta.yaml lists that hold
  nothing unpushed (repo_holds, plus no repo inside them), and names each
  one it keeps with what it holds. `meta git clone-sync` does both. All
  three use the clone queue and update's discovery, take -r/--depth,
  --dry-run, --json, --include/--exclude/--tag, and refuse in a worktree set.
- A looped command that fails in every repo because the tool rejected one
  of meta's own options (`meta git pull --recursive`) ends with
  `tip: --recursive is an option of meta itself: it goes before the
  command, as in meta --recursive git pull`, read from the tool's error.
- In `meta git pull/status/...` a listed project that isn't cloned is a
  warning naming clone-missing, not a failure (an error with --strict);
  `meta exec` still fails there.
- `meta git update` counts its progress to the repos the .meta.yaml files
  list ([1/7] ... [7/7]), and says an unlisted repo short:
  `x isn't in .meta.yaml (nothing unpushed; meta git clone-prune removes it)`.
- README and skills list update, clone-missing, clone-prune and clone-sync.
@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

  • Run on-demand review

This review includes 10 billable files and costs up to $2.50.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 43 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 88 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Team
  • Run ID: d8c0eb90-4e68-4944-b314-2dd61ff24ff0
Commits

Reviewing files that changed from the base of the PR and between 1bff5b3 and 85eec86.

Files selected for processing: 10
  • README.md
  • docs/faq_troubleshooting.md
  • loop_lib/src/lib.rs
  • meta_git_cli/src/clone_missing.rs
  • meta_git_cli/src/clone_worker.rs
  • meta_git_cli/src/update.rs
  • meta_git_lib/src/clone_queue.rs
  • meta_project_cli/src/lib.rs
  • meta_project_cli/src/main.rs
  • tests/git.bats

Walkthrough

The Git plugin adds commands to clone missing projects, prune eligible unlisted repositories, and perform both steps. The change also updates missing-project guidance and adds wrapper-option placement tips for looped commands.

Changes

Git Clone Workflows

Layer / File(s) Summary
Repository discovery and selection
meta_git_lib/src/clone_queue.rs
CloneQueue tracks listed project paths and selections, reports cloned paths, and filters unlisted repositories that contain a listed project.
Clone, prune, and sync execution
meta_git_cli/src/clone_missing.rs, meta_git_cli/src/update.rs, meta_git_cli/src/clone.rs, meta_git_cli/src/clone_worker.rs
The new commands clone missing projects, prune eligible unlisted repositories, or run both operations. Pruning checks repository contents and structure before removal.
Update flow and command integration
meta_git_cli/src/update.rs, meta_git_cli/src/lib.rs, meta_git_cli/src/main.rs, meta_core/src/gitdir.rs, meta_project_cli/src/lib.rs
The update flow uses shared workspace and execution helpers. Command dispatch includes the new operations, and missing checkouts refer to clone-missing; strict mode can make missing-checkout warnings fatal.
Command guidance and integration tests
README.md, claude-plugin/skills/*, meta_cli/tests/*, tests/*
Documentation describes the commands and options. Tests cover cloning, pruning, sync, missing-project handling, and output.

Wrapper Option Tips

Layer / File(s) Summary
Option tip detection and wiring
loop_lib/src/lib.rs, meta_cli/src/main.rs, meta_cli/src/subprocess_plugins.rs, tests/git.bats
Looped commands can print a reordered invocation tip for selected wrapper options placed after the command. Meta passes wrapper option definitions to raw and plan command execution.

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant GitPlugin
  participant CloneQueue
  participant WorkspaceFS
  participant Leftover
  User->>GitPlugin: Run clone-sync
  GitPlugin->>CloneQueue: Discover configured projects and unlisted repositories
  CloneQueue->>WorkspaceFS: Resolve project paths
  GitPlugin->>WorkspaceFS: Clone missing projects
  GitPlugin->>Leftover: Classify unlisted repositories
  Leftover->>WorkspaceFS: Inspect removal conditions
  GitPlugin->>WorkspaceFS: Remove eligible repositories
Loading

Suggested reviewers: mateodelnorte

Merge Risk: Low · previous review 1bff5

Some misplaced options may fail without the new placement tip. This is a bounded guidance issue and does not prevent merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 76.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies the three new commands and the related tips and warnings. It is somewhat detailed but remains specific and relevant to the main changes.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 76.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 25 functions across 17 files. (3 skipped: 3 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit checks each repo's place,
Then clones the gaps at hopping pace.
Clean leftovers leave the burrow floor,
While guarded ones stay by the door.
Sync brings both steps to the same trail.

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Team
  • Run ID: 29207601-5d2d-4a1d-bc51-52f0fa8a3c9f
Commits

Reviewing files that changed from the base of the PR and between b10cd01 and 1bff5b3.

Files selected for processing: 20
  • README.md
  • claude-plugin/skills/meta-git/SKILL.md
  • claude-plugin/skills/meta-plugins/SKILL.md
  • loop_lib/src/lib.rs
  • meta_cli/src/main.rs
  • meta_cli/src/subprocess_plugins.rs
  • meta_cli/tests/checkout.rs
  • meta_cli/tests/docs.rs
  • meta_core/src/gitdir.rs
  • meta_git_cli/src/clone.rs
  • meta_git_cli/src/clone_missing.rs
  • meta_git_cli/src/clone_worker.rs
  • meta_git_cli/src/lib.rs
  • meta_git_cli/src/main.rs
  • meta_git_cli/src/update.rs
  • meta_git_lib/src/clone_queue.rs
  • meta_project_cli/src/lib.rs
  • tests/git.bats
  • tests/project_list.bats
  • tests/url_credentials.bats

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

@coderabbitai
coderabbitai Bot requested a review from mateodelnorte November 3, 2026 02:17

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Fix comments: Fix CodeRabbit comments on this PR

Comment thread loop_lib/src/lib.rs Resolved
- clone-prune keeps a leftover holding a bare repository too, and says
  "removed only in part" (exit 1) when a removal fails midway.
- --include/--exclude/--tag with a command's own -r is refused: meta
  chose the selection without the nested projects; -r goes to meta.
- The tip reads only the tool's own error, so `meta --sequential git
  status -s --no-such-option` gives none; it also reads git's
  `unrecognized argument: --json` and `--option=value`.
- --json names a failed clone and a refused folder by their paths.
- update's leftover warning names `meta -r git clone-prune` after -r;
  the remaining hints and the FAQ name clone-missing for cloning.
- Tests: an uncloned project during a real pull, the tip cases, the bare
  repo, the -r refusal, JSON paths.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant