Skip to content

実装: agent-retrospective evaluator の identity.value 決定論的算出を分離する deterministic enrichment phase を追加する #2362

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "agent-retrospective evaluator を canonical candidate builder ではなく judgment producer に再設計し、identity/evaluation history/evidence の deterministic 部分を Python 側が 100% 決定論的に組み立てることで、非空 finding が candidate_schema_invalid で失敗しない状態にする"
change_kind: code

Parent Issue

なし(単独改善。関連 Issue として #2192・#2240・#2288・#2289・#2301・#2358 を参照)

Parent Goal Ref

Scope Reframe(本 Issue の改訂理由・#2367 review 経由の human decision に基づく)

本 Issue は当初、.claude/agents/retrospective-evaluator.md(evaluator prompt)を Out of Scope とし、「evaluator が完成 canonical candidate 相当の出力を要求され続けても enrichment 側の無条件上書きで無害化する」という前提で設計された。

PR #2367 の実装・OWNER レビュー・fix_delta を通じて、この前提が成立しないことが実証された:

  1. OWNER レビュー(https://github.com/squne121/loop-protocol/pull/2367#issuecomment-5451104673)が、旧実装の _fallback_evaluation_entry() 等が「bookkeeping の補完」ではなく「finding の判定・履歴・証拠の捏造」になっていることを specific code citation で指摘(P0: valid indeterminate evaluation が classified/new に意味論的に反転される、P0: 実在しない runtime receipt を参照する evidence の捏造、P1: subject_ref/rule_id が candidate_id に退化)。
  2. fix_delta で該当する捏造コードを完全削除し fail-closed(candidate_schema_invalid)にしたところ、AC3 の live CLI 検証が決定論的に失敗することが実測で判明した(3 回連続再現)。原因は、frozen retrospective-evaluator.md prompt が実行のたびに canonical shape とは全く異なる vocabulary(subject_path/defect_pattern、verdict/severity_assessed 等)を生成するためであり、かつ evaluator 呼び出しに渡される wire schema(evaluation_result_v1.schema.json)の candidate_records[].items が {"type": "object"} のみで実質無拘束であることが根本原因と確認された。
  3. 「捏造しない」(OWNER 必須要件)と「frozen evaluator prompt に対して AC3 が PASS する」は、evaluator prompt/wire schema を変更しない限り両立不可能であることが、独立した 4 系統の調査(Issue/PR/関連Issue 監査、evaluator wire-contract 監査、実装 diff 監査、architecture 比較の 4 SubAgent、うち architecture 比較では Claude Code Agent SDK の --json-schema が「渡された schema に対する validate + re-prompt + retry-limit fail-closed」であり、渡す schema が緩ければこの機構が効かないことを公式ドキュメント一次資料で確認)で確認された。

Repository owner はこれを踏まえ、retrospective-evaluator.md の Out of Scope 制約を撤回し、本 Issue / PR #2367 内で end-to-end contract を完成させることを承認した。ADR は不要と判断(既存 Issue の contract reframe として処理)。

Current Validated Scope

  • .claude/skills/agent-retrospective/scripts/run_retrospective.py の run_evaluation()・EvaluatorRequest・Evaluation.from_wire() / Evaluation._post_validate() / _validate_candidate_records()(canonical candidate validation)・_enrich_candidate_record()(deterministic enrichment)周辺
  • .claude/skills/agent-retrospective/scripts/schemas/evaluation_result_v1.schema.json(evaluator 呼び出し時に --json-schema として渡される wire schema。draft-07。現状 candidate_records[].items は {"type": "object"} のみで無拘束)
  • .claude/agents/retrospective-evaluator.md(evaluator の system prompt / frontmatter。tools: [] を維持したまま、出力 shape の instruction のみを改訂する)
  • run_retrospective.py の _validate_retrospective_schema_module()(sibling module loader)経由での compute_finding_identity() 呼び出し(--state-backend fixture を使った実 CLI 実行を含む)
  • 上記に対応する .claude/skills/agent-retrospective/scripts/tests/ 配下のテスト

Remaining Parent Gaps

  • なし(本 Issue で evaluator 側 identity 決定論化・judgment/deterministic 分離を完結させる)

Outcome

retrospective-evaluator agent を「canonical candidate builder」から「judgment producer」に再設計する。責務分離は以下の通り:

observer projections
    ↓
retrospective-evaluator(schema-constrained judgment-only output)
    ↓
deterministic enrichment / canonical assembly(100% Python)
    ↓
canonical validate_candidate()
    ↓
PublishRequest

evaluator が authority を持つフィールド(judgment-only wire contract)

evaluator の構造化出力(--json-schema で拘束)は、各 candidate record について以下のみを要求する:

  • candidate_id(lifecycle 識別子。evaluator が生成してよいが Python が形式検証する)
  • title, description
  • claim_class
  • subject_ref(kind/value。canonical schema の discriminated union・pattern 制約と同一の制約を wire schema 側にも実装する。draft-07 で自前 author する。$ref で canonical schema を跨いで参照しない — canonical schema は draft 2020-12 であり Agent SDK の --json-schema は draft-07 のみ受理する)
  • rule_id(namespaced dot-separated token。pattern ^[a-z0-9_]+(\.[a-z0-9_]+)*$ を wire schema 側にも実装する)
  • evidence_refs[] のうち、evaluator が実際に observer 出力から参照できる部分(ref_type・source_id 等、実在する observer evidence を指す情報)。projection_digest は evaluator に要求しない(下記参照)
  • 意味判断として真に evaluator-authoritative な最小限の evaluation judgment フィールド(後述の Authority Matrix 参照。evaluation_status/presence_delta/delta_status/indeterminate_reason/previous_evaluation_ref は要求しない — Python が compute_delta()/PreviousStateProvider から 100% 決定論的に構築する)

evaluator には identity.key/identity.value/repository_id/source_run_ref/created_at/updated_at/evaluations[](history 全体)を一切要求しない。プロンプトの placeholder({"...": "..."} 等)を撤去し、要求するフィールドのみを具体例付きで明示する。

Python が 100% 決定論的に構築するフィールド

  • identity.key(repository_id・evaluator judgment の claim_class/subject_ref/rule_id から構築。不正な subject_ref/rule_id は合成せず candidate_schema_invalid として fail-closed のまま維持する — PR feat: agent-retrospective evaluator に identity.value 決定論的算出の deterministic enrichment phase を追加する #2367 fix_delta items 1-6 の fail-closed 方針をそのまま維持する)
  • identity.value(compute_finding_identity() を sibling module loader 経由で呼び出す。既存実装のまま変更しない)
  • source_run_ref・created_at・updated_at(既存実装のまま変更しない)
  • evaluations[](evaluator の wire payload から一切パースしない。compute_delta()/PreviousStateProvider の出力から Python が直接構築する。valid indeterminate entry(delta_status 不在)・valid classified entry・複数 entry の history chain のいずれも、evaluator 出力に依存せず正しく構築・保存される)
  • evidence_refs[].projection_digest(evaluator が参照した実在する evidence(observer 出力に含まれる実データ)から Python が再計算する。実データが利用不能な場合は digest を捏造せず、該当 evidence entry を含めない、または candidate 全体を candidate_schema_invalid として fail させる。壊れた文字列の repr() をハッシュ化するような偽装は禁止のまま維持する)

evaluator が誤って identity/evaluations/repository_id 等を出力に含めても、wire schema の additionalProperties: false(または同等の拒否)で構造的に弾かれるか、Python enrichment 側で無視される(無条件上書きではなく、そもそも wire contract に存在しないフィールドとして扱う)。

Identity/Deterministic Field Authority Matrix(改訂版)

Field Authority
candidate_id evaluator が生成(lifecycle 識別子。Python は形式検証のみ)
title, description evaluator judgment
claim_class evaluator judgment
subject_ref, rule_id evaluator judgment(不正値は fail-closed。Python は合成しない)
repository_id run_cli() / execute_run() caller context(EvaluatorRequest には追加しない)
source_run_ref.base_sha RunContext.base_sha
source_run_ref.source_set_digest authoritative evaluator request / plan
identity.algorithm canonical validator 定数(sha256-jcs-v1)
identity.value compute_finding_identity()(canonical SSOT)の算出結果
created_at, updated_at injected run timestamp
evaluations[].evaluation_id, classified_at, classifier_version Python 決定論的生成(evaluator 出力から取得しない)
evaluations[].evaluated_run_ref source_run_ref と同一の Python-authoritative context
evaluations[].previous_evaluation_ref Python が history chain から決定論的に構築(compute_delta() の出力)
evaluations[].observed, source_coverage, evaluation_status, presence_delta, signal_delta, delta_status, indeterminate_reason, baseline_signal/current_signal/expected_signal Python が compute_delta()/PreviousStateProvider の実データから決定論的に構築する(evaluator wire payload から一切パースしない。Python が model judgment を別の意味へ変換すること — 例: indeterminate を classified/new に書き換えること — は禁止)
evidence_refs[].ref_type, source_id evaluator judgment(observer 出力に実在する evidence を参照する場合のみ)
evidence_refs[].resource_identity evaluator が参照した実在するリソースの記述(捏造禁止。実在しない runtime_receipt を作らない)
evidence_refs[].projection_digest Python が実データから再計算(evaluator 供給値は信用しない。再計算不能なら fail-closed)
evaluator が誤って出力した identity/evaluations/repository_id/source_run_ref/created_at/updated_at wire schema レベルで構造的に拒否されるか無視される(無条件上書きではなく「そもそも wire contract に存在しないフィールド」として扱う)

Runtime Verification Applicability

runtime_verification_applicability:
  decision: immediate
  reason: "judgment-only wire contract への変更が実際に evaluator の実出力の vocabulary drift を解消し、evaluator 経由の non-empty finding が実 CLI 実行で candidate_schema_invalid を出さないことは、静的検証(型検査・lint・fixture-only unit test)だけでは保証できないため。"
  applicable_acs: [AC5]
  execution_environment: "claude binary が PATH 上にあり claude auth status が成功する Linux/WSL repository checkout(run_retrospective.py --state-backend fixture 実行可能な環境)"
  skip_conditions: "claude binary が PATH に見つからない、または claude auth status が非0で終了する(#2301 の verify_run_retrospective_live_cli.sh と同じ2条件)"
  fallback_policy: "SKIP は PASS に変換しない。fallback / synthetic canonical record 経由の成功は FAIL として扱う。"
  artifact_requirements: "verify_run_evaluation_enrichment_live_cli.sh の実行ログ(3 observers → evaluator → canonical candidate → PublishRequest 到達を示す stdout/stderr 抜粋、artifacts/2362/ 配下)"

In Scope

  • .claude/skills/agent-retrospective/scripts/schemas/evaluation_result_v1.schema.json の candidate_records[].items を、evaluator-authoritative フィールドのみを要求する judgment-only shape に絞り込む(draft-07 で自前 author。canonical schema への $ref 越境はしない。identity/evaluations/repository_id/source_run_ref/created_at/updated_at は wire schema に含めない)
  • .claude/agents/retrospective-evaluator.md の system prompt を、新しい judgment-only wire contract に一致させて改訂する(tools: [] は維持。placeholder JSON を撤去し、要求するフィールドの具体例を提示する)
  • run_retrospective.py の _enrich_candidate_record() を、evaluations[] を evaluator wire payload から一切パースせず compute_delta()/PreviousStateProvider の出力から Python が直接構築するように変更する(PR feat: agent-retrospective evaluator に identity.value 決定論的算出の deterministic enrichment phase を追加する #2367 fix_delta items 1-6 で確立した fail-closed 方針は維持: 不正な subject_ref/rule_id の合成は行わず candidate_schema_invalid を維持する)
  • evidence_refs[].projection_digest を実データ(observer 出力に含まれる実際の evidence projection)から Python が再計算するロジックを実装する。再計算不能な場合は捏造せず fail-closed にする
  • evaluation_result_v1 schema の互換性方針を確定する: 既存 consumer(run_retrospective.py・test_run_retrospective.py・test_run_retrospective_identity_binding.py・test_security_boundary.py・references/wire-contract.md)の inventory を取り、additive tightening(v1 のまま)で対応可能かを実装前に確認する。対応不能と判明した場合は Stop Conditions に従い報告する(version bump/field rename を独断で行わない)
  • AC3(旧 AC3 相当。番号は AC5 に振り直し)の live test を、nonce-tagged candidate の finding_contract/identity/semantic judgment フィールドを厳密に assert する形に維持・強化する(既存 PR feat: agent-retrospective evaluator に identity.value 決定論的算出の deterministic enrichment phase を追加する #2367 fix_delta item 5 の assertion を土台にする)
  • 上記変更に対応する .claude/skills/agent-retrospective/scripts/tests/ 配下のユニットテスト追加・更新(PR feat: agent-retrospective evaluator に identity.value 決定論的算出の deterministic enrichment phase を追加する #2367 の worktree に既にある items 1-6 の回帰テストは維持し、拡張する)
  • PR feat: agent-retrospective evaluator に identity.value 決定論的算出の deterministic enrichment phase を追加する #2367 の未commit変更(items 1-6)を破棄せず、そのまま維持・拡張する

Out of Scope

Acceptance Criteria

  • AC1: .claude/skills/agent-retrospective/scripts/schemas/evaluation_result_v1.schema.json の candidate_records[].items が、evaluator-authoritative フィールド(candidate_id/title/description/claim_class/subject_ref/rule_id/evidence_refs のうち evaluator 参照可能な部分)のみを要求する judgment-only shape に改訂されており、draft-07 として valid であり、identity/evaluations/repository_id/source_run_ref/created_at/updated_at を要求・許容しない
  • AC2: retrospective-evaluator.md の system prompt が新しい judgment-only wire contract と一致しており、identity/evaluations の placeholder({"...": "..."} 等)を含まない
  • AC3: run_evaluation() の _enrich_candidate_record()(または後継関数)が evaluations[] を evaluator wire payload から一切パースせず、compute_delta()/PreviousStateProvider の出力から直接構築する。valid classified entry・valid indeterminate entry(delta_status 不在)・複数 entry の history chain のいずれも、evaluator 出力とは独立して正しく構築・保存されることをユニットテストで固定する
  • AC4: 不正な subject_ref/rule_id は合成されず candidate_schema_invalid として fail-closed になる(PR feat: agent-retrospective evaluator に identity.value 決定論的算出の deterministic enrichment phase を追加する #2367 fix_delta items 1/3 の既存契約を維持)。evidence_refs[].projection_digest は実データから再計算され、再計算不能な場合は捏造せず fail-closed になる
  • AC5: evaluator 経由の non-empty finding を含む実 CLI 実行(run_retrospective.py --state-backend fixture)で candidate_schema_invalid エラーが発生せず、3 observers → evaluator(judgment-only output)→ deterministic enrichment → canonical candidate → PublishRequest まで1回で到達する。verify_run_evaluation_enrichment_live_cli.sh は nonce-tagged candidate を特定し、finding_contract/identity.key.repository_id/identity.value(compute_finding_identity() の再計算結果と一致)/claim_class/subject_ref/rule_id が evaluator judgment と一致することを必須 assert する。SKIP は PASS に変換しない。fallback/synthetic canonical record 経由の成功は FAIL として扱う
  • AC6: 既存 evaluation_result_v1 schema の consumer(test_run_retrospective.py・test_run_retrospective_identity_binding.py・test_security_boundary.py・references/wire-contract.md を含む)が、additive tightening 後も matched fixture で正しく動作する(互換性が破れる場合は fixture を新契約に更新し、その旨を PR 本文で明示する)
  • AC7: 追加・更新したユニットテストが PASS する(PR feat: agent-retrospective evaluator に identity.value 決定論的算出の deterministic enrichment phase を追加する #2367 fix_delta で追加された items 1-6 の回帰テストを含め、新規 AC1-AC4 の回帰テストを追加する)

Verification Commands

# AC1
$ uv run --locked pytest .claude/skills/agent-retrospective/scripts/tests/test_deterministic_enrichment.py -k "wire_schema or judgment_only"
# AC2
$ uv run --locked pytest .claude/skills/agent-retrospective/scripts/tests/test_deterministic_enrichment.py -k "evaluator_prompt or prompt_contract"
# AC3
$ uv run --locked pytest .claude/skills/agent-retrospective/scripts/tests/test_deterministic_enrichment.py -k "evaluation_history or compute_delta"
# AC4
$ uv run --locked pytest .claude/skills/agent-retrospective/scripts/tests/test_deterministic_enrichment.py -k "fail_closed or projection_digest"
# AC5
# preflight-scope: runtime_only
$ .claude/skills/agent-retrospective/scripts/tests/verify_run_evaluation_enrichment_live_cli.sh
# AC6
$ uv run --locked pytest .claude/skills/agent-retrospective/scripts/tests/test_run_retrospective.py .claude/skills/agent-retrospective/scripts/tests/test_run_retrospective_identity_binding.py .claude/skills/agent-retrospective/scripts/tests/test_security_boundary.py
# AC7
$ uv run --locked pytest .claude/skills/agent-retrospective/scripts/tests/

(注: 上記 -k selector は実装時に実テスト関数名へ更新すること。selector 名自体は本 Issue の意図を示すガイドであり、実装が対応する具体的なテスト関数名で AC を満たしていれば selector 文字列の完全一致は必須としない。ただし各 AC に対応する具体的テストが存在し実行可能であることは必須。)

Allowed Paths

  • .claude/skills/agent-retrospective/scripts/run_retrospective.py
  • .claude/skills/agent-retrospective/scripts/schemas/evaluation_result_v1.schema.json
  • .claude/agents/retrospective-evaluator.md
  • .claude/skills/agent-retrospective/scripts/tests/
  • .claude/skills/agent-retrospective/references/wire-contract.md(記述更新のみ。契約自体の正本は schema/prompt/code)

Stop Conditions

  • 上記 Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合。ただし evaluation_result_v1 の additive tightening(candidate_records[].items の絞り込み)自体は本 Issue の In Scope であり、本条項の対象外とする。v2 bump またはフィールド rename(candidate_records → 別名)が真に必要と判明した場合は本条項に該当し停止する
  • agent_improvement_candidate_v1.schema.json(canonical schema)自体の変更が必要と判明した場合は 実装: agent-retrospective を optional plugin distribution として配布可能にする #2240 の Stop Condition と整合させ、この Issue 単独では変更しない
  • fallback / synthetic canonical record の再導入が必要に見える状況になった場合(そのように見える場合は実装を止めて報告する。捏造で回避しない)
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • identity/evaluation-history/evidence 以外の canonical candidate 制約で新たな schema 違反が露出し、対応範囲が本 Issue の Allowed Paths を超えると判明した場合

Required Skills

なし

Required Design References

  • .claude/skills/agent-retrospective/schemas/agent_improvement_candidate_v1.schema.json
  • .claude/skills/agent-retrospective/scripts/schemas/evaluation_result_v1.schema.json
  • .claude/agents/retrospective-evaluator.md
  • .claude/skills/agent-retrospective/references/wire-contract.md
  • docs/dev/agent-skill-boundaries.md
  • docs/dev/runtime-verification-policy.md

Scope Delta(任意)

承認済み scope reframe(2026-08-28、repository owner 承認):

Source

Activity

  1. added
    enhancement
    phase/implementation
    triage-required
    agent/implementer
    on Aug 27, 2026
  2. squne121 commented on Aug 27, 2026

    @squne121
    OwnerAuthor

    判定

    REQUEST_CHANGES / implementation_readiness: blocked / recommended_disposition: reframe_in_place です。

    Issue #2362 の着眼点自体は正しいです。むしろ #2240 より先に直すべき production blocker です。PR #2358 の実 Claude Code smoke では3 observer の substantive finding 生成までは成功した一方、run_cli() を evaluator まで通した2回の試行はいずれも、evaluator が finding_contract.identity.key に observer_id / run_id / claim 等を混入させて candidate_schema_invalid になっています。#2240 の OWNER review でも「repository_id を知らず SHA-256 を計算する道具もない LLM に canonical identity を完成させている」ことが根因として切り分けられています。

    ただし、現在の #2362 契約は解決方針は正しいものの、実装境界と検証契約がまだ曖昧です。このまま impl-review-loop に入れると、「grep/pytest は通ったが full run はまだ evaluator で落ちる」という false-green がかなりあり得ます。Issue 自身は runtime verification を immediate と宣言しているのに、その AC3 Verification Command が実 CLI ではなく unit pytest なのも明確な矛盾です。

    敵対的 findings

    Priority | Finding | 判定 -- | -- | -- P0 | AC3 が実 CLI 契約なのに Verification Command は pytest | blocker P0 | deterministic enrichment を挿入する正確な call-graph 境界が未定義 | blocker P1 | repository_id 等の authority/source が関数境界に存在しない | contract fix P1 | 「model judgment のみ」と現行 evaluator prompt が矛盾 | contract fix P1 | AC2 が canonical helper の「再利用」ではなく再実装でも通る | contract fix P1 | identity 以外の run-bound deterministic fields が AC で未検証 | contract fix P2 | AC1 の git grep compute_finding_identity は実装の正しさを証明しない | VC replacement P2 | live smoke は新ハーネスではなく既存経路の1回実行で十分 | simplify

    これを Issue に入れるだけで実装の迷いがかなり減ります。

    P1 — retrospective-evaluator.md を Out of Scope にするなら「無視する値」を明記する

    現在の evaluator system prompt は実際には LLM に、source_run_ref、created_at、updated_at、identity.key、identity.value を含む完成 canonical candidateを出すよう要求しています。しかも identity の例は key: {"...": "..."} です。

    したがって #2362 の「LLM output は model judgment 値のみ」という記述とは厳密には一致しません。

    ここは scope を広げて agent prompt を作り直す必要まではありません。個人開発として最小にするなら、

    evaluator が deterministic field を出力しても、それらは authority を持たず enrichment phase が必ず捨てて再構築する

    と契約化すれば十分です。

    将来的には evaluator の prompt 自体も judgment draft 専用に縮めた方がトークン効率・成功率は上がりますが、#2362 の blocker にしなくてよいと思います。

    P1 — compute_finding_identity() は「同一実装」ではなく直接再利用すべき

    既存 validate_retrospective_schema.py には canonical helper がすでに存在します。sha256-jcs-v1、非ASCII UTF-8、object property ordering、非有限数拒否まで既に規定され、PR #2289 では JCS 周辺の不整合を実際に修正した履歴があります。

    RFC 8785 自体も hashing/signing の再現性を得るため canonical representation を使うことを目的としており、ここで二つ目の「ほぼ同じ JCS」を書く利点はありません。(RFCエディタ)

    したがって AC2 は、

    run_retrospective.py は _validate_retrospective_schema_module().compute_finding_identity(identity_key) を canonical SSOT として直接呼び、JCS/SHA-256 implementation を複製しない

    まで強くしてよいです。

    現在 run_retrospective.py は既に sibling validator を lazy-load していますから、新しい依存関係すら増えません。

    P1 — identity を直せば本当に full candidate が通るかはまだ未証明

    canonical candidate の finding_contract.evaluations[] には evaluation_id、evaluated_run_ref、classified_at、signal群、coverage、evaluation status など多数の必須・相互整合条件があります。

    現在 evaluator は tools: [] で、CLI の外側 schema も nested candidate schema を渡していません。したがって identity を修正したら次に別の canonical constraint が露出する可能性はあります。これは今の段階で新 Issue を作る理由ではありません。

    実 CLI AC3 を本物に直せば、そのリスクを安価に検出できます。

    もし identity enrichment 後に別 field で落ちるなら、その時点で #2362 内で「run-bound field の deterministic enrichment」に含めるかを判断すればよいです。先回りして巨大な candidate builder を作る必要はありません。

    P2 — grep VC は削除してよい

    AC1 の

    git grep -n "compute_finding_identity" ...

    はコメントに名前を書くだけでも PASS します。#2288 自身も過去の refinement で「grep ベース VC は semantic AC を証明しない」と判断し、専用 pytest へ置き換えた履歴があります。

    #2362 も同じでよく、grep は不要です。

    推奨する #2362 の最小修正

    新しいセキュリティ層や CI harness を増やさず、次の5点だけ本文に反映すれば implementation-ready にできます。

    1. enrichment の順序を固定する: outer evaluator envelope parse → judgment allowlist extraction → deterministic overwrite → Evaluation construction/canonical validation。

    2. authority matrix を追加し、model が返した repository_id / identity.value / source_run_ref / timestamp は信用せず上書きすると明記する。

    3. AC2 を canonical helper の直接再利用にする。JCS/SHA-256 の再実装は禁止。

    4. AC3 を本当の live VC にする。既存 production path + --state-backend fixture で substantive non-empty finding → evaluator → canonical candidate → PublishRequest を1回確認。恒久 CI は不要。

    5. grep VC を削除し、unit test では「LLM が壊れた identity.key / fake identity.value を返しても authoritative 4-key identity に上書きされる」「同じ judgment + context なら identity が同一」「repository/rule/subject が変われば identity が変わる」を固定する。

    #2362 には現在コメントがなく、実装 PR もまだ前提化されていない段階なので、今ここで reframe するコストは非常に低いです。コメント欄も現時点では空です。

    総じて、Issue の存在と基本設計は採用でよいが、現状の AC/VC のまま実装開始は反対です。修正は小さく、特に security/permission machinery を増築する必要はありません。狙うべきは「LLM に deterministic bookkeeping をさせない」「一度だけ本物の production run で価値経路を通す」の2点です。

    ## 判定

    REQUEST_CHANGES / implementation_readiness: blocked / recommended_disposition: reframe_in_place です。

    Issue #2362 の着眼点自体は正しいです。むしろ #2240 より先に直すべき production blocker です。PR #2358 の実 Claude Code smoke では3 observer の substantive finding 生成までは成功した一方、run_cli() を evaluator まで通した2回の試行はいずれも、evaluator が finding_contract.identity.key に observer_id / run_id / claim 等を混入させて candidate_schema_invalid になっています。#2240 の OWNER review でも「repository_id を知らず SHA-256 を計算する道具もない LLM に canonical identity を完成させている」ことが根因として切り分けられています。

    ただし、現在の #2362 契約は解決方針は正しいものの、実装境界と検証契約がまだ曖昧です。このまま impl-review-loop に入れると、「grep/pytest は通ったが full run はまだ evaluator で落ちる」という false-green がかなりあり得ます。Issue 自身は runtime verification を immediate と宣言しているのに、その AC3 Verification Command が実 CLI ではなく unit pytest なのも明確な矛盾です。

    敵対的 findings

    Priority Finding 判定
    P0 AC3 が実 CLI 契約なのに Verification Command は pytest blocker
    P0 deterministic enrichment を挿入する正確な call-graph 境界が未定義 blocker
    P1 repository_id 等の authority/source が関数境界に存在しない contract fix
    P1 「model judgment のみ」と現行 evaluator prompt が矛盾 contract fix
    P1 AC2 が canonical helper の「再利用」ではなく再実装でも通る contract fix
    P1 identity 以外の run-bound deterministic fields が AC で未検証 contract fix
    P2 AC1 の git grep compute_finding_identity は実装の正しさを証明しない VC replacement
    P2 live smoke は新ハーネスではなく既存経路の1回実行で十分 simplify

    P0 — enrichment は現在の run_evaluation() に単純挿入できない

    現行コードは evaluator の structured_output を受け取った直後、

    structured_output
      → parse_agent_output_with_repair(..., Evaluation)
      → Evaluation.__post_validate()
      → _validate_candidate_records()
      → canonical validate_candidate()
    

    という順に進みます。つまり Evaluation を構築した時点ですでに candidate validation が走るので、「validation に失敗した後で identity を補完する」ことはできません。現在の run_evaluation() が実際にこの順序であることも確認できます。

    一方、Claude CLI に渡している evaluation_result_v1.schema.json は、意図的に candidate_records[] を単なる object としか規定せず、canonical candidate validation は Python 側に委譲しています。したがって schema 変更なしで、

    Claude structured_output
      → outer Evaluation envelope の shape validation
      → candidate draft の judgment field 抽出
      → deterministic enrichment
      → Evaluation 構築
      → canonical candidate validation
    

    と分離する余地はあります。

    AC1 はこの順序まで固定すべきです。 「validator の前に enrichment」とだけ書くより、Evaluation construction 自体が canonical validation boundary であることを明記した方が実装者が誤りません。

    P0 — AC3 は実 CLI に直すべき

    Issue は Outcome、Runtime Verification Applicability、AC3 の全部で「evaluator 経由 non-empty finding の実 CLI 成功」を要求しています。それなのに VC は、

    uv run --locked pytest ... -k test_run_evaluation_deterministic_enrichment_success

    です。これは fake evaluator が canonical draft を返せば簡単に緑になります。

    ここは新しい Claude-live CI や恒久ハーネスを作る必要はありません。PR #2358 と同じ考え方で、merge 前に一度だけ run_retrospective.py --state-backend fixture の production call graph を実 Claude Code で通し、

    3 observers → evaluator → non-empty canonical candidate → PublishRequest

    まで到達したログを PR 本文に残せば十分です。Claude Code 公式も claude -p --output-format json --json-schema ... の structured_output を programmatic surface として定義しています。(Claude)

    しかも最近の Claude Code では、headless --json-schema で schema-valid な placeholder に退化する報告や、特に toolless structured-output 呼び出しで placeholder key が出る報告があります。retrospective-evaluator はまさに tools: [] なので、unit test だけで終わらせない理由として十分です。ただしこれは upstream issue の観測であり、#2362 に新たな防御ハーネスを持ち込む理由にはしなくてよいです。([GitHub]2)

    P1 — authority matrix を Issue に入れた方がよい

    現在の EvaluatorRequest が持つのは run_id/base_sha/source_set_digest/finding_sets だけで、repository_id は持ちません。repository_id は run_cli() / execute_run() の一段外側には既に存在していますが、現在 run_evaluation() には渡されていません。

    私は EvaluatorRequest に repository_id を足すのには反対です。LLM が知る必要がない deterministic context を model input に増やすだけです。代わりに Python の enrichment context として明確に分けるのがよいです。

    Field Authority
    title, description evaluator judgment
    claim_class evaluator judgment
    subject_ref, rule_id evaluator judgment
    repository_id run_cli() caller context
    source_run_ref.base_sha RunContext.base_sha
    source_run_ref.source_set_digest authoritative evaluator request / plan
    identity.algorithm canonical validator constant
    identity.value canonical compute_finding_identity()
    created_at, updated_at injected run timestamp
    model が出した repository_id/value/source_run_ref/timestamp ignore / overwrite

    これを Issue に入れるだけで実装の迷いがかなり減ります。

    P1 — retrospective-evaluator.md を Out of Scope にするなら「無視する値」を明記する

    現在の evaluator system prompt は実際には LLM に、source_run_ref、created_at、updated_at、identity.key、identity.value を含む完成 canonical candidateを出すよう要求しています。しかも identity の例は key: {"...": "..."} です。

    したがって #2362 の「LLM output は model judgment 値のみ」という記述とは厳密には一致しません。

    ここは scope を広げて agent prompt を作り直す必要まではありません。個人開発として最小にするなら、

    evaluator が deterministic field を出力しても、それらは authority を持たず enrichment phase が必ず捨てて再構築する

    と契約化すれば十分です。

    将来的には evaluator の prompt 自体も judgment draft 専用に縮めた方がトークン効率・成功率は上がりますが、#2362 の blocker にしなくてよいと思います。

    P1 — compute_finding_identity() は「同一実装」ではなく直接再利用すべき

    既存 validate_retrospective_schema.py には canonical helper がすでに存在します。sha256-jcs-v1、非ASCII UTF-8、object property ordering、非有限数拒否まで既に規定され、PR #2289 では JCS 周辺の不整合を実際に修正した履歴があります。

    RFC 8785 自体も hashing/signing の再現性を得るため canonical representation を使うことを目的としており、ここで二つ目の「ほぼ同じ JCS」を書く利点はありません。([RFCエディタ]3)

    したがって AC2 は、

    run_retrospective.py は _validate_retrospective_schema_module().compute_finding_identity(identity_key) を canonical SSOT として直接呼び、JCS/SHA-256 implementation を複製しない

    まで強くしてよいです。

    現在 run_retrospective.py は既に sibling validator を lazy-load していますから、新しい依存関係すら増えません。

    P1 — identity を直せば本当に full candidate が通るかはまだ未証明

    canonical candidate の finding_contract.evaluations[] には evaluation_id、evaluated_run_ref、classified_at、signal群、coverage、evaluation status など多数の必須・相互整合条件があります。

    現在 evaluator は tools: [] で、CLI の外側 schema も nested candidate schema を渡していません。したがって identity を修正したら次に別の canonical constraint が露出する可能性はあります。これは今の段階で新 Issue を作る理由ではありません。

    実 CLI AC3 を本物に直せば、そのリスクを安価に検出できます。

    もし identity enrichment 後に別 field で落ちるなら、その時点で #2362 内で「run-bound field の deterministic enrichment」に含めるかを判断すればよいです。先回りして巨大な candidate builder を作る必要はありません。

    P2 — grep VC は削除してよい

    AC1 の

    git grep -n "compute_finding_identity" ...

    はコメントに名前を書くだけでも PASS します。#2288 自身も過去の refinement で「grep ベース VC は semantic AC を証明しない」と判断し、専用 pytest へ置き換えた履歴があります。

    #2362 も同じでよく、grep は不要です。

    推奨する #2362 の最小修正

    新しいセキュリティ層や CI harness を増やさず、次の5点だけ本文に反映すれば implementation-ready にできます。

    1. enrichment の順序を固定する: outer evaluator envelope parse → judgment allowlist extraction → deterministic overwrite → Evaluation construction/canonical validation。
    2. authority matrix を追加し、model が返した repository_id / identity.value / source_run_ref / timestamp は信用せず上書きすると明記する。
    3. AC2 を canonical helper の直接再利用にする。JCS/SHA-256 の再実装は禁止。
    4. AC3 を本当の live VC にする。既存 production path + --state-backend fixture で substantive non-empty finding → evaluator → canonical candidate → PublishRequest を1回確認。恒久 CI は不要。
    5. grep VC を削除し、unit test では「LLM が壊れた identity.key / fake identity.value を返しても authoritative 4-key identity に上書きされる」「同じ judgment + context なら identity が同一」「repository/rule/subject が変われば identity が変わる」を固定する。

    #2362 には現在コメントがなく、実装 PR もまだ前提化されていない段階なので、今ここで reframe するコストは非常に低いです。コメント欄も現時点では空です。

    総じて、Issue の存在と基本設計は採用でよいが、現状の AC/VC のまま実装開始は反対です。修正は小さく、特に security/permission machinery を増築する必要はありません。狙うべきは「LLM に deterministic bookkeeping をさせない」「一度だけ本物の production run で価値経路を通す」の2点です。

  3. squne121 commented on Aug 27, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop: approved

    anchor comment(OWNER, #2362 (comment) 、REQUEST_CHANGES / implementation_readiness: blocked / recommended_disposition: reframe_in_place)を受け、本文を全面改訂しました。

    実施内容

    1. 投稿された技術的主張の検証(codebase-investigator): OWNERコメントの6件の技術的主張(validation timing・schema delegation・sibling validator・EvaluatorRequest構造・evaluator prompt・grep VCの限界)はすべて repository 実態で confirmed(1件のみ partially confirmed)。
    2. 決定論的レビュー(review-issue / check_issue_contract.py): 初回 needs-fix(10 blockers: Runtime Verification Applicability 必須フィールド欠落、decision-tag 不整合、git grep allowlist 違反、pytest exit5 等)→ rewrite → VERDICT: approve。
    3. セマンティック設計レビュー(issue-design-reviewer, Step 2.5, 2周): 1周目で4件の設計上の懸念(blocker: AC3 VC が claude_live マーカーの pytest addopts デフォルト除外で骨抜きになる懸念/high: outer envelope parse の smuggled-key scan 維持が未記載/medium: run_evaluation() への repository_id/clock 注入という signature 変更が未記載/low: 複数 candidate_records の独立性契約欠落)を検出 → rewrite → 2周目で assessment: clear(findings: 0)。

    最終状態

    • REVIEWED_BODY_SHA256: sha256:266a2db343b179579e6c29e0de26911824e4f833928e721cd78deed2f0eb67c8
    • deterministic checker: VERDICT: approve / BLOCKERS: 0
    • semantic design review: assessment: clear / findings: 0
    • baseline_vc_preflight: AC1/AC2/AC4 = expected_baseline_fail/go、AC3 = preflight_scope_runtime_only/go、errors: []

    Next Action

    Issue は実装着手可能な状態です。実装ループ(impl-review-loop)の起動は本 refinement loop のスコープ外のため、必要であれば別途起動してください。

  4. self-assigned this
    on Aug 27, 2026
  5. squne121 commented on Aug 27, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-08-28)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent/implementerenhancementphase/implementationtriage-required

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions