Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "#242"
goal_ref: "session recording policy — producer が schema contract の secret_policy フィールドを実際に出力する"
change_kind: codeParent Issue
Parent Goal Ref
- Goal: session recording policy の整備(Kill Switch / secret boundary / producer-consumer contract)
- Desired Destination: docs: session 記録 Kill Switch policy と検証コマンド整備 (session-recording-policy.md) #242 配下の子 Issue として session recording 関連の実装を完結させる
Current Validated Scope
scripts/generate-session-manifest.mjsにsecret_policyフィールドの出力を追加する
Remaining Parent Gaps
- なし(本 Issue 完了で docs: session 記録 Kill Switch policy と検証コマンド整備 (session-recording-policy.md) #242 の secret_policy producer gap が解消される)
Outcome
scripts/generate-session-manifest.mjs が生成する manifest JSON に secret_policy フィールド(value_exposed: false / boundary_enforced: true / mode: "presence_only")が含まれるよう実装され、pnpm test が PASS した状態でコミットが存在する。
boundary_enforced: true は static producer contract(「このスクリプトが生成する manifest は secret boundary 前提の contract に従う」という宣言)であり、runtime attestation(hook が実際にこのプロセス中に実行されたという証拠)ではない。
Background
PR #495(Issue #412)で docs/schemas/agent-session-manifest.schema.json に secret_policy フィールドを追加し、schema contract test で代替された。しかし producer である scripts/generate-session-manifest.mjs は #412 の Allowed Paths 外のため実際の出力には含まれていない。本 Issue はその follow-up として producer 側の実装を行う。
origin PR: #495
source: post_merge_cleanup
origin_pr: "https://github.com/squne121/loop-protocol/pull/495"
dedupe_key: "follow-up:squne121/loop-protocol:pr/495:secret-policy-producer-output"注意: docs/schemas/agent-session-manifest.schema.json の top-level required 配列には secret_policy が含まれていない(optional フィールド)。そのため schema validation だけでは producer が secret_policy を必ず出力することを保証できない。保証は producer regression test(tests/agent-session-manifest-producer.test.ts)の明示 assertion で行う。
In Scope
scripts/generate-session-manifest.mjsにsecret_policyフィールドの出力を追加する(固定値:value_exposed: false/boundary_enforced: true/mode: "presence_only")boundary_enforced: trueは static producer contract として追加する。runtime attestation ではないため、コード中にコメントで明示すること
tests/agent-session-manifest-producer.test.tsにsecret_policyフィールドの deep-equal assertion を追加する(schema validation ではなく producer 出力 JSON の構造を直接検証する)
Out of Scope
docs/schemas/agent-session-manifest.schema.jsonの変更(feat(#412): secret boundary guard — fail-closed PreToolUse hook + deny entries + tests #495 で実施済み)secret_policyフィールドの値をランタイム引数から受け取る動的化- 他の producer / consumer スクリプトへの同フィールド追加
- schema の top-level
requiredへのsecret_policy追加(別 follow-up で扱う) scripts/lib/agent-session-manifest-validation.mjsの修正
Acceptance Criteria
- AC1:
scripts/generate-session-manifest.mjsが出力する manifest JSON にsecret_policy.value_exposedキーが存在する - AC2:
secret_policy.value_exposedの値がfalseである - AC3:
secret_policy.boundary_enforcedの値がtrueである(static producer contract として実装されること) - AC4:
secret_policy.modeの値が"presence_only"である - AC5:
tests/agent-session-manifest-producer.test.tsにsecret_policyの deep-equal assertion が追加されている - AC6:
pnpm testが全件 PASS する(新規のsecret_policydeep-equal assertion を含む) - AC7:
pnpm typecheckがエラーなしで完了する
Verification Commands
# AC1
$ rg -c "secret_policy" scripts/generate-session-manifest.mjs
# AC2
$ rg -n "value_exposed" scripts/generate-session-manifest.mjs
# AC3
$ rg -n "boundary_enforced" scripts/generate-session-manifest.mjs
# AC4
$ rg -n "presence_only" scripts/generate-session-manifest.mjs
# AC5
$ rg -n "secret_policy" tests/agent-session-manifest-producer.test.ts
# AC6
$ pnpm test
# AC7
$ pnpm typecheckRuntime Verification Applicability
decision: not_applicable
reason: "全 VC コマンド(rg / pnpm test / pnpm typecheck)は CI で実行可能。runtime-only 環境は不要。"Allowed Paths
scripts/generate-session-manifest.mjstests/agent-session-manifest-producer.test.ts
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
boundary_enforced: trueが「secret_boundary_guardhook が実際にこのプロセス中に実行された」ことの runtime proof として意味する必要があると判明した場合 → この Issue を停止し、hook/wrapper/CI attestation の follow-up Issue を別途起票する
Required Skills
- Node.js / ESM (
.mjs) - JSON Schema (agent-session-manifest.schema.json)
Scope Delta(任意)
N/A
Delivery Rule
1 Issue = 1 PR。Draft PR で開始し、AC が全件 PASS したらレビュー依頼する。
Activity
squne121 commentedon May 31, 2026
判定
REQUEST_CHANGES 寄り。
Issue #500 の問題設定自体は妥当です。現在の
generate-session-manifest.mjsは manifest 本体にproducerとredactionを出している一方、secret_policyを出していません。Issue #500 は、PR #495 / Issue #412 で schema 側に追加されたsecret_policyを producer 出力にも反映するための follow-up と整理されています。([GitHub]1)ただし、このまま実装すると「セキュリティ境界が実際に効いていた」という未検証の自己申告フィールドを成果物に混ぜる危険があります。 特に
boundary_enforced: trueは、schema 上「secret_boundary_guardPreToolUse hook がこの session 中に active だったか」を意味する説明になっていますが、単体 producer は hook 実行状態を観測していません。([GitHub]2)主要な敵対的レビュー
1.
boundary_enforced: trueは producer 単体では実証不能#500 は固定値として以下を要求しています。
{ "secret_policy": { "value_exposed": false, "boundary_enforced": true, "mode": "presence_only" } }しかし、
boundary_enforcedが「実際に guard が走った」ことを表すなら、scripts/generate-session-manifest.mjsに固定値でtrueを入れるのは危険です。Claude Code hook は PreToolUse で exit code 2 を返すと tool call を block できますが、それは hook 実行系の事実であって、JSON producer が単独で知れる事実ではありません。([Claude Code]3)修正要求: #500 の contract を次のどちらかに明確化すべきです。
boundary_enforced: trueは「この producer contract は secret boundary 前提で生成される」という静的 contract 表示であり、runtime attestation ではない。現状のままでは、単に
node scripts/generate-session-manifest.mjsを手元実行してもboundary_enforced: trueが出るため、監査ログとしては過大主張になります。2. schema は
secret_policyの存在を強制していない#500 は schema 変更を out-of-scope にしていますが、現行 schema の top-level
requiredにはsecret_policyが含まれていません。また JSON Schema / Ajv では、propertiesに定義しただけではその property は必須にならず、必須化にはrequiredが必要です。([GitHub]2)さらに、
secret_policyオブジェクト内にもvalue_exposed/boundary_enforced/modeのrequiredが見当たりません。つまり schema contract test だけでは「producer が必ず完全なsecret_policyを出す」ことを保証できません。([GitHub]2)修正要求: #500 の AC に、schema validation ではなく producer 出力 JSON の deep-equal regression test を明示してください。schema を強くするのは別 follow-up でもよいですが、その場合は #500 の完了条件に「schema は必須化しないため producer test で担保する」と明記すべきです。
3. Verification が
rg中心で弱すぎる#500 の検証コマンドは
rg "secret_policy|value_exposed|boundary_enforced|presence_only"とpnpm typecheck/testが中心です。これは「文字列がリポジトリ内に存在する」ことしか証明せず、「manifest 出力に正しい JSON として入る」ことを証明しません。([GitHub]4)最低限、以下のような executable verification が必要です。
加えて、
github-comment形式を producer がサポートしているなら、コードフェンス内 JSON にも同一 field が出ることを確認すべきです。artifact-only / no public comment という #402 の安全境界と衝突しない範囲で、出力形式ごとの regression test を置くのが妥当です。([GitHub]5)4. 既存の semantic validator が
secret_policyを見ていない現状、
scripts/lib/agent-session-manifest-validation.mjsにはsecret_policyの参照が見つかりませんでした。([GitHub]6)#500 の Allowed Paths は
scripts/generate-session-manifest.mjsと generate 関連 tests に絞られているため、validator 側で「欠落を fail する」修正はこの Issue の範囲外に見えます。([GitHub]4)修正要求: #500 では validator をいじらず、
tests/agent-session-manifest-producer.test.tsに producer 出力の明示 assertion を足すのが安全です。tests tree には当該 producer test が存在するため、そこが最短の受け皿です。([GitHub]7)5.
value_exposed: falseは必要条件であって十分条件ではないIssue #412 / PR #495 は、secret value を manifest/log/artifact に出さないため、PreToolUse guard、workflow の
secrets.非参照、sentinel test、構造 assertion を要求していました。([GitHub]8)GitHub Actions 側でも、secret の自動 redaction は万能ではなく、変換・エンコード済み secret や stdout/stderr 経由の露出に注意が必要です。([GitHub Docs]9)
修正要求:
secret_policy.value_exposed: falseを追加しても、既存の fail-closed secret detection / sentinel test / no-log 方針を弱めてはいけません。特に producer test では、secret_policy追加により既存のredactionや secret detection の挙動が変わっていないことを確認すべきです。推奨する実装形
manifest組み立ての近くに定数を置き、typo と accidental mutation を避ける形がよいです。manifest には
redactionの直前あたりに追加。ただし、コメントで以下を明示してください。
// Static producer contract. This does not attest that the hook ran in this process.このコメントがないと、将来の reviewer が
boundary_enforcedを runtime evidence と誤読します。#500 の Issue 本文に入れるべき修正
AC を次のように強化してください。
--format jsonの producer 出力にsecret_policyが deep-equal で存在する。--validate付き実行で schema validation が通る。secret_policyassertion を追加する。github-comment形式が JSON manifest を含むなら、その JSON にも同一 field がある。secret_policy追加後も secret sentinel / redaction 系 test は pass する。boundary_enforcedは runtime attestation ではなく static producer contract である、と Issue に明記する。Stop Conditions も追加すべきです。
最終評価
#500 は「schema にある field を producer が出していない」という実装ギャップを閉じる Issue としては正しいです。
ただし、現在の文面は 固定 JSON 追加だけで security boundary が実証されたように見える ため、そのまま merge すると監査上の意味が濁ります。
結論としては、実装は小さいが contract の文言と test が弱い。
PR 化するなら、
boundary_enforcedの意味を static contract に限定し、rgではなく producer 出力の deep-equal test で完了判定するべきです。squne121 commentedon May 31, 2026
Contract Snapshot (2026-05-31T03:28:00Z)
scripts/generate-session-manifest.mjsが生成する manifest JSON にsecret_policyフィールド(value_exposed: false/boundary_enforced: true/mode: "presence_only")が含まれ、pnpm testが PASS した状態でコミットが存在するsecret_policyフィールド存在・各値・deep-equal assertion・pnpm test PASS・pnpm typecheck PASS)scripts/generate-session-manifest.mjs,tests/agent-session-manifest-producer.test.ts.claude/worktrees/issue-500-generate-session-manifest-mjs-secret-polworktree-issue-500-generate-session-manifest-mjs-secret-polsqune121 commentedon May 31, 2026
implement-issue: 実装完了 (2026-05-31T12:32:00Z)
.claude/worktrees/issue-500-generate-session-manifest-mjs-secret-polworktree-issue-500-generate-session-manifest-mjs-secret-polsqune121 commentedon May 31, 2026
Stop Condition 発動
boundary_enforced: trueが schema 上 "secret_boundary_guard PreToolUse hook was active during this session" という runtime attestation に読める状態のまま、static producer contract として固定値trueを出す実装をマージすることは、security telemetry の意味論的 greenwashing になるため、本 Issue を停止します。発動 Stop Condition
状況
secret_policyを出す)は満たしているschema.jsonのboundary_enforceddescription は runtime attestation を意図している次アクション
secret_policy.boundary_enforcedの意味論再設計(runtime と static の分離)feat(#500): replace boundary_enforced with producer_contract + runtim…
squne121 commentedon May 31, 2026
implement-issue: 再実装完了 (2026-05-31 — producer_contract + runtime_boundary 対応)
前回の Stop Condition(boundary_enforced の意味論衝突)を解消。
PR #537(#536)でスキーマが
producer_contract + runtime_boundary構造に分割されたため、worktree を main にマージして producer 出力を新スキーマに合わせた。.claude/worktrees/issue-500-generate-session-manifest-mjs-secret-polworktree-issue-500-generate-session-manifest-mjs-secret-polfeat(#500): replace boundary_enforced with producer_contract + runtim…