Skip to content

test(host-cli): dependency snapshot for ~/.claude/ path contract (closes #864) - #1183

Closed
bassilkhilo-ag2 wants to merge 1 commit into
sonichi:mainfrom
bassilkhilo-ag2:test/host-cli-dependency-snapshot-864
Closed

bassilkhilo-ag2 wants to merge 1 commit into
sonichi:mainfrom
bassilkhilo-ag2:test/host-cli-dependency-snapshot-864

Conversation

@bassilkhilo-ag2

Copy link
Copy Markdown
Collaborator

Problem

Issue #864 tracks Mini's host-CLI discipline 3/3: a snapshot test that catches Anthropic-side ~/.claude/ convention drift early (e.g. if Claude Code reorganizes projects/<hash>/memory/ before users do).

Prior disciplines landed: #860 added claudeHomePath() helper (Python + TS). This PR adds the test that exercises it.

Solution

tests/host-cli-dependency-snapshot.test.py — two test layers:

A. Helper correctness (always runs in CI):

  • claude_home_path() defaults to ~/.claude/
  • $CLAUDE_HOME env override is respected
  • Subpath joining produces expected ~/.claude/channels/discord/access.json style paths

B. Installed-path smoke check (skips if ~/.claude/ absent):

  • skills/ dir exists on installed hosts
  • CLAUDE_HOME write-contract: redirecting to a temp dir lets callers write and read back correctly (tests + alt-host installs)

Layer B gracefully skips in CI (no real install). Channel dirs log an INFO note if absent (bridge may not be configured) without failing.

Test output

$ python3 tests/host-cli-dependency-snapshot.test.py
  INFO B1: /Users/…/.claude/channels/telegram not found (bridge may not be configured)
PASS: host-cli-dependency-snapshot — 3 helper + 2 contract tests.

Passes in CI (no ~/.claude/ → B1 skips, all others pass).

🤖 Generated with Claude Code

 sonichi#864)

Add tests/host-cli-dependency-snapshot.test.py — Mini's host-CLI discipline
3/3 (see sonichi#857, sonichi#858, sonichi#860). Two layers:

A. Helper correctness (always runs in CI):
   - claude_home_path() defaults to ~/.claude/
   - $CLAUDE_HOME env override respected
   - subpath joining produces expected paths

B. Installed-path smoke check (skips if ~/.claude/ absent):
   - Key dirs exist on installed hosts (skills/, channel dirs)
   - Write contract: CLAUDE_HOME override lets callers redirect writes to
     a temp dir for tests + alt-host installs

Catches Anthropic-side convention drift (e.g. Claude Code moving projects/
<hash>/memory/ to a new path) before users hit it. Safe to run in CI —
existence checks gate on ~/.claude/ being present.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@VasiliyRad VasiliyRad left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Clean. Single file, no unrelated changes. Tests guard a real contract: A1-A3 verify claude_home_path() default/override/subpath behaviour; B2 (write-contract) is the most valuable — proves $CLAUDE_HOME redirect works end-to-end for tests and alt-host installs. B1 gracefully skips in CI. One minor note: the importlib.reload() calls are unnecessary since CLAUDE_HOME is read at call time inside the function, not at module load — but harmless. Good addition for #864.

@VasiliyRad VasiliyRad left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Solid two-layer snapshot. Layer A is pure helper correctness — claude_home_path() defaults + CLAUDE_HOME env override + importlib.reload(up) for env-clear hygiene. Layer B is the installed-path smoke that gracefully skips when ~/.claude/ is absent (CI-friendly). Catches Anthropic-side convention drift on the user-machine path early without forcing a CI dep on the real install. 1-file test, no bundled changes.

LGTM 👍

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