Repository navigation
Description
Parent Issue
なし(単独改善)
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "PR #2310 CI failure triage(run 32617957047)で発覚した、test_isolated_anchor_single_authority.py の transient-failure skip判定が実際にproductionが返すGH_API_FAILURE blockerを見落とし、rate-limit等のtransient環境要因でhard failureになる問題を、構造化reason_codeベースの判定へ改修する。あわせて #2257 AC4 が要求していた reason_code/source/operation の stdout 三値一貫投影の未実装差分を同時に解消する"
change_kind: codeParent Goal Ref
- Goal: なし(単独改善)
- Desired Destination: なし
Background(レビュー反映)
本 Issue はレビュー(#2317 (comment) )で REQUEST_CHANGES 相当の指摘を受けた。反映方針は以下の通り。
- 直接原因(
GH_API_FAILUREを丸ごと SKIP 対象に広げず、production が既に持つ構造化reason_codeを使う)は妥当と判断され、維持する。 - 一方、既存 canonical JSON schema は
environment_failureに対してreason_code/source/operationの3フィールドを必須にしており、実装: Claude-GPT issue-refinement preflight の anchor comment 取得を credentialless transport へ統一する #2257 AC4 はこの3フィールドすべての stdout 投影を要求していた。本 Issue はREASON_CODE:のみを追加する案だったため、JSON artifact(3フィールド)・compact stdout(reason_code のみ)・実装: Claude-GPT issue-refinement preflight の anchor comment 取得を credentialless transport へ統一する #2257 契約(3フィールドとも stdout 必要)の3者不一致が残っていた。これを解消し、environment_failureのときはREASON_CODE/SOURCE/OPERATIONの3行を一貫して出力する。 - formatter (
_build_compact_stdout()) の unit test は、既存の.claude/skills/issue-refinement-loop/tests/test_refinement_preflight.py::TestBuildCompactStdoutが正しい置き場所であり、scripts/agent-guards/tests/test_isolated_anchor_single_authority.pyからのimportlibcross-layer import で新設すべきではない。本 Issue の Allowed Paths にtest_refinement_preflight.pyを追加し、formatter contract のテストはそちらに置く。 - この live test(
test_isolated_anchor_single_authority.pyの live subprocess テスト)は merge-blocking な authoritative runtime evidence ではなく、外部 GitHub API 到達性に依存する best-effort live smoke test であると明文化する(ドキュメント上の位置付け明確化のみであり、本 Issue の scope である skip 判定の挙動自体は変更しない)。 - live test を独立 CI lane(non-blocking / scheduled)へ分離する設計変更は本 Issue のスコープ外とし、必要であれば follow-up Issue で扱う。
Current Validated Scope
scripts/agent-guards/tests/test_isolated_anchor_single_authority.pyのtest_ac5_ac6_skill_runtime_exec_with_human_context_live_subprocess_resolves_anchor_via_credentialless_authorityのtransient-failure skip判定を、構造化reason_code(productionが既に細分類済みの closed enum)ベースの判定へ置き換える- 上記判定に必要な
reason_code/source/operationを compact stdout から機械可読に取得可能にするため、.claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.pyの compact stdout renderer(_build_compact_stdout)に最小限の追加を行う(調査の結果、現状の compact stdout にはreason_code系フィールドが一切出力されておらず、artifact file も早期失敗時(_fetch_issue/_fetch_issue_comments/_fetch_single_comment失敗時)には書き出されないため、stdout露出が必須と判明。実装: Claude-GPT issue-refinement preflight の anchor comment 取得を credentialless transport へ統一する #2257 AC4 は3フィールドとも stdout 投影を要求していたため、reason_codeのみでなくsource/operationも同時に投影する) - formatter (
_build_compact_stdout()) の unit test は.claude/skills/issue-refinement-loop/tests/test_refinement_preflight.py::TestBuildCompactStdoutに追加する(既存の raw body/comment 非漏洩検証と同じファイルに contract test を集約する)
Remaining Parent Gaps
- なし
Outcome
scripts/agent-guards/tests/test_isolated_anchor_single_authority.py の対象テストが、compact stdout に environment_failure 時のみ一貫して露出する production 側の細分類済み REASON_CODE / SOURCE / OPERATION(REASON_CODE は closed enum: rate_limited / upstream_environment_failure / transport_connectivity_failure の系統のみ transient 判定)を根拠に skip 可否を判定するよう改修され、genuine failure(認証依存混入・404・bare 403・不正contract・間違った anchor・credentialless authority bypass・意図しない gh CLI フォールバック依存・production code 例外・duplicate/empty/malformed な REASON_CODE 行等)は一切 false-green にならないことが、test_isolated_anchor_single_authority.py(predicate/parser/live 挙動)と test_refinement_preflight.py::TestBuildCompactStdout(formatter contract)の両方に追加した決定論的 unit test で保証されている状態。あわせて、この live test が merge-blocking runtime evidence ではなく best-effort live smoke test であることが Background に明記されている。
Runtime Verification Applicability
- decision: not_applicable
- reason: 本 Issue の Verification Commands はすべて
_build_compact_stdoutおよび新設する transient 判定 predicate / parser を synthetic なresultdict / 文字列で直接呼び出す決定論的 pytest unit test であり、実プロセス起動・実ネットワーク通信・実 GitHub API 呼び出しを必要としない。既存の live subprocess テスト自体は本 Issue のスコープ外の既存機構であり、変更後もその実行結果検証はCI上の live 実行に委ねられる(当該 live test は best-effort live smoke test であり、authoritative runtime evidence ではない旨は Background 参照)。
In Scope
.claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.pyの_build_compact_stdout()に、result["status"] == "environment_failure"の場合のみREASON_CODE: <code>/SOURCE: <source>/OPERATION: <operation>の3行を(result["reason_code"]/result["source"]/result["operation"]の値を用いて)出力する最小限の追加を行う(status != "environment_failure"の場合は3行とも出力しない。raw body/comment 等の detail は引き続き出力しない)- 上記 production 変更に対する決定論的 unit test を
.claude/skills/issue-refinement-loop/tests/test_refinement_preflight.py::TestBuildCompactStdout内に新設する(synthetic なresultdict を_build_compact_stdout()に渡し、env failure 時に3行とも出ること/non-env failure 時に3行とも出ないこと/raw detail が漏れないことを検証する) scripts/agent-guards/tests/test_isolated_anchor_single_authority.pyに、compact stdout からREASON_CODE:行を厳密パースし、値が closed set{rate_limited, upstream_environment_failure, transport_connectivity_failure}の完全一致の場合にのみ transient と判定する predicate 関数を新設する(例:_is_transient_environment_failure_reason_code(reason_code: str) -> boolと、stdout から該当行を抽出する helper)。この抽出・判定は以下を満たす:REASON_CODE:行が stdout に exactly one 存在する場合のみ値を採用する(存在しない、または複数存在する場合は transient と判定しない=hard failure 側を維持)REASON_CODE:の値が空文字列の場合は transient と判定しない(hard failure 側を維持)- 想定外の malformed な行(prefix 不一致等)は transient と判定しない(hard failure 側を維持)
- stderr の内容は判定ソースとして一切使用しない(stdout のみを判定対象とする)
- transient closed set に含まれない未知の将来
reason_code(今回未定義のもの)はデフォルトで transient と判定しない(hard failure 側を維持し、false-green の拡大を防ぐ)
- 上記 predicate を
test_ac5_ac6_skill_runtime_exec_with_human_context_live_subprocess_resolves_anchor_via_credentialless_authority(900行目付近のskip判定ブロック)に適用し、既存の broad substring OR-chain("rate_limited" in stdout or "upstream_environment_failure" in stdout or ...)を置き換える - 上記 predicate/parser に対する決定論的 unit test を
scripts/agent-guards/tests/test_isolated_anchor_single_authority.py内に新設する(importlib.util.spec_from_file_locationでrun_refinement_preflight.pyを直接 import し、synthetic なresultdict を_build_compact_stdout()に渡して出力行を検証する。同ファイル内の_load_skill_runtime_exec_anchor_fixtures()が既に使っている同一パターンを踏襲する。ただし formatter そのものの contract test は上記の通りtest_refinement_preflight.py側に置き、本ファイルには stdout parser / transient predicate / live subprocess 挙動のテストのみを置く) - predicate の negative-case として、以下をすべて検証する unit test を追加する:
GH_API_FAILUREblocker のみが存在しREASON_CODE:行が存在しない stdout →FalseREASON_CODE:の値が transient closed set 外(例:unexpected_authentication_dependency/http_403_forbidden/canonical_resource_missing/gh_auth_required/malformed_response_body/transport_internal_error)→FalseREASON_CODE:行が重複して2回以上出現する stdout →FalseREASON_CODE:の値が空文字列の stdout →False
Out of Scope
run_refinement_preflight.pyの_project_environment_failure_reason()/_classify_final_environment_failure()等、reason_code の細分類ロジックそのものの変更(既に必要な細分類は保持されているため不要)- 同ファイル内の別テスト(205〜217行目付近、別関数の transient skip 判定)の改修(対象が異なる別テストであり、本 Issue の再現条件・背景に含まれないため)
- live test(
test_isolated_anchor_single_authority.pyの live subprocess テスト)を独立 CI lane(non-blocking / scheduled)へ分離する設計変更(Background 参照。本 Issue は位置付けの明文化のみを扱い、CI ワークフロー構成の変更は follow-up Issue で扱う) - 安易な
pytest.skip()対象文字列リストへの"GH_API_FAILURE"追加のみでの修正(Background 参照。genuine failure を false-green にするリスクがあるため)
Acceptance Criteria
- AC1:
run_refinement_preflight.pyの_build_compact_stdout()は、result["status"] == "environment_failure"のときREASON_CODE: <code>/SOURCE: <source>/OPERATION: <operation>の3行を出力する - AC2:
_build_compact_stdout()はresult["status"] != "environment_failure"のときREASON_CODE:/SOURCE:/OPERATION:のいずれの行も出力しない - AC3:
test_isolated_anchor_single_authority.pyに新設した transient 判定 predicate は、REASON_CODE:の値がrate_limited/upstream_environment_failure/transport_connectivity_failureの場合にTrueを返す - AC4: 同 predicate は、
REASON_CODE:行が存在せずBLOCKERS: GH_API_FAILUREのみが存在する stdout に対してFalseを返す - AC5: 同 predicate は、
REASON_CODE:の値が transient closed set 外の genuine reason code(unexpected_authentication_dependency/http_403_forbidden/canonical_resource_missing/gh_auth_required/malformed_response_body/transport_internal_errorのいずれか)の場合にFalseを返す - AC6:
test_ac5_ac6_skill_runtime_exec_with_human_context_live_subprocess_resolves_anchor_via_credentialless_authorityの skip 判定ブロックが AC3-AC5 の predicate を使用しており、旧来の broad substring OR-chain("rate_limited" in stdout or ...)が同ブロックから除去されている - AC7: 同 predicate は、
REASON_CODE:行が stdout に重複して2回以上出現する場合、または値が空文字列の場合にFalseを返す - AC8:
.claude/skills/issue-refinement-loop/tests/test_refinement_preflight.py::TestBuildCompactStdoutに、_build_compact_stdout()が env failure 時にREASON_CODE/SOURCE/OPERATIONの3行を出力し、non-env failure 時にはいずれも出力せず、raw body/comment 等の detail を漏らさないことを検証する unit test が追加されている
Verification Commands
# AC1
$ rg -n "def test_reason_code_source_operation_lines_emitted_for_environment_failure_status" scripts/agent-guards/tests/test_isolated_anchor_single_authority.py# AC2
$ rg -n "def test_reason_code_source_operation_lines_omitted_when_status_is_not_environment_failure" scripts/agent-guards/tests/test_isolated_anchor_single_authority.py# AC3
$ rg -n "def test_transient_environment_failure_predicate_true_for_transient_reason_codes" scripts/agent-guards/tests/test_isolated_anchor_single_authority.py# AC4
$ rg -n "def test_transient_environment_failure_predicate_false_without_reason_code_line" scripts/agent-guards/tests/test_isolated_anchor_single_authority.py# AC5
$ rg -n "def test_transient_environment_failure_predicate_false_for_genuine_reason_codes" scripts/agent-guards/tests/test_isolated_anchor_single_authority.py# AC6
$ rg -Fc "_is_transient_environment_failure_reason_code(" scripts/agent-guards/tests/test_isolated_anchor_single_authority.py# AC7
$ rg -n "def test_transient_environment_failure_predicate_false_for_duplicate_or_empty_reason_code" scripts/agent-guards/tests/test_isolated_anchor_single_authority.py# AC8
$ rg -n "def test_environment_failure_emits_reason_code_source_operation_and_no_raw_detail_leak" .claude/skills/issue-refinement-loop/tests/test_refinement_preflight.pyAllowed Paths
- scripts/agent-guards/tests/test_isolated_anchor_single_authority.py
- .claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py
- .claude/skills/issue-refinement-loop/tests/test_refinement_preflight.py
- pyproject.toml
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
Required Skills
- Python pytest(importlib.util によるモジュール直接ロード、monkeypatch 不要の synthetic dict 検証)
Required Design References
- docs/dev/runtime-verification-policy.md
Scope Delta(該当時のみ記載)
pyproject.toml(github_livepytest marker の docstring 1行の一般化: 「real GitHub API write access のみを対象とする記述」から「未認証の live GitHub REST/API 読み取りも対象に含む記述」への変更)を Allowed Paths に追加した。これは OWNER squne121 が PR fix: test_isolated_anchor_single_authority のtransient判定を構造化reason_codeベースに改修する #2319 の REQUEST_CHANGES レビューコメント(https://github.com/squne121/loop-protocol/pull/2319#issuecomment-5384827550)で本変更を明示的に事前承認し、「Issue の Allowed Paths を少し超える可能性がありますが…scope delta を許容する価値があります」と述べたことに基づく。関連 PR: fix: test_isolated_anchor_single_authority のtransient判定を構造化reason_codeベースに改修する #2319
Notes for Reviewer
- Scope Collision (C1, overlap preflight advisory):
Allowed Pathsに含めた.claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.pyは多数の既存 Issue(実装: fix: recover source evidence before refinement human escalation #2195, 実装: SHA-bound evidence index と command fingerprint budget で再読・重複調査・wait polling による context churn を抑制する #2052, 実装: run_refinement_preflight.py の結果に decisions フィールドを出力しSKILL.mdとのSSOT乖離を解消する #1556, 実装: fix(issue-refinement-loop): no-human-approval autonomy mode を loop state routing に明示する #1007, 実装: issue-refinement-loop の preflight result から LOOP_STATE を生成する route wrapper を追加し CLI/schema 迷走を防ぐ #1006 等)でも参照されている広く共有されたファイルである。本 Issue の変更は_build_compact_stdout()への3行追加(環境失敗時のみ)に限定した非破壊的追加であり、既存の他 Issue の作業と機能的に衝突しない想定(advisory のみで起票自体を止める理由にはならない旨は.claude/skills/create-issue/SKILL.md導入: AIエージェント運用をminimal harnessへ縮退し、過剰なcontrol-planeを廃止する #1860 Owner Decision に基づく) - 安易な
pytest.skip()対象文字列リストへの"GH_API_FAILURE"追加のみでの修正は禁止(Background 参照。genuine failure を false-green にするリスクがあるため) - 本 Issue は 実装: test_isolated_anchor_single_authority のtransient failure skip判定を構造化reason_codeベースに改修する #2317 (comment) のレビューを反映し、stdout 3フィールド一貫化・formatter test 配置修正・live test 位置付け明文化・strict parser AC 強化を Issue 本文へ取り込んだ(issue-refinement-loop 自律実行、2026-08-23)
Activity
squne121 commentedon Aug 23, 2026
結論
Issue #2317 は
REQUEST_CHANGES相当です。ただし、狙っている直接原因は正しいです。
GH_API_FAILURE自体を SKIP 対象に広げず、production が既に持っている structuredreason_codeを使う方向は採用すべきです。Issue 本文もそこは適切に限定できています。問題は、現在の仕様だと「今回の CI flake を直す」ことに寄りすぎて、既存 contract との矛盾と live-network test の置き場所という根本問題を固定化する点です。
P1 — #2257 で「未解決」とされた
pytest.skip()問題を、そのまま正式仕様化しているIssue #2257 は runtime verification を
immediateとし、GitHub API 到達不能を「SKIP ではなくenvironment_failureとして扱う」と要求していました。また AC4 は structuredreason_code/source/operationを artifact と stdout の両方へ一貫して出す契約でした。PR #2260 自身も、production-graph live test が rate-limit / connectivity / upstream failure で
pytest.skip()することを P1-6 の未解決残課題として明記してマージされています。 実際、現在の対象テストはその3分類が stdout/stderr に見つかればpytest.skip()します。 pytest におけるpytest.skip()は文字通りテストを skipped として終了させる API です。(pytest 公式ドキュメント)したがって #2317 は、既知の残課題を解決するのではなく、より正確に発火するようにしているだけです。
ただし、個人趣味開発で CI 可用性を優先するなら、私は「SKIP を禁止する」方向には戻しません。むしろ設計上の役割を変えるべきです。
これなら transient failure を SKIP にすることが設計上矛盾しません。逆に AC5/AC6 の authoritative runtime evidence と呼び続けるなら、SKIP green 化は矛盾したままです。
P1 —
REASON_CODE:だけ追加するのは、既存 structured contract の中途半端な再投影現在の canonical JSON schema はすでに
environment_failureに対して、reason_codesourceoperationの3フィールドを必須にし、非
environment_failureでは禁止しています。reason_code自体も closed enum です。一方 #2317 は stdout へ
REASON_CODE:だけ追加します。これは特にまずいのが、元の #2257 AC4 が3フィールドすべての stdout projection を要求していたことです。つまり今回
reason_codeだけ出すと、JSON artifact: 3フィールド
compact stdout: reason_code だけ
実装: Claude-GPT issue-refinement preflight の anchor comment 取得を credentialless transport へ統一する #2257 の契約: 3フィールドとも stdout に必要
という3者不一致が残ります。
修正案:
_build_compact_stdout()を触るなら一度で、を
environment_failure時だけ出す方がよいです。追加の taxonomy や security mechanism は不要です。既存 result dict の値を3行投影するだけなので、ここを別 Issue に分割するメリットはほぼありません。
P1 — formatter の unit test を置くファイルが間違っている
#2317 は
_build_compact_stdout()の unit test を、scripts/agent-guards/tests/test_isolated_anchor_single_authority.pyから
importlibで production module をロードして実装しようとしています。しかし formatter の既存 unit tests は既に、
.claude/skills/issue-refinement-loop/tests/test_refinement_preflight.pyの
TestBuildCompactStdoutに存在します。ここでは raw body/comment を stdout に漏らさないことや既存 projection が直接検証されています。#2317 はそのファイルを明示的に Out of Scope にしています。これはテスト責務を逆転させています。
Allowed Paths に
test_refinement_preflight.pyを追加してください。役割はこう分離するのが自然です。
test_refinement_preflight.py_build_compact_stdout()の contractenv failure → reason/source/operation が出る
non-env failure →出ない
raw detail が出ない
test_isolated_anchor_single_authority.pystdout parser
transient predicate
live subprocess の最終挙動
この方が importlib 経由の妙な cross-layer unit test を増やさずに済みます。
P2 — 本質的な flake 原因は「未認証 GitHub REST live test を通常 CI に混ぜていること」
credentialless transport は意図的に token を受け取らない設計です。現実装自身も anonymous GitHub API のレート制限を受け入れる設計になっています。
GitHub 公式仕様では未認証 REST API は発信元 IP 単位で 60 requests/hourです。認証済みなら通常 5,000/hour、Actions の
GITHUB_TOKENなら repository ごと 1,000/hour です。(GitHub Docs)このテストでは「token が隔離されていること」そのものを検証したいので、
GITHUB_TOKENを渡す修正は当然ダメです。したがって最も有効なのは API client をさらに harden することではなく test lane を分けることです。個人開発なら、私は以下の構成を推します。
fault injection / formatter / predicate の deterministic tests は required CI。
tokenless production-graph live test は
live_network等の独立 lane。通常 PR では non-blocking、scheduled/manual または対象機能変更時だけ実行。
live test の transient 3分類は SKIP/neutral。
auth dependency、404、bare 403、malformed response、authority bypass、unexpected
ghinvocation は hard FAIL。これなら harness のために無関係な PR が赤くなる問題をかなり減らせます。
P2 — transient closed set 自体は妥当
ここは #2317 のままでよいです。
SKIP対象:rate_limitedupstream_environment_failuretransport_connectivity_failurehard failure:
unexpected_authentication_dependencyhttp_403_forbiddencanonical_resource_missingmalformed_response_bodycross_repository_read_rejectedinvalid_issue_numberinvalid_comment_idtransport_internal_errorplanner/internal 系
GitHub 公式でも primary rate-limit は 403/429 かつ
x-ratelimit-remaining: 0で判別し、secondary rate-limit ではRetry-After等を見て retry/backoff する契約です。bare 403 を transient にしない現在の taxonomy は正しいです。(GitHub Docs)malformed_response_bodyまで transient に広げない判断も妥当です。プロトコル/parser regression と外部一時障害を区別できなくなるためです。P2 — strict parser の AC をもう少し強くするべき
単に「値が3種類なら True」だけでは弱いです。以下まで machine contract にしてください。
returncode == 3STATUS: environment_failureが exactly oneREASON_CODE:が exactly oneprefix は完全一致
duplicate
REASON_CODE:は hard failureempty value は hard failure
malformed line は hard failure
stderr は判定ソースに使わない
transient closed set は完全一致
未知の将来 reason code はデフォルト hard failure
特に unknown new enum → SKIP にしないのが重要です。closed set が将来増えても、明示レビューなしに false-green が拡大しません。
推奨する #2317 の変更
実装前に最低限、Issue を次の方針へ直すのがよいです。
項目 | 現在 | 推奨 -- | -- | -- stdout | REASON_CODE のみ | REASON_CODE / SOURCE / OPERATION formatter test | agent-guards test 内から import | test_refinement_preflight.py transient判定 | 3 reason exact match | 維持 malformed/missing | hard failure | 維持+duplicateも追加 stderr | 現 substring 判定に使用 | 判定から完全排除 live test の位置付け | AC5/AC6 系 runtime test のまま SKIP | best-effort live smoke と明文化 Runtime Applicability | not_applicable | patch自体は not_applicable でよい。ただし live smoke と runtime evidence を区別 Stop Condition | source/operationなら別Issue | 削除。既存フィールドなので同時対応 Allowed Paths | 2ファイル | test_refinement_preflight.py を追加最終評価
直接修正としては 7/10、Issue contract としては 5/10。
GH_API_FAILUREを丸ごと SKIP しない判断、closed-set exact match、synthetic deterministic test 化は良いです。PR #2310 の実障害に対する局所解としても成立しています。一方、現状のままだと「#2257 で残課題と認識済みだった live-network SKIP」をより堅牢に温存し、さらに既存の
reason_code/source/operationstdout contract のうち1つだけ直す形になります。実装着手前に Issue 本文を更新する価値が高いです。特に個人趣味開発という前提なら、セキュリティハーネスを増やすより、deterministic required CI と flaky external live smoke の分離を優先するのが最も費用対効果が高いです。
## 結論Issue #2317 は
REQUEST_CHANGES相当です。ただし、狙っている直接原因は正しいです。
GH_API_FAILURE自体を SKIP 対象に広げず、production が既に持っている structuredreason_codeを使う方向は採用すべきです。Issue 本文もそこは適切に限定できています。問題は、現在の仕様だと「今回の CI flake を直す」ことに寄りすぎて、既存 contract との矛盾と live-network test の置き場所という根本問題を固定化する点です。
P1 — #2257 で「未解決」とされた
pytest.skip()問題を、そのまま正式仕様化しているIssue #2257 は runtime verification を
immediateとし、GitHub API 到達不能を「SKIP ではなくenvironment_failureとして扱う」と要求していました。また AC4 は structuredreason_code/source/operationを artifact と stdout の両方へ一貫して出す契約でした。PR #2260 自身も、production-graph live test が rate-limit / connectivity / upstream failure で
pytest.skip()することを P1-6 の未解決残課題として明記してマージされています。 実際、現在の対象テストはその3分類が stdout/stderr に見つかればpytest.skip()します。 pytest におけるpytest.skip()は文字通りテストを skipped として終了させる API です。([pytest 公式ドキュメント]1)したがって #2317 は、既知の残課題を解決するのではなく、より正確に発火するようにしているだけです。
ただし、個人趣味開発で CI 可用性を優先するなら、私は「SKIP を禁止する」方向には戻しません。むしろ設計上の役割を変えるべきです。
これなら transient failure を SKIP にすることが設計上矛盾しません。逆に AC5/AC6 の authoritative runtime evidence と呼び続けるなら、SKIP green 化は矛盾したままです。
P1 —
REASON_CODE:だけ追加するのは、既存 structured contract の中途半端な再投影現在の canonical JSON schema はすでに
environment_failureに対して、reason_codesourceoperationの3フィールドを必須にし、非
environment_failureでは禁止しています。reason_code自体も closed enum です。一方 #2317 は stdout へ
REASON_CODE:だけ追加します。これは特にまずいのが、元の #2257 AC4 が3フィールドすべての stdout projection を要求していたことです。つまり今回
reason_codeだけ出すと、という3者不一致が残ります。
修正案:
_build_compact_stdout()を触るなら一度で、を
environment_failure時だけ出す方がよいです。追加の taxonomy や security mechanism は不要です。既存 result dict の値を3行投影するだけなので、ここを別 Issue に分割するメリットはほぼありません。
P1 — formatter の unit test を置くファイルが間違っている
#2317 は
_build_compact_stdout()の unit test を、scripts/agent-guards/tests/test_isolated_anchor_single_authority.pyから
importlibで production module をロードして実装しようとしています。しかし formatter の既存 unit tests は既に、
.claude/skills/issue-refinement-loop/tests/test_refinement_preflight.pyの
TestBuildCompactStdoutに存在します。ここでは raw body/comment を stdout に漏らさないことや既存 projection が直接検証されています。#2317 はそのファイルを明示的に Out of Scope にしています。これはテスト責務を逆転させています。
Allowed Paths に
test_refinement_preflight.pyを追加してください。役割はこう分離するのが自然です。
test_refinement_preflight.py_build_compact_stdout()の contracttest_isolated_anchor_single_authority.pyこの方が importlib 経由の妙な cross-layer unit test を増やさずに済みます。
P2 — 本質的な flake 原因は「未認証 GitHub REST live test を通常 CI に混ぜていること」
credentialless transport は意図的に token を受け取らない設計です。現実装自身も anonymous GitHub API のレート制限を受け入れる設計になっています。
GitHub 公式仕様では未認証 REST API は発信元 IP 単位で 60 requests/hourです。認証済みなら通常 5,000/hour、Actions の
GITHUB_TOKENなら repository ごと 1,000/hour です。([GitHub Docs]2)このテストでは「token が隔離されていること」そのものを検証したいので、
GITHUB_TOKENを渡す修正は当然ダメです。したがって最も有効なのは API client をさらに harden することではなく test lane を分けることです。個人開発なら、私は以下の構成を推します。
live_network等の独立 lane。ghinvocation は hard FAIL。これなら harness のために無関係な PR が赤くなる問題をかなり減らせます。
P2 — transient closed set 自体は妥当
ここは #2317 のままでよいです。
SKIP対象:rate_limitedupstream_environment_failuretransport_connectivity_failurehard failure:
unexpected_authentication_dependencyhttp_403_forbiddencanonical_resource_missingmalformed_response_bodycross_repository_read_rejectedinvalid_issue_numberinvalid_comment_idtransport_internal_errorGitHub 公式でも primary rate-limit は 403/429 かつ
x-ratelimit-remaining: 0で判別し、secondary rate-limit ではRetry-After等を見て retry/backoff する契約です。bare 403 を transient にしない現在の taxonomy は正しいです。([GitHub Docs]2)malformed_response_bodyまで transient に広げない判断も妥当です。プロトコル/parser regression と外部一時障害を区別できなくなるためです。P2 — strict parser の AC をもう少し強くするべき
単に「値が3種類なら True」だけでは弱いです。以下まで machine contract にしてください。
returncode == 3STATUS: environment_failureが exactly oneREASON_CODE:が exactly oneREASON_CODE:は hard failure特に unknown new enum → SKIP にしないのが重要です。closed set が将来増えても、明示レビューなしに false-green が拡大しません。
推奨する #2317 の変更
実装前に最低限、Issue を次の方針へ直すのがよいです。
REASON_CODEのみREASON_CODE / SOURCE / OPERATIONtest_refinement_preflight.pynot_applicablenot_applicableでよい。ただし live smoke と runtime evidence を区別test_refinement_preflight.pyを追加最終評価
直接修正としては 7/10、Issue contract としては 5/10。
GH_API_FAILUREを丸ごと SKIP しない判断、closed-set exact match、synthetic deterministic test 化は良いです。PR #2310 の実障害に対する局所解としても成立しています。一方、現状のままだと「#2257 で残課題と認識済みだった live-network SKIP」をより堅牢に温存し、さらに既存の
reason_code/source/operationstdout contract のうち1つだけ直す形になります。実装着手前に Issue 本文を更新する価値が高いです。特に個人趣味開発という前提なら、セキュリティハーネスを増やすより、deterministic required CI と flaky external live smoke の分離を優先するのが最も費用対効果が高いです。
squne121 commentedon Aug 23, 2026
root-owned entry router audit
route: invoke_impl_review_loop
reason: fresh_review_go_live_equality
squne121 commentedon Aug 23, 2026
issue-refinement-loop 終了報告(自律実行)
termination_reason: approved
起点: https://github.com/squne121/loop-protocol/issues/2317#issuecomment-5384468564(OWNER、`REQUEST_CHANGES` 相当)
反映内容(P1/P2 → Issue 本文への反映)
REASON_CODEのみからREASON_CODE/SOURCE/OPERATIONの3フィールド一貫投影へ変更(実装: Claude-GPT issue-refinement preflight の anchor comment 取得を credentialless transport へ統一する #2257 AC4 契約との不一致を解消)_build_compact_stdout()) の unit test 置き場所を.claude/skills/issue-refinement-loop/tests/test_refinement_preflight.py::TestBuildCompactStdoutに修正し、Allowed Paths に追加test_isolated_anchor_single_authority.pyの live subprocess テスト)が merge-blocking な authoritative runtime evidence ではなく best-effort live smoke test であることを Background に明記REASON_CODE:/ 空値を hard failure として扱う AC7 を追加、stderr 非使用を明記)反復(iteration)内訳
review-issue の deterministic checker(
ISSUE_REVIEW_RESULT_COMPACT_V2)による rewrite iteration が計4回発生した。STATUS: needs_fix(guard LP017: Stop Conditions テンプレート文言不一致で pre-mutation fail、mutation 未実行)uv run --locked python3 -m pytest ...がcommand_not_allowed)uv run python3 -m pytest ...へ修正して再適用 → 適用成功。ただし review-issue 再実行で新規 test 関数を既存ファイルに-k参照する VC がpytest collected 0 tests (exit 5)=vc_no_tests_collectedで blocked と判明(6件)rg -n "def <test名>" <path>形式(AC2/AC6と同型)へ変更して再適用 → 適用成功。ただし AC6 のrg -c "..."に未エスケープの(があり regex parse error (exit 2) で「Unable to automatically classify exit code」が1件残存rg -Fc(fixed-string) へ修正して再適用 → review-issue:VERDICT: approve(BLOCKERS: 0)Contract Review(Final Gate)
issue-contract-review(run_contract_review_once.py --mode execute)を実行し、CONTRACT_REVIEW_RESULT_V1.status: goを確認済み(readiness_status: go/vc_preflight_status: pass、AC1〜AC8 全てexpected_baseline_fail/goに分類)。sha256:7549c2f233d39089fc71cfd39f9e6de6d83ad867535bd4b5bc4dbc7fabc8c1c4Semantic Design Review(Step 2.5)
semantic_review_trigger.pyによる applicability 判定はsemantic_review_applicable: false(deterministic checker gap 0件、heuristic concern 0件、anchor comment からの severity-tagged finding 抽出も0件)。追加の semantic レビューはスキップ。squne121 commentedon Aug 23, 2026
implement-issue: 実装完了 (2026-08-23)
.claude/worktrees/issue-2317-reason-code-skipworktree-issue-2317-reason-code-skip99f936711578bde5713ad51245a807404ccb1b97実装内容
run_refinement_preflight.py::_build_compact_stdout()に、status == "environment_failure"のときのみREASON_CODE/SOURCE/OPERATIONの3行を出力する最小限の追加(AC1/AC2、実装: Claude-GPT issue-refinement preflight の anchor comment 取得を credentialless transport へ統一する #2257 AC4 未実装差分の解消)test_isolated_anchor_single_authority.pyに_is_transient_environment_failure_reason_code()predicate と_extract_reason_code_line_value()helper を新設し、live subprocess テストの skip 判定を旧 broad substring OR-chain(stdout/stderr 両方チェック)から stdout-only closed-set exact-match 判定へ置換(AC3〜AC7)test_refinement_preflight.py::TestBuildCompactStdoutに formatter contract の unit test を追加(AC8)Verification Commands(Issue 本文の AC1〜AC8)
全 8 件 PASS(
rg -n/rg -Fcで該当 test 名・呼び出し箇所を確認済み)。追加検証
uv run pytest scripts/agent-guards/tests/test_isolated_anchor_single_authority.py -k "not live_subprocess and not credentialless_authority"→ 7 passeduv run pytest .claude/skills/issue-refinement-loop/tests/test_refinement_preflight.py→ 87 passeduv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py→ 24 passeduvx ruff check <3 changed files>→ All checks passedpnpm typecheck/pnpm lint/pnpm test/pnpm build: TS 変更なしのためスキップ(PR 本文に明記)後続: PR レビュー(pr-review-judge)→ マージ → post-merge-cleanup
fix: PR #2319 review fix_delta iteration 1 (Issue #2317)
fix: test_isolated_anchor_single_authority のtransient判定を構造化reason_cod…