Skip to content

実装: edit_issue_txn.py semantic_rewrite_constraints テストfixtureのchecked_body_sha256を実producer shape(64桁hex)に揃える #2329

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "PR #2326 (Closes #2316) 人間レビュー P2-1 (non-blocking) の完全解消。producer-shaped fixture の checked_body_sha256 を実 producer shape(64桁hex)に揃え、回帰検出可能な pytest assertion として残す"
change_kind: code

Parent Issue

none(単独改善・post-merge-cleanup の follow-up candidate)

Parent Goal Ref

  • Goal: 該当なし(単独 follow-up Issue)
  • Desired Destination: 該当なし(単独 follow-up Issue)

Current Validated Scope

  • .claude/skills/edit-issue/tests/test_edit_issue_txn.py 内の producer-shaped fixture における checked_body_sha256 の値を、実際の SEMANTIC_REVIEW_RESULT_V1 producer(semantic_review_transport.py)が生成する 64 桁 16 進文字列の shape に揃える
  • 同ファイル内の既存 positive test(test_rewrite_lane_semantic_with_producer_shaped_constraints_accepted)に、fixture の checked_body_sha256 が 64 桁 16 進文字列であることを検証する runtime shape assertion を追加し、同種の fixture drift を pytest が回帰検出できるようにする

Remaining Parent Gaps

なし

Outcome

.claude/skills/edit-issue/tests/test_edit_issue_txn.py 内の producer-shaped fixture の checked_body_sha256 値が、実測 62 桁の hex 文字列から "a" * 64(64 桁の hex 文字列)に修正され、かつ既存の test_rewrite_lane_semantic_with_producer_shaped_constraints_accepted に len(digest) == 64 および全文字が [0-9a-f] であることを検証する assertion が追加されたコミットが作成され、既存の関連テストが pass している状態

Runtime Verification Applicability

  • decision: not_applicable
  • reason: 静的検証(テストfixture文字列の桁数・文字種検証を pytest assertion として組み込み、既存 pytest を実行するのみ)で完結するため

In Scope

  • .claude/skills/edit-issue/tests/test_edit_issue_txn.py 内の _semantic_producer_shaped_constraints() が返す fixture(checked_body_sha256 フィールド)の値を、"a" * 64 に修正する
  • 同ファイル内の既存 test test_rewrite_lane_semantic_with_producer_shaped_constraints_accepted に、fixture の checked_body_sha256 の長さ(64)と文字種([0-9a-f])を検証する assertion を追加する

Out of Scope

  • .claude/skills/edit-issue/scripts/edit_issue_txn.py の実装ロジック変更(同スクリプトは semantic_rewrite_constraints を opaque envelope として扱い、schema_version 以外は深く検証しない consumer であり、本 Issue の対象外)
  • 新規テストファイル・schema validation harness の追加
  • fixture 内の no_progress_route / finding 構造の id フィールド(既に fix_delta で修正済みのため対象外)
  • .claude/skills/edit-issue/tests/test_edit_issue_txn.py 以外のファイル変更

Acceptance Criteria

  • AC1: _semantic_producer_shaped_constraints() の checked_body_sha256 fixture 値が "a" * 64(64 桁の 16 進文字列)である
  • AC2: test_rewrite_lane_semantic_with_producer_shaped_constraints_accepted に len(digest) == 64 かつ全文字が [0-9a-f] であることを検証する assertion が追加されている
  • AC3: 既存の関連テストが引き続き pass する

Verification Commands

# AC1
$ rg -n "checked_body_sha256.: .a. \* 64" .claude/skills/edit-issue/tests/test_edit_issue_txn.py
# AC2
$ uv run --locked pytest .claude/skills/edit-issue/tests/test_edit_issue_txn.py -k "rewrite_lane_semantic_with_producer_shaped_constraints_accepted" -v
# AC3
$ uv run --locked pytest .claude/skills/edit-issue/tests/test_edit_issue_txn.py -v

Allowed Paths

  • .claude/skills/edit-issue/tests/test_edit_issue_txn.py

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

Required Skills

なし

Required Design References

  • schemas/semantic_review_result_v1.schema.json(body_sha256 を ^[0-9a-f]{64}$ と定義する canonical contract。SEMANTIC_REVIEW_RESULT_V1 の正本)
  • .claude/skills/issue-refinement-loop/scripts/semantic_review_transport.py(hashlib.sha256(...).hexdigest() で body_sha256 を実際に生成する producer)
  • .claude/skills/issue-refinement-loop/scripts/join_review_results.py(caller から受け取った checked_body_sha256 をそのまま semantic_rewrite_constraints へ転記する forwarding 経路。自身では生成・検証しない)
  • .claude/skills/issue-refinement-loop/tests/test_join_review_results.py(producer-shaped fixture の実装例)
  • .claude/skills/issue-refinement-loop/references/semantic-design-review.md(checked_body_sha256 を含む semantic review の producer/consumer フロー設計ドキュメント)

(.claude/skills/edit-issue/scripts/edit_issue_txn.py は semantic_rewrite_constraints を opaque envelope として扱う consumer であり、checked_body_sha256 の producer shape の正本ではない。前版 Issue 本文の Required Design References 記載は誤りであったため訂正した)

Scope Delta(任意)

N/A

Source

Notes for Reviewer

Activity

  1. added
    triage-required
    phase/implementation
    enhancement
    agent/implementer
    on Aug 24, 2026
  2. squne121 commented on Aug 24, 2026

    @squne121
    OwnerAuthor

    判定

    REQUEST_CHANGES — 小規模な契約修正後に実装するのが妥当です。
    P0 はありません。実装自体は非常に小さく、production code・runtime smoke・live GitHub test・追加ハーネスは不要です。

    Issue #2329 の問題認識そのものは正しいです。現在の _semantic_producer_shaped_constraints() の checked_body_sha256 は 62桁で、コメントでは ^[0-9a-f]{64}$ を満たすと説明しているのに実データが一致していません。 Issue 本文も、この残存 P2 を単独 follow-up として直す意図になっています。

    ただし、Issue 契約には2点直した方がよい箇所があります。

    Severity | Finding | 判定 -- | -- | -- P1-1 | producer shape の SSOT を誤認している | blocker P1-2 | 今回の不具合を pytest が回帰検出しない | blocker P2-1 | 64文字リテラルを再度手で数える設計 | non-blocking P2-2 | overlap は実質 false positive | 問題なし

    P1-1: Required Design References が逆です

    Issue #2329 は Required Design References で edit_issue_txn.py を「`SEMANTIC_REVIEW_RESULT_V1 producer shape の正本」としています。

    これは実装と一致しません。

    edit_issue_txn.py は consumer であり、PR #2326 自身も semantic_rewrite_constraints の nested payload を opaque envelope として扱い、schema_version 以外は深く検証しない、としています。

    実際の authority は次の流れです。

    semantic_review_transport.py が pinned body に対して hashlib.sha256(...).hexdigest() を生成します。そして完成した artifact を canonical JSON Schema で検証します。

    その schema が body_sha256 を明示的に ^[0-9a-f]{64}$ と定義しています。

    その後 join_review_results.py は、caller から受け取った checked_body_sha256 を semantic_rewrite_constraints にそのまま転記するだけです。自身では SHA-256 を生成も検証もしていません。 production 手順でも、transport が保存した artifact と pinned body_sha256 を joiner に渡す構成です。

    したがって Required Design References は少なくとも、

    • schemas/semantic_review_result_v1.schema.json — 64 lowercase hex の canonical contract

    • .claude/skills/issue-refinement-loop/scripts/semantic_review_transport.py — 実 hash producer

    • .claude/skills/issue-refinement-loop/scripts/join_review_results.py — checked_body_sha256 への forwarding

    • .claude/skills/issue-refinement-loop/tests/test_join_review_results.py — producer-side test example

    へ直すべきです。

    Python の公式仕様でも hexdigest() は digest の2倍長の16進文字列を返し、sha256(...).hexdigest() の出力は64文字になります。(Python documentation) JSON Schema 側で ^[0-9a-f]{64}$ とアンカーする方法も公式ガイドと整合しています。(JSON Schema)

    P1-2: AC1 が source grep にしか存在せず、pytest は現在の62桁でも通る

    ここが実用上の主問題です。

    現在の PR #2326 系テストは、この62桁 fixture が存在する状態でも 59 tests pass としてマージされています。 これはバグではなく、edit_issue_txn.py が nested envelope を意図的に opaque としているからです。

    つまり Issue #2329 の現在の VC は、

    rg -o "checked_body_sha256\": \"[0-9a-f]{64}\"" ...

    だけが AC1 を検証し、続く pytest は AC1 を一切検証していません。

    今回の defect はまさに「producer-shaped とコメントしている fixture が実は producer-shaped でなかった」ことです。ここをもう一度 source grep だけで直すと、一度は直っても regression test にはなりません。

    しかも #1719 では、このリポジトリ自身が Verification Commands の実装文字列への強結合を behavior-based test に置き換える方向を明記しています。

    ただし、新しいテストファイルや schema validation harness は不要です。既存の positive test に3行程度足せば十分です。

    constraints = _semantic_producer_shaped_constraints()
    digest = constraints["checked_body_sha256"]
    

    assert len(digest) == 64
    assert all(c in "0123456789abcdef" for c in digest)

    payload["semantic_rewrite_constraints"] = constraints

    対象は既存の

    test_rewrite_lane_semantic_with_producer_shaped_constraints_accepted

    でよいです。これなら現行62桁では red、修正後は green になり、AC1 が実際の pytest suite に残ります。

    P2-1: 修正値は「別の手数え64文字」にしない方がよい

    PR #2326 の元レビューでも推奨例は "a" * 64 でしたし、producer 側の既存テストもすでに checked_body_sha256="a" * 64 を使っています。 同じ test_edit_issue_txn.py 自体にも "0" * 64 という書き方があります。

    したがって、

    "checked_body_sha256": "a" * 64,

    で十分です。

    今回の defect は「64文字のつもりで手書きしたら62文字だった」です。もう一度63/64/65文字を人間が数えるリテラルを置くより、長さをコードで表現した方が明瞭で、保守コストもゼロに近いです。

    pytest の考え方としても fixture はテストへ reliable / consistent な context を提供するものなので、fixture 自体の前提を executable assertion にしておく方が自然です。(pytestドキュメント)

    overlap の評価

    #1916 は同じ test_edit_issue_txn.py を触りますが、対象は native relationship pagination / totalCount 検証です。 #1719 は AC/VC parser parity です。

    したがって #2329 の Notes にある non_conflict_reason は妥当です。fixture helper 周辺だけなら意味的 conflict はほぼありません。worktree 作成時の通常の Git conflict 検出で十分です。

    また #1860 は live Issue/PR、実 diff、実 test、CI、独立 review を authority とし、独自 checker や digest control-plane の追加を避ける方針です。 この Issue で新規 schema、security validation、live canary、専用 CI lane を追加する必要はありません。

    推奨する Issue #2329 の着地点

    スコープは1ファイルのままでよいです。Runtime Verification Applicability: not_applicable も維持して問題ありません。uv run --locked pytest も、lockfile を勝手に更新せず実行するという意味で現在の uv の仕様に適合しています。(Astral Docs)

    修正内容だけ次のように変えるのが最も軽量です。

    def _semantic_producer_shaped_constraints() -> dict:
    return {
    ...
    "checked_body_sha256": "a" * 64,
    ...
    }

    既存 positive test に runtime shape assertion を追加し、Verification Commands は source rg を主証拠にするのではなく、

    uv run --locked pytest 
    .claude/skills/edit-issue/tests/test_edit_issue_txn.py
    -k "rewrite_lane_semantic_with_producer_shaped_constraints_accepted" -v

    uv run --locked pytest
    .claude/skills/edit-issue/tests/test_edit_issue_txn.py -v

    とするのを推奨します。

    結論として、Issue の方向性・Allowed Paths・scope size は良好です。修正すべきなのは「producer SSOT の誤記」と「同じ種類の fixture drift を再発検出できない VC」の2点だけです。 ここを直せば、余計なハーネスを増やさず、#2326 の P2-1 を実質的に閉じられます。

    ## 判定

    REQUEST_CHANGES — 小規模な契約修正後に実装するのが妥当です。
    P0 はありません。実装自体は非常に小さく、production code・runtime smoke・live GitHub test・追加ハーネスは不要です。

    Issue #2329 の問題認識そのものは正しいです。現在の _semantic_producer_shaped_constraints() の checked_body_sha256 は 62桁で、コメントでは ^[0-9a-f]{64}$ を満たすと説明しているのに実データが一致していません。 Issue 本文も、この残存 P2 を単独 follow-up として直す意図になっています。

    ただし、Issue 契約には2点直した方がよい箇所があります。

    Severity Finding 判定
    P1-1 producer shape の SSOT を誤認している blocker
    P1-2 今回の不具合を pytest が回帰検出しない blocker
    P2-1 64文字リテラルを再度手で数える設計 non-blocking
    P2-2 overlap は実質 false positive 問題なし

    P1-1: Required Design References が逆です

    Issue #2329 は Required Design References で edit_issue_txn.py を「`SEMANTIC_REVIEW_RESULT_V1 producer shape の正本」としています。

    これは実装と一致しません。

    edit_issue_txn.py は consumer であり、PR #2326 自身も semantic_rewrite_constraints の nested payload を opaque envelope として扱い、schema_version 以外は深く検証しない、としています。

    実際の authority は次の流れです。

    semantic_review_transport.py が pinned body に対して hashlib.sha256(...).hexdigest() を生成します。そして完成した artifact を canonical JSON Schema で検証します。

    その schema が body_sha256 を明示的に ^[0-9a-f]{64}$ と定義しています。

    その後 join_review_results.py は、caller から受け取った checked_body_sha256 を semantic_rewrite_constraints にそのまま転記するだけです。自身では SHA-256 を生成も検証もしていません。 production 手順でも、transport が保存した artifact と pinned body_sha256 を joiner に渡す構成です。

    したがって Required Design References は少なくとも、

    • schemas/semantic_review_result_v1.schema.json — 64 lowercase hex の canonical contract
    • .claude/skills/issue-refinement-loop/scripts/semantic_review_transport.py — 実 hash producer
    • .claude/skills/issue-refinement-loop/scripts/join_review_results.py — checked_body_sha256 への forwarding
    • .claude/skills/issue-refinement-loop/tests/test_join_review_results.py — producer-side test example

    へ直すべきです。

    Python の公式仕様でも hexdigest() は digest の2倍長の16進文字列を返し、sha256(...).hexdigest() の出力は64文字になります。([Python documentation]1) JSON Schema 側で ^[0-9a-f]{64}$ とアンカーする方法も公式ガイドと整合しています。([JSON Schema]2)

    P1-2: AC1 が source grep にしか存在せず、pytest は現在の62桁でも通る

    ここが実用上の主問題です。

    現在の PR #2326 系テストは、この62桁 fixture が存在する状態でも 59 tests pass としてマージされています。 これはバグではなく、edit_issue_txn.py が nested envelope を意図的に opaque としているからです。

    つまり Issue #2329 の現在の VC は、

    rg -o "checked_body_sha256\": \"[0-9a-f]{64}\"" ...

    だけが AC1 を検証し、続く pytest は AC1 を一切検証していません。

    今回の defect はまさに「producer-shaped とコメントしている fixture が実は producer-shaped でなかった」ことです。ここをもう一度 source grep だけで直すと、一度は直っても regression test にはなりません。

    しかも #1719 では、このリポジトリ自身が Verification Commands の実装文字列への強結合を behavior-based test に置き換える方向を明記しています。

    ただし、新しいテストファイルや schema validation harness は不要です。既存の positive test に3行程度足せば十分です。

    constraints = _semantic_producer_shaped_constraints()
    digest = constraints["checked_body_sha256"]
    
    assert len(digest) == 64
    assert all(c in "0123456789abcdef" for c in digest)
    
    payload["semantic_rewrite_constraints"] = constraints

    対象は既存の

    test_rewrite_lane_semantic_with_producer_shaped_constraints_accepted

    でよいです。これなら現行62桁では red、修正後は green になり、AC1 が実際の pytest suite に残ります。

    P2-1: 修正値は「別の手数え64文字」にしない方がよい

    PR #2326 の元レビューでも推奨例は "a" * 64 でしたし、producer 側の既存テストもすでに checked_body_sha256="a" * 64 を使っています。 同じ test_edit_issue_txn.py 自体にも "0" * 64 という書き方があります。

    したがって、

    "checked_body_sha256": "a" * 64,

    で十分です。

    今回の defect は「64文字のつもりで手書きしたら62文字だった」です。もう一度63/64/65文字を人間が数えるリテラルを置くより、長さをコードで表現した方が明瞭で、保守コストもゼロに近いです。

    pytest の考え方としても fixture はテストへ reliable / consistent な context を提供するものなので、fixture 自体の前提を executable assertion にしておく方が自然です。([pytestドキュメント]3)

    overlap の評価

    #1916 は同じ test_edit_issue_txn.py を触りますが、対象は native relationship pagination / totalCount 検証です。 #1719 は AC/VC parser parity です。

    したがって #2329 の Notes にある non_conflict_reason は妥当です。fixture helper 周辺だけなら意味的 conflict はほぼありません。worktree 作成時の通常の Git conflict 検出で十分です。

    また #1860 は live Issue/PR、実 diff、実 test、CI、独立 review を authority とし、独自 checker や digest control-plane の追加を避ける方針です。 この Issue で新規 schema、security validation、live canary、専用 CI lane を追加する必要はありません。

    推奨する Issue #2329 の着地点

    スコープは1ファイルのままでよいです。Runtime Verification Applicability: not_applicable も維持して問題ありません。uv run --locked pytest も、lockfile を勝手に更新せず実行するという意味で現在の uv の仕様に適合しています。([Astral Docs]4)

    修正内容だけ次のように変えるのが最も軽量です。

    def _semantic_producer_shaped_constraints() -> dict:
        return {
            ...
            "checked_body_sha256": "a" * 64,
            ...
        }

    既存 positive test に runtime shape assertion を追加し、Verification Commands は source rg を主証拠にするのではなく、

    uv run --locked pytest \
      .claude/skills/edit-issue/tests/test_edit_issue_txn.py \
      -k "rewrite_lane_semantic_with_producer_shaped_constraints_accepted" -v
    
    uv run --locked pytest \
      .claude/skills/edit-issue/tests/test_edit_issue_txn.py -v

    とするのを推奨します。

    結論として、Issue の方向性・Allowed Paths・scope size は良好です。修正すべきなのは「producer SSOT の誤記」と「同じ種類の fixture drift を再発検出できない VC」の2点だけです。 ここを直せば、余計なハーネスを増やさず、#2326 の P2-1 を実質的に閉じられます。

  3. squne121 commented on Aug 24, 2026

    @squne121
    OwnerAuthor

    root-owned entry router audit

    route: invoke_impl_review_loop
    reason: fresh_review_go_live_equality

  4. squne121 commented on Aug 24, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop 終了報告(1 iteration・approve)

    VERDICT: approve(deterministic checker、ISSUE_REVIEW_RESULT_COMPACT_V2、blockers: 0)

    反映内容

    参照コメント(OWNER, REQUEST_CHANGES, #2329 (comment) )の指摘をすべて本文へ反映しました。

    また Step 2 の deterministic checker が検出した RDR001(Required Design References が実質空/非design-doc)blocker も、上記の訂正で同時に解消しました。

    実行証跡

    • Step 0f preflight: STATUS: warn / NEXT_ACTION: proceed_with_notes(preflight.run.with_human_context)
    • Step 4 rewrite: issue-editor 経由で本文置換。STATUS: ok、BODY_HASH: sha256:e99f1228742fbdead31440f0dfefdb530f61e8e9c544ae69f2fa294506b0442c
    • Step 2 final review(readback後): run_root_review_pipeline.py produce → VERDICT: approve、REVIEWED_BODY_SHA256 が readback hash と一致
    • Step 2.5: semantic_review_trigger.py → semantic_review_applicable: false(スキップ)

    参考(Final Gate 情報)

    root_entry_router.py による current-run 判定: route: invoke_impl_review_loop, reason: fresh_review_go_live_equality(fresh contract-review go かつ live body/base SHA 一致)。実装ハンドオフ(impl-review-loop 起動)は本タスクの依頼スコープ(refinement loop のみ)外のため、本セッションでは起動していません。実装着手が必要な場合は別途 impl-review-loop を起動してください。

  5. squne121 commented on Aug 25, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-08-25T11:10:38Z)

  6. self-assigned this
    on Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent/implementerenhancementphase/implementationtriage-required

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions