Skip to content

実装: Task Context adapter の recover / local-only 経路で non_closing_authority による Refs-bound PR の binding を受理する #2910

Open

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "Refs-bound PR の post-merge Task Context binding を、通常経路だけでなく復旧経路(recover)と local-only 経路でも同一の non_closing_authority 検証で成立させ、手動介入を不要にする"
change_kind: workflow

Parent Issue

none

Parent Goal Ref

Current Validated Scope

  • .claude/skills/post-merge-cleanup/scripts/task_context_workflow_signal.py の _fresh_merged_evidence(recover / local-only 共有)から _merged_evidence(..., allow_non_closing=True) を呼ぶ配線
  • tests/task-context/test_post_merge_workflow_signal_adapter.py の回帰テスト(既存の「recover / local-only は拒否」固定テストを新契約へ更新)
  • .claude/skills/post-merge-cleanup/SKILL.md、docs/dev/task-context.md、docs/dev/workflow.md の「recover / local-only は non-closing binding を受理せず従来どおり停止」記述の更新と、それを固定する tests/test_post_merge_cleanup_boundary.py の文言 assertion の更新

Remaining Parent Gaps

Background

Outcome

task_context_workflow_signal.py の --phase recover / --phase local-only が、#2878 と同一の 7 key authority 検証(decision == nonclosing_required、level が A1 または A2、repo / issue_number / pr_number 一致、pr_body_sha256 一致。live issue_state は再判定しない)を満たす Refs-bound PR を bind し、それ以外は従来の reason code で拒否して書き込み 0 とする状態が、実 CLI subprocess テストの PASS と post-merge-cleanup/SKILL.md / docs/dev/task-context.md / docs/dev/workflow.md の記述更新で確認できる。

Runtime Verification Applicability

decision: immediate
reason: Allowed Paths の .claude/skills/post-merge-cleanup/SKILL.md は docs/dev/extension-surface-runtime-policy.yaml の skill-invocation-procedure-or-contract-change(skill-invocation-runtime-smoke)の hard selector に該当し、default_decision: immediate である。免除条件(runtime 非読込・実行意味不変)は満たさない。経路選択(normal / local-only / stop)の意味は変えないため、#2817 AC11 の既存 read-only smoke fixture を再利用し、変更後の SKILL が実 runtime で引き続き宣言どおりに読まれ経路選択が退行しないことだけを確認する。新しい harness・runner・fixture は追加しない。
applicable_acs: [AC7]
execution_environment: linked worktree 内で claude 実行ファイルと uv が利用可能な現在の Claude Code session から scripts/agent-ops/run_worktree_agent_runtime_smoke.py を --runtime claude --mode structured で起動する。canonical root からは実行しない。output directory は run ごとに未使用の worktree 配下 path とする。smoke は read-only で、Task Context DB・cleanup_exec・adapter・gh・git 変更系を起動しない。
skip_conditions: claude または uv が利用不能、または structured smoke を起動できない環境では exit 77 + stdout 先頭 SKIP: で停止し、AC7 を PASS 扱いしない(docs/dev/runtime-verification-policy.md の SKIP 規約)。
fallback_policy: AC1〜AC6 の unit / subprocess test の PASS は AC7 の代替にしない。runtime を起動できない場合に static な文言確認だけで AC7 を PASS としない。
artifact_requirements: Claude Code version、起動条件、exit code、順序 marker の観測結果を PR 本文に記録する。raw transcript・credential・secret は記録しない。
runtime_assertion_bindings:

  • profile: skill-invocation-runtime-smoke
    assertion: procedure_steps_executed_in_declared_order
    ac: AC7
  • profile: skill-invocation-runtime-smoke
    assertion: output_contract_schema_fields_present
    ac: AC7

In Scope

  • _fresh_merged_evidence が _merged_evidence(snapshot, issue_number, pr_number, allow_non_closing=True) を呼ぶよう配線する(recover / local-only の双方)。fresh snapshot(mtime 300 秒以内)と --merge-identity の 40 hex 照合・--explicit-recovery 必須・local-only の outcome 許可集合など recover / local-only 固有の規則は順序・結果とも変えない。
  • tests/task-context/test_post_merge_workflow_signal_adapter.py に回帰テストを追加し、既存の「recover / local-only は拒否」テストを新契約(bind される)へ置き換える。
  • .claude/skills/post-merge-cleanup/SKILL.md、docs/dev/task-context.md、docs/dev/workflow.md の「recover / local-only は未対応」記述を「merged / completed / recover / local-only で受理」へ更新し、tests/test_post_merge_cleanup_boundary.py の該当文言 assertion を追従させる。

Out of Scope

Acceptance Criteria

  • AC1: closing node が空で有効な non_closing_authority(decision nonclosing_required、level A1 / A2 の双方)を持つ merged Refs-bound PR の fresh snapshot で、--phase recover --explicit-recovery が RELATION_ISSUE_MISMATCH で拒否されず、--phase merged と同じ証拠で claim の遡及付与(signal_recover)に進む。close authority は付与されない。
  • AC2: 同じ snapshot で --phase local-only が(許可 outcome の場合)local_only / LOCAL_ONLY_PERMITTED を返し、Task Context への書き込みは 0、authority の cleanup_completed / parent_issue_close / superseded_pr_close は全て false のままである。
  • AC3: 無効な non_closing_authority(欠落、decision 不一致、level が A1 / A2 以外、repo / issue_number / pr_number 不一致、pr_body_sha256 不一致、pullRequest.body 欠落・非 string、key 集合の不正)では recover / local-only の双方が従来の reason code(RELATION_ISSUE_MISMATCH 等)で拒否し、DB 書き込み 0 である。
  • AC4: recover / local-only 固有の規則が不変である。有効な authority があっても、snapshot が 300 秒より古ければ SNAPSHOT_STALE、--merge-identity 不一致なら MERGE_IDENTITY_MISMATCH、--explicit-recovery 欠落なら EXPLICIT_RECOVERY_REQUIRED で拒否され、書き込み 0 である。
  • AC5: closing node が 1 件以上ある PR の recover / local-only の挙動が従来どおりである(別 Issue の node があれば non-closing 判定へ fall through せず拒否)。
  • AC6: .claude/skills/post-merge-cleanup/SKILL.md、docs/dev/task-context.md、docs/dev/workflow.md が recover / local-only でも non_closing_authority binding が受理されると記述し、旧記述(recover / local-only は non-closing binding を受理せず従来どおり停止)が残っておらず、tests/test_post_merge_cleanup_boundary.py の assertion が新記述と一致して PASS する。
  • AC7: extension-surface policy が要求する最小の runtime 確認として、既存 read-only smoke(実装: マージ済み PR に Task Context の claim を遡及付与する復旧経路を追加する #2817 AC11 の fixture)が変更後の SKILL で実 Claude Code runtime 上に PASS し、順序 marker が宣言順に観測される(Runtime Verification Applicability 参照)。
  • AC8: 既存の品質ゲートが通る。

Verification Commands

# AC1
# baseline-expect: fail
$ uv run --locked pytest tests/task-context/test_post_merge_workflow_signal_adapter.py::test_given_non_closing_authority_when_recover_phase_then_claims_without_close_authority
# AC2
# baseline-expect: fail
$ uv run --locked pytest tests/task-context/test_post_merge_workflow_signal_adapter.py::test_given_non_closing_authority_when_local_only_phase_then_permit_with_zero_writes
# AC3
# baseline-expect: fail
$ uv run --locked pytest tests/task-context/test_post_merge_workflow_signal_adapter.py::test_given_invalid_non_closing_authority_when_recover_or_local_only_then_rejected_with_zero_writes
# AC4
# baseline-expect: fail
$ uv run --locked pytest tests/task-context/test_post_merge_workflow_signal_adapter.py::test_given_valid_non_closing_authority_when_recover_local_only_rules_violated_then_unchanged_rejection
# AC5
# baseline-expect: fail
$ uv run --locked pytest tests/task-context/test_post_merge_workflow_signal_adapter.py::test_given_closing_node_when_recover_or_local_only_then_legacy_behavior_unchanged
# AC6
# baseline-expect: fail
$ uv run --locked pytest tests/test_post_merge_cleanup_boundary.py::test_given_close_gate_matrix_when_compared_then_workflow_and_post_merge_skill_match
# AC6
$ uv run --locked pytest tests/task-context/test_post_merge_workflow_signal_adapter.py
# AC7
# preflight-scope: runtime_only
$ uv run --locked python3 scripts/agent-ops/run_worktree_agent_runtime_smoke.py --runtime claude --mode structured --worktree . --prompt-file tests/task-context/fixtures/post_merge_local_only_runtime_prompt.md --output-dir .claude/artifacts/worktree-agent-runtime-smoke/issue-recover-local-only-non-closing-ac7-run1 --timeout-seconds 600 --max-turns 12 --require-subagent-causal-evidence --require-min-subagents 1 --expect-ordered-marker POST_MERGE_ROUTE_A=normal_dispatch --expect-ordered-marker POST_MERGE_ROUTE_B=local_only --expect-ordered-marker POST_MERGE_ROUTE_C=stop_human_review --expect-marker POST_MERGE_ROUTE_A=normal_dispatch --expect-marker POST_MERGE_ROUTE_B=local_only --expect-marker POST_MERGE_ROUTE_C=stop_human_review
# AC8
$ pnpm typecheck
# AC8
$ pnpm lint
# AC8
$ pnpm test
# AC8
$ pnpm build
# AC8
$ uv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py

Allowed Paths

  • .claude/skills/post-merge-cleanup/scripts/task_context_workflow_signal.py
  • .claude/skills/post-merge-cleanup/SKILL.md
  • tests/task-context/test_post_merge_workflow_signal_adapter.py
  • tests/test_post_merge_cleanup_boundary.py
  • docs/dev/task-context.md
  • docs/dev/workflow.md

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • 7 key の再定義、新 reason code・新 schema、cleanup_exec.py の変更(実装: cleanup_exec の linked Issue 認可を closing relation 非依存の non_closing_authority に対応させる #2891)、Issue の自動 close、close gate の変更が必要と判明した場合
  • 動作検証 AC の VC が SKIP(exit 77)を返した場合(実行環境不可のためエスカレーション)
  • fallback 経由でのみ「成功」する場合(FAIL として扱い、実行環境を確認)

Required Skills

なし

Required Design References

  • docs/dev/task-context.md
  • docs/dev/workflow.md
  • docs/dev/runtime-verification-policy.md
  • docs/dev/extension-surface-runtime-policy.yaml
  • .claude/skills/post-merge-cleanup/SKILL.md

Delivery Rule

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/implementerenhancementphase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions