Skip to content

実装: get_ci_failed_log.py の diagnostic/error 出力を redact_tokens() 経由に統一する #2759

Open

Description

@squne121

Machine-Readable Contract

contract_schema_version: 1
issue_kind: implementation
parent_issue: "none"
goal_ref: "docs/dev/secret-policy.md"
change_kind: "redaction-bypass-fix"

Parent Issue

なし(単独改善 / Issue #2728 のレビュー中に発見した follow-up)

Parent Goal Ref

なし(親 Issue なし)。参照する正本は docs/dev/secret-policy.md(no-secret 運用境界)。

Current Validated Scope

.claude/skills/impl-review-loop/scripts/get_ci_failed_log.py の main() 内、gh CLI 呼び出し結果に対する diagnostic/error 出力の 3 箇所のみ。redaction ロジック自体(redact_tokens() の実装や正規表現パターン)は変更しない。

Remaining Parent Gaps

なし。本 Issue 完了後、get_ci_failed_log.py の全 emit_result() 呼び出し経路が redact_tokens() を経由する状態になる想定。他ファイルの同種 gap(例: Issue #2686 が対象とする issue_relationship.update GraphQL error diagnostics)は本 Issue のスコープ外。

Outcome

.claude/skills/impl-review-loop/scripts/get_ci_failed_log.py の main() 内で emit_result() に diagnostic/error メッセージを渡している以下 3 箇所が、正常系ログ出力パス(main() L311 log_text, redaction_applied = redact_tokens(log_text))と同様に redact_tokens() を経由してから emit_result() に渡るよう修正されたコミットが存在する状態:

  • gh run view failed: {err.strip()}(L206 付近)
  • gh run list failed: {err.strip()}(L237 付近)
  • Failed to parse gh output: {out[:200]}(L247 付近)

修正後、各箇所の emit_result(...) 呼び出しに渡る redaction_applied 引数値が redact_tokens() の実際の適用結果(token を検出・置換した場合は True)を正しく反映しており、get_ci_failed_log.py --help 相当の import と redact_tokens の単体呼び出しに対する新規 pytest ケースが green である状態。

Runtime Verification Applicability

  • decision: not_applicable
  • reason: 静的な diagnostic 出力経路の redaction 適用有無は grep/rg と pytest の決定論的検証で完結するため

In Scope

  • main() 内、gh run view 失敗時の emit_result(log_text=f"gh run view failed: {err.strip()}", ...) 呼び出し前に err を redact_tokens() に通し、結果の redaction_applied を渡す
  • main() 内、gh run list 失敗時の emit_result(log_text=f"gh run list failed: {err.strip()}", ...) 呼び出し前に err を redact_tokens() に通し、結果の redaction_applied を渡す
  • main() 内、gh run list の JSON パース失敗時の emit_result(log_text=f"Failed to parse gh output: {out[:200]}", ...) 呼び出し前に out[:200] を redact_tokens() に通し、結果の redaction_applied を渡す
  • 上記 3 箇所を対象にした新規 pytest(token を含む fake err/out を与えた場合に redaction 済み文字列が stdout に出力され、redaction_applied: true を含む JSON が返ることを検証する)の追加
  • 既存の同ファイル test file(Allowed Paths に記載の 2 候補パスのうち、実際に存在する方)への追記

Out of Scope

Acceptance Criteria

  • AC1: gh run view 失敗時の diagnostic message (gh run view failed: ...) が redact_tokens() を経由してから emit_result() に渡る
  • AC2: gh run list 失敗時の diagnostic message (gh run list failed: ...) が redact_tokens() を経由してから emit_result() に渡る
  • AC3: gh run list の JSON パース失敗時の diagnostic message (Failed to parse gh output: ...) が redact_tokens() を経由してから emit_result() に渡る
  • AC4: 上記 3 経路で redact_tokens() が token を検出した場合、emit_result() に渡る redaction_applied 引数が True になる
  • AC5: AC1〜AC4 を検証する新規 pytest ケースが追加され green である

Verification Commands

# AC1
$ rg -n "redact_tokens\(err\)" .claude/skills/impl-review-loop/scripts/get_ci_failed_log.py
# AC2
$ rg -c "redact_tokens\(err\)" .claude/skills/impl-review-loop/scripts/get_ci_failed_log.py
# AC3
$ rg -n "redact_tokens\(out" .claude/skills/impl-review-loop/scripts/get_ci_failed_log.py
# AC4
$ rg -c "redaction_applied=redaction_applied" .claude/skills/impl-review-loop/scripts/get_ci_failed_log.py
# AC5
$ uv run pytest tests/impl_review_loop/test_get_ci_failed_log.py -v

Allowed Paths

Stop Conditions

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

Required Skills

なし

Required Design References

なし(docs/dev/secret-policy.md の no-secret 運用境界を踏まえるのみで、追加の設計参照は不要)

Delivery Rule

Notes for Reviewer

  • 優先度: optional_follow_up(低優先度)。実クレデンシャル漏洩インシデントは未確認であり、プロアクティブな gap 解消が目的。緊急対応は不要
  • tests/impl_review_loop/test_get_ci_failed_log.py が現時点(2026-09-25, main HEAD e3ee04c6)で存在する test file であることを確認済み。.claude/skills/impl-review-loop/tests/test_get_ci_failed_log.py はまだ存在しない(Issue 実装: get_ci_failed_log.py の KNOWN_TOKEN_PATTERN を新形式 ghs_ App installation token に対応させる #2728 のテスト移動が先行する場合に備えて Allowed Paths の候補に含めている)
  • dedupe_key: follow-up:squne121/loop-protocol:issue-2728:diagnostic-redaction-bypass
  • keyword search(diagnostic-redaction-bypass / redact_tokens emit_result get_ci_failed_log)で同一 concern を対象にした既存 OPEN/CLOSED Issue は見つからなかった

Notes for Reviewer(続き: overlap preflight)

Allowed Paths ベースの overlap preflight(check_issue_overlap.py)実行結果: decision: overlap_requires_comment(policy_class C1)。

  • #2728 と .claude/skills/impl-review-loop/scripts/get_ci_failed_log.py が overlap(本 Issue の Notes ですでに言及済み。hard dependency は設定しない方針に変更なし)
  • #1390 / #420 は tests/impl_review_loop/test_get_ci_failed_log.py の親ディレクトリ tests の bare path 一致による false positive(対象ファイルもテーマも本 Issue と無関係)と判断し、対応不要

Source

Issue #2728(.claude/skills/impl-review-loop/scripts/get_ci_failed_log.py の KNOWN_TOKEN_PATTERN 拡張)のレビュー中、repository investigation により発見。参照コメント: #2728 (comment)

Activity

  1. squne121 commented on Sep 25, 2026

    @squne121
    OwnerAuthor

    create-issue transaction partial-failure

    Issue: #2759
    Failure stage: label-apply
    Message: label-apply failed

    Requested:

    • labels: phase/implementation, agent/implementer, enhancement, area/security, follow-up, optional_follow_up
    • parent: (none)
    • blocked-by (dependencies): (none)
    • blocking: (none)
      Completed steps: create

    Failure context: command=gh issue edit --repo squne121/loop-protocol 2759 --add-label phase/implementation,agent/implementer,enhancement,area/security,follow-up,optional_follow_up
    output=failed to update #2759: 'optional_follow_up' not found
    failed to update 1 issue
    matching_issue_numbers=[2759]
    issue_number=2759

    Recovery hint: stage 'label-apply' encountered an unexpected failure.
    Generic guidance: verify the issue state manually and re-run the transaction if safe.
    gh issue view 2759 --repo squne121/loop-protocol --json number,title,labels,state
    idempotent re-run: depends on the specific failure

    Please recover deterministically before re-running the create issue transaction.

  2. added
    enhancement
    phase/implementation
    agent/implementer
    area/security
    follow-up
    on Sep 25, 2026
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/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions