Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "#242"
goal_ref: "secret_policy.boundary_enforced の意味論を runtime と static に分離し、schema description と producer behavior を一致させる"
change_kind: code+docsParent Issue
Parent Goal Ref
- Goal: session recording policy の整備(Kill Switch / secret boundary / producer-consumer contract)
- Desired Destination:
boundary_enforcedの意味論曖昧性を解消し、consumer が runtime 証拠と static 宣言を混同しない schema contract を確立する
Background
PR #532(Issue #500 follow-up)で scripts/generate-session-manifest.mjs に secret_policy.boundary_enforced: true を固定値で追加した。しかし docs/schemas/agent-session-manifest.schema.json の boundary_enforced description は "secret_boundary_guard PreToolUse hook was active during this session" と runtime attestation を意図している。
実装コメントは static producer contract と明記しているが、schema description との乖離が security telemetry の greenwashing リスクを生む。Issue #500 の Stop Condition が発動し、PR #532 は as-is merge しない判断となった。
origin PR: #532
origin Issue: #500
source: stop_condition
origin_pr: "https://github.com/squne121/loop-protocol/pull/532"
dedupe_key: "follow-up:squne121/loop-protocol:pr/532:boundary-enforced-semantics"Current Validated Scope
docs/schemas/agent-session-manifest.schema.json の secret_policy フィールド定義を再設計し、runtime attestation と static producer contract を明示的に分離する。
Remaining Parent Gaps
- PR feat(#500): replace boundary_enforced with producer_contract + runtime_boundary in secret_policy #532 の実装が使えるかは本 Issue 完了後の schema に合わせて判断する
Outcome
docs/schemas/agent-session-manifest.schema.json の secret_policy フィールドが再設計され、pnpm test が PASS した状態でコミットが存在する。
本 Issue は schema-only(Option A)。producer 実装変更(scripts/generate-session-manifest.mjs)は別 Issue で行う。
runtime_boundary の設計例(if/then で attested: true のとき evidence_ref を必須化):
"runtime_boundary": {
"type": "object",
"required": ["attested"],
"properties": {
"attested": {
"type": "boolean",
"description": "Whether runtime secret boundary enforcement was actually attested for this session."
},
"evidence_ref": {
"type": ["string", "null"],
"description": "Reference to runtime evidence when attested is true."
}
},
"allOf": [
{
"if": {
"properties": { "attested": { "const": true } },
"required": ["attested"]
},
"then": {
"required": ["evidence_ref"],
"properties": {
"evidence_ref": { "type": "string", "minLength": 1 }
}
}
}
]
}In Scope
docs/schemas/agent-session-manifest.schema.jsonのsecret_policyフィールド定義を再設計する(runtime / static 分離)- 現行の
boundary_enforcedフィールドを schema から廃止する producer_contract/runtime_boundaryの新フィールドを別 object として schema に追加する(description / type / required を明示)runtime_boundary.attested: trueの場合evidence_refを非空 string 必須とする制約をif/thenで schema に追加する- schema contract test を新定義に合わせて更新する(valid / invalid fixtures 追加)
docs/dev/secret-policy.mdに意味論分離の方針を追記する(任意)
Out of Scope
scripts/generate-session-manifest.mjsの producer 実装変更(schema 確定後の別 Issue)secret_boundary_guardhook の runtime attestation 実装(別 Issue)- 他 producer / consumer スクリプトへの横展開
注意: PR #532(producer に旧形状の
boundary_enforced: trueを追加)は本 Issue のスキーマ完了まで merge しない。新スキーマ確定後、PR #532 を rebase または close して新形状対応 PR に差し替える。
Acceptance Criteria
- AC1:
docs/schemas/agent-session-manifest.schema.jsonからsecret_policy.boundary_enforcedを廃止する - AC2:
secret_policy.producer_contractとsecret_policy.runtime_boundaryが別 object として定義され、それぞれ description / type / required が明示されている - AC3: schema contract test が以下を検証している
- static producer contract は runtime attestation として扱われない
runtime_boundary.attested: trueの場合は runtime evidence を要求するruntime_boundary.attested: falseの場合は evidence が不要または null である
- AC4:
pnpm testが PASS する
Verification Commands
# AC1
rg -n '"producer_contract"|"runtime_boundary"|"attested"|"evidence_ref"' docs/schemas/agent-session-manifest.schema.json
# AC2
# AC3
# AC4
pnpm testRuntime Verification Applicability
decision: not_applicable
reason: "全 VC コマンド(rg / pnpm test)は CI で実行可能。runtime-only 環境は不要。"Allowed Paths
docs/schemas/agent-session-manifest.schema.jsontests/配下の schema contract test(既存ファイルの修正・invalid fixture 追加のみ)docs/dev/secret-policy.md(任意)
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
Required Skills
- JSON Schema
- Node.js / TypeScript(test 修正)
Delivery Rule
1 Issue = 1 PR。Draft PR で開始し、AC が全件 PASS したらレビュー依頼する。
Activity
squne121 commentedon May 31, 2026
結論
#536は方向性は正しいですが、このまま実装 Issue として走らせると、schema-only の変更で producer contract を壊すか、逆に runtime attestation の偽装余地を残します。判定は REQUEST_CHANGES。特に
boundary_enforcedを「残して description だけ変える」余地を AC1 が許している点は、今回の問題を再発させます。#536の背景整理は妥当です。PR #532 はscripts/generate-session-manifest.mjsにsecret_policy: { value_exposed: false, boundary_enforced: true, mode: 'presence_only' }を追加し、コメント上は「static producer contract であり runtime attestation ではない」と明記しています。([GitHub]1) 一方、main の schema はboundary_enforcedを “secret_boundary_guard PreToolUse hook was active during this session” と説明しており、これは hook 実行の runtime claim です。([GitHub]2) したがって#536が言う「static producer contract と runtime attestation の分離」は必要です。([GitHub]3)Blockers
1.
AC1が弱すぎる。boundary_enforcedの温存を許している#536の AC1 は「boundary_enforcedが存在しない、または description が runtime attestation を意図しないものに修正」となっています。([GitHub]3) これは危険です。今回の事故原因は、同じ boolean 名が static と runtime の両方に読めることです。description を変えても、consumer は過去の実装・名前・既存 fixture から runtime enforcement と誤読できます。修正要求:
推奨は削除です。互換性を理由に残すなら、少なくとも
deprecated: true相当の説明、invalid fixture、consumer migration note が必要です。2. Scope が自己矛盾している
#536の Outcome は、manifest JSON が新しいsecret_policy形状を持つことを成功状態として例示しています。([GitHub]3) しかし Out of Scope ではscripts/generate-session-manifest.mjsの producer 実装変更を除外しています。([GitHub]3)これは実装者にとって矛盾です。schema を変えるだけなら、PR #532 の producer 出力は新 schema と不整合になります。逆に新 schema に合わせた manifest を実際に生成させるなら producer 変更が必要です。現在 main の producer は
secret_policyを出力していません。([GitHub]4) PR #532 は producer に旧形状のboundary_enforcedを追加しています。([GitHub]1)修正要求:
現状の
Out of Scopeのままなら Option A に倒すべきです。3. runtime attestation の証拠条件が schema で表現されていない
Issue の例は
runtime_boundary.attested: false/evidence_ref: nullですが、attested: trueのときにevidence_refが必須・非 null・検証可能であることが AC にありません。([GitHub]3) これは runtime attestation の greenwashing を完全には止めません。JSON Schema Draft 2020-12 では
requiredは存在を強制し、propertiesは「存在した場合の値」を記述するだけです。([learnjsonschema.com]5) またif/thenやdependentRequiredで条件付き必須を表現できます。([JSON Schema]6)修正要求:
evidence_refは可能なら#/evidence/0のような JSON Pointer に寄せるべきです。単なる自由文字列だと、証拠への結合が弱いです。4.
producer_contract.declared: trueも自己申告にすぎないIssue の例では
producer_contract.declared: trueとname: presence_only_no_secret_valuesだけです。([GitHub]3) これは static contract として最低限ですが、consumer が意味を機械判定するには弱いです。SLSA は attestation を「artifact に関する authenticated metadata」として扱い、署名は attestation 作成者の真正性を示し、metadata が明示的に意味を持つ設計を説明しています。([SLSA]7) in-toto でも attestation は subject と predicate type を結合し、envelope が authentication/serialization を扱う層として整理されています。([GitHub]8) この Issue ではそこまで重い署名基盤は不要ですが、少なくとも
producer_contractは「名前だけ」ではなく、schema 上で解釈可能な contract ID / version / claims を持たせるべきです。修正案:
5.
secret_policyの root required 方針が未決#536の AC3 はsecret_policy内の required を求めていますが、root のrequiredにsecret_policyを入れるかどうかは未定義です。([GitHub]3) 現在 main schema の root required にはsecret_policyが入っていません。([GitHub]2)ここは明示しないと、実装者が互換性破壊を起こします。
推奨:
追加すべき invalid fixtures
最低限、以下を schema contract test に入れてください。
{ "secret_policy": { "value_exposed": false, "boundary_enforced": true, "mode": "presence_only" } }これは 旧 PR #532 形状として invalid にするべきです。少なくとも
boundary_enforcedを producer contract として読ませないためです。{ "secret_policy": { "value_exposed": false, "mode": "presence_only", "producer_contract": { "declared": true, "id": "presence_only_no_secret_values", "version": "v1", "claims": { "secret_values_not_serialized": true, "presence_only": true } }, "runtime_boundary": { "attested": true, "evidence_ref": null } } }これは invalid。
attested: trueなら証拠参照必須です。{ "secret_policy": { "value_exposed": true, "mode": "presence_only", "producer_contract": { "declared": true, "id": "presence_only_no_secret_values", "version": "v1", "claims": { "secret_values_not_serialized": true, "presence_only": true } }, "runtime_boundary": { "attested": false, "evidence_ref": null } } }これは invalid。
value_exposedはconst: falseに固定すべきです。改稿すべき Acceptance Criteria
この Issue は次のように締めた方が安全です。
実装方針
#536は PR #532 を as-is merge しないための blocking follow-upとしては妥当です。PR #532 の本文・diff は固定値boundary_enforced: trueを追加しており、しかも PR コメントでは全 AC PASS / mergeable と報告しています。([GitHub]9) ただし schema 側の description と意味論が食い違っているため、#536完了前に #532 を merge すると telemetry contract が汚染されます。推奨順序:
#536を schema-only として修正。boundary_enforced旧形状を invalid fixture 化。producer_contract/runtime_boundaryの新 schema を入れる。LOOP_VERDICT
squne121 commentedon May 31, 2026
issue-refinement-loop 終了報告
人間判断が必要な残存論点
1. AC4 VC のパイプ除去(軽微・即時修正可能)
2. VC の baseline-fail 解釈不一致
reviewer が iteration=2 で多数の VC を "unexpected_pass" と判定したが、これは実装前に既存パターン(
null,claims,version等の一般的なキーワード)が schema の他部分にマッチしたことによる誤検知の可能性がある。以下の選択肢があります:
Option A: VC を全て
pnpm testに統合し、schema contract test で AC を検証させる(VC はpnpm test1 行)Option B: AC1 以外の VC を全て削除し、
pnpm testのみで全 AC を一括カバーする(最小VC)Option C: 現状の VC を維持し、reviewer の誤検知を accept して approve を人間判定する
推奨
Option B(最小 VC) を推奨。schema contract test を充実させて
pnpm testで全 AC をカバーし、VC は AC1(rg で boundary_enforced 不在確認)と AC10(pnpm test)のみにする。Issue 本文の VC セクションを上記に差し替えてから
/impl-review-loop 536で実装に進めてください。squne121 commentedon May 31, 2026
結論:もう
issue-refinement-loopを再実行せず、人間判断で Issue 本文を 1 回だけ手直ししてから PR に進むのがよいです。ループはmax_iterations=3到達で human escalation しており、残ブロッカーも「仕様そのもの」より VC/AC の書き方が reviewer に誤検知される形になっています。直すべき点
現在の #536 は、schema 側で
secret_policyのruntime attestationとstatic producer contractを分離する Issue になっており、producer 実装変更や runtime hook 実装は Out of Scope です。これは方向性として正しいです。([GitHub]1)ただし現在の VC は危険です。
$ rg -n "producer_contract\|runtime_boundary\|attested" docs/schemas/agent-session-manifest.schema.jsonこれは直した方がいいです。理由は 2 つです。
$が入っていて、そのまま実行できない。\|が意図した OR にならない可能性がある。OR にしたいなら|を使うべきです。おすすめの Issue 修正方針
VC は最小化してください。AC の意味論は test に寄せる。
rgは補助確認だけにする。Acceptance Criteria はこう寄せる
JSON Schema では
propertiesに定義しただけでは必須にならず、必須化にはrequiredが必要です。なので AC2/AC3 はrequired配列と contract test に落とすのが正攻法です。(JSON Schema)Verification Commands はこれだけでよい
pnpm testどうしても grep を残すなら、補助確認としてこの程度にしてください。
ただしこれは「存在確認」であって「意味論の検証」ではありません。意味論は test に移すべきです。
schema 側の設計アドバイス
runtime_boundary.attested: trueのときだけevidence_refを要求したいなら、JSON Schema のif/thenが適しています。if/then/elseは Draft 7 以降の条件付き schema 適用で、ifが valid の場合にthenが適用されます。(JSON Schema)例:
重要なのは
if側にもrequiredを入れることです。JSON Schema の公式説明でも、ifschema にrequiredがないと、判定対象プロパティが未定義の場合に余計な条件が適用されることがあります。(JSON Schema)次の一手
#536 の本文を上の AC/VC に置換して、PR では schema と contract test だけを変更してください。
scripts/generate-session-manifest.mjsは触らない。producer の出力変更が必要になったら、それは #536 ではなく後続 Issue に切るべきです。現在の Issue 本文でも producer 実装変更と runtime hook 実装は Out of Scope になっています。([GitHub]1)squne121 commentedon May 31, 2026
impl-review-loop: 人間判断要請 (2026-05-31T04:18:00Z)
phase/implementationが未充足です。現在の#536にはkind/implementationはありますが、phase/implementationがありません。CONTRACT_REVIEW_RESULT_V1 status: gocomment は未 materialize です。2026-05-31T04:09:41Z 時点の Issue コメント 3 件には該当コメントがありません。Preflight evidence
applicability=not_applicable,decision=passstatus=passrg -n '"producer_contract"|"runtime_boundary"|"attested"|"evidence_ref"' docs/schemas/agent-session-manifest.schema.jsonは baseline fail としてdecision=gopnpm testは regression gate として pass(15 files / 266 tests)次アクション
#536にphase/implementationラベルを付与するissue-contract-reviewを実行してCONTRACT_REVIEW_RESULT_V1 status: gocomment を materialize する/impl-review-loop 536を再開するsqune121 commentedon May 31, 2026
Contract Snapshot (2026-05-31T04:21:30Z)
docs/schemas/agent-session-manifest.schema.jsonのsecret_policyフィールドを再設計し、pnpm testが PASS した状態でコミットが存在するsecret_policy.boundary_enforcedを廃止するproducer_contractとruntime_boundaryを別 object として定義するattested/evidence_ref制約を検証するpnpm testが PASS するrg -n '"producer_contract"|"runtime_boundary"|"attested"|"evidence_ref"' docs/schemas/agent-session-manifest.schema.jsonpnpm testdocs/schemas/agent-session-manifest.schema.jsontests/配下の schema contract testdocs/dev/secret-policy.md(任意).claude/worktrees/issue-536-secret-policy-boundary-enforced-runtime-worktree-issue-536-secret-policy-boundary-enforced-runtime-squne121 commentedon May 31, 2026
implement-issue: 実装完了 (2026-05-31T04:27:30Z)
.claude/worktrees/issue-536-secret-policy-boundary-enforced-runtime-worktree-issue-536-secret-policy-boundary-enforced-runtime-rg -n '"producer_contract"|"runtime_boundary"|"attested"|"evidence_ref"' docs/schemas/agent-session-manifest.schema.json: PASSpnpm test: PASS (15 files / 270 tests)pnpm typecheck: PASSpnpm lint: PASSpnpm build: PASSsqune121 commentedon May 31, 2026
impl-review-loop: 完了 (2026-05-31T04:30:00Z)
fix(#536): tighten runtime evidence contract
feat(#536): split secret policy runtime and static schema (#537)
feat(#500): replace boundary_enforced with producer_contract + runtim…
feat(#500): replace boundary_enforced with producer_contract + runtim…
fix(#699): update test_manifest_schema_has_secret_policy_property to …
fix(#699): update test_manifest_schema_has_secret_policy_property to …