Skip to content

実装: GitHub Issue labels を presentation-only metadata として SSOT 化する - #2092

Merged
squne121 merged 8 commits into
mainfrom
worktree-issue-2084-label-authority
Aug 11, 2026
Merged

squne121 merged 8 commits into
mainfrom
worktree-issue-2084-label-authority

Conversation

@squne121

Copy link
Copy Markdown
Owner

Summary

この PR は Issue #2084 の実装です。GitHub Issue labels を presentation-only / non-authoritative metadata として SSOT 化し、label→gate 結合を production consumer(docs/dev/workflow.md、build_intake_capsule.py、impl-review-loop/steps/preparation.md、issue-refinement-loop/SKILL.md・termination-policy.md、implement-issue/SKILL.md)から除去しました。

  • docs/dev/workflow.md の implementation_consumer_ready_contract から required_routing_labels / hard_stop_labels を除去し、「labels are presentation-only」の SSOT 原則を明記しました。
  • docs/dev/github-ops.md に、既存の state/blocked / state/queued の「補助・派生表示」原則を全ラベル種別へ一般化した SSOT セクションを追加しました。
  • build_intake_capsule.py の ready_status(_next_action_route が参照する readiness gate)から phase_label_ok 依存を除去しました(ready_tuple.phase_label_present は観測用フィールドとして残しています)。
  • impl-review-loop/steps/preparation.md の Intake Gate metadata_not_ready から phase/implementation label 欠落条件を除去しました。
  • issue-refinement-loop/SKILL.md Step 0 の hard stop 条件から state/needs-human / state/done の label 単独判定を除去し、停止には OWNER の明示指示や human_judgment_required が必要である旨を明記、state/done の代替として GitHub native Issue closed state を参照するようにしました。
  • termination-policy.md の LOOP_HANDOFF_RESULT_V1 から metadata.phase_label_ready を impl_ready 条件から除去し、label_sync_observation(kind: presentation_sync)を non-authoritative telemetry として再定義、auto_fixes.required に triage label 遷移を追加しない契約を明記しました。
  • apply_triage_label_transition.py(新規)を追加し、triage-required remove・phase/implementation / agent/implementer add を readiness decision 後の best-effort presentation sync として実行します(applied | noop | failed。permission/network/API failure は warning、readiness authority フィールドは一切含みません)。
  • implement-issue/SKILL.md の phase/implementation 依存記述を、readiness gate ではなく routing/classification 用の非authoritative 参照であることが分かるよう更新しました。

Checks

  • AC1(docs/dev/workflow.md から required_routing_labels/hard_stop_labels 除去 + presentation-only SSOT 明記): ! grep -n -e "required_routing_labels" -e "hard_stop_labels" docs/dev/workflow.md (exit 0, no match) / grep -n -e "presentation-only" -e "presentation_only" docs/dev/workflow.md (1 件マッチ) を実行し、両方 PASS しました。
  • AC2(docs/dev/github-ops.md に全ラベル種別 SSOT セクション追加): grep -n -e "presentation-only" -e "presentation_only" docs/dev/github-ops.md を実行し、2 件マッチしました。
  • AC3(ready_status が phase_label_ok に非依存。runtime-verification: true): uv run --locked pytest .claude/skills/impl-review-loop/tests/test_label_authority_invariants.py::test_ready_status_independent_of_phase_label -v を実行し、1 件成功しました(labels=[] / labels=["phase/implementation"] の両方で issue_ready_tuple.status == "pass"、next_action.route も同一であることを end-to-end で確認)。
  • AC4(preparation.md の metadata_not_ready から label 条件除去 + test_intake_gate.py 整合。runtime-verification: true): uv run --locked pytest .claude/skills/impl-review-loop/tests/test_intake_gate.py -v を実行し、26 件すべて成功しました(新規 test_ac3_metadata_not_ready_excludes_phase_implementation_label を含む)。
  • AC5(SKILL.md Step 0 hard stop から label 単独判定除去 + test_loop_policy.py 整合。runtime-verification: true): uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_loop_policy.py -k "hard_stop" -v を実行し、12 件すべて成功しました。
  • AC6(termination-policy.md から phase_label_ready 除去 + presentation_sync 再定義): ! grep -n "phase_label_ready" .claude/skills/issue-refinement-loop/references/termination-policy.md (exit 1, no match) / grep -n -e "presentation_sync" -e "label_sync_observation" .claude/skills/issue-refinement-loop/references/termination-policy.md (4 件マッチ) を実行し、両方 PASS しました。
  • AC7(apply_triage_label_transition.py の applied/noop/failed 契約。runtime-verification: true): uv run --locked pytest .claude/skills/issue-refinement-loop/scripts/tests/test_apply_triage_label_transition.py -v を実行し、9 件すべて成功しました(idempotency、unrelated label 保持、permission/network/API failure の warning-only 化、readiness authority フィールド非混入を含む)。
  • AC8(label permutation matrix。runtime-verification: true): uv run --locked pytest .claude/skills/impl-review-loop/tests/test_label_authority_invariants.py::test_ready_status_label_permutation_matrix -v を実行し、8 件すべて成功しました([] / triage-required / phase/implementation / state/needs-human の全組み合わせで baseline と同一の ready_status / next_action.route)。
  • AC9(## Runtime Verification Applicability セクションが Issue 本文に存在): gh issue view 2084 --repo squne121/loop-protocol --json body -q .body で本文中に該当セクションの存在を確認しました(Issue 自身の自己参照チェック)。
  • AC10(implement-issue/SKILL.md の phase/implementation 言及が非authoritative 化されている): grep -n "phase/implementation" .claude/skills/implement-issue/SKILL.md を実行し、1 件マッチ(readiness gate ではなく routing/classification 用の非authoritative 参照である旨を明記した文言)を確認しました。
  • 既存回帰なし: uv run --locked pytest .claude/skills/impl-review-loop/tests/test_build_intake_capsule.py -v を実行し、14 件すべて成功しました。uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_loop_policy.py -q を実行し、26 件すべて成功しました(全件、-k hard_stop 限定でない)。
  • 標準 4 コマンド: pnpm typecheck(PASS)、pnpm lint(PASS)、pnpm test(1872 件すべて成功、112 test files)、pnpm build(PASS、dist/ 生成)をすべて実行し PASS しました。

Runtime Verification Artifacts(動作検証証跡)

decision: immediate、applicable_acs: [AC3, AC4, AC5, AC7, AC8](Issue 本文の ## Runtime Verification Applicability 節)に従い、以下を pytest subprocess / fixture-backed 挙動として実測しました(mock-only route ではなく build_intake_capsule.py / apply_triage_label_transition.py の実関数呼び出し)。

  • AC3/AC8: test_label_authority_invariants.py は build_intake_capsule() を _run_command の副作用差し替えのみで end-to-end 実行し、label permutation(8 パターン)ごとの issue_ready_tuple.status / next_action.route が baseline(labels=[])と同一であることを assert しています。
  • AC4: test_intake_gate.py::test_ac3_metadata_not_ready_excludes_phase_implementation_label は preparation.md の metadata_not_ready セクション本文(条件リスト部分のみを code-fence 前で切り出し)に phase/implementation が含まれないことを固定しています。
  • AC5: test_loop_policy.py::test_hard_stop_state_needs_human / test_hard_stop_state_done は、SKILL.md に別 authority(human_judgment_required / OWNER)と native closed state 参照が明記されていることを固定しています。
  • AC7: test_apply_triage_label_transition.py は scripted gh CLI 応答(rc/stdout/stderr)を注入する _ScriptedRunner で apply_triage_label_transition() を直接実行し、applied/noop/failed の 3 分岐、idempotency(2 回目実行が noop)、unrelated label 保持、permission/network/API failure が例外を投げず warnings に記録されること、戻り値に status/routing_action/implementation_allowed キーが一切含まれないことを固定しています。

Schema Change Applicability

  • decision: schema_change
  • reason: .claude/skills/issue-refinement-loop/references/termination-policy.md の LOOP_HANDOFF_RESULT_V1 スキーマ定義から metadata.phase_label_ready: bool フィールドを削除し、label_sync_observation(新規ブロック)を追加しました。また apply_triage_label_transition.py の新規 APPLY_TRIAGE_LABEL_TRANSITION_RESULT_V1 スキーマを追加しています。

Schema Consumer Inventory

Consumer ファイル 更新有無 備考
.claude/skills/issue-refinement-loop/references/termination-policy.md(LOOP_HANDOFF_RESULT_V1 SSOT 定義自体) 更新済み metadata.phase_label_ready 削除、label_sync_observation 追加、impl_ready 条件式から該当項目を除去
.claude/skills/issue-refinement-loop/scripts/*.py(decide_next_loop_action.py / publish_termination_report.py / validate_issue_execution_decision.py 等) 更新不要 grep -rn "phase_label_ready" .claude/skills/issue-refinement-loop/scripts/ で現行 main に該当フィールドをキーとして parse する production コードが存在しないことを確認済み(marker は LLM orchestrator が prose として読む契約であり、構造化 JSON パーサーの consumer が存在しない)
.claude/skills/issue-refinement-loop/tests/test_publish_termination_report.py 更新不要 同ファイルに phase_label_ready の参照なし(grep で確認済み)
render_termination_report.py / test_render_termination_report.py / test_loop_handoff_result.py 対象外(既に撤去済み) #1873 で production path から撤去済みであり、現行 main(本 PR の base)に存在しない
apply_triage_label_transition.py(新規スキーマ APPLY_TRIAGE_LABEL_TRANSITION_RESULT_V1 の producer) 新規追加 本 PR で新規追加するスクリプト自身。既存の consumer は現時点で存在せず(Issue #2084 の In Scope はスクリプト追加までであり、orchestrator への配線は対象外)

Before / After(LOOP_HANDOFF_RESULT_V1.metadata フィールド変更)

# before
LOOP_HANDOFF_RESULT_V1:
  metadata:
    title_prefix_ready: bool
    phase_label_ready: bool   # impl_ready 条件 4 として必須参照されていた

# after
LOOP_HANDOFF_RESULT_V1:
  metadata:
    title_prefix_ready: bool
  label_sync_observation:     # 新規。impl_ready 判定に一切寄与しない telemetry-only ブロック
    kind: presentation_sync
    result: applied | noop | failed
    detail: string

Safety Claim Matrix

Claim Implemented? Not controlled Evidence Follow-up
build_intake_capsule.py の ready_status / next_action.route が label 構成に依存せず不変である yes N/A AC3/AC8 テスト(test_label_authority_invariants.py 全 10 件 PASS) N/A
preparation.md Intake Gate の metadata_not_ready が phase/implementation label 欠落を理由に停止しない yes N/A AC4 テスト(test_intake_gate.py 全 26 件 PASS、新規 test_ac3_metadata_not_ready_excludes_phase_implementation_label) N/A
issue-refinement-loop Step 0 の hard stop が state/needs-human/state/done label 単独では発動しない(別 authority が必要) yes N/A AC5 テスト(test_loop_policy.py -k hard_stop 全 12 件 PASS) N/A
apply_triage_label_transition.py の label mutation 失敗(permission/network/API)が readiness/status/routing_action/implementation_allowed を一切変化させない yes N/A AC7 テスト(test_apply_triage_label_transition.py 全 9 件 PASS、test_result_schema_does_not_contain_readiness_authority_fields 含む) N/A
label mutation は readiness decision 後の best-effort presentation sync に限定され、readiness gate として機能しない yes N/A apply_triage_label_transition.py の run_fn 差し替えテストで gh CLI 失敗が例外を投げず warnings に記録されることを確認、termination-policy.md の label_sync_observation 契約記述 N/A
本 PR は cross-repository mutation、destructive operation、secret/credential exposure、権限昇格を含まない yes(Out of Scope として明示) N/A Issue #2084 Out of Scope 節 N/A

Notes

)

label→gate 結合を production consumer(docs/dev/workflow.md、
build_intake_capsule.py、impl-review-loop/steps/preparation.md、
issue-refinement-loop/SKILL.md・termination-policy.md、
implement-issue/SKILL.md)から除去し、readiness authority を
non-label evidence(native issue open/closed state、GitHub native
dependency close 状態、CONTRACT_REVIEW_RESULT_V1 status)のみで
再定義する。triage-required remove / phase/implementation・
agent/implementer add は readiness decision 後の best-effort
presentation sync(apply_triage_label_transition.py、新規)として
再定義する。

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@github-actions

github-actions Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Preview URL

Preview removed (PR #2092 closed).

squne121 and others added 2 commits August 11, 2026 18:49
PR Body Japanese Check の per-block 検査で「既存 Issue の native
parent/blockedBy/blocking 同期」見出しが ratio=0.089 (jp=5, total=56)
となり閾値 0.1 未達だったため、意味を変えずに日本語の助詞・説明を
補って比率を引き上げる。

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@squne121

Copy link
Copy Markdown
Owner Author

判定: REQUEST_CHANGES

PR #2092 の方向性は妥当ですが、「labels は readiness/control-flow authority ではない」という最重要 invariant が、上流 consumer に残っています。現状はマージ不可と判定します。

P0 — issue-contract-review 経由で label gate が残っている

PR HEAD の新しい docs/dev/workflow.md は、

  • labels は presentation-only
  • readiness authority に labels を使ってはならない
  • CONTRACT_REVIEW_RESULT_V1 status: go は readiness authority
  • issue-contract-review 自身もこの contract を正本として使う

と定義しています。

ところが current main の canonical issue-contract-review/SKILL.md は今も、

state/needs-human がある場合のみ BLOCKED

という判定を明記しています。 さらに contract-compliance.md は State Label を compliance check に含め、「fail 1つでも BLOCKED」「state/needs-human が着手判定をブロック」と明記しています。

したがって実際の依存関係は、

state/needs-human label
→ issue-contract-review BLOCKED
→ CONTRACT_REVIEW_RESULT_V1 != go
→ implementation_consumer_ready_contract 不成立

となり、label が一段上流を経由して transitive readiness authority のままです。

これは #2084 の OWNER directive、「label は AI の着手可否・品質の authority にしない」と明確に矛盾します。#2084 自身も Readiness Plane と Presentation Plane の分離を Outcome としています。

さらに今回の permutation test はこの欠陥を検出できません。_run_with_labels() が CONTRACT_SNAPSHOT_ENSURE_RESULT_V1.status = "go" を固定注入したうえで build_intake_capsule() だけを実行しているため、問題の issue-contract-review → CONTRACT_REVIEW_RESULT_V1 上流経路そのものをバイパスしています。 その状態で state/needs-human を含む8 permutationを検証しているため、下流の invariant は証明していても、repository-wide invariant は証明していません。

修正必須です。#2084 の Allowed Paths / scope を最低でも以下まで拡張すべきです。

  • .claude/skills/issue-contract-review/SKILL.md
  • .claude/skills/issue-contract-review/references/contract-compliance.md
  • 関連する issue-contract-review tests
  • 後述の derived design doc

checks.state_label を残すなら observational telemetry に限定し、CONTRACT_REVIEW_RESULT_V1.status の算出に絶対に寄与させない契約にしてください。


P1 — 新しい label sync は production に一度も配線されていない

PR 本文自身が、新設 apply_triage_label_transition.py について

既存 consumer は現時点で存在せず、orchestrator への配線は対象外

と明記しています。

一方 #2084 の Outcome は、readiness decision 後に実行される best-effort presentation sync と定義しています。

したがって現在実装されたのは「実行可能な standalone utility」であって、production workflow で presentation sync が起きる機能ではありません。

ここは契約をどちらかに統一すべきです。

  • production でも同期させる → readiness 決定後に明示的に配線する。
  • 今回は utility の提供だけ → Issue/PR の Outcome を「配線は follow-up」と明確化する。

現状の「sync を実装した」という Safety Claim は強すぎます。


P1 — “best-effort / non-blocking” なのに gh が無期限に hang できる

_default_run() は subprocess.run() に timeout を設定していません。

結果 JSON から readiness fields を排除しても、gh issue view/edit 自体が network stall すると 関数が返らず、呼び出し側 workflow を物理的に止められます。これは「結果値を gate にしない」だけでは防げない control-flow coupling です。

Python の公式 API には subprocess.run(..., timeout=...) があり、期限超過を TimeoutExpired として処理できます。([Python documentation]1)

配線前に、

  • bounded timeout
  • TimeoutExpired → result: failed
  • warning telemetry
  • exit 0

まで実装してください。


P2 — applied が実際の post-state を証明していない

現在は、

  1. 現在 labels を読む
  2. remove
  3. add
  4. command の exit code だけで applied
  5. readback なし

です。unrelated_labels_preserved も変更前 snapshot から計算した値で、変更後に確認していません。

これは OWNER review が具体的に要求した

read → delta → mutation → readback

からも readback が抜けています。

GitHub CLI は add/remove label を同じ gh issue edit invocation に指定できます。(GitHub CLI) また REST の Add labels は既存 labels への追加として定義されています。([GitHub Docs]3)

改善案は、

  1. 可能なら remove/add を1 invocation にまとめる
  2. その後 gh issue view --json labels
  3. requested delta が成立したことを確認
  4. そこで初めて applied
  5. concurrent unrelated-label mutation は壊さない

です。単一 CLI invocation にしても transaction になるとは限らないので、最終 readback は残すべきです。


P2 — architecture review 用の derived design が旧 contract のまま

docs/dev/workflows/impl-review-loop-design.md は現在も Invocation Contract の前提を

issue-contract-review status: go かつ state/needs-human 非存在

としています。

この文書には canonical_sources_win と明記されているので runtime SSOT ではありません。しかし、まさに contract migration / architecture review 時にロードする文書です。

今回の変更時に一番誤誘導してはいけない資産なので、同PRで修正する方が安全です。


関連 Issue / PR の評価

#2086 は #2084 で露呈した「human-context scope expansion を human escalation にしてしまう」別の workflow defect を扱っています。label authority 問題そのものの修正ではありません。

PR #2068 も現在 Draft/Open で、freeform OWNER authority の transport/receipt/controlled consumer が主題です。これも今回見つかった issue-contract-review の label gate を代替して解消するものではありません。

また #1944 は preparation.md / implement-issue が CONTRACT_REVIEW_ONCE_RESULT_V1.applicability を読むための OPEN Issue で、今回と同じ consumer を変更予定です。将来の競合・契約ドリフト対象として追従が必要です。


CI / merge readiness

HEAD e2c7d3f… の CI は非常に良好です。typecheck、lint、test、build、python-test、validate-generated-artifact、visual-impact-policy-trusted などが success しています。

ただしその後 main は #2081 のマージで 21501ba… に進みました。 現在 PR branch は current main に対して diverged / behind_by: 1 です。 #2081 は contract-review/bootstrap 周辺を変更しているため、このPRでは特に current main を取り込んだ後の fresh CI が必要です。


外部仕様との照合

設計思想自体は妥当です。GitHub 公式も labels を work の categorization / tracking 用として説明しています。([GitHub Docs]4)

ただし labels は issues:labeled / unlabeled で GitHub Actions の trigger にもできます。つまり「presentation-only」を保証したいなら、単にデータ型や docs を変えるだけでは不十分で、label event → workflow → readiness mutation の経路も consumer inventory の対象にする必要があります。([GitHub Docs]5) 今回確認した repository search では github.event.label の直接参照は見つからなかったため、現時点の主 blocker は Actions ではなく issue-contract-review です。

推奨修正順

  1. P0: 実装: issue-refinement-loop の approved 終了時に triage-required ラベル遷移を実行する #2084 scope を拡張し issue-contract-review/SKILL.md + contract-compliance.md から state/needs-human → BLOCKED を除去。
  2. CONTRACT_REVIEW_RESULT_V1 を含む上流から下流まで、labels を変えても final readiness が不変な regression test を追加。現在の「status: go 固定 fixture」は authority invariant test では使わない。
  3. production sync が 実装: issue-refinement-loop の approved 終了時に triage-required ラベル遷移を実行する #2084 の成果物なら apply_triage_label_transition.py を readiness 後の telemetry lane に実配線。
  4. subprocess timeout + TimeoutExpired handling を追加。
  5. post-mutation readback を追加し、applied を observed final state に基づかせる。
  6. derived design doc を更新。
  7. current main を取り込み、全 required CI + label-authority regression を fresh HEAD で再実行。

**最終 verdict は REQUEST_CHANGES / P0 blocker あり**です。特に1番目を直さずマージすると、「label gate を撤去した」という PR の中心的 Safety Claim が成立しません。

@squne121 squne121 self-assigned this Aug 11, 2026
squne121 and others added 5 commits August 11, 2026 19:44
…out/readbackを追加する (#2084)

PR #2092 への OWNER REQUEST_CHANGES(comment #5251894253)に基づく fix_delta。

- issue-contract-review/SKILL.md・contract-compliance.md から state/needs-human
  label を BLOCKED authority として扱う記述を除去し、readiness authority は
  label 非依存の non-label evidence のみである契約に揃えた(AC11)。
- issue-contract-review 自体の実行経路(run_once() / check_product_spec_contract.py
  の実 decision pipeline)を通す regression test を追加し、label permutation
  でも readiness が不変であることを固定した(AC12)。
- apply_triage_label_transition.py の subprocess 呼び出しに bounded timeout
  (30秒)を追加し、TimeoutExpired 時は result: failed + warning + exit 0 で
  終了するようにした。また label mutation 後に readback を行い、実際に delta
  が適用されたことを確認してから applied を返すよう変更した(AC13)。
- docs/dev/workflows/impl-review-loop-design.md の Invocation Contract /
  Failure Mode / Escalation 記述を label-authority 契約に整合させた(AC14)。

Co-Authored-By: Claude Sonnet 5 <[email protected]>
CI ruff check の F401 unused-import 指摘を解消。

Co-Authored-By: Claude Sonnet 5 <[email protected]>
pr-reviewer REQUEST_CHANGES対応。AC1 VC(`! grep required_routing_labels/hard_stop_labels`)が
SSOT原則の否定文脈の説明文中に残っていたliteral語でfailしていたため、
意味を変えずに婉曲表現へ書き換えた。
@squne121
squne121 marked this pull request as ready for review August 11, 2026 11:33
@squne121
squne121 merged commit 3559ad2 into main Aug 11, 2026
36 of 37 checks passed
@squne121
squne121 deleted the worktree-issue-2084-label-authority branch August 11, 2026 11:40
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.

実装: issue-refinement-loop の approved 終了時に triage-required ラベル遷移を実行する

1 participant