Skip to content

実装: persist_retrospective_run.py の secret redaction パターンを新形式 ghs_ App installation token に対応させる #2727

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "PR #2722(Issue #2718 close)の人間レビューコメントで指摘された repository-wide gap の一部として、.claude/skills/agent-retrospective/scripts/persist_retrospective_run.py の _TOKEN_PATTERNS を新形式 ghs_ App installation token に対応させる"
change_kind: code

Parent Issue

なし(単独改善)

Parent Goal Ref

Current Validated Scope

  • .claude/skills/agent-retrospective/scripts/persist_retrospective_run.py の _scan_value_patterns() は、public-facing envelope/value が _TOKEN_PATTERNS にマッチした時点で即座に PublicSafetyViolation(reason_code="token_pattern_detected") を raise する fail-closed detector / publication gate であり、token の一部を伏字化して投稿する redactor ではない(PublicSafetyViolation 発生時、呼び出し元の publish path は transport.create_comment() へ一切到達しない)。
  • _TOKEN_PATTERNS(1146-1153行目付近)は re.compile(r"\bghs_[A-Za-z0-9]{20,}\b") を含む。典型的な新形式 GitHub App installation token ghs_<APP_ID>_<header>.<payload>.<signature> に対しては、ghs_ 後の [A-Za-z0-9]{20,} matcher が APP_ID 直後の _(word character であり [A-Za-z0-9] に含まれない)で停止し、かつ _ は word character のため末尾 \b もそこで成立しない。したがって「. の直前まで部分マッチする」のではなく、典型的な新形式 fixture に対して実質的に unmatched(検出されない) である。
  • Issue 実装: compact_author_result.py の GitHub token 検出パターンを新形式 ghs_ App installation token に対応させる #2726 / PR fix: compact_author_result.pyのghs_パターンを新形式GitHubトークンに対応させる #2746(本日 main にマージ済み)により、scripts/agent-guards/controlled_skill_mutation_exec.py の _SECRET_LIKE_PATTERNS(802行目)には新形式専用 matcher ghs_[A-Za-z0-9._-]{36,} が先行実装されている。persist_retrospective_run.py の _TOKEN_PATTERNS にはこの新形式専用 matcher に相当するエントリが存在しない。
  • 既存テスト .claude/skills/agent-retrospective/scripts/tests/test_persist_retrospective_run.py に ghs_ を対象にしたテストは存在しない(rg -n "ghs_" .claude/skills/agent-retrospective/scripts/tests/test_persist_retrospective_run.py は 0 件)。既存の test_public_safety_validator_runs_before_post_rejects_token_pattern は PublicSafetyViolation + reason_code + transport.create_call_count == 0 を検証する既存 harness パターンを持ち、本 Issue の AC2/AC3 で同型パターンを再利用する。

Remaining Parent Gaps

  • scripts/summarize_agent_transcript.py、.claude/skills/issue-refinement-loop/scripts/compact_author_result.py、.claude/skills/impl-review-loop/scripts/get_ci_failed_log.py の同種 gap は別 follow-up Issue として個別に起票する(本 Issue のスコープ外)。

Outcome

.claude/skills/agent-retrospective/scripts/persist_retrospective_run.py の _TOKEN_PATTERNS に新形式 GitHub App installation token ghs_<APP_ID>_<header>.<payload>.<signature> を検出する dedicated matcher が追加されており、当該トークンを含む public-facing envelope/value を既存 publish path に渡すと PublicSafetyViolation(reason_code="token_pattern_detected") が発生して transport.create_comment() の呼び出し回数が0のまま拒否される(= fail-closed detector / publication gate として機能する)ことを直接検証する pytest が .claude/skills/agent-retrospective/scripts/tests/test_persist_retrospective_run.py に追加されて PASS している。既存の classic ghp_ / github_pat_ / gho_ / ghs_(classic 形式)検出挙動は回帰していない。

Runtime Verification Applicability

In Scope

  • _TOKEN_PATTERNS 内に、既存 legacy matcher \bghs_[A-Za-z0-9]{20,}\b を単純に広げるのではなく、新形式専用 matcher ghs_[A-Za-z0-9._-]{36,} 相当を 追加 し、legacy matcher も残す(Issue 実装: compact_author_result.py の GitHub token 検出パターンを新形式 ghs_ App installation token に対応させる #2726 / PR fix: compact_author_result.pyのghs_パターンを新形式GitHubトークンに対応させる #2746、controlled_skill_mutation_exec.py の _SECRET_LIKE_PATTERNS(802行目、ghs_[A-Za-z0-9._-]{36,})を precedent として踏襲する)。charset [A-Za-z0-9._-] は GitHub installation-token matcher が扱う文字集合であり、. は JWT/JWS compact serialization の segment delimiter である(JWT の各 segment 自体は base64url だが、. を含む charset 全体を「base64url charset」と呼ばない)。JWT 内部の header/payload/signature それぞれの意味論を解釈する parser は要求しない。
  • 新形式トークンを含む public-facing envelope/value が既存 publish path で PublicSafetyViolation(reason_code="token_pattern_detected") を発生させ、transport.create_comment() の呼び出し回数が0であることを直接検証する pytest の追加
  • classic \bghs_[A-Za-z0-9]{20,}\b 形式トークンが引き続き同じ fail-closed path で拒否されることを直接検証する pytest の追加(既存 suite 全件の regression 維持を含む)

Out of Scope

  • 他ファイル(summarize_agent_transcript.py / compact_author_result.py / get_ci_failed_log.py)の同種 gap 修正(別 follow-up Issue で扱う)
  • 新規 secret scanner サブシステムの新設
  • _TOKEN_PATTERNS 内の他エントリ(ghp_ / github_pat_ / gho_ / sk- / AKIA / xox[abp]-)のロジック変更
  • live GitHub mutation test や credential canary の追加
  • ghp_ / github_pat_ / gho_ 向けの新規 regression test の追加増殖(既存 suite + classic ghs_ の直接 regression で十分とする)

Acceptance Criteria

  • AC1: _TOKEN_PATTERNS に、新形式 GitHub App installation token を検出する ghs_[A-Za-z0-9._-]{36,} 相当の dedicated matcher が存在する(既存 legacy matcher \bghs_[A-Za-z0-9]{20,}\b はそのまま残す)
  • AC2: 現実的な synthetic ghs_<APP_ID>_<header>.<payload>.<signature>(. を正確に2個含み、長さ目安 520 文字以上)を public-facing envelope/value に含めて既存 publish path を実行すると、PublicSafetyViolation が発生し、reason_code == "token_pattern_detected" となり、transport.create_comment() の呼び出し回数が0のままであることを、既存の test_public_safety_validator_runs_before_post_rejects_token_pattern と同型の transport call-count harness を再利用して直接検証する
  • AC3: classic legacy ghs_ token(\bghs_[A-Za-z0-9]{20,}\b にマッチする短縮形)が引き続き同じ fail-closed path(PublicSafetyViolation + reason_code == "token_pattern_detected" + transport.create_call_count == 0)で拒否され、test_persist_retrospective_run.py の既存 suite 全件が PASS する

Verification Commands

# AC1
# baseline-expect: fail
$ rg -n 'ghs_\[A-Za-z0-9\._-\]\{36,\}' .claude/skills/agent-retrospective/scripts/persist_retrospective_run.py

# AC2
# baseline-expect: fail
$ uv run pytest .claude/skills/agent-retrospective/scripts/tests/test_persist_retrospective_run.py::test_new_format_installation_token_blocks_publication -q

# AC3
# baseline-expect: pass
$ uv run pytest .claude/skills/agent-retrospective/scripts/tests/test_persist_retrospective_run.py -q

Allowed Paths

  • .claude/skills/agent-retrospective/scripts/persist_retrospective_run.py
  • .claude/skills/agent-retrospective/scripts/tests/test_persist_retrospective_run.py

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

Required Skills

なし

Required Design References

Scope Delta(任意)

N/A

Notes for Reviewer

  • 優先度: optional_follow_up(低優先度)。実在の credential 漏洩インシデントは確認されておらず、プロアクティブな gap 解消目的の改善である。緊急対応は不要。
  • Scope Overlap Preflight(check_issue_overlap.py)の結果: decision=safe_new_issue(no_overlap)。既存 OPEN Issue との allowed_paths 重複は検出されなかった。
  • 本 Issue は PR fix: 新形式GitHub App installation token(ghs_APPID_JWT)を完全redactする #2722 の人間レビューコメント(issuecomment-5770273156)で明示的に follow-up 推奨された4ファイルのうち1件。他の3ファイルは別 Issue として個別起票する。
  • 本 Issue は canonical Step 2 review(run_root_review_pipeline.py produce)で verdict: needs-fix を受け、OWNER のレビューコメント(issuecomment-5827300623)が「redactor ではなく fail-closed detector / publication gate である」という contract semantics の訂正を要求したため、full rewrite された。旧 AC1-3・旧 VC1(rg -n "_TOKEN_PATTERNS" ... が baseline main で既に PASS していた無効な検証コマンド)は置き換え済み。

Source

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    triage-required
    follow-up
    area/security
    on Sep 22, 2026
  2. squne121 commented on Sep 25, 2026

    @squne121
    OwnerAuthor

    判定

    Issue #2727 は REQUEST_CHANGES 相当です。 ただし、目的そのものは妥当で、実装を大きくする必要はありません。問題は主に Issue 契約が対象コードの実際の semantics とずれていることです。

    特に、現行 .claude/skills/agent-retrospective/scripts/persist_retrospective_run.py は token を伏字化する redactor ではありません。_scan_value_patterns() が _TOKEN_PATTERNS にヒットした時点で PublicSafetyViolation(reason_code="token_pattern_detected") を送出し、transport.create_comment() へ到達させない fail-closed detector / publication gate です。したがって「token 全体を redaction できたか」より、「新形式 token を検出して投稿をゼロ回で拒否したか」が本来の acceptance boundary です。
    Issue #2727
    persist_retrospective_run.py

    優先度 | Finding | 推奨 -- | -- | -- P1 | redactor と detector を混同している。Outcome/AC2 の「断片を残さず redaction」は production behavior ではない | Outcome/AC を PublicSafetyViolation + zero transport calls に変更 P1 | 現行 regex の失敗理由が誤っている。「. 直前まで部分マッチ」ではない | 「APP_ID 後の _ のため典型的新形式を認識できない」に訂正 P1 | {20,} のまま charset だけ広げる余地があり、fail-close detector として false positive を増やす | 新形式専用 ghs_[A-Za-z0-9._-]{36,} を追加し、legacy matcher は残す P2 | [A-Za-z0-9._-] を「base64url charset」と呼んでいる | . は JWS/JWT compact serialization の delimiter と明記 P2 | AC1 の rg -n "_TOKEN_PATTERNS" は現 main で既に PASS | exact matcher 検索か behavioral pytest に変更 P2 | AC2 が「単一マッチで token 全体を consume」を要求しているが detector では不要 | production fail-close test を正本にする P2 | synthetic fixture が弱いと別 matcher 経由で false-pass できる | #2746 precedent の現実的な約520文字 fixture を流用 P3 | ghp/github_pat/gho まで新規 regression test を増やす必要性は低い | classic ghs_ の直接 test + 既存 suite 全件で十分

    1. 現行 regex の失敗理由は書き直すべき

    現在は、

    re.compile(r"\bghs_[A-Za-z0-9]{20,}\b")

    です。

    Issue #2727 は新形式に対して「. の直前までマッチする」としていますが、典型的な新形式は、

    ghs_123456789_<JWT-header>.<JWT-payload>.<JWT-signature>
                   ^
                   APP_ID 後の "_"

    なので、ghs_ 後の [A-Za-z0-9]{20,} が APP_ID 後の _ で途切れます。さらに _ は regex 上の word character なので、末尾 \b もここでは成立しません。

    これは元 Issue #2718 / PR #2722 のレビューですでに fact-check され、「典型的 fixture では partial match ではなく unmatched」へ訂正されています。#2727 はその修正前の説明を引き継いでしまっています。
    Issue #2718
    PR #2722 の OWNER review

    2. {36,} に揃えるのが適切

    2026年5月時点の GitHub 自身の guidance は、新旧 GitHub App installation token を扱う matcher として概ね、

    ghs_[A-Za-z0-9.\-_]{36,}

    を案内しています。新形式は ghs_<APP_ID>_<JWT> で約520文字、JWT compact serialization のため2個の . を持ちます。GitHub は token の内部構造に依存せず opaque string として扱うことも推奨しています。The GitHub Blog

    ここで重要なのは、. は base64url の文字ではないことです。JWT の各 segment は base64url ですが、. は segment delimiter です。Issue #2727 の「base64url charset [A-Za-z0-9._-]」という記述は修正した方がよいです。

    リポジトリ内でも、すでに #2718/#2722、#2725/#2735、そして 本日 main に入った #2726/#2746 が ghs_[A-Za-z0-9._-]{36,} に収束しています。Trivy など外部実装でも同じ方向です。GitHub

    特に #2726 / PR #2746 は重要です。こちらも当初 redactor と detector を混同していましたが、OWNER review 後に detector + fail-closed として契約を修正しており、#2727 とほぼ同型です。
    Issue #2726
    PR #2746

    3. 実装は小さくてよい

    品質とワークフローの軽さを両立するなら、既存 ghs_ matcher を置換するより、新形式専用 matcher を追加して legacy matcher を残すのが扱いやすいです。

    _TOKEN_PATTERNS: tuple[re.Pattern[str], ...] = (    re.compile(r"\bghp_[A-Za-z0-9]{20,}\b"),    re.compile(r"\bgithub_pat_[A-Za-z0-9_]{20,}\b"),    re.compile(r"\bgho_[A-Za-z0-9]{20,}\b"),    # GitHub App installation token, including ghs_<APP_ID>_<JWT>.    # JWT segments are base64url; "." separates compact-JWS segments.    re.compile(r"ghs_[A-Za-z0-9._-]{36,}"),    # Preserve the existing broader legacy secret-like behavior.    re.compile(r"\bghs_[A-Za-z0-9]{20,}\b"),    ...)

    この構造なら、新形式は GitHub 現行 guidance に合わせつつ、既存の「20文字以上なら suspicious として block」という挙動も消しません。ここは redactor と違って最初の match で例外になるため、specific-before-general の順序は readability 上は良いものの、現在の fixture に対する correctness requirement ではありません。

    また、新 matcher に古い \b を機械的に付ける必要もありません。公式 guidance とリポジトリ内の先行実装に合わせる方が単純です。

    4. Acceptance Criteria は production behavior に寄せる

    現 AC2 の「_TOKEN_PATTERNS により全体が単一マッチ」は、内部実装を固定しすぎています。#2727 で証明したいのは最終的にはこれです。

    AC1:
    _TOKEN_PATTERNS に新形式 GitHub App installation token を検出する
    ghs_[A-Za-z0-9._-]{36,} 相当の dedicated matcher が存在する。
    

    AC2:
    新形式 ghs_<APP_ID>_<JWT> を public-facing envelope の値に含めて
    既存 publish path を実行すると PublicSafetyViolation が発生し、
    reason_code == "token_pattern_detected" となり、
    transport.create_comment() の呼び出し回数が 0 のままである。

    AC3:
    classic ghs_ token も引き続き同じ fail-closed 経路で拒否され、
    test_persist_retrospective_run.py 全件が PASS する。

    これはすでにテストコードに存在する PublicSafetyViolation / create_call_count == 0 の harness を再利用できるので、新規 security framework や live credential canary は不要です。Runtime Verification Applicability: not_applicable もそのままで妥当です。

    fixture は PR #2746 に合わせて、APP_ID + header.payload.signature、. が正確に2個、 / - を含み、全長がおおむね実トークン相当の >=520 になる synthetic token にすると、非常に安価にテスト品質を上げられます。PR #2746

    5. Verification Commands も直した方がよい

    現行 AC1 の、

    rg -n "TOKEN_PATTERNS" ...

    は変更前から成功するので verification になっていません。最低限、次の程度で十分です。

    rg -n 'ghs[A-Za-z0-9.-]{36,}' 
    .claude/skills/agent-retrospective/scripts/persist_retrospective_run.py

    uv run pytest
    .claude/skills/agent-retrospective/scripts/tests/test_persist_retrospective_run.py::test_publish_rejects_new_ghs_installation_token -q

    uv run pytest
    .claude/skills/agent-retrospective/scripts/tests/test_persist_retrospective_run.py::test_publish_rejects_legacy_ghs_token -q

    uv run pytest
    .claude/skills/agent-retrospective/scripts/tests/test_persist_retrospective_run.py -q

    この程度ならハーネスを増やさず、実装を壊したときだけ明確に落ちます。

    結論

    #2727 は実装自体は小さく価値がありますが、そのまま実装へ渡すのは勧めません。特に「redaction」という framing のままだと、内部 regex の whole-match テストだけ増えて、実際の publication boundary を検証しない PR になり得ます。

    修正の中心は、**「redactor → fail-closed detector」「partial match → typical new-format is unmatched」「base64url charset → token matcher charset」「{20,} → dedicated {36,}」**の4点です。Allowed Paths、Out of Scope、live verification 不要というスコープはそのままでよく、追加の scanner や security harness は不要です。

    また、2026年9月25日現在の main はすでに PR #2746 の detector 対応を含んでいるため、#2727 は #2726 の refined contract を横展開する形に寄せるのが最も低コストで整合的です。
    現在の main head を含む commit

    ## 判定

    Issue #2727 は REQUEST_CHANGES 相当です。 ただし、目的そのものは妥当で、実装を大きくする必要はありません。問題は主に Issue 契約が対象コードの実際の semantics とずれていることです。

    特に、現行 .claude/skills/agent-retrospective/scripts/persist_retrospective_run.py は token を伏字化する redactor ではありません。_scan_value_patterns() が _TOKEN_PATTERNS にヒットした時点で PublicSafetyViolation(reason_code="token_pattern_detected") を送出し、transport.create_comment() へ到達させない fail-closed detector / publication gate です。したがって「token 全体を redaction できたか」より、「新形式 token を検出して投稿をゼロ回で拒否したか」が本来の acceptance boundary です。
    [Issue #2727](https://github.com/squne121/loop-protocol/issues/2727?utm_source=chatgpt.com)
    [persist_retrospective_run.py](https://github.com/squne121/loop-protocol/blob/main/.claude/skills/agent-retrospective/scripts/persist_retrospective_run.py?utm_source=chatgpt.com)

    優先度 Finding 推奨
    P1 redactor と detector を混同している。Outcome/AC2 の「断片を残さず redaction」は production behavior ではない Outcome/AC を PublicSafetyViolation + zero transport calls に変更
    P1 現行 regex の失敗理由が誤っている。「. 直前まで部分マッチ」ではない 「APP_ID 後の _ のため典型的新形式を認識できない」に訂正
    P1 {20,} のまま charset だけ広げる余地があり、fail-close detector として false positive を増やす 新形式専用 ghs_[A-Za-z0-9._-]{36,} を追加し、legacy matcher は残す
    P2 [A-Za-z0-9._-] を「base64url charset」と呼んでいる . は JWS/JWT compact serialization の delimiter と明記
    P2 AC1 の rg -n "_TOKEN_PATTERNS" は現 main で既に PASS exact matcher 検索か behavioral pytest に変更
    P2 AC2 が「単一マッチで token 全体を consume」を要求しているが detector では不要 production fail-close test を正本にする
    P2 synthetic fixture が弱いと別 matcher 経由で false-pass できる #2746 precedent の現実的な約520文字 fixture を流用
    P3 ghp/github_pat/gho まで新規 regression test を増やす必要性は低い classic ghs_ の直接 test + 既存 suite 全件で十分

    1. 現行 regex の失敗理由は書き直すべき

    現在は、

    re.compile(r"\bghs_[A-Za-z0-9]{20,}\b")

    です。

    Issue #2727 は新形式に対して「. の直前までマッチする」としていますが、典型的な新形式は、

    ghs_123456789_<JWT-header>.<JWT-payload>.<JWT-signature>
                   ^
                   APP_ID 後の "_"
    

    なので、ghs_ 後の [A-Za-z0-9]{20,} が APP_ID 後の _ で途切れます。さらに _ は regex 上の word character なので、末尾 \b もここでは成立しません。

    これは元 Issue #2718 / PR #2722 のレビューですでに fact-check され、「典型的 fixture では partial match ではなく unmatched」へ訂正されています。#2727 はその修正前の説明を引き継いでしまっています。
    Issue #2718
    [PR #2722 の OWNER review](#2722)

    2. {36,} に揃えるのが適切

    2026年5月時点の GitHub 自身の guidance は、新旧 GitHub App installation token を扱う matcher として概ね、

    ghs_[A-Za-z0-9.\-_]{36,}

    を案内しています。新形式は ghs_<APP_ID>_<JWT> で約520文字、JWT compact serialization のため2個の . を持ちます。GitHub は token の内部構造に依存せず opaque string として扱うことも推奨しています。:chatgpt-content-reference{index="4"}

    ここで重要なのは、. は base64url の文字ではないことです。JWT の各 segment は base64url ですが、. は segment delimiter です。Issue #2727 の「base64url charset [A-Za-z0-9._-]」という記述は修正した方がよいです。

    リポジトリ内でも、すでに #2718/#2722、#2725/#2735、そして 本日 main に入った #2726/#2746 が ghs_[A-Za-z0-9._-]{36,} に収束しています。Trivy など外部実装でも同じ方向です。:chatgpt-content-reference{index="5"}

    特に #2726 / PR #2746 は重要です。こちらも当初 redactor と detector を混同していましたが、OWNER review 後に detector + fail-closed として契約を修正しており、#2727 とほぼ同型です。
    Issue #2726
    PR #2746

    3. 実装は小さくてよい

    品質とワークフローの軽さを両立するなら、既存 ghs_ matcher を置換するより、新形式専用 matcher を追加して legacy matcher を残すのが扱いやすいです。

    _TOKEN_PATTERNS: tuple[re.Pattern[str], ...] = (
        re.compile(r"\bghp_[A-Za-z0-9]{20,}\b"),
        re.compile(r"\bgithub_pat_[A-Za-z0-9_]{20,}\b"),
        re.compile(r"\bgho_[A-Za-z0-9]{20,}\b"),
    
        # [GitHub](https://github.com/aquasecurity/trivy/blob/main/pkg/fanal/secret/builtin-rules.go?utm_source=chatgpt.com) App installation token, including ghs_<APP_ID>_<JWT>.
        # JWT segments are base64url; "." separates compact-JWS segments.
        re.compile(r"ghs_[A-Za-z0-9._-]{36,}"),
    
        # Preserve the existing broader legacy secret-like behavior.
        re.compile(r"\bghs_[A-Za-z0-9]{20,}\b"),
    
        ...
    )

    この構造なら、新形式は GitHub 現行 guidance に合わせつつ、既存の「20文字以上なら suspicious として block」という挙動も消しません。ここは redactor と違って最初の match で例外になるため、specific-before-general の順序は readability 上は良いものの、現在の fixture に対する correctness requirement ではありません。

    また、新 matcher に古い \b を機械的に付ける必要もありません。公式 guidance とリポジトリ内の先行実装に合わせる方が単純です。

    4. Acceptance Criteria は production behavior に寄せる

    現 AC2 の「_TOKEN_PATTERNS により全体が単一マッチ」は、内部実装を固定しすぎています。#2727 で証明したいのは最終的にはこれです。

    AC1:
    _TOKEN_PATTERNS に新形式 GitHub App installation token を検出する
    ghs_[A-Za-z0-9._-]{36,} 相当の dedicated matcher が存在する。
    
    AC2:
    新形式 ghs_<APP_ID>_<JWT> を public-facing envelope の値に含めて
    既存 publish path を実行すると PublicSafetyViolation が発生し、
    reason_code == "token_pattern_detected" となり、
    transport.create_comment() の呼び出し回数が 0 のままである。
    
    AC3:
    classic ghs_ token も引き続き同じ fail-closed 経路で拒否され、
    test_persist_retrospective_run.py 全件が PASS する。
    

    これはすでにテストコードに存在する PublicSafetyViolation / create_call_count == 0 の harness を再利用できるので、新規 security framework や live credential canary は不要です。Runtime Verification Applicability: not_applicable もそのままで妥当です。

    fixture は PR #2746 に合わせて、APP_ID + header.payload.signature、. が正確に2個、_ / - を含み、全長がおおむね実トークン相当の >=520 になる synthetic token にすると、非常に安価にテスト品質を上げられます。PR #2746

    5. Verification Commands も直した方がよい

    現行 AC1 の、

    rg -n "_TOKEN_PATTERNS" ...

    は変更前から成功するので verification になっていません。最低限、次の程度で十分です。

    rg -n 'ghs_\[A-Za-z0-9\._-\]\{36,\}' \
      .claude/skills/agent-retrospective/scripts/persist_retrospective_run.py
    
    uv run pytest \
      .claude/skills/agent-retrospective/scripts/tests/test_persist_retrospective_run.py::test_publish_rejects_new_ghs_installation_token -q
    
    uv run pytest \
      .claude/skills/agent-retrospective/scripts/tests/test_persist_retrospective_run.py::test_publish_rejects_legacy_ghs_token -q
    
    uv run pytest \
      .claude/skills/agent-retrospective/scripts/tests/test_persist_retrospective_run.py -q

    この程度ならハーネスを増やさず、実装を壊したときだけ明確に落ちます。

    結論

    #2727 は実装自体は小さく価値がありますが、そのまま実装へ渡すのは勧めません。特に「redaction」という framing のままだと、内部 regex の whole-match テストだけ増えて、実際の publication boundary を検証しない PR になり得ます。

    修正の中心は、**「redactor → fail-closed detector」「partial match → typical new-format is unmatched」「base64url charset → token matcher charset」「{20,} → dedicated {36,}」**の4点です。Allowed Paths、Out of Scope、live verification 不要というスコープはそのままでよく、追加の scanner や security harness は不要です。

    また、2026年9月25日現在の main はすでに PR #2746 の detector 対応を含んでいるため、#2727 は #2726 の refined contract を横展開する形に寄せるのが最も低コストで整合的です。
    現在の main head を含む commit

  3. squne121 commented on Sep 25, 2026

    @squne121
    OwnerAuthor

    確認した限り、推奨は Issue #2727 を新規に作り直さず、target comment #5827300623 を trusted human context / OWNER feedback として固定し、既存 Issue 本文を issue-refinement-loop で更新する です。

    理由は明確です。[#2727](#2727) の目的と Allowed Paths は概ね維持できますが、[対象コメント](#2727 (comment)) が指摘する「redactor → fail-closed detector」「典型的新形式は partial match ではなく unmatched」「新形式専用 {36,} matcher + legacy matcher 維持」「AC を publication boundary に置く」の修正が契約本文に必要です。同型の [#2726](#2726) は既にこの方向へ refinement 済みなので、これを precedent として横展開するのが最小コストです。[issue-refinement-loop](https://github.com/squne121/loop-protocol/tree/main/.claude/skills/issue-refinement-loop) 自体も、anchor comment が direct human context の場合は preflight.run.with_human_context → trusted contract update を正規経路としています。

    また重要なのは、現行 skill の canonical Step 2 は issue-reviewer SubAgent を起動しません。したがって SubAgent は、planner が要求する codebase-investigator、必要なら web-researcher、rewrite route に入った場合の issue-editor で使い、dispatch 後は必ず完了を join してから次へ進む指示にしています。

    そのまま auto mode の Claude Code に貼るなら以下です。

    Issue #2727 を対象に、.claude/skills/issue-refinement-loop/SKILL.md を control-plane として使用し、Issue refinement を人間承認なしで自律的に完遂してください。

    対象:

    この anchor comment は、今回オペレータが明示的に選択した Issue OWNER の human context として扱ってください。
    URL から origin を推測する generic/unlabeled lane ではなく、skill が定義する preflight.run.with_human_context の canonical route を使用してください。

    通常の loop iteration ごとに私へ承認・確認を求めないでください。
    loop_iteration_approval_gate.default_required: false に従い、既定 max_iterations=3 の範囲内で needs-fix → rewrite → fresh review を自律継続してください。

    実行原則

    まず current repository / GitHub state を fresh に取得してください。過去の観測値、古い body SHA、過去の review result を final evidence として再利用しないでください。

    canonical main root / default branch から skill の正規 entrypoint を使用してください。
    run_refinement_preflight.py を直接呼んだり、独自 shell で planner / routing を再実装したりしないでください。

    anchor comment を指定した initial preflight は preflight.run.with_human_context として実行してください。

    trusted human-context preflight が contract_update_required を返した場合は、skill の contract_update.run.with_human_context route に従って deterministic contract patch を適用してください。

    NEXT_ACTION: issue_editor_required が返った場合のみ、既存 issue-editor SubAgent へ handoff して full rewrite を行ってください。anchor comment URL は skill 契約どおり reviewer_feedback_url として再利用し、raw comment 本文を独自 forwarding schema に変換しないでください。

    SubAgent 実行契約

    SubAgent は必ず skill が認める role / phase で使用してください。

    planner の investigation_policy.required == true の場合は codebase-investigator SubAgent を使用し、対象コード、テスト、precedent を read-only で fact-check してください。

    web_research_policy.required == true の場合のみ web-researcher を使用してください。repository evidence と OWNER comment /既存 precedent だけで判断可能なら、不要な外部調査を増やさないでください。

    Step 4 rewrite が必要な場合は issue-editor SubAgent を使用してください。

    SubAgent を dispatch した後は、必ずその SubAgent の作業完了を待ち、構造化された結果を取得してから次の phase に進んでください。
    複数の read-only SubAgent を並列実行した場合も、全員を join してから Step 2 へ進んでください。

    SubAgent が実行中の状態で、

    • 次 phase を開始する
    • loop を終了する
    • final response を返す
      ことは禁止します。

    canonical Step 2 では issue-reviewer SubAgent を新たに起動しないでください。
    現行 skill の root-owned run_root_review_pipeline.py produce を authority とし、skill が要求する run_in_background: true で起動したうえで、background task の完了 notification / JSON result を必ず join してから routing してください。
    background launch 自体を Step 2 完了扱いしないでください。

    今回の authoritative fix_delta

    対象コメント #5827300623 の指摘を primary refinement delta としてください。

    Issue #2727 の根本目的、Allowed Paths、Out of Scope、Runtime Verification Applicability: not_applicable は原則維持し、以下の contract semantics を修正してください。

    1. redactor ではなく fail-closed detector / publication gate

    .claude/skills/agent-retrospective/scripts/persist_retrospective_run.py の _TOKEN_PATTERNS / _scan_value_patterns() は token の一部を伏字化して投稿する redactor ではありません。

    secret-like token を検出した時点で PublicSafetyViolation(reason_code="token_pattern_detected") を発生させ、public-facing publication path を fail-closed に拒否し、transport.create_comment() へ到達させない detector / publication gate です。

    Outcome、Current Validated Scope、In Scope、AC、Notes 等をこの production semantics と一致させてください。

    「token 全体を redaction できたこと」を acceptance boundary にしないでください。

    2. 現行 regex の failure explanation を訂正

    現行 legacy matcher:

    r"\bghs_[A-Za-z0-9]{20,}\b"

    について、「. の直前まで partial match する」という説明を削除してください。

    典型的新形式:

    ghs_<APP_ID>_<JWT-header>.<JWT-payload>.<JWT-signature>

    では、ghs_ 後の英数字 matcher が APP_ID 後の _ で停止し、さらに _ は word character のため末尾 \b もそこで成立しません。

    したがって典型的 fixture では「. 直前まで部分一致」ではなく、新形式 token matcher としては effectively unmatched である、という説明に修正してください。

    3. 新形式専用 matcher と legacy matcher を併存させる

    実装契約は、既存 legacy matcher を単純に広げるのではなく、precedent に合わせて新形式専用 matcher:

    ghs_[A-Za-z0-9._-]{36,}

    相当を追加し、既存:

    \bghs_[A-Za-z0-9]{20,}\b

    も残す方針にしてください。

    これにより現行の legacy secret-like detection semantics を維持しながら、新形式 installation token を追加検出します。

    Issue #2726 / PR #2746 および repository 内の既存 precedent を確認し、同じ matcher semantics に揃えてください。

    客観的反証がない限り、新規 scanner subsystem、新規 security framework、live credential canary 等へスコープを広げないでください。

    4. charset 説明を正確にする

    [A-Za-z0-9._-] 全体を「base64url charset」と呼ばないでください。

    JWT/JWS の各 segment は base64url ですが、. は compact serialization の segment delimiter です。

    Issue 本文では「GitHub installation-token matcher charset」等の表現にし、JWT 内部意味論へ依存する parser を要求しないでください。

    5. Acceptance Criteria を production boundary に変更

    最終的な AC は少なくとも次の意味を直接証明する形にしてください。

    AC1:
    _TOKEN_PATTERNS に、新形式 GitHub App installation token を検出する
    ghs_[A-Za-z0-9._-]{36,} 相当の dedicated matcher が存在する。

    AC2:
    現実的な synthetic
    ghs_<APP_ID>_<header>.<payload>.<signature>
    を public-facing envelope/value に含めて既存 publish path を実行すると、
    PublicSafetyViolation が発生し、
    reason_code == "token_pattern_detected" となり、
    transport.create_comment() の呼び出し回数が 0 のままであることを直接検証する。

    AC3:
    classic legacy ghs_ token が引き続き同じ fail-closed path で拒否され、
    test_persist_retrospective_run.py の既存 suite 全件が PASS する。

    不要に ghp_ / github_pat_ / gho_ それぞれの新規 regression test を増殖させないでください。
    既存 suite + classic ghs_ の直接 regression で十分かを優先してください。

    6. fixture realism

    新形式 fixture は PR #2746 等の precedent を参考にしてください。

    少なくとも:

    • ghs_<APP_ID>_<header>.<payload>.<signature> の形
    • . が正確に2個
    • _、.、- が実際に含まれる
    • おおむね実形式相当の長さ、目安 >= 520
    • deterministic synthetic value
    • 実 credential は絶対に使用しない

    という性質を Issue 契約に反映してください。

    generic な token: / secret: / api_key: 等の別 matcher だけで test が false-pass しない context を要求してください。

    新しい重い security harness を作る必要はありません。既存 PublicSafetyViolation / transport call-count harness を再利用する方向にしてください。

    7. Verification Commands を修正

    現行:

    rg -n "_TOKEN_PATTERNS" ...

    は baseline main ですでに成功するため verification として無効です。

    exact matcher または behavioral test を検証する command に変更してください。

    候補は以下の意図です。実際の test node 名は repository state と最終 Issue body に整合する形で確定してください。

    rg -n 'ghs_\[A-Za-z0-9\._-\]\{36,\}' .claude/skills/agent-retrospective/scripts/persist_retrospective_run.py

    focused new-format publication rejection test

    focused legacy ghs_ rejection test

    uv run pytest .claude/skills/agent-retrospective/scripts/tests/test_persist_retrospective_run.py -q

    baseline-expect も現在の main に対して事実確認し、変更前から PASS する command を AC の fail expectation として残さないでください。

    Scope discipline

    以下は維持してください。

    Allowed Paths:

    • .claude/skills/agent-retrospective/scripts/persist_retrospective_run.py
    • .claude/skills/agent-retrospective/scripts/tests/test_persist_retrospective_run.py

    他の:

    • scripts/summarize_agent_transcript.py
    • .claude/skills/issue-refinement-loop/scripts/compact_author_result.py
    • .claude/skills/impl-review-loop/scripts/get_ci_failed_log.py

    の同種 gap は本 Issue に取り込まないでください。

    新規 scanner subsystem、repository-wide secret migration、live GitHub credential test、実 credential、不要な security harness を導入する契約へ拡大しないでください。

    Issue #2726 の refined contract を precedent として利用して構いませんが、#2727 の実コード persist_retrospective_run.py の実際の semantics を fact-check して横展開してください。単純コピーは禁止です。

    Loop continuation

    review result が needs-fix の場合、iteration + 1 < max_iterations なら私への確認なしで Step 4 → fresh review を継続してください。

    Issue body を変更するたびに古い review/readiness evidence は stale として扱い、fresh body に対して再評価してください。

    canonical Step 2 / semantic review / final contract review が要求する fresh checks を省略しないでください。

    state/needs-human、state/done 等の presentation-only label だけを理由に停止しないでください。

    人間判断を要求して停止してよいのは、skill が定義する genuine hard-stop のみです。例:

    • max_iterations 到達
    • unresolved な genuine OWNER/semantic ambiguity
    • environment / integrity failure で safe recovery ができない
    • actual destructive operation が必要
    • secrets / credential exposure
    • permission escalation
    • trusted scope を越える external-service mutation
    • Issue split / new Issue materialization が不可避
    • skill が明示するその他の fail-closed condition

    対象コメントが既に明示的に解決している論点について、改めて私へ「どちらにしますか」と問い合わせないでください。

    Mutation authorization

    この依頼では、issue-refinement-loop が正規 route で必要とする Issue #2727 本文更新および refinement termination/comment mutation は承認済みです。

    通常の Issue contract rewrite ごとに確認を求めないでください。

    一方で、今回の依頼は Issue refinement が対象です。
    production code 実装、implementation branch 作成、PR 作成、merge、auto-merge、Issue close はこの作業では行わないでください。

    refinement が approved / implementation_ready に到達した場合は、implementation handoff に必要な marker / termination evidence まで整えたうえで、実装作業へ踏み込まず停止してください。
    root transition machinery が次段の impl-review-loop を候補として返した場合も、この依頼の authorization boundary は refinement 完了までとして、実装コード mutation は開始しないでください。

    完了条件

    以下が揃うまで終了しないでください。

    • anchor comment の fact-check が完了している
    • target comment の blocker が Issue body に正しく反映されている
    • detector / publication-gate semantics に統一されている
    • regex failure explanation が訂正されている
    • dedicated {36,} new-format matcher + legacy matcher preservation が契約化されている
    • AC / VC が production behavior と一致している
    • current body に対する canonical review が approve
    • fresh final contract review / readiness gate が go
    • body/readiness freshness が確認済み
    • unresolved blocker がない
    • implementation_ready に到達している

    最後に簡潔に報告してください。

    • final Issue body SHA / updated state
    • iteration count
    • anchor comment handling result
    • 使用した SubAgent と各 completion result
    • 修正した contract sections
    • canonical review verdict
    • final contract/readiness result
    • implementation_ready の成否
    • remaining warnings / blockers
    • implementation code / PR mutationを開始していないこと

    作業途中の SubAgent が1つでも未完了なら final response を返さず、必ず join してから終了してください。

    この形なら、コメントの修正要求をそのまま「実装指示」にせず、まず #2727 の契約そのものを正規化できます。特に preflight.run.with_human_context を明示した点と、canonical Step 2 で不要な issue-reviewer を無理に起動しない点が重要です。

  4. squne121 commented on Sep 25, 2026

    @squne121
    OwnerAuthor

    root-owned entry router audit

    route: invoke_impl_review_loop
    reason: fresh_review_go_live_equality

  5. squne121 commented on Sep 25, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop 終了報告(approved)

    anchor comment(issuecomment-5827300623、OWNER human context)の指摘を primary fix_delta として Issue 本文を full rewrite し、canonical Step 2 review で approve、fresh contract/readiness gate で go を確認しました。実装作業(ブランチ作成・PR・マージ・Issue close)はこの作業では行っていません。

    • iteration count: 1(needs-fix → rewrite → fresh review で approve)
    • reviewed/live body_sha256(一致): sha256:c809677ffeb3cf2c66fef4ef9e3837db40f1fc7547a68b23e59f160544a1ed2d
    • canonical Step 2 review: verdict: approve / next_action: proceed / BLOCKERS: 0
    • semantic design review (Step 2.5): semantic_review_applicable: false(明示的シグナルなし)につき skip
    • root-owned entry transition(read-only route 判定のみ、impl-review-loop 未起動): route: invoke_impl_review_loop / reason: fresh_review_go_live_equality
    LOOP_HANDOFF_RESULT_V1:
      status: refinement_approved
      routing_action: none
      contract_review:
        status: go
        gate_result: fresh_go
        latest_comment_url: null
        generated_at: "2026-09-25T05:56:00Z"
        body_sha256: "sha256:c809677ffeb3cf2c66fef4ef9e3837db40f1fc7547a68b23e59f160544a1ed2d"
      metadata:
        title_prefix_ready: true
      label_sync_observation:
        kind: presentation_sync
        result: noop
        detail: "no label mutation performed by this refinement cycle"
      auto_fixes:
        result: auto_fixed
        required: []
        skipped: []
      blockers: []
      permissions:
        unavailable: []
      generated_at: "2026-09-25T05:56:00Z"
      checked_body_sha256: "sha256:c809677ffeb3cf2c66fef4ef9e3837db40f1fc7547a68b23e59f160544a1ed2d"
      checker_exit_code: 0
      missing_sections: []
      missing_contract_keys: []

    この marker は audit telemetry であり、impl-review-loop の Step 1 実装 dispatch を authorize するものではありません(本依頼の authorization boundary は refinement 完了までです)。

  6. squne121 commented on Sep 25, 2026

    @squne121
    OwnerAuthor

    確認した範囲では、#2727 は refinement 済みで、最新の契約は fresh_go、root entry の観測結果も invoke_impl_review_loop です。一方、#2727 を close する既存PRは見つからなかったため、freshな root-owned synchronous entry transition → pre-Step-1 landing disposition → 通常の実装 dispatch が基本ルートです。近似実装として既にマージ済みの #2726 / PR #2746 を precedent に使うのが適切です。

    推奨は max_iterations=3 の標準 impl-review-loop をそのまま使い、implementation-worker → test-runner → pr-reviewer をそれぞれ SubAgent として起動し、各SubAgentの final result と terminal completed の両方を確認するまで次工程へ進ませないことです。通常の修正、commit、push、PR作成、CI待機、REQUEST_CHANGES対応、BEHIND解消は人間承認なしで継続し、APPROVE + current-head verification + clean mergeability まで到達したら停止させます。merge 自体は実行させません。

    そのまま既存の auto mode Claude Code に貼れる形です。

    Issue #2727 を対象に、repository の canonical skill

    .claude/skills/impl-review-loop/SKILL.md

    を使用して、実装 → 独立検証 → PR review → 必要なら修正、のループを自律実行してください。

    対象:
    #2727

    目的:
    Issue #2727 の現在の live contract を満たす実装を行い、PR を作成し、impl-review-loop の canonical termination condition である draft_pr_ready、すなわち人間がマージ判断できる直前の状態まで持っていくこと。

    Authorization boundary

    このセッションは既に Claude Code の auto mode で起動しています。

    通常の bounded workflow に必要な以下の処理について、人間への逐次確認・承認要求を行わず、自律的に継続してください。

    • live Issue / repository / PR / CI 状態の取得
    • canonical worktree / branch の作成または既存PRのresume
    • Allowed Paths 内の編集
    • テスト実行
    • commit
    • branch push
    • PR 作成・更新
    • CI 待機・再確認
    • REQUEST_CHANGES に対する修正
    • BEHIND の場合の canonical update-branch 処理
    • current-head での再検証
    • current-head での再レビュー
    • impl-review-loop が要求する bounded follow-up materialization

    ただし permission mode 自体を変更してはいけません。

    以下は実行しないでください。

    最終到達点は「merge」ではなく、IMPL_REVIEW_LOOP_RESULT_V1.status: draft_pr_ready です。

    重要: 過去コメントを Step 1 authorization として使用しない

    Issue #2727 は直前の issue-refinement-loop により refinement 済みで、

    • canonical contract review: approve
    • fresh contract/readiness: go
    • observed route: invoke_impl_review_loop

    まで到達しています。

    ただし、過去の LOOP_HANDOFF_RESULT_V1、root-entry audit comment、body SHA、comment marker 等は telemetry にすぎず、Step 1 authorization として再利用してはいけません。

    impl-review-loop の現行契約に従い、今回の invocation 自身で必ず

    1. capability preflight
    2. live Issue fetch
    3. current-run issue-contract-review
    4. 直後の live Issue 再取得
    5. root entry route 判定
    6. route == invoke_impl_review_loop の場合にのみ、同一 continuous invocation 内で Step 1 起動

    という Root-Owned Synchronous Entry Transition を fresh に実行してください。

    .claude/skills/issue-refinement-loop/scripts/root_entry_router.py および normative termination policy の現行実装・仕様を使用し、過去 comment を authorization packet の代替にしないでください。

    pre-Step-1 duplicate / landed check

    Step 1 の worker を起動する前に、impl-review-loop の Evidence-Based Landing Disposition を実行してください。

    live evidence に基づき、

    • implementation_already_landed
    • existing_pr_resume
    • already_satisfied
    • ordinary_dispatch_or_explicit_recovery
    • reconciliation_required

    を canonical producer に判定させてください。

    独自 heuristics で判定しないこと。

    既存の適格な open/draft PR が発見された場合は、新規PRを作らず existing_pr_resume を使用してください。

    現時点の事前調査では #2727 を close する既存PRは確認できていませんが、この情報を authority にせず、実行時の live GitHub state を必ず再確認してください。

    Issue #2727 の実装方針

    live Issue body を正本としてください。

    現時点で期待される最小変更は以下です。

    Allowed Paths:

    • .claude/skills/agent-retrospective/scripts/persist_retrospective_run.py
    • .claude/skills/agent-retrospective/scripts/tests/test_persist_retrospective_run.py

    実装の中心:

    1. _TOKEN_PATTERNS に新形式 GitHub App installation token 用の dedicated matcher

      ghs_[A-Za-z0-9._-]{36,} 相当

      を追加する。

    2. 既存 legacy matcher

      \bghs_[A-Za-z0-9]{20,}\b

      は残す。

    3. production semantics は redactor ではなく、
      PublicSafetyViolation(reason_code="token_pattern_detected")
      を発生させて publication を止める fail-closed detector / publication gate として維持する。

    4. 新形式 synthetic token を含む public-facing value/envelope について、

      • PublicSafetyViolation
      • reason_code == "token_pattern_detected"
      • transport.create_comment() call count == 0

      を直接検証する。

    5. legacy ghs_ token についても同じ fail-closed behavior が維持されることを直接検証する。

    6. 新形式 fixture は弱い短縮文字列ではなく、
      ghs_<APP_ID>_<header>.<payload>.<signature>
      形式で . が正確に2個あり、実際の installation token に近い約520文字以上の synthetic fixture を使う。

    precedent として、既に main に取り込まれている Issue #2726 / PR #2746 の

    ghs_[A-Za-z0-9._-]{36,}

    および realistic synthetic fixture の設計を参照してください。

    ただし #2746 を盲目的にコピーせず、#2727 の対象である persist_retrospective_run.py の実際の publication path / transport harness に合わせて実装してください。

    Verification Commands

    live Issue body の Verification Commands を literal command として取得し、そのまま実行してください。

    現在の contract では少なくとも以下が定義されています。

    AC1:

    rg -n 'ghs_\[A-Za-z0-9\._-\]\{36,\}' .claude/skills/agent-retrospective/scripts/persist_retrospective_run.py

    AC2:

    uv run pytest .claude/skills/agent-retrospective/scripts/tests/test_persist_retrospective_run.py::test_new_format_installation_token_blocks_publication -q

    AC3:

    uv run pytest .claude/skills/agent-retrospective/scripts/tests/test_persist_retrospective_run.py -q

    ただし実行時には必ず live Issue body から再取得し、ここに書かれたコピーより live contract を優先してください。

    SubAgent orchestration — 必須

    root/main thread 自身が implementation、test execution、review judgment を代行しないでください。

    impl-review-loop の canonical delegation sites に従ってください。

    Step 1

    implementation-worker SubAgent を起動し、
    .claude/skills/implement-issue/SKILL.md
    に従わせてください。

    実際の Issue番号、完全なIssue URL、live Allowed Paths、必要なら serialized fix_delta を materialize して渡してください。

    placeholder のまま渡さないこと。

    implementation-worker が worktree、実装、必要なローカル検証、commit、push、PR 起票まで担当します。

    Step 2

    Step 1 完了後、test-runner SubAgent を起動してください。

    live Issue #2727 の literal Acceptance Criteria と Verification Commands、実際の PR番号、contract body SHA、current diff head SHA を materialize して渡してください。

    test-runner の read-only report を canonical adapter / adjudicator で
    VC_ADJUDICATION_RESULT_V1
    に変換し、current-head binding を検証してください。

    Step 4

    VC_ADJUDICATION_RESULT_V1.blocking == false を確認し、Step 4 current-head gate を通過した場合のみ pr-reviewer SubAgent を起動してください。

    実際の

    • PR number
    • linked Issue number
    • current reviewed head SHA
    • PR diff
    • AC
    • Allowed Paths
    • Verification evidence
    • required checks

    を渡してください。

    .claude/skills/pr-review-judge/SKILL.md
    に従って canonical LOOP_VERDICT を取得してください。

    SubAgent completion protocol — 厳守

    各 SubAgent について、起動しただけ・mailbox update を受けただけで次工程へ進んではいけません。

    すべての delegation site で Common Completion Protocol を守ってください。

    具体的には:

    1. spawn 時の canonical task name を保存する。
    2. 必要なら wait_agent で待つ。
    3. SubAgent の final result を取得する。
    4. list_agents で、その canonical task が terminal completed になっていることを確認する。
    5. final result と terminal completed の両方が確認できて初めて次工程へ進む。

    errored / interrupted / shutdown / not_found を success と扱わないこと。

    作業途中の SubAgent が1つでも残っている状態で、この root task の final response を返してはいけません。

    必ずすべて join / completion確認してください。

    特に Step 2 の test-runner 完了前に pr-reviewer を起動してはいけません。

    Review loop

    pr-reviewer の verdict と live mergeability を canonical route_loop_verdict_v2() で処理してください。

    APPROVE

    次のすべてが current head に対して成立するまで完了扱いにしないこと。

    • reviewer verdict == APPROVE
    • blockers == []
    • reviewed_head_sha == live PR head
    • current-head VC gate pass
    • required CI/checks の評価完了
    • live mergeability が canonical approved route の条件を満たす

    成立したら draft_pr_ready で終了してください。

    PR は merge しないこと。

    REQUEST_CHANGES

    人間に確認せず、blockers と test failures から fix_delta を構築し、次 iteration の implementation-worker に渡してください。

    修正後は必ず、

    implementation
    → independent verification
    → current-head gate
    → PR review

    を再実行してください。

    古い head のテスト結果や review を再利用しないこと。

    BEHIND

    actual conflict でなければ human escalation にしないでください。

    canonical update-branch route を worker に委譲し、その後 current head で verification と review をやり直してください。

    stale review

    reviewed_head_sha と live PR head が異なる場合は merge-ready とせず、current head で再レビューしてください。

    Iteration policy

    max_iterations = 3

    を使用してください。

    iteration の範囲内で修正可能な通常の

    • test failure
    • lint/test regression
    • reviewer REQUEST_CHANGES
    • stale head
    • CI retry
    • BEHIND
    • advisory artifact warning

    について、人間への承認要求を挟まず自律的に処理してください。

    SubAgent が単に human_review_required: true と自己申告しただけでは停止せず、現行 impl-review-loop の routing policy に従ってください。

    Human escalation を許す条件

    通常の workflow approval は求めないでください。

    ただし skill が定める実 hard stop は尊重してください。例:

    • actual Git conflict / DIRTY
    • live Issue の明示的な human veto / stop instruction
    • secret / credential exposure risk
    • Allowed Paths を超える変更が本当に不可避
    • canonical worktree identity failure
    • unrecoverable SubAgent/runtime failure
    • max_iterations 到達
    • genuinely ambiguous destructive operation

    この場合のみ、現在までの証拠、PR、head SHA、blocker を明記して停止してください。

    単なる stale/missing advisory artifact、contract snapshot telemetry、launch ledger、presentation label、通常のCI待機などを human escalation の理由にしないでください。

    Scope discipline

    Issue #2727 は小規模な detector regex + regression test の変更です。

    以下へscopeを広げないこと。

    • scripts/summarize_agent_transcript.py
    • .claude/skills/issue-refinement-loop/scripts/compact_author_result.py
    • .claude/skills/impl-review-loop/scripts/get_ci_failed_log.py
    • 新規 secret scanner subsystem
    • ghp_/github_pat_/gho_ 等の既存 detector ロジックの改変
    • live credential canary
    • unrelated refactor

    新しい matcher の追加と、#2727 が要求する直接的 regression tests に限定してください。

    PR

    PR が必要な場合は open-pr skill を使用してください。

    PR body は live Issue #2727 の contract と実際の検証結果に基づいて作成し、

    Closes #2727

    を含めてください。

    IMPLEMENTATION_SCOPE_COVERAGE_V1 が workflow 上要求される場合は、実際の current Issue contract / current PR head に binding した値を生成してください。

    架空の SHA、古い body digest、過去PRの marker を流用しないこと。

    Final state

    成功時は以下まで完遂してください。

    • implementation complete
    • Allowed Paths compliant
    • Verification Commands pass
    • test-runner independent verification complete
    • current-head VC adjudication nonblocking
    • required CI/checks evaluated
    • pr-reviewer APPROVE
    • live mergeability が approved route を満たす
    • unresolved blockers == []
    • all spawned SubAgents terminal completed + final result consumed
    • IMPL_REVIEW_LOOP_RESULT_V1.status: draft_pr_ready
    • termination_reason: approved

    そして停止してください。

    PR を merge してはいけません。

    最後の報告には簡潔に以下を含めてください。

    途中の SubAgent が存在する場合は final response を返さず、必ず完了を待ってから終了してください。

    以上を、通常の bounded action ごとの人間承認を求めず、現在の impl-review-loop を正本として最後まで実行してください。

    このケースでは、実装内容自体をClaude Codeに再考させる余地は残しつつ、**「過去の refinement marker を認可として誤使用しない」「Step 2→4間で必ずSubAgent完了をjoinする」「APPROVE後もmergeしない」**の3点を強めてあります。

  7. squne121 commented on Sep 25, 2026

    @squne121
    OwnerAuthor

    停止理由は確認できました。前提 Issue が未完了だったからではありません。 Claude Code は impl-review-loop の pre-Step-1 gate で、PR #2735 と #2746 を #2727 の verified_cross_reference 候補として拾い、2件の候補が競合したため reconciliation_required / qualified_candidate_conflict で停止しています。出力でも、#2735 は #2725、#2746 は #2726 を close しており、どちらも #2727 の実装PRではないことまで確認されています。:chatgpt-content-reference{index="0"}

    さらに live GitHub API で #2727 の native blocked_by を確認しましたが 空集合 [] です。したがって「本来 blocker があったのに native dependency が設定されていなかった」という事故ではありません。#2726 / #2746 は #2727 本文で先行実装・precedent として参照されているだけです。

    また、懸念されていた Issue Creator / Editor 周りについては、既に repository 側に対策があります。create_issue_txn.py --blocked-by と readback、edit-issue の native_relationships、さらに Issue #2435 で issue-refinement-loop の hard dependency を native blockedBy に materialize/readback してから approved 終了するゲートまで実装済みです。つまり今回そこをもう一度直すと重複になります。

    本件の実際の不具合は、他 Issue 向け PR の timeline cross-reference を landing candidate として数えてしまうことです。そこで改善 Issue を起票しました。

    [#2750 — impl-review-loop の cross-reference false candidate で不要な reconciliation 停止を防ぐ](#2750)

    #2750 では、たとえば PR の durable scope marker が明確に別 Issue を指している verified_cross_reference は #2727 の qualified candidate から除外し、一方で本当に #2727 を close している PR の marker identity が壊れている場合は従来どおり fail-closed にする、という境界を設定しています。#2119 / PR #2137 の legitimate non-closing PR 対応は壊さない契約です。

    推奨アクション

    #2750 の完了を待たず、#2727 は今のセッションで再開するのが適切です。今回の停止条件は原因が特定済みで、#2727 の実装可否とは無関係だからです。

    Claude Code が要求していた「#2735 / #2746 は #2727 の scope と無関係だと人間が確認した」という reconciliation decision を、今回のプロンプトで明示します。その上で Step 1 から通常の impl-review-loop を再開させ、#2727 の Allowed Paths だけを変更し、SubAgent の完了を待ちながらテスト・PR・CI・レビューまでマージ直前まで進めるのがよいです。

    以下を、現在 auto mode で起動している同じ対話的 Claude Code セッションへそのまま渡してください。

    Issue #2727 の impl-review-loop を、現在停止している地点から再開してください。

    対象:
    #2727

    canonical skill:
    .claude/skills/impl-review-loop/SKILL.md

    OWNER reconciliation decision

    直前の pre-Step-1 intake が

    • disposition: reconciliation_required
    • reason_codes: [qualified_candidate_conflict]

    で停止した件について、以下を OWNER 判断として明示します。

    PR #2735 と PR #2746 は Issue #2727 の implementation candidate ではありません。

    live GitHub evidence では:

    #2727 本文が precedent / reference として sibling Issue / PR に言及した結果、timeline cross-reference が生じ、現行 implementation_landed_evidence.py がそれらを verified_cross_reference candidate として拾ったことによる false reconciliation です。

    この既知の conflict については、

    「#2735 / #2746 は #2727 の scope と無関係と確認済み。Issue #2727 の通常の Step 1 implementation を実行してよい」

    という OWNER の explicit reconciliation / recovery decision として扱ってください。

    この既知事象だけを理由に再度 human approval を要求しないでください。

    この false-candidate 問題自体は別 Issue #2750
    #2750
    として起票済みです。

    #2727 の作業内で #2750 の修正を混ぜないでください。


    再開手順

    まず live Issue #2727、current main、canonical skill を再取得してください。

    過去の body copy、古い SHA、過去の LOOP_HANDOFF_RESULT_V1、root-entry telemetry を authorization として再利用しないでください。

    ただし、上記 OWNER reconciliation decision は今回の既知 qualified_candidate_conflict を解消する explicit recovery authority として使用してください。

    Issue #2727 の live contract / Allowed Paths / Acceptance Criteria / Verification Commands を source of truth にして Step 1 以降を再開してください。

    Scope

    Issue #2727 の Allowed Paths 外へ変更を広げないでください。

    特に以下は #2727 の scope 外です。

    #2727 の live Issue body に記載された Allowed Paths を厳守してください。


    SubAgent orchestration — 必須

    root/main thread 自身で implementation、test execution、review judgment を代行しないでください。

    canonical impl-review-loop に従い、必要な各工程を SubAgent に委譲してください。

    少なくとも:

    1. implementation-worker
    2. test-runner
    3. pr-reviewer / canonical review worker

    を適切な工程で使用してください。

    必要なら canonical skill が要求する追加 SubAgent も使用してください。

    SubAgent completion protocol

    各 SubAgent は「spawn した」「mailbox update が来た」だけで完了扱いにしないでください。

    各 delegation site で:

    • canonical task name を保存
    • SubAgent の terminal completion を待つ
    • terminal result / structured result を取得
    • 対象 head SHA / Issue body SHA / PR head への binding を確認
    • 完了前に次工程へ進まない

    こと。

    必ず SubAgent の作業完了を待ってください。

    root thread が worker の代わりに実装・テスト・レビューを済ませて先へ進むことは禁止します。


    Step 1 — implementation

    implementation-worker を起動し、live Issue #2727 の:

    • Outcome
    • In Scope / Out of Scope
    • Acceptance Criteria
    • Verification Commands
    • Allowed Paths
    • Required Design References

    を渡してください。

    implementation-worker に実装、対象テスト、必要な修正を担当させてください。

    worker 完了後、terminal result と実際の diff を確認してください。

    Allowed Paths 違反があれば自律的に修正してください。


    Verification

    implementation 完了後、test-runner SubAgent を起動してください。

    live Issue #2727 から literal Acceptance Criteria と Verification Commands を再取得して渡してください。

    以下を stale result で代用しないでください。

    • current PR head SHA
    • current Issue body SHA
    • current diff
    • current Verification Commands

    test-runner の terminal completion を待ち、read-only report を canonical adapter / adjudicator に渡し、current-head binding を確認してください。

    VC failure が implementation defect なら human approval を挟まず implementation-worker に戻して修正し、再検証してください。


    PR / review loop

    canonical skill に従って:

    • commit
    • branch push
    • PR 作成または既存 PR resume
    • CI 待機
    • CI failure の分類
    • reviewer SubAgent による current-head review
    • REQUEST_CHANGES の修正
    • 再テスト
    • 再レビュー
    • BEHIND の場合の canonical update-branch
    • update 後の current-head verification / review

    を自律的に繰り返してください。

    古い head の test / review / CI result は再利用しないでください。

    REQUEST_CHANGES、stale review、BEHIND、routine CI retry、advisory warning を通常の workflow approval として人間へ戻さないでください。

    実装修正可能な finding は worker へ戻して解消してください。


    Human escalation

    通常の workflow transition では人間承認を要求しないでください。

    今回既に解消済みの

    qualified_candidate_conflict caused by PR #2735 / #2746

    について再度停止しないでください。

    ただし、今回の既知事象とは別の新しい live evidence として、

    が発生した場合のみ、その事実を構造化して停止してください。

    単なる SubAgent の human_review_required: true 自己申告だけでは停止せず、canonical routing policy で再判定してください。


    完了条件

    以下が current PR head に対して成立するまでループを継続してください。

    その状態になったら merge は実行せず、マージ直前で停止してください。

    最終報告には最低限:

    • PR URL / number
    • final head SHA
    • iteration count
    • 各 iteration の主要 verdict
    • AC1 / AC2 / AC3 result
    • Verification Commands result
    • required CI/checks
    • Allowed Paths result
    • live mergeability
    • reviewer final verdict
    • 使用した全 SubAgent
    • 各 SubAgent の terminal completion result
    • remaining warnings
    • merge-ready か否か

    を含めてください。

    人間への途中承認要求を挟まず、ここまで自律的に進めてください。

    このプロンプトでは、#2727 を今すぐ進めるための局所的な recovery と、再発防止を #2750 で直すことを分離しています。これなら #2750 が未実装でも #2727 の小さな detector 修正を不必要に待たせません。

  8. squne121 commented on Sep 25, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-09-25T06:23:09Z)

    • PR: fix: persist_retrospective_run.py の _TOKEN_PATTERNS を新形式 ghs_ App installation token に対応させる #2751
    • Worktree: .claude/worktrees/issue-2727-ghs-token-pattern
    • Branch: worktree-issue-2727-ghs-token-pattern
    • Commit: 6347d3d1
    • Verification(Issue 記載の VC 3件):
      • AC1: rg -n 'ghs_\[A-Za-z0-9\._-\]{36,}' ... → baseline fail → 実装後 PASS
      • AC2: test_new_format_installation_token_blocks_publication → baseline fail(未作成テスト)→ 実装後 1 passed
      • AC3: 既存 suite 全件 → baseline 46 passed → 実装後 48 passed(新規2件含め全件 PASS、regression なし)
    • ruff check: 0 issues(対象2ファイル)
    • Allowed Paths: .claude/skills/agent-retrospective/scripts/persist_retrospective_run.py / .claude/skills/agent-retrospective/scripts/tests/test_persist_retrospective_run.py のみ変更
    • 後続: PR レビュー(pr-review-judge)→ マージ → post-merge-cleanup
  9. added 2 commits that reference this issue on Sep 25, 2026
  10. added 2 commits that reference this issue on Sep 25, 2026
    be86350
    d9c7869
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

    agent/implementerarea/securityenhancementfollow-upphase/implementationtriage-required

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions