Skip to content

[Bug]: the destructive-home test guard only recognises single-line rmSync(getConfigDir()) #4705

Closed

Description

@lidge-jun

Client or integration

Other

Area

Other

Summary

tests/ci-workflows/test-home-guard.test.ts exists because a test once deleted the real OpenCodex home. The source scan it performs recognises only same-line forms — rmSync(getConfigDir()) and const x = getConfigDir().

Multiline calls, let aliases, helper wrappers, fs.rmSync(...), and the sibling resolvers getConfigPath() and usageLogPath() all pass it. A future test could reintroduce the exact incident while CI stays green.

The specific quota test that caused the original incident is correctly fixed (tests/usage/quota-reset-seen-store.test.ts:39-46,111-119 creates and pins a temporary home and deletes only that), and no other committed test currently deletes the real home. This is about the guard, not a live defect.

Reproduction

  1. Read the source scan in tests/ci-workflows/test-home-guard.test.ts:552.
  2. Write a test that resolves the home through a let alias or a helper wrapper and deletes it, or that splits the call across lines.
  3. The guard does not flag it.

Suggested fix: use an AST scan instead of line matching, or require destructive tests to delete only paths handed out by an ownership-tracking fixture, with adversarial false-negative cases in the guard's own tests.

Version

2.56.0 (e4a8539)

Operating system

macOS 15.5

Logs or error output

(static analysis; no runtime output)

Checks

  • I searched existing issues and documentation.
  • I removed secrets, tokens, account details, request credentials, and personal data.

Activity

  1. added
    bug
    on Sep 15, 2026
  2. lidge-jun commented on Sep 15, 2026

    @lidge-jun
    OwnerAuthor

    리뷰 · 우선순위 65 / 80

    이 이슈는 파괴적 home 삭제를 막는 테스트 가드가 한 줄 패턴만 본다는 한계 보고다. tip의 tests/ci-workflows/test-home-guard.test.ts 약 552행대는 rmSync|rmdirSync|unlinkSync|...가 같은 줄에서 getConfigDir()를 받거나, const x = getConfigDir()로 묶인 이름만 추적한다. let 별칭, 헬퍼 래퍼, 여러 줄 호출, fs.rmSync, 형제 getConfigPath()/usageLogPath()는 통과한다. 주석이 말하는 2026-09-15 실홈 삭제 사고의 재발을, 형태만 바꾸면 CI가 못 잡을 수 있다.

    좋은 소식은 당시 원인 테스트(tests/usage/quota-reset-seen-store.test.ts)는 임시 home을 핀하고 그것만 지운다. 지금 tip에 실홈을 지우는 커밋된 테스트는 없다. 이슈도 ‘가드의 구멍이지 현재 라이브 결함은 아니다’라고 정확히 적었다. #4681 home guard invariant와 맞닿은 후속이다.

    고치려면 줄 정규식 대신 AST 스캔을 쓰거나, 파괴 테스트가 ownership-tracking fixture가 준 경로만 지우게 강제하고, 가드 자체에 의도적 거짓음성 케이스를 넣어야 한다.

    라인 tests/ci-workflows/test-home-guard.test.ts ~552 - same-line/const 패턴만 탐지.
    경로 getConfigPath/usageLogPath - 가드가 형제 resolver를 보지 않음.
    경로 tests/usage/quota-reset-seen-store.test.ts - 원사고 테스트는 이미 올바르게 핀됨.
    경로 가드 테스트 - adversarial false-negative fixture가 약함.

    메인테이너의 판단이 필요한 지점

    • AST 스캔 vs fixture-only 삭제 계약 중 무엇으로 강화할지.
    • fs.rmSync·다줄 호출을 얼마나 깊게 볼지.
    • 형제 path resolver까지 같은 가드에 넣을지.

    너의 추천
    받아라. 우선 다줄/let/helper 거짓음성 픽스처를 가드 테스트에 넣고, 탐지기를 그 픽스처가 빨개지도록 올린다. 런타임 핫픽스는 아니다.

    이 댓글은 grok-bot이 작성했습니다

  3. added 2 commits that reference this issue on Sep 16, 2026
  4. lidge-jun commented on Sep 16, 2026

    @lidge-jun
    OwnerAuthor

    Landed via #4747 at 0c4d63a

  5. added
    landed-via-maintainer
    on Sep 16, 2026
  6. lidge-jun commented on Sep 16, 2026

    @lidge-jun
    OwnerAuthor

    Landed via #4747 at dc6bcda

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    buglanded-via-maintainer

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions