Skip to content

fix(dataloader): read a relative cache root back absolute (#1280) - #1281

Draft
HugoXK wants to merge 3 commits into
mainfrom
agent/1280-cache-root-abs
Draft

HugoXK wants to merge 3 commits into
mainfrom
agent/1280-cache-root-abs

Conversation

@HugoXK

@HugoXK HugoXK commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #1280

What changed

Two halves of one thing: the dataset cache root is written by one process and read by another, so it must be neither relative nor resolved in two different places.

dataloader._cache_root() expanded ~ but never made the root absolute, so AGENTDESCENT_CACHE=rel-cache read back as rel-cache and cache_path() created it relative to whatever cwd the caller had — the half #402/#403 already closed for the run store (runstore._normalise). Both branches now normalise once: abspath(expanduser(...)) for AGENTDESCENT_CACHE, and abspath(expanduser(xdg))/agentdescent for XDG_CACHE_HOME. CACHE_ROOT and the no-variable path are byte-identical to before, and cache_path()'s signature, its makedirs, and the cache=False bypass contract in hf_rows / hf_rows_modelscope / fetch_bytes are untouched.

runstore.launch() is the half that makes the issue's own headline stop being true. It builds child_env from os.environ, and the scrub deliberately keeps AGENTDESCENT_*; the child then starts at cwd=rd.path. With only the dataloader half, the launcher resolved tree A and the detached child resolved tree B, so the cache still moved with every run directory. Only the launcher still knows the cwd the operator typed the value in, so a relative AGENTDESCENT_CACHE or XDG_CACHE_HOME is spelled absolute there — after the caller's env is merged (an explicitly passed relative value is normalised too) and before the Ticket marker block. An absolute value is forwarded untouched; the markers and PYTHONPATH are not involved.

The stale docstring in the issue is the third part of the same fix: hf_rows_modelscope promised responses under one fixed ~/.cache/agentdescent/modelscope/ while :421 writes through _raw_cache_path → cache_path → _cache_root() and honours both knobs. It now names both knobs and no longer claims a fixed path.

Not a goal: the default root, the fetch/cache keying, and any change to what is downloaded.

Verification at the tip

Tip SHA: 7fbcc3d — base 0a6e782f8f206eb1477d72f334e84c2ff0ba4b09, 3 commits, +210/−7 across 5 files (as the API reports it).

Ran:

  • red first at 0a6e782f with only tests/test_dataloader_cache_root_abs.py added: 4 failed, 1 passed in 0.91s — the failures are rel-cache/rel-xdg read back relative (including cache_path handing back rel-cache/gsm8k/x.jsonl from either cwd) and the stale ~/.cache/agentdescent/modelscope/ docstring; the pass is the unchanged-default row
  • launcher red at 62e8dd00 (the first commit alone) with only tests/test_runstore_cache_env.py added: 2 failed, 1 passed — both relative knobs reach the child as rel-cache / rel-xdg, and the absolute-value row passes
  • Product's probe_child_cache_root.py, which drives the real launch env/cwd construction (only the spawn stubbed) and then asks a real child for _cache_root():
    • at 62e8dd00: one_tree: false for both knobs, value_in_child_env still rel-cache / rel-xdg; launcher <launcher cwd>/rel-cache vs child <run dir>/rel-cache, and <launcher cwd>/rel-xdg/agentdescent vs <run dir>/rel-xdg/agentdescent
    • at 438aee6: one_tree: true for both knobs, value_in_child_env = <launcher cwd>/rel-cache and <launcher cwd>/rel-xdg, child root equal to launcher root, all_paths_inside_temp: true
  • the two new test files at the tip: 8 passed in 0.99s
  • dataloader family (test_dataloader.py, test_dataloader_cache_root.py, test_dataloader_cache_names.py, test_dataloader_cache_root_abs.py): 60 passed in 2.85s
  • runstore family (test_runstore_cli.py, test_runstore_tilde.py, test_runstore_cache_env.py): 58 passed in 23.65s
  • the #1273 knob rows: tests/test_adas_example.py tests/test_skill_evolution_example.py -k cache → 3 passed, 31 deselected in 1.76s
  • python -m tools.changelog_fragments check → 46 changelog fragment(s) OK; python -m tools.gen_api_docs --check → docs/api.md is up to date
  • CI on 438aee6242: 10 checks — build, otel-wire and test (3.9)–test (3.13) all success, deploy skipped, both report-only checks success; zero failing

The contract this keeps, stated plainly: the detached child inherits the launcher's resolved root, so the process that starts a run and the run itself name one tree.

The rule that survives is narrower and unchanged: a relative value is still resolved against the cwd of the process that reads it — the same contract #403 gave the run store — so anything that builds a child_env by hand, outside launch, should be given an absolute AGENTDESCENT_CACHE. This PR does not widen that; it stops launch from being one of those callers.

No UI surface: library path resolution only.

Not run: full pytest -q (markdown is not installed here for tests/test_docs_links.py); mkdocs build --strict (no docs page changed; mkdocs not installed). No network or model call in the new tests; the probe is a local file run, not part of the suite.

Draft on purpose: no flip without the Lead's word.

AGENTDESCENT_CACHE and XDG_CACHE_HOME were expanded but not made absolute,
so cache_path handed back (and created) a bare relative directory: the same
half-expansion #402 fixed for the run store, left in the dataset cache after
#1261. hf_rows_modelscope's docstring still promised one fixed
~/.cache/agentdescent/modelscope/ path, so documented and written roots
disagreed once the knob moved.

Refs #1280
@HugoXK HugoXK added area:bench Benchmarks, A/B runs and reports (bench/, reports/) bug Something isn't working labels Nov 25, 2026
`launch` scrubs the environment but keeps `AGENTDESCENT_*` and starts the
child at `cwd=rd.path`, so a relative `AGENTDESCENT_CACHE` or
`XDG_CACHE_HOME` named one tree in the process that launched the run and
another in the run itself: the cache moved with every run directory, which
is the bug #1280 is about. Only the launcher still knows the cwd the value
was typed in, so both knobs are spelled absolute there when they are
relative -- after the caller's `env` is merged, before the Ticket marker
handling. An absolute value is forwarded untouched and `PYTHONPATH` is not
involved. #402/#403 normalised the store the same way.

Verified with Product's `probe_child_cache_root.py`, which asks a real
child for `_cache_root()`: `one_tree: false` for both knobs at 62e8dd0,
`one_tree: true` at this tip with an absolute `value_in_child_env`.
The fragment said the dataset cache root is one spelled path "however a later
caller was launched", which is false outside `launch`: a caller that builds its
own environment by hand and reads a relative value from another cwd still
spells a different path to the same tree -- the `#403` contract the PR body
states narrowly. Release notes are read as promises, so the fragment now stops
at "a bare relative directory"; its last sentence already scopes the launch
claim.

Docs-only: one changelog fragment, no code or test change. Refs #1280.
@HugoXK

HugoXK commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

Pre-report — PR #1281, field changelog fragment: drop the claim that the root is one spelled path for every caller.

What changes. changelog.d/1280-cache-root-abs.md currently ends its first sentence with ..., so the dataset cache root is one spelled path however a later caller was launched. I am deleting that trailing clause and nothing else in the file: the sentence now stops at a bare relative directory. The reflow is the clause removal, not new text.

Why. That clause is false outside launch(). A caller that builds its own child_env by hand and reads a relative value from another cwd still spells a different path to the same tree — exactly the #403 contract the PR body states narrowly. Release notes are read as promises, so the fragment must not promise more than the code does. The fragment's final sentence already scopes the launch claim correctly, which is why this is a deletion rather than an added caveat.

Scope. One file, one commit: no code, no tests, PR body untouched (it does not contain that sentence). Docs-only delta on top of 438aee62424b4b8296a5acb8a9adf278e701479e.

@HugoXK

HugoXK commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

Pre-report — PR #1281, field body: restamp Tip SHA to the head after the changelog commit.

What changes. Only the Tip SHA: sentence in ## Verification at the tip. It currently reads Tip SHA: 438aee62424b4b8296a5acb8a9adf278e701479e — base \0a6e782`, 2 commits, `+211/−7` across 5 files (as the API reports it).It becomes the same sentence with7fbcc3d, 3 commits and \+210/−7` — the head as my own read of /pulls/1281 returns it in this turn, not as copied from a message.

Why. The body still names 438aee62; the changelog commit 7fbcc3d landed after it, so the tip line pointed one commit behind. The fragment fix added a commit and this restamps the line in the same turn.

What stays. Line CI on \438aee6`: 10 checks …` is left exactly as written: it is labelled by that sha and true of it. A head-CI claim would be unverified, so it is not added.

Scope. One PATCH to the body, one sentence. No code, no push, no flip, no labels, no issue comment.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:bench Benchmarks, A/B runs and reports (bench/, reports/) bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bench: a relative dataset cache root is read back relative, so the run's cache moves with the caller's cwd

1 participant