Skip to content

fix(runstore): expand a literal '~' in --store and $AGENTDESCENT_HOME (#402) - #403

Merged
Birfy merged 1 commit into
mainfrom
fix/402-tilde-store
Oct 18, 2026
Merged

Birfy merged 1 commit into
mainfrom
fix/402-tilde-store

Conversation

@Birfy

@Birfy Birfy commented Oct 18, 2026

Copy link
Copy Markdown
Collaborator

Closes #402

A literal ~ in --store or $AGENTDESCENT_HOME (what an MCP host config's args/env or a quoted --store '~/st' delivers) was only half expanded: RunDir expanded it (#400), so create wrote under $HOME, but list_runs / get's message / CLI status / MCP status used the raw base, looked in ./~/st, said "no runs", and left a stray ~ directory in the cwd. AGENTDESCENT_HOME=~/x was never expanded at all.

Change:

  • runstore.store_path(store) normalises the base once (expanduser + abspath); create, get, list_runs use it.
  • root() expands $AGENTDESCENT_HOME.
  • CLI status ("no runs under …") and MCP status's store report the expanded absolute path.
  • changelog.d/402-tilde-store.md.

Verification:

  • tests/test_runstore_tilde.py: 4 new tests, all fail on main (bc7395a) and pass here.
  • Real CLI from an empty cwd with HOME pointed at a temp dir: agentdescent --store '~/st' evolve spec.json --detach then agentdescent --store '~/st' status shows the run as done, no ./~ directory. On main the same status prints no runs under ~/st.

@Birfy
Birfy enabled auto-merge (squash) October 18, 2026 04:29
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T04:31:04.808837Z e9a7a58 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Birfy Birfy left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

LGTM (self-approval is blocked, so posting as a comment).

  • The 4 new tests in tests/test_runstore_tilde.py fail on main bc7395a and pass on this branch.
  • Full pytest on Python 3.13 exits 0.
  • Real CLI check from an empty cwd: agentdescent --store '~/st' evolve spec.json --detach then agentdescent --store '~/st' status shows the run done with no stray ./~ directory; on main the same status prints no runs under ~/st.

Squash auto-merge is armed; it will land once the CI matrix is green.

@Birfy Birfy left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Verdict: approve (posted as a comment because GitHub blocks self-approval). Reviewed at e9a7a58.

This closes the gap left by #400/#401 cleanly: the store base is normalised in exactly one place (runstore.store_path), and every consumer of store= already funnels through create / get / list_runs (CLI status/show/apply/cancel/resume, MCP Tools.*, serve_http's handler, require_resume_host_on_path), so there's no second raw-base path left behind. root() expanding $AGENTDESCENT_HOME also fixes doctor's run_store for free.

What I checked

  • tests/test_runstore_tilde.py: all 4 new tests fail on origin/main and pass on this branch.
  • Full pytest on 3.12 locally: exit 0.
  • Real CLI from an empty cwd with HOME pointed at a temp dir, using the stub skill_dir spec from tests/test_evolvespec._dir_spec:
    • agentdescent --store '~/st' evolve spec.json --detach lands in $HOME/st/<id>; agentdescent --store '~/st' status shows it done; show <id> works; no ./~ in the cwd.
    • AGENTDESCENT_HOME='~/adh' agentdescent evolve … --detach lands in $HOME/adh/runs/<id>; status, show and doctor (run_store: $HOME/adh/runs) all agree; again no stray ./~.
    • Tools(store='~/st').status() reports the absolute $HOME/st with the one run.
  • CI: docs build passed; the test matrix was still queued when I posted.

Design notes (all non-blocking)

  • A relative $AGENTDESCENT_HOME is now resolved against the cwd at call time and becomes absolute. That matches how a relative --store already behaves after #400, so it's consistent rather than a regression, just worth knowing.
  • store_path("") still falls back to root(), same as the old store or root(), so empty --store behaviour is unchanged.

Nits (optional)

  • test_mcp_status_and_cli_status_name_the_expanded_store could also assert not (cwd / "~").exists() after the CLI status, to pin the "no stray directory" part for the CLI path too (the first two tests cover it for create/list_runs).
  • docs/plugins.md:472 mentions $AGENTDESCENT_HOME/runs; a short note that ~ in host-config env/args is now expanded would help plugin users who hit #402 before, but the changelog entry already covers it.

Nice, small and well-scoped fix.

@Birfy
Birfy merged commit e75924d into main Oct 18, 2026
7 checks passed
@Birfy
Birfy deleted the fix/402-tilde-store branch October 18, 2026 04:45
@HugoXK HugoXK added area:runstore Run store, ledger, checkpoint, resume and replay bug Something isn't working labels Nov 18, 2026
HugoXK added a commit that referenced this pull request 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`.
HugoXK added a commit that referenced this pull request Nov 25, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:runstore Run store, ledger, checkpoint, resume and replay bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

runstore: a literal '~' in --store or $AGENTDESCENT_HOME is only half expanded (runs created, list says none)

2 participants