Repository navigation
Closed
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phase
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "impl-review-loop 着手直後の初期調査(contract snapshot / VC preflight / worktree / PR / checkout 汚染)を毎回個別コマンドで再確認している重複を、deterministic な intake capsule に集約して read/token bloat を削る"
change_kind: workflowParent Issue
none(単独改善)
Parent Goal Ref
- Goal: impl-review-loop の着手フェーズで、Issue ready 判定・contract snapshot 状態・worktree/PR 状態・main checkout 汚染・agent runtime を、二重実行なしに 1 度で compact に把握できる
- Desired Destination:
build_intake_capsule.pyがIMPL_REVIEW_INTAKE_CAPSULE_V1を返し、preparation がこれを最初に参照してgh issue view/git status/ snapshot 探索の二重実行を避ける
Current Validated Scope
.claude/skills/impl-review-loop/scripts/build_intake_capsule.pyを新規追加し、IMPL_REVIEW_INTAKE_CAPSULE_V1を出力する.claude/skills/impl-review-loop/steps/preparation.mdを更新し、着手直後に capsule を最初に参照する手順へ変更する.claude/skills/impl-review-loop/tests/test_build_intake_capsule.pyを新規追加し、出力契約・stdout budget・本文非露出を検証するIMPL_REVIEW_INTAKE_CAPSULE_V1の各キー(issue_ready_tuple/contract_snapshot/worktree/repo_state/agent_runtime/next_action)
とstdout_budget/artifact/.claude/skills非露出を満たす
Remaining Parent Gaps
- contract blocked 理由の自動分類(vc_design / environment / mixed)は本 Issue では扱わず follow-up(contract blocker triage)で扱う
- worktree 外 mutation の hook enforcement は別 Issue(worktree scope guard)で扱う
Outcome
uv run python3 .claude/skills/impl-review-loop/scripts/build_intake_capsule.py --issue-number 942 --repo squne121/loop-protocol --max-stdout-bytes 4096 が 4096 bytes 以下の valid な IMPL_REVIEW_INTAKE_CAPSULE_V1 を返し、full 詳細は artifacts/impl-review-loop/intake-capsule-<issue>.json に保存され、pnpm typecheck/lint/test/build と新規 pytest が PASS する状態。
In Scope
IMPL_REVIEW_INTAKE_CAPSULE_V1の出力契約(issue_ready_tuple / contract_snapshot / worktree / repo_state / agent_runtime / next_action)- stdout budget(4096 bytes 以下)と artifact への詳細退避
.claude/skills本文全文を出力しない(heading / schema 名のみ)- preparation.md からの参照手順の追加(二重実行回避)
- 対応するテスト追加
.claude/skills/impl-review-loop/scripts/build_intake_capsule.py.claude/skills/impl-review-loop/steps/preparation.md.claude/skills/impl-review-loop/tests/test_build_intake_capsule.py
Out of Scope
- contract blocked 理由の triage 分類(別 Issue)
- worktree 外 mutation の hook enforcement(別 Issue)
ensure_contract_snapshot自体の挙動変更(capsule は既存 dry-run JSON を要約するのみ)- Allowed Paths を impl-review-loop skill 外へ拡張すること
Acceptance Criteria
- AC1: Issue baseline_vc_preflight に GitHub metadata readback 用の安全な assertion 経路を追加する #942 のように
CONTRACT_REVIEW_RESULT_V1 status: goが無い場合、contract_snapshot.status: missingとnext_action.routeにensure_contract_snapshot相当の route を出す。 - AC2:
ensure_contract_snapshotの dry-run JSON が与えられた場合、VC blocked categories を再実行なしでtop_blocked_categoriesに要約する。 - AC3: main checkout が dirty の場合、
repo_state.dirty_paths_summaryに path 件数と代表 path のみを返し、full diff は返さない。 - AC4: stdout は 4096 bytes 以下であり、詳細 artifact を
artifacts/impl-review-loop/intake-capsule-<issue>.jsonに保存する。 - AC5:
.claude/skills本文全文を出力せず、heading と schema 名のみを返す。 - AC6: preparation 手順が capsule を最初に参照し、同じ
gh issue view/git status/ snapshot 探索を二重実行しない(preparation.md に明記され、capsule 参照が手順先頭に来る)。 - AC7:
uv run pytest .claude/skills/impl-review-loop/tests/test_build_intake_capsule.py,pnpm typecheck,pnpm lint,pnpm test,pnpm buildが PASS する。
Runtime Verification Applicability
decision: not_applicable
reason: "tooling script + docs 変更であり、runtime 動作や外部 service 実行を成功条件に含まない。全 AC は pytest / stdout budget / 静的検証で確認可能"Verification Commands
baseline では新規 script / test が未作成のため、AC1〜AC6 の pytest は file not found(pytest exit 4)で baseline-fail する(baseline-expect: fail)。実装後に PASS する。AC7 の pnpm 群は repo 全体の regression gate。
# AC1
# baseline-expect: fail
$ uv run pytest .claude/skills/impl-review-loop/tests/test_build_intake_capsule.py -k "test_ac1_contract_snapshot_missing_routes_to_ensure_contract_snapshot" -v# AC2
# baseline-expect: fail
$ uv run pytest .claude/skills/impl-review-loop/tests/test_build_intake_capsule.py -k "blocked_categories" -v# AC3
# baseline-expect: fail
$ uv run pytest .claude/skills/impl-review-loop/tests/test_build_intake_capsule.py -k "main_dirty_summary" -v# AC4
# baseline-expect: fail
$ uv run pytest .claude/skills/impl-review-loop/tests/test_build_intake_capsule.py -k "stdout_budget or artifact" -v# AC5
# baseline-expect: fail
$ uv run pytest .claude/skills/impl-review-loop/tests/test_build_intake_capsule.py -k "ac5_stdout_does_not_include_full_skill_body" -v# AC6
# baseline-expect: fail
$ uv run pytest .claude/skills/impl-review-loop/tests/test_build_intake_capsule.py -k "ac6_preparation_refers_to_capsule_before_redundant_commands" -v# AC7
# baseline-expect: deferred
$ :Allowed Paths
.claude/skills/impl-review-loop/scripts/build_intake_capsule.py.claude/skills/impl-review-loop/steps/preparation.md.claude/skills/impl-review-loop/tests/test_build_intake_capsule.py
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
ensure_contract_snapshot自体の挙動変更が必要になった場合- In Scope の固定契約(schema キー集合)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割)
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
- 同一 loop 内で capsule が fresh/valid と判定されたにも関わらず、
gh issue view/ comments fetch /git status/ snapshot 探索を再実行する場合 contract_snapshotの source / upstream 失敗分類が混在し、contract_blocker_triageでconcrete routingが構築不能になった場合
Required Skills
- Python 3(argparse / CLI 出力契約 / stdout budget 制御)
- JSON contract / schema 設計(compact stdout と artifact の分離、metadata-only 要約)
Scope Delta(任意)
N/A
Metadata
Metadata
Assignees
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phase
Activity
squne121 commentedon Jun 19, 2026
判定: Request Changes / BLOCK 推奨
#958 の方向性自体は妥当です。現行
preparation.mdは Step 0 でgh issue view、コメント探索、ensure_contract_snapshot、さらに Step 2 で ready tuple 再確認を行う構造になっており、#958 の「着手直後の状態収集を deterministic な capsule に集約する」という狙いは、token/read bloat 削減として筋が通っています。#958 自体もbuild_intake_capsule.py、preparation.md、専用 pytest の3ファイルをスコープにしており、stdout 4096 bytes 以下・詳細 artifact 退避・.claude/skills本文全文を出さない契約を置いています。ただし、現契約のまま実装すると「重複を削る intake capsule」ではなく、「既存の前処理の前にもう1つ追加される要約スクリプト」になりやすいです。特に #959 / #966 / #962 との schema 境界、
ensure_contract_snapshotの status 正規化、GitHub comment/body/log の漏洩境界、再実行禁止の強制力が弱いです。#958 自体にコメントはありませんでした。直接のレビューコメントは無く、関連判断材料は #942 の BLOCK コメント、#959 とその実装PR #980、#966、#962、現行
preparation.md/ensure_contract_snapshot.py/ parser 実装です。主要な敵対的指摘
BLOCKER 1: capsule が「唯一の intake source」になる保証がない
#958 は「preparation が capsule を最初に参照して
gh issue view/git status/ snapshot 探索の二重実行を避ける」としていますが、現行preparation.mdには Step 0 でgh issue view、Issue comment API 探索、Step 2 で再度gh issue viewが明記されています。修正要求:
preparation.mdに「capsule が fresh / valid の場合、同一 loop ではgh issue view、comments fetch、maingit status、snapshot 探索を再実行しない」を MUST として明記してください。単に「最初に参照する」だけでは不十分です。後続ステップは capsule のsource_integrityとcollected_atを読む構造に変える必要があります。BLOCKER 2:
contract_snapshot.status: missingが upstream status を潰す#958 AC1 は、#942 のように
CONTRACT_REVIEW_RESULT_V1 status: goが無い場合にcontract_snapshot.status: missingとnext_action.route: ensure_contract_snapshotを出す、としています。しかし現行
ensure_contract_snapshot.pyはok、blocked_needs_refinement、human_judgment、dry_run_would_post、stale_or_conflicting_snapshot、runtime_errorなど複数の意味を持つ status を返します。check-only で go が無い場合はhuman_judgment / readiness_blockedになり、auto/dry-run ではdry_run_would_postやblocked_needs_refinementにもなります。修正要求: capsule は upstream status を捨てず、最低限こう分けるべきです。
missingだけだと、VC設計不備・環境エラー・stale・単純未実行が同じ route に落ちます。これは intake capsule の価値を損ないます。BLOCKER 3: #959 の triage router と schema 統合しないと即 drift する
#959 は
ensure_contract_snapshotの blocked evidence を pure transform でCONTRACT_BLOCKER_TRIAGE_V1に正規化する Issue で、PR #980 で既に merged されています。PR本文では、raw log を再分類せず、短い triage summary と route key だけを preparation が使う設計になっています。#958 も
top_blocked_categoriesを出すと書いていますが、#959 は「raw command result を再分類しない」「vc_preflight.classifications[]のみを消費する」としており、capsule 側が独自分類を持つと二重正規化になります。修正要求: #958 の
top_blocked_categoriesは独自 classifier ではなく、#959 のCONTRACT_BLOCKER_TRIAGE_V1を参照または埋め込むだけにしてください。たとえば:scalar-only
checks.vc_preflightは #959 側で unsupported とされているため、capsule でも「分類不能」として fail-closed すべきです。BLOCKER 4: GitHub CLI /
gh apisurface の扱いが甘いと危険現行 parser は Issue comments を
gh api --paginate ... --jqで取得します。GitHub CLI のgh apiは REST v3 endpoint だけでなくgraphqlも扱え、-f/-F/--input/--header/--paginate/--slurp/--templateなど広い surface を持ちます。特に request parameter を追加すると通常は POST に切り替わり、--method GETを使うと query string に入る仕様です。(GitHub CLI) (GitHub CLI)#942 の関連コメントでも、raw
gh apiを広げるのではなく、固定 argv + Python JSON parse + exit code 変換に寄せるべきだと BLOCK 指摘されています。修正要求:
build_intake_capsule.pyは shell string を組まず、subprocess.run([...], shell=False)の固定 argv にしてください。Python docs でも、shell 経由ではなく argv list で実行する形が推奨される文脈があります。([Python documentation]2) ([Python documentation]2)加えて、
gh --jqは「表示抽出」に限定し、assertion の合否判定に使わないこと。JSON parse / status normalize は Python 側で行うべきです。BLOCKER 5: 4096 bytes budget が「stdout」しか守っていない
#958 は stdout 4096 bytes 以下と
.claude/skills本文全文を出さないことを AC にしています。しかし漏洩・context汚染の主犯は
.claude/skills本文だけではありません。Issue body、comment body、VC stdout/stderr、ghverbose output、dirty path の大量列挙も同じく危険です。現行ensure_contract_snapshot.pyは stdout を compact JSON のみにする方針を持っていますが、capsule 側も同じ赤線を持たないと崩れます。修正要求: 4096 bytes は
len(json.dumps(..., ensure_ascii=False, separators=(",", ":")).encode("utf-8"))で検証してください。Python の文字数ではなく UTF-8 byte 長です。フィールド単位にも上限を置くべきです。推奨上限:
BLOCKER 6: comment parser の silent skip を capsule が継承すると証跡が消える
現行
contract_review_result_parser.pyはgh api --jqの NDJSON を1行ずつ parse し、json.loadsに失敗した行をpassで無視します。YAML も PyYAML が無ければ簡易fallback parserになり、構造的に弱いです。Issue comments API はデフォルトで ascending ID 順、pagination は
per_page最大100です。([GitHub Docs]3)修正要求: capsule では malformed JSON/YAML を黙殺せず、
source_integrity.parse_warnings[]に件数・種類だけを残してください。body全文は不要ですが、invalid_json_lines_count、invalid_contract_blocks_count、ambiguous_contract_blocks_countは必要です。これがないと「go が無い」のか「parse できなかった」のか区別できません。schema 改訂案
最低限、
IMPL_REVIEW_INTAKE_CAPSULE_V1はこの程度まで固定した方が安全です。{ "schema": "IMPL_REVIEW_INTAKE_CAPSULE_V1", "schema_version": 1, "repo": "squne121/loop-protocol", "issue_number": 958, "generated_at": "ISO8601", "max_stdout_bytes": 4096, "artifact_path": "artifacts/impl-review-loop/intake-capsule-958.json", "source_integrity": { "git_head_sha": "...", "issue_body_sha256": "sha256:...", "issue_updated_at": "...", "comments_digest": "sha256:...", "commands": [ { "name": "issue_view", "argv_sha256": "sha256:...", "exit_code": 0, "stdout_sha256": "sha256:...", "collected_at": "ISO8601" } ], "parse_warnings": [], "evidence_complete": true }, "issue_ready_tuple": { "title_prefix_ok": true, "phase_label_present": true, "dependency_state": "all_closed | blocked | unknown", "status": "pass | failed | unknown" }, "contract_snapshot": { "normalized_status": "go | missing_go | latest_blocked | stale | human_judgment | runtime_error", "upstream_schema": "CONTRACT_REVIEW_RESULT_V1 | CONTRACT_SNAPSHOT_ENSURE_RESULT_V1 | none", "upstream_status": "ok | blocked_needs_refinement | human_judgment | dry_run_would_post | stale_or_conflicting_snapshot | runtime_error | null", "source": "existing_go | latest_blocked | readiness_blocked | materialized_go | none", "contract_snapshot_url": null, "top_blocked_categories": [], "contract_blocker_triage": { "schema": "CONTRACT_BLOCKER_TRIAGE_V1", "status": "not_run" } }, "worktree": { "status": "clean | dirty | unavailable | deferred_to_concurrent_work_ledger", "current_branch": "...", "head_sha": "..." }, "repo_state": { "dirty_paths_summary": { "count": 0, "sample": [], "truncated": false } }, "agent_runtime": { "status": "unknown | available | deferred_to_capability_router", "route": null }, "next_action": { "route": "continue | ensure_contract_snapshot | run_contract_blocker_triage | stop_human | refresh_contract_snapshot", "reason_codes": [] } }関連Issueとの整合要求
#966 は
CONCURRENT_WORK_LEDGER_V1を作り、active worktrees / main checkout / overlaps を capsule に20行以内で埋め込む前提です。#958 が先に弱い worktree summary を独自実装すると、#966 と責務衝突します。#962 は
WORKER_CAPABILITY_ROUTE_V1をagent_runtimeフィールドへ反映する前提です。#958 側でagent_runtimeを曖昧な文字列にすると、Haiku fallback 制限や high-reasoning route と衝突します。#960 / #963 は worktree外 mutation や staging 混入の hook enforcement です。#958 はそれらを「防ぐ」Issueではなく、検出・要約・routeするだけに留めるべきです。
改訂AC案
現ACに加えて、最低限以下を足してください。
テスト追加案
test_build_intake_capsule.pyは golden happy path だけでは不足です。既存test_ensure_contract_snapshot.pyのように importlib + mock runner で固定する方針は使えます。追加すべきケース:
argparseはデフォルトで abbreviation を許すため、fail-closed CLI にするならallow_abbrev=Falseを指定するのが安全です。([Python documentation]4)実装PRが出た場合の reject 条件
実装PRは以下のどれかに該当したら Request Changes で止めるべきです。
build_intake_capsule.pyが capsule 作成後もpreparation.mdの既存gh issue view/ comments fetch /git statusを残している。missing/blocked/runtime_error/human_judgmentを同じnext_action.routeに潰している。top_blocked_categoriesを 実装: ensure_contract_snapshot blocked 結果の contract triage を自動化する #959 のCONTRACT_BLOCKER_TRIAGE_V1ではなく独自分類している。shell=True、shell string、または broadgh apiwrapper を使っている。artifacts/impl-review-loop/intake-capsule-<issue>.jsonに詳細を保存するが、その artifact の redaction / gitignore / path containment が未検証。pnpm typecheck/lint/test/buildと targeted pytest だけで、capsule schema golden / byte budget / preparation ordering test が無い。最終評価
#958 は 実装してよいが、現契約のままでは危険です。特に「一括収集」の核は script 追加ではなく、
preparation.mdの既存 read path を capsule consumer に置き換えることです。修正後の到達点は、
IMPL_REVIEW_INTAKE_CAPSULE_V1が Step 0 の canonical input になり、#959 の triage、#966 の ledger、#962 の capability route を安全に接続できる schema hub になることです。現状のACだけだと、そこまで保証できません。squne121 commentedon Jun 19, 2026
Refinement Loop: Approved
The issue has been approved and is ready for implementation.
approvedsqune121 commentedon Jun 19, 2026
Contract Review Result
feat(workflow): add intake capsule builder for impl-review-loop (#958)
chore: trigger PR check rerun (#958)
feat(workflow): add intake capsule builder for impl-review-loop (#958)
squne121 commentedon Jun 19, 2026
impl-review-loop: 完了 (2026-06-20T00:00:00Z)
squne121 commentedon Jun 19, 2026
post-merge-cleanup: 完了 (2026-06-20T00:00:00Z)
git status --shortの差分解消後に再実施squne121 commentedon Jun 19, 2026
post-merge-cleanup: 完了 (訂正版 2026-06-20T00:00:00Z)
feat(workflow): add intake capsule builder for impl-review-loop (#958) (
squne121 commentedon Jun 19, 2026
post-merge-cleanup: 完了 (2026-06-19T23:37:07Z)
squne121 commentedon Jun 19, 2026
post-merge-cleanup: 完了 (2026-06-20T00:00:00Z)
squne121 commentedon Jun 19, 2026
POST_MERGE_CLEANUP_REPORT_V1
status: complete
scope: chore/gitignore-cleanup, pr-1002-test のローカル削除戻し + 保留中ワークツリー一括整理
human_review_required: false
cleaned_branches: [chore/gitignore-cleanup, pr-1002-test]
cleaned_worktrees: [agent-a283835860f621a8f, issue-828-context-mode-ops-docs, issue-829-termination-comment-cause, issue-929-playwright-docker-migration, issue-943-pnpm-ci-build, issue-970-secret-boundary-multiedit, issue-993-vc-grammar-unify-fix, resolve-missing-deps, issue-958-impl-review-loop-intake-capsule-issue-co, /tmp/loop-pr957, /tmp/loop-protocol-pr957, /tmp/loop-protocol-pr957-v2, /tmp/pr957-head, issue-828 deleted fixture restored before remove]
cleaned_refs: [worktree-agent-a283835860f621a8f, worktree-issue-828-context-mode-ops-docs, worktree-issue-829-termination-comment-cause, worktree-issue-929-playwright-docker-migration, worktree-issue-943-pnpm-ci-build, worktree-issue-958-impl-review-loop-intake-capsule-issue-co, worktree-issue-970-secret-boundary-multiedit, worktree-issue-993-vc-grammar-unify-fix, worktree-resolve-missing-deps]
notes: ローカル main ワークツリーの未コミット差分は無し。,-R,text