Skip to content

docs: sync issue-refinement-loop design note contracts - #1017

Merged
squne121 merged 3 commits into
mainfrom
worktree-issue-1012-issue-refinement-loop
Jun 20, 2026
Merged

squne121 merged 3 commits into
mainfrom
worktree-issue-1012-issue-refinement-loop

Conversation

@squne121

@squne121 squne121 commented Jun 20, 2026 •

Copy link
Copy Markdown
Owner

概要

  • issue-refinement-loop の派生設計ノートを SSOT(SKILL.md)に合わせ、
    max_iterations と停止セマンティクスの齟齬を解消しました。
  • DERIVED_RUNTIME_CLAIMS_V1 を追加して、実行時重要契約を明示しました。
  • stale 再発を検知するため、回帰テストを追加しました。

関連Issue: #1012 を解決します。

@github-actions

github-actions Bot commented Jun 20, 2026 •

Copy link
Copy Markdown
Contributor

Preview URL

Preview removed (PR #1017 closed).

@squne121 squne121 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOOP_VERDICT_V2

LOOP_VERDICT_V2:
  verdict: APPROVE
  reviewed_head_sha: "f9c7701a8da3562ac1aa4e23812de4294f6a2a93"
  merge_ready: false
  mergeability:
    mergeable: MERGEABLE
    merge_state_status: BEHIND
  allowed_paths_gate:
    status: ok
    producer_role: review_subagent
    worker_report_used_as_canonical: false
  blockers: []
  required_auto_actions:
    - kind: update_branch
      executor: implementation-worker
      skill: implement-issue.update_branch
      expected_head_sha: "f9c7701a8da3562ac1aa4e23812de4294f6a2a93"
      blocking_merge_ready: true
      mechanical: true
  auto_fix_applied: []
  follow_up_issue_requests: []

@squne121 squne121 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOOP_VERDICT_V2

LOOP_VERDICT_V2:
  verdict: APPROVE
  reviewed_head_sha: "67da7713203a9d7e322c2533c94ed88656726f14"
  merge_ready: true
  mergeability:
    mergeable: MERGEABLE
    merge_state_status: CLEAN
  allowed_paths_gate:
    status: ok
    producer_role: review_subagent
    worker_report_used_as_canonical: false
  blockers: []
  required_auto_actions: []
  auto_fix_applied: []
  follow_up_issue_requests: []

@squne121

Copy link
Copy Markdown
Owner Author

判定: REQUEST_CHANGES

PR #1017 の方向性は正しいです。#1012 の要求どおり、max_iterations=1 / needs_second_pass 由来の stale contract を潰し、DERIVED_RUNTIME_CLAIMS_V1 と回帰テストを追加しています。PR上の最終 LOOP_VERDICT_V2 も merge_ready: true、CI も ci / python-test 等が成功しています。

ただし、merge すると stale design note を完全には防げません。残存しているズレが実運用の誤読に直結するので、現状は止めるべきです。

Blockers

1. iteration >= max_iterations が残っており、0-indexed routing と矛盾する

design note の State Model と Failure Mode はまだ iteration >= max_iterations と書いています。

しかし canonical は iteration + 1 >= max_iterations です。SKILL、loop-state.md、decide_next_loop_action.py がすべてこの条件で一致しています。

これは表記ゆれではありません。iteration が 0-indexed の現在ラウンドなら、max_iterations=3 で iteration=2 の needs-fix は停止です。iteration >= max_iterations と読むと 1 回余分に回せる解釈になります。

修正要求:

  • design note 内の停止条件を全部 last_verdict == needs-fix AND iteration + 1 >= max_iterations -> human_escalation に統一
  • iteration >= max_iterations を design note から原則排除
  • テストに「design note に裸の iteration >= max_iterations が残ったら fail」を追加

2. ISSUE_REVIEW_RESULT_COMPACT_V1 なのに、旧 full contract の field を読む設計が残っている

SubAgent Contract Matrix は schema を ISSUE_REVIEW_RESULT_COMPACT_V1 に更新していますが、Fields read by orchestrator に needs_second_pass, blocking_issues, non_blocking_improvements, diff_proposal を残しています。

現行 SKILL は、orchestrator は STATUS と VERDICT だけで routing し、full structured data は EVIDENCE: / ARTIFACT: パスから取得すると明記しています。 PR #805 も raw REVIEW_ISSUE_RESULT_V1 を compact stdout と full artifact JSON に分離する変更です。

修正要求:

  • issue-reviewer 行の “Fields read by orchestrator” を STATUS, VERDICT のみにする
  • needs_second_pass は compact routing field ではないので削除
  • full review payload は artifact-only / opaque と明記

3. LOOP_STATE の参照先がまだ stale

design note は LOOP_STATE の完全定義を SKILL.md の ## LOOP_STATE Summary としています。 しかし現在の SKILL は、機械可読 schema は schemas/loop_state.schema.json、field/routing semantics は references/loop-state.md、next action は decide_next_loop_action.py に委譲すると書いています。

DERIVED_RUNTIME_CLAIMS_V1 では references/loop-state.md を期待値にしていますが、本文の prose が古いままです。

修正要求:

  • LOOP_STATE 定義参照を schemas/loop_state.schema.json + references/loop-state.md + scripts/decide_next_loop_action.py に更新
  • SKILL.md は thin entrypoint / reference map として扱い、field definition の正本扱いにしない

Test gaps

追加されたテストは有用ですが、まだ「stale を検出するテスト」ではなく「正しい文字列がどこかにあることを確認するテスト」に寄っています。

  • canonical_selector は存在確認だけで、実際には selector を解決していません。
  • iteration termination test は SKILL 全体に needs-fix、iteration + 1 >= max_iterations、human_escalation が別々に存在することしか見ていません。同じ routing rule で結合している保証がありません。
  • long-copy 検出は SKILL.md だけを対象にしていますが、design note の canonical_sources は agent 定義や agent-skill-boundaries.md も含みます。
  • not_loaded_when は frontmatter YAML を parse せず、単に本文中の文字列を grep しています。

修正要求:

  • frontmatter と DERIVED_RUNTIME_CLAIMS_V1 を YAML として parse する
  • canonical_sources を列挙し、少なくとも存在する source 全部を long-copy 検出対象にする
  • decide_next_action() に対して iteration=1,max=3,needs-fix -> continue と iteration=2,max=3,needs-fix -> human_escalation の contract test を追加
  • design note 全文に needs_second_pass が残ったら fail
  • design note 全文に裸の iteration >= max_iterations が残ったら fail

Web調査に基づく実装改善

yaml.safe_load を使っている点は正しいです。PyYAML は yaml.load が信頼できない入力に対して危険になり得ること、safe_load が標準タグだけを扱うことを公式に説明しています。

一方で negative fixture は repo 実体に強く依存しています。pytest の tmp_path は各 test function 固有の一時ディレクトリを pathlib.Path として提供するので、stale fixture は tmp_path に書いて検査する方が安全です。([pytestドキュメント]1)

また _repo_root() の fallback current.parents[7] は brittle です。Path.parents は祖先パスの sequence なので、実行場所やパッケージ配置が変わると index 前提が壊れます。([Python documentation]2) .git が見つからない場合は fallback せず、明示的に fail させる方がテストとして健全です。

Non-blocking

投稿用レビューコメント案

## Verdict: REQUEST_CHANGES

方向性は正しいですが、まだ stale contract が残っています。

### Blockers

1. `iteration >= max_iterations` が design note に残っています。canonical は `iteration + 1 >= max_iterations` です。`iteration` は 0-indexed の現在ラウンドなので、この差は off-by-one の実運用バグになります。

2. `ISSUE_REVIEW_RESULT_COMPACT_V1` に更新した一方で、SubAgent Contract Matrix は `needs_second_pass`, `blocking_issues`, `non_blocking_improvements`, `diff_proposal` を orchestrator read fields として残しています。現行 SKILL は `STATUS` / `VERDICT` のみで routing し、full structured data は artifact 経由です。

3. `LOOP_STATE` の本文参照がまだ SKILL.md の `## LOOP_STATE Summary` になっています。現在の正本は `schemas/loop_state.schema.json` / `references/loop-state.md` / `decide_next_loop_action.py` です。

4. 新設テストは `canonical_selector` を解決しておらず、文字列の同居確認に留まっています。`iteration + 1 >= max_iterations` と `human_escalation` が同じ routing rule で結合していることを保証していません。

5. long-copy 検出が `SKILL.md` のみ対象です。design note の `canonical_sources` 全体を対象にしてください。

### Required fixes

- design note から裸の `iteration >= max_iterations` と `needs_second_pass` を排除する。
- `issue-reviewer` compact contract の read fields を `STATUS` / `VERDICT` のみにする。
- `LOOP_STATE` 参照先を current canonical に更新する。
- `decide_next_action()` に対する boundary tests を追加する。
- frontmatter / claims block を YAML parse して検査し、`canonical_sources` 全体を long-copy 検出対象にする。

このPRは「CI green だが semantic red」です。修正範囲は小さいので、上記を直せば merge 可能です。

@squne121 squne121 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOOP_VERDICT_V2

LOOP_VERDICT_V2:
  verdict: APPROVE
  reviewed_head_sha: "37f5298db1577dd2090401c1023e82c100494b81"
  merge_ready: true
  mergeability:
    mergeable: MERGEABLE
    merge_state_status: CLEAN
  allowed_paths_gate:
    status: ok
    producer_role: review_subagent
    worker_report_used_as_canonical: false
  blockers: []
  required_auto_actions: []
  auto_fix_applied: []
  follow_up_issue_requests: []

@squne121
squne121 merged commit 21f230f into main Jun 20, 2026
20 checks passed
@squne121
squne121 deleted the worktree-issue-1012-issue-refinement-loop branch June 20, 2026 00:42
@squne121

Copy link
Copy Markdown
Owner Author
POST_MERGE_CLEANUP_REPORT_V1:
  status: ok
  generated_at: "2026-06-20T00:50:00Z"
  generated_by: post-merge-cleanup-worker
  human_review_required: false
  cleaned_branches:
    - "worktree-issue-1012-issue-refinement-loop"
  cleaned_worktrees:
    - "/home/squne/projects/LOOP_PROTOCOL/.claude/worktrees/issue-1012-issue-refinement-loop"
  unresolved_cleanup_items: []
  parent_issue_status:
    parent_issue_number: 1012
    all_children_closed: true
    recommended_action: close
  superseded_prs: []
  follow_up_issue_requests: []
  stash_restored: n/a
  stash_entry_ref: null
  warnings: []
  errors: []

実施内容

備考

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