Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "#242"
goal_ref: "既存 scripts/lib/agent-session-manifest-validation.mjs semantic validator と scripts/extract-agent-session-manifest-from-comment.mjs extractor を再利用した pnpm manifest:check entrypoint と CI gate を追加し、main にマージされる manifest の品質を保証する"
change_kind: codeParent Issue
Parent Goal Ref
- Goal: agent_session_manifest producer (Issue A) の出力を schema 検証し、GitHub に載る manifest の品質を保証する
- Desired Destination: CI pipeline に
pnpm manifest:checkを組み込み、invalid manifest を reject する gate
Current Validated Scope
pnpm manifest:checkscript の新規追加scripts/check-agent-session-manifests.mjsの新規追加(既存scripts/lib/agent-session-manifest-validation.mjsとscripts/extract-agent-session-manifest-from-comment.mjsを import する thin wrapper).github/workflows/ci.ymlのtestjob へのpnpm manifest:check統合- marker 付き GitHub comment fixture からの extractor → validator roundtrip テスト
Remaining Parent Gaps
- producer 本体実装 (Issue A)
- no-push / private checkpoint verifier (Issue C)
- Kill Switch runtime smoke (Issue D)
Outcome
既存 shared validation module (scripts/lib/agent-session-manifest-validation.mjs) と extractor (scripts/extract-agent-session-manifest-from-comment.mjs) を thin wrapper から呼ぶ pnpm manifest:check entrypoint を追加し、.github/workflows/ci.yml の test job に統合することで、main にマージされる manifest の品質を CI で保証する状態。
visibility: public_github_comment での source_kind: transcript / local_file 拒否に加え、redaction / raw transcript / local absolute path / secret-like metadata の semantic violation も fail-close する。明示 target 指定で対象 0 件のときは fail(空検査 green を禁止)。
#426 が生成する session-manifest artifact が存在する場合は validate 対象とし、無い場合も docs/schemas/examples と tests/fixtures の static 検査で常時 green を担保する。
In Scope
package.jsonへの"manifest:check"script 追加scripts/check-agent-session-manifests.mjsの新規追加(既存scripts/lib/agent-session-manifest-validation.mjsとscripts/extract-agent-session-manifest-from-comment.mjsを import し、JSON manifest と marker 付き GitHub comment fixture の双方を validate する thin wrapper)- 既定 target:
docs/schemas/examples/**/*.json,tests/fixtures/**/agent-session-manifest*.{json,md}、環境変数 or option 指定があれば追加 glob - 明示 target 指定時に対象 0 件なら exit 1
.github/workflows/ci.ymlのtestjob 内にpnpm manifest:checkを追加tests/**にmanifest:checkentrypoint の positive/negative fixture テスト追加(marker 付き comment fixture からの extractor → validator roundtrip を含む)
Out of Scope
- validator / extractor / shared validation module の再実装または semantic rule の追加(schema 変更を含む)
agent-session-manifest.schema.jsonの変更- producer 本体実装(実装: agent_session_manifest/v1 deterministic script producer を schema conform で実装する #377 で完了済み)
- producer の hook 起動 / session-manifest workflow / artifact 生成(実装: agent_session_manifest/v1 producer を .claude/settings.json hooks と .github/workflows で自動 invoke する #402 / PR feat(#402): wire agent_session_manifest/v1 producer to hooks and CI #426 の責務)
- GitHub branch protection で required check に昇格させる作業
- no-push verifier (Issue C) / Kill Switch smoke (Issue D)
Acceptance Criteria
- AC1:
pnpm manifest:checkがpackage.jsonに登録されている - AC2:
scripts/check-agent-session-manifests.mjsが存在し、scripts/lib/agent-session-manifest-validation.mjsとscripts/extract-agent-session-manifest-from-comment.mjsを import している(新規 validator は実装しない) - AC3: valid JSON manifest fixture を渡すと exit 0
- AC4: invalid JSON manifest fixture(必須フィールド欠落 / schema 違反)で exit 1
- AC5: GitHub Issue / PR comment fixture(
<!-- agent_session_manifest:v1 start -->/<!-- agent_session_manifest:v1 end -->marker と dynamic fence で囲まれた manifest)を extractor で抽出 → validator で validate できる。複数 marker / 欠落 marker / fence mismatch / malformed JSON は exit 1 - AC6:
visibility: public_github_commentでevidence.source_kind: transcriptまたはlocal_fileを含む manifest で exit 1 - AC7:
redaction.raw_transcript_included: true/visibility: public_github_commentかつredaction.local_paths_included: trueで exit 1 - AC8:
producer.command/producer.source_ref/evidence.source_refに絶対パス(/home/,/Users/,C:\)やsecret/token/api[_-]?key様の値が混入したら exit 1 - AC9:
token_usage.availability: unavailableのとき token count フィールドが0ではなくnullであることを要求(違反で exit 1) - AC10:
verification.skipped_count > 0かつverification.overall: passの組合せで exit 1 - AC11: 明示 target glob 指定で対象 0 件のとき exit 1
- AC12: validation failure 時に field / expected / actual を含む detailed error message を stderr に出力
- AC13:
.github/workflows/ci.ymlのtestjob 内でpnpm manifest:checkが呼ばれる - AC14:
pnpm typecheckが pass する - AC15:
pnpm lintが pass する - AC16:
pnpm testが pass する - AC17:
pnpm buildが pass する
Verification Commands
# AC1: pnpm manifest:check が登録
$ rg -n '"manifest:check"' package.json
# AC2: thin wrapper が存在する(既存 validator/extractor module の import は PR review で確認)
$ test -f scripts/check-agent-session-manifests.mjs
# AC3: valid JSON manifest fixture が exit 0 で pass する test case が manifest:check entrypoint に存在する
$ rg -n "manifest:check.*valid fixture|valid fixture.*manifest:check" tests/
# AC4: invalid JSON manifest fixture が exit 1+ で fail する test case が manifest:check entrypoint に存在する
$ rg -n "manifest:check.*invalid schema|invalid schema.*manifest:check" tests/
# AC5: comment marker roundtrip (extractor→validator) の test case が manifest:check entrypoint に存在する
$ rg -n "manifest:check.*marker roundtrip|marker roundtrip.*manifest:check" tests/
# AC6: public_github_comment + transcript/local_file 拒否の test case が manifest:check entrypoint に存在する
$ rg -n "manifest:check.*public_github_comment|public_github_comment.*manifest:check" tests/
# AC7: redaction.raw_transcript_included / local_paths_included 違反拒否の test case が manifest:check entrypoint に存在する
$ rg -n "manifest:check.*redaction violation|redaction violation.*manifest:check" tests/
# AC8: secret / local absolute path leakage 検出の test case が manifest:check entrypoint に存在する
$ rg -n "manifest:check.*leakage|leakage.*manifest:check" tests/
# AC9: token_usage.availability=unavailable と token count null 要求の test case が manifest:check entrypoint に存在する
$ rg -n "manifest:check.*token_usage availability|token_usage availability.*manifest:check" tests/
# AC10: verification.skipped_count vs overall=pass の組合せ拒否 test case が manifest:check entrypoint に存在する
$ rg -n "manifest:check.*skipped vs pass|skipped vs pass.*manifest:check" tests/
# AC11: explicit target glob 0 件で exit 1 の test case が manifest:check entrypoint に存在する
$ rg -n "manifest:check.*empty target|empty target.*manifest:check" tests/
# AC12: detailed error message (field / expected / actual) の test case が manifest:check entrypoint に存在する
$ rg -n "manifest:check.*detailed error|detailed error.*manifest:check" tests/
# AC13: ci.yml の test job 内で manifest:check が呼ばれる
$ rg -n "manifest:check" .github/workflows/ci.yml
# AC14: typecheck (regression_gate)
$ pnpm typecheck
# AC15: lint (regression_gate)
$ pnpm lint
# AC16: test (regression_gate)
$ pnpm test
# AC17: build (regression_gate)
$ pnpm buildAllowed Paths
scripts/check-agent-session-manifests.mjs(新規)package.json(manifest:checkscript 追加のみ).github/workflows/ci.yml(manifest:check追加のみ)tests/agent-session-manifest-check.test.ts(新規)tests/fixtures/agent-session-manifest/**(新規 fixture)scripts/validate-agent-session-manifest.mjs,scripts/extract-agent-session-manifest-from-comment.mjs,scripts/lib/agent-session-manifest-validation.mjs,docs/schemas/agent-session-manifest.schema.json(参照のみ。変更禁止)
Stop Conditions
- Allowed Paths 外への変更が必要と判明
- In Scope の固定契約の変更が必要
- new Issue 起票が必要と判明
- nested SubAgent delegation が必要
- 外部サービス利用・権限昇格が必要
pnpm typecheck/lint/test/buildのいずれかが fail した場合- 既存 validator / extractor / shared module の semantic rule を変更する必要が判明したら停止し、別 Issue へ
agent-session-manifest.schema.jsonの変更が必要と判明したら停止.github/workflows/ci.ymlの test job 以外(typecheck/lint/build)の job 変更が必要なら停止
Runtime Verification Applicability
decision: not_applicable
rationale: 全 AC が決定論的 script verification (rg / test -f / pnpm typecheck/lint/test/build) で成立し、外部 CLI / auth / network / fallback semantics を伴わない。意味論検証は新規 vitest テストケース内で実行され、pnpm test (AC16) regression gate に包含される。SKIP exit 77 / _*_fallback: true 経路は本 Issue のスコープに存在しない。
Related
- Parent: docs: session 記録 Kill Switch policy と検証コマンド整備 (session-recording-policy.md) #242 (CLOSED)
- Depends on: PR feat(#377): implement agent_session_manifest/v1 deterministic script producer #404 (MERGED), PR feat(#401): add producer provenance object to manifest schema #409 (MERGED)
- Coordinates with: 実装: agent_session_manifest/v1 producer を .claude/settings.json hooks と .github/workflows で自動 invoke する #402 (OPEN), PR feat(#402): wire agent_session_manifest/v1 producer to hooks and CI #426 (DRAFT) — producer hook wiring と artifact 生成は 実装: agent_session_manifest/v1 producer を .claude/settings.json hooks と .github/workflows で自動 invoke する #402/feat(#402): wire agent_session_manifest/v1 producer to hooks and CI #426 の責務
- Sibling: 実装: session-recording-policy skill を作成して操作手順を標準化する #326 (OPEN), Issue C / D / E
Source
source: refinement_loop_rewrite_from_followup
origin_issue: "#326"
anchor_comment_url: "https://github.com/squne121/loop-protocol/issues/326#issuecomment-4528499380"
dedupe_key: "326-followup-B"Required Skills
- なし(implementation issue)
Activity
squne121 commentedon May 27, 2026
結論
Issue #378 はそのまま実装開始すると高確率で二重実装・誤ったCI接続・偽陽性のgreen checkを作る。現状のままなら BLOCK / 要Issue再整形 が妥当です。
#378 は「
pnpm manifest:checkを追加し、validator/parser を新規実装し、CIに統合する」Issueですが、関連Issue/PRの後続状態を見ると、validator・extractor・Ajv 2020-12 設定・producer semantic validation は既に #377 / PR #404 / PR #409 でかなり実装済みです。したがって #378 の実体は「新規validator実装」ではなく、既存 validator/extractor を使ったmanifest:checkentrypoint と CI enforcement の追加に縮退させるべきです。([GitHub]1)BLOCKER 1: Issue本文が現在のmainとズレている
#378 は
scripts/validate-agent-session-manifest.mjsと GitHub comment parser を「新規実装」としていますが、PR #404 は既にscripts/validate-agent-session-manifest.mjs、scripts/extract-agent-session-manifest-from-comment.mjs、tests/agent-session-manifest-producer.test.tsを追加したと記録しており、mainにも validator が存在します。validator は Ajv 2020-12 と semantic validation を行うと明記されています。([GitHub]1)一方で、現在の
package.jsonにはdev/test/typecheck/lint/build/preview/policy:*はあるが、manifest:checkはまだありません。つまり #378 の残件は **「validatorを書く」ではなく「既存validatorを包むmanifest:checkを定義し、CIで実行する」**です。([GitHub]2)BLOCKER 2: Verification Command が Vitest とCI実体に合っていない
#378 の AC5 は
pnpm test -- --testPathPattern="manifest.*comment"を指定していますが、これは Jest 由来の発想です。Vitest の公式ガイドは、ファイル名で絞る場合は filename pattern をCLI引数として渡し、テスト名で絞る場合は-t/--testNamePatternを使うと説明しています。--testPathPattern前提のVCは不正確です。([GitHub]1)修正案:
また、#378 は
.github/workflows/test.yml/.github/workflows/python-test.ymlをgrep対象にしていますが、現在のworkflowは.github/workflows/ci.ymlで、Node系のtestjob と Python系のpython-testjob が同一ファイル内にあります。VCは.github/workflows/ci.ymlを検査対象にすべきです。([GitHub]1)BLOCKER 3: #402 / PR #426 と責務が衝突する
#402 は producer を
.claude/settings.jsonhooks と GitHub Actions artifact workflow から自動起動するIssueで、manifestを private artifact に出す設計です。PR #426 は draft 状態で、.github/workflows/session-manifest.yml、upload-artifact、stdout/comment禁止などを追加する内容です。([GitHub]3)#378 が独立にCIへ
manifest:checkを入れるだけだと、以下のどちらかになります。したがって #378 は #402/#426 の後続として、少なくとも以下を明記すべきです。
HIGH: schema validation だけでは security gate として弱い
agent_session_manifest/v1の schema docs は、visibility: public_github_commentの場合にsource_kind: transcript/local_fileを禁止するとしています。これは JSON Schema の if/then で機械検証される設計です。([GitHub]4)ただし #378 の目的は security label 付きの gate なので、JSON Schema だけでは足りません。既存 validator は producer がある場合に actor/evidence subset、
producer.kindとevidence.source_kindの対応、verification semantic rule なども検査しています。#378 はこの既存 semantic validator を必ず使うべきで、単純な Ajv CLI ラッパーに戻してはいけません。([GitHub]5)最低限、
manifest:checkは次を fail-close で見るべきです。HIGH: comment parser の仕様は「fenced code block」ではなく marker付きcontractに寄せるべき
#378 は「markdown fenced code block 内の manifest」を抽出するとだけ書いていますが、既存 extractor は
<!-- agent_session_manifest:v1 start -->/endmarker と、最低4バッククォート以上の動的fence長を前提にしています。これは単なる「最初の ```json を拾う」実装より安全です。([GitHub]6)#378 のAC5は次のように書き換えるべきです。
既存テストにも fenced markdown roundtrip はあります。#378 ではこのテストを再実装するのではなく、
manifest:checkentrypoint 経由で同じ保証が効くことを追加テストするべきです。([GitHub]7)修正後のIssueスコープ案
#378 はこう縮めるのが安全です。
GitHubコメント案
最終判定: 要再整形。実装開始不可。
squne121 commentedon May 27, 2026
Contract Snapshot (2026-05-27T20:59:00Z)
pnpm manifest:checkentrypoint と CI test job 統合を追加し、main にマージされる manifest 品質を CI で保証するscripts/check-agent-session-manifests.mjs/package.json/.github/workflows/ci.yml/tests/agent-session-manifest-check.test.ts/tests/fixtures/agent-session-manifest/**.claude/worktrees/issue-378-agent-session-manifest-producer-outputworktree-issue-378-agent-session-manifest-producer-outputsqune121 commentedon May 27, 2026
implement-issue: 実装完了 (2026-05-27T21:12:16Z)
.claude/worktrees/issue-378-agent-session-manifest-producer-outputworktree-issue-378-agent-session-manifest-producer-outputfix: B1 inline markdown extraction を extractor subprocess integration…
fix: manifest:check B1 unsupported-file gate + NB1 unknown-option exi…
squne121 commentedon May 27, 2026
implement-issue iter2: 修正完了 (2026-05-28T06:36:30Z)
worktree-issue-378-agent-session-manifest-producer-output対応内容
B1 (blocker): explicit target に unsupported ファイル(.txt 等)が含まれる場合 exit 1 で fail-closed。supported file が 0 件の場合も "no supported manifest files were validated" で exit 1。regression tests 2 件追加。
B2 (blocker): PR 本文を scope-down("producer output の CI gate" → "schema/examples/fixtures の CI validation gate (pre-gate)")。follow-up Issue #434 を起票し PR 本文の Related follow-ups セクションに記載。
NB1: --help 以外の未知 -- option を exit 2 で reject。テスト 1 件追加。
NB3:
execFileSyncの maxBuffer を 10MB に明示。NB5: Safety Claim Matrix を canonical 5-column 形式(Claim ID / Claim / Threat Model / Mitigation / Evidence)へ書き換え。
NB2: Out of Scope として PR 本文に Note を記載(別 Issue 化)。
検証結果
pnpm typecheck: PASSpnpm lint: PASSpnpm test: 75/75 PASS(既存 72 + 新規 3)pnpm build: PASSfollow-up Issue
feat: pnpm manifest:check entrypoint と CI gate を追加する (#378) (#431)