Skip to content

feat(#393): thin issue-refinement-loop entrypoint - #413

Merged
squne121 merged 5 commits into
mainfrom
worktree-issue-393-thin-entrypoint
May 26, 2026
Merged

squne121 merged 5 commits into
mainfrom
worktree-issue-393-thin-entrypoint

Conversation

@squne121

@squne121 squne121 commented May 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • issue-refinement-loop/SKILL.md を thin entrypoint に縮小しつつ、Step 0 の実行順序と LOOP_STATE の routing-critical field を entrypoint 側へ戻しました。
  • anchor comment handling、scope signal guard、AC/VC reflection、follow-up materialization、web research routing、termination policy を topic 別 reference に分割しました。
  • thin-entrypoint sentinel と forbidden-fragment pytest に加え、Step 0 順序・routing field・Product/Spec fail-closed routing の regression test を追加しました。

受け入れ条件の達成状況

  • AC1 references/index.md を追加しました。
  • AC2 thin entrypoint sentinel ISSUE_REFINEMENT_LOOP_THIN_ENTRYPOINT_V1 を追加しました。
  • AC3 SKILL.md を 235 行 / 10289 bytes に縮小し、500 行以下を満たしました。
  • AC4 required topic references を SKILL.md から明示リンクしました。
  • AC5 plan_refinement_loop.py / REFINEMENT_LOOP_PLAN_V1 consume を entrypoint に残しました。
  • AC6 termination / follow-up / web research / anchor handling の意味論を reference owner file に退避し、Step 0 順序と Product/Spec routing の fail-closed semantics を補いました。
  • AC7 repo gate と issue-refinement-loop tests を実行して PASS しました。
  • AC8 planner 判定条件の prose 再実装を SKILL.md から除去しました。
  • AC9 tests/test_thin_entrypoint.py を追加し、順序と routing-critical fields の回帰も検証するようにしました。
  • AC10 references/index.md に topic / file / loaded_when / owner / moved_from / must_not 列を追加しました。
  • AC11 frontmatter decision と実測値をこの PR 本文に記録しました。

Frontmatter Decision

Item Decision Reason
disable-model-invocation: true not adopted issue-refinement-loop は planner / reviewer / worker を束ねる orchestrator であり、モデル呼び出し自体を禁止すると routing entrypoint の役割を壊すため。
paths frontmatter not adopted trigger は path-local ではなく Issue contract / command phrase / comment context に依存し、実際の編集境界は Issue contract の Allowed Paths と worker 側 guard で制御しているため。

Measurement

Metric Value
SKILL.md lines 235
SKILL.md bytes 10289
frontmatter description chars 167
references/index.md chars 1711
references/*.md file count 9

検証コマンド結果

  • pnpm typecheck
  • pnpm lint
  • pnpm test
  • pnpm build
  • uv run python3 -m pytest .claude/skills/issue-refinement-loop/tests/ -q
  • uv run python3 -m pytest .claude/skills/issue-refinement-loop/tests/test_thin_entrypoint.py -v
  • uv run python3 -m pytest .claude/skills/issue-refinement-loop/tests/test_skill_md_wiring.py -v

Allowed Paths 遵守

  • .claude/skills/issue-refinement-loop/SKILL.md
  • .claude/skills/issue-refinement-loop/references/
  • .claude/skills/issue-refinement-loop/tests/
  • .claude/skills/issue-refinement-loop/fixtures/ は未変更

Schema Change Applicability

  • decision: not_schema_change
  • reason: 既存 schema ID や machine-readable contract のキー集合は変更せず、skill entrypoint と reference 構成、およびそれを検証する pytest のみを更新したため。

Schema Consumer Inventory

N/A: schema 変更なし。

Compatibility Decision

  • change_type: N/A
  • compatibility: N/A
  • migration_required: N/A
  • migration_or_followup: N/A
  • reason: schema 変更なし。

Safety Claim Matrix

N/A: safety boundary / auth / sandbox / transport の挙動変更はありません。skill docs と test coverage の再構成のみです。

Notes

@squne121
squne121 marked this pull request as ready for review May 26, 2026 10:25
@squne121

Copy link
Copy Markdown
Owner Author

判定

REQUEST_CHANGES。
方向性は妥当です。SKILL.md を 220 行まで落とし、references/ と sentinel / pytest を追加した点は #393 の主目的に沿っています。PR本文でも、SKILL.md 220 行、references/*.md 9 件、Frontmatter Decision、検証コマンド結果が記録されています。

ただし、thin entrypoint 化の過程で実行順序と LOOP_STATE 契約が落ちています。 このままマージすると、軽量化には成功しても orchestration semantics が壊れる可能性があります。

良い点

Claude Code 公式 docs は、supporting files に詳細を逃がして SKILL.md を focused に保つこと、詳細 reference は必要時だけ読むこと、SKILL.md は 500 行未満にすることを明示しています。今回の SKILL.md 220 行化と references/index.md はこの方向に合っています。([Claude Code]1)

disable-model-invocation: true と paths frontmatter を採用しない判断も、PR本文で明示されており、#393 AC11 は形式上満たしています。Claude Code docs 上も disable-model-invocation は自動ロードを防ぐ手段であり、明示起動専用 workflow 向けです。今回の skill が orchestrator として自動 routing される可能性を残したいなら、不採用判断自体は合理的です。 ([Claude Code]1)

SubAgent 側を触っていない点もよいです。Claude Code subagents は独立 context window、custom system prompt、tool access、permission を持つため、.claude/agents/*.md や tools / disallowedTools をこのPRで変えると挙動変更になります。#394 に defer する境界は正しいです。([Claude Code]2)

Blockers

1. Step 0 の順序が #393 / scope-rollup-policy と矛盾している

PR後の SKILL.md は Step 0 で、hard stop → anchor → stale label hygiene → scope rollup / Product routing の順に読めます。つまり state/blocked / state/queued の削除 mutation が scope rollup preflight より前に来ています。

これは既存契約と逆です。#393 は scope rollup preflight と Product/Spec signal detection を Step 0-hygiene より前に実行する前提で書かれており、scope-rollup-policy.md も issue-refinement-loop では Step 0d 完了後、Step 0-hygiene 実行前に ISSUE_SCOPE_ROLLUP_DECISION_V2 を記録すると定義しています。

修正案:

### Step 0: Preconditions

1. Issue 本文と必要コメントを取得し、`state/needs-human` / `state/done` の hard stop を確認する。
2. `anchor_comment_url` がある場合は snapshot を固定し、対象 Issue 所属を検証する。
3. scope rollup preflight を mutation-free で実行し、`LOOP_STATE.scope_rollup_decision` を記録する。
4. Product/Spec routing signal を検知し、`LOOP_STATE.product_spec_context` を記録する。
5. 本 Issue への refinement 継続が確定した後、stale な `state/blocked` / `state/queued` を hygiene として除去する。

これはマージ前に必須修正です。

2. LOOP_STATE summary から重要 field が落ちている

PR #407 は plan_refinement_loop.py の出力を consume して、LOOP_STATE.investigation_policy、web_research_policy、scope_signal_guard、delivery rollup、follow-up candidates を populate する設計でした。

しかし PR #413 の LOOP_STATE Summary には、少なくとも以下が見当たりません。

  • scope_rollup_decision
  • scope_signal_guard
  • delivery_rollup
  • follow_up_materialization
  • superseded_decision

特に scope_rollup_decision は scope-rollup-policy 側で LOOP_STATE.scope_rollup_decision に記録すると明記されています。entrypoint の summary から消えると、orchestrator が planner input assembly や routing 時に落とす危険があります。

修正案: LOOP_STATE Summary に最小 field だけ復元してください。詳細 schema は references に逃がしてよいですが、routing-critical field 名は entrypoint に残すべきです。

  scope_rollup_decision: null
  scope_signal_guard:
    triggered: false
    excluded_by_anchor_reframe: false
    reason_code: null
  delivery_rollup:
    applicable: false
    unmaterialized_slots: []
  follow_up_materialization:
    candidates: []
  superseded_decision:
    decision_summary: null
    alternative_issue_number: null
    close_reason: null

3. Product/Spec routing が thin 化で弱くなりすぎている

scope-signal-guard.md には Product/Spec routing の summary はありますが、旧 Step 0e の「tasks.md signal は fail-closed で implementation route に進めない」「routing_target を issue_materialization にする」などの実行上重要な state 更新が、かなり圧縮されています。

#393 は tasks.md / Spec Kit routing を references に逃がすことは許していますが、意味論の保持を AC6 にしています。 現状の reference は「summary」としては読めますが、orchestrator がどの field を更新するかが曖昧です。

修正案: scope-signal-guard.md に最低限これを戻してください。

product_spec_routing_gate:
  tasks_md_signal:
    work_kind: tasks_materialization
    routing_target: issue_materialization
    fail_closed: true
    implementation_route_allowed: false

4. test_thin_entrypoint.py は存在検査中心で、意味論保持をほぼ検証していない

追加テストは sentinel、500 行以下、index column、required reference link、旧 prose fragment の不存在、reference file の存在を見ています。 これは AC1〜AC5 / AC8〜AC10 の表層確認としては有効です。

しかし、今回実際に起きている Step 0 順序逆転 や routing-critical LOOP_STATE field の欠落 は検出できません。つまり「thin entrypoint であること」は守れても、「同じ orchestrator として動くこと」は守れていません。

修正案: 少なくとも以下の regression tests を追加してください。

def test_step0_orders_scope_rollup_before_hygiene():
    text = load_skill_md()
    assert text.index("scope rollup") < text.index("state/blocked")

def test_loop_state_summary_keeps_routing_critical_fields():
    text = load_skill_md()
    for field in [
        "scope_rollup_decision",
        "scope_signal_guard",
        "delivery_rollup",
        "follow_up_materialization",
    ]:
        assert field in text

より堅くするなら、scope-rollup-policy.md 側の Step 0d 完了後、Step 0-hygiene 実行前 と entrypoint の順序を両方検証してください。

Non-blocking comments

references/index.md は必要列を満たしていますが、owner が planner + orchestrator のような複合表現になっている箇所は、将来また責務が曖昧になりやすいです。planner owns detection / orchestrator owns routing のように分解した方が安全です。

web-research-routing.md は #203 / #394 境界を守り、retry / fallback / raw grounding state を保持しないと明記しています。この点は維持でよいです。

PR #311 の先例では、thin entrypoint 化後も known follow-up を明示し、矛盾がある reference は別Issue化していました。今回も、意味論保持テストの不足を #413 内で直せない場合は follow-up ではなく blocker として扱うべきです。なぜならこれは「追加改善」ではなく orchestration の退行だからです。

投稿用レビュー案

REQUEST_CHANGES

thin entrypoint 化の方向性は妥当です。`SKILL.md` 220 lines、references/index、sentinel、forbidden-fragment pytest、Frontmatter Decision の記録は #393 の主目的に沿っています。

ただし、現差分には semantic regression があります。

Blockers:

1. Step 0 の順序が壊れています。
   現 `SKILL.md` は stale state label hygiene を scope rollup / Product-Spec routing より前に実行する読み順です。しかし #393 と `references/scope-rollup-policy.md` は、scope rollup preflight と `ISSUE_SCOPE_ROLLUP_DECISION_V2` 記録を Step 0-hygiene より前に行う前提です。hygiene は mutation なので、preflight より前に置かないでください。

2. `LOOP_STATE Summary` から routing-critical fields が落ちています。
   `scope_rollup_decision`, `scope_signal_guard`, `delivery_rollup`, `follow_up_materialization` は PR #407 の planner consume / routing に必要です。詳細 schema は references に逃がしてよいですが、field 名は entrypoint summary に残してください。

3. Product/Spec routing summary が弱くなりすぎています。
   `tasks.md` signal の fail-closed、`work_kind: tasks_materialization`, `routing_target: issue_materialization`, implementation route 禁止は reference 側に明示してください。

4. `test_thin_entrypoint.py` が存在・リンク・旧 fragment 不存在の検査に偏っており、今回の Step 0 順序逆転や LOOP_STATE field 欠落を検出できません。
   `scope rollup before hygiene` と routing-critical fields の regression test を追加してください。

この修正なしにマージすると、固定 token cost は下がりますが、issue-refinement-loop の orchestration semantics が落ちます。

結論

現状はマージ不可。
最小修正は、SKILL.md の Step 0 順序修正、LOOP_STATE Summary の routing-critical field 復元、Product/Spec routing field の reference 明文化、pytest の regression 追加です。これが入れば、かなりマージに近いです。

@squne121

Copy link
Copy Markdown
Owner Author

判定: REQUEST_CHANGES寄り。マージ前に 1 点だけ直したい

PR #413 は #393 の主目的である issue-refinement-loop/SKILL.md の thin entrypoint 化、references/ 分割、planner SSOT 化、frontmatter 採否記録を概ね満たしています。PR 本文上も、SKILL.md 235 行、references/*.md 9 件、Frontmatter Decision、検証コマンド結果が記録されています。

Claude Code 公式 docs でも、複雑な skill は supporting files に詳細を分離し、SKILL.md は 500 行未満に保つこと、skill content は読み込まれると context に残るため各行が継続 token cost になることが明記されています。今回の方向性はその実装慣行に合っています。([Claude Code]1)

良い点

#393 の AC はかなり消化されています。references/index.md は topic / file / loaded_when / owner / moved_from / must_not を持ち、各 reference の読み込み条件と責務境界を一覧化しています。

前回レビューで問題視されていた Step 0 の順序、routing-critical な LOOP_STATE field、Product/Spec fail-closed routing は現在の差分では復元済みです。SKILL.md は scope rollup → Product/Spec routing → stale label hygiene の順で書かれ、scope_rollup_decision / scope_signal_guard / delivery_rollup / follow_up_materialization / superseded_decision も summary に戻っています。

scope-signal-guard.md も tasks.md signal を tasks_materialization とし、routing_target: issue_materialization、fail_closed: true、implementation_route_allowed: false を明示しています。これは旧 Step 0e の重要意味論を reference 側に保持できています。

SubAgent 側を触っていない点も妥当です。Claude Code の subagent は独立 context、system prompt、tool access、permission を持つため、.claude/agents/*.md や tools / disallowedTools / model / skills をこの PR で触ると挙動変更になります。#394 に defer する境界は正しいです。([Claude Code]2)

Blocker

1. anchor_comment の詳細 metadata が reference 側でも曖昧になっている

旧 SKILL.md の LOOP_STATE.anchor_comment は、id、issue_number、html_url、api_url、user_login、author_association、snapshot、captured_at、fetched_at、comment_created_at、comment_updated_at まで明示していました。

現行 PR では entrypoint summary からそれらを落とす判断自体は許容できますが、移設先の anchor-comment-handling.md でも「本文・issue_url・投稿者 metadata」「snapshot と取得 metadata」としか書かれておらず、最低限保持すべき field set が機械可読に固定されていません。

これは薄くしたこと自体の問題ではなく、監査可能性と stale comment 判定の退行リスクです。特に author_association は trusted author policy で OWNER / MEMBER / COLLABORATOR 判定に使うのに、Required flow / schema 側で必須 field として固定されていません。

修正案:

## Required LOOP_STATE fields

`LOOP_STATE.anchor_comment` MUST preserve at least:

```yaml
anchor_comment:
  url: <string>
  id: <string>
  issue_number: <int>
  html_url: <url>
  api_url: <url>
  user_login: <string>
  author_association: OWNER | MEMBER | COLLABORATOR | CONTRIBUTOR | NONE
  snapshot: <string>
  captured_at: <iso8601>
  fetched_at: <iso8601>
  comment_created_at: <iso8601>
  comment_updated_at: <iso8601>
  preliminary_classification: superseded_by_decision | reframe_in_place | feedback_update_required | human_escalation
  final_classification: superseded_by_decision | reframe_in_place | feedback_update_required | human_escalation | null
  classification_reason: <string|null>
  verified_claims: []
  unresolved_claims: []
  scope_impact: none | amend | replace | ambiguous | null
  requires_fact_check: <bool>

Trusted author policy depends on author_association; do not omit it from the captured snapshot metadata.


`test_thin_entrypoint.py` か別テストで、`anchor-comment-handling.md` に `author_association`, `comment_updated_at`, `captured_at`, `api_url` が残っていることだけでも regression guard にしてください。

## Non-blocking

`test_thin_entrypoint.py` は前回指摘の Step 0 順序、routing-critical field、Product/Spec fail-closed routing を検査するよう改善されています。これは良いです。ただし sentinel test は `max_skill_lines: 500` と `subagent_contract_mode: link_only` までは直接 assert していません。行数 test と Out of Scope で実質カバーされていますが、sentinel の契約性を高めるなら追加 assert してよいです。:contentReference[oaicite:9]{index=9}

`web-research-routing.md` は #203 / #394 境界を概ね守っています。`WEB_RESEARCH_RESULT_V1` は web-researcher / gemini-cli-headless-delegation 側を SSOT とし、orchestrator は consumer fields のみを読む、retry/fallback/raw grounding state を保持しない、という線引きは妥当です。:contentReference[oaicite:10]{index=10}

## 投稿用レビュー案

```md
REQUEST_CHANGES

#413 は #393 の主目的である `issue-refinement-loop/SKILL.md` の thin entrypoint 化、references 分割、planner SSOT 化を概ね満たしています。Step 0 順序、routing-critical LOOP_STATE fields、Product/Spec fail-closed routing も前回指摘から修正されています。

ただし、anchor comment handling の metadata contract が薄くなりすぎています。

旧 SKILL.md は `LOOP_STATE.anchor_comment` に `id`, `issue_number`, `html_url`, `api_url`, `user_login`, `author_association`, `snapshot`, `captured_at`, `fetched_at`, `comment_created_at`, `comment_updated_at` を明示していました。現 PR では entrypoint summary から落とすのはよいですが、移設先の `references/anchor-comment-handling.md` でも「投稿者 metadata」「取得 metadata」としか書かれておらず、最低保持 field が固定されていません。

特に `author_association` は trusted author policy の `OWNER / MEMBER / COLLABORATOR` 判定に必要です。ここが曖昧だと、thin entrypoint 化によって stale comment / untrusted comment の分類が退行します。

修正してください:

- `references/anchor-comment-handling.md` に `LOOP_STATE.anchor_comment` の最低必須 field set を YAML で明記する
- 少なくとも `author_association`, `comment_updated_at`, `captured_at`, `api_url`, `snapshot` を必須 field として残す
- 可能なら pytest で required field 名の存在を regression guard にする

この修正が入れば、マージ可能にかなり近いです。

@squne121

Copy link
Copy Markdown
Owner Author

CI checks were not attached to the latest head commit, so this PR is being temporarily closed and reopened to retrigger pull_request workflows.

@squne121 squne121 closed this May 26, 2026
@squne121 squne121 reopened this May 26, 2026
@squne121
squne121 marked this pull request as draft May 26, 2026 11:03
@squne121
squne121 marked this pull request as ready for review May 26, 2026 11:03
@squne121
squne121 force-pushed the worktree-issue-393-thin-entrypoint branch from c49ec89 to 90eabf2 Compare May 26, 2026 11:15
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.

1 participant