Skip to content

feat(hooks): add Bash blast-radius ask to output-block-falsify-advisory - #1025

Merged
devseunggwan merged 3 commits into
mainfrom
claude/issue-1010-blast-radius-ask
Aug 15, 2026
Merged

devseunggwan merged 3 commits into
mainfrom
claude/issue-1010-blast-radius-ask

Conversation

@devseunggwan

Copy link
Copy Markdown
Owner

결정

Bash leg 에 blast-radius 술어를 추가하고 permissionDecision: ask 로 발화한다. blast radius 는 수치 임계 없이 "비가역 동사 × 공유 표면 토큰" 2요소로 정의한다 (유지보수자 판정).

공백 — 실측

falsification 요구의 판별자는 정확히 두 개뿐이었다:

  • AskUserQuestion — _has_recommended_marker / _t2_matching_labels (impl.py:388, 442)
  • Bash — _is_bulk_action_command 의 5개 동사 <verb> all 정규식 (impl.py:691)

수치 크기·prod 마커·파괴적 동사 술어가 훅 어디에도 없다. 실제 prod 재귀 삭제가 PreToolUse/Bash 그룹 전체를 조용히 통과한다. 변경 전 상태를 재현해 포착했다.

왜 stderr 가 아니라 ask 인가

hooks/_lib/_hook_io.py:88-92 가 stderr 를 모델에 먹여지지 않는 채널로 문서화하고 있고, #874 가 그 채널을 관측 효과 0 으로 측정했다. ask 는 모델에 실제로 닿는 유일한 채널이고, side-effect-scan 이 kubectl delete 를 게이트하는 방식과 같다.

수용된 대가는 재시도 비용이다 — 이 훅은 이미 자주 발화한다. 그래서 술어를 좁게 유지했다. 이 근거를 spec.md 에 적었다.

발화 조건 — 2요소, 수치 임계 없음

비가역 동사(rm -r, delete, drop, truncate, purge — 목록을 새로 만들지 않고 destructive-bash-guard 가 이미 파괴적으로 취급하는 어휘를 재사용) 가 공유 표면 토큰(prod, s3://, gs://, namespace, 스키마/테이블명) 과 한 명령 세그먼트 안에서 함께 나타날 때.

수치 임계도, 재귀·와일드카드 가중치도 없다. 2요소 형태를 택한 것은 튜닝 지점이 적고 테스트가 쉽기 때문이다.

범위 제한 — AskUserQuestion leg 는 건드리지 않았다

menu-mutation-tier-advisory 가 이미 그 표면에서 ask 를 발화하고, 그 훅의 어휘가 지금 PR #1016 으로 바뀌는 중이다. 두 번째 asker 를 얹으면 이중 발화가 나고 상호작용을 측정할 수 없게 된다. spec.md 에 이것을 누락이 아니라 의도적 경계로 적었다.

회귀 — 양방향

방향 케이스
이제 ask 해야 prod 를 대상으로 한 bulk delete 계열
계속 침묵해야 rm -rf node_modules, rm -r build/ 같은 일상적 로컬 삭제
$ bash tests/hooks/advisory-nudge/test_output_block_falsify_advisory.sh
  Results: 125 passed, 0 failed
$ python3 scripts/check-plugin-manifests.py     OK

매니페스트 변경은 없다 — 훅이 이미 PreToolUse / matcher: "Bash" 엔트리를 갖고 있어 새 leg 는 구성상 등록돼 있다.

함께 고친 낡은 문서

Bash leg 를 advisory 전용으로 서술하던 두 행을 교체했다 — ARCHITECTURE.md 와 docs/hook/INDEX.md.

docs/hook-operating-matrix.md 의 tier 컬럼(advisory)은 이 변경 이전부터 이미 부정확했다 — AskUserQuestion T1/T2 leg 가 #369/#899 이후 ask 를 내고 있는데도 그 행은 advisory 라고 적고 있었다. 이 PR 이 그 부정확을 넓히긴 하지만 만들지는 않았다. 그 파일은 build-plugin-manifests.py 가 생성하므로 손으로 고치면 덮어써진다 — tier 메타데이터를 매니페스트 쪽에서 바로잡는 별도 작업이 맞다.

미확인

  • 실제 사건 3건 자체를 확인하지 못했다. 그 세션의 전사·텔레메트리·픽스처가 이 저장소에 없다. 그럴듯한 도구 호출 형태를 재구성해 프로브한 것이며, 실제 명령이 무엇이었는지, 애초에 Bash 를 거쳤는지, 64M-객체 권고가 AskUserQuestion 으로 표면화됐는지 산문이었는지 확인할 수 없다.
  • exit-0 PreToolUse stderr 가 모델에 절대 닿지 않는다는 주장은 코드 경로로 확인했지만 살아 있는 세션에서 관측하지는 않았다.
  • 이슈가 인용한 실패 feat(init): initialize skills repository with Claude Code skills #1(python3 delete_objects.py --limit-batches 20) 처럼 동사가 스크립트 이름 뒤에 숨는 형태는 이 술어로도 잡히지 않는다. 2요소 정의의 알려진 한계이고 spec.md 에 적었다.

Closes #1010


🤖 Generated with Claude Code

https://claude.ai/code/session_014Q4o2BtBPpsrr19he6qVpc


Generated by Claude Code

@coderabbitai

coderabbitai Bot commented Aug 15, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@devseunggwan, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 4 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: caa1960f-a750-4233-be29-7783669ff6ca

📥 Commits

Reviewing files that changed from the base of the PR and between c4bd6dc and 784fe5f.

📒 Files selected for processing (6)
  • .gitignore
  • ARCHITECTURE.md
  • docs/hook/INDEX.md
  • hooks/advisory-nudge/output-block-falsify-advisory/impl.py
  • hooks/advisory-nudge/output-block-falsify-advisory/spec.md
  • tests/hooks/advisory-nudge/test_output_block_falsify_advisory.sh

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devseunggwan

devseunggwan commented Aug 15, 2026 •

Copy link
Copy Markdown
Owner Author

Verification — 784fe5f (rev 3)

Carried: none — 남은 (b)·(c) 는 다음 행동을 명시하지 않은 항목이라 이월하지 않습니다. rev 2 에서 해소된 (a) 는 행 6 에 있습니다.

# Claim Result
1 이 PR 이 실행 산출물을 싣지 않는다 — a57d3d8 이 커밋했던 53KB .coverage 를 670ae98 이 제거했다 PASS(live)
2 PR 이 주장한 공백이 실재했다 — 변경 전에는 prod 재귀 삭제가 조용히 통과했다 PASS(live)
3 2요소 술어가 양방향이다 — 일상적 로컬 삭제는 계속 침묵한다 PASS(live)
4 AskUserQuestion leg 은 건드리지 않았고 이중 발화가 없다 PASS(live)
5 스위트와 매니페스트 체크가 통과한다 PASS(live)
6 #1016 이 머지된 뒤에도 두 훅이 이중 발화하지 않는다 — 같은 페이로드에 한쪽만 답한다 PASS(live)
Unverified — (b) 재시도 비용 증가량 미측정, (c) 실사용 발생 건수 0건 — (a) 는 rev 2 에서 해소돼 행 6 이 됐습니다

(b) PR 본문이 "수용된 대가는 재시도 비용" 이라고 적었습니다. 행 3 의 침묵 케이스가 술어가 좁다는 방향을 고정하지만, 그 목록도 이 PR 이 저작한 것입니다 — 실제 세션 명령 캡처로 측정한 오발화율이 아닙니다.

(c) 이 훅은 지금까지 이 술어 없이 배포돼 있었으므로, 통과시킨 prod 삭제가 실제로 몇 건이었는지는 관측 이력이 없습니다. 행 2 는 코드 경로 재현이지 발생 기록이 아닙니다.

Evidence 1 — 커밋된 53KB 바이너리를 찾아, 그것이 이 PR 의 것임을 확인하고 제거

앵커를 쓰려고 diffstat 을 읽다가 .coverage | Bin 0 -> 53248 bytes 가 보였습니다. coverage.py 가 로컬 실행 때 쓰는 SQLite 파일이고 소스가 아닙니다. 누가 넣었는지, 무시 목록에 있었는지부터 확인했습니다:

$ git log --oneline --diff-filter=A -- .coverage
a57d3d8 feat(hooks): add Bash blast-radius ask to output-block-falsify-advisory
$ git ls-tree origin/main --name-only -- .coverage
(빈 출력 — main 에는 없음)
$ git check-ignore -v .coverage; echo "check-ignore exit=$?"
check-ignore exit=1

이 PR 의 첫 커밋이 넣었고, main 에는 없고, .gitignore 는 이것을 무시하지 않습니다(check-ignore 는 무시 대상일 때 0 을 냅니다 — 여기서는 1 이므로 무시 대상이 아님). 즉 다음 로컬 실행이 다시 스테이징할 수 있는 상태였습니다. 670ae98 이 추적에서 빼고 coverage.py 계열을 .gitignore 에 넣습니다:

$ git rm --cached -q .coverage && rm -f .coverage && git add .gitignore
$ git status --porcelain
D  .coverage
M  .gitignore
Evidence 2 — 변경 전 훅과 변경 후 훅에 같은 명령을 통과시켜 공백을 재현

"공백이 실재했다" 는 이 PR 의 존재 이유이므로 주장이 아니라 측정이어야 합니다. main 의 훅 사본과 브랜치의 훅에 같은 명령을 넣고, 유일한 변수를 훅 버전으로 두었습니다.

$ bash "$P/probe_1025.sh"
== must now ask: irreversible verb x shared-surface token
  aws s3 rm --recursive s3://prod-...            before=silent  after=ask
  kubectl delete namespace prod-ingest           before=silent  after=ask
  rm -rf /mnt/prod/warehouse                     before=silent  after=ask
  DROP TABLE prod.analytics.events               before=silent  after=ask

네 형태 모두 변경 전에는 아무 말도 하지 않았습니다. $P 는 프로브를 워크트리 밖에 두려고 담아 둔 경로 변수입니다.

Evidence 3 — 같은 하니스의 아래쪽 절반이 술어의 좁음을 고정

ask 는 사람에게 닿는 채널이라 오발화 비용이 로그 한 줄이 아닙니다. 그래서 발화 쪽만 보는 것으로는 부족하고, 일상 명령이 계속 조용한지가 같은 무게로 확인돼야 합니다. 위 블록의 아래쪽 절반입니다 — 별도 실행이 아닙니다.

== must stay silent: everyday local deletes (no shared surface)
  rm -rf node_modules                            before=silent  after=silent
  rm -r build/                                   before=silent  after=silent
  rm -rf .pytest_cache                           before=silent  after=silent
  git branch -D feature/old                      before=silent  after=silent

네 개 모두 비가역 동사를 담고 있고 공유 표면 토큰이 없습니다. 2요소 곱이 실제로 곱으로 동작한다는 뜻이고, 동사만으로 발화했다면 이 네 줄이 after=ask 로 넘어갔을 것입니다.

Evidence 4 — `AskUserQuestion` 표면에 새 술어가 닿지 않는지 직접 확인

PR 은 그 leg 을 의도적으로 비워 뒀다고 적습니다. 확인 방법은 두 가지입니다 — diff 에서 그쪽 판별자가 바뀌었는지, 그리고 실제 메뉴 payload 가 새 leg 에 닿는지.

$ git diff origin/main...HEAD -- hooks/advisory-nudge/output-block-falsify-advisory/impl.py \
    | grep -nE '^[-+].*(_has_recommended_marker|_t2_matching_labels|AskUserQuestion)' | head
75:+    session_id: object, decision: str, tool: str = "AskUserQuestion"
79:+    `tool` defaults to `AskUserQuestion` for the two original call sites; the
92:-        _TELEMETRY_HOOK_NAME, _TELEMETRY_HOOK_ROLE, decision, session_id, "AskUserQuestion"

세 줄 전부 텔레메트리 기록 함수가 tool 인자를 받게 된 변경이고, 기본값이 AskUserQuestion 이라 기존 두 호출부의 동작이 그대로입니다. 판별자 _has_recommended_marker / _t2_matching_labels 는 어느 쪽으로도 나타나지 않습니다.

실제 payload 로도 봅니다 — 새 술어가 노릴 법한 어휘(Delete the prod namespace)를 메뉴 옵션에 넣었습니다:

$ printf '%s' '{"tool_name":"AskUserQuestion","session_id":"probe","tool_input":{"questions":[{"question":"q","header":"h","options":[{"label":"Delete the prod namespace","description":""},{"label":"Keep it","description":""}]}]}}' \
    | python3 hooks/advisory-nudge/output-block-falsify-advisory/impl.py | head -c 300
(빈 출력)

Refutation: 새 leg 이 이 표면까지 닿았다면 여기서 ask JSON 이 나왔어야 합니다. Positive control: 같은 훅이 죽어 있는 것이 아니라는 근거는 Evidence 2 입니다 — 같은 impl.py 가 Bash payload 에는 네 번 ask 를 냅니다.

Evidence 5 — 스위트와 매니페스트 체크

행 2~4 는 제가 고른 입력이므로, 이 PR 이 스스로 고정한 기대값 전량과 저장소의 매니페스트 정합성 체크도 함께 돌립니다. 후자는 훅을 추가·변경하면 hooks/manifest.json 과 각 플랫폼 hooks.json 이 함께 재생성돼야 하기 때문입니다.

$ bash tests/hooks/advisory-nudge/test_output_block_falsify_advisory.sh
  Results: 125 passed, 0 failed
$ python3 scripts/check-plugin-manifests.py && echo "check-plugin-manifests exit=$?"
plugin-manifest check OK
check-plugin-manifests exit=0
Evidence 6 — 두 훅에 같은 페이로드를 먹여, 한쪽만 답하는지 확인

rev 1 이 이 항목을 측정 불가로 남긴 이유는 #1016 이 아직 열려 있어서였습니다. #1016 은 8a62c97 로 머지됐고 이 브랜치는 그 위로 리베이스됐으므로, 이제 두 훅의 실제 코드가 한 트리에 있습니다 — 질문이 답할 수 있는 상태가 됐다는 뜻입니다. 물어야 하는 것은 "둘 다 말하는 순간이 있는가" 이므로, 같은 페이로드를 양쪽에 넣고 누가 말하는지 셉니다.

$ python3 "$P/probe_1025_interaction.py"
payload: AskUserQuestion (shared surface)
  output-block-falsify   exit=0 SPEAKS  📋 Every gate on `AskUserQuestion` (satisfy ALL before re-running):
  menu-mutation-tier     exit=0 silent

payload: Bash (this PR's new leg)
  output-block-falsify   exit=0 SPEAKS
  menu-mutation-tier     exit=0 silent

menu-mutation-tier 가 두 번 다 침묵합니다. 이 상태로 멈추면 "잠잠하다" 와 "하니스가 이 훅을 아예 못 부르고 있다" 를 구분할 수 없으므로, 이 훅이 잡도록 문서화된 형태를 만들어 다시 돌립니다. 위 페이로드의 취소 는 _question_triggers 가 후보를 세기 전에 제거하는 포기 옵션이라(impl.py:581 주석) 후보가 1개로 떨어져 침묵한 것입니다 — 아래는 포기·저위험 옵션 없이 변경 옵션 2개만 둔 대조군입니다.

Positive control:

$ python3 "$P/probe_1025_control.py"
  output-block-falsify   exit=0 silent
  menu-mutation-tier     exit=0 SPEAKS  [advisory] AskUserQuestion approval menu offers no non-mutating tier.

대조군에서 역할이 정확히 뒤집힙니다. 세 페이로드 어디에서도 둘이 같이 말하지 않았고, 하니스는 양쪽 훅을 모두 발화시킬 수 있습니다. $P 는 프로브를 워크트리 밖에 두려고 담아 둔 경로 변수입니다.

History — rev 3, 이월 판정 기록 · rev 2, 리베이스 + Unverified (a) 해소 · rev 1, 최초 게시

rev 3 — 머지 직전 Carried: none 을 표 위에 적었습니다. 근거 블록과 판정은 그대로입니다.

rev 2 — 670ae98 → 784fe5f. main 이 12커밋 앞서 리베이스했고 3커밋이 충돌 없이 재적용됐습니다. 검증 대상 경로는 리베이스 전후 동일합니다:

$ git diff --quiet 670ae98 HEAD -- hooks/advisory-nudge/output-block-falsify-advisory/ tests/hooks/advisory-nudge/test_output_block_falsify_advisory.sh ; echo "verified-paths exit=$?"
verified-paths exit=0

같은 리베이스가 #1016 을 브랜치 안으로 들여왔기 때문에 rev 1 의 Unverified (a) 가 측정 가능해졌고, 행 6 과 Evidence 6 으로 승격했습니다. 대체된 근거는 없습니다 — (a) 는 "측정 불가" 였지 틀린 판정이 아니었습니다.

rev 1 — 최초 게시. 다만 이 앵커의 대상 SHA 는 게시 시점에 8b906fe 에서 670ae98 로 움직였습니다 — 행 1 의 .coverage 제거가 검증 도중에 나온 수정이기 때문이고, 표의 모든 근거는 670ae98 에서 다시 측정한 것입니다.

claude and others added 3 commits August 15, 2026 23:19
The falsification requirement had no magnitude, prod-marker or destructive-verb
predicate on the Bash surface. The only discriminator was
`_is_bulk_action_command`'s five-verb "<verb> all" regex, so a real production
recursive delete passed the whole PreToolUse/Bash group in silence. Reproduced
before the change, all rc=0 with empty stdout AND empty stderr:

  aws s3 rm s3://prod-data-lake/ --recursive
  kubectl delete namespace production
  psql -c "DROP TABLE prod.users"
  rm -rf /srv/prod/uploads

Positive control from the same run, proving the probe harness was live:
`close all open issues via gh cli` emitted the bulk advisory on stderr.

Adds a two-factor blast-radius predicate: an IRREVERSIBLE VERB (delete, drop,
truncate, purge, plus a structural rm+recursive-flag check) co-occurring with a
SHARED-SURFACE TOKEN (prod/production, s3://, gs://, namespace, or a DDL keyword
followed by a dotted schema-qualified identifier) inside the SAME command
segment, walked via the shared safe_tokenize -> iter_command_starts pipeline.
No numeric threshold and no recursive/wildcard weighting: an object count is not
knowable from command text without executing it and a weighting scheme is not
verifiable by inspection, while a co-occurrence of two named vocabularies is
both. The verb vocabulary is taken from what the repo already treats as
destructive (destructive-bash-guard's `find -delete` / `truncate -s 0`,
side-effect-scan's `kubectl delete`) rather than invented here.

The decision is `permissionDecision: ask`, not the exit-0 stderr advisory.
stderr on exit 0 is the channel hooks/_lib/_hook_io.py:88-92 documents as not
model-fed, and #874 measured that tier at 42 fires in one session with zero
observed effect. `ask` is the only channel that reaches the model and is how
side-effect-scan already gates `kubectl delete`. The accepted cost is retry tax
on a hook that already fires often, which is why the predicate stays tight.
Verified end-to-end through hooks/_lib/_dispatch.py: the ask survives group
aggregation, and `rm -rf node_modules` produces no decision from the whole group.

Three scoping decisions are load-bearing and each is pinned by a fixture:
same-segment co-occurrence (so `rm foo.txt && grep -r bar prod` stays quiet),
`rm` needing the recursive flag rather than the force flag (so `aws s3 rm
--recursive`, which has no force flag, is caught while `rm /srv/prod/one-file`
is not), and the schema/table surface requiring qualification (so an unqualified
`drop table tmp_rows` on a local scratch DB stays quiet).

Blast radius takes precedence over the bulk-action advisory when both match --
the ask reason already carries the falsification instruction and the advisory's
channel does not reach the model, so emitting both would only duplicate a debug
log line. One pre-existing fixture moved tiers because of this and is annotated;
bulk-phrase-only coverage is preserved by a new fixture with no shared surface.

`_record_block_telemetry` takes `tool` as a third parameter defaulting to
AskUserQuestion so the Bash ask records with tool=Bash; the two surfaces have
different retry-tax profiles and a tier decision for one must not be re-scored
from the other's fire count.

No tier is added to the AskUserQuestion leg. menu-mutation-tier-advisory already
asks on that surface and its vocabulary is in flight, so a second asker would
double-fire and make the interaction unmeasurable. Recorded in spec.md as a
deliberate boundary, not an omission, along with the probed false negatives
(cross-segment pipelines, unparseable quoting, variable-hidden surfaces).

Fixtures cover both directions -- 7 must-ask cases and 11 must-stay-silent
controls including the two routine-local deletes the predicate must never touch.
Three mutation runs confirm the controls are load-bearing: dropping segment
scoping, removing the prod word boundary, and narrowing rm to argv[0] each fail
exactly the fixtures written for them. 125 passed, 0 failed.

Closes #1010

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014Q4o2BtBPpsrr19he6qVpc
The fence added for the before/after evidence carried no language (MD040). It
holds a shell transcript with rc/stdout/stderr lines rather than runnable
commands, so it takes `text` — the label this repo already uses 40 times for
transcripts, against `bash` for commands. The file's other bare fence is
pre-existing and left alone.

Confidence: high
Session-Id: 9e3b4abb-9995-41aa-8c70-4c2be1bb61ba
a57d3d8 committed a 53KB .coverage SQLite db — a local run artifact
that was never meant to ship. Remove it and add the coverage.py family
to .gitignore so a later run cannot re-stage it.

Confidence: high
Session-Id: 9e3b4abb-9995-41aa-8c70-4c2be1bb61ba
@devseunggwan
devseunggwan force-pushed the claude/issue-1010-blast-radius-ask branch from 670ae98 to 784fe5f Compare August 15, 2026 14:21
@devseunggwan

Copy link
Copy Markdown
Owner Author

Verification updated — 784fe5f rev 2 · 리베이스 후 SHA 갱신 + Unverified (a) 를 실측으로 해소(행 6, Evidence 6: 두 훅이 서로 배타적으로 발화, 양성 대조 포함) → #1025 (comment)

@devseunggwan

Copy link
Copy Markdown
Owner Author

Verification updated — 784fe5f rev 3 · 머지 직전 Carried: none 기록 → #1025 (comment)

@devseunggwan
devseunggwan merged commit 6aa725b into main Aug 15, 2026
10 checks passed
@devseunggwan
devseunggwan deleted the claude/issue-1010-blast-radius-ask branch August 15, 2026 14:31
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.

Gate falsification on blast radius, not on the recommended label

2 participants