Skip to content

調査: visual-impact-policy-trusted の attempt-specific artifact naming を実 CI rerun (run_attempt>=2) で検証する #2287

Open

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: research
parent_issue: "#2230"
goal_ref: "#2284 Phase B が main へ merge された後、production V3 artifact protocol を同一 same-repository pull_request CI run の attempt 1/2 で一度だけ実証する"
change_kind: research-only

Parent Issue

#2230

Outcome

#2284 Phase B を含む main を base とする same-repository PR の pull_request 起点 ci run を、適格性確認後に full workflow rerun で一度だけ attempt 2 にし、attempt 1/2 の post-Phase-B production artifact と trusted consumer を直接検証した verification-result comment が #2287 に一件だけ記録される。全 AC が PASS の場合に限り #2287 を close できる。現時点では dependency 未充足のため runtime verification、CI rerun、verification-result comment、close は blocked である。

Dependencies and Execution Gate

Source

dedupe_key: "follow-up:squne121/loop-protocol:pr/2279:1"
source: post_merge_cleanup
source_url: "https://github.com/squne121/loop-protocol/pull/2279"
authoritative_anchors:
  structured: "https://github.com/squne121/loop-protocol/issues/2287#issuecomment-5457998707"
  adversarial: "https://github.com/squne121/loop-protocol/issues/2287#issuecomment-5456842673"

The structured anchor is approved_by_trusted_anchor. Its authorized delta is exactly: GitHub Issue #2287 contract body only; repository files prohibited. This rewrite materializes the normalized adversarial-anchor requirements and the user authorization; it does not authorize their future execution before the execution gate.

In Scope

Out of Scope

  • Any runtime verification, CI rerun, verification-result comment, or close before #2284 Phase B merged to main and fresh canonical gates pass.
  • Repository file, branch, commit, PR, PR body, workflow, label, or repository configuration mutation.
  • workflow_dispatch, dummy commits, failed-only reruns, job-only reruns, a second or later rerun, new security/permission/verification harnesses, and unrelated GitHub mutation.
  • Treating CheckRun display text as a substitute for direct artifact JSON type validation.

Allowed Paths

Allowed Operations

Only after the Dependencies and Execution Gate is satisfied:

Repository Mutation

Repository mutation is prohibited at all times: repository files, branches, commits, PR creation or modification, PR body, workflow files, and workflow-dispatch alternative-run generation. Future operational GitHub mutations above are distinct from repository mutation and remain prohibited until the execution gate passes.

Acceptance Criteria

  • AC1: Runtime execution starts only after #2284 Phase B merged to main and fresh canonical gates pass. The selected candidate is a completed initial attempt (run_attempt == 1) of workflow ci, event pull_request, from a same-repository PR; its current PR head SHA equals the run head_sha; its base contains the Phase B merge commit; and it is within GitHub's 30-day rerun eligibility window.
  • AC2: Exactly one full workflow rerun is initiated for that RUN_ID, reaches run_attempt == 2, and no failed-only, job-only, workflow_dispatch, or additional rerun is used. During selection and rerun, the PR head is not updated and concurrent ci activity capable of contaminating correlation is avoided; any detected stale head or contamination blocks further mutation.
  • AC3: A fully paginated run-scoped artifact listing, using producer SSOT post-Phase-B exact names, contains for each attempt 1 and 2 exactly one nonexpired decision artifact and exactly one nonexpired evidence-manifest artifact. Each selected artifact metadata record has strict expected workflow_run.id == RUN_ID and workflow_run.head_sha == HEAD_SHA identity.
  • AC4: ZIP contents of both decision artifacts directly validate JSON workflow_run_id, run_attempt, and head_sha as the strict expected tuple (RUN_ID, 1|2, HEAD_SHA); the first two are JSON numbers with integer semantics, not strings or fractional numbers, and the decision schema is VISUAL_IMPACT_DECISION_V1.
  • AC5: ZIP contents of both V3 evidence artifacts directly validate top-level workflow_run_id, run_attempt, and head_sha with the same strict typed tuple; schema is VISUAL_BASELINE_REVIEW_EVIDENCE_V3; when surfaces[] is nonempty every record matches the envelope tuple, and an empty surfaces: [] still has envelope identity.
  • AC6: The attempt-2 trusted consumer execution is correlated uniquely through existing evidence (source run/attempt summary if present, otherwise consumer run ID, timestamps, event chain, and logs), trusted artifact acquisition succeeds, and the relevant visual-impact-policy-trusted CheckRun/workflow conclusion is success.
  • AC7: Exactly one 調査: visual-impact-policy-trusted の attempt-specific artifact naming を実 CI rerun (run_attempt>=2) で検証する #2287 verification-result comment records source PR, base/head SHA, RUN_ID, attempts, producer-SSOT artifact names/IDs/expired values, direct JSON tuples, consumer run ID, CheckRun ID, and PASS/FAIL outcome. If all ACs pass, and only then, 調査: visual-impact-policy-trusted の attempt-specific artifact naming を実 CI rerun (run_attempt>=2) で検証する #2287 is closed.
  • AC8: No repository file, branch, commit, PR, PR body, workflow, label, or configuration mutation occurs for this Issue.

Verification Commands

Case A (#2284 Phase B unmerged) is baseline-deferred: do not execute dependency-gated Actions commands. Their # baseline-expect: deferred annotation makes the canonical baseline preflight skip them rather than treating the current restricted read-only allowlist or unavailable V3 target as a result for the future protocol. After the execution gate passes, Case B is immediate: execute the same commands under the then-authorized operational gate and retain the resulting evidence. Producer exact names and JSON filenames are resolved from the post-Phase-B production workflow SSOT before use.

# AC1
# baseline-expect: deferred
$ gh api "repos/squne121/loop-protocol/actions/runs/RUN_ID"
# baseline-expect: deferred
$ gh api "repos/squne121/loop-protocol/pulls/PR_NUMBER"
# baseline-expect: deferred
$ gh api "repos/squne121/loop-protocol/compare/PHASE_B_MERGE_SHA...BASE_SHA"

Inspect returned metadata for ci, pull_request, completed initial attempt, same-repository PR, current head equality, 30-day eligibility, and Phase-B base containment before any mutation.

# AC2
# baseline-expect: deferred
$ gh run rerun RUN_ID --repo squne121/loop-protocol
# baseline-expect: deferred
$ gh run watch RUN_ID --repo squne121/loop-protocol --exit-status
# baseline-expect: deferred
$ gh api "repos/squne121/loop-protocol/actions/runs/RUN_ID"

Use the full rerun command exactly once without --failed or --job; re-read PR head and concurrent activity before and during rerun.

# AC3
# baseline-expect: deferred
$ gh api --paginate "repos/squne121/loop-protocol/actions/runs/RUN_ID/artifacts?per_page=100"

Collect every page and use producer-SSOT exact names to assert exactly one nonexpired decision and evidence artifact for each attempt and strict RUN_ID/HEAD_SHA metadata identity.

# AC4
# baseline-expect: deferred
$ gh api "repos/squne121/loop-protocol/actions/artifacts/DECISION_ARTIFACT_ID/zip"

Download and unzip each decision ZIP; directly validate VISUAL_IMPACT_DECISION_V1, numeric integer fields, and exact (RUN_ID, attempt, HEAD_SHA) tuple.

# AC5
# baseline-expect: deferred
$ gh api "repos/squne121/loop-protocol/actions/artifacts/EVIDENCE_ARTIFACT_ID/zip"

Download and unzip each evidence ZIP; directly validate V3 envelope typed tuple and every nonempty surfaces[] record; empty surfaces still require envelope identity.

# AC6
# baseline-expect: deferred
$ gh api "repos/squne121/loop-protocol/actions/runs/RUN_ID/jobs"
# baseline-expect: deferred
$ gh api "repos/squne121/loop-protocol/commits/HEAD_SHA/check-runs"

Use existing consumer run metadata, timestamps, event chain, and logs to uniquely correlate attempt 2; confirm trusted acquisition and relevant conclusion success.

# AC7
# baseline-expect: pass
$ gh issue view 2287 --repo squne121/loop-protocol --json comments,state

After complete evidence collection, verify exactly one verification-result comment and close only when every AC passes.

# AC8
# baseline-expect: pass
$ git status --short
# baseline-expect: pass
$ gh issue view 2287 --repo squne121/loop-protocol --json body,state

Confirm no repository or prohibited GitHub mutation occurred.

Runtime Verification Applicability

  • decision: deferred
  • reason: Case A cannot establish the production V3 runtime target while #2284 Phase B is unmerged; current baseline validation must not execute or infer an Actions-runtime result from restricted read-only command availability.
  • deferred_destination:
  • deferred_verification_condition: #2284 Phase B is merged to main, then fresh human-context preflight and canonical gates return ready/proceed; only then Case B becomes immediate for this Issue's existing one-rerun protocol, evidence collection, sole verification-result comment, and conditional close.

Stop Conditions

  • Outcome / Scope / AC が検索可能な形で記載されていない場合は即停止

  • Allowed Paths 外への書き込みを試みた場合は即停止

  • 権限不足(permission denied)により操作が完了できない場合は即停止

  • 成果物の書き込みに失敗した場合(I/O エラー等)は即停止

  • CI rerun 発生に失敗する、または run_attempt >= 2 の実 run に到達できない場合は即停止し人間判断を仰ぐ

  • cardinality 違反・型不一致が発見された場合は本 Issue を close せず修正 implementation Issue を起票してから停止する

  • Before the execution gate, stop as blocked with dependency evidence; do not rerun, comment a verification result, or close.

  • If no eligible candidate exists, eligibility is expired, head becomes stale, a concurrent CI run prevents unambiguous correlation, permissions fail, rerun does not reach attempt 2, or any AC fails: perform no additional rerun, preserve blocked/FAIL evidence, and stop.

  • If artifact cardinality, expiry, typed tuple, V3 envelope/surface identity, trusted acquisition, or consumer correlation/conclusion fails: do not repair repository code in 調査: visual-impact-policy-trusted の attempt-specific artifact naming を実 CI rerun (run_attempt>=2) で検証する #2287; create a minimal implementation Issue only when required and retain 調査: visual-impact-policy-trusted の attempt-specific artifact naming を実 CI rerun (run_attempt>=2) で検証する #2287 open.

  • Never bypass fresh preflight, canonical gates, or the repository-mutation prohibition.

Handoff Contract

Required Skills

なし

Unblocked by

Issue #2384 / PR #2388(ci.yml の producer を V3 evidence manifest schema へ切り替える Phase B 実装)が上記コミットで main にマージ済み。本 Issue #2287 の実行ゲート(旧記述「#2284 Phase B が main へ merge」)は、実際の Phase B 実装単位である Issue #2384 / PR #2388 のマージをもって満たされた。

Activity

  1. added
    phase/research
    state/queued
    agent/research
    on Aug 21, 2026
  2. squne121 commented on Aug 28, 2026

    @squne121
    OwnerAuthor

    判定

    verdict: REQUEST_CHANGES
    disposition: reframe_in_place
    execute_now: false
    close_now: false
    blocked_by: "#2284 Phase B の main マージ"
    new_issue_required: false
    new_security_harness_required: false

    #2287 の検証目的そのものは有用です。
    ただし、現在の本文のままでは、一部のVerification Commandsが実在しないAPIを呼び、対象runの選定条件も誤っており、さらに進行中の #2284 より前に実行すると旧V2経路を検証して終わるため、後で同じ検証をやり直すことになります。

    したがって、今クローズするのも、今実行するのも不適切です。#2284 Phase B後のproduction V3経路を一度だけ検証するIssueへ改稿するのが妥当です。

    #2287 は2026年8月21日の起票後、コメント0件・本文更新なしで、現在も「V3はOut of Scope」「Open Questionsなし」「次はrerun」としています。一方、#2284はその後、V3 envelopeとproducer切替をPhase A/Bで実施し、GitHub-hosted実rerunは#2287に委譲する契約へ更新されています。現状の#2287は、この後続設計をまだ反映していません。


    敵対的レビュー findings

    [P1-1] #2284 Phase Bより前に実行すると、検証対象がすぐ旧式になる

    #2284は、V3 envelopeを導入したうえで、Phase Bとして実producerをV3 writer・generic filenameへ切り替えるところまでを完了条件にしています。さらに、GitHub-hostedのrun_attempt >= 2検証は明示的に#2287へ委譲されています。

    ところが#2287は、現在も次の前提です。

    • PR #2279直後の実装を検証する
    • V3化はOut of Scope
    • すぐrerunする
    • Open Questionsなし

    このまま今実行すると、V2のattempt-specific artifact namingをPASSにした直後、#2284 Phase Bでproducerや内部manifest形式が変わります。すると、本当に稼働確認したい最終構成を再度rerunする必要が生じます。

    修正要求


    [P1-2] AC2・AC3のartifact APIは存在しない

    AC1で使用している次のworkflow run attempt取得APIは実在します。

    /actions/runs/{run_id}/attempts/{attempt_number}
    

    一方、AC2・AC3に書かれた次のAPIは存在しません。

    /actions/runs/{run_id}/attempts/1/artifacts
    /actions/runs/{run_id}/attempts/2/artifacts
    

    GitHub Actionsのartifact一覧APIは、attempt別ではなくrun全体に対する次のendpointだけです。

    GET /repos/{owner}/{repo}/actions/runs/{run_id}/artifacts
    

    指定できるquery parameterはname、per_page、page、directionで、attempt番号による絞り込みはありません。したがって、attempt-specific suffixで名前を分ける設計自体は妥当ですが、#2287のAC2・AC3は現状のままでは実行不能です。([GitHub ドキュメント]1)

    修正要求

    run全体のartifact一覧を最後のページまで取得し、その中から以下4名称をそれぞれexactly oneで検証します。

    • visual-impact-decision-v1-1
    • component-vrt-evidence-manifest-1
    • visual-impact-decision-v1-2
    • component-vrt-evidence-manifest-2

    [P1-3] 「main上のCI run」という対象指定ではAC5が成立しない

    現在のtrusted consumerは、source ci runのeventがpull_requestの場合だけ実行されます。push、workflow_dispatch、merge_groupのrunは明示的に無視されます。

    したがって、「main上のCI run」をmainへのpush runと解釈すると、visual-impact-policy-trustedはskipされ、AC5を満たせません。

    正しい対象は次です。

    #2284 Phase Bを含むmainをbaseとし、そのbase上で発生した、同一リポジトリPRのpull_request起点ci run

    さらにGitHubのrerunは、元runと同じGITHUB_SHAとGITHUB_REFを使います。現在のtrusted consumerは、元runのhead SHAとPRの現在head SHAが異なる場合にstaleとして拒否します。したがって、対象PRのheadが更新された後に古いrunをrerunしてはいけません。([GitHub Docs]2)

    対象runの必須条件


    [P1-4] Allowed Paths: 読み取り専用とAC1が矛盾している

    #2287は「読み取り専用」「Allowed Paths外への書き込みで即停止」としていますが、AC1ではworkflow rerunを必須とし、AC6ではIssueコメントを書き込みます。

    GitHub ActionsのrerunはREST上のPOST操作で、Actionsのwrite permissionを必要とします。Issueコメントも書き込みです。([GitHub Docs]1)

    この矛盾は、最近のClaude Code/Claude-GPTの権限制御問題と特に相性が悪く、agentが「read-only契約違反」と判定してAC1より前で停止する可能性があります。

    修正要求

    Allowed Pathsではなく、次のようにファイル変更とGitHub操作を分離します。

    ## Allowed Operations
    
    - 対象workflow runに対するfull rerunを1回だけ実行してよい
    - Actions run、jobs、artifacts、CheckRunを読み取ってよい
    - #2287へ検証結果コメントを1件投稿してよい
    
    ## Repository Mutation
    
    - repository fileの変更は禁止
    - branch、commit、PR bodyの変更は禁止
    - workflow_dispatchによる代替run生成は禁止

    [P1-5] AC4はdecision artifactのJSON型を検証していない

    AC4は次を実行する契約です。

    gh api repos/.../check-runs/CHECK_RUN_ID --jq '.output'

    しかし、これはCheckRunの表示用summary/textを取得するだけです。JSON artifact内で値がintegerなのか、文字列なのかは判定できません。

    さらに現在のvisual-impact-policy-trusted CheckRun summaryには、workflow_run_idもrun_attemptも出力されていません。成功時はPR番号とhead SHAを記録するだけです。

    親Issue #2230が要求しているのは、decisionとevidenceの両artifactが、exact (workflow_run_id, run_attempt, head_sha) tupleを持つことです。

    修正要求

    attempt 1・2の両方について、実artifact ZIPをダウンロードしてjqで検証します。

    • workflow_run_id | type == "number"
    • run_attempt | type == "number"
    • 小数ではなく整数
    • workflow_run_id == RUN_ID
    • run_attempt == 1または2
    • head_sha == HEAD_SHA
    • V3 evidenceはtop-level envelopeでも同じtuple
    • surfaces[]が存在する場合は各recordもenvelopeと一致

    [P1-6] evidenceだけを数えており、decision側の重複・欠落を見逃す

    現行AC2はcomponent-vrt-evidence-manifest-*しか確認しません。しかし、#2230の契約はdecisionとevidenceの両方をattempt identityへ結合するものです。decision側だけ重複・欠落しても、現在のAC2はPASSします。

    また、Outcomeではactions/download-artifactのexact-name解決を検証すると書かれていますが、trusted consumerのproduction経路は現在、resolve_visual_impact.py --mode acquire-trusted-artifactを呼び出し、name= filter、全ページ取得、cardinality、expired、head SHAを検証してからartifact IDでダウンロードしています。

    修正要求

    検証対象を実装に合わせます。

    1. REST artifact一覧で4名称すべてのcardinalityを確認
    2. attempt 2のtrusted consumerログでacquire-trusted-artifactが成功したことを確認
    3. visual-impact-policy-trustedがsuccessであることを確認
    4. actions/download-artifactそのものを別途検証するための新しいharnessは作らない

    [P1-7] AC5は同じhead上の別CheckRunを誤採用できる

    現在のAC5はcommit全体のCheckRun一覧を取得し、visual-impact-policy-trustedがsuccessかを見るだけです。

    同じhead SHAに対して複数回CIやrerunが行われると、同名CheckRunが複数存在し得ます。現在のCheckRun summaryにはsource run ID/attemptがないため、「どれか1件がsuccess」だけでは、attempt 2を処理した結果だと確定できません。

    最小コストの改善

    #2284で既に.github/workflows/visual-impact-trusted-consumer.ymlを編集するため、Phase BのついでにCheckRun summaryへ次だけ追加するのがよいです。

    source_workflow_run_id=<RUN_ID>
    source_run_attempt=<RUN_ATTEMPT>
    

    これは新しいsecurity harnessではなく、単なる監査可能性の改善です。新Issueは不要です。

    この変更を入れない場合は、#2287の実行中に他のci runを完了させない「quiet window」を作り、attempt 2完了直後に生成されたconsumer workflow run IDとCheckRun IDを時刻で相関させる必要があります。


    [P2-1] full rerunとfailed/job rerunが区別されていない

    GitHubは次を別操作として扱います。

    • workflow全体のrerun
    • failed jobsだけのrerun
    • 特定jobだけのrerun

    この検証ではproducer jobを確実に再実行し、-2 artifactを生成する必要があるため、full rerun限定です。--failedや--jobでは、attempt 1で成功したproducerが再実行されず、必要なartifactが生成されない可能性があります。([GitHub Docs]2)

    gh run rerun "$RUN_ID" --repo squne121/loop-protocol

    のみを許可し、次は禁止すべきです。

    gh run rerun "$RUN_ID" --failed
    gh run rerun --job "$JOB_ID"

    GitHubではGITHUB_RUN_IDはrerunしても変わらず、GITHUB_RUN_ATTEMPTだけが1から増加します。したがって、同一run ID内で-1と-2を比較する現在の基本設計は正しいです。([GitHub Docs]3)


    [P2-2] 「research」とStop Conditionsが実務に合っていない

    このIssueにはOpen Questionsがなく、やることは決定済みの一回限りの運用検証です。それにもかかわらず、phase/research、agent/researchで、失敗時には即停止・人間判断・別Issue作成を要求しています。

    検証Issueでは、次は「停止条件」ではなくFAILとして記録すべき結果です。

    • rerun後にjobが失敗した
    • artifactが欠落した
    • cardinalityが1でない
    • JSON型が違う
    • trusted consumerがfailureになった

    権限不足や秘密情報要求は停止条件でよいですが、検証対象の不具合を見つけた時点で停止すると、診断に必要な残りのartifactやログを回収できません。

    また、不具合発見時に必ず新Issueを起票する必要もありません。まず#2287へFAIL証跡を記録し、#2284で扱える問題なら#2284へ戻し、独立した修正が必要な場合だけ新Issueを作る方が軽量です。


    現在どこまで実証済みか

    2026年8月28日の実run 33200591485では、少なくとも次のattempt 1 artifactが実際に生成されています。

    • visual-impact-decision-v1-1
    • component-vrt-evidence-manifest-1

    いずれもexpired: falseで、同じrun ID・head SHAに結び付いています。一方、そのrun内に-2 artifactはありません。したがって、現時点で残っている価値ある確認点は、基本的なsuffix生成ではなく、同一run IDでattempt 1と2が共存し、attempt 2のtrusted consumerが正しく選択できるかです。

    PR #2279の敵対的レビューでも、移行前runを使ったAC9 PASSは誤りであり、post-migrationのattempt 2以上が存在するまでSKIP/OPENとするべきだと明示されています。


    推奨する改稿内容

    新タイトル

    検証: #2284 Phase B後のvisual-impact artifactを同一CI runのattempt 1/2で実証する

    Machine-Readable Contract

    既存schemaのenum制約を増やさないため、issue_kindを変えられない場合はresearchのままで構いません。ただしgoalを更新します。

    contract_schema_version: v1
    issue_kind: research
    parent_issue: "#2230"
    goal_ref: "#2284 Phase B が main へマージされた後の production V3 artifact protocol を、同一 pull_request CI run の attempt 1/2 で実証する"
    change_kind: research-only

    Dependencies

    - Depends on #2284 Phase B merged
    - 対象runのbase SHAが#2284 Phase B merge commitを含むこと
    - 対象runはpull_request eventかつrun_attempt=1であること
    - 対象PRの現在head SHAがrunのhead_shaから変わっていないこと

    改訂Acceptance Criteria

    • AC1: 実装: visual-impact evidence manifest schema を V3 化し run_attempt を digest 対象に含める #2284 Phase B後の同一リポジトリPR起点ci runをfull rerunし、同一RUN_IDでrun_attempt == 2へ到達する
    • AC2: run全体のartifact一覧に、decision/evidence双方の-1/-2計4名称が各exactly one、expired == falseで存在する
    • AC3: 4 artifactのmetadataが同じworkflow_run.idとhead_shaを持つ
    • AC4: attempt 1/2のdecision JSONが、JSON integerのexact (workflow_run_id, run_attempt, head_sha) tupleを持つ
    • AC5: attempt 1/2のV3 evidence envelopeが同じexact tupleを持ち、各surface recordもenvelopeと一致する
    • AC6: attempt 2を処理したtrusted consumer workflow runが完了し、対応するvisual-impact-policy-trusted CheckRunがsuccess
    • AC7: source PR、base/head SHA、RUN_ID、attempt番号、artifact名・ID・expired、JSON tuple、consumer run ID、CheckRun IDを#2287コメントへ記録する
    • AC8: repository file、branch、PR本文への変更がない

    修正版Verification Commands

    1. 対象runのpreflightとfull rerun

    set -euo pipefail
    
    REPO="squne121/loop-protocol"
    RUN_ID="RUN_ID_PLACEHOLDER"
    CUTOVER_SHA="ISSUE_2284_PHASE_B_MERGE_SHA_PLACEHOLDER"
    
    RUN_JSON="$(gh api "repos/${REPO}/actions/runs/${RUN_ID}")"
    PR_NUMBER="$(jq -r '.pull_requests[0].number // empty' <<<"${RUN_JSON}")"
    HEAD_SHA="$(jq -r '.head_sha' <<<"${RUN_JSON}")"
    BASE_SHA="$(jq -r '.pull_requests[0].base.sha // empty' <<<"${RUN_JSON}")"
    
    jq -e '
      .name == "ci" and
      .path == ".github/workflows/ci.yml" and
      .event == "pull_request" and
      .status == "completed" and
      .run_attempt == 1 and
      (.pull_requests | length) >= 1
    ' <<<"${RUN_JSON}" >/dev/null
    
    test "$(gh api "repos/${REPO}/pulls/${PR_NUMBER}" --jq '.state')" = "open"
    test "$(gh api "repos/${REPO}/pulls/${PR_NUMBER}" --jq '.head.sha')" = "${HEAD_SHA}"
    
    case "$(gh api "repos/${REPO}/compare/${CUTOVER_SHA}...${BASE_SHA}" --jq '.status')" in
      ahead|identical) ;;
      *)
        echo "対象runのbaseが#2284 Phase B cutoverを含んでいません" >&2
        exit 1
        ;;
    esac
    
    # full rerunのみ。--failed / --jobは禁止。
    gh run rerun "${RUN_ID}" --repo "${REPO}"
    gh run watch "${RUN_ID}" --repo "${REPO}" --exit-status
    
    test "$(gh api "repos/${REPO}/actions/runs/${RUN_ID}" --jq '.run_attempt')" -eq 2

    2. run全体から4 artifactを検証

    ARTIFACTS_JSON="$(mktemp)"
    
    gh api --paginate --slurp \
      "repos/${REPO}/actions/runs/${RUN_ID}/artifacts?per_page=100" \
      --jq '[.[].artifacts[]]' >"${ARTIFACTS_JSON}"
    
    for attempt in 1 2; do
      for prefix in \
        visual-impact-decision-v1 \
        component-vrt-evidence-manifest
      do
        name="${prefix}-${attempt}"
    
        jq -e \
          --arg name "${name}" \
          --arg head_sha "${HEAD_SHA}" \
          --argjson run_id "${RUN_ID}" '
            [.[] | select(.name == $name)] as $matches
            | ($matches | length) == 1
              and ($matches[0].expired == false)
              and ($matches[0].workflow_run.id == $run_id)
              and ($matches[0].workflow_run.head_sha == $head_sha)
          ' "${ARTIFACTS_JSON}" >/dev/null
      done
    done

    3. artifactをID指定で取得し、JSON型とtupleを検証

    ROOT="$(mktemp -d)"
    
    download_artifact() {
      local name="$1"
      local destination="$2"
      local artifact_id
    
      artifact_id="$(
        jq -r --arg name "${name}" \
          '.[] | select(.name == $name) | .id' \
          "${ARTIFACTS_JSON}"
      )"
    
      mkdir -p "${destination}"
      gh api "repos/${REPO}/actions/artifacts/${artifact_id}/zip" \
        >"${destination}.zip"
      unzip -q "${destination}.zip" -d "${destination}"
    
      printf '%s\t%s\n' "${name}" "${artifact_id}"
    }
    
    for attempt in 1 2; do
      download_artifact \
        "visual-impact-decision-v1-${attempt}" \
        "${ROOT}/decision-${attempt}"
    
      download_artifact \
        "component-vrt-evidence-manifest-${attempt}" \
        "${ROOT}/evidence-${attempt}"
    
      decision="${ROOT}/decision-${attempt}/visual_impact_decision_v1.json"
      evidence="${ROOT}/evidence-${attempt}/visual_baseline_review_evidence.json"
    
      jq -e \
        --arg expected_sha "${HEAD_SHA}" \
        --argjson expected_id "${RUN_ID}" \
        --argjson expected_attempt "${attempt}" '
          .workflow_run_id as $actual_id
          | .run_attempt as $actual_attempt
          | .head_sha as $actual_sha
          | .schema == "VISUAL_IMPACT_DECISION_V1"
            and (($actual_id | type) == "number")
            and (($actual_id | floor) == $actual_id)
            and ($actual_id == $expected_id)
            and (($actual_attempt | type) == "number")
            and (($actual_attempt | floor) == $actual_attempt)
            and ($actual_attempt == $expected_attempt)
            and ($actual_sha == $expected_sha)
        ' "${decision}" >/dev/null
    
      jq -e \
        --arg expected_sha "${HEAD_SHA}" \
        --argjson expected_id "${RUN_ID}" \
        --argjson expected_attempt "${attempt}" '
          .workflow_run_id as $actual_id
          | .run_attempt as $actual_attempt
          | .head_sha as $actual_sha
          | .schema == "VISUAL_BASELINE_REVIEW_EVIDENCE_V3"
            and (($actual_id | type) == "number")
            and (($actual_id | floor) == $actual_id)
            and ($actual_id == $expected_id)
            and (($actual_attempt | type) == "number")
            and (($actual_attempt | floor) == $actual_attempt)
            and ($actual_attempt == $expected_attempt)
            and ($actual_sha == $expected_sha)
            and (
              [.surfaces[] |
                (.workflow_run_id == $expected_id)
                and (.run_attempt == $expected_attempt)
                and (.head_sha == $expected_sha)
              ] | all
            )
        ' "${evidence}" >/dev/null
    done

    最終推奨

    #2287は残す。ただし今は実行せず、#2284 Phase B後の一回限りのoperational verificationへ改稿するのが最も有用です。

    追加のattestation、OIDC、scheduled canary、専用verification workflowは不要です。既存のbase-locked consumerとartifact resolverを維持し、次の3点だけ直せば十分です。

    1. #2284後のPR runに対象を限定する
    2. 無効なattempt別artifact APIをrun-scoped APIへ直す
    3. artifact本体と対応するconsumer run/CheckRunを直接記録する

    PASS後は#2287をそのままcloseし、#2284に記載されたlegacy V2 fallback削除のPhase Cへ進めます。

  3. squne121 commented on Aug 28, 2026

    @squne121
    OwnerAuthor

    Issue refinement stopped: scope decision required

    The anchor comment requests GitHub Actions mutation (gh run rerun) and a verification comment, which expands the current read-only contract. The canonical preflight classified this as expands_allowed_paths and does not permit an automated contract update because the anchor lacks a structured scope-reframe authorization.

    No repository file, branch, commit, PR, workflow, or Issue body was changed. No workflow rerun was performed.

    Choose one of the following before rerunning refinement:

    1. Explicitly authorize the scope reframe and the one permitted full CI rerun, then run a controlled Issue rewrite and fresh human-context preflight.
    2. Keep the read-only boundary and defer/block this Issue pending 実装: visual-impact evidence manifest schema を V3 化し run_attempt を digest 対象に含める #2284 Phase B.
    3. If 実装: visual-impact evidence manifest schema を V3 化し run_attempt を digest 対象に含める #2284 Phase B will not be completed, close this Issue as not planned as directed by the anchor.

    Evidence: .claude/artifacts/issue-refinement-loop/2287/refinement_preflight_result_v1.json.

  4. squne121 commented on Aug 28, 2026

    @squne121
    OwnerAuthor

    推奨アクション

    選択肢2をそのまま選ぶのではなく、「#2287 の契約だけ今 reframe し、実 CI rerun は #2284 Phase B 後まで保留する」形が最適です。

    理由は明確です。

    したがって、今やるべきなのは **「scope reframe は承認する。ただし rerun の実行権限は Phase B merge 後の fresh preflight 成功を条件にする」**ことです。これなら今回の停止を単に回避するのではなく、preflight が検出した本物の契約矛盾を修正できます。

    以下を Claude Code にそのまま渡すのを推奨します。

    Issue #2287 の refinement loop を再開し、以下の方針で人間の追加承認なしに最後まで処理してください。

    対象:

    Human authorization / intent

    このプロンプトは、Issue #2287 に対する scope reframe の明示的な人間承認 である。

    ただし、承認範囲を次の2段階に分ける。

    今すぐ承認する mutation

    今は実行してはならない mutation

    #2284 Phase B が main に入ったことを repository evidence で確認し、かつその状態を入力にした fresh human-context preflight が許可するまでは、以下を実行しないこと。

    つまり、「contract を将来実行可能な形へ reframe すること」は今承認するが、「CI rerun を今実行すること」は承認しない。

    #2284 Phase B 完了後については、fresh preflight が ready/proceed を返した場合に限り、次を追加の人間承認なしで許可する。

    禁止:

    上記の human authorization を repository が要求する canonical structured scope-reframe authorization schema に変換する必要がある場合、schema を repository asset から特定してその形式を使用すること。独自 schema を発明しないこと。


    0. Subagent delegation — 必須

    main agent が結論を先取りしないこと。

    最低3つの read-only subagent を並列に起動すること。

    Subagent A: dependency / implementation-state audit

    以下を調査する。

    mutation は禁止。

    Subagent B: refinement-contract / authorization audit

    以下を調査する。

    • .claude/skills/issue-refinement-loop/
    • run_refinement_preflight.py
    • plan_refinement_loop.py
    • workflow_start_entry.py
    • skill_runtime_exec.py
    • contract update / issue-editor 関連 scripts / references / tests
    • structured scope-reframe authorization の canonical schema / marker / parser
    • preflight.run.with_human_context
    • contract_update.run.with_human_context
    • NEXT_ACTION: issue_editor_required
    • full rewrite required 時の canonical handoff

    今回の human authorization を canonical workflow にどう入力すべきか確定する。

    guard を迂回する提案は禁止。

    Subagent C: GitHub Actions verification audit

    repository implementation と最新 GitHub Actions 仕様を照合して以下を確定する。

    • full workflow rerun の正規操作
    • failed-only / job-only rerun との違い
    • rerun の run_id / run_attempt semantics
    • GITHUB_SHA / GITHUB_REF
    • 30-day rerun restriction
    • workflow-run artifacts API
    • attempt-specific artifact API の有無
    • artifact pagination / exact-name cardinality の正しい確認方法
    • trusted consumer の起動条件
    • pull_request run を選ぶために必要な条件
    • stale PR head を rerun した場合の問題
    • decision/evidence artifact の実 ZIP を検証する方法

    新しい harness は設計しない。

    Join barrier

    3つの subagent がすべて作業を完了して結果を返すまで、Issue body更新、label更新、CI rerun、Issue comment投稿など一切の mutation を開始してはならない。

    「十分分かった」と判断して subagent を途中で放置しないこと。
    Task/Agent が asynchronous に返る場合も、全 subagent の terminal result を取得するまで待つこと。

    全結果を main agent で reconcile し、矛盾がある場合は repository evidence を優先して解消すること。


    1. Current-state decision

    subagent join 後、最初に #2284 Phase B の状態を判定する。

    Case A: #2284 Phase B が未完了

    今回はこちらが想定される primary path。

    Case B: #2284 Phase B が main に merge 済み

    • controlled reframe を完了
    • fresh human-context preflight を実行
    • fresh issue review / readiness を実行
    • 全 gate が ready/proceed の場合のみ、後述の runtime verification へ進む

    Case C: #2284 が closed as not planned / Phase B が明示的に廃止

    #2287 は旧 V2 production path だけを検証するために rerun を消費しない。

    単に #2284 が open で停滞しているだけなら Case C に分類しないこと。


    2. #2287 contract reframe requirements

    anchor comment #5456842673 を authority としつつ、現在の repository state と公式 GitHub semantics で再検証すること。

    少なくとも次を反映する。

    Dependency

    明示的に:

    Depends on: #2284 Phase B merged to main

    #2284 Phase B 前は runtime verification を開始しない。

    Verification target

    旧:

    ではなく、

    を検証対象とする。

    Allowed Operations

    repository path mutation と GitHub operational mutation を混在させない。

    将来 execution gate 通過後にのみ:

    を許可する。

    Repository Mutation

    明示的に禁止:

    • repository files
    • branch
    • commit
    • PR
    • workflow file
    • workflow_dispatch による代替 run

    Run selection

    candidate run は最低でも以下を満たすこと。

    適格 run が存在しなければ、workflow_dispatch や dummy commit を生成して代替しない。
    その場合は blocked evidence を残して停止する。

    Full rerun semantics

    必ず workflow 全体の rerun を使用する。

    許可:
    gh run rerun <RUN_ID>

    禁止:
    gh run rerun <RUN_ID> --failed
    gh run rerun --job ...

    actual command は repository の canonical command / permission policy が別 route を要求する場合はそちらを優先する。

    Artifact verification

    存在しない endpoint:

    /actions/runs/{run_id}/attempts/{attempt}/artifacts

    を使用しない。

    workflow run 全体の artifact collection を pagination 完了まで取得し、attempt-specific artifact names から identity を判断する。

    Phase B 後の実際の producer 名を repository から再確認した上で、少なくとも attempt 1 / 2 の:

    • decision artifact
    • evidence manifest artifact

    について expected exact names の cardinality がそれぞれ exactly one であることを確認する。

    名前は Issue の古い文字列を盲目的に使わず、Phase B 後の production workflow を SSOT とする。

    Artifact content

    attempt 1 / attempt 2 の実 artifact ZIP を取得して JSON を直接検証する。

    少なくとも:

    • workflow_run_id
    • run_attempt
    • head_sha

    について

    • JSON type
    • integer semantics
    • expected RUN_ID
    • expected attempt
    • expected HEAD_SHA

    を検証する。

    V3 evidence envelopeについて:

    • top-level tuple
    • surfaces[] が存在する場合は各 record と envelope の一致
    • no-impact surfaces: [] の場合も envelope identity が存在すること

    を確認する。

    表示用 CheckRun summary のみを JSON type 検証の代替にしてはならない。

    Trusted consumer

    attempt 2 に由来する trusted consumer execution を特定して:

    • trusted artifact acquisition が成功
    • relevant trusted CheckRun / workflow conclusion == success

    を確認する。

    同一 head SHA 上に同名 CheckRun が複数ある可能性を考慮し、「同名で success が1件ある」だけで attempt 2 と結び付けない。

    #2284 Phase B が source run id / attempt を summary に追加している場合はそれを使う。
    追加されていない場合は workflow run ID、timestamps、event chain、logs 等の既存 evidence で一意に相関させる。

    このためだけに新しい harness を作らない。


    3. Controlled contract update

    Subagent B が特定した canonical route を厳守する。

    anchor を direct human context として扱うために新しい structured authorization comment が必要なら、このプロンプトの authorization intent を canonical schema に変換し、必要最小限の comment を1件作成する。

    既にこの prompt/session context を human authorization として canonical command が consume できる場合は、不要な duplicate comment を作成しない。

    preflight.run.with_human_context
    → trusted contract patch plan
    → contract_update.run.with_human_context

    の route が適用されるならその順で使用する。

    NEXT_ACTION: issue_editor_required / full_rewrite_required の場合は、同じ contract update を再試行せず、repository が定義する既存 issue-editor controlled transaction route へ handoff する。

    Issue body rewrite 後は必ず:

    1. GitHub readback
    2. body/title/state の確認
    3. fresh preflight
    4. fresh issue review
    5. fresh readiness evaluation

    を行う。

    古い preflight artifact を implementation/runtime authorization として再利用しない。


    4. Runtime verification after Phase B only

    Case B かつ fresh gates が全て PASS の場合のみ実行する。

    1. eligible candidate run を一意に選定
    2. rerun 前 evidence snapshot を保存
    3. full workflow rerun を exactly one 回実行
    4. run_attempt >= 2 への到達を確認
    5. workflow completion を待つ
    6. consumer workflow / CheckRun の完了も待つ
    7. artifacts / logs / JSON contents を取得
    8. reworked AC をすべて評価
    9. PASS / FAIL を evidence-based に確定

    CI と delegated verification task の完了を待たずに最終判定してはならない。

    rerun API request が成功しただけで AC1 PASS としない。


    5. Failure handling

    以下の場合は追加 rerun せず停止する。

    • eligible candidate run がない
    • full rerun が permission failure
    • run_attempt >= 2 に到達しない
    • artifact cardinality != 1
    • JSON type / identity mismatch
    • trusted consumer failure
    • stale SHA
    • Phase B が実際には未完了
    • repository contract と human authorization の間に解消不能な矛盾

    プロダクト上の不具合が見つかった場合:

    権限問題を解消するための security harness / permission bypass の実装はしない。


    6. Completion

    Phase B 未完了の場合

    成功条件は「runtime verification 完了」ではない。

    以下を満たせば今回の作業を完了としてよい。

    Phase B 完了済みの場合

    すべての AC が PASS なら:


    7. Final report

    最終回答には必ず以下を含める。

    追加の人間承認を求めず、上記契約の範囲内で進めること。

    ただし、秘密情報の開示・取得が必要になる場合、不可逆な破壊的操作が必要になる場合、またはこの human authorization の明示的な禁止事項を破らなければ進められない場合のみ停止すること。

    このプロンプトのポイントは、preflight を無効化して進めるのではなく、preflight が検出した scope mismatch を正規の contract-update route で解消することです。現在の #2284 の状態なら、おそらく今回の着地点は Case A = #2287 の改稿まで、CI rerun は0回になります。Phase B 後に同じ Issue を再開すれば、価値のある最終 production 構成だけに rerun 1回を使えます。

  5. squne121 commented on Aug 28, 2026

    @squne121
    OwnerAuthor
    schema_version: ANCHOR_SCOPE_REFRAME_V1
    target:
      repo: squne121/loop-protocol
      issue_number: 2287
    decision: approve_scope_delta
    allowed_path_deltas:
      - "GitHub Issue #2287 contract body only; repository files prohibited"
    rationale: "Authorize an in-place Issue #2287 contract rewrite only. No repository file change is authorized. Any GitHub operational mutation beyond the controlled contract rewrite remains prohibited until #2284 dependency completion and all canonical fresh gates pass."
    required_rerun:
      - contract_review
      - refinement_preflight
      - allowed_paths_gate
  6. squne121 commented on Aug 28, 2026

    @squne121
    OwnerAuthor
    schema_version: ANCHOR_SCOPE_REFRAME_V1
    target:
      repo: squne121/loop-protocol
      issue_number: 2287
    decision: approve_scope_delta
    allowed_path_deltas:
      - "GitHub Issue #2287 contract body only; repository files prohibited"
    rationale: "Authorize an in-place Issue #2287 contract rewrite only. No repository file change is authorized. Any GitHub operational mutation beyond the controlled contract rewrite remains prohibited until #2284 dependency completion and all canonical fresh gates pass."
    required_rerun:
      - contract_review
      - refinement_preflight
      - allowed_paths_gate
  7. squne121 commented on Aug 29, 2026

    @squne121
    OwnerAuthor

    post-merge-cleanup: follow-up note (2026-08-29)

    PR #2388(Issue #2284 Phase B: .github/workflows/ci.yml の evidence manifest producer を V3 schema/generic filename へ切り替え)が main へマージされました(merged_at: 2026-08-29T02:21:10Z)。

    本 Issue の直近コメントに記載された blocked_by: "#2284 Phase B の main マージ" の条件はこれで解消しています。Phase B の producer cutover が production 経路(ci.yml → visual-impact-policy / visual-impact-policy-trusted)で実際に通ることは PR #2388 の review evidence(gh pr checks bounded poll、trusted consumer の実 run 検証)で確認済みです。

    本コメントは post-merge-cleanup の follow-up 候補として自動生成された note のみであり、Issue #2287 自体の contract 判定・scope reframe の実行判断は行いません。次アクション(実 CI rerun による attempt-specific artifact naming 検証の再開)は既存の Issue #2287 の直近コメント(ANCHOR_SCOPE_REFRAME_V1)に従ってください。

    Source: #2388

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/researchphase/researchstate/queued

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions