Skip to content

refactor(ai-loop): #896 検証ロジックを c3_contract.py へ共通契約層化(TASK-0896 exec)#902

Open
s977043 wants to merge 6 commits into
mainfrom
feat/task-0896-c3-contract
Open

refactor(ai-loop): #896 検証ロジックを c3_contract.py へ共通契約層化(TASK-0896 exec)#902
s977043 wants to merge 6 commits into
mainfrom
feat/task-0896-c3-contract

Conversation

@s977043

@s977043 s977043 commented Jul 22, 2026

Copy link
Copy Markdown
Owner

概要

c3-prime 契約の検証規則(契約定数 / sha256・canonical JSON hash / reviewer snapshot 三つ組照合)を scripts/ai-loop/c3_contract.py 単一モジュールへ集約し、arbiter / plan_package / c3prime_verify の 3 消費者が import 参照する構造にする振る舞い不変リファクタ#873 delivery.py / #874 run_evidence.py が最初から共通層を import できる基盤整理(EPIC #870・実装順は #873 と並行、c3_contract 先行 merge → #873 rebase)。

Closes #896

コミット構成(1 コミット 1 種類・各コミットで 4 系テスト green・単独 revert 可)

コミット 内容
91dbd81 (a) 契約定数集約(ARTIFACTS / VALID_* / SNAPSHOT_KEYS + REQUIRED_KEYS 系。is 同一を ConsumerAliasTests で固定)
673112d (b) sha256 / canonical JSON hash 単一実装化(ローカル hashlib 実装 0 件)
cf925c9 (c) snapshot 三つ組照合を check_snapshot_trio へ共通化 — strict_keys 引数で #889 R2 由来の強度非対称を保存(arbiter=余剰キー許容 / c3prime=ちょうど 5 キー)。理由リスト順序契約 + 代表文言回帰 + I/O 封じ純粋性テスト + AC-6 AST 回帰検査
99816f8 (d) sync copy + delete 保護の対列挙 / ta-55 に test_c3_contract 実行追記(CI 実行経路)/ plugin bundled 再生成(10 本・byte 同一)

検証(AC-1〜8 全 PASS・詳細 = handoff.md)

  • 4 系テスト: test_c3_contract 22 / test_arbiter 247 / test_plan_package 30 / test_c3prime_verify 12・run-tests 412 passed 0 failed(既存 411 の期待値変更ゼロ + ta-55 追記 1)
  • 敵対レビュー 2 レーン(critical/major 0): 独立レーンが新旧実装を同一敵対入力で駆動し plan_package_check 37/37 tuple 全一致・c3prime_verify 37/37 exit code 全一致・producer 出力 byte 同一を実測。Codex レーンも強度低下・偽造受理・import fail-open なしを確認(disposition: evidence/adversarial-review-disposition.md)
  • sync 2 回目 no-op / ta-30 bundled 自立 PASS(scripts=10)/ scripts↔plugin cmp 10 ファイル byte 一致

既知の注記(handoff KI-1)

複合異常入力での先頭 stderr 診断の優先順のみ変化(例: verdict 不正 + trio 改竄の同時入力で trio 不一致が先に報告される)。exit code・判定結果は全一致で、stderr を機械 parse する消費者は 0 件(rg 全数確認)。R-004 順序契約(キー集合 → 空値 → 三つ組)の設計帰結。

Refs: R-001, R-003, R-004, R-005, R-006, R-008, R-009, R-010

🤖 Generated with Claude Code

s977043 and others added 5 commits July 22, 2026 17:46
ARTIFACTS / VALID_DECISIONS / VALID_VERDICTS / SNAPSHOT_KEYS +
REQUIRED_KEYS 系(record 用 / 入力ブロック用)を単一モジュール定義にし、
arbiter / plan_package / c3prime_verify は import 参照(is 同一を
test_c3_contract.py で固定)。値は移行前と byte 同一・挙動変更なし。
arbiter への sys.path 操作は追加しない(R-008)。

Refs: #896

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…K-0896 コミット b)

plan_package._sha256_of / c3prime_verify._sha256 と両者の canonical
JSON hash 式を c3_contract.sha256_of_file / canonical_hash の単一実装に
置換(AC-2)。1 byte 改変検出・キー順序非依存の境界値テストを追加。
挙動変更なし(4 系テスト green・hashlib ローカル実装 0 件)。

Refs: #896

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… コミット c)

契約 AC-5 の核心規則(5 キー整合 + 三つ組一致)を c3_contract の I/O なし
純関数に集約し、arbiter(strict_keys=False = 余剰キー許容)と
c3prime_verify(strict_keys=True = ちょうど 5 キー)の両経路が同一実装を
使う(AC-3)。#889 R2 由来の強度非対称は strict_keys 引数で保存(R-005)。
理由リストは検査順で順序契約固定 + 代表文言回帰テスト(R-004)+
I/O 封じ純粋性テスト(R-003)+ AC-6 の AST 回帰検査。
残置: verdict 語彙 / 独立性 / AUTO_APPROVED / reviewers 2 者(c3prime)、
構造検査 / source_sha vs target_sha(arbiter)。
判定結果不変(4 系テスト green・偽造 14 パターン reject 不変)。

Refs: #896

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ミット d)

- sync-plugin-plangate.sh の copy 列挙 + delete 保護 case へ
  c3_contract.py / test_c3_contract.py を追加(R-008 教訓の対列挙)
- ta-55 に test_c3_contract.py 実行を追記(新設テストの CI 実行経路 / R-010)
- plugin bundled scripts を sync 再生成(8→10 本・byte 同一検証済み)
- sync 2 回目 no-op / ta-30 bundled 自立 PASS / run-tests 412 passed 0 failed

Refs: #896

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…dence)

Refs: #896

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 22, 2026 09:35
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

… River Review F-1)

strict 経路でキー集合検査通過後の falsy 値が「キー欠落」と報告され
オペレータ誤読を招くため 1 語修正(判定結果・exit code 不変・旧文言の
被参照 0 件実測)。順序契約テストの assert を同時更新(契約改版として
明示コミット / R-004 Fallback 準拠)。plugin sync 再生成込み。

Refs: #896

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@s977043

s977043 commented Jul 22, 2026

Copy link
Copy Markdown
Owner Author

River Review(ローカル)実施結果

river-review:review-local を branch diff(origin/main...HEAD)へ適用(finding verification 付き・4 スイート独立再実行 + byte 比較 + 被参照 grep の実測検証済み)。

総合判定: マージ可(APPROVE 推奨)— critical/major 0

# severity 指摘 disposition
F-1 minor strict 経路で「キー存在するが空値」の診断が「キー欠落」と誤読されうる(判定・exit code 不変) 1c0cb0f で是正(文言を「キー欠落または空値」へ + 回帰テスト更新・契約改版として明示コミット)
F-2 info 複合異常時の先頭診断優先順変化 既 disposition(handoff KI-1)
F-3 info arbiter の sys.path 非挿入(python3 -P で fail-closed crash を実測 = auto-approve に倒れない) 既 disposition(handoff KI-2・R-008 確定設計)
F-4 info arbiter の共通層 import 中腹配置 不採用(使用箇所直近の意図コメントあり・AST テスト位置非依存)

security / performance は指摘なし(検証強度の非対称保存・受理器全検査項目の残存・fail-closed 構造を実コード照合で確認)。詳細: docs/working/TASK-0896/evidence/adversarial-review-disposition.md

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.

refactor(ai-loop): 検証ロジックの共通契約層化 — 定数/hash/snapshot三つ組照合の重複解消(#873/#874 前の基盤整理)

2 participants