docs: runnable partial-clone worked example#8
Merged
Conversation
examples/partial_clone_demo.exs — Mix.install of the published
package, blob:none partial clone of a public repo, one file read,
and a memory_report/1 comparison against an eager clone proving
exactly one blob crossed the wire (1 of 1,906 blobs; 358 KB of
5.7 MB compressed, measured against GitHub).
Also demos the FS.size/3 gate: {:error, :not_local} before the
read (no fetch triggered), O(1) from cache after.
README links it from the partial-clone section; .formatter.exs
now covers examples/.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VEo6srWr3aFwhtwaXDTCZZ
Print plumbing (thousands-separator regex, padded-column report) replaced with Map.take + IO.inspect; the eager-clone control group dropped — the blob_count: 0 -> 1 transition around the single read is the proof, and a free FS.ls afterward shows navigation doesn't move it. 67 lines -> 32, one network clone + one blob fetch. (FS.walk was considered for the file-count denominator but correctly refuses :lazy repositories; ls has no such guard since it reads one local tree.) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VEo6srWr3aFwhtwaXDTCZZ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Read one file from a git repo without downloading the repo — 32 lines, standalone, pure Elixir.
The script
Mix.installs the published package (no checkout needed), cloneselixir-ai-tools/just_bashunder ablob:nonefilter — protocol v2 partial clone: refs + commits + trees cross the wire, file contents don't — readsREADME.md, and letsRepository.memory_report/1account for every object fetched:Each line is one claim:
blob_count: 0after clone — the filter held; nothing was shipped speculatively.FS.size/3before the read returns{:error, :not_local}instead of fetching. The size probe is a gate: a caller (an agent loop, say) decides whether to pull a blob before paying for it.blob_count: 0 → 1aroundread_path/3— reading one file fetched exactly one blob. No readahead, no surprise pack.FS.lsafterwards doesn't move the count: trees are local, so navigating the repo is free after a filtered clone.No printing framework, no control-group second clone — the
0 → 1transition brackets the read, which is the whole proof. All state lives in the%Repository{}value the caller threads; there is no process, ETS table, or daemon behind it.A protocol note, and a follow-up. The example uses
filter: {:blob, :none}deliberately rather thanlazy: true. A bare lazy clone defers everything — but its on-demand fetch is awant <sha>with no filter, andgit upload-packanswers a commit want with the commit's entire reachable graph. So the firstread_pathon a bare-lazy repo hauls in the whole repository. The README quick-start currently pairslazy: truewithtorvalds/linux, which would do exactly that on first read; the fix is either correcting that example or makinglazy: trueimplyblob:nonewhen the server advertises filter support. Tracked as a follow-up, decided separately from this PR.Also here: the README links the example from its partial-clone section, and
.formatter.exsnow coversexamples/so the script stays format-gated in CI.🤖 Generated with Claude Code
https://claude.ai/code/session_01VEo6srWr3aFwhtwaXDTCZZ