Skip to content

実装: scope-rollup-runner capture の timestamp 誤変換と非verbatim転記による fail-closed 反復を解消する #1661

Open

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "impl-review-loop preparation Step 2.5 の scope-rollup-runner capture が unquoted ISO8601 timestamp の datetime 誤変換・SubAgent による非 verbatim 転記で反復して fail-closed する問題を解消する"
change_kind: workflow

Parent Issue

none(単独改善)

Parent Goal Ref

  • Goal: なし(単独改善のため親 Issue なし)
  • Desired Destination: なし

Current Validated Scope

  • .claude/skills/impl-review-loop/scripts/parse_scope_rollup_run_result.py の YAML パースを timestamp-safe にする
  • .claude/hooks/capture_scope_rollup_final_response.py の YAML パースを timestamp-safe にする
  • .claude/agents/scope-rollup-runner.md に timestamp クォート必須化・raw stdout verbatim 転記の明示指示を追加する
  • 上記変更を回帰させる新規 pytest を追加する

Remaining Parent Gaps

  • なし。ただし agent_type_mismatch / hook_unavailable が特定の起動経路で頻発する根本原因(SubAgent 起動方法と SubagentStop hook 発火条件の不整合の可能性)は本 Issue のスコープ外であり、必要なら follow-up の調査 Issue で扱う。

Outcome

parse_scope_rollup_run_result.py と capture_scope_rollup_final_response.py が、ISSUE_SCOPE_ROLLUP_RUN_RESULT_V1 marker 内のクォートなし ISO8601 timestamp(ネストされた result.payload 内も含む)を PyYAML の datetime 自動変換に晒さず常に文字列として扱い、TypeError を送出せず決定論的な reject を返すよう修正され、かつ scope-rollup-runner.md に timestamp フィールドの二重引用符必須化と executor raw stdout の verbatim 転記を明示する指示が追加された状態。対応する新規回帰テスト(2ファイル)が追加され全て PASS している。

In Scope

  • parse_scope_rollup_run_result.py の _load_yaml_no_duplicate_keys(内部の _StrictLoader)から PyYAML の implicit timestamp resolver を除去し、marker 内の全フィールド(トップレベルの requested_at / generated_at と result.payload 配下のネストされたフィールドの両方)でクォートなし ISO8601 文字列が datetime 型へ自動変換されないようにする
  • capture_scope_rollup_final_response.py の _StrictLoader に同様の timestamp resolver 除去を適用し、parse_scope_rollup_run_result.py と一貫した文字列保持動作にする
  • 上記変更後も、既存の _parse_iso8601 による timestamp 順序検証(generated_at が requested_at より後)や _compute_payload_sha256 の canonical JSON 化が引き続き正しく動作することを保証する
  • scope-rollup-runner.md に、marker 内の全 ISO8601 timestamp フィールドを二重引用符で囲んだ文字列として出力することを明示する指示文を追加する
  • scope-rollup-runner.md に、run_scope_rollup_preflight.py の stdout(特に result.payload)を要約・言い換え・再構成せず、フィールド単位でそのまま転記することを明示する指示文を追加する
  • 上記4点の回帰を検証する新規 pytest ファイルを2つ追加する(既存テストファイルの変更は行わない)

Out of Scope

  • agent_type_mismatch / hook_unavailable が特定の起動経路で頻発する根本原因調査(SubAgent 起動経路と SubagentStop hook 発火条件の不整合の可能性を含む)。これは production telemetry・起動経路の実地観測を要する調査であり、follow-up の調査 Issue に切り出す
  • Codex 側の SubagentStop capture 復旧(Issue 実装: Codex の SubagentStop scope-rollup capture を復旧する #1527 が担当)
  • scope_rollup.run exact executor の skill_runtime_exec sibling profile への統合(Issue 実装:scope_rollup.runをskill_runtime_execのsiblingexactprofileへ統合する #1601 が担当)
  • marker schema・capture path・sidecar schema・duplicate/stale 判定ロジックそのものの変更(本 Issue は timestamp パース経路の防御的修正と agent 指示強化のみ)

Acceptance Criteria

  • AC1: parse_scope_rollup_run_result.py の _load_yaml_no_duplicate_keys が、marker のトップレベル requested_at / generated_at にクォートなし ISO8601 timestamp が書かれていても、_validate_marker_payload が datetime 型に起因する例外を送出せず、正しい文字列比較で処理を継続する。
  • AC2: parse_scope_rollup_run_result.py の _compute_payload_sha256 が、result.payload 配下にネストされたクォートなし timestamp 様フィールドを含む marker を渡されても TypeError を送出せず、status: rejected(reject_reason: result_sha_mismatch)で決定論的に fail-closed する。
  • AC3: capture_scope_rollup_final_response.py の _extract_marker_payload / _decision_from_payload が、クォートなし ISO8601 timestamp を含む last_assistant_message を渡されても例外を送出せず、requested_at / generated_at を文字列として SCOPE_ROLLUP_CAPTURE_RESULT_V1 に記録する。
  • AC4: scope-rollup-runner.md に、marker 内の全 ISO8601 timestamp フィールドを二重引用符で囲んだ文字列として出力することを明示する指示文が追加されている。
  • AC5: scope-rollup-runner.md に、run_scope_rollup_preflight.py の stdout(特に result.payload)を要約・言い換え・再構成せずそのまま転記することを明示する指示文が追加されている。

Verification Commands

# AC1
# baseline-expect: fail
# preflight-scope: pr_review_only
$ uv run --locked python3 -m pytest .claude/skills/impl-review-loop/tests/test_parse_scope_rollup_timestamp_hardening.py::test_unquoted_top_level_timestamps_do_not_datetime_convert

# AC2
# baseline-expect: fail
# preflight-scope: pr_review_only
$ uv run --locked python3 -m pytest .claude/skills/impl-review-loop/tests/test_parse_scope_rollup_timestamp_hardening.py::test_unquoted_nested_payload_timestamp_rejects_without_raising

# AC3
# baseline-expect: fail
# preflight-scope: pr_review_only
$ uv run --locked python3 -m pytest .claude/hooks/tests/test_scope_rollup_capture_timestamp_hardening.py::test_unquoted_marker_timestamps_captured_as_strings

# AC4
# baseline-expect: fail
$ rg -c "二重引用符で囲んだ文字列として出力する" .claude/agents/scope-rollup-runner.md

# AC5
# baseline-expect: fail
$ rg -c "要約・言い換え・再構成せず" .claude/agents/scope-rollup-runner.md

Allowed Paths

  • .claude/skills/impl-review-loop/scripts/parse_scope_rollup_run_result.py
  • .claude/skills/impl-review-loop/tests/test_parse_scope_rollup_timestamp_hardening.py
  • .claude/hooks/capture_scope_rollup_final_response.py
  • .claude/hooks/tests/test_scope_rollup_capture_timestamp_hardening.py
  • .claude/agents/scope-rollup-runner.md

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

Required Skills

  • Python(PyYAML カスタム Loader / SafeLoader resolver 制御)
  • pytest(回帰テスト設計)
  • SubAgent プロンプト設計(agent definition の指示強化)

Required Design References

  • docs/dev/hook-boundaries.md
  • .claude/skills/impl-review-loop/steps/preparation.md

Scope Delta

N/A

Notes for Reviewer

Activity

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

    phase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions