Skip to content

[bug] idd-diagnose Step 0.5 Clarity gate greps '### Clarity Surface' without stripping code fences → false-positive REFUSE (sister concern from #178) #181

Description

@kiki830621

Problem

idd-diagnose Step 0.5 Clarity Surface gate 用裸 grep + awk 偵測 ### Clarity Surface annotation block,未先剝除 fenced code blocks:

if echo "$BODY" | grep -q '^### Clarity Surface'; then
  BLOCK=$(echo "$BODY" | awk '/^### Clarity Surface/{flag=1; print; next} flag && /^### /{flag=0} flag')
  SURFACED_COUNT=$(echo "$BLOCK" | grep -cE '\| surfaced \|')
  ...

當 issue body 在 ``` code fence 內示意一個 Clarity Surface block(例如一個討論 clarity 機制、或記錄 audit-block 結構的 issue),裸 grep 把示意 code 當成真的 annotation block → gate 誤判 → false-positive REFUSE,擋下一個本該 PROCEED 的 diagnose。

Type

bug(spec gap / footgun in published skill — idd-diagnose SKILL.md Step 0.5)

Repro(實證 — dogfood catch)

  1. Issue body 在 code fence 內含 ### Clarity Surface(示意,非真 annotation;body 內無真 surfaced/deferred 表格列)。
  2. 跑 /idd-diagnose #N。
  3. Step 0.5 gate 的 grep '^### Clarity Surface' 命中 fence 內那行 → 進 refuse 分支。

實證:診斷 #178 時親自撞到——#178(本 issue 的 parent)body line 10 的 ### Clarity Surface 在 code fence(line 7–14)內,是用來示意 idd-update 吃掉 audit block 的 bug,不是真 annotation。手動數 fence 數量(奇偶)才確認是 false positive、PROCEED;但 SKILL.md 的 gate prose 不做這個剝除,較不謹慎的執行者會被誤導 refuse。

Root cause(初判)

Step 0.5 的 grep/awk 是無語意感知的結構匹配——^### Clarity Surface 在 markdown 語境下,fence 內與 fence 外意義完全不同,但裸 grep 一視同仁。這跟 #178 同屬一個 class(idd-update 用 --- 當錨、本 gate 用 ### Clarity Surface 當錨,都缺 markdown-aware 前處理)。

Suggested fix(方向,待 diagnose 確認)

在 Step 0.5 grep/awk 之前先剝除 fenced code blocks,沿用 idd-list Step 3.5(#14)已驗證的 strip_fenced_code():

FENCE_RE = ```[\s\S]*?```      # 同 idd-list references impl
BODY_STRIPPED = strip_fenced_code(BODY)
# 之後所有 grep '^### Clarity Surface' / surfaced-row count 改用 BODY_STRIPPED

idd-list Step 3.5 早就為完全相同的 false-positive class 加了 strip_fenced_code()(PR-ref scan 把 ```bash Refs #99 ``` 誤當真 ref)——本 gate 應 reuse 同一前處理。Inline code(`### Clarity Surface`)是否也剝可比照 idd-list 決策(idd-list 選擇不剝 inline,false-positive 較罕見)。

Impact

Source: surfaced during /idd-diagnose #178 sister concern surfacing (Step 3.6)


Current Status

Phase: closed
Last updated: 2026-06-01 by idd-close

Key Decisions

Scope Changes

  • (none)

Blocking

  • (none)

Commits

Verification

Activity

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