Skip to content

knowledge-wiki: no_hooks 확보 실패 시 fail-open — 중첩 claude 재귀 #38

Closed

Description

@Hyeongseob91

문제

accumulate.py 는 중첩 claude 호출이 자기 자신을 다시 부르지 않도록
disableAllHooks 설정 파일을 만들어 --settings 로 넘긴다.

그런데 그 파일을 못 만들면 설정 없이 그냥 호출한다.

no_hooks = wiki / tenant.subdir / ".no-hooks.json"
if not no_hooks.exists():
    try:
        no_hooks.write_text('{"disableAllHooks": true}\n', encoding="utf-8")
    except OSError:
        no_hooks = None      # ← fail-open

compile._claude 는 no_hooks 가 None이면 --settings 없이 claude --print 를 띄운다.
자식 세션은 같은 Stop 훅을 물고 있으므로 종료 시 accumulate.py 를 다시 실행하고,
그게 또 claude 를 띄운다.

왜 문제인가

이 모듈의 다른 실패 경로는 전부 폐기다. G2 호출 실패, G3 파싱 실패, 타임아웃 모두
fail-closed로 처리한다 (compile.py 의 docstring이 그렇게 선언한다).
여기만 반대 방향이고, 하필 결과가 재귀다.

발생 조건(디스크 가득 참, 권한, 읽기 전용 마운트)은 드물지만
드문 조건에서 조용히 폭주하는 게 정확히 이 기능이 피하려던 실패 모드다.

제안

no_hooks 를 확보하지 못하면 그 세션은 폐기한다 (로그 남기고 return 0).
article 하나를 잃는 비용과 재귀 비용은 비대칭이다 — 모듈의 다른 결정과 같은 근거다.

#36에서 이 파일을 머신 로컬 상태 디렉터리로 옮기면 위키 repo 권한과도 분리된다.

관련: #34 리뷰

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions