Skip to content

feat: scope-rollup registry invocation metadata - #1594

Merged
squne121 merged 1 commit into
mainfrom
worktree-issue-1579-scope-rollup-registry
Jul 18, 2026
Merged

squne121 merged 1 commit into
mainfrom
worktree-issue-1579-scope-rollup-registry

Conversation

@squne121

Copy link
Copy Markdown
Owner

Summary

  • scope_rollup.run の registry argv に --invocation-id と --requested-at を canonical 順序で追加しました。
  • 2つの必須文字列プレースホルダーを registry contract に追加し、直接 executor が既に要求する invocation metadata と SSOT を一致させます。
  • 完全 argv、必須値欠落、余分なパラメータ拒否、未解決プレースホルダー不在を回帰テストで固定しました。

Architecture decision

scope-rollup の specialized worker、policy、guard は変更しません。registry の child argv と既存 exact executor の入力契約だけを一致させる限定変更です。

Contract ownership

責務の境界は次表のとおり維持します。

所有者 責務 今回の変更内容
command_registry.py 子プロセス argv と必須プレースホルダーの管理 invocation metadata を追加
skill_runtime_command_policy.py exact command admission の安全判定 変更なし
run_scope_rollup_preflight.py invocation metadata の検証と結果生成 変更なし

Exact changed files

変更対象は次の許可済み2ファイルだけです。

  • .claude/skills/issue-refinement-loop/scripts/command_registry.py
  • .claude/skills/issue-refinement-loop/tests/test_command_registry.py

Checks

対象契約に対応する検証をすべて成功させました。

Schema Change Applicability

  • decision: schema_change
  • reason: scope_rollup.run の registry render contract に必須 placeholder と argv token を追加する additive change のため

Schema Consumer Inventory

Before

scope_rollup.run registry entry は issue number と repository だけを render parameter として要求していました。

After

同 entry は invocation identity と request timestamp を必須文字列として受け取り、--repo の後に固定順序で child argv へ渡します。

Consumer ファイル 更新有無 備考
scripts/agent-guards/skill_runtime_command_policy.py No 既に invocation metadata を exact command contract として所有
scripts/agent-guards/run_scope_rollup_preflight.py No 既に同 metadata を worker input として検証
.claude/agents/scope-rollup-runner.md No 既に caller-generated metadata を要求
.claude/skills/issue-refinement-loop/tests/test_command_registry.py Yes registry render contract を固定

Safety Claim Matrix

安全性に関する責務と未制御範囲を次表へ明示します。

Claim Implemented? Not controlled Evidence Follow-up 日本語による安全性の説明
metadata 欠落を registry render 時に fail-closed にする Yes caller value の semantic format validation は policy/worker の責務 missing-value tests #1580 の sibling profile 統合 必須メタデータの欠落を子プロセスへ渡しません
argv token order を1形状に固定する Yes direct-worker legacy path の cutover は未実施 exact argv test #1580 canonical argv の順序を回帰テストで固定します
未定義パラメータを child argv へ渡さない Yes registry 外の手書き command は本PRの対象外 extra-parameter test #1580 registry にない入力は fail-closed で拒否します

Base and head

PR作成時点の base と検証済み head は以下です。

  • 基準 base SHA: 15c3f143877bab657886e2987927431594a7fbbd
  • 検証済み head SHA: 95ee00544b0fa3f33a132b10d76886a8b2b28680
  • 重複プリフライト証跡: sha256:e053279b7f870d42ab704212c1f7f43d084b358e6b4166bd77c22d8b7d0888b8

Rollback plan

この1コミットを revert すれば、registry の argv と placeholder contract は直前の状態に戻ります。worker、policy、guard、結果スキーマ、repository write root は変更していません。

Notes

@github-actions

Copy link
Copy Markdown
Contributor

Preview URL

✅ verified live assets: https://squne121.github.io/loop-protocol/pr-1594/

The preview will be removed when this PR is closed.

@squne121 squne121 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

owner-level evidence review

Issue #1579 の AC1〜AC3 は registry entry の exact argv と required placeholders の追加で満たされ、AC4 は対象 pytest 37件の成功で確認しました。差分は contract の Allowed Paths にある2ファイルだけであり、allowed-paths review gate は current head で ok です。

CI の required checks はすべて 95ee00544b0fa3f33a132b10d76886a8b2b28680 に対して成功しました。通常コメント、formal review、inline review thread を再取得し、actionable feedback はありません。

LOOP_VERDICT_V2:
  verdict: APPROVE
  reviewed_head_sha: "95ee00544b0fa3f33a132b10d76886a8b2b28680"
  merge_ready: true
  mergeability:
    mergeable: MERGEABLE
    merge_state_status: CLEAN
  blockers: []
  required_auto_actions: []
  auto_fix_applied: []
  follow_up_issue_requests: []
  allowed_paths_gate:
    status: ok
  allowed_paths_gate_source: review_subagent

@squne121
squne121 merged commit e52913a into main Jul 18, 2026
22 checks passed
@squne121
squne121 deleted the worktree-issue-1579-scope-rollup-registry branch July 18, 2026 09:25
squne121 added a commit that referenced this pull request Jul 19, 2026
…#1602)

merge 済み PR #1594 の PR_REVIEW_PUBLISH_MARKER_V1 local marker が repo に残留し、
後続 preflight を unauthorized_write_path で fail-close 停止させていた(Issue #1593)。
remote GitHub state(merged-check endpoint + review_id primary key の exact review 一致)
を独立に再検証した場合に限り、marker を repo 外 archive root(XDG_STATE_HOME authority、
no-overwrite 発行)へ退避し、dir-fd/inode-bound TOCTOU-safe な unlink で repo 側 marker を
除去する専用 executor を追加する。失敗は
SOURCE_VALIDATED -> ARCHIVE_PREPARED -> ARCHIVE_DURABLE -> SOURCE_REMOVED
-> SOURCE_REMOVAL_DURABLE -> COMMITTED の state machine で honest に分類し、
unlink 前は marker を必ず保持、unlink 後に postcondition を確認できない場合は
indeterminate を返して「保持した」と偽らない。

post-merge-cleanup に merged PR number 限定の呼び出し手順を追加し、
POST_MERGE_CLEANUP_REPORT_V1 に pr_review_marker_archive result block を追加した。
責務境界(remote authority / archive は local cache/audit lifecycle に限定 / preflight
generic allowlist は拡張しない)を agent-skill-boundaries.md に記録した。

Co-Authored-By: Claude Sonnet 5 <[email protected]>
squne121 added a commit that referenced this pull request Jul 19, 2026
…#1628)

* 実装: マージ済み PR の pr_review.publish marker を限定 archive し preflight 阻害を防ぐ (#1602)

merge 済み PR #1594 の PR_REVIEW_PUBLISH_MARKER_V1 local marker が repo に残留し、
後続 preflight を unauthorized_write_path で fail-close 停止させていた(Issue #1593)。
remote GitHub state(merged-check endpoint + review_id primary key の exact review 一致)
を独立に再検証した場合に限り、marker を repo 外 archive root(XDG_STATE_HOME authority、
no-overwrite 発行)へ退避し、dir-fd/inode-bound TOCTOU-safe な unlink で repo 側 marker を
除去する専用 executor を追加する。失敗は
SOURCE_VALIDATED -> ARCHIVE_PREPARED -> ARCHIVE_DURABLE -> SOURCE_REMOVED
-> SOURCE_REMOVAL_DURABLE -> COMMITTED の state machine で honest に分類し、
unlink 前は marker を必ず保持、unlink 後に postcondition を確認できない場合は
indeterminate を返して「保持した」と偽らない。

post-merge-cleanup に merged PR number 限定の呼び出し手順を追加し、
POST_MERGE_CLEANUP_REPORT_V1 に pr_review_marker_archive result block を追加した。
責務境界(remote authority / archive は local cache/audit lifecycle に限定 / preflight
generic allowlist は拡張しない)を agent-skill-boundaries.md に記録した。

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix: PR #1628 review指摘の governed invocation欠落とCI test-plan未登録を修正する

- post-merge-cleanup/SKILL.md のドキュメント例に uv run --locked を追加
- .github/ci/python-test-plan.json に scripts/agent-ops/tests/ を登録し
  test_pr_review_marker_archive_exec.py を python-test lane でカバーする

* fix: harden pr_review_marker_archive_exec.py against OWNER security review P0-P2

OWNER security review (PR #1628 review comment #5014930088) identified
five P0 and several P1/P2 blockers in the merged-PR marker archive
executor. This addresses all of them:

- P0-1: archive root resolver no longer requires ownership of pre-existing
  system ancestors (e.g. /home); ownership is checked only from the
  nearest EXISTING ancestor (e.g. $HOME) downward. The resolved root is
  also refused if it resolves inside the repository itself.
- P0-2: gh/git are resolved ONLY from a fixed trusted PATH
  (/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin), never the ambient
  process PATH, with a sanitized subprocess environment. The worktree's
  origin remote is bound to a canonical https/ssh github.com URL and must
  match the repo the executor operates against.
- P0-3: any pre-existing archive destination (fresh check or a concurrent
  EEXIST race) is re-opened via a parent-directory fd with O_NOFOLLOW and
  strictly validated (regular file, owning uid, mode 0600, nlink==1,
  schema-valid JSON) before being trusted.
- P0-4: the marker's idempotency_key is strictly parsed and cross-checked
  against repo/pr_number/expected_head_sha; the review body's SHA-256 is
  recomputed from the pre-marker content and compared against the
  idempotency_key's body_sha256 component; the review author's identity
  is cross-checked against the authenticated gh identity.
- P0-5: source presence after unlink is classified into
  absent/same_inode_present/different_inode_present/unknown instead of a
  boolean, so a different file recreated at the canonical path is never
  conflated with "absent".
- P1-2: filesystem errors while preparing the archive (ENOSPC, EACCES,
  malformed pre-existing archive, ...) are converted to bounded
  reason_codes instead of propagating as raw exceptions; source marker
  file descriptors are always closed via an ExitStack-managed callback.
- P2: the merged-check HTTP status line is parsed strictly (anchored
  regex, not substring match), the 204 branch also requires rc==0, and
  gh api calls send explicit Accept / X-GitHub-Api-Version headers.

Extends the existing 8 tests to 38, covering the production
$HOME/.local/state resolver, repo-internal/relative/symlink/other-uid/
non-private XDG_STATE_HOME rejection, fake gh/git on the ambient PATH,
forged/symlinked/FIFO/directory/hardlinked archive destinations, the
concurrent-writer EEXIST durability barrier, rewritten review body /
review author mismatch, different-inode-after-unlink classification, and
bounded filesystem-error classification.

Issue #1602. PR #1628 review
#1628 (comment)

* fix: post-merge worker の実行ポリシーに pr_review_marker_archive_exec.py を配線する (P1-1)

OWNER レビュー指摘(PR #1628 review, P1-1): post-merge-cleanup/SKILL.md が
呼び出す scripts/agent-ops/pr_review_marker_archive_exec.py が Claude Code
の command allowlist に含まれておらず、自動 post-merge cleanup 経路が実行
できなかった。.claude/settings.json の permissions.allow に exact command
allow エントリを追加する。

---------

Co-authored-by: Claude Sonnet 5 <[email protected]>
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.

実装: command_registry.py の scope_rollup.run argv テンプレートに --invocation-id/--requested-at を反映する

1 participant