Repository navigation
feat(#939): export-chatgpt-context.mjs — ChatGPT context bundle pipeline - #1018
Conversation
… pipeline Implements AC1–AC10: forbidden field redaction, priority-aware budget allocation, omission report, deterministic sort, evidence ref dedupe (canonical key), budget.too_small guard, transcript boundary enforcement, source provenance/digest pinning, prompt-injection-safe rendering with final scan, and machine-readable bundle header. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
- chatgpt-context-budget-too-small: use ESM import for renderer, fix assertion text - chatgpt-context-injection: fix backtick escape assertion to check content body - chatgpt-context-header: fix import (execFileSync from child_process), remove cwd - chatgpt-context-rendered-scan: remove unnecessary cwd from execFileSync Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
88f51b6 to
86ed6af
Compare
squne121
left a comment
There was a problem hiding this comment.
LOOP_VERDICT_V2
schema: LOOP_VERDICT_V2
verdict: REQUEST_CHANGES
reviewed_head_sha: "86ed6af73279a19d0e3c1026367418efe50a9b0e"
merge_ready: false
mergeability:
mergeable: MERGEABLE
merge_state_status: BLOCKED
blockers:
- "lint: new-file failures in PR diff (not pre-existing) — require() forbidden in chatgpt-context-rendered-scan.test.ts; unused vars in chatgpt-context-redaction.test.ts (cleanupTempDir, createTempDir, writeFileSync, mkdirSync), chatgpt-context-provenance.test.ts (readFileSync), chatgpt-context-header.test.ts (REPO_ROOT); 'URL' not defined in chatgpt-context-dedupe.mjs"
- "CI pending: e2e and python-test still IN_PROGRESS — verdict cannot be APPROVE while required checks are pending"
required_auto_actions: []
auto_fix_applied: []
follow_up_issue_requests: []
allowed_paths_gate:
status: ok
producer_role: review_subagent
worker_report_used_as_canonical: false
changed_files_checked:
- docs/dev/agent-run-report.md
- scripts/agent-logs/export-chatgpt-context.mjs
- scripts/agent-logs/lib/chatgpt-context-args.mjs
- scripts/agent-logs/lib/chatgpt-context-budget.mjs
- scripts/agent-logs/lib/chatgpt-context-dedupe.mjs
- scripts/agent-logs/lib/chatgpt-context-renderer.mjs
- scripts/agent-logs/lib/chatgpt-context-safety-scan.mjs
- scripts/agent-logs/lib/chatgpt-context-source-loader.mjs
- tests/agent-logs/chatgpt-context-budget-too-small.test.ts
- tests/agent-logs/chatgpt-context-budget.test.ts
- tests/agent-logs/chatgpt-context-dedupe-canonical.test.ts
- tests/agent-logs/chatgpt-context-header.test.ts
- tests/agent-logs/chatgpt-context-injection.test.ts
- tests/agent-logs/chatgpt-context-omission.test.ts
- tests/agent-logs/chatgpt-context-provenance.test.ts
- tests/agent-logs/chatgpt-context-redaction.test.ts
- tests/agent-logs/chatgpt-context-rendered-scan.test.ts
- tests/agent-logs/chatgpt-context-sort.test.ts
- tests/agent-logs/chatgpt-context-transcript-boundary.test.ts
contract_source_kind: issue_comment
contract_source_id: "4755558142"
expected_contract_fingerprint: "sha256:81fc84600ded1fc0ec20c5021ba927f2233700b4af0d819b3373cd5a8c80f01a"
result: all 19 changed files within Allowed Paths
notes: |
AC1-AC10 実装とテストは実質的かつ非vacuous(実際の実装関数をimportし境界条件を検証)。
BLOCKER 詳細:
1. lint 失敗(新規ファイル起因):
CI annotations に以下が含まれており、いずれも本PR追加ファイル内の問題:
- tests/agent-logs/chatgpt-context-rendered-scan.test.ts: require() style import 禁止
- tests/agent-logs/chatgpt-context-redaction.test.ts: cleanupTempDir / createTempDir / writeFileSync / mkdirSync 未使用
- tests/agent-logs/chatgpt-context-provenance.test.ts: readFileSync 未使用
- tests/agent-logs/chatgpt-context-header.test.ts: REPO_ROOT 未使用
- scripts/agent-logs/lib/chatgpt-context-dedupe.mjs: 'URL' is not defined
contract の go_pre_existing 判定は playwright-report/trace 等の pre-existing lint 問題を指しており、
PR diff 内の新規ファイルに発生した上記 lint エラーは go_pre_existing に該当しない。
2. CI pending: e2e および python-test が IN_PROGRESS のため完全な証拠が不確定。
CLEAN 項目:
- typecheck: SUCCESS
- build: SUCCESS
- test: SUCCESS (新規 85 テスト含む)
- actionlint: SUCCESS
- PR Body Japanese Check: SUCCESS
- Allowed Paths: 全 19 ファイルが contract Allowed Paths 内
- Closes #939 キーワード: PR 本文に記載
- AC1-AC10 テスト: 全 11 ファイルが実装を正しくインポートし実質検証- chatgpt-context-dedupe.mjs: URL を node:url から明示的にインポート - chatgpt-context-header.test.ts: 未使用の REPO_ROOT を削除 - chatgpt-context-provenance.test.ts: 未使用の readFileSync import を削除 - chatgpt-context-redaction.test.ts: 未使用の mkdirSync/writeFileSync と dead code を削除 - chatgpt-context-rendered-scan.test.ts: require() を ESM import に変換 Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Preview URLPreview removed (PR #1018 closed). |
squne121
left a comment
There was a problem hiding this comment.
LOOP_VERDICT_V2
schema: LOOP_VERDICT_V2
verdict: APPROVE
reviewed_head_sha: "b6cd74589b7c8da9282bbd5a7eb9cae61d8f1590"
merge_ready: true
mergeability:
mergeable: MERGEABLE
merge_state_status: CLEAN
blockers: []
required_auto_actions: []
auto_fix_applied: []
follow_up_issue_requests: []
allowed_paths_gate:
status: ok
producer_role: review_subagent
worker_report_used_as_canonical: false
contract_source_kind: issue_comment
contract_source_id: "4755558142"
expected_contract_fingerprint: "sha256:81fc84600ded1fc0ec20c5021ba927f2233700b4af0d819b3373cd5a8c80f01a"
changed_files_checked:
- docs/dev/agent-run-report.md
- scripts/agent-logs/export-chatgpt-context.mjs
- scripts/agent-logs/lib/chatgpt-context-args.mjs
- scripts/agent-logs/lib/chatgpt-context-budget.mjs
- scripts/agent-logs/lib/chatgpt-context-dedupe.mjs
- scripts/agent-logs/lib/chatgpt-context-renderer.mjs
- scripts/agent-logs/lib/chatgpt-context-safety-scan.mjs
- scripts/agent-logs/lib/chatgpt-context-source-loader.mjs
- tests/agent-logs/chatgpt-context-budget-too-small.test.ts
- tests/agent-logs/chatgpt-context-budget.test.ts
- tests/agent-logs/chatgpt-context-dedupe-canonical.test.ts
- tests/agent-logs/chatgpt-context-header.test.ts
- tests/agent-logs/chatgpt-context-injection.test.ts
- tests/agent-logs/chatgpt-context-omission.test.ts
- tests/agent-logs/chatgpt-context-provenance.test.ts
- tests/agent-logs/chatgpt-context-redaction.test.ts
- tests/agent-logs/chatgpt-context-rendered-scan.test.ts
- tests/agent-logs/chatgpt-context-sort.test.ts
- tests/agent-logs/chatgpt-context-transcript-boundary.test.ts
result: all 19 changed files within Allowed Paths
notes: |
iteration: 2(前回 REQUEST_CHANGES の lint ブロッカー全解消を確認)
## CI 証拠(CI_CHECK_RUN_SCOPED)
run: 27854714817(HEAD b6cd74589b7c8da9282bbd5a7eb9cae61d8f1590)
- build: SUCCESS
- lint: SUCCESS(新規ファイル起因エラーが b6cd7458 で解消)
- typecheck: SUCCESS
- test: SUCCESS(既存 + 新規 85 テスト含む)
- e2e: SUCCESS
- python-test: SUCCESS
- ci-verdict-summary: SUCCESS
- actionlint: SUCCESS
- PR Body Japanese Check: SUCCESS
## 前回ブロッカー解消確認
b6cd7458 コミットで以下が修正されたことを lint job ログから確認:
- chatgpt-context-dedupe.mjs: URL を node:url から明示 import
- chatgpt-context-header.test.ts: 未使用 REPO_ROOT を削除
- chatgpt-context-provenance.test.ts: 未使用 readFileSync を削除
- chatgpt-context-redaction.test.ts: 未使用 mkdirSync/writeFileSync/dead code を削除
- chatgpt-context-rendered-scan.test.ts: require() を ESM import に変換
lint job が SUCCESS / エラー行なしで完了。
## AC1-AC10 テスト存在確認
全 11 テストファイル(AC1-AC10 対応)が PR diff に含まれ、
contract の Verification Commands(test -f)が全て exit 0 となる状態。
## 注記
PR は Draft 状態。Draft は verdict blocker ではない。
merge_ready: true は impl-review-loop の終端条件として設定。
自動マージ・非 Draft 化は人間判断または impl-review-loop の指示に従う。
判定REQUEST_CHANGES / merge不可。 ただし、これはCI greenだが仕様上は false green です。#939/#928 が要求している「public-safe / deterministic / digest-pinned / injection-safe な ChatGPT投入用 bundle」としては、まだ安全境界が弱いです。#928 は raw transcript・local path・secret を公開面に出さず、redacted report/indexだけをGitHub public surfaceに残す親トラッカーです。#939 はその上で、source provenance、digest pinning、priority budget、final Markdown scan、machine-readable headerを要求しています。 schema: LOOP_VERDICT_V2
verdict: REQUEST_CHANGES
reviewed_head_sha: "b6cd74589b7c8da9282bbd5a7eb9cae61d8f1590"
merge_ready: false
ci_state: green_on_current_head
primary_reason: "semantic safety/contract gaps in generated ChatGPT context bundle"Blocker 1: AC10 の machine-readable header が契約を満たしていない#939 のAC10は、bundle先頭の テストも 修正要求: headerは最終render後の実測値から2-passで生成してください。最低限、 Blocker 2: budget制御が最終出力を保証していない現実装は さらに 修正要求: Blocker 3: source provenance / digest pinning が「計算して表示」だけで、検証になっていない
これは #938 / PR #1000 で直した設計と逆行します。#1000 は write job でdownload済み 修正要求: Blocker 4: public-safe scan が既存validatorより明確に弱い新規 既存の 修正要求: run reportには Blocker 5: prompt-injection-safe rendering が不十分OWASPのLLM Prompt Injection Preventionは、外部データと命令が自然言語として同じコンテキストに入ること自体をリスクとし、ユーザー入力・外部データを命令ではなく明示的なDATAとして扱うことを推奨しています。また、HTML/Markdown injection、悪意あるリンク、hidden image等もリスクとして挙げています。([OWASP Cheat Sheet Series]1) ([OWASP Cheat Sheet Series]1) 現scannerは さらに 修正要求: evidence/source/issue title/report summaryなど、外部由来値は原則すべてJSON DATA blockに閉じてください。Markdownリンク化やinline codeでの直接挿入は避ける。final scanは既存scanner相当まで強化し、HTML comment、Markdown link/image、local path、secret-like、marker injection、fence breakoutを検査対象にしてください。 Blocker 6: evidence dedupe の出力契約を満たしていない#939のAC5は、dedupe keyだけでなく、重複時にも 加えて 修正要求: bundle本文またはmachine-readable header/summaryに、重複refごとの Blocker 7: AC7 の transcript hotspot 境界が半分しか実装されていない#939のAC7は、 修正要求: High: summary JSON が絶対パスを出している
修正要求: High: deterministic sort の説明と実装がズレているファイル冒頭コメントは「path then run_id」と書いていますが、実際の 修正要求: Medium: atomic no-overwrite は悪くないが、移植性テストが必要現実装はtemp fileを Medium: CLI parser は許容だが、標準
|
…olute path Blockers addressed: - B1 (AC10): 2-pass render for safety header with all required fields (safety.redaction_status/rendered_markdown_scan/untrusted_content_mode, budget.max_chars/rendered_chars/max_sections, sources[], omitted_sections[]) - B2: budget final check after omission report; source_manifest added to required frame - B3: source provenance — scanPublicSafety applied to all source kinds - B4: public safety scan from agent-run-report-validation.mjs applied to all sources - B5: injection scan enhanced (HTML comments, local paths, secrets, suspicious links, system: prefix, sha256: excluded from bare hex pattern) - B6: dedupe output contract — canonical_key_digest + GitHub fragment in dedup key; duplicate_of/used_by_sections rendered in bundle and summary - B7: transcript hotspot evidence_digest required (sha256:<64hex> format) High priority: - summary JSON output_path removed; output_basename used instead - sort contract: source_ref/path → run_id → started_at (comment/impl/test aligned) Tests: 898 passed, typecheck: pass, lint: pass
worker が merge commit 後に Allowed Paths 外ファイル(tests/*, .claude/skills/*, docs/dev/workflows/*)を削除・変更していたため、origin/main の状態に戻す。 Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
squne121
left a comment
There was a problem hiding this comment.
LOOP_VERDICT_V2
schema: LOOP_VERDICT_V2
verdict: APPROVE
merge_ready: true
reviewed_head_sha: "c0da7903041dbc1e7484f08346d1066e0653d6fd"
iteration: 2
required_auto_actions: []
allowed_paths_gate:
status: ok
changed_files: 19
all_within_allowed_paths: true
producer_role: review_subagent
worker_report_used_as_canonical: false
gate_result: ALLOWED_PATHS_GATE_RESULT_V1
expected_contract_fingerprint: "sha256:81fc84600ded1fc0ec20c5021ba927f2233700b4af0d819b3373cd5a8c80f01a"
contract_source_kind: issue_comment
contract_source_id: "4755558142"
note: "body_sha256 は contract 生成後に issue が更新されたため現 body と不一致だが、AC/Scope の実質変更はなく(チェックボックス未変更・Stop Conditions 追加のみ)、indeterminate 扱いとしない。Allowed Paths 全 19 ファイルを独立照合し全 OK。"
merge_state_status: BLOCKED
mergeable: MERGEABLE
blockers: []
ci:
build: pass
typecheck: pass
test: pass
lint: pass
e2e: pass
python-test: pass
actionlint: pass
ci-verdict-summary: pass
notes: |
B1–B7 全 blocker の修正を実装で確認した。
B1(AC10 header 2-pass render): renderSafetyHeader が 2-pass 構成に変更済み。
1st pass で placeholder、body render 後に実測 rendered_chars / sources / omitted_sections で
2nd pass を実行している。chatgpt-context-header.test.ts が
safety.* / budget.* / sources / omitted_sections の全必須フィールドをアサートしている。
B2(budget 最終出力長保証): assertBudgetSufficient に source_manifest を追加済み。
omission report 追加後に bundleMarkdown.length > budget.maxChars を再検証し、
超過時に budget.too_small を投げる。
B3(source provenance / digest pinning): loadSources が論理 source_ref (basename のみ) を
使用し、絶対 path を bundle に出さない。applyPublicSafetyScan が全 source kind に適用。
scanPublicSafety を agent-run-report-validation.mjs から dynamic import している。
B4(既存 validator gate 組み込み): chatgpt-context-source-loader.mjs の applyPublicSafetyScan
が全 source kind に scanPublicSafety を適用。module 不在時のみ graceful skip。
B5(injection-safe rendering 強化): INJECTION_PATTERNS に HTML comment / system: prefix /
YAML front matter を追加。MARKDOWN_LINK_INJECTION_PATTERNS(javascript: / data: / local path link)、
LOCAL_PATH_PATTERNS、SECRET_PATTERNS(sk- / github_pat_ / ghp_ / bare 40+hex)を独立 array として定義。
外部由来テキストは wrapAsDataBlock で DATA fenced block 化。
B6(evidence dedupe 出力契約): dedupeEvidenceRefs が canonical_key_digest / used_by_sections /
duplicate_of を全 ref に付与。renderEvidenceRefs が unique / duplicate 双方を DATA block で出力。
fragment_id を canonicalizeUrl が構造化抽出し dedupe key に含める。
B7(transcript hotspot evidence_digest 必須化): validateTranscriptHotspots が
evidence_digest の存在と sha256:<64hex> 形式を検証する。
High(summary output_path 絶対 path 削除): summary.output_path を output_basename に変更。
scanRenderedMarkdown を summary JSON serialization にも適用。
High(sort contract 契約化): sortRunReports コメントと実装が
source_ref/path → run_id → started_at の 3-key 優先順位で一致。
merge_state_status が BLOCKED なのは branch protection required check 待ちであり、
実装上のブロッカーではない。全 CI ジョブ pass 確認済み。
mergeStateStatus: BLOCKED、mergeable: MERGEABLE。
post-merge-cleanup: 完了
FOLLOW_UP_MATERIALIZATION_RESULT_V1:
schema_version: 1
materialized_by: post-merge-cleanup
follow_up_issues: []
note_only_observations: [] |
概要
Closes #939(Issue #939 を完了する)
ChatGPT 投入用 context bundle を生成する
export-chatgpt-context.mjsと関連ライブラリを追加する。docs/dev/agent-run-report.mdを新規作成する(export surface の説明)変更ファイル
Allowed Paths 内(contract 準拠):
scripts/agent-logs/export-chatgpt-context.mjs— CLI エントリポイントscripts/agent-logs/lib/chatgpt-context-args.mjs— 引数パースscripts/agent-logs/lib/chatgpt-context-source-loader.mjs— ソース読み込み・forbidden field スキャン・digest 計算scripts/agent-logs/lib/chatgpt-context-safety-scan.mjs— injection スキャン・DATA block ラップscripts/agent-logs/lib/chatgpt-context-dedupe.mjs— evidence ref canonicalization + dedupescripts/agent-logs/lib/chatgpt-context-budget.mjs— priority-aware budget allocationscripts/agent-logs/lib/chatgpt-context-renderer.mjs— Markdown セクションレンダラーtests/agent-logs/chatgpt-context-*.test.ts— 11 本のテストファイルdocs/dev/agent-run-report.md— docs 追記AC 対応表
chatgpt-context-source-loader.mjsのscanForForbiddenFieldschatgpt-context-redaction.test.tschatgpt-context-budget.mjsのapplyBudget/SECTION_PRIORITY_ORDERchatgpt-context-budget.test.tsapplyBudgetのomitted出力(section_id/reason/priority/original_chars/omitted_digest)chatgpt-context-omission.test.tsexport-chatgpt-context.mjsのsortRunReports+loadSourcesの path sortchatgpt-context-sort.test.tschatgpt-context-dedupe.mjsのdedupeEvidenceRefs/buildDedupeKeychatgpt-context-dedupe-canonical.test.tsassertBudgetSufficientchatgpt-context-budget-too-small.test.tsvalidateTranscriptHotspots+ forbidden field scanchatgpt-context-transcript-boundary.test.tsloadSourcesの manifest 生成chatgpt-context-provenance.test.tschatgpt-context-safety-scan.mjs+renderSafetyHeaderchatgpt-context-injection.test.ts+chatgpt-context-rendered-scan.test.tsrenderSafetyHeaderのchatgpt_context_bundle/v1YAML blockchatgpt-context-header.test.ts検証結果
pnpm typecheck: 合格pnpm test(既存 781 テスト): 合格pnpm lint: pre-existing 問題のみ(playwright-report/trace + tsconfigRootDir — contract でgo_pre_existing)pnpm build: worktree 内では正常(main tree の root 所有 dist/assets EACCES は既知 env 問題)Allowed Paths 準拠確認
全変更ファイルが contract の Allowed Paths 内に収まることを確認した。
🤖 Claude Code で生成