Skip to content

feat(refs): a files-only fetch, so a corpus source certifies only the tree it reads - #281

Merged
github-actions[bot] merged 1 commit into
mainfrom
feat/files-only-fetch
Oct 23, 2026
Merged

github-actions[bot] merged 1 commit into
mainfrom
feat/files-only-fetch

Conversation

@aitrawog

@aitrawog aitrawog commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Agent: charly-spec279

Summary

spec/refs.DownloadRepo initialises every submodule a freshly fetched repo
declares and fails the whole fetch when one cannot be fetched — populateSubmodules,
deliberately, because a --repo cache is a whole project a user drives with nothing
but the charly binary. That contract is right for --repo and fatal for a corpus
SOURCE
fetch, which reads the fetched repo's charly.yml and its .agents/ trees
and no submodule at all.

Measured COLD (fresh CHARLY_REPO_CACHE, the real charly marketplace generate,
opencharly/opencharly:v2026.296.2037, 412 declared gitlinks):

start 23:12:40Z
charly: resolving github.com/opencharly/pod-charly-hooks:v2026.290.1114 (0 resolved, 1 queued)
Downloading github.com/opencharly/pod-charly-hooks:v2026.290.1114...
charly: resolving github.com/opencharly/opencharly:v2026.296.2037 (1 resolved, 0 queued)
Downloading github.com/opencharly/opencharly:v2026.296.2037...
charly marketplace: collect entities: resolve @github.com/opencharly/opencharly:v2026.296.2037: downloading github.com/opencharly/opencharly:v2026.296.2037: populating submodules in /home/atrawog/.cache/charly/prefix279c/github.com/opencharly/[email protected]: exit status 128
fatal: Unable to create '/home/atrawog/.cache/charly/prefix279c/github.com/opencharly/[email protected]/.git/modules/charly/shallow.lock': File exists.

Another git process seems to be running in this repository, or the lock file may be stale
fatal: Fetched in submodule path 'charly', but it did not contain 52145aff0beaf0594105b13ca0a5306200be9184. Direct fetching of that commit failed.
generate rc=1
end 23:18:55Z

So @github.com/opencharly/opencharly:<tag> could not be a corpus source at all —
that is why the pin was withdrawn from opencharly/marketplace#566 — and the three
general-guidance skills the umbrella authors (agents, cutover-policy,
root-cause-analyzer; umbrella AGENTS.md Part II #5) had no reachable home. The same
population had already been measured as a pure cost on the same walk in spec#267
(431 gitlinks, ~3 min cold, 272 MB transient, none of it read).

The fix — the issue's candidate 1, as a sibling fetch rather than an options type

// whole project: unchanged signature, unchanged behaviour (submodules populated)
func DownloadRepo(repoPath, version string) (string, error)

// corpus/docs SOURCE: the repo's own tree, and nothing else
func DownloadRepoFiles(repoPath, version string) (string, error)

Why this candidate, and why spelled this way. The deciding criterion is that the
fetch should certify exactly what the reader needs and no more:

  • candywalk.RemoteResolver is func(repoPath, version string) (string, error), so a
    sibling with that exact signature threads through the existing seam with no sdk
    change at all
    — candywalk.CollectEntitiesRemote(roots, refs.DownloadRepoFiles).
    An options type would have needed either a wrapper closure at every call site or a
    seam change in the SDK.
  • DownloadRepo keeps its signature AND its submodule contract, so no --repo caller
    changes a line. Nothing is relaxed globally: the mode is a per-fetch decision.
  • Candidate 2 (a per-ref marker in the pin contract) was rejected: it puts a reader's
    requirement into the REF, where every consumer of that ref inherits it. A ref names a
    repo at a version; what the fetch must certify is the CALLER's business.

Two mechanisms make it a mode rather than a flag:

  1. Its own cache key — <cache>/.files/<repo>@<version>, one directory level below
    the whole-project <cache>/<repo>@<version>. Content decides the key: a tree export
    is not a usable --repo cache and a populated export is a superset, so sharing one
    key would make each caller re-download the other's entry on every run.
  2. Its own freshness predicate — repoCacheFreshMode: a whole-project export must
    carry its submodule content (unchanged), while a files-only export is complete the
    moment its tree is there, because that is the entire content its reader asked for.

The mode directory rather than a .files suffix on the basename was itself decided
by measurement: plugin-marketplace's resolve.go ranks two sources that publish one
identity by the CalVer it reads at the END of Entity.SourceRoot
(@v<YYYY>.<DDD>.<HHMM>$). A suffix made every fetched source unparseable and an
unparseable rank silently hands the identity to whichever twin still parsed. The
basename therefore stays <repo>@<version>, and the mode lives one level up.

The three arms

1. COLD + the umbrella ref → rc=0, and the tree is what got certified.

$ export CHARLY_REPO_CACHE=$(mktemp -d)           # COLD: no entry for the ref at all
$ charly marketplace generate --root . --out ./out
charly: resolving github.com/opencharly/pod-charly-hooks:v2026.290.1114 (0 resolved, 2 queued)
Downloading github.com/opencharly/pod-charly-hooks:v2026.290.1114 (files only)...
charly: resolving github.com/opencharly/layer-charly-internals:v2026.296.1907 (1 resolved, 1 queued)
Downloading github.com/opencharly/layer-charly-internals:v2026.296.1907 (files only)...
charly: resolving github.com/opencharly/opencharly:v2026.296.2037 (2 resolved, 0 queued)
Downloading github.com/opencharly/opencharly:v2026.296.2037 (files only)...
generate rc=0
end 23:28:42Z                                        # 12s end-to-end, cold, all three refs

$ ls out/internals/skills/
agents  cutover-policy  egress  git-workflow  go  go-quality  marketplace  plugin  repo-setup  root-cause-analyzer  vm-deploy-target

2. The --repo caller still populates (refs.DownloadRepo, unchanged):

$ GOWORK=off go test ./refs/ -run 'TestDownloadRepo_PopulatesSubmodules' -v
=== RUN   TestDownloadRepo_PopulatesSubmodules
Downloading local/super2:main...
--- PASS: TestDownloadRepo_PopulatesSubmodules (0.63s)

  # the assertion that matters, from the test:
  #   whole-project export must publish to <repo>@<version>          → dir = .../local/super2@main
  #   the declared submodule MUST be populated                       → sub/ holds sub.txt
  #   (populateSubmodules still runs, still fails loud — arm 3)

3. A genuinely unreachable declared submodule still fails the whole-project fetch
LOUDLY
— the fetch has not become universally lenient:

$ GOWORK=off go test ./refs/ -run 'TestUnreachableSubmodule_ProjectFailsLoud_FilesSucceeds' -v
=== RUN   TestUnreachableSubmodule_ProjectFailsLoud_FilesSucceeds
Downloading local/broken:main...
Downloading local/broken:main (files only)...
--- PASS: TestUnreachableSubmodule_ProjectFailsLoud_FilesSucceeds (0.48s)

  # the SAME repo, whose declared submodule is a dead URL:
  #   refs.DownloadRepo      → error containing "populating submodules in …"  (a genuinely
  #                            unreachable submodule still fails the whole-project fetch)
  #   refs.DownloadRepoFiles → rc=0, tree present  (it reads no submodule)

$ GOWORK=off go test ./refs/ -run 'TestDownloadRepoFiles|TestRepoCacheFreshMode' -v
=== RUN   TestDownloadRepoFiles_SkipsDeclaredSubmodules
--- PASS ...   # files-only export of a submodule-bearing repo: succeeds, sub/ empty, its own cache entry
=== RUN   TestDownloadRepoFiles_ReusesFilesCache
--- PASS ...   # a tree export is COMPLETE for its own reader: no re-clone on an unchanged ref
=== RUN   TestRepoCacheFreshMode_FilesAcceptsTreeExport
--- PASS ...   # fresh for the files-only reader, STALE for the whole-project one; a moved commit is stale for both

How tested

The change-class gate for this repo (.github/workflows/ci.yml: build, test, gofmt,
golangci-lint), run on the committed tree, plus the changed path executed live against
real remotes:

$ GOWORK=off go build ./...        → rc=0
$ GOWORK=off go vet ./...          → rc=0
$ gofmt -l .                       → (no output)
$ GOWORK=off go test ./...         → 24 packages ok, 0 FAIL
$ go install github.com/golangci/golangci-lint/v2/cmd/[email protected]   # GOTOOLCHAIN=go1.26.0
$ golangci-lint --version
golangci-lint has version 2.13.2 built with go1.26.0 from (unknown, modified: ?, mod sum: "h1:bCyq3E4vo9qwzifjpzJqYndEt7Ncva80qkk8G2B4TXU=") on (unknown)
$ golangci-lint run ./...
0 issues.
  • golangci-lint was installed the CI way — go install …@v2.13.2 under
    GOTOOLCHAIN=go1.26.0, the toolchain go.mod names (go-version-file: go.mod) — not
    a host-built binary: a v2.13.2 linter built with the host's go1.27.3 cannot decode this
    toolchain's export data (opencharly/sdk#466), and a host-toolchain red would be an
    environment finding, not this diff's. Under the module's own toolchain: 0 issues.
  • The new tests use local file:// remotes (no network) and fail without the change:
    DownloadRepoFiles does not exist before it, and TestRepoCacheFreshMode_… asserts a
    tree export is fresh for the files-only reader and STALE for the whole-project one —
    the pre-change predicate has no such distinction.
  • One full go test ./... run reported TestGenReproducible failing with
    write /tmp/…: disk quota exceeded. Re-run with TMPDIR on the root filesystem it
    passes (ok github.com/opencharly/spec/spec), so the failure is this host's tmpfs
    quota, not the tree.

Rulebook compliance

Rule How it is honoured
R1 The failure was reproduced COLD before any fix, the RCA is in the issue, and every arm is measured rather than argued. The two sibling findings are filed (below), not waved through.
R2 One fetch implementation (downloadRepoFromMode), one clone (gitCloneMode), one population branch (populateByMode), one freshness predicate (repoCacheFreshMode). No second copy of any of them, and no test-only wrapper left behind.
R3 No retry, sleep, timeout or leniency added. The fix removes a need; it does not paper over a failure — arm 3 proves the loud failure is intact.
R4 Code before prose: the capability (a files-only fetch) exists in the product, and the consumer leg is a one-line seam swap.
R5 Additive only; nothing renamed or retired, so there is no stale reference to sweep.
R6 Session worktree off fresh origin/main; one commit; no force-push, no direct push to main.
R7 The changed path ran live against real remotes (the cold arms above) and the tests fail without it.
R9 No binary ships from this repo; the consumer rebuild is the marketplace's own pinned toolchain.
R10 This is a contract-module (library) change with no disposable bed: the gate is this repo's CI plus the live arms, run on the committed tree.

Change classification

Additive library change in the contract module: one new exported fetch
(DownloadRepoFiles), two new internal cache-location helpers (repoFilesCachePath and
the mode dispatcher repoCachePathFor) plus the filesCacheDir constant, one mode
parameter threaded through the existing fetch/clone/freshness path, and five tests in
refs/git_files_test.go (the four remote-backed arms plus the mode-relative freshness
predicate). No schema change, no wire change, no migration, no behavioural change for any
existing caller.

Filed issues

Attribution

This session's delivered system message reads, verbatim: You are a coding agent powered by the deepseek-v4.1-flash model. — harness DeepSeek Harness, model
deepseek-v4.1-flash, the pair the footer names; cited together with
opencharly/opencharly#538, the open record of this runtime being real and running
while the validator's model allowlist rejected it.

Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)

… tree it reads

spec/refs.DownloadRepo populates EVERY submodule a fetched repo declares and fails
the whole fetch when one is unreachable (populateSubmodules, deliberate). That is
right for a `--repo` cache — a whole project a user drives with the charly binary —
and fatal for a corpus SOURCE fetch: `charly marketplace generate` reads a manifest
and a .agents/ tree and no submodule at all, yet inherited the population. Measured
in CI on opencharly/marketplace#566, pinning opencharly/opencharly (412 declared
gitlinks): charly-registry needs credentials the runner lacks and pod-osm-tools
fails on `could not set core.worktree`, and either one fails the entire corpus walk.
The 431-gitlink population was already measured as a pure cost in spec#267.

DownloadRepoFiles is the files-only fetch: same signature as candywalk's
RemoteResolver, so the corpus generator passes it as the existing seam with no SDK
change, while DownloadRepo keeps its signature and its submodule contract. It is a
MODE, not a global opt-out: a per-fetch decision with its own cache entry
(<repo>@<version>.files, because content decides the key), and its own freshness
predicate — a tree export is complete without submodule content, a whole-project
export never is.

Tests (local file:// remotes, no network) prove the three arms the issue asks for:
files-only fetch of a submodule-bearing repo succeeds and populates nothing; the
whole-project fetch of the SAME repo still populates; a genuinely unreachable
submodule still fails the whole-project fetch loud while the files-only fetch of
that repo succeeds; and a tree export is fresh for the files-only reader and stale
for the whole-project one.

Closes #279

Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)
@github-actions

Copy link
Copy Markdown

Review — PASS

I re-derived every claim in the body against the six provided diffs and the single commit. No comments exist on this PR, so there is no sign-off to evaluate and no stale claim to dismiss; the change is judged on its own evidence.

What the diff actually does

  • refs/cache.go — adds filesCacheDir (.files), repoFilesCachePath (<cache>/.files/<repo>@<version>), and repoCachePathFor (mode → path). The basename stays <repo>@<version>, which is exactly the shape the body says plugin-marketplace's resolve.go parses; the mode lives one directory up. The doc changes on RepoCachePath/IsRepoCached correctly scope them to the whole-project entry.
  • refs/git.go — introduces the unexported fetchMode (fetchProject/fetchFiles), gitCloneMode (with populateByMode gating populateSubmodules), downloadRepoWithOverride (shared RDD-override + fetch body), downloadRepoFromMode, and repoCacheFreshMode. GitClone and DownloadRepo keep their signatures and their submodule-populating behaviour; the files-only path skips population and uses its own cache key and freshness predicate. The mode-relative freshness is correct: a whole-project export still requires populated submodules; a files-only export is complete on tree + matching provenance, and the two never share a path, so one mode's predicate is never applied to the other's export.
  • refs/git_files_test.go — five new tests using local file:// remotes, covering arm 1 (files-only skips declared submodules, publishes under .files/, basename preserved, project entry untouched), arm 2 (whole-project still populates and holds sub/sub.txt), arm 3 (unreachable submodule fails the project fetch with populating submodules in … while the files-only fetch of the same repo succeeds), cache reuse, and the mode-relative freshness predicate including a moved-commit staleness check. These genuinely fail without the change (fetchFiles/downloadRepoFromMode do not exist, and the old predicate has no mode split).
  • refs/cache_test.go, refs/git_fresh_test.go, refs/git_test.go — mechanical renames to repoCacheFreshMode(..., fetchProject) and downloadRepoFromMode(..., fetchProject); behaviour-preserving and consistent with the old assertions.

Correctness and scope

  • No behavioural change for existing callers: DownloadRepo → downloadRepoWithOverride(..., fetchProject) → identical clone/populate/freshness path; GitClone → gitCloneMode(..., fetchProject) → identical.
  • The failure path is intact: populateSubmodules still fails loud for whole-project fetches, and the new test proves the contrast on the same repo.
  • Cache isolation is sound: the .download temp path and lock derive from the mode-specific cachePath, so the two modes cannot publish over each other, and the atomic-rename/provenance contract is preserved.
  • No secrets, no new dependencies, no injection surface. The protocol.file.allow=always setting is confined to the test process via t.Setenv, which is appropriate for local file:// submodule remotes.

Minor, non-blocking body inaccuracies

  • "Change classification" says "four tests"; git_files_test.go contains five test functions (the four remote-backed ones plus TestRepoCacheFreshMode_FilesAcceptsTreeExport).
  • It says "one new internal cache-location helper"; the diff adds two (repoFilesCachePath and the dispatcher repoCachePathFor) plus the filesCacheDir const.

Neither affects the substance: every arm the body claims is reproduced by the tests, the console messages (Downloading … (files only)...) match the code, and the file count (6) and commit count (1) match the provided state. The out-of-repo consumer swap and the two filed sibling issues are honestly scoped as follow-ups rather than claimed as done here.

Comments

There are zero comment threads; nothing to disposition, and no maintainer sign-off is present, so the change stands on the evidence above — which it does.

Verdict: PASS


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) October 23, 2026 23:31
@github-actions
github-actions Bot merged commit 317df91 into main Oct 23, 2026
4 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Oct 23, 2026
github-actions Bot pushed a commit to opencharly/marketplace that referenced this pull request Oct 24, 2026
The umbrella's three general-guidance skills (agents, cutover-policy,
root-cause-analyzer) have no code, plugin or config behind them, so their home is
the one repo every consumer shares (opencharly/opencharly#600, AGENTS.md Part II
#5). This is the pin #566 withdrew: a repo declaring 412
submodules could not be a corpus source at all while the walk's fetch populated
every one of them and failed the whole fetch when one could not be fetched.

Producer-first: opencharly/spec#281 landed the files-only fetch
(refs.DownloadRepoFiles, tag v0.2026296.2332), opencharly/plugin-marketplace#49
made the corpus walk use it (tag candy/plugin-marketplace/v0.2026296.2345), and
this PR takes both plus the pin.

The corpus delta is ONE file — internals/skills/agents/references/
hooks-and-lifecycle.md — because the three bodies are byte-identical in both
sources; the agents REFERENCE file is the only thing that differs, and it now
matches the umbrella's, not [email protected]'s copy. 361
SKILL.md, 496 artifacts, no skill gained or lost. The carrier keeps publishing
git-workflow and repo-setup, so its pin stays: its drain is its own PR.

Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)

Co-authored-by: Andreas Trawoeger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants