Skip to content

feat(refinement): fixture human-context runtime profile - #2143

Merged
squne121 merged 4 commits into
mainfrom
worktree-issue-2136-fixture-human-context
Aug 15, 2026
Merged

squne121 merged 4 commits into
mainfrom
worktree-issue-2136-fixture-human-context

Conversation

@squne121

@squne121 squne121 commented Aug 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

fixture と human-context を同時に渡す test-only sibling command preflight.run.fixture.with_human_context を追加し、real executor subprocess から real preflight/planner までを offline E2E で検証します。production の preflight.run.with_human_context は変更していません。

今回の hardening は、transport の optional pair、Issue artifact-root confinement、argparse 前の raw argv exact gate、CLI 由来の human-context authority、実到達する gh canary と空の GH_CONFIG_DIR を対象にします。

Closes #2136(本 PR は Issue #2136 を完了させます。)

Checks

  • reviewed main SHA(conflict resolve のため rebase 基点として使用・最終確認時点でも同一): fe3c2f8aca410a1f0b085bd64566fb596d5b9408
  • current PR head SHA(fresh、conflict resolve + H1-H8 hardening 後): 9a7037e900e1d3fbaa4e8489c813a8a8e1c713d8
  • reviewed Issue body SHA: sha256:3b3f88e7ed3a2add644c3bbda751fedfedd0a6d7e8c52de764573fd5c69618fc
  • current-head required CI: wait_ci_checks.py --required で head 9a7037e9 に bind して確認。typecheck / lint / test / build / python-test(agent-session-manifest validate-generated-artifact)すべて SUCCESS。full check list(e2e-core、e2e-responsive-matrix 含む)も gh pr checks 2143 で全 SUCCESS(deploy-pages 系のみ環境上 SKIPPED)。
  • AC1: registry/security lane は 80 passed。
  • AC2 と AC5: policy/executor anchor lane は 39 passed。transport present/absent はともに valid、partial・duplicate・reordered・--flag=value・unknown・symlink(H1)・whitespace/quote/backslash を含む fixture path(H3)は child 起動前に reject します。
  • AC3 と AC4: real subprocess E2E は 1 passed。exact argv を検証し、route は contract_update_required、implementation_allowed は false。fixture/transport は Issue 実装: preflight.run.with_human_context に gh fixture 対応を追加し AC3 positive route の real subprocess E2E を完成する #2136 artifact root に束縛され、fixture に known_context を注入せず CLI の human-context URL から derived planner output でのみ束縛されることを assert 済み。
  • AC4 negative control: effective child PATH の先頭と gh 解決先は test-only canary、sentinel は未発火(real subprocess run で証明、親側 diagnostic probe のみに依存しない)。GitHub token env は除去し、空の per-test GH_CONFIG_DIR と GH_PROMPT_DISABLED=1 を real child へ渡し、network/live API fallback は成功根拠にしていません。
  • AC6: issue-refinement-loop full suite は 1342 passed(回帰なし)。Ruff と git diff --check は pass。
  • H1-H8 adversarial hardening(fresh head 反映済み): H1(artifact-root/intermediate-dir symlink alias)と H3(raw argv serialize→shlex round-trip の unsafe-char)は CONFIRMED のうえ Allowed Paths 内で修正・regression test 追加。H2(optional transport absent の real-subprocess 到達性)は不足していた regression を追加。H4/H5/H6/H7/H8 は既存実装・テストで falsified(追加修正不要、独立 reviewer が再確認済み)。
  • 独立 pr-reviewer(fresh head 9a7037e9 に bind、H1-H8 を自ら再検証): verdict: APPROVE、blockers: []。feat(refinement): fixture human-context runtime profile #2143 (comment)
  • live mergeability(reviewer 投稿後の readback): mergeable: MERGEABLE、mergeStateStatus: CLEAN。

Schema Change Applicability

  • decision: not_schema_change
  • registry entry と runtime policy は既存 schema の additive command profile であり、既存フィールドの型・意味・consumer protocol は変更しません。

Schema Consumer Inventory

既存 consumer は registry validator、policy exact parser、executor dispatch、関連 pytest です。新 profile は既存 command ID の意味を変更せず、専用 ID のみを追加します。

Safety Claim Matrix

Claim Implemented? Not controlled Evidence Follow-up
sibling command は strict argv と shell=False を維持する yes - registry/policy/executor targeted tests、AC2 39 passed -
fixture/human-context E2E は live GitHub に到達しない yes - real subprocess run で PATH-first gh canary resolution・sentinel 未発火を証明、empty GH_CONFIG_DIR、全 token env removal、GH_PROMPT_DISABLED、AC3/AC4 1 passed。negative control PASS 済みのため yes -
fixture と transport は target Issue artifact root 外を受理しない(symlink alias 含む) yes - absolute/traversal/symlink escape/wrong-issue/root binding negative tests、H1 で intermediate-dir・artifact-root-prefix・transport-path の symlink component walk を追加、negative control PASS -
production human-context lane は fixture を受理しない(fixture/agent-report/production 三 lane 相互隔離) yes - sibling negative tests、AC5 lane 39 passed、独立 reviewer が production 側 --fixture reject と agent-report 側 transport reject の双方を再確認 -
raw argv exact gate は shlex round-trip で意味保存する(H3) yes - fixture path 内 whitespace/"/'/\ を shared helper で reject + argv-native pre-check、grammar widening なし -
compact reviewer transport の健全性 no reviewer transport contract historical transport failure は semantic approval に使用していない #2054

Notes

@github-actions

github-actions Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Preview URL

Preview removed (PR #2143 closed).

@squne121

Copy link
Copy Markdown
Owner Author

判定

PR #2143 は REQUEST_CHANGES 相当です。現状の actual_semantic_blockers: [] は維持できません。

visual-impact-policy-trusted の pr_body_digest_mismatch は確かに #2136 外の問題で、専用 Issue #2145 まで既に切り出されています。current #2143 head に対して trusted check が producer_artifact_verification_rejected で落ちていることも確認できました。 #2145 自身も、原因を trusted consumer の gh api --jq と producer の printf '%s' の改行差として特定し、別スコープで修正する契約にしています。

ただし敵対的に Issue #2136 の live contract と PR #2143 の実 diff を再照合すると、#2136 内に少なくとも4件の契約 blocker が残っています。

Severity | Finding | 判定 -- | -- | -- P1 | AC4 の gh canary が PATH に入っていない | confirmed P1 | optional であるべき transport flag が mandatory | confirmed P1 | fixture confinement が target Issue artifact root ではなく repo root | confirmed P1 | AC3 fixture が known_context.human_context_comment_urls を直接注入 | confirmed P2 | same-head PR-body edit を stale epoch と識別できない trusted workflow race | design gap / inference

P1: AC4 の gh canary が実質的に機能していない

#2136 の live contract は、AC4 の negative control として E2E child の PATH 先頭に gh canary を置くことを要求し、token unset や空の GH_CONFIG_DIR だけでは証明にならないと明示しています。

ところが PR #2143 のテスト自身が、

It is not placed on PATH

と明記しています。実際、$HOME/.local/bin/gh は作っていますが env["PATH"] を変更していません。

したがって、

assert not sentinel.exists()

が PASS しても、「gh が呼ばれなかった」は証明できません。canary ではない実 gh が解決された場合を検出できないからです。PR 本文の「fixture/human-context E2E は live GitHub に到達しない」という Safety Claim は現状過大です。PR 本文でもこの claim を AC3/AC4 の根拠にしています。

production executable trust を緩めるのではなく、test-only child environment で canary が実際に gh として resolve されることまで negative control で証明すべきです。

P1: optional transport pair が mandatory に変わっている

#2136 は --investigation-evidence-transport-path を optional flag pair として定義しています。

しかし新 registry entry は argv に常時その pair を含め、placeholder も "required": True です。 PR diff でもその状態が確認できます。

さらに executor 側も fixture+human-context command では transport path 欠落を拒否します。つまり AC1 の public command grammar 自体が Issue contract と一致していません。

transport-present happy path が PASS していても AC1 達成にはなりません。transport-absent の正当な invocation を regression として追加する必要があります。

P1: fixture の confinement が target Issue artifact root になっていない

#2136 は fixture を target Issue の artifact root 内に confinement し、その外を AC2 で拒否する契約です。

ところが _is_safe_repo_relative_fixture_path() が確認しているのは、実質的に

commonpath(root, resolved) == repo_root

までです。つまり repository 内なら通る実装です。

しかも positive E2E 自身が、

fixture_rel = "fixtures/ac3.json"

として repo root 直下の fixtures/ に作っています。

これは AC2 が要求する security boundary をテスト自身が迂回している状態です。fixture を例えば .claude/artifacts/issue-refinement-loop/<issue>/... に移し、issue number に束縛して confinement 判定する必要があります。

P1: AC3 が known_context を test fixture から直接注入している

#2136 は、real subprocess E2E の success を test 側からの known_context 直接注入で代替してはならない、と明示しています。

しかし _ac3_fixture() は、

"known_context": {"human_context_comment_urls": [anchor_url], ...}

を直接設定しています。

そのため --human-context-comment-url の production wiring が壊れていても、fixture 内の既知 context が positive route を助ける可能性があります。これは #2086 で過去に問題になった「real subprocess を称しながら authority context を test 側から供給する false-green」にかなり近い構造です。

fixture 側の human-context known_context は空にし、CLI flag → executor → preflight → planner の経路だけで contract_update_required に到達させるべきです。


visual-impact-policy-trusted の扱い

#2143 で security workflow を緩和せず停止した判断そのものは正しいです。#2145 はこの defect を明示的に分離しており、trusted consumer の PR-body read を producer と byte-equivalent にすることだけを扱います。また #2145 の contract では、この trusted check は branch protection required check ではなく P2 tracking と記録されています。

ただし branch-protection の required-status API は今回の GitHub App 権限では 403 だったため、「non-required」は #2145 の live authority に基づく判断であり、私から branch protection 設定そのものを独立 readback できたわけではありません。

修正方法については、単純な shell command substitution より、API JSON を trusted-side Python で parse し、body.encode("utf-8") を byte write する方法を推奨します。現状は trusted side が gh api ... --jq ... > pr_body.txt、producer が printf '%s' "$PR_BODY" です。 GitHub CLI の --jq は jq query を提供するインターフェースで、jq では --join-output/-j が「output 後の newline を付けない」専用オプションです。(GitHub CLI)

JSON decode → UTF-8 bytes write なら、元 body が本当に末尾 LF を含むケースまで保存できます。#2145 の fixture も「末尾改行なし」だけでなく、空 body、1個/複数個の末尾 LF、日本語、複数行、shell metacharacter を入れると品質が上がります。

なお #2144 は現在も Draft/Open で、同じ .github/workflows/visual-impact-trusted-consumer.yml と resolve_visual_impact.py を変更しています。 #2145 の worktree を開始する前に #2144 の current diff と再度 overlap 判定することが必須です。

高速に更新される main への耐性

ここは かなり改善されていますが、まだ完全ではありません。

#2102 は main advancement を通常の concurrency event として扱い、base-bound evidence の invalidation/rebind、latest-main net diff、expected-head/expected-old CAS、bounded drift retry、scope-clean reconciliation を実装する契約です。 再確認時点でも #2143 の base SHA は b6a69e... のままで、PR head も de5ccca... のままです。 したがって 今回の #2143 は今この瞬間には base drift していません。

弱いのは Git commit の drift ではなく、同じ head SHA のまま変化できる authority です。

現在 CI は PR の edited でも起動し、同一 ref の古い run を cancel-in-progress します。 GitHub Actions の concurrency は同じ group の in-progress run を cancel できますが、workflow_run: completed は triggering workflow の成功・失敗にかかわらず発生します。(GitHub Docs)

一方 trusted consumer の stale 判定は現在 workflow_run.head_sha != live PR head_sha が中心です。

したがって推論上、

PR body edit → head SHA は同じ → producer run generation は変わる → 古い workflow_run と新 live body が混ざる

という same-head metadata race を stale_head として識別できません。

改善するなら evidence epoch を単なる {base_sha, head_sha} ではなく、

{main_sha, issue_body_sha256, issue_updated_at, pr_head_sha, pr_body_sha256, producer_run_id, run_attempt}

程度まで拡張するのがよいです。body が変わったら security corruption 扱いではなく stale_pr_metadata_epoch、head が変われば stale_head_epoch、main が変われば #2102 reconciliation、と failure taxonomy を分離できます。

また複数 ClaudeCode/CodexCLI session では、全 main drift で full restart する必要はありません。old_main..new_main が PR の changed paths、Allowed Paths、または transitive control-plane dependencies と交差するときだけ evidence を選択 invalidation し、CI/security/review の base-bound evidence は常に再束縛する、という #2102 の方向が適切です。

推奨順序

まず #2143 の4件を同じ PR 内で修正し、AC1–AC6 を literal contract に対して再実行してください。その後 current main/head/body を再readし、独立 review をやり直します。#2145 は #2143 の修正と混ぜず、#2144 との overlap を解消してから別 worktree/PR で扱うのがよいです。

この ChatGPT 環境には SubAgent を実際に spawn/join する機能がないため、今回こちらから複数 SubAgent を起動して完了待ちすることはできませんでした。以下の CodexCLI prompt では、read-only SubAgent を並列起動し、全員 terminal になるまで mutation を禁止する join barrier を明示しています。

あなたは squne121/loop-protocol の root orchestrator である。

対象:

目的:

  1. PR feat(refinement): fixture human-context runtime profile #2143 を live Issue 実装: preflight.run.with_human_context に gh fixture 対応を追加し AC3 positive route の real subprocess E2E を完成する #2136 contract に対して敵対的に再レビューする。

  2. confirmed blocker があれば 実装: preflight.run.with_human_context に gh fixture 対応を追加し AC3 positive route の real subprocess E2E を完成する #2136 Allowed Paths 内だけで修正する。

  3. current main が高速に前進することを正常な concurrency event として扱い、stale evidence を再利用しない。

  4. 実装: visual-impact-policy-trusted の PR body 独立検証を producer 側改行取り扱いと一致させ pr_body_digest_mismatch 誤検知を解消する #2145 の trusted visual-policy defect は 実装: preflight.run.with_human_context に gh fixture 対応を追加し AC3 positive route の real subprocess E2E を完成する #2136 に混入させず、実装: visual-impact-policy-trusted に TS import graph transitive reachability の trusted-side 独立検証を追加する #2144 との overlap を確認して別スコープとして扱う。

  5. 実装・テスト・独立レビューまで人間承認不要で進める。ただし merge は実行しない。

  6. destructive operation、secret exposure、権限昇格、Allowed Paths 外変更、security gate の弱化は hard stop とする。

0. Live authority を最初に再取得する

過去の SHA・本文・チェック結果を authority として信用しない。

必ず fresh に取得する:

取得した値を LIVE_AUTHORITY_V1 として保持する。

実装開始後も、次の境界ごとに current main / PR head / Issue body を readback する:

  • mutation 前

  • commit 前

  • push 前

  • review 前

  • PR body 更新前

  • final verdict 前

main drift は通常の concurrency event とする。
#2102 の current contract / implementation を再利用し、main drift 自体で implementation iteration budget を消費しない。
古い CI / review / scope snapshot / contract snapshot を current evidence として再利用しない。

1. SubAgent fan-out

root coordinator から read-only SubAgent を並列起動する。

各 SubAgent は子 SubAgent を起動してはならない。
各 SubAgent に mutation authority を与えてはならない。

最低5 lane:

A. contract-diff-auditor

B. negative-control-auditor

  • AC3/AC4 real subprocess E2E を敵対的レビュー

  • gh canary reachability

  • PATH / HOME / GH_CONFIG_DIR / token env

  • known_context injection

  • real registry/executor/preflight/planner reachability

  • false-green の可能性
    を監査

C. trusted-visual-auditor

D. concurrency-epoch-auditor

E. external-spec-researcher
一次情報のみを使用:

  • GitHub Actions official docs

  • GitHub CLI official manual

  • jq official manual

  • Python subprocess docs

  • pytest docs
    必要な仕様だけを収集する。

JOIN BARRIER

A-E 全 SubAgent が terminal result を返すまで一切 mutation しない。

失敗・timeout した SubAgent は semantic approval に変換しない。
transport failure と semantic verdict を分離する。
#2054 が current main に未マージなら、その原則を手作業でも維持する。

A-E 全結果を root coordinator が統合し、
ADVERSARIAL_PREFLIGHT_V1
を作成してから implementation に進む。

2. 次の4 finding を「仮説」として必ず再検証する

過去レビューを盲信せず live diff で CONFIRMED / DISPROVED を判定する。

Finding 1: gh canary が reachable でない疑い

Issue #2136 AC4 は E2E child の PATH 先頭に gh canary を置く契約である。

PR #2143 の既知実装では $HOME/.local/bin/gh を作る一方、
test docstring が「PATH には置かない」と記述していた。

確認事項:

  • actual child environment で gh がどこに resolve されるか

  • canary が実際に accidental gh invocation を捕捉可能か

  • executor _sanitize_env() / executable trust が PATH をどう扱うか

CONFIRMED の場合:

  • production executable trust/PATH validation は絶対に緩めない

  • test-only E2E environment だけで canary が実際に gh として resolve されるようにする

  • canary resolution 自体を negative-control test で証明する

  • canary invocation は sentinel + nonzero exit

  • live network success を PASS にしない

Finding 2: optional transport pair が mandatory の疑い

Issue #2136 の live contract で
--investigation-evidence-transport-path
が optional flag pair か再確認する。

registry / validator / exact parser / executor が transport absent shape を拒否しているなら CONFIRMED。

CONFIRMED の場合:

  • transport-present と transport-absent の両方を valid grammar とする

  • duplicate / reordered / --flag=value / partial pair / unknown token は reject

  • registry の既存 optional-flag-pair infrastructure があれば再利用

  • schema/key-set 変更が必要なら勝手に拡張せず scope_change_required で hard stop

Finding 3: fixture confinement が repo-root のみに留まる疑い

Issue #2136 AC2 の fixture root を live body から正確に読み取る。

_is_safe_repo_relative_fixture_path() が単に repository-root confinement しか行わず、
positive fixture が fixtures/ac3.json 等に置かれているなら CONFIRMED。

CONFIRMED の場合:

  • fixture を target Issue artifact root 配下へ移す

  • issue number に binding

  • absolute path

  • ..

  • leading -

  • NUL / LF / CR

  • symlink escape

  • wrong issue artifact root
    を child 起動前に拒否する。

production fixture profile の既存 semantics は変えない。

Finding 4: known_context test injection の疑い

AC3 fixture が
known_context.human_context_comment_urls
を anchor URL で事前投入していないか調べる。

Issue contract がこれを AC3 success 根拠として禁止している場合、
fixture injection を削除する。

修正後は:
CLI
→ skill_runtime_exec
→ registry/policy
→ run_refinement_preflight
→ human-context derivation
→ planner/classifier
だけで
contract_update_required
かつ
implementation_allowed == false
へ到達させる。

direct run_preflight()、stub registry、test-side derived authority injection を代替証拠にしない。

3. #2136 implementation

confirmed blocker のみ修正する。

変更可能なのは current Issue #2136 の live Allowed Paths のみ。
毎回 live body から再取得すること。

実装方針:

  • smallest safe delta

  • production preflight.run.with_human_context を widen しない

  • sibling test-only command に限定

  • shell=False 維持

  • local_only 維持

  • mutation:false 維持

  • canonical root/default branch binding 維持

  • repo / issue / anchor / transport binding を弱めない

  • security rejection を PASS に変えない

4. Verification

Issue #2136 の literal Verification Commands を live body から抽出し、全件実行する。

加えて最低限:

  • registry tests

  • registry security tests

  • policy anchor tests

  • executor anchor tests

  • AC3/AC4 stable subprocess node

  • production preflight.run.fixture

  • production preflight.run.with_human_context

  • agent-report / unlabelled negative lanes

  • authority transport regressions

  • full issue-refinement-loop suite

  • relevant agent-guards suite

  • Ruff on changed Python

  • git diff --check

AC3/AC4 では以下を machine-verifiable に記録:

  • exact subprocess argv

  • effective test-only environment classification

  • gh canary resolved path

  • sentinel absent

  • no live GitHub success fallback

  • route.action

  • implementation_allowed

  • fixture resolved path

  • fixture issue-root binding

  • transport-present case

  • transport-absent case

test count は古い PR body からコピーしない。
current HEAD で再計測する。

5. main drift reconciliation

implementation 中に origin/main が前進した場合:

  1. old_base / new_base を記録

  2. current PR head を再read

  3. Issue body sha256 を再read

  4. old_base..new_base changed paths を収集

  5. PR Allowed Paths / direct dependencies / transitive control-plane dependencies と交差判定

  6. 実装: issue-refinement-loop / impl-review-loop の main drift を自動再束縛・scope-clean reconciliation する #2102 の scope-clean reconciliation を利用

  7. stale evidence epoch を破棄

  8. latest-main net diff で Allowed Paths を再gate

  9. semantic ambiguity が無ければ自動継続

  10. CAS mismatch / conflict / contract drift は fail-closed

main drift だけで fix iteration budget を消費しない。

evidence epoch は最低限:

  • main_sha

  • issue_body_sha256

  • issue_updated_at

  • pr_head_sha

  • pr_body_sha256

  • relevant workflow_run_id

  • run_attempt

を追跡する。

6. Independent final review

実装担当とは別の read-only reviewer SubAgent を新規起動する。
過去 SubAgent の verdict を再利用しない。

review input:

  • current Issue body

  • current main

  • current PR head

  • full diff

  • literal AC

  • current tests

  • current CI

  • confirmed/disproved findings

  • main drift history

P0/P1/P2 を明示する。

review transport failure の場合:

  • semantic approval として扱わない

  • bounded retry

  • retry 枯渇なら environment_failure

  • fallback approval を捏造しない

GitHub PR review publisher が current repository contract 上利用可能なら、
current head SHA に束縛して review evidence を永続化する。
権限・契約上不可能なら local artifact として明示し、
「GitHub submitted review 済み」とは報告しない。

7. PR #2143 更新

全 #2136 blocker が解消した場合のみ PR body を更新する。

必須:

  • reviewed main SHA

  • current PR head SHA

  • current Issue body SHA

  • AC1-AC6 fresh results

  • gh canary の実 reachability evidence

  • fixture confinement evidence

  • optional transport present/absent evidence

  • known_context non-injection evidence

  • full regression count

  • Ruff

  • diff check

  • independent review verdict

  • unresolved external check を明確に分離

merge は実行しない。

8. #2145 / trusted visual-policy

#2136 の修正と同一 PR に混ぜない。

まず:

PR #2144 は trusted consumer workflow を並行変更している可能性があるため、
hunk-level conflict と semantic overlap を確認する。

safe に独立実装できない場合は
overlap_reconciliation_required
で停止し、別 session の変更を上書きしない。

#2145 を実装する権限・scope が明確に存在する場合のみ専用 worktree で進める。

PR body の byte-exact 取得では:

  • tr -d '\n' を使わない

  • echo -n に依存しない

  • shell command substitution による trailing-newline loss を避ける

  • API JSON を trusted/base-branch Python で parse

  • body string を UTF-8 bytes として write
    する方式を第一候補として検証する。

fixture:

  • empty

  • single line

  • multiline

  • Japanese / Unicode

  • no trailing LF

  • one trailing LF

  • multiple trailing LF

  • shell metacharacters
    を含める。

producer の pr_body_sha256 と trusted-side rederived SHA256 が
同一 body bytes で一致することを証明する。

workflow trust boundary は弱めない。
candidate PR head のコードを privileged workflow_run job で実行しない。

9. same-head PR metadata race の調査

次を adversarial scenario として検証する:

T0:
PR head = H
PR body digest = B1
CI run R1 starts

T1:
head は H のまま PR body を B2 に edit
R1 が cancel/completed
CI run R2 starts

T2:
workflow_run consumer が R1 artifact を受け取る
live PR head は H
live PR body は B2

現在の stale check が head SHA のみなら、
R1 を stale と識別できない可能性がある。

これは #2145 の newline fix と別 scope か判定する。

別 scope の場合:

推奨 epoch:
{pr_head_sha, pr_body_sha256, producer_run_id, run_attempt}

10. Safety / stop conditions

即時 hard stop:

  • destructive git operation

  • force push

  • protected branch direct update

  • secret/token 出力

  • permission escalation

  • security workflow/check の緩和

  • Allowed Paths 外変更

  • Issue contract の無断書換え

  • schema/key-set の無断変更
    -別 agent/worktree の変更上書き

  • ambiguous concurrent edit

  • unresolved CAS mismatch

  • current-head readback failure

他セッションの worktree を cleanup/delete しない。

11. 最終出力

最後に次の machine-readable report を返す:

ISSUE_2136_ADVERSARIAL_RECOVERY_RESULT_V1

必須フィールド:

status:

  • merge_ready

  • needs_fix

  • environment_failure

  • scope_change_required

  • overlap_reconciliation_required

  • hard_stop

authority:

  • main_sha

  • issue_body_sha256

  • issue_updated_at

  • pr_number

  • pr_head_sha

  • pr_base_sha

  • pr_body_sha256

subagents:

  • launched

  • completed

  • failed_or_blocked

  • dangling

  • roles

findings:

  • id

  • severity

  • status: confirmed|disproved|fixed

  • evidence

  • changed_paths_if_fixed

verification:

  • ACごとの fresh result

  • regression count

  • ruff

  • diff_check

  • canary_resolved_path

  • canary_invoked

  • fixture_root_binding

  • optional_transport_present

  • optional_transport_absent

main_drift:

  • detected

  • old_base

  • current_base

  • reconciliation

  • stale_evidence_invalidated

review:

  • current_head_reviewed

  • verdict

  • blockers

  • transport_status

  • github_review_persisted

trusted_visual:

  • current_check_status

  • issue_2145_state

  • pr_2144_overlap

  • newline_defect_status

  • same_head_metadata_race_status

remaining_blockers:

  • exact blocker list

next_action:

  • exact next executable action

merge は実行しない。
全 SubAgent が terminal で dangling: 0 であることを最後に確認する。

この prompt の重要点は、#2145 を先に直して #2143 を通すのではなく、まず #2143 自身の false-green AC を潰すことです。trusted visual check が直ったとしても、現状の #2136 AC2/AC3/AC4 は merge-ready の証拠として不足しています。

## 判定

PR #2143 は REQUEST_CHANGES 相当です。現状の actual_semantic_blockers: [] は維持できません。

visual-impact-policy-trusted の pr_body_digest_mismatch は確かに #2136 外の問題で、専用 Issue #2145 まで既に切り出されています。current #2143 head に対して trusted check が producer_artifact_verification_rejected で落ちていることも確認できました。 #2145 自身も、原因を trusted consumer の gh api --jq と producer の printf '%s' の改行差として特定し、別スコープで修正する契約にしています。

ただし敵対的に Issue #2136 の live contract と PR #2143 の実 diff を再照合すると、#2136 内に少なくとも4件の契約 blocker が残っています。

Severity Finding 判定
P1 AC4 の gh canary が PATH に入っていない confirmed
P1 optional であるべき transport flag が mandatory confirmed
P1 fixture confinement が target Issue artifact root ではなく repo root confirmed
P1 AC3 fixture が known_context.human_context_comment_urls を直接注入 confirmed
P2 same-head PR-body edit を stale epoch と識別できない trusted workflow race design gap / inference

P1: AC4 の gh canary が実質的に機能していない

#2136 の live contract は、AC4 の negative control として E2E child の PATH 先頭に gh canary を置くことを要求し、token unset や空の GH_CONFIG_DIR だけでは証明にならないと明示しています。

ところが PR #2143 のテスト自身が、

It is not placed on PATH

と明記しています。実際、$HOME/.local/bin/gh は作っていますが env["PATH"] を変更していません。

したがって、

assert not sentinel.exists()

が PASS しても、「gh が呼ばれなかった」は証明できません。canary ではない実 gh が解決された場合を検出できないからです。PR 本文の「fixture/human-context E2E は live GitHub に到達しない」という Safety Claim は現状過大です。PR 本文でもこの claim を AC3/AC4 の根拠にしています。

production executable trust を緩めるのではなく、test-only child environment で canary が実際に gh として resolve されることまで negative control で証明すべきです。

P1: optional transport pair が mandatory に変わっている

#2136 は --investigation-evidence-transport-path を optional flag pair として定義しています。

しかし新 registry entry は argv に常時その pair を含め、placeholder も "required": True です。 PR diff でもその状態が確認できます。

さらに executor 側も fixture+human-context command では transport path 欠落を拒否します。つまり AC1 の public command grammar 自体が Issue contract と一致していません。

transport-present happy path が PASS していても AC1 達成にはなりません。transport-absent の正当な invocation を regression として追加する必要があります。

P1: fixture の confinement が target Issue artifact root になっていない

#2136 は fixture を target Issue の artifact root 内に confinement し、その外を AC2 で拒否する契約です。

ところが _is_safe_repo_relative_fixture_path() が確認しているのは、実質的に

commonpath(root, resolved) == repo_root

までです。つまり repository 内なら通る実装です。

しかも positive E2E 自身が、

fixture_rel = "fixtures/ac3.json"

として repo root 直下の fixtures/ に作っています。

これは AC2 が要求する security boundary をテスト自身が迂回している状態です。fixture を例えば .claude/artifacts/issue-refinement-loop/<issue>/... に移し、issue number に束縛して confinement 判定する必要があります。

P1: AC3 が known_context を test fixture から直接注入している

#2136 は、real subprocess E2E の success を test 側からの known_context 直接注入で代替してはならない、と明示しています。

しかし _ac3_fixture() は、

"known_context": {"human_context_comment_urls": [anchor_url], ...}

を直接設定しています。

そのため --human-context-comment-url の production wiring が壊れていても、fixture 内の既知 context が positive route を助ける可能性があります。これは #2086 で過去に問題になった「real subprocess を称しながら authority context を test 側から供給する false-green」にかなり近い構造です。

fixture 側の human-context known_context は空にし、CLI flag → executor → preflight → planner の経路だけで contract_update_required に到達させるべきです。


visual-impact-policy-trusted の扱い

#2143 で security workflow を緩和せず停止した判断そのものは正しいです。#2145 はこの defect を明示的に分離しており、trusted consumer の PR-body read を producer と byte-equivalent にすることだけを扱います。また #2145 の contract では、この trusted check は branch protection required check ではなく P2 tracking と記録されています。

ただし branch-protection の required-status API は今回の GitHub App 権限では 403 だったため、「non-required」は #2145 の live authority に基づく判断であり、私から branch protection 設定そのものを独立 readback できたわけではありません。

修正方法については、単純な shell command substitution より、API JSON を trusted-side Python で parse し、body.encode("utf-8") を byte write する方法を推奨します。現状は trusted side が gh api ... --jq ... > pr_body.txt、producer が printf '%s' "$PR_BODY" です。 GitHub CLI の --jq は jq query を提供するインターフェースで、jq では --join-output/-j が「output 後の newline を付けない」専用オプションです。(GitHub CLI)

JSON decode → UTF-8 bytes write なら、元 body が本当に末尾 LF を含むケースまで保存できます。#2145 の fixture も「末尾改行なし」だけでなく、空 body、1個/複数個の末尾 LF、日本語、複数行、shell metacharacter を入れると品質が上がります。

なお #2144 は現在も Draft/Open で、同じ .github/workflows/visual-impact-trusted-consumer.yml と resolve_visual_impact.py を変更しています。 #2145 の worktree を開始する前に #2144 の current diff と再度 overlap 判定することが必須です。

高速に更新される main への耐性

ここは かなり改善されていますが、まだ完全ではありません。

#2102 は main advancement を通常の concurrency event として扱い、base-bound evidence の invalidation/rebind、latest-main net diff、expected-head/expected-old CAS、bounded drift retry、scope-clean reconciliation を実装する契約です。 再確認時点でも #2143 の base SHA は b6a69e... のままで、PR head も de5ccca... のままです。 したがって 今回の #2143 は今この瞬間には base drift していません。

弱いのは Git commit の drift ではなく、同じ head SHA のまま変化できる authority です。

現在 CI は PR の edited でも起動し、同一 ref の古い run を cancel-in-progress します。 GitHub Actions の concurrency は同じ group の in-progress run を cancel できますが、workflow_run: completed は triggering workflow の成功・失敗にかかわらず発生します。([GitHub Docs]2)

一方 trusted consumer の stale 判定は現在 workflow_run.head_sha != live PR head_sha が中心です。

したがって推論上、

PR body edit → head SHA は同じ → producer run generation は変わる → 古い workflow_run と新 live body が混ざる

という same-head metadata race を stale_head として識別できません。

改善するなら evidence epoch を単なる {base_sha, head_sha} ではなく、

{main_sha, issue_body_sha256, issue_updated_at, pr_head_sha, pr_body_sha256, producer_run_id, run_attempt}

程度まで拡張するのがよいです。body が変わったら security corruption 扱いではなく stale_pr_metadata_epoch、head が変われば stale_head_epoch、main が変われば #2102 reconciliation、と failure taxonomy を分離できます。

また複数 ClaudeCode/CodexCLI session では、全 main drift で full restart する必要はありません。old_main..new_main が PR の changed paths、Allowed Paths、または transitive control-plane dependencies と交差するときだけ evidence を選択 invalidation し、CI/security/review の base-bound evidence は常に再束縛する、という #2102 の方向が適切です。

推奨順序

まず #2143 の4件を同じ PR 内で修正し、AC1–AC6 を literal contract に対して再実行してください。その後 current main/head/body を再readし、独立 review をやり直します。#2145 は #2143 の修正と混ぜず、#2144 との overlap を解消してから別 worktree/PR で扱うのがよいです。

この ChatGPT 環境には SubAgent を実際に spawn/join する機能がないため、今回こちらから複数 SubAgent を起動して完了待ちすることはできませんでした。以下の CodexCLI prompt では、read-only SubAgent を並列起動し、全員 terminal になるまで mutation を禁止する join barrier を明示しています。

あなたは squne121/loop-protocol の root orchestrator である。

対象:

目的:

  1. PR feat(refinement): fixture human-context runtime profile #2143 を live Issue 実装: preflight.run.with_human_context に gh fixture 対応を追加し AC3 positive route の real subprocess E2E を完成する #2136 contract に対して敵対的に再レビューする。
  2. confirmed blocker があれば 実装: preflight.run.with_human_context に gh fixture 対応を追加し AC3 positive route の real subprocess E2E を完成する #2136 Allowed Paths 内だけで修正する。
  3. current main が高速に前進することを正常な concurrency event として扱い、stale evidence を再利用しない。
  4. 実装: visual-impact-policy-trusted の PR body 独立検証を producer 側改行取り扱いと一致させ pr_body_digest_mismatch 誤検知を解消する #2145 の trusted visual-policy defect は 実装: preflight.run.with_human_context に gh fixture 対応を追加し AC3 positive route の real subprocess E2E を完成する #2136 に混入させず、実装: visual-impact-policy-trusted に TS import graph transitive reachability の trusted-side 独立検証を追加する #2144 との overlap を確認して別スコープとして扱う。
  5. 実装・テスト・独立レビューまで人間承認不要で進める。ただし merge は実行しない。
  6. destructive operation、secret exposure、権限昇格、Allowed Paths 外変更、security gate の弱化は hard stop とする。

0. Live authority を最初に再取得する

過去の SHA・本文・チェック結果を authority として信用しない。

必ず fresh に取得する:

取得した値を LIVE_AUTHORITY_V1 として保持する。

実装開始後も、次の境界ごとに current main / PR head / Issue body を readback する:

  • mutation 前
  • commit 前
  • push 前
  • review 前
  • PR body 更新前
  • final verdict 前

main drift は通常の concurrency event とする。
#2102 の current contract / implementation を再利用し、main drift 自体で implementation iteration budget を消費しない。
古い CI / review / scope snapshot / contract snapshot を current evidence として再利用しない。

1. SubAgent fan-out

root coordinator から read-only SubAgent を並列起動する。

各 SubAgent は子 SubAgent を起動してはならない。
各 SubAgent に mutation authority を与えてはならない。

最低5 lane:

A. contract-diff-auditor

B. negative-control-auditor

  • AC3/AC4 real subprocess E2E を敵対的レビュー
  • gh canary reachability
  • PATH / HOME / GH_CONFIG_DIR / token env
  • known_context injection
  • real registry/executor/preflight/planner reachability
  • false-green の可能性
    を監査

C. trusted-visual-auditor

D. concurrency-epoch-auditor

E. external-spec-researcher
一次情報のみを使用:

  • GitHub Actions official docs
  • GitHub CLI official manual
  • jq official manual
  • Python subprocess docs
  • pytest docs
    必要な仕様だけを収集する。

JOIN BARRIER

A-E 全 SubAgent が terminal result を返すまで一切 mutation しない。

失敗・timeout した SubAgent は semantic approval に変換しない。
transport failure と semantic verdict を分離する。
#2054 が current main に未マージなら、その原則を手作業でも維持する。

A-E 全結果を root coordinator が統合し、
ADVERSARIAL_PREFLIGHT_V1
を作成してから implementation に進む。

2. 次の4 finding を「仮説」として必ず再検証する

過去レビューを盲信せず live diff で CONFIRMED / DISPROVED を判定する。

Finding 1: gh canary が reachable でない疑い

Issue #2136 AC4 は E2E child の PATH 先頭に gh canary を置く契約である。

PR #2143 の既知実装では $HOME/.local/bin/gh を作る一方、
test docstring が「PATH には置かない」と記述していた。

確認事項:

  • actual child environment で gh がどこに resolve されるか
  • canary が実際に accidental gh invocation を捕捉可能か
  • executor _sanitize_env() / executable trust が PATH をどう扱うか

CONFIRMED の場合:

  • production executable trust/PATH validation は絶対に緩めない
  • test-only E2E environment だけで canary が実際に gh として resolve されるようにする
  • canary resolution 自体を negative-control test で証明する
  • canary invocation は sentinel + nonzero exit
  • live network success を PASS にしない

Finding 2: optional transport pair が mandatory の疑い

Issue #2136 の live contract で
--investigation-evidence-transport-path
が optional flag pair か再確認する。

registry / validator / exact parser / executor が transport absent shape を拒否しているなら CONFIRMED。

CONFIRMED の場合:

  • transport-present と transport-absent の両方を valid grammar とする
  • duplicate / reordered / --flag=value / partial pair / unknown token は reject
  • registry の既存 optional-flag-pair infrastructure があれば再利用
  • schema/key-set 変更が必要なら勝手に拡張せず scope_change_required で hard stop

Finding 3: fixture confinement が repo-root のみに留まる疑い

Issue #2136 AC2 の fixture root を live body から正確に読み取る。

_is_safe_repo_relative_fixture_path() が単に repository-root confinement しか行わず、
positive fixture が fixtures/ac3.json 等に置かれているなら CONFIRMED。

CONFIRMED の場合:

  • fixture を target Issue artifact root 配下へ移す
  • issue number に binding
  • absolute path
  • ..
  • leading -
  • NUL / LF / CR
  • symlink escape
  • wrong issue artifact root
    を child 起動前に拒否する。

production fixture profile の既存 semantics は変えない。

Finding 4: known_context test injection の疑い

AC3 fixture が
known_context.human_context_comment_urls
を anchor URL で事前投入していないか調べる。

Issue contract がこれを AC3 success 根拠として禁止している場合、
fixture injection を削除する。

修正後は:
CLI
→ skill_runtime_exec
→ registry/policy
→ run_refinement_preflight
→ human-context derivation
→ planner/classifier
だけで
contract_update_required
かつ
implementation_allowed == false
へ到達させる。

direct run_preflight()、stub registry、test-side derived authority injection を代替証拠にしない。

3. #2136 implementation

confirmed blocker のみ修正する。

変更可能なのは current Issue #2136 の live Allowed Paths のみ。
毎回 live body から再取得すること。

実装方針:

  • smallest safe delta
  • production preflight.run.with_human_context を widen しない
  • sibling test-only command に限定
  • shell=False 維持
  • local_only 維持
  • mutation:false 維持
  • canonical root/default branch binding 維持
  • repo / issue / anchor / transport binding を弱めない
  • security rejection を PASS に変えない

4. Verification

Issue #2136 の literal Verification Commands を live body から抽出し、全件実行する。

加えて最低限:

  • registry tests
  • registry security tests
  • policy anchor tests
  • executor anchor tests
  • AC3/AC4 stable subprocess node
  • production preflight.run.fixture
  • production preflight.run.with_human_context
  • agent-report / unlabelled negative lanes
  • authority transport regressions
  • full issue-refinement-loop suite
  • relevant agent-guards suite
  • Ruff on changed Python
  • git diff --check

AC3/AC4 では以下を machine-verifiable に記録:

  • exact subprocess argv
  • effective test-only environment classification
  • gh canary resolved path
  • sentinel absent
  • no live GitHub success fallback
  • route.action
  • implementation_allowed
  • fixture resolved path
  • fixture issue-root binding
  • transport-present case
  • transport-absent case

test count は古い PR body からコピーしない。
current HEAD で再計測する。

5. main drift reconciliation

implementation 中に origin/main が前進した場合:

  1. old_base / new_base を記録
  2. current PR head を再read
  3. Issue body sha256 を再read
  4. old_base..new_base changed paths を収集
  5. PR Allowed Paths / direct dependencies / transitive control-plane dependencies と交差判定
  6. 実装: issue-refinement-loop / impl-review-loop の main drift を自動再束縛・scope-clean reconciliation する #2102 の scope-clean reconciliation を利用
  7. stale evidence epoch を破棄
  8. latest-main net diff で Allowed Paths を再gate
  9. semantic ambiguity が無ければ自動継続
  10. CAS mismatch / conflict / contract drift は fail-closed

main drift だけで fix iteration budget を消費しない。

evidence epoch は最低限:

  • main_sha
  • issue_body_sha256
  • issue_updated_at
  • pr_head_sha
  • pr_body_sha256
  • relevant workflow_run_id
  • run_attempt

を追跡する。

6. Independent final review

実装担当とは別の read-only reviewer SubAgent を新規起動する。
過去 SubAgent の verdict を再利用しない。

review input:

  • current Issue body
  • current main
  • current PR head
  • full diff
  • literal AC
  • current tests
  • current CI
  • confirmed/disproved findings
  • main drift history

P0/P1/P2 を明示する。

review transport failure の場合:

  • semantic approval として扱わない
  • bounded retry
  • retry 枯渇なら environment_failure
  • fallback approval を捏造しない

GitHub PR review publisher が current repository contract 上利用可能なら、
current head SHA に束縛して review evidence を永続化する。
権限・契約上不可能なら local artifact として明示し、
「GitHub submitted review 済み」とは報告しない。

7. PR #2143 更新

全 #2136 blocker が解消した場合のみ PR body を更新する。

必須:

  • reviewed main SHA
  • current PR head SHA
  • current Issue body SHA
  • AC1-AC6 fresh results
  • gh canary の実 reachability evidence
  • fixture confinement evidence
  • optional transport present/absent evidence
  • known_context non-injection evidence
  • full regression count
  • Ruff
  • diff check
  • independent review verdict
  • unresolved external check を明確に分離

merge は実行しない。

8. #2145 / trusted visual-policy

#2136 の修正と同一 PR に混ぜない。

まず:

PR #2144 は trusted consumer workflow を並行変更している可能性があるため、
hunk-level conflict と semantic overlap を確認する。

safe に独立実装できない場合は
overlap_reconciliation_required
で停止し、別 session の変更を上書きしない。

#2145 を実装する権限・scope が明確に存在する場合のみ専用 worktree で進める。

PR body の byte-exact 取得では:

  • tr -d '\n' を使わない
  • echo -n に依存しない
  • shell command substitution による trailing-newline loss を避ける
  • API JSON を trusted/base-branch Python で parse
  • body string を UTF-8 bytes として write
    する方式を第一候補として検証する。

fixture:

  • empty
  • single line
  • multiline
  • Japanese / Unicode
  • no trailing LF
  • one trailing LF
  • multiple trailing LF
  • shell metacharacters
    を含める。

producer の pr_body_sha256 と trusted-side rederived SHA256 が
同一 body bytes で一致することを証明する。

workflow trust boundary は弱めない。
candidate PR head のコードを privileged workflow_run job で実行しない。

9. same-head PR metadata race の調査

次を adversarial scenario として検証する:

T0:
PR head = H
PR body digest = B1
CI run R1 starts

T1:
head は H のまま PR body を B2 に edit
R1 が cancel/completed
CI run R2 starts

T2:
workflow_run consumer が R1 artifact を受け取る
live PR head は H
live PR body は B2

現在の stale check が head SHA のみなら、
R1 を stale と識別できない可能性がある。

これは #2145 の newline fix と別 scope か判定する。

別 scope の場合:

推奨 epoch:
{pr_head_sha, pr_body_sha256, producer_run_id, run_attempt}

10. Safety / stop conditions

即時 hard stop:

  • destructive git operation
  • force push
  • protected branch direct update
  • secret/token 出力
  • permission escalation
  • security workflow/check の緩和
  • Allowed Paths 外変更
  • Issue contract の無断書換え
  • schema/key-set の無断変更
    -別 agent/worktree の変更上書き
  • ambiguous concurrent edit
  • unresolved CAS mismatch
  • current-head readback failure

他セッションの worktree を cleanup/delete しない。

11. 最終出力

最後に次の machine-readable report を返す:

ISSUE_2136_ADVERSARIAL_RECOVERY_RESULT_V1

必須フィールド:

status:

  • merge_ready
  • needs_fix
  • environment_failure
  • scope_change_required
  • overlap_reconciliation_required
  • hard_stop

authority:

  • main_sha
  • issue_body_sha256
  • issue_updated_at
  • pr_number
  • pr_head_sha
  • pr_base_sha
  • pr_body_sha256

subagents:

  • launched
  • completed
  • failed_or_blocked
  • dangling
  • roles

findings:

  • id
  • severity
  • status: confirmed|disproved|fixed
  • evidence
  • changed_paths_if_fixed

verification:

  • ACごとの fresh result
  • regression count
  • ruff
  • diff_check
  • canary_resolved_path
  • canary_invoked
  • fixture_root_binding
  • optional_transport_present
  • optional_transport_absent

main_drift:

  • detected
  • old_base
  • current_base
  • reconciliation
  • stale_evidence_invalidated

review:

  • current_head_reviewed
  • verdict
  • blockers
  • transport_status
  • github_review_persisted

trusted_visual:

  • current_check_status
  • issue_2145_state
  • pr_2144_overlap
  • newline_defect_status
  • same_head_metadata_race_status

remaining_blockers:

  • exact blocker list

next_action:

  • exact next executable action

merge は実行しない。
全 SubAgent が terminal で dangling: 0 であることを最後に確認する。

この prompt の重要点は、#2145 を先に直して #2143 を通すのではなく、まず #2143 自身の false-green AC を潰すことです。trusted visual check が直ったとしても、現状の #2136 AC2/AC3/AC4 は merge-ready の証拠として不足しています。

@squne121

Copy link
Copy Markdown
Owner Author

独立 current-head レビュー

独立 read-only review で、AC1–AC6、Allowed Paths、optional transport pair、Issue artifact-root confinement、argparse 前 raw argv reject、fixture の known_context 非注入、PATH-first gh canary/GH_CONFIG_DIR isolation を確認しました。

#2145 の trusted visual-policy byte transport と stale_pr_metadata_epoch は別スコープとして分離し、本 PR の approval 根拠には使用していません。historical reviewer transport failure も semantic approval に使用していません。

verdict: APPROVE
reviewed_head_sha: "29c21a4e1cc2ebdd4ea5af7f1c3c02a96f49d2e3"
blockers: []
warnings:
  - "GitHub submitted formal review ではなく、repository contract に従う current-head evidence comment。"
  - "#2145/#2144 trusted workflow overlap と stale_pr_metadata_epoch は #2136 scope 外。"

@squne121

Copy link
Copy Markdown
Owner Author

調査時点では、PR #2143 の head は 29c21a4e... のままですが、main は fe3c2f8a... まで進んでおり、GitHub API 上の PR は mergeable_state: dirty です。直近の APPROVE コメントは旧 main b6a69ebf... を基準にしたものなので、競合解消後の fresh head に対して CI と独立レビューを全面的に取り直す必要があります。

旧レビューで指摘された4件、つまり「実効 gh canary」「transport optionality」「target-Issue artifact-root confinement」「known_context 直接注入」は 29c21a4e... では修正済みと再レビューされています。 ただし、新たに Issue artifact root ディレクトリ自体を sibling Issue root への symlink にした場合の confinement は敵対的に再検証する価値があります。現実装は lexical prefix を確認後、realpath() した artifact root を信頼境界として使っているため、これは未証明の P1 候補です。Python の realpath() は symlink を解決するため、ディレクトリ境界そのものの symlink を明示的に negative test すべきです。 ([Python documentation]1)

また gh 非依存の証明については、GH_TOKEN の unset だけでは不十分です。GitHub CLI は環境変数以外の保存 credential も利用し得るため、現在のような PATH-first canary、隔離 GH_CONFIG_DIR、prompt disable を組み合わせる方向が妥当です。 ([GitHub CLI]2) Python subprocess の argv/env/timeout と pytest tmp_path の設計も公式仕様と整合します。 ([Python documentation]3)

以下をそのまま Claude Code に渡せます。

Claude Code 作業プロンプト — PR #2143 impl-review-loop

Repository: squne121/loop-protocol
Target Issue: #2136
Existing PR: #2143

Objective

既存 PR #2143 に対して repository-native の impl-review-loop を実行し、

current main への追従・競合解消 → 実装修正 → Verification → required CI → 独立 adversarial PR review → fix_delta → 再検証

を、通常の iteration ごとの人間承認を求めず自律的に反復してください。

最終到達点は **マージそのものではなく「マージ直前」**です。

以下をすべて同一 fresh PR head について満たした時点で停止してください。

PR を merge してはいけません。


Autonomy policy

通常の実装、テスト、commit、push、conflict resolution、review fix、再レビューについて、人間の iteration approval を求めないでください。

ただし、これは security / permission / repository guard の bypass を意味しません。

禁止:

rebase 後の push が必要な場合は repository runbook に従い、必要な場合のみ --force-with-lease を使用してください。

repository-native impl-review-loop の bounded iteration / consecutive-conflict / hard-stop 規則は維持してください。hard stop に到達した場合だけ停止し、その理由と証拠を報告してください。


Authority / freshness rule

この prompt に書かれた SHA、CI 状態、過去 verdict は starting observation にすぎず authority ではありません。

作業開始時と、各 mutation 後、最終判定直前に必ず live state を再取得してください。

最低限:

git fetch origin main

git rev-parse origin/main

gh issue view 2136 \
  --repo squne121/loop-protocol \
  --json title,body,state,comments,updatedAt

gh pr view 2143 \
  --repo squne121/loop-protocol \
  --json \
  number,state,isDraft,headRefName,headRefOid,baseRefName,mergeable,mergeStateStatus,body,comments,reviews

gh pr diff 2143 \
  --repo squne121/loop-protocol

過去の APPROVE、CI green、PR 本文の test counts を current-head evidence として再利用しないでください。


Mandatory repository sources

最初に以下を live read してください。

Primary contract

Repository workflow

  • .claude/skills/impl-review-loop/SKILL.md
  • .claude/skills/impl-review-loop/steps/preparation.md
  • .claude/skills/impl-review-loop/steps/step-1-implementation.md
  • .claude/skills/impl-review-loop/steps/step-2-verification.md
  • .claude/skills/impl-review-loop/steps/step-4-pr-review.md
  • .claude/skills/impl-review-loop/steps/step-5-feedback-and-termination.md
  • .claude/skills/impl-review-loop/steps/step-5-mergeability-handling.md
  • .claude/skills/impl-review-loop/steps/conflicting-pr-escalation-runbook.md
  • .claude/skills/implement-issue/SKILL.md
  • .claude/skills/pr-review-judge/SKILL.md
  • docs/dev/workflow.md
  • docs/dev/agent-skill-boundaries.md
  • docs/dev/runtime-verification-policy.md

live repository の記述を、この prompt より優先してください。


Mandatory historical investigation

Issue/PR 番号から内容を推測せず、live body / comments / diff を取得してください。

最低限:


Current-state conflict handling

prompt 作成時点では PR #2143 は main advancement による conflict 状態でした。

したがって live state でも mergeable == CONFLICTING または mergeStateStatus == DIRTY なら、repository の CONFLICTING PR Escalation Runbook をそのまま実行してください。

root thread が直接 conflict edit を行わず、implementation-worker へ conflict resolution を委譲してください。

解決後は必ず:

  1. fresh PR head SHA を取得
  2. current main との差分を取得
  3. Allowed Paths を再評価
  4. Verification を全面再実行
  5. fresh current-head CI を取得
  6. independent PR review を全面再実行

してください。

旧 head の test/CI/review evidence を merge readiness に流用してはいけません。


SubAgent discipline

root thread は control-plane に限定してください。

root が直接:

  • implementation edit
  • conflict edit
  • test judgment
  • PR review judgment

を兼任しないでください。

repository-native dispatch に従い、

  • implementation-worker
  • test-runner
  • pr-reviewer

を使ってください。

各 SubAgent は nested SubAgent delegation をしないでください。

各 dispatch について:

  • canonical task name
  • launched
  • terminal completed / failed
  • final result consumed

を確認し、最終判定前に dangling: 0 としてください。

timeout や途中 mailbox message を completion と扱わないでください。


External research

変更対象の技術について Web research を行ってください。

一次資料を優先してください。

最低限:

GitHub CLI official documentation

確認事項:

  • GH_TOKEN
  • GITHUB_TOKEN
  • stored credentials
  • GH_CONFIG_DIR
  • GH_PROMPT_DISABLED
  • executable resolution
  • headless authentication

目的:

GH_TOKEN を unset しただけでは gh 非呼出しを証明できないことを踏まえ、AC4 の canary が false-green にならないか確認する。

Python official documentation

確認事項:

  • subprocess.run
  • argv sequence
  • shell=False
  • env
  • timeout
  • os.path.realpath
  • os.path.commonpath
  • symlink semantics
  • shlex.split
  • shlex.join

pytest official documentation

確認事項:

  • tmp_path
  • per-test isolation
  • parallel test isolation

Git official documentation

確認事項:

  • git clone --local
  • --no-hardlinks
  • concurrent source-repository mutation時の注意
  • rebase / force-with-lease semantics が必要ならその一次資料

external research の結論は raw human instruction として worker に渡さず、root が repository evidence と突き合わせて technical_recommendation に正規化してください。


Adversarial review requirements

単なる「Issue の文字列どおり実装されているか」ではなく、security boundary と false-green の両方を攻撃してください。

以下は 仮説です。必ず current main + fresh PR diff で prove / falsify してください。


H0 — stale approval / stale CI

旧 PR head の approval や CI success は、current main への conflict resolution 後には無効です。

以下を fresh head に bind し直してください。

  • main SHA
  • PR head SHA
  • Issue body SHA
  • Verification result
  • CI workflow run
  • review verdict

PR 本文の evidence も fresh values に更新してください。


H1 — P1 candidate: target Issue artifact-root 自体の symlink alias

現在の実装が概念的に、

prefix = f".claude/artifacts/issue-refinement-loop/{issue_number}/"
artifact_root = realpath(join(root, prefix))
resolved = realpath(join(root, path))
commonpath([artifact_root, resolved]) == artifact_root

のような判定なら、次を敵対的に試してください。

.claude/artifacts/issue-refinement-loop/2136
    -> symlink to
.claude/artifacts/issue-refinement-loop/OTHER_ISSUE

その上で lexical path が、

.claude/artifacts/issue-refinement-loop/2136/fixture.json

である場合に parser が誤って accept しないか確認してください。

同様に:

  • fixture
  • investigation evidence transport
  • intermediate directory symlink
  • leaf symlink
  • sibling Issue root alias

を確認してください。

Issue #2136 AC2 の意味は単なる repository confinement ではなく、

target Issue #2136 の artifact root への binding

です。

If confirmed

Allowed Paths 内の最小修正で、target Issue artifact root 自体やその trusted path components の symlink substitution を reject してください。

既存 security utility / precedent があれば再利用してください。

過剰な新 security framework は作らないでください。

最低限、次の regression test を追加してください。

GIVEN target Issue artifact root itself is a symlink to another Issue artifact root
WHEN preflight.run.fixture.with_human_context is parsed/executed
THEN reject before child subprocess launch

fixture と transport の双方を確認してください。


H2 — optional transport pair の end-to-end 証明不足

--investigation-evidence-transport-path は optional pair です。

以下を層ごとに確認してください。

  • registry render: present
  • registry render: absent
  • policy exact parser: present
  • policy exact parser: absent
  • executor raw argv gate: present
  • executor raw argv gate: absent
  • executor render params: absent
  • real child launch: absent

parser unit test が PASS するだけで、executor が absent case を誤拒否していない証明になるか敵対的に評価してください。

executor 層が独立して regression 可能なら、transport-absent の real-executor regression を追加してください。

ただし AC3 の contract_update_required positive fixture が transport を必要とするなら、

  • optional grammar の real launch test
  • AC3 transport-present positive-route test

を別目的として分離してください。


H3 — raw argv serialize → shlex parse round-trip

current executor が raw argv を、

" ".join(raw_argv)

で string 化した後、policy 側が shlex.split() しているなら、これが exact argv gate として意味保存か確認してください。

特に:

  • whitespace を含む repo-relative filename
  • quote
  • backslash
  • shell-like characters

について placeholder contract がそもそも禁止しているか確認してください。

Case A

contract がこれらを明示的に禁止している:

→ reject regression を追加し、現在の grammar が intentional であることを固定。

Case B

contract 上 valid:

→ string round-trip に依存せず argv-native validation にするか、少なくとも lossless な quoting を使用。

ただし production parser の一般化や grammar widening は行わないでください。


H4 — gh canary が本当に executor child から resolve されるか

以下をすべて確認してください。

  • executor が生成する effective child PATH の先頭が canary directory
  • which gh 相当の resolution が canary 自体を指す
  • canary が呼ばれたら deterministic sentinel + nonzero exit
  • sentinel が最後まで存在しない
  • GitHub token environment が child に残っていない
  • empty per-test GH_CONFIG_DIR
  • GH_PROMPT_DISABLED=1
  • bounded timeout
  • live API / network fallback success が test PASS の根拠にならない

単に、

assert not sentinel.exists()

だけを見て PASS にしないでください。

実際に child environment で gh が canary に resolve されることを先に証明してください。


H5 — production lane isolation

新しい test-only sibling により、以下が accidentally widen されていないか確認してください。

  • preflight.run.fixture
  • preflight.run.with_human_context
  • preflight.run.with_anchor
  • preflight.run.with_agent_report

特に production preflight.run.with_human_context に:

  • --fixture
  • test-only GH_CONFIG_DIR behavior
  • sibling execution class
  • sibling PATH exception

が漏れていないことを確認してください。


H6 — authority / binding laundering

以下を negative test してください。

  • wrong repo
  • wrong Issue number
  • anchor URL が別 Issue
  • fixture Issue number mismatch
  • transport Issue mismatch
  • transport repo mismatch
  • transport anchor mismatch
  • body SHA mismatch
  • HEAD SHA mismatch
  • payload digest mismatch
  • duplicate flags
  • reordered flags
  • --flag=value
  • unknown flags
  • partial optional pair
  • duplicate optional pair
  • absolute path
  • ..
  • leading -
  • NUL
  • newline
  • symlink escape

いずれも canonical child の起動前、または transport validation 境界で fail-closed になることを確認してください。


H7 — known_context false-green の再発

AC3 positive E2E fixture に以下を直接 inject してはいけません。

known_context.human_context_comment_urls
investigation_derived_path_literals
scope authority equivalent

human-context authority は、

CLI flag
→ executor
→ registry-rendered child argv
→ run_refinement_preflight.py
→ planner

を実際に通って導出されることを確認してください。


H8 — local clone / test isolation

real-assets test が local clone + copy を利用している場合、source repository の dirty / mutable state を accidentally test input として取り込まないことを確認してください。

impl-review-loop preparation の clean-worktree invariant を前提としてよいですが、その invariant を bypass して test success を作らないでください。

tmp_path による test isolation と並列 pytest での collision がないことも確認してください。


Scope control

Issue #2136 の live Allowed Paths を authoritative としてください。

現在の契約で許可されたファイル以外が必要になった場合は、勝手に scope expansion しないでください。

特に以下はこの PR に混ぜない:

ただし current main との Git conflict を Issue #2136 の変更を保存するために解消することは conflict runbook の範囲で処理してください。


Implementation loop

repository-native impl-review-loop を Issue #2136 に対して開始してください。

default max_iterations を使用してください。

各 iteration:

Preparation
  ↓
Implementation / conflict resolution / fix_delta
  ↓
Verification
  ↓
fresh required CI
  ↓
independent adversarial PR review
  ↓
route_loop_verdict_v2

REQUEST_CHANGES

blockers[] をそのまま次 iteration の bounded fix_delta にして自動継続してください。

人間承認を挟まない。

stale reviewed head

fresh head で再レビュー。

BEHIND

repository-native update-branch route に従う。

CONFLICTING / DIRTY

CONFLICTING PR Escalation Runbook に従う。

BLOCKED / UNSTABLE / UNKNOWN

repository-native routing と bounded retry を使用し、自己判断で approval に昇格させない。


Verification

Issue #2136 の live Verification Commands を正確に実行してください。

加えて、今回の adversarial review で追加・変更した failure mode の targeted tests を実行してください。

最低限の regression scope:

uv run --locked pytest \
  .claude/skills/issue-refinement-loop/tests/test_command_registry.py \
  .claude/skills/issue-refinement-loop/tests/test_command_registry_security.py \
  -q

uv run --locked pytest \
  scripts/agent-guards/tests/test_skill_runtime_policy_anchor.py \
  scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py \
  -q

uv run --locked pytest \
  .claude/skills/issue-refinement-loop/tests/test_fixture_human_context_subprocess.py::test_fixture_human_context_real_subprocess_reaches_contract_update_required_ac3 \
  -q

uv run --locked pytest \
  .claude/skills/issue-refinement-loop/tests/ \
  -q

Issue の supplemental Ruff command も current live body から取得して実行してください。

さらに:

git diff --check

を実行。

agent-guards 全体が repository policy 上必要なら current canonical command で実行してください。

test count を prompt 内の過去値に合わせる必要はありません。fresh result を正本としてください。


Required CI

push 後は current PR head SHA を再取得してください。

repository の wait_ci_checks.sh を --required 付きで使用し、current head に bind してください。

branch protection / current repository policy から required checks を live resolve してください。

旧 workflow run の success を再利用しないでください。

required check failure があれば、CI log helper を使って root cause を取得し、fix_delta に含めて loop を継続してください。


Final independent adversarial review

CI success 後、fresh pr-reviewer を起動してください。

reviewer には実値として:

を渡してください。

reviewer は最低限:

verdict: APPROVE | REQUEST_CHANGES | HUMAN_REVIEW_REQUIRED
reviewed_head_sha: "<exact current head>"
blockers: []
warnings: []

を返すこと。

レビュー投稿前後で PR head を readback し、head が変わったら verdict を stale として破棄し fresh review をやり直してください。


PR body update

最終 fresh head について PR 本文の evidence を更新してください。

最低限:

  • reviewed current main SHA
  • current PR head SHA
  • current Issue body SHA
  • AC1–AC6 evidence
  • targeted adversarial regression results
  • full regression result
  • required CI run identity
  • independent review result
  • Schema Change Applicability
  • Safety Claim Matrix
  • out-of-scope / not-controlled claims

過大 claim をしないでください。

特に、

live GitHub に到達しない
target Issue artifact root 外を受理しない
strict argv

のような security claim は、それを直接壊そうとする negative control が PASS した場合だけ yes にしてください。


Completion condition

次の条件が すべて同一 head SHA に対して成立したら終了してください。

completion:
  issue_2136_ac1_ac6: pass
  allowed_paths: pass
  verification_commands: pass
  supplemental_checks: pass
  required_ci: pass
  reviewer_verdict: APPROVE
  reviewed_head_matches_current_head: true
  blockers: []
  live_mergeability_route: approved
  worktree_clean: true
  unresolved_conflict: false
  dangling_subagents: 0

その時点で、

READY FOR HUMAN MERGE

として停止してください。

merge は実行しないでください。

Closes #2136 は PR 本文に維持し、Issue close は merge に委ねてください。


Hard-stop report

repository-native hard stop に到達した場合は、承認を求める曖昧な質問ではなく、停止理由を具体的に返してください。

IMPL_REVIEW_LOOP_RESULT_V1:
  status: draft_pr_ready | human_escalation | max_iterations | hard_stop
  issue: 2136
  pr: 2143
  current_main_sha: "<sha>"
  current_pr_head_sha: "<sha>"
  mergeability:
    mergeable: "<value>"
    merge_state_status: "<value>"
  verification:
    status: pass | fail
    commands: []
  required_ci:
    status: pass | fail | incomplete
    checks: []
  review:
    verdict: APPROVE | REQUEST_CHANGES | HUMAN_REVIEW_REQUIRED | null
    reviewed_head_sha: "<sha|null>"
    blockers: []
    warnings: []
  adversarial_hypotheses:
    H1_issue_root_symlink_alias: confirmed | falsified | unresolved
    H2_optional_transport_e2e: confirmed | falsified | unresolved
    H3_raw_argv_roundtrip: confirmed | falsified | unresolved
    H4_gh_canary_resolution: confirmed | falsified | unresolved
    H5_production_lane_isolation: confirmed | falsified | unresolved
    H6_binding_fail_closed: confirmed | falsified | unresolved
    H7_known_context_false_green: confirmed | falsified | unresolved
    H8_test_isolation: confirmed | falsified | unresolved
  changed_paths: []
  out_of_scope_findings: []
  subagents:
    launched: 0
    completed: 0
    failed_or_blocked: 0
    dangling: 0
  termination_reason: "<reason>"

取得不能な evidence を推測で PASS にしないでください。

このプロンプトの主眼は、いま残っている DIRTY を単に解消して過去の APPROVE に戻すのではなく、current main との再統合後に security failure modes を再攻撃し、同一 fresh head に CI・レビュー・mergeability を束縛し直すことです。repository 自身の impl-review-loop も、DIRTY を conflict runbook に送り、解消後に Verification と PR review を再実行する契約になっています。

@squne121
squne121 force-pushed the worktree-issue-2136-fixture-human-context branch from 29c21a4 to a978c06 Compare August 14, 2026 16:39
…erage (H2)

H1 (confirmed): `_is_safe_issue_artifact_path()`'s realpath+commonpath
confinement is bypassable when a directory inside -- or exactly at --
the artifact-root prefix is a symlink, since both sides of the
comparison resolve through the same symlink and still agree. Added
`_path_contains_symlink_component()` to reject any symlinked path
component (fixture, transport, intermediate dir, or the artifact-root
prefix itself / sibling-issue-root alias) before realpath resolution.

H3 (confirmed): skill_runtime_exec.py re-serializes already-parsed argv
into a `" ".join(...)` string before the policy layer re-tokenizes it
with `shlex.split()` for validation, while the REAL child argv is built
separately from the untouched original values. A fixture/transport path
containing whitespace/quotes/backslash could validate a different
(truncated) substring than the one actually forwarded to the real
child. `_is_safe_repo_relative_fixture_path()` now rejects those
characters outright, and skill_runtime_exec.py additionally validates
`args.fixture` / `args.investigation_evidence_transport_path` directly
(argv-native, before any serialization) for the fixture+human-context
sibling.

H2: added a real-subprocess regression proving the executor's own
admission/dispatch path (not just the parser) accepts the
`--investigation-evidence-transport-path`-absent case.

H4/H5/H6/H7/H8: investigated, already adequately covered by the
existing PR #2143 test suite -- no changes required.
@squne121

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE

Independent review at head 9a7037e900e1d3fbaa4e8489c813a8a8e1c713d8 (verified live via gh pr view and a detached scratch worktree checkout of pull/2143/head, which resolved to the same SHA and whose merge-base with origin/main equals origin/main HEAD — no staleness, no unresolved conflict).

Verification performed

Blockers

(none)

verdict: APPROVE
reviewed_head_sha: "9a7037e900e1d3fbaa4e8489c813a8a8e1c713d8"
blockers: []
warnings: []

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.

実装: preflight.run.with_human_context に gh fixture 対応を追加し AC3 positive route の real subprocess E2E を完成する

1 participant