Skip to content

Tighten Studio instruction-file cleanup boundaries - #7097

Merged
danielhanchen merged 5 commits into
mainfrom
agent/unlink-instruction-symlinks
Jul 13, 2026
Merged

danielhanchen merged 5 commits into
mainfrom
agent/unlink-instruction-symlinks

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Jul 13, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #7096 after a full before/after installer audit.

What changed

  • Treat symlinks named AGENTS.md or CLAUDE.md as cleanup candidates in the Bash installer.
  • Limit recursive frontend/OXC cleanup to generated node_modules trees instead of scanning a developer's entire local source tree.
  • Add a regression test that executes the real Bash helper and verifies the link is removed while its external target is preserved.

Why

The original Bash helper used find -type f, which excludes symbolic links. The audit also found that scanning all of frontend and the OXC source tree could delete an intentionally authored, untracked instruction file from a --local developer checkout. The actual reproduced dependency artifact is under node_modules, while the repository-owned i18n guide was already renamed to README.md in #7096.

Impact

No hardware detection, GPU selection, build flags, frontend application code, runtime paths, or CI workflows change. Cleanup still removes exact AGENTS.md/CLAUDE.md dependency artifacts, does not follow directory links or junctions, preserves external link targets, and no longer touches unrelated source-tree files.

Validation

  • Real sandboxed install.sh --local before/after/follow-up runs completed successfully with redirected HOME, caches, Studio home, no Torch, no autostart, and a user-owned linked llama tree
  • Pre-PR install retained 2 reproduced files; post-PR/follow-up dependency trees retained 0
  • Follow-up install preserved 2 deliberately developer-owned source files and 2 external linked llama files
  • 684 changed-path tests passed across Python 3.9–3.14; 6 Windows-junction skips on Linux
  • 1,059 full installer tests passed on Python 3.13 and again on 3.14; 3 skips per run
  • 32 GNU find + 32 BusyBox find + 23 PowerShell cleanup matrix checks passed
  • 324 shell hardware/routing assertions passed with no PR regression
  • Frontend typecheck, i18n parity, build, and exact pre/post bundle hash comparison passed
  • Before/after wheels built; the old wheel contains the i18n AGENTS.md, while the new wheel contains README.md and no instruction-file entries
  • An isolated in-place upgrade from the pre-Studio: remove AGENTS.md and CLAUDE.md from install artifacts #7096 wheel removed the stale AGENTS.md, installed README.md, and left 0 instruction files
  • Bash/PowerShell parsers and repository pre-commit hooks passed

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request updates the cleanup logic in studio/setup.sh to find and remove symlinks (-type l) as well as regular files for AGENTS.md and CLAUDE.md, and adds a corresponding test. The review feedback suggests improving the test's robustness by checking for bash availability on the host system and using Path.lexists() instead of Path.exists() to correctly verify symlink deletion.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +2302 to +2308
subprocess.run(
["bash", "-c", function + '\n_remove_agent_instruction_files "$1"', "bash", str(managed)],
check = True,
)

assert not instruction.exists()
assert external.read_text(encoding = "utf-8") == "external"

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.

medium

Robustness and Correctness Improvements

  1. Bash Availability Check: On Windows environments where developer mode is enabled (allowing symlink creation to succeed), bash might still be missing from the PATH. Skip tests that invoke platform-specific shells (like bash) via subprocesses when those shells are unavailable on the host system.
  2. Symlink Deletion Assertion: Using Path.lexists() instead of Path.exists() is more robust for verifying symlink deletion. Path.exists() returns False if the symlink is broken (i.e., its target is missing or unreadable), which could lead to false positives. Path.lexists() checks for the existence of the symlink itself without following it.
    import shutil
    if not shutil.which("bash"):
        pytest.skip("bash is not available on this system")

    subprocess.run(
        ["bash", "-c", function + '\n_remove_agent_instruction_files "$1"', "bash", str(managed)],
        check = True,
    )

    assert not instruction.lexists()
    assert external.read_text(encoding = "utf-8") == "external"
References
  1. Skip tests that invoke platform-specific shells (like 'sh' or 'pwsh') via subprocesses when those shells are unavailable on the host system (e.g., using pytest.mark.skipif), or structure the test suite to run the native shell of each platform.

@danielhanchen danielhanchen changed the title Handle linked instruction files in Studio cleanup Tighten Studio instruction-file cleanup boundaries Jul 13, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: cda68e6ccf

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen marked this pull request as ready for review July 13, 2026 08:45
@danielhanchen
danielhanchen merged commit c570180 into main Jul 13, 2026
46 checks passed
@danielhanchen
danielhanchen deleted the agent/unlink-instruction-symlinks branch July 13, 2026 08:46
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