Skip to content

実装: agent-retrospective に Latitude CLI runtime evidence enrichment を追加する #2375

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "agent-retrospective が Latitude CLI の利用可能な runtime evidence を public-safe かつ予算上限付きで決定論的に enrichment できるようにする"
change_kind: mixed

Parent Issue

none

Parent Goal Ref

Current Validated Scope

Remaining Parent Gaps

Background

#1153 は Latitude trace を private observation plane に保持し、GitHub には public-safe summary と opaque evidence reference だけを投稿することを固定している。#1223 は agent_run_report/v1 向けの observation-source adapter を実装済みだが、agent-retrospective 自身には Latitude CLI から runtime evidence を bounded に取得して finding evaluation へ反映する専用経路がない。#1939 の日次 retrospective は provider telemetry を完了 gate にしないため、Latitude が unavailable でも retrospective の実行を妨げず、availability を明示した evidence として扱う必要がある。

Outcome

agent-retrospective に latitude_runtime_evidence/v1 の validator、bounded collector、deterministic enrichment とテストが追加され、Latitude CLI が利用可能なときは public-safe evidence reference と allowlisted metrics を finding evaluation に結合し、利用不能・不正・予算超過時は raw payload を出さず明示的な unavailable/error evidence に縮退する状態。

Design

  • CLI collector は private input を process memory 内で allowlist projection に変換し、raw JSON、trace body、prompt、tool I/O、command output 全文、absolute path、credential を retrospective run、finding、fixture、log、GitHub artifact に永続化しない。
  • latitude_runtime_evidence/v1 は collector の唯一の公開可能な出力契約とし、collector result をそのまま任意 JSON として受理しない。
  • deterministic enrichment は validated evidence の stable identity と availability を finding input に加えるだけで、Latitude evidence の欠落を supported/verified/positive finding へ昇格させない。
  • CLI failure、timeout、malformed output、schema violation、forbidden field 検出、collection-budget 超過は fail-closed な evidence result に正規化する。retrospective 全体を false-green にせず、provider unavailable が単独で既存 retrospective を中断させることもない。

CLI Boundary

  • Latitude CLI は read-only evidence collection のみを許可する。workspace/configuration/trace の作成、更新、削除、export、credential login/logout、remote state mutation を禁止する。
  • collector は allowlisted command shape のみを argv 配列で起動し、shell、eval、stdin prompt、任意 subcommand、任意 path、環境変数値のログ出力を使用しない。
  • executable 不在、認証不足、network unavailable、non-zero exit、timeout は availability: unavailable または closed error code として表現し、raw stderr/stdout は捨てる。
  • real CLI verification は opt-in とし、credential の表示・保存・GitHub への送信を行わない。unavailable 時は pytest 経由の SKIP(pytest.skip()、stdout に SKIP: prefix)と evidence artifact を残す。

Binding Rules

  • latitude_runtime_evidence/v1 が available の場合だけ、allowlisted metrics と opaque evidence_ref を finding evaluation に bind できる。
  • evidence identity は canonical public projection から決定論的に算出し、raw trace ID、raw payload、local absolute path を identity/digest input に含めない。
  • 同一 retrospective run 内の evidence は最大 1 件とし、duplicate、unknown schema version、unknown field、forbidden field、identity mismatch は fail closed とする。
  • unavailable/error evidence は evidence_ref と metric を null にし、finding の claim class、status、confidence を positive 側へ変更しない。
  • latitude_otlp は private provenance としてのみ扱い、既存 実装: observation-source adapter を allowlist projection で agent_run_report/v1 に接続する #1223 の public source_kind enum を変更しない。

latitude_runtime_evidence/v1

schema_version: latitude_runtime_evidence/v1
availability: available | unavailable | error
collected_at: RFC3339 UTC timestamp
collector_version: non-empty string
evidence_identity: sha256 public-projection identity | null
evidence_ref: opaque non-secret reference | null
metrics:
  trace_count: integer | null
  span_count: integer | null
  duration_ms: integer | null
reason_code: closed non-free-form code | null

available は non-null evidence_identity、evidence_ref、allowlisted metrics を要求する。unavailable と error は metrics/evidence fields をすべて null にし、closed reason_code を要求する。上記以外の key、raw textual payload、prompt、message、tool、authorization、token、secret、path を拒否する。

Collection Budget

  • 1 retrospective run あたり Latitude CLI 起動は最大 1 回。
  • collector timeout は 10 秒以下、captured output は 64 KiB 以下、allowlisted projected metric は 3 個以下とする。
  • pagination、trace content export、retry loop、background polling、network retry は行わない。
  • budget 超過は reason code を伴う unavailable/error result に正規化し、partial raw output を保持しない。

In Scope

  • agent-retrospective に latitude_runtime_evidence/v1 schema/validation、bounded CLI collector、deterministic enrichment binding を追加する。
  • fake CLI を使う unit/integration tests、public-safety negative fixtures、CLI unavailable/timeout/malformed/budget-exceeded tests を追加する。
  • runtime verification script と skill/reference documentation に CLI boundary、collection budget、pytest 経由の SKIP/FAIL semantics を記録する。

Acceptance Criteria

  • AC1: latitude_runtime_evidence/v1 validator は closed key set、availability 別 nullability、closed reason code、canonical public identity を強制し、unknown/forbidden/raw field を fail closed する。
  • AC2: collector は allowlisted argv の Latitude CLI を最大 1 回だけ起動し、10 秒/64 KiB/3 metrics の Collection Budget を超える結果を raw output なしで unavailable/error evidence に正規化する。
  • AC3: available evidence だけが deterministic enrichment に bind され、unavailable/error/invalid/duplicate evidence は finding を positive claim/status/confidence に昇格させない。
  • AC4: raw trace、prompt、message、tool I/O、stdout/stderr 全文、authorization、token、secret、absolute local path が schema output、retrospective result、fixture、log に混入すると validator/test が fail closed する。
  • AC5: existing agent_run_report/v1 public source_kind enum を変更せず、latitude_otlp を public source_kind として出力しない。
  • AC6: available Latitude CLI に対する opt-in runtime verification(pytest 経由)は public-safe artifact を生成して成功する。CLI/auth/network が unavailable のときは artifact を残して pytest.skip() による SKIP、予期しない runtime failure は assertion による FAIL で終了する。

Verification Commands

# AC1
$ uv run --locked pytest .claude/skills/agent-retrospective/scripts/tests/test_latitude_runtime_evidence.py

# AC2
$ uv run --locked pytest .claude/skills/agent-retrospective/scripts/tests/test_latitude_runtime_evidence.py

# AC3
$ uv run --locked pytest .claude/skills/agent-retrospective/scripts/tests/test_run_retrospective.py

# AC4
$ uv run --locked pytest .claude/skills/agent-retrospective/scripts/tests/test_public_safe_evidence_refs.py

# AC5
$ uv run --locked pytest .claude/skills/agent-retrospective/scripts/tests/test_latitude_runtime_evidence.py

# AC6
$ uv run --locked pytest .claude/skills/agent-retrospective/scripts/tests/verify_latitude_runtime_evidence_live_cli.py

Runtime Verification Applicability

decision: immediate
reason: "AC6 は実際の Latitude CLI process、authentication/network availability、および public-safe artifact を検証対象とする。"
applicable_acs:
  - AC6
execution_environment:
  cli_tools:
    - python3
    - uv
    - latitude
  auth_required: true
  network_required: true
skip_conditions:
  - "Latitude CLI 実行ファイルが見つからない場合は SKIP とし FAIL に変換しない"
  - "Latitude 認証情報または network が利用不能な場合は SKIP とし FAIL に変換しない"
fallback_policy:
  fallback_success_is_pass: false
  notes: "CLI/認証/ネットワーク unavailable 時に fallback 経由の成功を PASS に変換しない。SKIP を維持し、public-safe artifact を保存する。"
artifact_requirements:
  - "raw trace/credential を含まない generated public-safe artifact"
  - "command exit status(PASS/FAIL/SKIP を判別できる形式)"
  • runtime VC: uv run --locked pytest .claude/skills/agent-retrospective/scripts/tests/verify_latitude_runtime_evidence_live_cli.py
  • evidence: command exit status と raw trace/credential を含まない generated public-safe artifact を Draft PR に添付する。CLI/auth/network unavailable は artifact を保存して SKIP とし、success と扱わない。

Out of Scope

Allowed Paths

Proposed Allowed Paths

  • .claude/skills/agent-retrospective/SKILL.md
  • .claude/skills/agent-retrospective/references/**
  • .claude/skills/agent-retrospective/schemas/latitude_runtime_evidence_v1.schema.json
  • .claude/skills/agent-retrospective/schemas/fixtures/**
  • .claude/skills/agent-retrospective/scripts/collect_snapshot.py
  • .claude/skills/agent-retrospective/scripts/run_retrospective.py
  • .claude/skills/agent-retrospective/scripts/validate_retrospective_schema.py
  • .claude/skills/agent-retrospective/scripts/tests/test_latitude_runtime_evidence.py
  • .claude/skills/agent-retrospective/scripts/tests/verify_latitude_runtime_evidence_live_cli.py
  • .claude/skills/agent-retrospective/scripts/tests/**

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合。
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)。
  • 後続 Phase / 別スコープへの波及が判明した場合。
  • nested SubAgent delegation が必要になった場合。
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合。
  • Latitude CLI が read-only allowlisted command shape で必要 evidence を返せず、CLI boundary の拡張または remote mutation が必要になった場合。
  • raw trace、credential、secret、prompt、tool I/O、absolute local path の保存・出力・GitHub publication が必要になった場合。

Required Skills

  • Python CLI development
  • JSON Schema validation
  • public-safe evidence design

Required Design References

Scope Delta(任意)

N/A

Delivery Rule

Notes for Reviewer

Scope Collision (C1): related_issue=#2374; overlapping_paths=.claude/skills/agent-retrospective/SKILL.md, .claude/skills/agent-retrospective/scripts/run_retrospective.py, .claude/skills/agent-retrospective/scripts/tests/test_run_retrospective.py. Non-conflict reason: #2374 は AGY advisory native fallback の observer-wave 回帰を対象とし、本 Issue は Latitude CLI の public-safe runtime evidence schema/collector/binding を対象とする。Edit intent: #2374 merge 後の current head に対して本 Issue の差分だけを追加する。Dependency ordering: #2374 merge 後に開始する。

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    on Aug 28, 2026
  2. squne121 commented on Aug 28, 2026

    @squne121
    OwnerAuthor
    はい。**Latitude CLI を `agent-retrospective` の private runtime evidence collector として組み込むのは効果が高い**です。MCPを常設せず、必要な retrospective 実行時だけCLI subprocessを起動する構成が、現在の設計にもよく合っています。
    
    特に現状の `agent-retrospective` は、root Skillが単一の `run_retrospective.py` を呼び、その内部でcollector → observer → evaluatorを統括する構成です。Latitude CLIを追加する場所が明確です。
    
    さらに重要なのは、現在のClaude Code collectorがsession JSONLから保持しているのが実質 `type / role / timestamp / sessionId / uuid` だけだという点です。tool名・duration・cost・model・error・parent/child span・Agent nestingなどは捨てています。 今回Latitude Web UIで有用だった情報の大半が、今のretrospective runtime observerには入っていません。
    
    Latitude CLIはまさにこの用途を想定しており、MCPなしでClaude Code等のagentから利用でき、JSON/JSONL出力とmachine-readableな`--schema`を提供しています。`latitude traces list --format jsonl`も公式例として掲載されています。([[Latitude Docs](https://docs.latitude.so/getting-started/cli)][1])
    
    ## 推奨アーキテクチャ
    
    Latitude CLIをobserverに直接自由操作させるのではなく、**deterministic collectorとしてroot orchestration側に入れる**のがよいです。
    
    ```text
    /agent-retrospective
           │
           ▼
    run_retrospective.py
           │
           ├── Claude Code session collector
           │
           ├── Claude-GPT collector
           │
           ├── Latitude CLI collector ← NEW
           │      │
           │      ├─ latitude --version
           │      ├─ latitude auth status
           │      ├─ command --schema
           │      ├─ traces/spans → JSONL
           │      └─ deterministic local analysis
           │
           ├── repository collector
           ├── GitHub collector
           └── Web collector
                   │
                   ▼
         retrospective-runtime-observer
                   │
                   ▼
              evaluator
                   │
                   ▼
       agent_improvement_candidate/v1
    ```
    
    Latitudeのraw JSONLをそのままLLM contextへ入れるのではありません。collector側で、
    
    ```text
    7,833 spans
           ↓
    deterministic aggregation
           ↓
    - p50/p95/p99
    - cost
    - errors
    - slow Agent
    - slow Bash
    - repeated commands
    - repeated Agent tasks
    - trace/session binding
    - top outliers
           ↓
    数KB〜数十KB程度の構造化evidence
    ```
    
    まで圧縮してからruntime observerへ渡します。
    
    これなら**MCP context overheadはゼロで、Latitudeを使うretrospectiveのときだけAPIアクセス**が発生します。
    
    また、既存schemaへ`source_id=latitude`を追加する必要もないと思います。現在のschemaではruntime sourceが`claude_code / claude_gpt`として設計されています。 さらに完了済みの#1223でも、`latitude_otlp`はprovenance/input sourceであってpublic `source_kind`にはしないという設計判断が既に固定されています。
    
    したがって、
    
    > **Latitude = Claude Code runtime evidenceのenrichment source**
    
    とするのが最小変更です。
    
    ---
    
    # ChatGPT用ZIPについて
    
    ここは少し設計を変えることを推奨します。
    
    **「ZIPをGitHub Issueに添付する」をcanonical workflowにするのは避けた方がよいです。**
    
    理由は2つあります。
    
    第一に、現行の[GitHub CLI](https://cli.github.com/manual/gh_issue_create?utm_source=chatgpt.com)には`gh issue create --attach`や`gh issue comment --attach`がありません。issue/commentはbody/body-fileまでです。([[GitHub](https://github.com/cli/cli/issues/12960?utm_source=chatgpt.com) CLI][2]) GitHub CLI側でも2026年現在、agent workflowのためのfile attachment対応が未解決課題として残っています。([GitHub][3])
    
    第二に、このrepoの既存方針と衝突します。#1153は、
    
    > Latitude/EntireCLI raw dataはPrivate Observation Planeに置き、GitHubにはpublic-safe projectionだけを置く
    
    と明確に定義しています。 #1939もLatitude/provider traceをoptional private audit evidenceと位置付け、raw transcript/prompt/tool I/OをGitHubへ投稿しない設計です。
    
    このrepoはpublicなので、GitHub Actions artifactもraw telemetryの退避先には向きません。GitHubのartifact APIはpublic resourceなら認証なしでも取得可能です。([[GitHub ドキュメント](https://docs.github.com/en/rest/actions/artifacts?utm_source=chatgpt.com)][4])
    
    ### 代わりに2層にします
    
    ```text
                            agent-retrospective
                                   │
                      ┌────────────┴────────────┐
                      ▼                         ▼
           Public-safe critique          Private analysis bundle
                context                       ZIP
                      │                         │
                      ▼                         ▼
              GitHub Issue                local filesystem
                      │                         │
                      ▼                         │
           ChatGPT GitHub connector             │
                                                ▼
                                        ChatGPTへ手動upload
    ```
    
    これが一番扱いやすいです。
    
    GitHub Issueには、
    
    ```text
    finding
    observed frequency
    duration impact
    cost impact
    current/historical
    evidence digest
    affected skill
    proposed change
    verification hypothesis
    counter-evidence
    ```
    
    程度の**批評用projection**を載せます。
    
    一方、
    
    ```text
    latitude-runtime-evidence.json
    selected-spans.jsonl
    command-frequency.json
    agent-frequency.json
    session-timeline.jsonl
    selected-session-excerpts.jsonl
    candidate.json
    manifest.json
    ```
    
    をZIP化し、ローカルに保存します。
    
    通常はGitHub connectorだけで私が改善Issueをレビューできます。
    
    「本当にこのIssueがretrospective evidenceから導けるのか」を深掘りしたい場合だけ、そのZIPをこのチャットへアップロードしてください。そうすれば私はファイルを直接解析できます。
    
    つまり人間操作は、
    
    > Latitude WebUIを延々操作する
    
    から、
    
    > **必要なときZIPを1個ChatGPTへドラッグする**
    
    まで減らせます。
    
    ---
    
    # Issueは2つに分けるのを推奨
    
    1 Issue = 1 PRという現在のrepo設計を考えると、Latitude collectorとChatGPT handoffは分離した方がよいです。
    
    ## Issue A案 — Latitude CLI enrichment
    
    **タイトル**
    
    > `実装: agent-retrospective に Latitude CLI runtime evidence enrichment を追加する`
    
    ````markdown
    ## Machine-Readable Contract
    
    ```yaml
    contract_schema_version: v1
    issue_kind: implementation
    parent_issue: "#1153"
    related_issues:
      - "#1223"
      - "#1939"
    goal_ref: >
      agent-retrospective の Claude Code runtime evidence を Latitude CLI の
      trace/span telemetry で bounded enrichment し、MCPを常設せず
      duration/cost/error/repetition/Agent nesting を retrospective evidence として利用可能にする
    change_kind: workflow
    ````
    
    ## Background
    
    現在の `.claude/skills/agent-retrospective` は Claude Code / Claude-GPT /
    repository / GitHub / Web の evidence を収集し、
    runtime observer → evaluator の2段階で improvement candidate を生成する。
    
    Claude Code source collector は session JSONL から
    `type / role / timestamp / sessionId / uuid` のみをallowlist projectionしており、
    以下を retrospective evidence として保持していない。
    
    * span duration
    * cost
    * model
    * tool name
    * tool latency
    * errors
    * parent/child span relation
    * Agent/SubAgent nesting
    * command repetition
    * Agent task repetition
    
    Latitudeには同じClaude Code runのOpenTelemetry traceが存在しており、
    CLIはJSON/JSONL machine-readable outputを提供する。
    
    MCPはClaude Code session contextへの常設負荷を避けるため使用しない。
    
    ## Outcome
    
    `agent-retrospective` 実行時のみ Latitude CLI を subprocess として呼び出し、
    対象Claude Code sessionsに対応するbounded telemetry projectionを生成して
    `retrospective-runtime-observer` へ渡せる。
    
    Latitudeが unavailable の場合も retrospective 全体は停止せず、
    runtime evidence availability を `partial | unavailable` として明示して継続する。
    
    ## Design
    
    ```text
    collect Claude session
            |
            +--> sessionId / time window
            |
            v
    LatitudeCliCollector
            |
            +--> CLI version/schema probe
            +--> trace/span query
            +--> bounded JSONL
            |
            v
    latitude_runtime_evidence/v1
            |
            +--> aggregate metrics
            +--> outliers
            +--> repetition clusters
            +--> error clusters
            +--> agent/tool statistics
            |
            v
    retrospective-runtime-observer
    ```
    
    Latitudeを新しいpublic `source_id` として追加しない。
    `claude_code` runtime sourceのprivate enrichmentとして扱う。
    
    ## CLI Boundary
    
    CLI command surfaceをコードに盲目的に固定しない。
    
    実行時に以下を確認する。
    
    * `latitude --version`
    * `latitude auth status`
    * 対象commandの `--schema`
    
    machine-readable schemaから利用可能なflagsを確認した上でqueryする。
    
    `--format json` / `--format jsonl` のみ使用する。
    
    `--debug` は使用しない。
    
    credentialはargvへ渡さず、Latitude CLI keyringを標準経路とする。
    
    ## Binding Rules
    
    Latitude traceとClaude Code local sessionの対応にはbinding strengthを持たせる。
    
    ```yaml
    binding:
      exact_trace_id
      exact_session_id
      bounded_time_and_repo_match
      unbound
    ```
    
    `exact_trace_id` / `exact_session_id` のみfinding authorityとして扱う。
    
    time/repo matchのみの場合はadvisory evidenceとする。
    
    ## latitude_runtime_evidence/v1
    
    最低限以下を保持する。
    
    ```yaml
    availability:
    cli_version:
    cli_schema_digest:
    query_window:
    binding:
    
    metrics:
      trace_count:
      span_count:
      error_count:
      total_cost:
      duration_p50:
      duration_p95:
      duration_p99:
    
    operations: []
    tools: []
    models: []
    
    outliers:
      slow_invoke_agent: []
      slow_tool_agent: []
      slow_bash: []
      slow_llm_request: []
    
    repetition:
      command_clusters: []
      agent_task_clusters: []
    
    errors: []
    ```
    
    raw HTTP response / API key / Authorization headerは含めない。
    
    ## Collection Budget
    
    * retrospective scope外の全履歴取得は禁止
    * default windowは対象session群を包含するbounded interval
    * pagination上限を設ける
    * CLI timeoutを設ける
    * raw JSONL byte budgetを設ける
    * outlier/repetition出力件数をboundedにする
    * run-scoped temp directoryへ保存し終了時cleanupする
    
    ## Acceptance Criteria
    
    * [ ] AC1: Latitude CLI collectorが独立moduleとして存在する
    * [ ] AC2: MCPを一切設定・起動しない
    * [ ] AC3: CLI version/auth/schemaをsecret非出力でpreflightする
    * [ ] AC4: JSON/JSONLからduration/cost/error/tool/model/Agent情報をbounded projectionできる
    * [ ] AC5: local Claude sessionとのbinding strengthを記録する
    * [ ] AC6: command repetitionとAgent task repetitionをdeterministicに集計する
    * [ ] AC7: Latitude unavailable/auth unavailable/schema drift/query timeout時もretrospectiveはtyped partial evidenceで継続する
    * [ ] AC8: runtime observerがLatitude enrichmentを利用できる
    * [ ] AC9: evaluator/public PublishRequestへraw Latitude payloadを渡さない
    * [ ] AC10: fixture CLI outputによるdeterministic unit/integration testが存在する
    
    ## Proposed Allowed Paths
    
    * `.claude/skills/agent-retrospective/SKILL.md`
    * `.claude/skills/agent-retrospective/scripts/run_retrospective.py`
    * `.claude/skills/agent-retrospective/scripts/collect_latitude_cli.py`
    * `.claude/skills/agent-retrospective/scripts/schemas/**`
    * `.claude/skills/agent-retrospective/scripts/tests/**`
    * `.claude/skills/agent-retrospective/references/**`
    * `.claude/agents/retrospective-runtime-observer.md`
    
    ## Verification Commands
    
    ```bash
    uv run --locked pytest \
      .claude/skills/agent-retrospective/scripts/tests/test_collect_latitude_cli.py -q
    
    uv run --locked pytest \
      .claude/skills/agent-retrospective/scripts/tests/ -q
    ```
    
    live verification:
    
    ```bash
    latitude --version
    latitude auth status
    ```
    
    その後、current CLI schemaから導出したread-only trace queryを
    直近の既知Claude Code sessionに対して1回実行し、
    `latitude_runtime_evidence/v1` が生成されることを確認する。
    
    ## Runtime Verification Applicability
    
    ```yaml
    decision: immediate
    external_service: Latitude Cloud
    mutation_allowed: false
    read_only: true
    required_claim:
      - CLI read access works
      - at least one Claude Code session can be bound to Latitude telemetry
    fallback:
      latitude_unavailable: retrospective_continues_as_partial
    ```
    
    ## Out of Scope
    
    * Latitude MCP
    * Latitude mutation
    * Dataset作成
    * Signal作成
    * raw telemetryのGitHub投稿
    * ChatGPT bundle生成
    * retrospective candidateの自動Issue起票
    * agent_retrospective_run/v1のpublic source enum変更
    
    ## Delivery Rule
    
    * 1 Issue = 1 Draft PR
    * Latitude CLIはoptional enrichment
    * provider telemetry unavailableをretrospective失敗にしない
    
    ````
    
    これは#1223の再実装ではありません。#1223は既にclosedで、public `agent_run_report`へのallowlist projectionを扱ったIssueです。 今回は**`.claude/skills/agent-retrospective`のprivate runtime observerへ、高解像度telemetryを供給すること**が差分です。
    
    ---
    
    # Issue B案 — ChatGPT critique handoff
    
    **タイトル**
    
    > `実装: agent-retrospective に ChatGPT critique context と local evidence bundle を追加する`
    
    ```markdown
    ## Machine-Readable Contract
    
    ```yaml
    contract_schema_version: v1
    issue_kind: implementation
    parent_issue: "#1939"
    related_issues:
      - "#1153"
    goal_ref: >
      agent-retrospective が生成した improvement candidate と、
      その根拠となった runtime evidence の対応をChatGPTが批評できる
      public-safe context + optional local ZIP bundleとして出力する
    change_kind: workflow
    ````
    
    ## Outcome
    
    retrospective candidateごとに、
    
    1. GitHub connectorだけで読めるpublic-safe critique context
    2. 必要時にChatGPTへ手動uploadできるlocal ZIP
    
    を生成する。
    
    GitHubへのraw telemetry ZIP自動添付をsuccess conditionにしない。
    
    ## Public Artifact
    
    `RETRO_CRITIQUE_CONTEXT_V1` を改善Issue commentまたは
    既存retrospective publication chainへ追加する。
    
    ```yaml
    schema: retro_critique_context/v1
    
    candidate:
      candidate_id:
      target_issue:
      title:
      proposed_change:
    
    evidence:
      observed_pattern:
      frequency:
      duration_impact:
      cost_impact:
      affected_workflows:
      current_or_historical:
      evidence_digest:
    
    causal_claim:
      hypothesis:
      supporting_evidence:
      counter_evidence:
      unresolved_questions:
    
    verification:
      expected_metric_change:
      regression_check:
      falsification_condition:
    
    private_bundle:
      available: true | false
      digest:
      format: agent_retro_private_bundle/v1
    ```
    
    local path、session id、raw prompt、raw tool I/Oはpublic artifactへ出さない。
    
    ## Local Bundle
    
    ```text
    agent-retro-<run-id>.zip
    ├── manifest.json
    ├── candidate.json
    ├── latitude-runtime-evidence.json
    ├── command-frequency.json
    ├── agent-frequency.json
    ├── session-timeline.jsonl
    ├── selected-session-excerpts.jsonl
    └── README.md
    ```
    
    このZIPはdefaultではローカルだけに保存する。
    
    GitHub Issueへの自動file attachmentは行わない。
    
    ## ChatGPT Workflow
    
    通常:
    
    ```text
    Improvement Issue
       ↓
    RETRO_CRITIQUE_CONTEXT_V1
       ↓
    ChatGPT GitHub connector
       ↓
    candidate critique
    ```
    
    deep analysis:
    
    ```text
    Improvement Issue URL
    +
    agent-retro-<run-id>.zip をChatGPTへupload
       ↓
    ChatGPT
       ↓
    rawer evidence + GitHub state + repo assetsを横断分析
    ```
    
    ## Required ChatGPT Critique Questions
    
    ChatGPTが少なくとも以下を評価可能なcontextを生成する。
    
    * findingからproposed changeへの因果接続は十分か
    * 単なる相関をroot causeとして扱っていないか
    * current implementationでも再現するか
    * fix scopeが広すぎないか
    * alternative explanationはないか
    * measurable success criterionがあるか
    * 改善後に同じLatitude patternが減少したと判定できるか
    
    ## Acceptance Criteria
    
    * [ ] AC1: candidateごとの`retro_critique_context/v1`を生成できる
    * [ ] AC2: evidence → hypothesis → proposed change → verificationの対応がmachine-readable
    * [ ] AC3: public artifactは既存public-safety boundaryを通過する
    * [ ] AC4: local ZIPをdeterministicに生成できる
    * [ ] AC5: ZIP manifestに各fileのsha256とschema versionを持つ
    * [ ] AC6: ZIPなしでもGitHub connector-only critiqueが可能
    * [ ] AC7: ZIPありの場合はChatGPTがより詳細なsession/runtime analysisを行える
    * [ ] AC8: GitHub Issue attachmentを必須依存にしない
    
    ## Proposed Allowed Paths
    
    * `.claude/skills/agent-retrospective/scripts/**`
    * `.claude/skills/agent-retrospective/schemas/**`
    * `.claude/skills/agent-retrospective/references/**`
    * `.claude/skills/agent-retrospective/SKILL.md`
    
    必要なら既存ChatGPT context producer側はScope Deltaとして別Issueへ分離する。
    
    ## Out of Scope
    
    * GitHub Issue binary uploadのbrowser automation
    * raw Latitude JSONLのGitHub投稿
    * raw session transcriptのGitHub投稿
    * GitHub Actions artifactへのprivate telemetry保存
    * ChatGPT retrospectiveの自動起動
    * improvement Issueの無断自動起票
    
    ## Delivery Rule
    
    * ChatGPT critiqueはhuman-triggered
    * bundle生成まではautomatic
    * bundle uploadはoptional human action
    * 1 Issue = 1 Draft PR
    
    ````
    
    ---
    
    ## 最終的に目指す運用
    
    こうなればかなり使いやすいはずです。
    
    ```text
    /agent-retrospective
           │
           ├── local session evidence
           ├── Latitude CLI telemetry
           ├── repository
           ├── GitHub
           └── Web
           │
           ▼
    retrospective
           │
           ▼
    improvement candidate
           │
           ├── public-safe critique context → GitHub
           │
           └── deep evidence ZIP → local
           │
           ▼
    改善Issue
           │
           ▼
    「このIssueを敵対的レビューして」
           │
           ├── 通常: ChatGPT GitHub connectorだけ
           │
           └── 深掘り: ZIPを追加upload
           ▼
    ChatGPTが
    retrospective evidence
            ↕
    root cause
            ↕
    proposed implementation
            ↕
    verification
    を批評
    ````
    
    この形なら、今回行った**Latitude WebUI → スクリーンショット → Gemini → ChatGPT**という人間オペレーションをほぼ廃止できます。
    
    また、#1939には既に「provider telemetryはoptional private audit support」「opaque public evidence → private local audit resolver」という方向性が書かれています。 したがって、新規の大きな思想変更というより、**既存設計で空いている実装穴をLatitude CLIで埋める**位置づけにできます。
    
    優先順位は **Issue A → 実運用で2〜3回評価 → Issue B** がよいです。Latitude CLI enrichment自体に有用性がなければ、bundle/handoffを作り込む必要がないためです。
    
    [1]: https://docs.latitude.so/getting-started/cli "CLI - Latitude Docs"
    [2]: https://cli.github.com/manual/gh_issue_create?utm_source=chatgpt.com "GitHub CLI | Take GitHub to the command line"
    [3]: https://github.com/cli/cli/issues/12960?utm_source=chatgpt.com "support image/file attachments in gh issue create and gh issue comment (critical for agentic workflows) · Issue #12960 · cli/cli · GitHub"
    [4]: https://docs.github.com/en/rest/actions/artifacts?utm_source=chatgpt.com "REST API endpoints for GitHub Actions artifacts - GitHub Docs"
    
  3. squne121 commented on Aug 29, 2026

    @squne121
    OwnerAuthor

    you asked

    message time: 2026-08-29 12:57:21

    #2375

    内容について関連Issue、PR、リポジトリ資産、コメントを参照した上で敵対的レビューして。

    取り扱う技術や配布物の実装をWEB検索し高品質化してほしい。
    個人趣味開発の前提で品質・有用性を優先したいからセキュリティやハーネスはワークフローを妨げないことを優先して。


    chatgpt response

    Issue・コメント・関連PR/Issue・実装資産を照合し、外部一次資料で技術前提も検証します。実害ある欠陥と過剰設計を分離し、個人開発での実用性、修正優先度、受け入れ条件まで厳しく判定します。


    chatgpt response

    最大の懸念は、runtime evidenceを3集計値へ縮めた結果、project・時間窓・trace集合が未定義で分析価値まで失っている点です。さらに「ローカル非永続化」は親Issueのprivate保持方針と下流#2376のbundle設計に矛盾します。


    chatgpt response

    既存#1223/PR #1247にはLatitude→agent_run_report/v1の投影経路があり、別schema/validator新設は二重正本化を招きます。現行7.10のsessions listならsessionId一致で、内容を露出せずエラー・token・costまで取得できます。


    chatgpt response

    敵対的レビュー結果

    判定

    Request changes。現状の #2375 は、そのまま実装すべきではありません。

    問題は「安全側に倒しすぎている」だけではありません。現在の契約では、Latitude CLIを一度呼び出し、trace_count・span_count・duration_msという三つの数字を生成する一方で、それが今回レビューしているClaude Codeセッションに対応する証拠なのかを保証できません。結果として、「安全だが役に立たない」より悪い、出所の違う数字をruntime evidenceらしく見せる仕組みになり得ます。Issue本文の一回実行・三メトリクス・非ページング・raw破棄という制限は、証拠の正確性より境界防御を優先しすぎています。

    一方、任意ソースとして扱うこと、public側へraw payloadを出さないこと、取得失敗で通常のretrospectiveを止めないことは妥当です。この核だけ残し、設計を組み直すべきです。


    重要な指摘

    P0-1. 対象セッションとのexact bindingが存在しない

    出力にはevidence_identityやevidence_refがありますが、少なくとも契約上、次の情報が明示されていません。

    • どのLatitude projectを読んだか
    • どのLatitude sessionを読んだか
    • Claude Code側のどのsessionと結び付けたか
    • exact matchなのか、時間範囲による推測なのか
    • 返された値が全件なのか、一ページ目だけなのか

    既存のcollect_snapshot.pyは、public-safeなローカル投影にもsessionIdを残しています。つまり結合キーの候補はすでにあります。これを使わず、project全体や時間窓の集計値を「今回のセッションの証拠」と扱う理由はありません。

    Latitude 7.10.0のschemaには、会話本文を含まないsession listと、sessionIdによるexact filterがあります。session summaryにはtrace数、span数、error数、実行時間、token、costなども含まれます。したがって、v1はexact session queryだけを許可すべきです。

    availability: availableの意味を、次のように強化してください。

    指定されたprojectとsession IDに対して、exact matchが一件だけ存在し、レスポンスschemaとcoverageを検証できた。

    ゼロ件、複数件、時間範囲だけの推測はavailableにしてはいけません。


    P0-2. evidence_identityが証拠のidentityになっていない

    三つの集計値を中心にdigestを作っても、別セッションが同じtrace数・span数・durationを持てば同じidentityになり得ます。それは証拠のidentityではなく、せいぜいsummary_digestです。

    次の二つを分ける必要があります。

    • evidence_identity
      provider namespace、project、session IDから作る安定した識別子
    • snapshot_digest
      binding、coverage、metrics、source schema versionから作る取得時点の内容digest

    collected_atはsnapshot digestに入れません。同じ証拠を再取得しただけでdigestが毎回変わるためです。


    P1-1. 既存のobservation-source adapterと二重化する

    #1223とPR #1247ですでに、次の経路が実装されています。

    provider固有のprivate input
        ↓
    observation-source-adapter
        ↓
    agent surfaceに正規化されたpublic-safe observation
        ↓
    agent_run_report
    

    PR #1247はlatitude_otlpをprovider側のinput kindとして受け、public出力ではagent surfaceへ正規化し、raw混入やavailability driftを既存gateで検査するところまで実装済みです。

    現行adapterにも、trace_count、span_count、prompt/completion/total tokenなどのcanonical projectionがあります。

    したがって、#2375のlatitude_runtime_evidence/v1を第二のpublic evidence schemaとして配線するのは不適切です。許されるのは次の構成です。

    Latitude CLI response
        ↓
    latitude_runtime_summary/v1      ← collector-private contract
        ↓
    既存 observation-source-adapter
        ↓
    既存 public observation schema
    

    IssueのAllowed Pathsにも、最低限以下を追加する必要があります。

    • scripts/agent-logs/lib/observation-source-adapter.mjs
    • 対応するadapter tests
    • run_retrospective.pyとcollectorの結合テスト

    新しいsecurity validatorを別に作るのではなく、既存adapterの境界を再利用すべきです。


    P1-2. 三メトリクス制限が主要な価値を捨てている

    Issueコメント側では、当初次のような分析を想定していました。

    • errorや失敗率
    • tokenとcost
    • durationの分位点
    • 遅いAgent/Bash
    • repeated commands/tasks
    • model、tool、nesting
    • trace/session binding
    • outlier抽出

    本文への収束過程で、これがtrace_count・span_count・duration_msの三つだけに縮んでいます。

    しかし現行Latitudeのsession listは、会話内容を取得せず、一件のsummary rowから少なくとも以下を取得できます。

    • traceCount
    • spanCount
    • errorCount
    • durationNs
    • input/output/total token
    • total cost
    • model/provider
    • agent/toolに関するdimension

    このため「最大三メトリクス」はsecurity boundaryではなく、単なる情報損失です。

    v1では一回のsession summary取得に限定しつつ、最低でも次を採用すべきです。

    trace_count
    span_count
    error_count
    active_duration_ms
    prompt_tokens
    completion_tokens
    total_tokens
    cost_total_microcents
    

    なお、LatitudeのdurationNsは単純なwall-clockではなく、sessionのactive execution timeとして定義されています。duration_msという曖昧な名称ではなく、active_duration_msと明記すべきです。wall-clockが必要なら、start/endから別途wall_duration_msを導出します。

    p95、遅いspan、重複tool callなどはspan queryと追加取得が必要になるため、v1から外して構いません。三メトリクスに削るのではなく、一回のsession summaryで取れる有用な値を全部使うのが適切な境界です。


    P1-3. 「一回だけ実行」とversion/auth/schema preflightが両立していない

    Issueコメントは、version・auth・schemaのpreflightを求めています。一方で本文は、CLI invocationを最大一回に制限しています。両方を同時に満たす契約にはなっていません。

    さらに、Latitude CLI 7.10.0は2026年8月18日に公開済みです。CLIのcommand/schema driftは将来の仮定ではなく、継続的に対処すべき現実の問題です。

    実行時契約は次のように分けるべきです。

    • retrospective一回につき、network data readは一回
    • version/schema検証はinstall時、doctor実行時、fixture更新時に行う
    • runtimeでの--versionはcache miss時だけ許可
    • 対応範囲は、たとえば>=7.10,<8
    • 未対応versionはunsupported_cli_version
    • shape不一致はschema_mismatch
    • どちらの場合も通常のretrospectiveは継続

    毎回version、auth、schema、data queryを順番に呼ぶのは遅く、逆に一切検証しないのは壊れやすいので、この分離が最も実用的です。


    P1-4. 非ページングなのにcoverageを表現していない

    Latitudeのlist APIはcursor paginationを持ちます。ページングを禁止すること自体は、exact session summaryだけを読むなら問題ありません。しかし、現在の契約には「取得結果が完全だったか」を表すフィールドがありません。

    一回の読み取りで完結させるなら、次の規則が妥当です。

    filter: sessionId == 対象ID
    limit: 2
    

    判定は次の通りです。

    • 一件かつhasMore == false
      → available、coverage: complete
    • ゼロ件
      → unavailable、session_not_foundまたはingestion_pending
    • 二件またはhasMore == true
      → error、ambiguous_binding
    • exact matchに失敗した場合
      → project集計や時間範囲検索へ自動fallbackしない

    limit: 2はデータを集めるためではなく、bindingの曖昧さを検出するためです。


    P1-5. 親設計・後続Issueとのprivate evidence契約が噛み合っていない

    #1153の設計は、rawなEntireCLI/Latitude情報をprivate observation planeに保持し、public review planeには要約・メトリクス・opaque referenceだけを出す二層構造です。

    #1939も、publicなopaque referenceからprivate evidenceを解決するresolver、availability、retention、failure semanticsを求めています。

    さらに後続の#2376は、permission-restrictedなlocal evidence bundleを明示的に作る契約です。

    したがって、#2375の「raw stdout/stderrは即破棄」「ローカルにも永続化しない」という絶対条件では、evidence_refを後から解決できず、#2376とも整合しません。

    個人開発向けには、次の軽量な方針で十分です。

    • raw conversationはデフォルトで保存しない
    • public artifactへは絶対に含めない
    • localには必要に応じて、metrics・identity・snapshot digest・normalized diagnosticだけを保存
    • 保存する場合は#2376のbundle規則に従う
    • 自動アップロードしない
    • raw保存は明示opt-inに限定

    「private planeを許容する」と「毎回raw transcriptを保存する」は別です。現在のIssueは両者を混同して、監査可能性まで捨てています。


    P1-6. public-safeとoperator diagnosticを混同している

    LatitudeのClaude Code向けtelemetryは、設定によってprompt、assistant response、tool call、tool resultを含むfull-fidelityな会話情報を送ります。したがって、session detail、trace detail、span detail、export、debug出力をpublic経路から禁止するのは正しい判断です。

    一方で、session listのrowはper-message contentを含まないため、ここだけに限定すれば危険度は大きく下げられます。

    しかし、stderrを完全に捨てると、次の区別ができません。

    • 未認証
    • project不存在
    • permission denied
    • timeout
    • rate limit
    • network failure
    • CLI/API schema不一致

    public reportには出さず、ローカルに次だけ残すべきです。

    exit_code
    reason_code
    cli_version
    normalized_message    最大2KiB
    

    既存のobservation adapterはすでにpublic出力のraw混入を検査しています。新しいrecursive secret/path scannerをcollector側へ重ねる必要はありません。typed projectionを作り、既存gateへ渡す方が小さく、保守しやすく、ワークフローを妨げません。


    P1-7. runtime evidenceがretrospectiveを改善する条件がない

    現在のAcceptance Criteriaは、主として次を検証しています。

    • コマンド境界
    • 出力schema
    • raw非保持
    • 実行回数やサイズ
    • unavailable時の挙動

    しかし、「取得した証拠がretrospectiveの品質を改善したか」を検証していません。

    少なくともfixtureで次を証明すべきです。

    • error_count > 0によりruntime reliability findingの優先度またはconfidenceが上がる
    • 異常なtoken/costによりbudget findingが追加または補強される
    • runtime evidenceがない場合、既存結果が変わらない
    • bindingが弱い、またはambiguousなevidenceはfindingを昇格させない
    • metricsだけから根本原因を断定しない

    これがなければ、#2375は「JSONを一個増やした」だけで終わります。


    P2-1. Issue dependencyとAllowed Pathsが不正確

    Machine-Readable Contractはparent_issue: noneですが、実際には少なくとも次の関係があります。

    related/design: #1153
    depends_on:     #1223 / PR #1247
    related:        #1939
    blocks:         #2376
    

    また、PR #2387は直近でrun_retrospective.pyのobserver呼び出し、schema選択、role adapterを変更しています。#2375が同じorchestratorを触るなら、この経路を壊さないregression testが必要です。

    #2375のAllowed Pathsは、既存adapterとの統合を許すように更新し、PR #2387のhead以降をauthoritative baseとして扱うべきです。


    推奨する最小設計

    Issue名も次の程度まで具体化した方がよいです。

    実装: agent-retrospective にexact-session-bound Latitude runtime summaryを既存observation adapter経由で追加する

    取得契約

    source: latitude sessions list
    project: explicit trusted configuration
    filter: exact sessionId match
    limit: 2
    network_reads: 1
    pagination: forbidden
    detail_endpoints: forbidden
    export: forbidden
    debug_mode: forbidden

    取得する値は、session summary一件に限定します。

    projection:
      - traceCount
      - spanCount
      - errorCount
      - durationNs
      - tokensInput
      - tokensOutput
      - tokensTotal
      - costTotalMicrocents
      - models
      - providers

    Latitude公式も、request・conversation・agent境界へsession IDやmetadataを付ける運用を案内しています。Claude Code側のsessionIdとLatitude側sessionの対応が直接取れない場合は、共通のretrospective_run_idをtelemetry metadataへ設定する処理が先行条件です。(GitHub)

    時間範囲による推測fallbackは入れません。 Exact bindingが作れないなら、そのrunではunavailableにするべきです。


    推奨出力schema

    {
      "schema_version": "latitude_runtime_summary/v2",
      "availability": "available",
      "binding": {
        "kind": "session_id",
        "strength": "exact",
        "project_ref_digest": "sha256:...",
        "session_ref_digest": "sha256:...",
        "coverage": "complete"
      },
      "metrics": {
        "trace_count": 12,
        "span_count": 93,
        "error_count": 2,
        "active_duration_ms": 18432,
        "prompt_tokens": 120000,
        "completion_tokens": 8000,
        "total_tokens": 128000,
        "cost_total_microcents": 123456
      },
      "dimensions": {
        "models": ["..."],
        "providers": ["..."]
      },
      "evidence_identity": "sha256:...",
      "snapshot_digest": "sha256:...",
      "source_version": "latitude-cli/7.10.0",
      "collected_at": "2026-08-29T00:00:00Z",
      "reason_code": null
    }

    規則は次の通りです。

    • availability != availableではmetricsをすべてnull
    • legitimate zeroとunavailableを混同しない
    • evidence_identityはprovider/project/sessionのidentity
    • snapshot_digestはbinding・coverage・metrics・source versionのcanonical digest
    • collected_atはdigest対象外
    • agentNamesやdefinedToolsはpublicには出さず、必要なら件数のみ
    • evidence_refは実際にresolverが存在する場合だけ付ける
    • resolver未実装の段階では、意味のないopaque文字列を生成しない

    書き換えるべきAcceptance Criteria

    1. Exact binding
      ローカルrunとLatitude sessionをproject+session IDでexactに結び付ける。時間窓・最新session・project全体へのfallbackは禁止。

    2. Content-free read
      session list相当のread-only commandだけを許可し、session/trace/span detail、export、mutation、debugを拒否する。

    3. Complete result
      limit: 2で取得し、一件かつhasMore == falseのときだけavailable / completeとする。

    4. Useful metrics
      trace、span、error、active duration、prompt/completion/total token、costを投影する。任意の「最大三個」制限は削除する。

    5. Existing adapter reuse
      collector-private summaryを既存observation-source adapterへ渡し、public側に新しい並行schemaを作らない。

    6. Correct identity
      evidence identityとsnapshot digestを分離し、digestからcollected_atを除外する。

    7. Nonblocking semantics
      CLI不在、未認証、session未検出、timeout、schema driftのいずれでも、基礎retrospectiveは成功させる。弱いevidenceでfindingを昇格させない。

    8. Bounded diagnostics
      publicにはraw stdout/stderr、会話、tool I/O、local pathを含めない。ローカルにはtyped reasonと最大2KiBのnormalized diagnosticを許可する。

    9. Compatibility
      7.10系のschema fixtureを保存し、対応version範囲を宣言する。version/schema検査はinstall/doctorまたはcache miss時に行い、毎runの多段preflightを要求しない。

    10. Utility proof
      Hermetic fixtureで、availableなruntime evidenceが少なくとも一つのfindingの根拠・confidence・priorityを決定論的に変えることを検証する。unavailable時は完全なno-opとする。

    11. Lightweight live verification
      実装時に一回だけ実CLI smokeを実行し、恒久的なnetwork CI gateにはしない。これはPR #2387で採用済みの「一回のlive consumer smoke、常設CIにはしない」という方針とも整合します。


    セキュリティ境界として残すもの

    個人趣味開発の前提では、hard guardは次の五つで十分です。

    1. read-onlyかつcontent-freeなlist endpointだけを使う
    2. model生成文字列をargv、project、session IDとして直接使わない
    3. detail・export・debugを禁止する
    4. public artifactへのraw出力と自動アップロードを禁止する
    5. Latitude失敗で通常のretrospectiveを失敗させない

    逆に、次は削除または緩和すべきです。

    • 最大三メトリクス
    • 全diagnosticの即時破棄
    • private manifestさえ保存できない絶対的な非永続化
    • 毎回のversion/auth/schema多段preflight
    • typed projection後にも実施する再帰的なsecret/path全文scan
    • 恒久的なlive network test

    実装順

    1. Issueのdependency、Allowed Paths、schema、ACを書き換える
    2. Claude Code session IDとLatitude sessionのexact bindingをlive smokeで確認する
    3. session summary collectorを一回のreadとして実装する
    4. 既存observation-source adapterを拡張する
    5. evidenceがfindingへ与える決定論的な効果を実装する
    6. Hermetic fixtureとPR #2387経路のregression testを追加する
    7. 実CLI smokeを一回実行する
    8. local evidence bundleは価値を確認してから#2376として接続する

    最終結論

    #2375の方向性自体には価値があります。特にerror・token・cost・active durationをsession単位でretrospectiveへ渡せれば、ログ本文だけでは弱い「実行効率」「予算消費」「runtime failure」の評価を改善できます。

    ただし、現在の本文は最重要のexact bindingを欠いたまま、三メトリクス・一回実行・完全破棄という形式的制約だけを強めています。実装着手前にIssueを改稿すべきです。

    exact bindingを実証できない場合は、project集計や時間範囲推定を証拠として導入せず、#2375をnot plannedにする方が高品質です。誤って結び付いたruntime metricsは、証拠がない状態よりレビュー品質を悪化させます。


    you asked

    message time: 2026-08-29 13:25:51

    懸念として agent-retrospective が Latitude CLI を必須とするような実装になると、他の環境で使えなくなってしまうので、依存しないような選択的に利用できるような構成にする方が良いと思います。
    agent-retrospective との導入について検証を行って、どのような接続がいいのか確認した方がいいのではないかと思いますが、いかがでしょうか。
    agent-retrospective が対象としたセッションログのIDから、AgentのIDからLatitudeの情報検索が可能なら、それがデータの整合性を保つ一意のデータになるのでは?


    chatgpt response

    その方針が妥当です。まず「optional enrichment」として成立するかを実環境で検証し、ローカルのsession IDからLatitude側へexact bindできることを確認してから本実装へ進むのが安全です。Agent IDについても、Latitude側で実際にどの識別子が保存・検索可能かを確認します。

    確認した限り、session ID はかなり強い結合キーです。LatitudeのClaude Code telemetry実装はStop hookのsession_idをそのまま取り出し、mainとSubAgentのspanすべてに同じsession.idを付けています。一方、SubAgent IDはsubagent.idとしてspan属性に載りますが、現行CLI/APIでこれを第一級の検索キーとして安定利用できるかは別途確認が必要です。

    はい。その考え方の方が良いです。前回のレビューから一段修正すると、#2375は**「Latitudeをagent-retrospectiveへ組み込むIssue」ではなく、「Latitudeが利用可能な環境だけで追加evidenceを供給するoptional adapterを成立させられるか検証し、成立した場合だけ接続するIssue」**に寄せるべきです。

    特にsession IDについては、かなり期待できます。

    LatitudeのClaude Code telemetry実装を確認すると、Stop hookのpayloadからClaude Codeのsession_idを直接取得し、その値をbuildOtlpRequest()へ渡しています。SubAgentについても親と同じsessionIdを引き継いでLatitudeへ送っています。

    さらにLatitude CLI 7.10.0には、明示したsession IDを扱うlatitude sessions get --project-slug ... --session-id ...が存在し、sessions listはconversation本文を含まないsession summaryを返します。 Latitude自身もClaude Code integrationについて「全spanがsession idを共有してLatitude UI上でgroupされる」と説明しています。(npm)

    したがって、基本bindingはかなり明快です。

    agent-retrospective
           │
           ├─ Claude Code local collector
           │      └─ sessionId = abc123
           │
           └─ [optional] Latitude adapter
                  │
                  └─ project + sessionId = abc123
                           ↓
                     exact session match
                           ↓
                     runtime metrics
    

    これは時間範囲やrepository名で「たぶんこのtrace」と推定するより大幅に強いです。

    Agent IDについて

    ここはsession IDと分けて考えるべきです。

    Latitudeの現行Claude Code telemetryはSubAgentについてもかなり良い情報を送っています。実装上、SubAgent transcriptからagentIdを取得し、SubagentInvocation.agentIdとして扱っています。

    さらに実際のOTLP spanには、

    subagent.id
    subagent.name
    subagent.type
    

    が付加されています。subagent.idは実装上<agentType>:<agentId>という形になっています。

    したがって概念的には、

    Claude session ID
        ↓ exact
    Latitude session
    
    Claude Agent/SubAgent ID
        ↓
    Latitude session内の特定SubAgent span群
    

    という二段階bindingが可能です。

    ただし、ここには重要な留保があります。

    「Latitudeにsubagent.idが保存されている」ことと、「現行Latitude CLIのfilterでsubagent.idを直接検索できる」ことは別です。

    現在確認できたCLIではsession IDは正式なaddressing keyですが、SubAgent IDについて同等の第一級CLI検索インターフェースまでは確認できていません。そのため現時点では、

    • session ID = primary exact identity
    • Agent/SubAgent ID = session内部のsecondary identity候補

    として設計するのが適切です。

    先にlive verificationをやるべき

    ここは同意します。実装より先に、小さな検証を入れた方がよいです。

    特に次の4点だけ確認すれば、接続方式をかなり確定できます。

    1. 実際のClaude Code JSONLにあるsessionId = Xを取る。
    2. Latitude CLIで同じXを指定して一意のsessionを取得できるか確認する。
    3. そのsessionのtrace/spanに、ローカルSubAgent transcriptのagentId = Yと対応するsubagent.idが存在するか確認する。
    4. conversation/prompt/tool I/Oを取得せず、session summaryやspan metadataだけでretrospectiveに必要なduration・cost・error・operation等を取得できるか確認する。

    ここで、

    local sessionId
        =
    Latitude sessionId
    

    が成立すれば、これをcanonical bindingにできます。

    さらに、

    local subagent agentId
        =
    Latitude subagent.idのID部分
    

    まで成立すれば、Agent単位のruntime analysisもかなり精密になります。

    逆にここが成立しなかった場合には、時間範囲matchingなどへ安易にfallbackせず、Latitude enrichmentをunavailableにする方がいいです。

    agent-retrospective本体はLatitude非依存にする

    ここはIssueの必須設計条件にした方がよいです。

    推奨構成はこうです。

    agent-retrospective core
    │
    ├─ Claude Code collector       required when applicable
    ├─ Claude-GPT collector        existing
    ├─ repository collector        existing
    ├─ GitHub collector            existing
    ├─ Web collector               existing
    │
    └─ optional enrichment providers
           │
           └─ Latitude CLI adapter
    

    Latitude adapterはroot orchestrationからinjectするだけで、core schemaやobserverがLatitudeの存在を要求しない構造にします。

    通常動作は例えば、

    Latitude未設定
    → skipped/not_configured
    → retrospectiveは従来通り
    
    Latitude CLIなし
    → unavailable
    → retrospectiveは従来通り
    
    Latitude認証なし
    → unavailable
    → retrospectiveは従来通り
    
    session exact matchなし
    → unavailable
    → retrospectiveは従来通り
    
    exact matchあり
    → runtime evidenceを追加
    → observer/evaluatorが補助証拠として利用
    

    です。

    重要なのは、「Latitude CLIがPATHにあったら勝手にネットワークアクセスする」仕様にも、しない方がよいことです。

    明示的に例えば、

    /agent-retrospective --runtime-evidence latitude

    あるいはrepo-local設定で、

    runtime_evidence:
      latitude:
        enabled: true

    としたときだけ利用する方が予測可能です。

    環境依存をさらに小さくするなら、

    off      デフォルト。Latitudeを一切probeしない
    auto     設定済みなら利用、失敗しても継続
    required live verification専用
    

    程度の三状態で十分です。通常運用はoffまたは明示設定されたautoです。

    #2375の設計をどう変えるか

    私は、いまの#2375をそのまま実装開始するより、runtime verificationをimplementation gateにすることを勧めます。

    つまり最初のAcceptance Criteriaを、

    AC0:
      live Claude Code sessionについて、
      local sessionId と Latitude sessionId の exact binding を実証する。
    
    AC0a:
      exact bindingが成立しない場合、
      time/repo heuristic matchingを導入せず実装を停止する。
    
    AC0b:
      SubAgentを含むsessionについて、
      local agentId と Latitude subagent.id の対応可否を記録する。
      対応できなくてもsession-level enrichmentは許容する。

    とします。

    その上で実装を、

    Level 0
    Latitudeなし
    → 完全に従来通り
    
    Level 1
    exact session binding
    → session-level duration/error/token/cost
    
    Level 2
    agent ID bindingも確認済み
    → SubAgentごとのduration/error/model/tool等
    

    というprogressive enhancementにするのがよいです。

    これならLatitude側APIの変更でAgent ID検索が使えなくなっても、agent-retrospectiveそのものは壊れません。

    さらに重要な点

    この設計にすると、前回私が提案した「Latitude用schemaをかなり厳密にpublic contract化する」必要性も下がります。

    Latitudeはあくまで、

    optional private evidence provider

    です。

    したがって、

    Latitude-specific response
            ↓
    optional adapter
            ↓
    generic runtime evidence
            ↓
    agent-retrospective
    

    という変換境界にする方がよいです。

    observer/evaluatorには、

    provider: optional
    availability: available
    binding:
      session: exact
      agent: exact | unavailable
    metrics:
      ...

    程度のgeneric evidenceを渡せばよく、observer自身にLatitude CLIの知識を持たせる必要がありません。

    これは将来的にLatitude以外のobservability sourceを使う場合にも有利です。


    結論として、#2375は「Latitude integration」より「optional runtime-evidence provider interface + Latitudeによる最初の実証」に修正するのが適切です。

    そして、ユーザーの指摘どおり、Claude Codeのsession ID → Latitude session IDの一致が確認できれば、それを最上位のcanonical identityにするべきです。実装を見る限り、この一致はかなり成立する可能性が高いです。SubAgentについてもagentIdはLatitude spanへsubagent.idとして送られているので、次のlive verificationではここまで確認する価値があります。

    この検証結果が揃ってから、#2375の最終schemaとACを固定するのが順序として最も堅いです。

  4. squne121 commented on Aug 29, 2026

    @squne121
    OwnerAuthor

    root-owned entry router audit

    route: invoke_impl_review_loop
    reason: fresh_review_go_live_equality

  5. self-assigned this
    on Aug 29, 2026
  6. squne121 commented on Aug 29, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-08-29T05:00:00Z)

    • PR: https://github.com/squne121/loop-protocol/pull/2392(Draft、Closes 実装: agent-retrospective に Latitude CLI runtime evidence enrichment を追加する #2375)
    • Worktree: .claude/worktrees/issue-2375-agent-retrospective-latitude-cli-runtime
    • Branch: worktree-issue-2375-agent-retrospective-latitude-cli-runtime
    • Verification:
      • test_latitude_runtime_evidence.py → 57 passed(AC1/AC2/AC5)
      • test_run_retrospective.py → 158 passed(AC3 追加分含む、既存回帰なし)
      • test_public_safe_evidence_refs.py → 36 passed(AC4 追加分含む)
      • verify_latitude_runtime_evidence_live_cli.py -rs → 1 skipped(AC6。latitude CLI 不在のため期待通り SKIP: latitude CLI executable not found in PATH。public-safe artifact 保存済み、gitignored)
      • 全体 scripts/tests/ → 582 passed, 9 deselected(既存回帰なし)
      • ruff check(変更ファイル)→ pass
    • Allowed Paths: 変更した 11 ファイルは Issue 本文の Allowed Paths と完全一致(Allowed Paths 外の変更なし)
    • 後続: PR レビュー(pr-review-judge)→ マージ → post-merge-cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent/implementerenhancementphase/implementation

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions