Skip to content

feat(#536): split secret policy runtime and static schema - #537

Merged
squne121 merged 3 commits into
mainfrom
worktree-issue-536-secret-policy-boundary-enforced-runtime-
May 31, 2026
Merged

squne121 merged 3 commits into
mainfrom
worktree-issue-536-secret-policy-boundary-enforced-runtime-

Conversation

@squne121

@squne121 squne121 commented May 31, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • docs/schemas/agent-session-manifest.schema.json から曖昧な secret_policy.boundary_enforced を削除し、producer_contract と runtime_boundary を別 object として追加
  • runtime_boundary.evidence_ref を常に required にし、attested: true では non-empty/non-whitespace string、attested: false では null のみ許可する条件付き schema を追加
  • docs/schemas/agent-session-manifest.md を新 shape に更新し、human-facing SSOT から旧 boundary_enforced 記述を除去
  • scripts/lib/agent-session-manifest-validation.mjs に runtime_boundary.evidence_ref と top-level evidence[] の semantic link check を追加
  • tests/agent-session-manifest.test.ts に missing/null/whitespace/mixed-legacy/linkage の回帰 tests を追加

Closes #536

Checks

  • AC1: secret_policy.boundary_enforced を schema から削除した
  • AC2: secret_policy.producer_contract と secret_policy.runtime_boundary を別 object として定義し、description / type / required を明示した
  • AC3: schema contract test で static producer contract と runtime attestation の分離、attested/evidence_ref 条件を検証した
  • AC4: pnpm test が PASS した

検証コマンド結果

Command Result
`rg -n '"producer_contract" "runtime_boundary"
pnpm test PASS (15 files / 275 tests)
pnpm typecheck PASS
pnpm lint PASS
pnpm build PASS

Allowed Paths 遵守

  • docs/schemas/agent-session-manifest.schema.json
  • tests/agent-session-manifest.test.ts
  • docs/schemas/agent-session-manifest.md
  • scripts/lib/agent-session-manifest-validation.mjs

Schema Change Applicability

  • decision: schema_change
  • changed_schema_ids:
    • agent_session_manifest/v1.secret_policy
  • rationale: secret_policy の contract shape 自体を変更し、legacy key を削除して新しい nested object を導入したため

Schema Consumer Inventory

Before

"secret_policy": {
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "value_exposed": { "const": false },
    "boundary_enforced": { "type": "boolean" },
    "mode": { "enum": ["presence_only"] }
  }
}

After

"secret_policy": {
  "type": "object",
  "required": ["value_exposed", "mode", "producer_contract", "runtime_boundary"],
  "properties": {
    "producer_contract": { "type": "object" },
    "runtime_boundary": { "type": "object", "allOf": ["if/then attested gate"] }
  }
}
Consumer ファイル 更新有無 備考
tests/agent-session-manifest.test.ts yes 新 shape / legacy reject / attestation evidence requirement を追加
scripts/lib/agent-session-manifest-validation.mjs yes attested: true の evidence_ref が top-level evidence[] に link していることを semantic validation で確認
tests/agent-session-manifest-producer.test.ts no main の producer はまだ secret_policy を出力しておらず、この PR は schema-only
docs/schemas/agent-session-manifest.md yes human-facing schema doc を新 shape に同期
scripts/generate-session-manifest.mjs no producer shape 移行は Issue #500 / PR #532 のスコープ。#536 完了後に別 PR で新 shape へ合わせる

Compatibility Decision

  • compatibility: breaking
  • reason: legacy secret_policy.boundary_enforced shape は新 schema で invalid になる
  • migration_or_followup: Issue #500 / PR #532 で producer を新 shape へ更新する。main 現在値は secret_policy 未出力のため本 PR 単体では後方互換を壊さない

Safety Claim Matrix

Claim Implemented? Not controlled Evidence Follow-up
static producer declaration を runtime attestation と誤読できない yes schema diff + tests/agent-session-manifest.test.ts valid case none
attested: true は runtime evidence なしで valid にならない yes invalid / valid runtime evidence tests + semantic linkage check none
attested: false で evidence_ref 欠落が通らない yes missing evidence_ref reject test none
legacy boundary_enforced shape は fail-close で reject される yes legacy shape reject test none
producer 実装 migration はこの PR では行わない no producer の新 shape 出力 Issue #500 / PR #532 #500

Contract Snapshot

#536 (comment)

Notes

Separate runtime attestation from the static producer contract in agent_session_manifest schema and cover the new contract with Ajv tests.
@squne121

Copy link
Copy Markdown
Owner Author

検証結果レポート

Issue #536: secret_policy.boundary_enforced の意味論を再設計し runtime attestation と static producer contract を schema 上で分離する

AC 確認コマンド 実行結果(要約) exit code 判定
AC1 `rg -n '"producer_contract" "runtime_boundary" "attested" "evidence_ref"' docs/schemas/agent-session-manifest.schema.json`
AC2 pnpm test schema validation tests に新 shape 受理ケースを追加し PASS 0 PASS
AC3 pnpm test legacy shape reject / runtime evidence requirement tests が PASS 0 PASS
AC4 pnpm test 15 files / 270 tests passed 0 PASS

総合判定

  • 全 AC PASS: YES
  • FAIL した AC: なし
  • SKIP した AC: なし
  • human_review_required: NO
TEST_VERDICT:
  result: PASS
  mergeable: MERGEABLE
  merge_state_status: BLOCKED
  branch_behind_main: false
  baseline_only: false
  verification_commands_pass: 4
  verification_commands_fail: 0
  verification_skipped_count: 0
  runtime_ac_results: []

@squne121
squne121 marked this pull request as ready for review May 31, 2026 04:28
@squne121

Copy link
Copy Markdown
Owner Author

検証結果レポート

Issue #536: secret_policy.boundary_enforced の意味論を再設計し runtime attestation と static producer contract を schema 上で分離する

AC 確認コマンド 実行結果(要約) exit code 判定
AC1 `rg -n '"producer_contract" "runtime_boundary" "attested" "evidence_ref"' docs/schemas/agent-session-manifest.schema.json`
AC2 pnpm test static producer contract / runtime boundary 分離ケースが PASS 0 PASS
AC3 pnpm test legacy shape reject / runtime evidence requirement が PASS 0 PASS
AC4 pnpm test 15 files / 270 tests passed 0 PASS

総合判定

  • 全 AC PASS: YES
  • FAIL した AC: なし
  • SKIP した AC: なし
  • human_review_required: NO
TEST_VERDICT:
  result: PASS
  mergeable: MERGEABLE
  merge_state_status: CLEAN
  branch_behind_main: false
  baseline_only: false
  verification_commands_pass: 4
  verification_commands_fail: 0
  verification_skipped_count: 0
  runtime_ac_results: []

@squne121 squne121 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOOP_VERDICT

schema-only 変更として Issue #536 の contract と整合しており、Changed Paths は Allowed Paths 内に閉じています。secret_policy.boundary_enforced の曖昧性は schema から除去され、static producer declaration と runtime attestation が別 object に分離されました。PR body には Schema Consumer Inventory / Safety Claim Matrix / compatibility follow-up が記載され、CI checks も全件 success です。

LOOP_VERDICT:
  verdict: APPROVE
  blockers: []
  mergeable: MERGEABLE
  mergeStateStatus: CLEAN
  reviewed_head_sha: e1159dd830a9644f0435e88f44fbb5e22cfb12ed
  recommendations: []
  follow_up_issue_requests: []

@squne121

Copy link
Copy Markdown
Owner Author

結論

REQUEST CHANGES。as-is merge は推奨しません。

PR #537 の方向性、つまり boundary_enforced を廃止し、static producer contract と runtime attestation を分離する判断は正しいです。Issue #536 も、PR #532 の boundary_enforced: true 固定値が runtime attestation に見えてしまうことを「security telemetry の greenwashing リスク」と明確に問題化しています。([GitHub]1)

ただし、現差分には 契約の穴 と ドキュメント不整合 が残っています。特に evidence_ref の扱いが「runtime evidence requirement」と呼ぶには弱いです。


ブロッカー 1: attested: false で evidence_ref 欠落が通る

PR は runtime_boundary.attested: false では evidence_ref: null のみ許可すると説明していますが、実際の schema では runtime_boundary.required が ["attested"] のみです。つまり evidence_ref を省略しても valid になります。差分でも runtime_boundary の required は attested だけです。([GitHub]2)

JSON Schema / Ajv では、properties に書いただけでは存在は要求されず、存在要求は required で行います。Ajv docs も properties は property を required にしない、required は指定 property の存在を要求すると明記しています。([Ajv]3) ([Ajv]3)

修正案:

"runtime_boundary": {
  "type": "object",
  "required": ["attested", "evidence_ref"],
  "additionalProperties": false,
  "properties": {
    "attested": { "type": "boolean" },
    "evidence_ref": { "type": ["string", "null"] }
  },
  "allOf": [
    {
      "if": {
        "properties": { "attested": { "const": true } },
        "required": ["attested"]
      },
      "then": {
        "properties": {
          "evidence_ref": {
            "type": "string",
            "minLength": 1,
            "pattern": "\\S"
          }
        }
      }
    },
    {
      "if": {
        "properties": { "attested": { "const": false } },
        "required": ["attested"]
      },
      "then": {
        "properties": {
          "evidence_ref": { "type": "null" }
        }
      }
    }
  ]
}

追加テスト:

it('GIVEN unattested runtime boundary without evidence_ref WHEN validating THEN explicit null evidence_ref is required', () => {
  const manifest = {
    ...createBaseManifest(),
    secret_policy: {
      ...createSecretPolicy(),
      runtime_boundary: {
        attested: false,
      },
    },
  }

  const result = validateManifestAgainstSchema(manifest)

  expect(result.valid).toBe(false)
  expect(result.errors.some((error) => error.path.includes('/secret_policy/runtime_boundary'))).toBe(true)
})

ブロッカー 2: human-facing schema doc が旧契約のまま

docs/schemas/agent-session-manifest.md が旧 secret_policy を説明したままです。現在の docs には boundary_enforced が残り、mode も presence_only | value_included | not_applicable と書かれていますが、PR #537 の schema は boundary_enforced を reject し、mode は presence_only のみです。([GitHub]4)

これは schema-only PR として見逃しにくいです。Issue #536 の目的は「consumer が runtime 証拠と static 宣言を混同しない schema contract」を確立することです。([GitHub]1) Human-facing doc が旧 contract を保持すると、producer/consumer 実装者が再び boundary_enforced を参照します。

修正要求:

docs/schemas/agent-session-manifest.md の secret_policy セクションを新 shape に更新してください。

最小内容:

## `secret_policy` オブジェクト(optional)

`secret_policy` は Secret 値を manifest に含めない static producer contract と、runtime boundary attestation を分離して記録する。

| フィールド | 型 | 必須 | 説明 |
|---|---|---|---|
| `value_exposed` | boolean const false | yes | Secret 値が manifest に露出していないこと |
| `mode` | enum `"presence_only"` | yes | Secret は presence-only metadata として扱う |
| `producer_contract` | object | yes | static producer declaration。runtime attestation ではない |
| `runtime_boundary` | object | yes | runtime boundary enforcement の attestation 状態 |

`boundary_enforced` は廃止。旧 shape は invalid。

Issue #536 の Allowed Paths には docs/dev/secret-policy.md は任意ですが、agent-session-manifest.md は schema の人間向け SSOT なので、ここを更新しないのは不整合です。PR #537 の Files changed は schema と test の 2 ファイルのみで、doc は更新されていません。([GitHub]2)


重要指摘: evidence_ref が「証拠」ではなく任意文字列

attested: true のとき evidence_ref は non-empty string なら通ります。テストも artifacts/runtime-boundary.log のような文字列だけを見ています。([GitHub]2)

これは runtime attestation として弱いです。SLSA では provenance は「どこで、いつ、どう produced されたか」を追跡できる verifiable information と定義されています。([SLSA]5) in-toto でも attestation は authenticated metadata であり、Statement が subject と predicate type を結びつけるモデルです。([GitHub]6)

この PR の evidence_ref: "foo" は、証跡リンク・可視性・ハッシュ・source_kind と結びつかないため、consumer は「attested: true」を信用できません。

推奨修正:

schema だけで完全な参照整合性を表現しきれないので、semantic validator に追加するのが妥当です。

function validateRuntimeBoundarySemantics(manifest) {
  const errors = []
  const rb = manifest.secret_policy?.runtime_boundary
  if (!rb || rb.attested !== true) return errors

  const evidenceList = Array.isArray(manifest.evidence) ? manifest.evidence : []
  const matched = evidenceList.some((e) =>
    e.source_ref === rb.evidence_ref &&
    ['hook_jsonl', 'ci_check', 'artifact'].includes(e.source_kind)
  )

  if (!matched) {
    errors.push({
      path: 'secret_policy.runtime_boundary.evidence_ref',
      message: 'runtime_boundary.evidence_ref must match an evidence[].source_ref with source_kind hook_jsonl, ci_check, or artifact',
    })
  }

  return errors
}

追加テスト:

it('GIVEN attested runtime boundary with evidence_ref not linked to evidence list WHEN validating semantics THEN it is rejected', () => {
  const manifest = {
    ...createBaseManifest(),
    secret_policy: {
      ...createSecretPolicy(),
      runtime_boundary: {
        attested: true,
        evidence_ref: 'artifacts/runtime-boundary.log',
      },
    },
    evidence: [],
  }

  const result = validateManifest(manifest)

  expect(result.valid).toBe(false)
  expect(result.errors.some((error) => error.path === 'secret_policy.runtime_boundary.evidence_ref')).toBe(true)
})

重要指摘: PR #532 / Issue #500 との整合が未解決

PR #532 はまだ旧 shape を producer に追加する内容です。secret_policy は value_exposed: false / boundary_enforced: true / mode: "presence_only" 固定値として説明されています。([GitHub]7) Issue #500 も AC として boundary_enforced: true を要求しています。([GitHub]8)

PR #537 の merge 後、PR #532 はそのままでは schema invalid になります。PR #537 の本文では producer migration は #500 / #532 側とされていますが、実際の #532 はまだ旧契約です。([GitHub]9)

要求:

PR #537 の Notes または follow-up を次のように明確化してください。

PR #532 must be rebased and rewritten before merge:
- remove secret_policy.boundary_enforced
- emit secret_policy.producer_contract
- emit secret_policy.runtime_boundary.attested=false
- emit secret_policy.runtime_boundary.evidence_ref=null
- update producer tests from legacy deep-equal to new shape

テスト不足

現テストは良い開始点です。legacy shape reject、attested: true + null evidence reject、attested: true + evidence accept は追加されています。([GitHub]2) ただし、攻撃的に見ると不足があります。

追加すべきケース:

it('rejects missing runtime_boundary.evidence_ref when attested is false')
it('rejects whitespace-only evidence_ref when attested is true')
it('rejects producer_contract.claims.secret_values_not_serialized=false')
it('rejects producer_contract.claims.presence_only=false')
it('rejects runtime_boundary.evidence_ref that is not linked to evidence[] in combined validation')
it('rejects legacy boundary_enforced even when new fields are also present')

特に最後は重要です。additionalProperties: false により reject されるはずですが、混在 shape を明示的に固定しておくと regression に強くなります。Ajv の additionalProperties: false は properties / patternProperties に含まれない property を拒否します。([Ajv]3)


CI / 配布物面の非ブロッカー

PR checks は 7 件あり、typecheck, lint, test, build, e2e, python-test, session-manifest が表示されています。([GitHub]10) ただし GitHub Actions 上で Node.js 20 action の deprecation warning が出ています。GitHub の警告では Node.js 24 への強制移行が 2026-06-16、Node.js 20 runner action removal が 2026-09-16 とされています。([GitHub]10)

これは PR #537 の直接責務ではありませんが、近い将来 CI が壊れる可能性があるので follow-up 化してください。


推奨レビューコメント

REQUEST_CHANGES

方向性は正しいが、as-is merge は不可。

1. `runtime_boundary.required` が `["attested"]` のみなので、`attested: false` で `evidence_ref` 欠落が valid になる。PR body の「attested:false では null のみ許可」とズレる。`required: ["attested", "evidence_ref"]` にし、false 側は `evidence_ref: null` を明示必須化してほしい。

2. `docs/schemas/agent-session-manifest.md` が旧 `secret_policy.boundary_enforced` と `mode: presence_only | value_included | not_applicable` を説明したまま。schema だけ変えて human-facing SSOT を放置すると、producer/consumer が旧 shape を再実装する。PR #537 内で更新してほしい。

3. `attested: true` の `evidence_ref` が任意 non-empty string で、top-level `evidence[]` とリンクされない。runtime attestation と呼ぶには弱い。schema で最小制約、semantic validator で `evidence[].source_ref` との一致を要求するテストを追加してほしい。

4. PR #532 / Issue #500 は旧 `boundary_enforced` shape のままなので、PR #537 merge 後にそのまま merge 不能。#532 を新 shape に rewrite することを PR body / follow-up に明記してほしい。

判定

boundary_enforced 廃止と runtime/static 分離の設計自体は採用でよいです。ただし、現状は schema contract の完成度が一段足りない ため、REQUEST_CHANGES が妥当です。 blocker は evidence_ref 必須性と stale doc の 2 点です。

Require runtime_boundary.evidence_ref, sync the human-facing schema doc, and validate evidence linkage semantically.
@squne121

Copy link
Copy Markdown
Owner Author

検証結果レポート

Issue #536: secret_policy.boundary_enforced の意味論を再設計し runtime attestation と static producer contract を schema 上で分離する

AC 確認コマンド 実行結果(要約) exit code 判定
AC1 pnpm test -- tests/agent-session-manifest.test.ts tests/agent-session-manifest-producer.test.ts tests/agent-session-manifest-check.test.ts schema と semantic validator の境界ケースを追加し PASS 0 PASS
AC2 pnpm test secret_policy 関連の回帰を含め 15 files / 275 tests passed 0 PASS
AC3 pnpm typecheck TypeScript 型検査 PASS 0 PASS
AC4 pnpm lint && pnpm build lint/build ともに PASS 0 PASS

対応したレビュー指摘

総合判定

  • 全 AC PASS: YES
  • FAIL した AC: なし
  • SKIP した AC: なし
  • human_review_required: NO
TEST_VERDICT:
  result: PASS
  mergeable: MERGEABLE
  merge_state_status: CLEAN
  branch_behind_main: false
  baseline_only: false
  verification_commands_pass: 4
  verification_commands_fail: 0
  verification_skipped_count: 0
  runtime_ac_results: []

@squne121 squne121 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOOP_VERDICT

review comment #issuecomment-4585772075 の blocker 4 点に対応しました。schema では runtime_boundary.evidence_ref を常時 required とし、attested: true では non-empty string、attested: false では explicit null を要求します。さらに semantic validator で secret_policy.runtime_boundary.evidence_ref と evidence[].source_ref の整合を検査し、human-facing schema doc と PR 本文も新 contract に同期しました。

LOOP_VERDICT:
  verdict: APPROVE
  blockers: []
  mergeable: MERGEABLE
  mergeStateStatus: CLEAN
  reviewed_head_sha: 0528f7f08938f0f59d3f52246d18221f204ff270
  recommendations:
    - "PR #532 / Issue #500 は merge 前に new secret_policy shape へ rewrite が必要"
  follow_up_issue_requests: []

@squne121
squne121 merged commit 9cd3a1f into main May 31, 2026
7 checks passed
@squne121
squne121 deleted the worktree-issue-536-secret-policy-boundary-enforced-runtime- branch May 31, 2026 05:23
squne121 added a commit that referenced this pull request May 31, 2026
…e_boundary in secret_policy

Aligns generate-session-manifest.mjs output with the new schema structure
introduced in PR #537 (feat(#536): split secret policy runtime and static schema).
Removes boundary_enforced (ambiguous runtime/static meaning) and replaces with
explicit producer_contract (static declaration) and runtime_boundary (attested:false,
evidence_ref:null) fields. Updates AC5 deep-equal assertions in
agent-session-manifest-producer.test.ts to match the new structure.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
squne121 added a commit that referenced this pull request May 31, 2026
…e_boundary in secret_policy (#532)

* feat: add secret_policy field to generate-session-manifest.mjs output (#500)

Adds static producer contract secret_policy field to manifest JSON output.
The field declares value_exposed:false / boundary_enforced:true / mode:presence_only
as a static contract declaration, not a runtime attestation.
Adds deep-equal assertions in agent-session-manifest-producer.test.ts to
prevent regression of the producer contract.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* feat(#500): replace boundary_enforced with producer_contract + runtime_boundary in secret_policy

Aligns generate-session-manifest.mjs output with the new schema structure
introduced in PR #537 (feat(#536): split secret policy runtime and static schema).
Removes boundary_enforced (ambiguous runtime/static meaning) and replaces with
explicit producer_contract (static declaration) and runtime_boundary (attested:false,
evidence_ref:null) fields. Updates AC5 deep-equal assertions in
agent-session-manifest-producer.test.ts to match the new structure.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

---------

Co-authored-by: Claude Sonnet 4.6 <[email protected]>
squne121 added a commit that referenced this pull request Jun 6, 2026
…match current schema shape

Update stale test expectations from boundary_enforced to the correct
#536/#537 schema shape (producer_contract + runtime_boundary) and add
regression guard asserting boundary_enforced is absent from the schema.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
squne121 added a commit that referenced this pull request Jun 6, 2026
…hema contract checks

- Replace boundary_enforced: True fixtures in test_sentinel_producer_injection_does_not_leak
  and test_manifest_fixture_with_secret_policy_validates_sentinel_absence with correct
  #537 shape (producer_contract + runtime_boundary)
- Add deeper contract checks to test_manifest_schema_has_secret_policy_property:
  required fields, additionalProperties: false, producer_contract/runtime_boundary
  subschema structure, and runtime_boundary.allOf conditional evidence contract

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
squne121 added a commit that referenced this pull request Jun 6, 2026
…match current schema shape (#716)

* fix(#699): update test_manifest_schema_has_secret_policy_property to match current schema shape

Update the stale test expectation to match the schema shape introduced in
#536/#537. The test was expecting the deprecated 'boundary_enforced' field
which was intentionally removed in #537 (breaking change) and replaced by
'producer_contract' (static declaration) and 'runtime_boundary' (runtime
attestation).

- Replace 'boundary_enforced' assertion with 'producer_contract' and
  'runtime_boundary' assertions
- Add regression guard: assert 'boundary_enforced' not in sp_props

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix(#699): update legacy boundary_enforced fixtures and add deeper schema contract checks

- Replace boundary_enforced: True fixtures in test_sentinel_producer_injection_does_not_leak
  and test_manifest_fixture_with_secret_policy_validates_sentinel_absence with correct
  #537 shape (producer_contract + runtime_boundary)
- Add deeper contract checks to test_manifest_schema_has_secret_policy_property:
  required fields, additionalProperties: false, producer_contract/runtime_boundary
  subschema structure, and runtime_boundary.allOf conditional evidence contract

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

---------

Co-authored-by: Claude Sonnet 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

実装: secret_policy.boundary_enforced の意味論を再設計し runtime attestation と static producer contract を schema 上で分離する

1 participant