Skip to content

実装: schemas/catalog.yaml と schema-consistency CI を導入し機械可読な schema カタログ管理を確立する #166

Open

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#131"
goal_ref: "schema 変更 PR で consumer 未更新を機械的に検出する手順を確立する(machine-readable catalog フェーズ)"
change_kind: workflow

Parent Issue

#131

Parent Goal Ref

Current Validated Scope

Issue #135 の Out of Scope に「schemas/catalog.yaml と schema-consistency CI の実装は follow-up Issue とする」と明記されている。#135 完了後に行う次フェーズとして、以下を実施する:

  • schemas/catalog.yaml で schema_id / producer / consumer / detection_patterns / validation_commands を機械可読化
  • scripts/check_schema_catalog.py でカタログ整合性を検証(catalog 参照ファイル存在確認・schema_id 重複確認・consumer pattern ヒット確認)
  • .github/workflows/schema-consistency.yml で schemas/**, .claude/**, docs/dev/schema-governance.md 変更時に自動検証

Remaining Parent Gaps

Outcome

schemas/catalog.yaml に初期 schema 6 件以上のエントリが記載され、scripts/check_schema_catalog.py --dry-run が全エントリの detection_patterns ヒット確認を実行し、.github/workflows/schema-consistency.yml が schema 関連ファイル変更 PR で自動実行される状態で test -f schemas/catalog.yaml が PASS している。

Background

Issue #135 では PR/レビュー運用として Schema Consumer Inventory を導入し、docs/dev に schema 定義と初期 schema list を記載する。しかし #135 の rg ベースの consumer 検出は以下を見落とす可能性がある:

  • jq のネスト参照変更
  • Python dict literal の key 参照
  • テスト fixture 内の古い JSON
  • schema 文字列を直接参照しない構造アクセス(transport_details.failure_class 等)

machine-readable な catalog + validation command + CI check で補完し、将来の schema 増加(ゲームデータ / save data / asset manifest)にも拡張可能な基盤を作る。

参照: PR #81(downstream-contract 破壊の発生源)、Issue #135(前フェーズ)、anchor_comment issuecomment-4508510881

Schema Definition

本 Issue でいう schema は、producer と consumer の境界を越えて parse / validate / serialize される machine-readable contract を指す(Issue #135 と同定義)。

Initial Known Schemas(catalog 初期エントリ対象)

Schema ID Producer Consumers
delegation_request_v1 .claude/skills/gemini-cli-headless-delegation/SKILL.md run_gemini_headless.py::validate_request()
delegation_result/v1 run_gemini_headless.py::_normalize_acp_result() verify_acp_roundtrip.sh, test_acp_transport.py
acp_result_v1 run_gemini_acp.py _normalize_acp_result()
TEST_VERDICT_MACHINE v1 test-runner SubAgent pr-review-judge, impl-review-loop
LOOP_VERDICT pr-review-judge impl-review-loop
model_routing.yaml maintainer run_gemini_headless.py, test_model_routing.py

In Scope

  • schemas/catalog.yaml を新規作成し、上記 6 件の初期エントリを schema_id / kind / format / status / owner / producers / consumers / detection_patterns / validation_commands / compatibility_policy キーで記載する
  • scripts/check_schema_catalog.py を新規作成し、以下を実装する:
    • catalog の参照ファイル存在確認(producers / consumers の実ファイルが存在するか)
    • schema_id 重複確認
    • detection_patterns のコードベースへの最低ヒット確認(0 ヒットは警告として記録)
    • --dry-run モードで YAML / JSON 構造化結果を stdout に出力
    • scripts/CLAUDE.md の制約に従い、Python stdlib + PyYAML(uv 環境、既存利用実績あり)を使用
  • .github/workflows/schema-consistency.yml を新規作成し、以下を設定する:
    • on: push/pull_request + paths: ['schemas/**', '.claude/**', 'docs/dev/schema-governance.md'] で限定トリガー
    • uv run python3 scripts/check_schema_catalog.py を実行
    • 検証失敗時に CI を落とす

Out of Scope

  • ゲームデータ(save data / asset manifest / entity 定義)の JSON Schema / Zod schema 導入
  • schemas/catalog.yaml を JSON Schema formal definition に移行すること
  • Ajv standalone / Zod による runtime validation の実装
  • schema バージョニング体系(SemVer 的 compatibility policy の詳細設計)
  • verify_acp_roundtrip.sh の修正

Acceptance Criteria

  • AC1: schemas/catalog.yaml が存在し、上記 Initial Known Schemas 6 件以上のエントリが schema_id / kind / format / status / owner / producers / consumers / detection_patterns / validation_commands キーを持って記載されている
  • AC2: scripts/check_schema_catalog.py が存在し、--dry-run オプションで catalog の参照ファイル存在確認・schema_id 重複確認・detection_patterns コードベースヒット確認を実行して YAML / JSON 形式の結果を stdout に出力する
  • AC3: .github/workflows/schema-consistency.yml が存在し、schemas/** / .claude/** / docs/dev/schema-governance.md の変更をトリガーに scripts/check_schema_catalog.py を実行する設定が記述されている
  • AC4: scripts/check_schema_catalog.py --dry-run が全エントリに対して実行でき、detection_patterns のヒット結果を含む構造化出力を返す

Verification Commands

# AC1: schemas/catalog.yaml が存在し 6 件以上のエントリを持つ
$ test -f schemas/catalog.yaml && echo "PASS: file exists" || echo "FAIL: file missing"
$ uv run python3 -c "import yaml; c=yaml.safe_load(open('schemas/catalog.yaml')); entries=c.get('schemas',[]); print(f'entries: {len(entries)}'); assert len(entries) >= 6, 'FAIL: < 6 entries'"

# AC2: scripts/check_schema_catalog.py が存在する
$ test -f scripts/check_schema_catalog.py && echo "PASS: file exists" || echo "FAIL: file missing"

# AC3: .github/workflows/schema-consistency.yml が存在し schemas/** トリガーが記述されている
$ test -f .github/workflows/schema-consistency.yml && echo "PASS: file exists" || echo "FAIL: file missing"
$ rg "schemas/\*\*" .github/workflows/schema-consistency.yml && echo "PASS: trigger found" || echo "FAIL: trigger missing"

# AC4: --dry-run で構造化出力が返る
$ uv run python3 scripts/check_schema_catalog.py --dry-run

# 品質ゲート
$ pnpm typecheck && pnpm lint && pnpm test && pnpm build

Allowed Paths

  • schemas/catalog.yaml
  • scripts/check_schema_catalog.py
  • .github/workflows/schema-consistency.yml

Runtime Verification Applicability

decision: not_applicable
reason: >
  本 Issue の変更対象はすべて静的ファイル(YAML catalog / Python script / CI workflow)の新規作成のみ。
  AC1〜AC4 はすべて `test -f` / `uv run python3 -c` / `rg` による静的コンテンツ確認であり、
  ゲームランタイムやサービス起動を必要としない。

Stop Conditions

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

Required Skills

  • Python(stdlib + PyYAML)
  • GitHub Actions workflow 構文

Scope Delta(任意)

N/A

Delivery Rule

1 Issue = 1 PR。Draft PR で開始し、全 AC の VC が PASS したらレビュー依頼する。Depends on #135 merge。

Activity

  1. added
    enhancement
    phase/implementation
    state/queued
    agent/implementer
    on May 21, 2026
  2. squne121 commented on May 21, 2026

    @squne121
    OwnerAuthor

    create-issue transaction partial-failure

    Issue: #166
    Failure stage: label-readback
    Message: label read-back mismatch

    Requested:

    Failure context:
    matching_issue_numbers=[166]
    issue_number=166

    Recovery hint: label-readback failed for #166.
    Manual re-apply command (idempotent: yes):
    gh issue edit 166 --repo squne121/loop-protocol --add-label
    Verify:
    gh issue view 166 --repo squne121/loop-protocol --json labels

    Please recover deterministically before re-running the create issue transaction.

  3. added
    state/blocked
    on May 21, 2026
  4. squne121 commented on May 21, 2026

    @squne121
    OwnerAuthor

    Blocked by #135 — #135 の実装完了後に着手する。

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/implementationstate/blockedstate/queued

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions