Repository navigation
Closed
Labels
Milestone
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "#131"
goal_ref: "M1 milestone の descendant issue / blocker を再帰的に収集し、open blocker / No milestone descendant / stale state label を自動検出する"
change_kind: workflowParent Issue
Parent Goal Ref
- Goal: M1 milestone の全 descendant issue を機械的に収集し、open blocker / milestone 未設定 descendant / stale state label を自動検出する
- Desired Destination:
scripts/milestone_rollup.pyがMILESTONE_DESCENDANT_ROLLUP_V1schema で結果を stdout に出力し、既存.claude/skills/milestone-rollup/scripts/milestone_rollup.shの Python 後継 checker として動作する
Current Validated Scope
scripts/milestone_rollup.pyの新規作成(read-only diagnostic checker)scripts/tests/test_milestone_rollup.pyの新規作成(API fixture ベースの unit test)
Remaining Parent Gaps
- GitHub Actions への組み込み(別 Issue で対応)
- milestone-rollup 結果を issue-refinement-loop / impl-review-loop / post-merge-cleanup に接続(別 Issue で対応)
Outcome
scripts/milestone_rollup.py が M1 Milestone の direct issues と GitHub native sub-issues descendants を recursive に収集し、以下を固定 schema MILESTONE_DESCENDANT_ROLLUP_V1 で stdout に出力する。
- PR direct milestone attachment(invariant violation)
- descendant milestone mismatch
- closed issue with stale state labels(
state/queued/state/in-progress) - open issue blocked by open dependency
既存 .claude/skills/milestone-rollup/scripts/milestone_rollup.sh の shell 実装との差分を明示し、Python checker は read-only report generator として実装する。
Milestone Direct Assignment Exception
本 Issue は issue_kind: implementation であり、parent は #131 だが M1 Milestone に直接割り当てている。理由: M1 close gate を判定する checker 実装そのものであり、checker がなければ M1 close 判断の品質ゲートが不成立になるため、#131 経由の間接所属より M1 直割当の方が優先度を明示しやすい(docs/dev/milestone-ops.md の例外ケース)。
In Scope
scripts/milestone_rollup.pyの新規作成- milestone number を引数に取り、GitHub REST API(
/milestones/{n}/issues+/issues/{n}/sub_issues)で descendants を BFS recursive 収集する MILESTONE_DESCENDANT_ROLLUP_V1schema を--format json(デフォルト)または--format markdownで stdout 出力する- open / closed 状態と milestone 設定の不一致を
milestone_mismatchesに出力する - closed issue に
state/queued/state/in-progressが残っている場合をstale_state_labelsに出力する - open issue が open blocker を持つ場合を
open_blockersに出力する(native dependency 優先、不能時は## Depends Onsection fallback) - milestone に PR が直接紐づく場合を
pr_mixedに出力する --strictオプションで invariant violation がある場合 exit 1
Out of Scope
- PR 本文 follow-up の prose parsing(別 Issue)
- Safety Claim Matrix follow-up の prose parsing(別 Issue)
- GitHub Actions への組み込み(別 Issue)
- 自動修正・label mutation・milestone mutation(検出のみ)
- milestone close(
docs/dev/milestone-ops.md通り人間判断)
Acceptance Criteria
- AC1:
uv run python3 scripts/milestone_rollup.py 1が M1 direct issues と descendants を recursive に列挙する - AC2: GitHub sub-issues REST API を pagination 付きで辿り、visited set により重複・循環・cross-repo sub-issue を安全に扱う
- AC3: milestone が null または対象 milestone 以外の descendant を
milestone_mismatchesに出力する - AC4: closed issue に
state/queuedまたはstate/in-progressが残る場合、stale_state_labelsに出力する - AC5: open issue が open blocker を持つ場合、
open_blockersに出力する。GitHub native dependency が取得不能な場合は## Depends Onsection 内の#Nのみを fallback として解析する - AC6: milestone に PR が直接紐づく場合、
pr_mixedに出力する - AC7: findings があっても report 生成に成功すれば exit 0。
--strict時は invariant violation があれば exit 1。API/auth/parse/usage error は常に non-zero - AC8: unit tests は API response fixture で、2 階層以上の descendant、pagination、PR 混入、stale label、milestone null、open blocker の各ケースを検証する
Verification Commands
# AC1
# AC2
# AC3
# AC4
# AC5
# AC6
# AC7
# preflight-scope: runtime_only
$ uv run python3 scripts/milestone_rollup.py 1
# AC7
# preflight-scope: runtime_only
$ uv run python3 scripts/milestone_rollup.py 1 --strict
# AC8
$ uv run pytest scripts/tests/test_milestone_rollup.py -vAllowed Paths
scripts/milestone_rollup.pyscripts/tests/test_milestone_rollup.pyscripts/tests/__init__.py
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
- GitHub API 認証が必要で環境変数未設定の場合(human escalation)
Runtime Verification Applicability
decision: not_applicable
reason: Python スクリプトの新規作成であり、ブラウザ / Canvas / WebSocket などランタイム動作は含まない。uv run pytest による unit test で AC を網羅的に検証可能
Required Skills
- Python 3 / GitHub REST API
- GitHub sub-issues API(BFS traversal / pagination / visited set)
gh api/uv run python3
Related
- 親 tracker: 実装・検証・レビュー・PR本文更新をAIエージェントに自律ループさせる際の停止条件が弱かった #131
- milestone-ops SSOT:
docs/dev/milestone-ops.md - 既存 shell 実装:
.claude/skills/milestone-rollup/scripts/milestone_rollup.sh(実装: milestone rollup / next-action 導線を作る (M-A4) #147 / PR feat(#147): milestone rollup skill 実装 (M-A4) #219 でマージ済み) - 後続 Actions 化: 別 Issue(未起票)
Activity
squne121 commentedon May 29, 2026
人間からのコメントです。
「scripts/milestone_rollup.py」って運用設計はどのように検討されているの?GitHub Actionsで自動で運用される?Issueが起票されたら自動で適用とか?マイルストーンとの接続はどうなっているの?マイルストーン設計変更に追従する?issue-refinement-loop や impl-review-loopなどメインループとの接続は?
squne121 commentedon May 29, 2026
Verdict: REQUEST_CHANGES
#468 は「やる価値はある」が、現 contract のまま実装すると 既存 milestone-rollup の重複実装・検出漏れ・運用 SSOT 逸脱を作る可能性が高いです。実装前に Issue contract を修正すべきです。
主要 blocker
1. Outcome と Out of Scope が矛盾している
#468 の Outcome は
linked PR、PR本文 follow-up、Safety Claim Matrix follow-upまで収集すると書いています。([GitHub]1)一方で Out of Scope では「PR 本文 follow-up の自動解析」を別 Issue としています。([GitHub]1)
これは contract として破綻しています。Safety Claim Matrix の
Follow-up欄を拾うには、少なくとも PR body の構造化パースが必要です。#137 でも Safety Claim Matrix は PR 本文必須セクションとして定義され、列にFollow-upが含まれます。([GitHub]2)修正案: #468 では
PR body follow-upとSafety Claim Matrix follow-upを Outcome から削除するか、逆に Out of Scope を外して AC/テストまで追加してください。中途半端に書くのが一番危険です。2. #147 / PR #219 の既存 milestone-rollup 実装と衝突している
#147 は既に milestone rollup / next-action 導線を作る Issue で、Outcome には
assignment_integrity、blocked/ready、next_action、human_escalationsの固定フォーマットが含まれます。([GitHub]3)PR #219 はこれを merge 済みで、
.claude/skills/milestone-rollup/SKILL.mdとscripts/milestone_rollup.shを追加し、assignment drift・blocked/ready・next-action を実装済みと説明しています。([GitHub]4)つまり #468 は「新規
scripts/milestone_rollup.py」ではなく、既存 skill の 後継 checker / refactor / Python 化 / descendant 拡張として定義しないと、同じ責務を二重に持ちます。現行 shell 実装には改善余地があります。たとえば #219 本文自身が
expected_set取得失敗時に fallback 値を使う後続課題を認識しています。([GitHub]4) これは #468 の良い着地点ですが、Issue contract はそこに接続できていません。修正案:
parent_issueだけでなく Related に#147,#219,#221相当の follow-up を明示し、Outcome を「既存 milestone-rollup の descendant traversal / stale state detector を Python checker として追加、必要なら shell skill から呼ぶ」に変更してください。3. M1 Milestone への Implementation Issue 直割当が SSOT と矛盾している
docs/dev/milestone-ops.mdは、GitHub Milestone に直接割り当てる対象を原則 Parent Issue とし、Implementation Issue は Parent Issue の child として間接的に属すると定義しています。([GitHub][5])しかし #468 は
issue_kind: implementationで、parent は#131、かつ Milestone は M1 に直接付いています。([GitHub]1)例外として Implementation Issue を直接 Milestone に含めるなら、例外理由を記録する必要があります。現 Issue 本文にはその記録が見当たりません。
修正案: どちらかに寄せるべきです。
## Milestone Direct Assignment Exceptionを追加し、「M1 close gate を実装する checker 自体なので例外的に M1 直割当する」などの理由を記録する。4. AC が弱く、goal の「open blocker」検出を検証していない
#468 の goal は
open blocker / No milestone descendant / stale state labelの自動検出ですが、AC は direct open issues、closed issue の stale label、direct child の null milestone、exit 0 だけです。([GitHub]1)open blockerの定義が AC に存在しません。さらに、GitHub には native issue dependencies があり、「blocked by / blocking」を Relationships で管理できます。([GitHub Docs][6]) 既存 workflow も dependency 判定を GitHub native dependency または
Depends on #Nfallback としています。([GitHub][7])修正案: AC を追加してください。
5. 「recursive descendant」と「direct child」が混在している
In Scope では「子 Issue を再帰収集」とありますが、AC3 は「direct child issue」の null milestone だけです。([GitHub]1)
GitHub sub-issues は最大 100 件/parent、最大 8 階層までネスト可能です。([GitHub Docs][8]) REST API でも
GET /repos/{owner}/{repo}/issues/{issue_number}/sub_issuesが提供され、per_page最大 100 と pagination が必要です。([GitHub Docs][9])修正案: direct child ではなく descendant 全体を対象にしてください。テストも BFS/DFS の 2 階層以上を fixture 化すべきです。
6. exit 0 の条件が危険に曖昧
#468 は「検出件数に関わらず exit 0」としています。これは report checker としては妥当ですが、API 失敗・認証失敗・pagination 失敗・JSON parse 失敗まで exit 0 になってはいけません。([GitHub]1)
GitHub REST API は pagination され、Link header または
gh api --paginate相当の全ページ取得が必要です。([GitHub][10])修正案: exit code を分けてください。
実装設計の推奨
#468 を実装するなら、
scripts/milestone_rollup.pyは既存 shell skill の置き換え候補として設計してください。推奨出力 schema:
実装ロジックは以下が最低線です。
GitHub Issues API は PR も issue として返すため、
pull_requestkey による分離は必須です。([GitHub Docs][11])現 repo 状態から見る検出対象の実例
この checker が必要な実データは既にあります。#133 は Closed ですが
state/in-progressラベルが残り、M1 Milestone に属しています。([GitHub][12])また #147 は Closed かつ
state/queuedが残っており、Milestone はNo milestoneです。([GitHub]3)つまり #468 のテストには、少なくとも以下を入れるべきです。
Issue 本文の修正案
この程度まで縮めると実装可能になります。
結論
#468 は **「既存 milestone-rollup の Python descendant checker 化」**として再定義すれば有用です。現状のままでは、#147/#219 と責務が衝突し、PR body/Safety Claim Matrix 解析を Outcome に含めながら Out of Scope に落とす矛盾があり、AC も goal を満たしていません。実装前に contract refinement を推奨します。
[5]: https://raw.githubusercontent.com/squne121/loop-protocol/main/docs/dev/milestone-ops.md "") | {number, id, state, title, due_on, html_url}'
└─ 同名 0 件 → 1 create へ進む
└─ 同名 1 件 (state=open) → 1 をスキップし update/readback へ進む
└─ 同名 1 件 (state=closed) → human escalation(reopen か新規作成かを人間が判断)
└─ 同名 2 件以上 → human escalation(どれを使うかを人間が判断)
[1] Milestone 作成
└─ gh api --method POST repos/{owner}/{repo}/milestones
-f title="<title>"
-f description=""
[-f due_on=""]
└─ readback: 返却された number・id を記録
[2] Issue を Milestone に割り当て
# gh CLI 経由: --milestone は milestone の title/name を受け取る(number 不可)
└─ gh issue edit {issue_number}
--milestone "<milestone_title>"
--repo {owner}/{repo}
# REST API 経由: milestone フィールドは milestone の number(integer)を渡す
└─ gh api --method PATCH repos/{owner}/{repo}/issues/{issue_number}
-f milestone={milestone_number}
└─ readback: gh issue view {issue_number} --json milestone で確認
└─ readback で milestone が null の場合は silent drop — human escalation
[3] 進捗 rollup
└─ gh api repos/{owner}/{repo}/milestones/{milestone_number}
└─ open_issues / closed_issues を取得
└─ PR 混入チェック: Milestone に PR が直接紐づいていないことを確認
gh api --paginate
"repos/{owner}/{repo}/issues?milestone={milestone_number}&state=all&per_page=100"
--jq '.[] | select(.pull_request != null) | {number, title, state, html_url}'
出力が非空の場合は human escalation(PR 直接紐づけ禁止の運用不変条件違反)
※ --paginate で全ページを列挙する(per_page=100 のみでは 101 件目以降が未検査になる)
└─ 関連 Issue にコメント投稿(github-ops.md の Body File Guidance に従う)
[4] open_issues: 0 を検知したら人間に通知
└─ close は実行しない
```
### 人間 fallback フロー
以下のいずれかの場合、AI エージェントは操作を停止し人間にエスカレーションする:
| 条件 | 対応 |
|---|---|
| 権限不足(403 / 404)| 1. Issue コメント投稿を試みる。2. コメント投稿も失敗した場合は Human Escalation コメント本文を標準出力に完全出力し、追加 write 操作を行わず停止する |
| silent drop(API 呼び出しは 200 だが実際に反映されない)| readback で確認し、不一致を報告 |
| SSOT 衝突(milestone の割り当てが他ドキュメントの方針と矛盾する)| 自動解決せず、矛盾を Issue コメントに記録し人間判断を要求 |
| Milestone close 判断 | AI は close せず、条件を満たしたことを通知するのみ |
| Scope 変更(Issue 追加・除外) | 提案のみ行い、人間の承認後に実行 |
### Human escalation コメントテンプレ
```markdown
## milestone-ops: Human Escalation Required ()
- Milestone: <title> (#)
- 理由: <権限不足 / silent drop / SSOT 衝突 / scope 変更 / close 判断>
- 状況: <具体的なエラー・矛盾の内容>
- 依頼: <人間に実行してほしい操作>
```
---
## GitHub REST API エンドポイント参照
### Milestone CRUD
| 操作 | メソッド | エンドポイント |
|---|---|---|
| 一覧取得 |
GET|/repos/{owner}/{repo}/milestones|| 作成 |
POST|/repos/{owner}/{repo}/milestones|| 取得 |
GET|/repos/{owner}/{repo}/milestones/{milestone_number}|| 更新 |
PATCH|/repos/{owner}/{repo}/milestones/{milestone_number}|| 削除 |
DELETE|/repos/{owner}/{repo}/milestones/{milestone_number}|### Issue への Milestone 割り当て
| 操作 | メソッド | エンドポイント | パラメータ |
|---|---|---|---|
| Milestone 割り当て・変更 |
PATCH|/repos/{owner}/{repo}/issues/{issue_number}|milestone: milestone のnumber(integer) || Milestone 解除 |
PATCH|/repos/{owner}/{repo}/issues/{issue_number}|milestone:null|###
ghCLI 等価コマンド```bash
# Milestone 作成
gh api --method POST repos/{owner}/{repo}/milestones
-f title="M1: Foundation Gate (v0.1.x)"
-f description="開発基盤・運用ルール・最小仕様正本を固めるフェーズ"
# Issue を Milestone に割り当て(gh CLI 経由: --milestone は title/name を渡す)
gh issue edit {issue_number}
--milestone "<milestone_title>"
--repo {owner}/{repo}
# Issue を Milestone に割り当て(REST API 経由: milestone フィールドは number を渡す)
gh api --method PATCH repos/{owner}/{repo}/issues/{issue_number}
-f milestone={milestone_number}
# Milestone 進捗確認
gh api repos/{owner}/{repo}/milestones/{milestone_number}
--jq '{title: .title, open: .open_issues, closed: .closed_issues, state: .state}'
# Milestone 内の PR 混入チェック(全ページ列挙 — PR 直接紐づけ禁止の検証)
gh api --paginate
"repos/{owner}/{repo}/issues?milestone={milestone_number}&state=all&per_page=100"
--jq '.[] | select(.pull_request != null) | {number, title, state, html_url}'
# 出力が非空の場合は human escalation
# Milestone close
gh api --method PATCH repos/{owner}/{repo}/milestones/{milestone_number}
-f state=closed
```
---
## Milestone 識別子規約
GitHub の Milestone には 2 種類の識別子がある。
| 識別子 | フィールド名 | 値の例 | 用途 |
|---|---|---|---|
| number |
number|1,2,3| REST API の path パラメータ。URL に含める識別子。/repos/{owner}/{repo}/milestones/{number}の{number}に使う || id |
id|12345678| GitHub database identifier。GraphQL のnode_id相当。通常の REST 操作では使わない |### 規約
- REST API path パラメータには必ず
numberを使う(idを path に使うと 404 になる)-
gh api/curlでエンドポイントを指定する際はnumberを path に埋め込む-
idは内部参照・GraphQL・webhook payload での識別に使われる場合があるが、REST path には使わない- Milestone 作成直後の readback で
numberを取得・記録し、以後の操作に使用する### readback で number を取得する例
```bash
MILESTONE_NUMBER=$(gh api --method POST repos/{owner}/{repo}/milestones
-f title="M1: Foundation Gate (v0.1.x)"
--jq '.number')
echo "Milestone number (REST path parameter): $MILESTONE_NUMBER"
```
---
## 関連ドキュメント
-
docs/dev/github-ops.md— ラベル運用・認証・Body File Guidance・permissions 方針(SSOT)-
docs/dev/workflow.md— Issue 駆動開発フロー全体(SSOT)-
docs/dev/agent-skill-boundaries.md— SubAgent / Skill 責務境界-
docs/dev/current-focus.md— 現在のフェーズと優先順位"
[6]: https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/creating-issue-dependencies "Creating issue dependencies - GitHub Docs"
[7]: https://raw.githubusercontent.com/squne121/loop-protocol/main/docs/dev/workflow.md "raw.githubusercontent.com"
[8]: https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/adding-sub-issues "Adding sub-issues - GitHub Docs"
[9]: https://docs.github.com/en/rest/issues/sub-issues "REST API endpoints for sub-issues - GitHub Docs"
[10]: https://github.com/github/docs/blob/main/content/rest/using-the-rest-api/using-pagination-in-the-rest-api.md "docs/content/rest/using-the-rest-api/using-pagination-in-the-rest-api.md at main · github/docs · GitHub"
[11]: https://docs.github.com/rest/issues/issues "REST API endpoints for issues - GitHub Docs"
[12]: #133 "導入: GitHub Milestone 運用の実体化 (parent) · Issue #133 · squne121/loop-protocol · GitHub"
squne121 commentedon May 29, 2026
#468 (comment)
結論: 人間コメントは blocker として妥当です。#468 は「
scripts/milestone_rollup.pyを作る」ことだけを contract 化しており、いつ・誰が・どのループから・どの権限で・どの結果をもって停止/通知/修正するのかが未定義です。現状のまま実装すると「便利な手動診断スクリプト」はできますが、M1 close 判定や loop 運用の品質ゲートには接続されません。問題点
#468 の Outcome は、milestone の direct issues、linked PR、親子 Issue、PR 本文 follow-up、Safety Claim Matrix follow-up まで収集すると書いています。一方で Out of Scope では GitHub Actions 組み込み、PR 本文 follow-up 自動解析、自動修正を除外しています。AC も
uv run python3 scripts/milestone_rollup.py 1の手動実行、closed issue の stale state label 警告、milestone null child の警告、常に exit 0 だけです。つまり Outcome が運用統合を匂わせているのに、AC は手動 CLI の smoke test で止まっている状態です。([GitHub]1)さらに
docs/dev/milestone-ops.mdは、Milestone 直接割当は原則 Parent Issue、Implementation Issue は parent 経由の間接所属、PR は Milestone に直接紐づけない、と定義しています。また Milestone close はopen_issues: 0、PR 混入 0、人間判断、scope 変更記録を AND 条件にしており、AI は自動 close しない設計です。([GitHub][2]) したがって #468 の script は単なる一覧ではなく、この SSOT の不変条件を検査する checkerとして設計しないと意味が薄いです。現リポジトリの
.github/workflowsはci.ymlとsession-manifest.ymlのみで、milestone rollup 専用 workflow はありません。([GitHub][3])session-manifest.ymlも push / pull_request の read-only workflow として明示されています。([GitHub][4]) なので「GitHub Actions で自動運用されるのか?」への現時点の答えは いいえ。#468 contract 上も Out of Scopeです。人間コメントへの返答案
修正方針
#468 は以下のように切るべきです。
#468 に残すもの
script-only / read-only / manual diagnosticに限定します。必須変更:
AC はこうするべきです。
exit 0固定は CI/loop 接続前の diagnostic なら妥当ですが、将来の gate 化には不十分です。最初から--strictを入れておくべきです。別 Issue に分けるもの
GitHub Actions integrationは別 Issue にするべきです。GitHub Actions にはissuesevent のopened,edited,milestoned,demilestonedがあり、issue が milestone に追加/削除されたときは milestone event ではなく issues event を使うのが公式に示されています。([GitHub Docs][5])workflow_dispatchとscheduleも使えますが、schedule は default branch 上で動き、遅延・drop の注意があります。([GitHub Docs][5])Actions 化するなら最低限こうです。
コメント投稿までやるなら
issues: writeが必要です。GitHub の公式例でもgh issue createや REST API 経由の Issue 作成にはissues: writeを付けています。([GitHub Docs][6]) ただし #468 の初期版は write 権限なしにすべきです。まず artifact / job summary 出力に留める方が安全です。loop 接続の設計
issue-refinement-loop/impl-review-loopへの接続は #468 ではなく後続 Issue で扱うべきです。docs/dev/workflow.mdは、SSOT、プロンプト層、決定論的ガードレール層を分け、Issue 起票 → refinement → contract review → impl-review-loop → post-merge cleanup という流れを定義しています。([GitHub][7])接続先はこの 3 点です。
issue-refinement-loop
parent / child / milestone の整合性確認。
MILESTONE_ROLLUP_RESULT_V1にchild_missing_milestoneやparent_not_in_milestoneがあれば refinement 対象にする。impl-review-loop preflight
着手 Issue の parent chain をたどり、属する milestone の invariant violation を確認する。ただし milestone 全体の WARN で個別実装を止めると過剰停止になるので、
--strict --scope issue:<N>のような局所判定が必要。post-merge cleanup / milestone close assist
PR merge 後に parent / milestone rollup を再計算し、
open_issues: 0かつ PR 直接紐づけ 0 なら「人間 close 判断待ち」コメントを出す。Milestone close 自体はmilestone-ops.md通り人間だけが実行する。最終判断
#468 は現状 REQUEST_CHANGES 相当です。
このまま進めるなら「手動 diagnostic script」と明記して Outcome を縮小する。
運用まで含めたいなら #468 の Allowed Paths と AC が不足しているため、GitHub Actions・SSOT更新・loop接続を別 Issue 化する。
最も安全な分割は次です。
この切り方なら、スクリプトの出力 contract を先に固定でき、Actions や loop 側がそれを安定して consume できます。
[2]: https://raw.githubusercontent.com/squne121/loop-protocol/main/docs/dev/milestone-ops.md "") | {number, id, state, title, due_on, html_url}'
└─ 同名 0 件 → 1 create へ進む
└─ 同名 1 件 (state=open) → 1 をスキップし update/readback へ進む
└─ 同名 1 件 (state=closed) → human escalation(reopen か新規作成かを人間が判断)
└─ 同名 2 件以上 → human escalation(どれを使うかを人間が判断)
[1] Milestone 作成
└─ gh api --method POST repos/{owner}/{repo}/milestones
-f title="<title>"
-f description=""
[-f due_on=""]
└─ readback: 返却された number・id を記録
[2] Issue を Milestone に割り当て
# gh CLI 経由: --milestone は milestone の title/name を受け取る(number 不可)
└─ gh issue edit {issue_number}
--milestone "<milestone_title>"
--repo {owner}/{repo}
# REST API 経由: milestone フィールドは milestone の number(integer)を渡す
└─ gh api --method PATCH repos/{owner}/{repo}/issues/{issue_number}
-f milestone={milestone_number}
└─ readback: gh issue view {issue_number} --json milestone で確認
└─ readback で milestone が null の場合は silent drop — human escalation
[3] 進捗 rollup
└─ gh api repos/{owner}/{repo}/milestones/{milestone_number}
└─ open_issues / closed_issues を取得
└─ PR 混入チェック: Milestone に PR が直接紐づいていないことを確認
gh api --paginate
"repos/{owner}/{repo}/issues?milestone={milestone_number}&state=all&per_page=100"
--jq '.[] | select(.pull_request != null) | {number, title, state, html_url}'
出力が非空の場合は human escalation(PR 直接紐づけ禁止の運用不変条件違反)
※ --paginate で全ページを列挙する(per_page=100 のみでは 101 件目以降が未検査になる)
└─ 関連 Issue にコメント投稿(github-ops.md の Body File Guidance に従う)
[4] open_issues: 0 を検知したら人間に通知
└─ close は実行しない
```
### 人間 fallback フロー
以下のいずれかの場合、AI エージェントは操作を停止し人間にエスカレーションする:
| 条件 | 対応 |
|---|---|
| 権限不足(403 / 404)| 1. Issue コメント投稿を試みる。2. コメント投稿も失敗した場合は Human Escalation コメント本文を標準出力に完全出力し、追加 write 操作を行わず停止する |
| silent drop(API 呼び出しは 200 だが実際に反映されない)| readback で確認し、不一致を報告 |
| SSOT 衝突(milestone の割り当てが他ドキュメントの方針と矛盾する)| 自動解決せず、矛盾を Issue コメントに記録し人間判断を要求 |
| Milestone close 判断 | AI は close せず、条件を満たしたことを通知するのみ |
| Scope 変更(Issue 追加・除外) | 提案のみ行い、人間の承認後に実行 |
### Human escalation コメントテンプレ
```markdown
## milestone-ops: Human Escalation Required ()
- Milestone: <title> (#)
- 理由: <権限不足 / silent drop / SSOT 衝突 / scope 変更 / close 判断>
- 状況: <具体的なエラー・矛盾の内容>
- 依頼: <人間に実行してほしい操作>
```
---
## GitHub REST API エンドポイント参照
### Milestone CRUD
| 操作 | メソッド | エンドポイント |
|---|---|---|
| 一覧取得 |
GET|/repos/{owner}/{repo}/milestones|| 作成 |
POST|/repos/{owner}/{repo}/milestones|| 取得 |
GET|/repos/{owner}/{repo}/milestones/{milestone_number}|| 更新 |
PATCH|/repos/{owner}/{repo}/milestones/{milestone_number}|| 削除 |
DELETE|/repos/{owner}/{repo}/milestones/{milestone_number}|### Issue への Milestone 割り当て
| 操作 | メソッド | エンドポイント | パラメータ |
|---|---|---|---|
| Milestone 割り当て・変更 |
PATCH|/repos/{owner}/{repo}/issues/{issue_number}|milestone: milestone のnumber(integer) || Milestone 解除 |
PATCH|/repos/{owner}/{repo}/issues/{issue_number}|milestone:null|###
ghCLI 等価コマンド```bash
# Milestone 作成
gh api --method POST repos/{owner}/{repo}/milestones
-f title="M1: Foundation Gate (v0.1.x)"
-f description="開発基盤・運用ルール・最小仕様正本を固めるフェーズ"
# Issue を Milestone に割り当て(gh CLI 経由: --milestone は title/name を渡す)
gh issue edit {issue_number}
--milestone "<milestone_title>"
--repo {owner}/{repo}
# Issue を Milestone に割り当て(REST API 経由: milestone フィールドは number を渡す)
gh api --method PATCH repos/{owner}/{repo}/issues/{issue_number}
-f milestone={milestone_number}
# Milestone 進捗確認
gh api repos/{owner}/{repo}/milestones/{milestone_number}
--jq '{title: .title, open: .open_issues, closed: .closed_issues, state: .state}'
# Milestone 内の PR 混入チェック(全ページ列挙 — PR 直接紐づけ禁止の検証)
gh api --paginate
"repos/{owner}/{repo}/issues?milestone={milestone_number}&state=all&per_page=100"
--jq '.[] | select(.pull_request != null) | {number, title, state, html_url}'
# 出力が非空の場合は human escalation
# Milestone close
gh api --method PATCH repos/{owner}/{repo}/milestones/{milestone_number}
-f state=closed
```
---
## Milestone 識別子規約
GitHub の Milestone には 2 種類の識別子がある。
| 識別子 | フィールド名 | 値の例 | 用途 |
|---|---|---|---|
| number |
number|1,2,3| REST API の path パラメータ。URL に含める識別子。/repos/{owner}/{repo}/milestones/{number}の{number}に使う || id |
id|12345678| GitHub database identifier。GraphQL のnode_id相当。通常の REST 操作では使わない |### 規約
- REST API path パラメータには必ず
numberを使う(idを path に使うと 404 になる)-
gh api/curlでエンドポイントを指定する際はnumberを path に埋め込む-
idは内部参照・GraphQL・webhook payload での識別に使われる場合があるが、REST path には使わない- Milestone 作成直後の readback で
numberを取得・記録し、以後の操作に使用する### readback で number を取得する例
```bash
MILESTONE_NUMBER=$(gh api --method POST repos/{owner}/{repo}/milestones
-f title="M1: Foundation Gate (v0.1.x)"
--jq '.number')
echo "Milestone number (REST path parameter): $MILESTONE_NUMBER"
```
---
## 関連ドキュメント
-
docs/dev/github-ops.md— ラベル運用・認証・Body File Guidance・permissions 方針(SSOT)-
docs/dev/workflow.md— Issue 駆動開発フロー全体(SSOT)-
docs/dev/agent-skill-boundaries.md— SubAgent / Skill 責務境界-
docs/dev/current-focus.md— 現在のフェーズと優先順位"
[3]: https://github.com/squne121/loop-protocol/tree/main/.github/workflows "loop-protocol/.github/workflows at main · squne121/loop-protocol · GitHub"
[4]: https://raw.githubusercontent.com/squne121/loop-protocol/main/.github/workflows/session-manifest.yml "raw.githubusercontent.com"
[5]: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows "Events that trigger workflows - GitHub Docs"
[6]: https://docs.github.com/actions/reference/authentication-in-a-workflow "Use GITHUB_TOKEN for authentication in workflows - GitHub Docs"
[7]: https://raw.githubusercontent.com/squne121/loop-protocol/main/docs/dev/workflow.md "raw.githubusercontent.com"
squne121 commentedon May 29, 2026
Contract Snapshot (2026-05-29T21:44:33Z)
scripts/milestone_rollup.pyが M1 Milestone の direct issues と GitHub native sub-issues descendants を recursive に収集し、MILESTONE_DESCENDANT_ROLLUP_V1schema で stdout に出力するscripts/milestone_rollup.py,scripts/tests/test_milestone_rollup.py.claude/worktrees/issue-468-m1-descendant-rollup-checkerworktree-issue-468-m1-descendant-rollup-checkersqune121 commentedon May 29, 2026
implement-issue: 実装完了 (2026-05-29T21:50:45Z)
.claude/worktrees/issue-468-m1-descendant-rollup-checkerworktree-issue-468-m1-descendant-rollup-checkersqune121 commentedon May 29, 2026
Contract Snapshot Addendum — runtime_only Waiver (2026-05-29T21:56:11Z)
対象: PR #479 のレビューで B1 として指摘された
verification_skipped_count > 0について。Issue #468 の
## Runtime Verification Applicabilityにdecision: not_applicableと明記されている通り、本 Issue はブラウザ / Canvas / WebSocket 等のランタイム動作を含まない。AC1・AC7 の VC は
# preflight-scope: runtime_onlyでマークされており、以下の理由で skip は acceptable とする:uv run python3 scripts/milestone_rollup.py 1は live GitHub API 呼び出しが必要であり、CI 環境のGITHUB_TOKEN設定に依存する。このため preflight での実行はruntime_onlyとして分類するのが妥当vc_preflight.classificationsにもverification_owner: impl-review-loop・runtime_verification_required: trueと記録済みWaiver 根拠:
Runtime Verification Applicability: not_applicablepr-review-judge はこの waiver を参照して APPROVE 可否を判断すること。
fix(#468): address PR #479 human review blockers in milestone_rollup.py
fix(#468): paginated native deps, strict fallback, timeout=30, partia…
feat(#468): add M1 descendant rollup checker (MILESTONE_DESCENDANT_RO…
squne121 commentedon May 29, 2026
post-merge-cleanup: 完了 (2026-05-29T22:43:59Z)
worktree-issue-468-m1-descendant-rollup-checker: 削除済み.claude/worktrees/issue-468-m1-descendant-rollup-checker: 削除済み