Repository navigation
Closed
Labels
agent/implementerAI implementer agentarea/ai-opsAI operations and agent tooling areaenhancementNew feature or requestphase/implementationImplementation phaseworkflowWorkflow / skill automation changes
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "#928"
goal_ref: "ChatGPT に投入しやすい public-safe context bundle を deterministic に生成する"
change_kind: mixedParent Issue
Parent Goal Ref
- Goal: parent issue、retro index、選択 run report、evidence ref から ChatGPT 改善相談用の入力面を安全に組み立てる。
- Desired Destination: token budget と omission 理由を持つ markdown bundle export を追加し、raw transcript なしで高密度な retrospective context を生成できるようにする。
Current Validated Scope
- context bundle export CLI と helper を追加する。
- deterministic sort、dedupe、budget 制御、omission report を固定する。
docs/dev/agent-run-report.mdに export surface を追記する。- source provenance / digest pinning、prompt-injection-safe rendering、priority-aware budget allocation を固定する。
Remaining Parent Gaps
- docs / skill handoff は 実装: agent-run-report.md / agent-retro-index.md と skill handoff を整備する #940 で扱う。
- EntireCLI safety は 実装: EntireCLI safety checker と conditional adoption guard を追加する #941 で扱う。
Outcome
ChatGPT 用 context bundle export script、tests、docs 追記が 1 PR で追加され、--max-chars / --max-sections 付き dry-run で raw transcript を含まない deterministic な markdown bundle を生成できる状態。source provenance と prompt-injection-safe rendering を含む public-safe な監査成果物として検証可能。
In Scope
- bundle export CLI と helper。
- deterministic sort と evidence ref dedupe(canonical dedupe key 含む)。
- omission reason / omitted sections の出力(
section_id,reason,priority,original_chars,omitted_digest必須)。 friction_signals,context_pollution_signals,ci_review_loops,human_intervention,follow_up_candidates優先保持。- source provenance / digest pinning(
source_manifest必須、digest mismatch fail-closed)。 - prompt-injection-safe rendering(
SECURITY_BOUNDARY固定出力、DATA fenced block、final Markdown scan)。 - priority-aware budget allocation(safety header 最優先、budget 不足時
budget.too_smallfail)。 - machine-readable bundle header(
chatgpt_context_bundle/v1スキーマ)。 - CLI 仕様の固定(
--retro-index-json等の明示入力)。
Out of Scope
- retro index 自体の再生成。
- GitHub comment upsert。
- EntireCLI safety 判定。
package.json/pnpm-lock.yamlの変更(直接 node 実行に限定)。- skill handoff / 運用手順(実装: agent-run-report.md / agent-retro-index.md と skill handoff を整備する #940 で扱う)。
docs/dev/agent-run-report.mdへの追記は CLI option contract / input-output format / safety boundary / examples のみ。
CLI Specification
$ node scripts/agent-logs/export-chatgpt-context.mjs \
--parent-issue-json artifacts/parent-issue-928.json \
--target-issue-json artifacts/issue-939.json \
--retro-index-json artifacts/agent-retro-index.json \
--source-set-json artifacts/agent-retro-index-source-set.json \
--run-report-json artifacts/report-1.json \
--evidence-ref-json artifacts/evidence-refs.json \
--max-chars 24000 \
--max-sections 12 \
--generated-at 2026-06-19T00:00:00.000Z \
--output artifacts/chatgpt-context.md \
--summary-json-out artifacts/chatgpt-context-summary.jsonstdout は chatgpt-context: bundle written 程度に留める。bundle 本文・絶対 path・raw validator value は stdout に出さない。
Acceptance Criteria
- AC1: export は raw transcript / local path / secret / full command output を含めない。入力 JSON / Markdown に
raw_transcript,transcript_excerpt,full_command_output,stdout,stderr,local_pathが含まれたら fail。 - AC2: token/context budget を
--max-charsまたは--max-sectionsで制御できる。section priority(safety header → source manifest → parent goal → priority signals → CI/review loops → evidence refs → lower-priority narrative → omission report)を固定し、priority 保持後に lower priority から落とす。 - AC3: omission が発生した場合、
omitted_sections[]にsection_id,reason,priority,original_chars,omitted_digestを含めて出力する。 - AC4: run reports は deterministic sort される。
- AC5: duplicate evidence refs は dedupe される。dedupe key は
kind + canonical_url_without_tracking + comment_id_or_artifact_id + body_digest_or_artifact_digest。重複時もused_by_sections[]とduplicate_ofを出力する。 - AC6:
friction_signals,context_pollution_signals,ci_review_loops,human_intervention,follow_up_candidatesが優先的に残る。budget が小さすぎて safety header + priority signals を保持できない場合はbudget.too_smallで fail する。 - AC7: 実装: transcript hotspot summarizer(summarize_agent_transcript.py)を追加し agent ops レビューを回帰計測可能にする #798 の transcript hotspot summarizer と役割が重複する場合でも、report の public-safe aggregate signal としてのみ参照し transcript 本文は取り込まない。
transcript_hotspot_summaryを許可する場合はpublic_safety.redaction_status === cleanと evidence digest を必須とする。 - AC8: bundle 生成時に各入力ファイルの source provenance を
source_manifest(source_kind,source_ref,canonical_digest,body_digest)として bundle 冒頭に出力する。--retro-index-json,--source-set-json,--run-report-json,--evidence-ref-jsonを明示入力とし、live fetch はデフォルト経路に含めない(--fetchモード分離)。digest mismatch は omission ではなく fail-closed。 - AC9: bundle 先頭に
SECURITY_BOUNDARYを固定出力する。外部由来テキストはすべてDATAfenced block または quote 化する。最終 rendered Markdown に対して injection scanner(ignore previous instructions等のパターン、HTML comment injection、code-fence breakout、markdown link injection)を走らせる。 - AC10: bundle 先頭に machine-readable header として
chatgpt_context_bundle/v1スキーマの YAML block を出力する。generated_at,target_issue,parent_issue,safety(redaction_status,rendered_markdown_scan,untrusted_content_mode),budget(max_chars,rendered_chars,max_sections),sources(各kindとdigest),omitted_sectionsを含む。
Verification Commands
# AC1
test -f tests/agent-logs/chatgpt-context-redaction.test.ts
# AC2
test -f tests/agent-logs/chatgpt-context-budget.test.ts
# AC3
test -f tests/agent-logs/chatgpt-context-omission.test.ts
# AC4
test -f tests/agent-logs/chatgpt-context-sort.test.ts
# AC5
test -f tests/agent-logs/chatgpt-context-dedupe-canonical.test.ts
# AC6
test -f tests/agent-logs/chatgpt-context-budget-too-small.test.ts
# AC7
test -f tests/agent-logs/chatgpt-context-transcript-boundary.test.ts
# AC8
test -f tests/agent-logs/chatgpt-context-provenance.test.ts
# AC9
test -f tests/agent-logs/chatgpt-context-injection.test.ts
test -f tests/agent-logs/chatgpt-context-rendered-scan.test.ts
# AC10
test -f tests/agent-logs/chatgpt-context-header.test.ts
pnpm typecheck
pnpm lint
pnpm test
pnpm buildAllowed Paths
scripts/agent-logs/export-chatgpt-context.mjsscripts/agent-logs/lib/chatgpt-context*.mjstests/agent-logs/chatgpt-context*.test.tsdocs/dev/agent-run-report.md
Runtime Verification Applicability
decision: not_applicable
reason: "export CLI / unit test / docs 追記の範囲で完結し、interactive runtime の証跡を成功条件に含まない"Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
- transcript 本文や full command output を含めないと成立しないことが判明した場合
Required Skills
- JavaScript / summarization pipelines
Scope Delta(任意)
N/A
Delivery Rule
1 Issue = 1 PRで完了する。- Draft PR を既定とする。
- 実装: transcript hotspot summarizer(summarize_agent_transcript.py)を追加し agent ops レビューを回帰計測可能にする #798 との責務境界は aggregate signal 参照に限定し、transcript 本文の再露出を禁止する。
Metadata
Metadata
Assignees
Labels
agent/implementerAI implementer agentarea/ai-opsAI operations and agent tooling areaenhancementNew feature or requestphase/implementationImplementation phaseworkflowWorkflow / skill automation changes
Activity
squne121 commentedon Jun 19, 2026
判定
現状の #939 は、実装着手前に仕様を締めるべきです。方向性は妥当ですが、このまま実装すると “public-safe context bundle” が false green になりやすいです。
今回確認した範囲では、#939 自体は open でコメントなしです。したがってレビュー対象は「Issue 契約・関連 Issue/PR/コメントから見た実装仕様」です。
#939 は、#928 の子 Issue として、ChatGPT 投入用の deterministic / public-safe な markdown bundle export を追加し、
--max-chars/--max-sections、omission report、evidence ref dedupe、優先保持フィールドを求めています。親 #928 は、raw transcript / local path / secret を public GitHub surface に出せないため、public-safe な
agent_run_report/v1/agent_retro_index/v1を永続保存し、ChatGPT に改善相談できる状態を目標にしています。Blocker 1: source provenance と digest pinning が未指定
#939 は「parent issue、retro index、選択 run report、evidence ref」から bundle を作るとしていますが、どの入力を正本とみなすか、入力 digest をどう固定するか、live GitHub state を再収集してよいかが未定義です。
これは #938/#1000 で実際に問題化した TOCTOU リスクと同型です。#938 は retro index 側で
merge_sha -> associated PR API -> PR closing keywords -> machine-readable refs -> parent child list -> branch hintの trust hierarchy と digest 分離を要求し、#1000 では download 済みagent-retro-index.json/agent-retro-index-source-set.jsonだけから parent marker を render/upsert する方向に修正されています。要求修正:
--retro-index-json,--source-set-json,--run-report-jsonまたは--run-report-markdown,--evidence-ref-json,--expected-digestを明示する。--fetchのような別モードに分け、実装: export-chatgpt-context.mjs を追加し ChatGPT投入用 context bundle を生成する #939 の通常経路には入れない。source_manifestを出し、各入力のsource_kind,source_ref,canonical_digest,body_digest,retrieved_atまたはartifact_digestを記録する。GitHub REST には commit に関連する PR を列挙する endpoint があり、merged commit から導入元 PR を特定する設計は #938 の trust hierarchy と整合します。([GitHub Docs]1)
Blocker 2: “public-safe” と “prompt-injection-safe” が混同されている
#939 の AC1 は raw transcript / local path / secret / full command output の除外を要求しています。これは必要条件ですが、ChatGPT に投入する bundle としては不十分です。Issue body、PR comment、report summary はすべて untrusted data です。OWASP の LLM Prompt Injection Prevention は、ユーザー入力・外部データを命令ではなくデータとして扱い、入力中の命令に従わない設計を推奨しています。([OWASP Cheat Sheet Series]2)
#937 は posting guard として validator、rendered markdown candidate の検証、final body scan、byte limit を必須化する設計です。#939 の bundle exporter も同じ最終レンダリング後スキャンを持つべきです。
要求修正:
SECURITY_BOUNDARYを固定出力する。DATAセクションとして fenced block または quote 化する。ignore previous instructions,system prompt, HTML comment,<script>, markdown link injection, code-fence breakout をテストする。Blocker 3: budget 制御が AC6 を破壊し得る
#939 は
--max-chars/--max-sectionsと、friction_signals,context_pollution_signals,ci_review_loops,human_intervention,follow_up_candidatesの優先保持を要求しています。単純な先頭からの切り詰めや section count 制限では、優先保持フィールドが落ちます。逆に priority を守ろうとして budget を超えると AC2 違反になります。
要求修正:
section priority を固定する。
--max-charsは最終 rendered Markdown 長で検証する。--max-sectionsは priority section を保護したうえで lower priority から落とす。budget が小さすぎて safety header + source manifest + priority signals + omission report を保持できない場合、unsafe partial bundle を出さず
budget.too_smallで fail する。omitted_sections[]にはsection_id,reason,priority,original_chars,omitted_digestを入れる。Blocker 4: evidence ref dedupe のキーが弱いと監査性が壊れる
#939 は duplicate evidence refs の dedupe を要求していますが、単なる URL 文字列 dedupe では不足です。GitHub comment URL、artifact URL、digest 付き report ref、同一 body の再投稿、fragment 違いが混在します。
#1000 では source-set artifact による
source_comment_set_digest再計算が導入され、summary の URL 配列だけでは不十分という問題が整理されています。要求修正:
dedupe key は最低限これにするべきです。
重複した場合も単に捨てず、
used_by_sections[]とduplicate_ofを残すべきです。ChatGPT に投入する context では、証跡がなぜ省略されたかが重要です。Blocker 5: #798 との責務境界が実装で enforce されない
#939 は #798 の transcript hotspot summarizer と重複しても aggregate signal としてのみ参照し、transcript 本文は取り込まないとしています。
ただし、これは Issue 文の注意書きだけでは不十分です。#935 は retro index に report 本文や transcript 断片の inline copy を禁止し、aggregate field に閉じる方針を置いています。 #936 も transcript は opaque ref のみ、full command output を扱わない設計です。
要求修正:
raw_transcript,transcript_excerpt,full_command_output,stdout,stderr,local_pathが含まれたら fail。transcript_hotspot_summaryのような aggregate field を許す場合は、public_safety.redaction_status === cleanと evidence digest を必須にする。High: CLI 仕様が不足している
#939 の Verification Commands はテスト名を指定していますが、CLI の入出力仕様がまだ薄いです。Node の
util.parseArgsは Node 20 以降で stable なので、新規 CLI で標準 parser を使う選択肢はあります。既存の repo custom parser を再利用するなら、それでもよいですが、ad-hoc なargv.split実装は避けるべきです。([Node.js]3)最低限、以下を固定してください。
stdout は
chatgpt-context: bundle written程度に留め、bundle 本文・絶対 path・raw validator value を出さない方が #936 の stdout hygiene と整合します。High: Markdown bundle に machine-readable header が必要
ChatGPT 向けに読みやすい Markdown を出すだけでは、determinism と omission の検証が弱くなります。bundle 先頭に machine-readable block を置くべきです。
これにより、人間・ChatGPT・CI の三者が同じ bundle を検証できます。
Medium: Allowed Paths と package script が衝突する可能性
#939 の Allowed Paths には
package.jsonが含まれていません。したがって、
pnpm agent-context:exportのような package script を追加したくなった時点で stop condition です。選択肢は二つです。
node scripts/agent-logs/export-chatgpt-context.mjs直実行に限定し、package.jsonは触らない。package.json/pnpm-lock.yamlを追加するよう Issue を修正する。現状のまま implementer に投げると、package script 追加で scope violation になるか、逆に UX が悪い CLI だけが残ります。
Medium: #940 との docs 境界が曖昧
#939 は
docs/dev/agent-run-report.mdの export surface 追記を in scope にしています。一方で docs / skill handoff は #940 に残しています。#939 側の docs は以下に限定すべきです。
Skill handoff、運用手順、Claude/Codex への使わせ方、GitHub workflow 運用は #940 に残すべきです。
追加すべきテスト
既存 AC のテスト名は良いですが、敵対的には以下を足してください。
実装方針
lib/chatgpt-context*.mjsは分割した方が安全です。builder は次の順で処理するべきです。
最終結論
#939 はそのままでも実装できますが、安全な配布物としては仕様がまだ足りません。特に以下は実装前に固定してください。
この補強なしで PR が出てきた場合、私は REQUEST_CHANGES を返します。方向性は良いですが、ChatGPT 投入用 bundle は「便利な Markdown」ではなく、public-safe かつ untrusted-data-safe な監査成果物として扱うべきです。
squne121 commentedon Jun 19, 2026
Refinement Loop: Human Escalation Required
The loop has terminated and requires human review. Cause: human judgment required
human_escalationhuman_judgment_requiredBlockers
squne121 commentedon Jun 19, 2026
Refinement Loop: Approved
The issue has been approved and is ready for implementation.
approvedsqune121 commentedon Jun 20, 2026
CONTRACT_REVIEW_RESULT_V1
Outcome
ChatGPT 用 context bundle export script、tests、docs 追記が 1 PR で追加され、
--max-chars/--max-sections付き dry-run で raw transcript を含まない deterministic な markdown bundle を生成できる状態。source provenance と prompt-injection-safe rendering を含む public-safe な監査成果物として検証可能。Acceptance Criteria(AC1–AC10)
Verification Commands(VC preflight)
Allowed Paths
Worktree / Branch
Checks
Handoff to implement-issue
.claude/worktrees/issue-939-export-chatgpt-contextworktree-issue-939-export-chatgpt-contextsqune121 commentedon Jun 20, 2026
実装完了報告
PR #1018 (Draft) を作成しました。
VC 結果
test -f tests/agent-logs/chatgpt-context-redaction.test.tstest -f tests/agent-logs/chatgpt-context-budget.test.tstest -f tests/agent-logs/chatgpt-context-omission.test.tstest -f tests/agent-logs/chatgpt-context-sort.test.tstest -f tests/agent-logs/chatgpt-context-dedupe-canonical.test.tstest -f tests/agent-logs/chatgpt-context-budget-too-small.test.tstest -f tests/agent-logs/chatgpt-context-transcript-boundary.test.tstest -f tests/agent-logs/chatgpt-context-provenance.test.tstest -f tests/agent-logs/chatgpt-context-injection.test.tstest -f tests/agent-logs/chatgpt-context-rendered-scan.test.tstest -f tests/agent-logs/chatgpt-context-header.test.tspnpm typecheckpnpm lintpnpm test(既存 781 テスト)pnpm buildAllowed Paths Compliance
self-report: true — 全変更ファイルが contract の Allowed Paths 内。
feat(#939): add export-chatgpt-context.mjs and ChatGPT context bundle…
fix(#939): fix test imports and assertion patterns
fix(#939): lint エラーを修正(unused vars / require() / URL import)
fix(#939): PR review REQUEST_CHANGES — B1-B7 + sort contract + no abs…
fix(#939): Allowed Paths 外の変更を origin/main から復元
feat(#939): export-chatgpt-context.mjs — ChatGPT context bundle pipel…