Repository navigation
Closed
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phase
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "controlled contract snapshot publisher の単一コメント readback が canonical parser projection と同じ trusted identity を検証できるようにする"
change_kind: codeParent Issue
none
Parent Goal Ref
- Goal: contract snapshot publisher の remote readback を fail-closed のまま正しい author identity で検証する。
- Desired Destination: Issue 実装: stale C1 decision を後続有効承認で supersede する #1649 の contract snapshot 再発行と implementation materialization を再開可能にする。
Current Validated Scope
- controlled publisher の単一コメント readback は id、URL、日時、本文だけを取得しており、trusted parser が要求する identity tuple を渡していない。
- canonical parser projection は
id、html_url、created_at、updated_at、body、author: .user.login、author_id: .user.id、author_type: .user.type、author_associationである。 - GitHub REST の単一 Issue comment response は nested
user.login、user.id、user.typeと top-levelauthor_associationを返すため、parser や trust policyを変更せず projection parity を回復できる。 - authoritative single-comment readback は
--hostname github.comとenv=_build_metadata_sanitized_env()で source binding する必要がある。
Remaining Parent Gaps
- Issue 実装: materializerのAllowed Paths正規化をcontract snapshotと統一する #1653 の materializer Allowed Paths 正規化差は別 Issue で扱う。
Outcome
controlled publisher が、単一 Issue comment REST response から canonical normalized identity key set を生成し、current・trusted・source-bound・fingerprint-ready な contract snapshot を production parser 経由で受理する。identity tuple の欠落・型不正・allowlist 不一致は fail-closed のままとし、固定 hostname と sanitized subprocess environment を伴う readback、および実 GitHub comment に対する read-only smoke の証跡を回帰テストとともに残す。
In Scope
_fetch_single_comment_by_id()のgh apiprojection を canonical parser projection と同じ normalized key set にする。author_idは GitHub REST の整数のまま保持し、文字列化しない。- 単一コメント readback を
--hostname github.comとenv=_build_metadata_sanitized_env()へ明示的に束縛する。 - REST-shaped response → normalized comment dict → production
parse_contract_review_results()→ trusted-author 判定の結合回帰を追加する。 - identity tuple の欠落、型不正、allowlist tuple 不一致を各 field ごとに fail-closed で検証する。
- exact comment-ID binding、duplicate-marker 回避、fingerprint readiness、live Issue body triple-hash 再検証を identity-bearing fixture で維持する。
- trusted source-bound comment #5015599730 を対象とする read-only GitHub smoke を、通常 CI から分離した
github_livetest lane として実装し、PR に証跡を記録する。
Out of Scope
- Issue 実装: materializerのAllowed Paths正規化をcontract snapshotと統一する #1653 が扱う materializer の Allowed Paths 正規化変更。
- contract snapshot の fingerprint schema、trusted publisher allowlist policy、two-phase publish 手順、production parser の共有定数化。
- Issue 実装: stale C1 decision を後続有効承認で supersede する #1649 の implementation 差分の変更。
- GitHub API response schema または GitHub CLI の仕様変更。
Acceptance Criteria
- AC1: 単一コメント readback が canonical normalized key set
id/html_url/created_at/updated_at/body/author/author_id/author_type/author_associationを生成し、author_idを bool でも文字列でもない正の整数として保持する。 - AC2: REST-shaped fixtureから得た current・trusted・source-bound・fingerprint-ready snapshot を production
parse_contract_review_results()と trusted-author 判定で受理する。 - AC3:
author、author_id、author_type、author_associationの各 field の欠落または型不正を parameterized regression ですべて fail-closed に拒否する。 - AC4: allowlist identity tuple の id、login、type、association の各不一致を parameterized regression ですべて fail-closed に拒否する。
- AC5: single-comment readback の argv が canonical
--jqprojection と--hostname github.comを含み、subprocess が_build_metadata_sanitized_env()を受け取る。 - AC6: identity-bearing REST fixture を使用しても exact comment-ID binding、duplicate-marker 回避、fingerprint readiness、live Issue body triple-hash 再検証が維持される。
- AC7: trusted source-bound comment #5015599730 の read-only GitHub response が canonical projection に正規化されることを
github_livelane で確認し、認証またはネットワークが使えない場合はSKIP:と exit 77 を記録し fallback を PASS として扱わない。
Runtime Verification Applicability
runtime_verification_applicability:
decision: immediate
reason: "今回の不具合は gh api の実 response normalization 境界にあるため、fixture regression に加え trusted source-bound Issue comment の read-only integration smoke が本 Issue 内で成立する。"
applicable_acs: [AC7]
execution_environment: "GitHub CLI 認証済みの WSL2 Ubuntu 24.04。ネットワーク接続と repositories/squne121/loop-protocol の Issue comment read 権限が必要。"
skip_conditions:
- "GitHub CLI 認証、ネットワーク、または対象 comment read 権限が利用できない場合、github_live test は stdout を SKIP: で開始し exit 77 を返して runtime verification artifact に記録する。"
fallback_policy: "fixture-only 実行、synthetic is_trusted_author boolean、raw nested user object、または host/environment binding を伴わない readback を AC7 の PASS として扱わない。"
artifact_requirements:
- "artifacts/runtime-verification-AC7-<timestamp>.log"
- "PR 本文の Runtime Verification Evidence に command、sanitized environment、canonical key set、exit code、PASS/FAIL/SKIP verdict を記録する。"Verification Commands
# AC1
# preflight-scope: pr_review_only
$ uv run --locked pytest scripts/agent-guards/tests/test_controlled_issue_metadata_exec.py -q -k "single_comment_canonical_projection"# AC2
# preflight-scope: pr_review_only
$ uv run --locked pytest scripts/agent-guards/tests/test_controlled_issue_metadata_exec.py -q -k "single_comment_production_parser_accepts_trusted_snapshot"# AC3
# preflight-scope: pr_review_only
$ uv run --locked pytest scripts/agent-guards/tests/test_controlled_issue_metadata_exec.py -q -k "single_comment_missing_identity_fails_closed"# AC4
# preflight-scope: pr_review_only
$ uv run --locked pytest scripts/agent-guards/tests/test_controlled_issue_metadata_exec.py -q -k "single_comment_identity_tuple_mismatch_fails_closed"# AC5
# preflight-scope: pr_review_only
$ uv run --locked pytest scripts/agent-guards/tests/test_controlled_issue_metadata_exec.py -q -k "single_comment_readback_binds_hostname_and_sanitized_env"# AC6
# preflight-scope: pr_review_only
$ uv run --locked pytest scripts/agent-guards/tests/test_controlled_issue_metadata_exec.py -q -k "single_comment_identity_fixture_preserves_existing_safeguards"# AC7
# preflight-scope: pr_review_only
$ uv run --locked pytest scripts/agent-guards/tests/test_controlled_issue_metadata_exec.py -q -m github_live -k "single_comment_read_only_github_smoke"Allowed Paths
- scripts/agent-guards/controlled_skill_mutation_exec.py
- scripts/agent-guards/tests/test_controlled_issue_metadata_exec.py
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
- GitHub CLI 認証、ネットワーク、または read-only comment 権限がなく AC7 が SKIP(exit 77)となった場合
- fallback 経由でのみ AC7 が成功する場合
Required Skills
なし
Required Design References
- docs/dev/workflow.md
- docs/dev/agent-skill-boundaries.md
- docs/dev/runtime-verification-policy.md
Scope Delta(任意)
N/A
Scope Collision
- related_issue: 実装: edit-issue skill の controlled executor に Issue title mutation を追加する #1660, 実装: HEAD-bound TEST_VERDICT publisher transaction を追加する #1647, 実装: GitHub native dependency 解除の controlled executor を追加する #1632, 実装: playtest-log の JSON Schema / validator の追加 #420, 実装: .claude/skills 配下スクリプトの executable bit を監査し CI guard を追加する #205
- overlapping_paths: scripts/agent-guards/controlled_skill_mutation_exec.py, scripts/agent-guards/tests/test_controlled_issue_metadata_exec.py
- non_conflict_reason: 実装: edit-issue skill の controlled executor に Issue title mutation を追加する #1660 は Issue title mutation、実装: HEAD-bound TEST_VERDICT publisher transaction を追加する #1647 は TEST_VERDICT publish、実装: GitHub native dependency 解除の controlled executor を追加する #1632 は GitHub dependency解除、実装: playtest-log の JSON Schema / validator の追加 #420/実装: .claude/skills 配下スクリプトの executable bit を監査し CI guard を追加する #205 は別の広域 concern を扱う。本 Issue は contract snapshot の canonical identity projection と source-bound single-comment readback に限定する。
- edit_intent: 単一コメント REST response を parser の trusted author 判定に必要な normalized metadata と整合させ、fixed hostname・sanitized environment・production parser regression・read-only smoke を固定する。
- dependency_ordering: 実装直前と commit/PR 作成直前に main の同一 Allowed Paths の競合を再取得し、既存 Issue の未コミット実装を変更しない。
Delivery Rule
- 1 Issue = 1 PR。
- 実装着手前に fresh
CONTRACT_REVIEW_RESULT_V1 status: goを取得する。 - normal commit / push のみを使用し、force push、hook disable、guard bypass を行わない。
Notes for Reviewer
- Anchor: 実装: controlled publisherのsnapshot author readbackを修正する #1664 (comment)
- 根因:
_fetch_single_comment_by_id()が identity tuple を持たない5キー projection を production trusted parser に渡し、current snapshot をremote_contract_snapshot_not_currentと誤判定する。 - API 根拠: GitHub REST single issue comment response の nested
user.login、user.id、user.typeと top-levelauthor_associationを正規化する。GitHub CLI の--hostname github.comを固定し、sanitized environment でも認証要件を保持する。
Metadata
Metadata
Assignees
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phase
Activity
squne121 commentedon Jul 20, 2026
判定
REQUEST_CHANGES — 原因分析は正しいものの、現状の Issue 契約では実装着手不可です。
Issue #1664 が特定した直接原因は正確です。
mainの_fetch_single_comment_by_id()はid、URL、日時、本文しか取得しておらず、その結果を trusted-author 判定を行う production parser に渡しています。parser 側はauthor、author_id、author_type、author_associationの完全な identity tuple を要求するため、正常な snapshot もremote_contract_snapshot_not_currentになります。ただし #1664 にはまだ補足コメントがなく、以下の security boundary とテスト境界が Issue 本文に固定されていません。現状のまま fresh
CONTRACT_REVIEW_RESULT_V1 status: goを出すべきではありません。1. Blocker: 正規化後のコメント schema が未定義
AC1 は「identity metadata を parser へ渡す」としか規定していません。これでは、実装者が GitHub REST の生の
userobject をそのまま残し、parser が期待する alias を生成しない実装でも、表面的には AC1 を満たしたと主張できます。production parser が使用している canonical projection は次です。
parser はこの正規化済みキーを読み、静的 allowlist に対して
user.id、login、type、association の全一致を要求します。フィールド欠落や型不一致はすべて fail-closed です。GitHub REST の単一 Issue comment response にも、nested
user.login、user.id、user.typeと top-levelauthor_associationが存在します。したがって schema や trust policy を変更する必要はなく、単一コメント readback の projection parity を回復すれば足ります。([GitHub Docs]1)必要な Issue 修正
AC1 に以下を明記すべきです。
2. Blocker: authoritative readback の host・environment binding が不足
現在の helper は次の形で
gh apiを呼んでいます。ここには次がありません。
--hostname github.comenv=_build_metadata_sanitized_env()一方、同じ executor の policy は
GH_HOST、GH_REPO、GH_CONFIG_DIR、debug 系変数を明示的な sanitize 対象としています。pr_review.publishなど後発の authoritative readback は、--hostnameと sanitized env の両方を使用しています。GitHub CLI は
--hostnameを提供しており、hostname が明示・推論されない処理ではGH_HOSTが接続先決定に関与します。現在の helper はcwdも固定していないため、「trusted GitHub identity を readback した」という security claim が helper 単体では閉じていません。([GitHub CLI]2)推奨形は以下です。
[ gh_bin, "api", "--hostname", _TRUSTED_GITHUB_HOST, f"repos/{repo}/issues/comments/{comment_id}", "--jq", _CANONICAL_COMMENT_PROJECTION, ]加えて、
subprocess.run(..., env=_build_metadata_sanitized_env())を渡す必要があります。これは Allowed Paths 内の同一ファイルで完結し、snapshot schema、publisher policy、two-phase publish の変更にも該当しません。#1664 の In Scope に含めるべきです。
3. Blocker: 現在のテストは今回の不具合を検出できない
既存の functional parser stub は、REST payload の identity metadata を検査せず、結果へ直接次を埋めています。
untrusted test も production trust policy を通すのではなく、stub の文字列を
Falseに置換して生成しています。つまり現在のテストが証明しているのは「trusted_only=Trueが synthetic boolean を除外すること」だけで、今回壊れている次の結合経路ではありません。さらに、単一 comment ID を選ぶ duplicate-marker 回帰テストの fake response も、現在の壊れた五フィールド payload をそのまま固定しています。これを更新しないと、projection regression が再発します。
最低限、次のテストが必要です。
subprocess.runの argv が canonical--jqprojection と--hostname github.comを含む。author、author_id、author_type、author_associationを一項目ずつ欠落させる parameterized test がすべて拒否される。userだけが存在し、正規化 alias がない comment は拒否される。production parser ファイルまで変更して projection を共有定数化すると Allowed Paths 外になります。本 Issue では parser を変更せず、exact projection parity をテストで固定するのが適切です。共有 helper 化は別 Issue が必要です。
4. High: Runtime Verification の
not_applicableは弱すぎるこの不具合は GitHub API のデータ不足ではなく、
gh api --jqによる response normalization の取りこぼしです。fixture test だけでも検証可能ですが、それを理由に実 API read-only smoke まで「適用外」とするのは、今回の再発経路と噛み合いません。リポジトリには GitHub 認証が必要な live test を
github_livemarker で通常 CI から除外し、明示実行可能にする先例があります。推奨する Runtime Verification は次です。
#1664 の直接の再現元である #1649 には、trusted author により投稿された source-bound
CONTRACT_REVIEW_RESULT_V1 status: gocomment が実在します。これを read-only smoke の対象にできます。CI 必須にしない場合でも、PR 本文には少なくとも次を証跡として残すべきです。
gh api \ --hostname github.com \ repos/squne121/loop-protocol/issues/comments/5015599730 \ --jq '{id,html_url,created_at,updated_at,body,author:.user.login,author_id:.user.id,author_type:.user.type,author_association}'5. Medium: AC と Verification Commands の追跡可能性が低い
AC1〜AC4 がすべて同じ test file 全体の実行になっており、どのテストがどの security property を証明するか判別できません。また、新規 positive regression が現行
mainで失敗するという baseline expectation もありません。推奨 AC 構成は次です。
新規 positive test には
baseline-expect: fail、既存 negative regression にはbaseline-expect: passを付けるべきです。回帰の系譜
今回の問題は単純な typo ではなく、段階的な security hardening 間の projection drift です。
trusted_only=Trueが導入されたが、controlled executor の修正は candidate filtering が中心で、単一 GET projection は canonical parser と同期されなかった。したがって修正の本質は「フィールドを四つ追加する」ではなく、canonical parser と authoritative single-comment readback の normalization contract を固定することです。
Scope と着手順序
#1653 の Allowed Paths normalization は別原因・別ファイルであり、Out of Scope の判断は妥当です。
一方、#1660 と #1647 はともに
controlled_skill_mutation_exec.pyを変更する open Issue です。実装直前だけでなく、commit・PR 作成直前にもmainの同ファイルを再取得し、projection helper、command dispatch、module trust chain 周辺の競合を確認する必要があります。最終結論
Issue #1664 の root cause、Allowed Paths、#1653 との分離は妥当です。
ただし、次の三点が本文に追加されるまで contract review は
blockedが適切です。--hostnameと sanitized environment による readback source binding本レビューは GitHub 上の current
main、Issue・PR・コメント・関連資産、および公式 GitHub REST/CLI 仕様に対する静的レビューです。ローカルで pytest は実行していません。squne121 commentedon Jul 20, 2026
Contract Review Result
squne121 commentedon Jul 20, 2026
Refinement Loop: Approved
The issue has been approved and is ready for implementation.
approvedsqune121 commentedon Jul 20, 2026
Refinement Loop: Human Escalation Required
The loop has terminated and requires human review. Cause: human judgment required
human_escalationhuman_judgment_requiredBlockers
squne121 commentedon Jul 20, 2026
Refinement Loop: Human Escalation Required
The loop has terminated and requires human review. Cause: human judgment required
human_escalationhuman_judgment_requiredBlockers
squne121 commentedon Jul 20, 2026
Scope Collision Decision
#1664 と #1632 は、同一の machine-readable key を編集せず、編集意図が独立しているため C1(安全な独立重複)として実装を続行する。
squne121 commentedon Jul 20, 2026
Refinement Loop: Human Escalation Required
The loop has terminated and requires human review. Cause: human judgment required
human_escalationhuman_judgment_requiredBlockers
squne121 commentedon Jul 20, 2026
Contract Review Result
squne121 commentedon Jul 20, 2026
Refinement Loop: Human Escalation Required
The loop has terminated and requires human review. Cause: human judgment required
human_escalationhuman_judgment_requiredBlockers
squne121 commentedon Jul 20, 2026
Contract Review Result
squne121 commentedon Jul 20, 2026
impl-review-loop: 完了(2026-07-20T11:09:03Z)
4eb2c44358d127a1ad63af98e3854e023b9ee1fafix: snapshot readbackの信頼境界を強化する (#1664)
squne121 commentedon Jul 20, 2026
impl-review-loop: 新HEAD再束縛後の完了(2026-07-20T11:37:42Z)
64a4b462fca9220463dcb72f42d06802e171db8c4eb2c44358d127a1ad63af98e3854e023b9ee1fa向け終了記録は本判定に使用しない。fix: snapshot author readbackを正規化する (#1665)