Skip to content

fix: macOS symlink compatibility + rename config to ~/.llm_config.sh#1

Open
JewelRoam wants to merge 5 commits into
lixinqi:mainfrom
JewelRoam:main
Open

fix: macOS symlink compatibility + rename config to ~/.llm_config.sh#1
JewelRoam wants to merge 5 commits into
lixinqi:mainfrom
JewelRoam:main

Conversation

@JewelRoam

@JewelRoam JewelRoam commented Apr 3, 2026

Copy link
Copy Markdown

仓库里接口是 OpenAI 格式,并非Anthropic Messages API,叫 .anthropic.sh 有误导;另外加了个 realpath 修复。

Summary

  • fix(make_tensor): Normalize both sides of os.path.relpath in symlink mode to fix macOS /var/private/var path resolution
  • rename: ~/.anthropic.sh~/.llm_config.sh across all files

Problem

Symlink bug on macOS

make_tensor(..., symlink=True) computes relative symlink paths with mismatched resolution:

# Before: source is resolved, destination is NOT
rel_src = os.path.relpath(
    str(path.resolve()),        # → /private/var/...
    os.path.dirname(file_path), # → /var/...  ← mismatch!
)

On macOS, /var is a symlink to /private/var. The prefix mismatch causes os.path.relpath to produce incorrect relative paths, resulting in FileNotFoundError: /private/private/var/... when downstream code calls os.path.realpath() to follow the symlink chain.

Config file naming

The LLM config variables (LLM_API_KEY, LLM_BASE_URL, LLM_MODEL) are provider-agnostic and use OpenAI-compatible API format. Naming the config file ~/.anthropic.sh is misleading. Renamed to ~/.llm_config.sh to accurately reflect its purpose.

Fix

# After: both sides consistently resolved
rel_src = os.path.relpath(
    os.path.realpath(str(opt_file_content_or_path)),
    os.path.realpath(os.path.dirname(file_path)),
)

Test

  • All make_tensor self-tests pass (including symlink mode)
  • All slice_view self-tests pass (depends on make_tensor symlink mode)
  • Verified on macOS 15 (Darwin 25.4.0) — _copy_back_to_storage_view in st_moe_forward now resolves paths correctly

JewelRoam and others added 3 commits April 3, 2026 18:33
…ibility

On macOS, Path.resolve() returns /private/var/... while raw tmpdir paths
use /var/..., causing os.path.relpath to compute broken relative symlinks.
Apply os.path.realpath to both source and destination before computing
the relative path.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@JewelRoam JewelRoam changed the title Fix relative symlink computation for macOS compatibility fix: macOS symlink compatibility + rename config to ~/.LLM_config.sh Apr 3, 2026
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@JewelRoam JewelRoam changed the title fix: macOS symlink compatibility + rename config to ~/.LLM_config.sh fix: macOS symlink compatibility + rename config to ~/.llm_config.sh Apr 3, 2026
# Conflicts:
#	demo/auto-encoder/claude.py
#	demo/auto-encoder/loop_run.py
YqGe585 added a commit to YqGe585/Experience that referenced this pull request Apr 29, 2026
…d-accum progress

- TODO lixinqi#1: marked completed with commit reference and implementation summary
- TODO lixinqi#2 forward first item: added implementation details, verification
  results (mean loss -22.4%, relevance +2.27pp on deep-mask samples),
  and notes on the three accompanying bug fixes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
YqGe585 added a commit to YqGe585/Experience that referenced this pull request Apr 29, 2026
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
YqGe585 added a commit to YqGe585/Experience that referenced this pull request Apr 29, 2026
Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
YqGe585 added a commit to YqGe585/Experience that referenced this pull request May 7, 2026
- Add prepare_dataset_index.py: one-shot script to build a reproducible
  file-level 80/20 train/eval split with three mask strategies (short 1-3
  lines, long 4-8 lines, structural via AST function-body detection).
  Generates dataset_index/ with 332 train and 82 eval samples across 65
  source files; train/eval file sets are fully disjoint.

- Update prepare_worktrees.py: add split="train"|"eval" and
  dataset_index_dir params. When split is given, samples are loaded from
  the pre-generated index (seeded random.sample) instead of being masked
  at runtime. Legacy split=None path is unchanged.

- Update test_harness.py: add --split and --dataset-index-dir CLI args;
  add _compute_extra_metrics() reporting AST pass rate, Exact Match rate,
  and per-mask-type stratified loss after each evaluation run.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
YqGe585 added a commit to YqGe585/Experience that referenced this pull request May 7, 2026
Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
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.

1 participant