Skip to content

実装: session recording Kill Switch runtime smoke test と secret exposure scanner を追加する #380

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#242"
goal_ref: "policy 文書だけでなく実際に危険条件を検出したら fail-closed する Kill Switch runtime smoke test と secret exposure scanner を追加する"
change_kind: code

Parent Issue

#242

Parent Goal Ref

Current Validated Scope

本 Issue は以下の CLOSED 成果物 を消費する統合安全検査を追加する:

新規追加する成果物:

  • 4 つの Kill Switch trigger fixture(実装: session recording no-push / private checkpoint / local-only verifier を追加する #379 verifier を fixture 設定に対して呼び出し、exit code を主判定とする):
    1. secrets_mode != none fixture
    2. checkpoint_token_present fixture
    3. public_checkpoint_branch_detected fixture
    4. raw_transcript_public_surface_detected fixture
  • secret exposure scanner: GitHub surface / artifact / manifest / hook log で secret-like pattern を検出
  • scanner は rule_id, source_kind, redacted_preview, sha256_prefix, location のみを出力し、raw_value / matched_text は JSON 出力にも含めない

Remaining Parent Gaps

Outcome

.claude/scripts/kill_switch_runtime_smoke.py と .claude/scripts/secret_exposure_scanner.py が実装され、以下を検証する状態:

Kill Switch runtime smoke test:

  • .claude/scripts/check_session_recording_runtime_safety.py(実装: session recording no-push / private checkpoint / local-only verifier を追加する #379 verifier)を fixture 設定に対して実行する
  • dangerous condition fixture では exit non-zero を assert する(exit code が主判定)
  • safe condition fixture では exit 0 を assert する
  • required_end_state YAML は stdout に出すが証跡であり判定本体ではない
  • fake fixture での required_end_state テンプレート:
required_end_state:
  session_recording_tool_enabled: false
  git_hooks_recording_enabled: false
  public_checkpoint_branch_present: false
  auto_push_sessions_allowed: false
  full_transcript_remote_visibility: none
  leaked_credentials_rotated_or_revoked:
    status: not_applicable
    reason: fake_fixture_only
  remediation_ticket_required: true

secret exposure scanner:

  • GitHub Issue / PR comment 表面を走査(Issues comments API / Pull request review comments API を区別)
  • artifact (.env, .claude/context/, checkpoints) を検査(Actions artifacts API、--max-bytes 10485760)
  • manifest evidence で secret pattern を検出(pnpm manifest:check を呼び出し、独自再実装しない)
  • 検出時に fail-closed で exit 1+ を返す
  • scanner 自体が secret を stderr/stdout に出力しない(finding は redacted 形式のみ)

In Scope

  • .claude/scripts/kill_switch_runtime_smoke.py (新規作成)
  • .claude/scripts/secret_exposure_scanner.py (新規作成)
  • 4 つの Kill Switch trigger fixture の実装(実装: session recording no-push / private checkpoint / local-only verifier を追加する #379 verifier を fixture 経由で呼び出す)
  • required_end_state YAML 出力フォーマット定義(fake fixture は rotated_or_revoked: not_applicable)
  • secret pattern 定義(provider-aware rules、実装: agent_session_manifest/v1 deterministic script producer を schema conform で実装する #377 rule set を再利用):
    • EntireCLI checkpoint markers: entire/checkpoints/v1, Entire-Checkpoint, Entire-Attribution
    • transcript markers: source_kind: transcript, source_kind: local_file, raw_transcript, assistant_response, tool_result
    • absolute path: /home/, /Users/, /tmp/, C:\
    • .env file content
    • BEGIN.*PRIVATE KEY
    • Anthropic API key: sk-[A-Za-z0-9_-]{30,}, sk-proj-[A-Za-z0-9_-]{30,}
    • GitHub tokens: gh[pousr]_[A-Za-z0-9]{36}
  • secret scanner CLI contract:
    • --repo / --issue / --pr / --scan-issue-comments / --scan-pr-review-comments / --scan-artifacts
    • --artifact-name / --since / --max-bytes 10485760 / --fail-on-api-error フラグ
  • CI GitHub Actions permissions: contents: read, issues: read, pull-requests: read, actions: read
  • scanner output schema (SECRET_EXPOSURE_SCAN_RESULT_V1): raw_value_included: false を必須フィールドとする
  • fixture test で valid (no secret) と invalid (secret detected) を区別
  • security:session-recording = pnpm policy:check && pnpm manifest:check && pnpm session-recording:smoke && pnpm secret-exposure:scan スクリプト追加

Out of Scope

Acceptance Criteria

Verification Commands

# AC1
$ test -f .claude/scripts/kill_switch_runtime_smoke.py

# AC2
$ test -f .claude/scripts/secret_exposure_scanner.py

# AC3
$ pnpm test -- --testPathPattern="kill_switch.*secrets_mode"

# AC4
$ pnpm test -- --testPathPattern="kill_switch.*checkpoint_token"

# AC5
$ pnpm test -- --testPathPattern="kill_switch.*public_branch"

# AC6
$ pnpm test -- --testPathPattern="kill_switch.*raw_transcript"

# AC7
$ pnpm test -- --testPathPattern="kill_switch.*required_end_state"

# AC8
$ pnpm test -- --testPathPattern="scanner.*transcript"

# AC9
$ pnpm test -- --testPathPattern="scanner.*token"

# AC10
$ pnpm test -- --testPathPattern="scanner.*path"

# AC11
$ pnpm test -- --testPathPattern="scanner.*no_raw"

# AC12
$ pnpm test -- --testPathPattern="scanner.*fixture"

# AC13
$ pnpm typecheck
$ pnpm lint
$ pnpm test
$ pnpm build

Allowed Paths

  • .claude/scripts/kill_switch_runtime_smoke.py (新規作成)
  • .claude/scripts/secret_exposure_scanner.py (新規作成)
  • tests/session-recording-kill-switch.test.ts (新規作成)
  • tests/fixtures/session-recording/** (fixture 追加)
  • package.json (session-recording:smoke / secret-exposure:scan / security:session-recording script 追加のみ)
  • .github/workflows/ci.yml (既存 test/python-test job への step 追加のみ)

Stop Conditions

  • Allowed Paths 外への変更が必要と判明
  • In Scope の固定契約(Kill Switch trigger condition / required_end_state)の変更が必要
  • new Issue 起票が必要と判明
  • nested SubAgent delegation が必要
  • 実 secret を fixture / test に含めようとした場合(即停止・strict enforcement)
  • pnpm typecheck/lint/test/build のいずれかが fail した場合

Runtime Verification Applicability

decision: immediate
rationale: Kill Switch smoke test と secret scanner の実行が必須。fixture-driven test なので実行時に trigger condition と secret detection を検証。

Related

Source

source: refinement_loop_followup
origin_issue: "#326"
anchor_comment_url: "https://github.com/squne121/loop-protocol/issues/326#issuecomment-4528499380"
dedupe_key: "326-followup-D"

Required Skills

  • なし(implementation issue)

Activity

  1. added
    kind/implementation
    area/security
    area/ai-ops
    on May 24, 2026
  2. squne121 commented on May 29, 2026

    @squne121
    OwnerAuthor

    結論: REQUEST CHANGES / そのまま実装着手は危険

    #380 は目的自体は妥当です。#242 の Kill Switch policy を「文書」から「実行時に落ちる検査」へ進める必要はあります。ただし、現在の #380 は依存関係・CI 経路・scanner の対象面・secret redaction の検証が粗く、このまま実装すると “fail-closed しているように見えるだけの自己満足 smoke test” になりやすいです。

    特に致命的なのは、#380 が「producer / validation gate / no-push verifier は Remaining Parent Gaps」と書いている一方で、現在は #377/#378/#379 が closed になっている点です。#380 は未完前提を並べる Issue ではなく、既存の producer・manifest gate・runtime safety verifier を消費する 統合安全検査 Issue に書き換えるべきです。#380 本文は producer / validation / no-push を gap として残していますが、#377 は closed で PR #404 に紐づき、#378 は closed で PR #431 に紐づき、#379 は closed で PR #474 に紐づいています。(GitHub)


    関連 Issue / PR の現在地

    項目 | 状態 | #380 への影響 -- | -- | -- #242 session recording policy / Kill Switch SSOT | closed | Kill Switch trigger / required_end_state の正本。#380 はここを再定義せず機械検証に徹するべき。#242 は secrets_mode != none、checkpoint token、public checkpoint branch、raw transcript public surface、secret scan flagged を trigger として定義しています。(GitHub) #324 policy checker CI | closed / PR #355 | CI 標準は .github/workflows/ci.yml と pnpm policy:check 系。#380 の allowed path が test.yml / python-test.yml 前提なのは古い。(GitHub) #325 Claude hook guard | closed / PR #365 | Stop/SubagentStop で policy 関連変更を検知し、fail 時は exit 2 で blocking する導線がある。#380 の smoke はこの hook/guard との関係を明示すべき。(GitHub) #326 session-recording-policy Skill | closed / PR #382 | 手順化は済み。ただし PR #382 のレビューでは、自動発火表現、checker 実行コマンド、VERDICT の自己申告性が問題化している。#380 はここを補完する実証レイヤにすべき。(GitHub) #377 deterministic manifest producer | closed / PR #404 | manifest 生成・validate・extract script が前提化済み。#380 の secret scanner は #377 の secret-like pattern と output 検査を再利用すべき。(GitHub) #378 manifest validation gate | closed / PR #431 | pnpm manifest:check と CI gate が前提化済み。#380 は manifest の public surface / semantic violation 検出を再実装せず呼び出すべき。(GitHub) #379 no-push / private checkpoint / local-only verifier | closed / PR #474 | public checkpoint branch、auto-push、unknown visibility、hook 残存などの verifier が前提化済み。#380 は kill switch fixture からこの verifier を実行する設計に寄せるべき。(GitHub) #381 Codex CLI Skill | open | Codex 側 skill 未完。#380 の CI/runtime scanner 自体は Codex skill 完了を待たなくてもよいが、pilot gate の十分条件にはならない。(GitHub)

    Blocker 1: #380 の契約が stale。依存成果物を消費していない

    #380 は producer 本体実装 / validation gate / no-push verifier を Remaining Parent Gaps としていますが、現在は #377/#378/#379 が closed です。これは単なる表記ミスではなく、実装方針を誤らせます。未完前提のままだと、#380 の実装者は既存の scripts/generate-session-manifest.mjs、pnpm manifest:check、.claude/scripts/check_session_recording_runtime_safety.py を無視して、類似ロジックを重複実装する危険があります。#377 は producer/validator/extractor と secret-like output 検査を scope に含め、#378 は manifest gate を .github/workflows/ci.yml に統合する設計、#379 は runtime safety verifier を実装対象にしています。(GitHub)

    修正方針:

    ## Current Validated Scope
    - #377 deterministic manifest producer: CLOSED / PR #404
    - #378 manifest validation gate: CLOSED / PR #431
    - #379 no-push/private/local-only verifier: CLOSED / PR #474
    - 本 Issue は上記成果物を消費し、Kill Switch runtime smoke と secret exposure scanner の統合検査を追加する
    

    Blocker 2: CI workflow allowed path が実態とズレている

    #380 の allowed paths は .github/workflows/test.yml または .github/workflows/python-test.yml を想定していますが、#324 は .github/workflows/ci.yml の python-test job に policy checker を統合しており、#378 も .github/workflows/ci.yml の test job に pnpm manifest:check を追加する設計です。(GitHub)

    修正すべき allowed paths:

    * `.github/workflows/ci.yml` 
      - existing test/python-test job への smoke/scanner step 追加のみ
    * `package.json`
      - `session-recording:smoke` / `secret-exposure:scan` / `security:session-recording` script 追加のみ
    

    現状のままだと、実装者は正しい CI に接続できず、Stop Condition に抵触するか、別 workflow を増やして CI 分散を起こします。


    Blocker 3: “runtime smoke” が実ランタイム経路を叩かない恐れがある

    #380 は fixture で kill switch condition と required_end_state YAML を assert するとしていますが、これだけでは runtime smoke ではありません。単に YAML を出すだけなら、policy checker の単体テストであり、Kill Switch が危険条件で実際に fail-closed する保証になりません。#325 は Stop/SubagentStop hook で fail 時 exit 2 にする設計を持ち、#379 は public branch / auto-push / unknown visibility / hook 残存を exit 1+ で検出する verifier を持ちます。#380 はこれらを fixture から実行する形にしないと「手順のテスト」に戻ります。(GitHub)

    最低限の修正:

    Kill Switch runtime smoke test は以下を実行する:
    1. policy fixture を作る
    2. #379 verifier を fixture repo/config に対して実行する
    3. dangerous condition では exit non-zero を assert する
    4. safe condition では exit 0 を assert する
    5. required_end_state は stdout JSON/YAML として出すが、exit code を主判定にする
    

    特に required_end_state は証跡であって判定本体ではありません。判定本体は exit code と structured finding です。


    Blocker 4: secret scanner の対象面が広すぎるのに API/権限/ページングが未定義

    #380 は Issue / PR comment / artifact / manifest / hook log を走査対象にしていますが、GitHub の surface は少なくとも別 API に分かれます。Issue/PR の通常コメントは Issues comments API、PR diff 上の review comments は Pull request review comments API、Actions artifact は Actions artifacts API です。Issue comments API は Issues または Pull requests の read 権限、PR review comments API は Pull requests read、Actions artifacts API は Actions read が必要になります。(GitHub Docs)

    このままでは「CI でたまたま public repo だから読めた」だけになり、private repo / fork PR / 権限不足 / rate limit / artifact zip 展開の扱いが曖昧です。

    追加すべき CLI contract:

    .claude/scripts/secret_exposure_scanner.py \
      --repo squne121/loop-protocol \
      --issue 380 \
      --pr 474 \
      --scan-issue-comments \
      --scan-pr-review-comments \
      --scan-artifacts \
      --artifact-name session-manifest \
      --since 2026-05-24T00:00:00Z \
      --max-bytes 10485760 \
      --fail-on-api-error
    

    また、CI では権限を明示すべきです。

    permissions:
      contents: read
      issues: read
      pull-requests: read
      actions: read
    

    Blocker 5: token-like regex が弱すぎるうえ、false positive を大量発生させる

    #380 の token-like pattern は ^[A-Za-z0-9_-]{20,}$ のような汎用長文字列を候補にしています。これは UUID、hash、manifest id、base64 断片、通常の識別子を大量に拾う一方で、sk-proj-...、ghp_...、JWT、private key、provider-specific token の構造的検出には弱いです。#377 はすでに sk-...、gh[pousr]_...、BEGIN .*PRIVATE KEY、絶対 path、.env、raw_transcript など、より具体的な生成物検査パターンを scope に入れています。#380 はこの rule set を再利用するべきです。(GitHub)

    外部ツール面では、Gitleaks は git repo / file / stdin の secret 検出に対応し、GitHub Action や pre-commit hook としても使える一方、現在は feature complete と明記されています。TruffleHog は Git、chat、wiki、logs、object stores、filesystem など広い source を対象にし、800 以上の secret type の分類と、可能な場合の live validation を持ちます。(GitHub)

    推奨は二層です。

    1. project-specific scanner: raw transcript / local path / agent manifest / Entire checkpoint など、プロジェクト固有 surface を deterministic に検査。

    2. standard scanner optional gate: Gitleaks または TruffleHog を CI の補助 gate として追加。ただし output は redacted のみ。


    Blocker 6: 「scanner が secret をログ出力しない」AC が検証になっていない

    #380 の AC11 は token=|secret=|api_key= を grep しない程度の検査です。これは弱すぎます。fake token fixture が sk-test-... や ghp_... を含んでいても、scanner がその値をそのまま出力した場合に検出できない可能性があります。#380 の scanner は「secret を見つける」だけでなく「secret を再漏洩しない」ことが主目的なので、stdout/stderr の完全捕捉と sentinel 不在 assertion が必要です。(GitHub)

    GitHub Actions では、GitHub secret ではない動的な機微値も ::add-mask::VALUE で mask 登録することが推奨されています。ただし、これは登録後のログ出力に効く補助策であり、scanner 自体が secret 値を出さない設計の代替ではありません。(GitHub Docs)

    修正 AC:

    AC: scanner は finding に raw match を含めない。
    - stdout/stderr に fixture sentinel secret の完全一致・部分一致が存在しない
    - finding は rule_id, source_kind, redacted_preview, sha256_prefix, location のみを出す
    - raw_value / matched_text / context_line は JSON 出力にも含めない
    

    Blocker 7: EntireCLI の実装リスクに対する scanner pattern が浅い

    Entire の README は、hooks が session data を capture し、session metadata を entire/checkpoints/v1 branch に保存すると説明しています。session には prompts、responses、files modified、timestamps が含まれ、checkpoint branch には transcript / prompts / files touched を含む metadata が保存されます。Entire の glossary でも checkpoint remote は metadata 保存先であり、default では code remote に push されると説明されています。(GitHub)

    つまり、#380 の scanner は [transcript] や raw_transcript_content だけ見ても不十分です。検出すべきなのは少なくとも以下です。

    entire/checkpoints/v1
    Entire-Checkpoint
    Entire-Attribution
    source_kind: transcript
    source_kind: local_file
    raw_transcript
    prompt
    assistant_response
    tool_result
    /home/
    /Users/
    /tmp/
    C:\
    .env
    BEGIN ... PRIVATE KEY
    sk-...
    sk-proj-...
    ghp_ / gho_ / ghu_ / ghs_ / ghr_
    

    さらに #378 は visibility: public_github_comment で evidence.source_kind: transcript または local_file を含む manifest を exit 1 にする gate を明記しています。#380 の scanner は manifest semantic validation を独自実装せず、pnpm manifest:check を呼ぶべきです。(GitHub)


    Blocker 8: fake token fixture と rotation/revocation required_end_state が矛盾する

    #242 の Kill Switch required_end_state には leaked_credentials_rotated_or_revoked: true が含まれます。#380 は「実 secret は使わない」「fake token fixture のみ」としているため、fixture test で rotated_or_revoked: true を assert すると虚偽の安全証跡になります。(GitHub)

    fixture では次のように分けるべきです。

    required_end_state:
      session_recording_tool_enabled: false
      git_hooks_recording_enabled: false
      public_checkpoint_branch_present: false
      auto_push_sessions_allowed: false
      full_transcript_remote_visibility: none
      leaked_credentials_rotated_or_revoked:
        status: not_applicable
        reason: fake_fixture_only
      remediation_ticket_required: true
    

    本物の secret 露出時だけ rotated_or_revoked: true を要求するのが正しいです。


    修正後の実装方針

    #380 は次の 3 ファイル + CI 接続に絞るのがよいです。

    Allowed Paths
    - `.claude/scripts/kill_switch_runtime_smoke.py`
    - `.claude/scripts/secret_exposure_scanner.py`
    - `tests/session-recording-kill-switch.test.ts`
    - `tests/fixtures/session-recording/**`
    - `package.json` script 追加のみ
    - `.github/workflows/ci.yml` 既存 job への step 追加のみ
    

    package scripts は以下の形がよいです。

    {
      "scripts": {
        "session-recording:smoke": "python .claude/scripts/kill_switch_runtime_smoke.py --fixtures tests/fixtures/session-recording",
        "secret-exposure:scan": "python .claude/scripts/secret_exposure_scanner.py --local tests/fixtures/session-recording --fail-on-finding",
        "security:session-recording": "pnpm policy:check && pnpm manifest:check && pnpm session-recording:smoke && pnpm secret-exposure:scan"
      }
    }
    

    scanner output schema は raw 値を禁止します。

    SECRET_EXPOSURE_SCAN_RESULT_V1:
      status: failed
      findings:
        - rule_id: github_token
          source_kind: github_issue_comment
          source_ref: issue:380#comment:<id>
          location:
            line: 12
            column: null
          redacted_preview: "ghp_****abcd"
          fingerprint_sha256_prefix: "12ab34cd56ef"
          raw_value_included: false
      raw_values_emitted: false
    

    最終判断

    #380 は close せず、契約修正してから implementation に入るべきです。現状のまま実装すると、既に closed になった #377/#378/#379 の成果物を取り込まず、scanner も secret を検出しながら再漏洩する危険が残ります。

    最低限の修正条件は次です。

    1. 実装: agent_session_manifest/v1 deterministic script producer を schema conform で実装する #377/実装: agent_session_manifest producer output の schema validation gate (pnpm manifest:check) を追加する #378/実装: session recording no-push / private checkpoint / local-only verifier を追加する #379 を Remaining Gaps から削除し、消費対象に変更。

    2. CI allowed path を .github/workflows/ci.yml に修正。

    3. Kill Switch smoke は 実装: session recording no-push / private checkpoint / local-only verifier を追加する #379 verifier / 実装: session recording policy guard を Claude hook (Stop/SubagentStop) に統合する #325 guard / 実装: session_recording_policy checker を CI / python-test workflow に統合する #324 policy check / 実装: agent_session_manifest producer output の schema validation gate (pnpm manifest:check) を追加する #378 manifest check の exit code を実行証跡にする。

    4. secret scanner は GitHub comments / PR review comments / artifacts の API・権限・ページング・artifact 展開上限を明記。

    5. raw secret を絶対に stdout/stderr/JSON に出さない sentinel test を AC に追加。

    6. ^[A-Za-z0-9_-]{20,}$ 中心の雑な token regex をやめ、実装: agent_session_manifest/v1 deterministic script producer を schema conform で実装する #377 の rule set + Gitleaks/TruffleHog 相当の provider-aware rules に寄せる。

    7. fake token fixture では rotation/revocation を not_applicable とし、実 secret remediation 証跡を捏造しない。

    この修正後なら、#380 は #246 pilot の前提 gate として意味を持ちます。現状ではまだ「安全装置のテスト」ではなく「安全装置があると主張するテスト」です。

    ## 結論: REQUEST CHANGES / そのまま実装着手は危険

    #380 は目的自体は妥当です。#242 の Kill Switch policy を「文書」から「実行時に落ちる検査」へ進める必要はあります。ただし、現在の #380 は依存関係・CI 経路・scanner の対象面・secret redaction の検証が粗く、このまま実装すると “fail-closed しているように見えるだけの自己満足 smoke test” になりやすいです。

    特に致命的なのは、#380 が「producer / validation gate / no-push verifier は Remaining Parent Gaps」と書いている一方で、現在は #377/#378/#379 が closed になっている点です。#380 は未完前提を並べる Issue ではなく、既存の producer・manifest gate・runtime safety verifier を消費する 統合安全検査 Issue に書き換えるべきです。#380 本文は producer / validation / no-push を gap として残していますが、#377 は closed で PR #404 に紐づき、#378 は closed で PR #431 に紐づき、#379 は closed で PR #474 に紐づいています。([GitHub]1)


    関連 Issue / PR の現在地

    項目 状態 #380 への影響
    #242 session recording policy / Kill Switch SSOT closed Kill Switch trigger / required_end_state の正本。#380 はここを再定義せず機械検証に徹するべき。#242 は secrets_mode != none、checkpoint token、public checkpoint branch、raw transcript public surface、secret scan flagged を trigger として定義しています。([GitHub]2)
    #324 policy checker CI closed / PR #355 CI 標準は .github/workflows/ci.yml と pnpm policy:check 系。#380 の allowed path が test.yml / python-test.yml 前提なのは古い。([GitHub]3)
    #325 Claude hook guard closed / PR #365 Stop/SubagentStop で policy 関連変更を検知し、fail 時は exit 2 で blocking する導線がある。#380 の smoke はこの hook/guard との関係を明示すべき。([GitHub]4)
    #326 session-recording-policy Skill closed / PR #382 手順化は済み。ただし PR #382 のレビューでは、自動発火表現、checker 実行コマンド、VERDICT の自己申告性が問題化している。#380 はここを補完する実証レイヤにすべき。([GitHub]5)
    #377 deterministic manifest producer closed / PR #404 manifest 生成・validate・extract script が前提化済み。#380 の secret scanner は #377 の secret-like pattern と output 検査を再利用すべき。([GitHub]6)
    #378 manifest validation gate closed / PR #431 pnpm manifest:check と CI gate が前提化済み。#380 は manifest の public surface / semantic violation 検出を再実装せず呼び出すべき。([GitHub]7)
    #379 no-push / private checkpoint / local-only verifier closed / PR #474 public checkpoint branch、auto-push、unknown visibility、hook 残存などの verifier が前提化済み。#380 は kill switch fixture からこの verifier を実行する設計に寄せるべき。([GitHub]8)
    #381 Codex CLI Skill open Codex 側 skill 未完。#380 の CI/runtime scanner 自体は Codex skill 完了を待たなくてもよいが、pilot gate の十分条件にはならない。([GitHub]9)

    Blocker 1: #380 の契約が stale。依存成果物を消費していない

    #380 は producer 本体実装 / validation gate / no-push verifier を Remaining Parent Gaps としていますが、現在は #377/#378/#379 が closed です。これは単なる表記ミスではなく、実装方針を誤らせます。未完前提のままだと、#380 の実装者は既存の scripts/generate-session-manifest.mjs、pnpm manifest:check、.claude/scripts/check_session_recording_runtime_safety.py を無視して、類似ロジックを重複実装する危険があります。#377 は producer/validator/extractor と secret-like output 検査を scope に含め、#378 は manifest gate を .github/workflows/ci.yml に統合する設計、#379 は runtime safety verifier を実装対象にしています。([GitHub]6)

    修正方針:

    ## Current Validated Scope
    - #377 deterministic manifest producer: CLOSED / PR #404
    - #378 manifest validation gate: CLOSED / PR #431
    - #379 no-push/private/local-only verifier: CLOSED / PR #474
    - 本 Issue は上記成果物を消費し、Kill Switch runtime smoke と secret exposure scanner の統合検査を追加する

    Blocker 2: CI workflow allowed path が実態とズレている

    #380 の allowed paths は .github/workflows/test.yml または .github/workflows/python-test.yml を想定していますが、#324 は .github/workflows/ci.yml の python-test job に policy checker を統合しており、#378 も .github/workflows/ci.yml の test job に pnpm manifest:check を追加する設計です。([GitHub]1)

    修正すべき allowed paths:

    * `.github/workflows/ci.yml` 
      - existing test/python-test job への smoke/scanner step 追加のみ
    * `package.json`
      - `session-recording:smoke` / `secret-exposure:scan` / `security:session-recording` script 追加のみ

    現状のままだと、実装者は正しい CI に接続できず、Stop Condition に抵触するか、別 workflow を増やして CI 分散を起こします。


    Blocker 3: “runtime smoke” が実ランタイム経路を叩かない恐れがある

    #380 は fixture で kill switch condition と required_end_state YAML を assert するとしていますが、これだけでは runtime smoke ではありません。単に YAML を出すだけなら、policy checker の単体テストであり、Kill Switch が危険条件で実際に fail-closed する保証になりません。#325 は Stop/SubagentStop hook で fail 時 exit 2 にする設計を持ち、#379 は public branch / auto-push / unknown visibility / hook 残存を exit 1+ で検出する verifier を持ちます。#380 はこれらを fixture から実行する形にしないと「手順のテスト」に戻ります。([GitHub]4)

    最低限の修正:

    Kill Switch runtime smoke test は以下を実行する:
    1. policy fixture を作る
    2. #379 verifier を fixture repo/config に対して実行する
    3. dangerous condition では exit non-zero を assert する
    4. safe condition では exit 0 を assert する
    5. required_end_state は stdout JSON/YAML として出すが、exit code を主判定にする

    特に required_end_state は証跡であって判定本体ではありません。判定本体は exit code と structured finding です。


    Blocker 4: secret scanner の対象面が広すぎるのに API/権限/ページングが未定義

    #380 は Issue / PR comment / artifact / manifest / hook log を走査対象にしていますが、GitHub の surface は少なくとも別 API に分かれます。Issue/PR の通常コメントは Issues comments API、PR diff 上の review comments は Pull request review comments API、Actions artifact は Actions artifacts API です。Issue comments API は Issues または Pull requests の read 権限、PR review comments API は Pull requests read、Actions artifacts API は Actions read が必要になります。([GitHub Docs]10)

    このままでは「CI でたまたま public repo だから読めた」だけになり、private repo / fork PR / 権限不足 / rate limit / artifact zip 展開の扱いが曖昧です。

    追加すべき CLI contract:

    .claude/scripts/secret_exposure_scanner.py \
      --repo squne121/loop-protocol \
      --issue 380 \
      --pr 474 \
      --scan-issue-comments \
      --scan-pr-review-comments \
      --scan-artifacts \
      --artifact-name session-manifest \
      --since 2026-05-24T00:00:00Z \
      --max-bytes 10485760 \
      --fail-on-api-error

    また、CI では権限を明示すべきです。

    permissions:
      contents: read
      issues: read
      pull-requests: read
      actions: read

    Blocker 5: token-like regex が弱すぎるうえ、false positive を大量発生させる

    #380 の token-like pattern は ^[A-Za-z0-9_-]{20,}$ のような汎用長文字列を候補にしています。これは UUID、hash、manifest id、base64 断片、通常の識別子を大量に拾う一方で、sk-proj-...、ghp_...、JWT、private key、provider-specific token の構造的検出には弱いです。#377 はすでに sk-...、gh[pousr]_...、BEGIN .*PRIVATE KEY、絶対 path、.env、raw_transcript など、より具体的な生成物検査パターンを scope に入れています。#380 はこの rule set を再利用するべきです。([GitHub]1)

    外部ツール面では、Gitleaks は git repo / file / stdin の secret 検出に対応し、GitHub Action や pre-commit hook としても使える一方、現在は feature complete と明記されています。TruffleHog は Git、chat、wiki、logs、object stores、filesystem など広い source を対象にし、800 以上の secret type の分類と、可能な場合の live validation を持ちます。([GitHub]11)

    推奨は二層です。

    1. project-specific scanner: raw transcript / local path / agent manifest / Entire checkpoint など、プロジェクト固有 surface を deterministic に検査。
    2. standard scanner optional gate: Gitleaks または TruffleHog を CI の補助 gate として追加。ただし output は redacted のみ。

    Blocker 6: 「scanner が secret をログ出力しない」AC が検証になっていない

    #380 の AC11 は token=|secret=|api_key= を grep しない程度の検査です。これは弱すぎます。fake token fixture が sk-test-... や ghp_... を含んでいても、scanner がその値をそのまま出力した場合に検出できない可能性があります。#380 の scanner は「secret を見つける」だけでなく「secret を再漏洩しない」ことが主目的なので、stdout/stderr の完全捕捉と sentinel 不在 assertion が必要です。([GitHub]1)

    GitHub Actions では、GitHub secret ではない動的な機微値も ::add-mask::VALUE で mask 登録することが推奨されています。ただし、これは登録後のログ出力に効く補助策であり、scanner 自体が secret 値を出さない設計の代替ではありません。([GitHub Docs]12)

    修正 AC:

    AC: scanner は finding に raw match を含めない。
    - stdout/stderr に fixture sentinel secret の完全一致・部分一致が存在しない
    - finding は rule_id, source_kind, redacted_preview, sha256_prefix, location のみを出す
    - raw_value / matched_text / context_line は JSON 出力にも含めない

    Blocker 7: EntireCLI の実装リスクに対する scanner pattern が浅い

    Entire の README は、hooks が session data を capture し、session metadata を entire/checkpoints/v1 branch に保存すると説明しています。session には prompts、responses、files modified、timestamps が含まれ、checkpoint branch には transcript / prompts / files touched を含む metadata が保存されます。Entire の glossary でも checkpoint remote は metadata 保存先であり、default では code remote に push されると説明されています。([GitHub]13)

    つまり、#380 の scanner は [transcript] や raw_transcript_content だけ見ても不十分です。検出すべきなのは少なくとも以下です。

    entire/checkpoints/v1
    Entire-Checkpoint
    Entire-Attribution
    source_kind: transcript
    source_kind: local_file
    raw_transcript
    prompt
    assistant_response
    tool_result
    /home/
    /Users/
    /tmp/
    C:\
    .env
    BEGIN ... PRIVATE KEY
    sk-...
    sk-proj-...
    ghp_ / gho_ / ghu_ / ghs_ / ghr_

    さらに #378 は visibility: public_github_comment で evidence.source_kind: transcript または local_file を含む manifest を exit 1 にする gate を明記しています。#380 の scanner は manifest semantic validation を独自実装せず、pnpm manifest:check を呼ぶべきです。([GitHub]7)


    Blocker 8: fake token fixture と rotation/revocation required_end_state が矛盾する

    #242 の Kill Switch required_end_state には leaked_credentials_rotated_or_revoked: true が含まれます。#380 は「実 secret は使わない」「fake token fixture のみ」としているため、fixture test で rotated_or_revoked: true を assert すると虚偽の安全証跡になります。([GitHub]2)

    fixture では次のように分けるべきです。

    required_end_state:
      session_recording_tool_enabled: false
      git_hooks_recording_enabled: false
      public_checkpoint_branch_present: false
      auto_push_sessions_allowed: false
      full_transcript_remote_visibility: none
      leaked_credentials_rotated_or_revoked:
        status: not_applicable
        reason: fake_fixture_only
      remediation_ticket_required: true

    本物の secret 露出時だけ rotated_or_revoked: true を要求するのが正しいです。


    修正後の実装方針

    #380 は次の 3 ファイル + CI 接続に絞るのがよいです。

    Allowed Paths
    - `.claude/scripts/kill_switch_runtime_smoke.py`
    - `.claude/scripts/secret_exposure_scanner.py`
    - `tests/session-recording-kill-switch.test.ts`
    - `tests/fixtures/session-recording/**`
    - `package.json` script 追加のみ
    - `.github/workflows/ci.yml` 既存 job への step 追加のみ

    package scripts は以下の形がよいです。

    {
      "scripts": {
        "session-recording:smoke": "python .claude/scripts/kill_switch_runtime_smoke.py --fixtures tests/fixtures/session-recording",
        "secret-exposure:scan": "python .claude/scripts/secret_exposure_scanner.py --local tests/fixtures/session-recording --fail-on-finding",
        "security:session-recording": "pnpm policy:check && pnpm manifest:check && pnpm session-recording:smoke && pnpm secret-exposure:scan"
      }
    }

    scanner output schema は raw 値を禁止します。

    SECRET_EXPOSURE_SCAN_RESULT_V1:
      status: failed
      findings:
        - rule_id: github_token
          source_kind: github_issue_comment
          source_ref: issue:380#comment:<id>
          location:
            line: 12
            column: null
          redacted_preview: "ghp_****abcd"
          fingerprint_sha256_prefix: "12ab34cd56ef"
          raw_value_included: false
      raw_values_emitted: false

    最終判断

    #380 は close せず、契約修正してから implementation に入るべきです。現状のまま実装すると、既に closed になった #377/#378/#379 の成果物を取り込まず、scanner も secret を検出しながら再漏洩する危険が残ります。

    最低限の修正条件は次です。

    1. 実装: agent_session_manifest/v1 deterministic script producer を schema conform で実装する #377/実装: agent_session_manifest producer output の schema validation gate (pnpm manifest:check) を追加する #378/実装: session recording no-push / private checkpoint / local-only verifier を追加する #379 を Remaining Gaps から削除し、消費対象に変更。
    2. CI allowed path を .github/workflows/ci.yml に修正。
    3. Kill Switch smoke は 実装: session recording no-push / private checkpoint / local-only verifier を追加する #379 verifier / 実装: session recording policy guard を Claude hook (Stop/SubagentStop) に統合する #325 guard / 実装: session_recording_policy checker を CI / python-test workflow に統合する #324 policy check / 実装: agent_session_manifest producer output の schema validation gate (pnpm manifest:check) を追加する #378 manifest check の exit code を実行証跡にする。
    4. secret scanner は GitHub comments / PR review comments / artifacts の API・権限・ページング・artifact 展開上限を明記。
    5. raw secret を絶対に stdout/stderr/JSON に出さない sentinel test を AC に追加。
    6. ^[A-Za-z0-9_-]{20,}$ 中心の雑な token regex をやめ、実装: agent_session_manifest/v1 deterministic script producer を schema conform で実装する #377 の rule set + Gitleaks/TruffleHog 相当の provider-aware rules に寄せる。
    7. fake token fixture では rotation/revocation を not_applicable とし、実 secret remediation 証跡を捏造しない。

    この修正後なら、#380 は #246 pilot の前提 gate として意味を持ちます。現状ではまだ「安全装置のテスト」ではなく「安全装置があると主張するテスト」です。

  3. squne121 commented on May 29, 2026

    @squne121
    OwnerAuthor

    Contract Snapshot (2026-05-30T00:00:00Z)

    • Outcome: .claude/scripts/kill_switch_runtime_smoke.py と .claude/scripts/secret_exposure_scanner.py を実装し、実装: session recording no-push / private checkpoint / local-only verifier を追加する #379 verifier を fixture 経由で呼び出す Kill Switch runtime smoke test と、provider-aware rules による secret exposure scanner を CI に統合する
    • Acceptance Criteria: AC1–AC13(全 13 件、すべて <!-- runtime-verification: true --> タグ付き)
    • Verification Commands: 16 コマンド(test -f x2、pnpm test -- --testPathPattern=... x11、pnpm typecheck/lint/test/build x4)
    • Allowed Paths:
      • .claude/scripts/kill_switch_runtime_smoke.py (新規)
      • .claude/scripts/secret_exposure_scanner.py (新規)
      • tests/session-recording-kill-switch.test.ts (新規)
      • tests/fixtures/session-recording/** (fixture)
      • package.json (script 追加のみ)
      • .github/workflows/ci.yml (既存 job への step 追加のみ)
    • Worktree: .claude/worktrees/issue-380-session-recording-kill-switch-runtime-sm
    • Branch: worktree-issue-380-session-recording-kill-switch-runtime-sm
    • VC preflight: baseline fail = 2 (AC1, AC2: file_not_found_expected), 想定外 pass = 0, 実行不可 = 0, regression_gate pass = 14
    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-05-30T00:00:00Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/380
      checks:
        template_compliance: pass
        state_label: ok
        allowed_paths_present: pass
        vc_present: pass
        stop_conditions_complete: pass
        vc_preflight:
          passed: true
          vc_failed_as_expected: 2
          vc_passed_unexpectedly: 0
          vc_unrunnable: 0
          vc_expected_pass: 14
          vc_skipped: 0
          classifications:
            - ac: AC1
              command: "test -f .claude/scripts/kill_switch_runtime_smoke.py"
              exit_code: 1
              category: file_not_found_expected
              scope_class: baseline_fail_expected
              confidence: high
              evidence:
                stdout_excerpt: ""
                stderr_excerpt: ""
              decision: go
            - ac: AC2
              command: "test -f .claude/scripts/secret_exposure_scanner.py"
              exit_code: 1
              category: file_not_found_expected
              scope_class: baseline_fail_expected
              confidence: high
              evidence:
                stdout_excerpt: ""
                stderr_excerpt: ""
              decision: go
            - ac: AC3
              command: "pnpm test -- --testPathPattern=\"kill_switch.*secrets_mode\""
              exit_code: 0
              category: regression_gate
              scope_class: regression_gate
              confidence: low
              evidence:
                stdout_excerpt: "Tests 166 passed (166)"
                stderr_excerpt: ""
              decision: go
            - ac: AC4
              command: "pnpm test -- --testPathPattern=\"kill_switch.*checkpoint_token\""
              exit_code: 0
              category: regression_gate
              scope_class: regression_gate
              confidence: low
              evidence:
                stdout_excerpt: "Tests 166 passed (166)"
                stderr_excerpt: ""
              decision: go
            - ac: AC5
              command: "pnpm test -- --testPathPattern=\"kill_switch.*public_branch\""
              exit_code: 0
              category: regression_gate
              scope_class: regression_gate
              confidence: low
              evidence:
                stdout_excerpt: "Tests 166 passed (166)"
                stderr_excerpt: ""
              decision: go
            - ac: AC6
              command: "pnpm test -- --testPathPattern=\"kill_switch.*raw_transcript\""
              exit_code: 0
              category: regression_gate
              scope_class: regression_gate
              confidence: low
              evidence:
                stdout_excerpt: "Tests 166 passed (166)"
                stderr_excerpt: ""
              decision: go
            - ac: AC7
              command: "pnpm test -- --testPathPattern=\"kill_switch.*required_end_state\""
              exit_code: 0
              category: regression_gate
              scope_class: regression_gate
              confidence: low
              evidence:
                stdout_excerpt: "Tests 166 passed (166)"
                stderr_excerpt: ""
              decision: go
            - ac: AC8
              command: "pnpm test -- --testPathPattern=\"scanner.*transcript\""
              exit_code: 0
              category: regression_gate
              scope_class: regression_gate
              confidence: low
              decision: go
            - ac: AC9
              command: "pnpm test -- --testPathPattern=\"scanner.*token\""
              exit_code: 0
              category: regression_gate
              scope_class: regression_gate
              confidence: low
              decision: go
            - ac: AC10
              command: "pnpm test -- --testPathPattern=\"scanner.*path\""
              exit_code: 0
              category: regression_gate
              scope_class: regression_gate
              confidence: low
              decision: go
            - ac: AC11
              command: "pnpm test -- --testPathPattern=\"scanner.*no_raw\""
              exit_code: 0
              category: regression_gate
              scope_class: regression_gate
              confidence: low
              decision: go
            - ac: AC12
              command: "pnpm test -- --testPathPattern=\"scanner.*fixture\""
              exit_code: 0
              category: regression_gate
              scope_class: regression_gate
              confidence: low
              decision: go
            - ac: AC13
              command: "pnpm typecheck"
              exit_code: 0
              category: regression_gate
              scope_class: regression_gate
              confidence: low
              decision: go
            - ac: AC13
              command: "pnpm lint"
              exit_code: 0
              category: regression_gate
              scope_class: regression_gate
              confidence: low
              decision: go
            - ac: AC13
              command: "pnpm test"
              exit_code: 0
              category: regression_gate
              scope_class: regression_gate
              confidence: low
              decision: go
            - ac: AC13
              command: "pnpm build"
              exit_code: 0
              category: regression_gate
              scope_class: regression_gate
              confidence: low
              decision: go
        ac_verifiability: pass
        product_spec_check:
          applicability: not_applicable
          decision: pass
          triggers:
            docs_product_allowed_paths: false
            tasks_md_mentioned: false
            specify_artifact_mentioned: false
            generated_task_mentioned: false
            product_spec_context_present: false
        worktree_branch_collision: clear
      next_action: implement_issue
      blocked_reasons: []
      warnings:
        - "decision: immediate かつ local test suite のみのため、SKIP exit 77 stop condition は not_applicable と判断(#379 先例一致)。実装者は artifacts/ への証跡書き出しロジックを含めること"
  4. squne121 commented on May 29, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-05-30T07:35:30Z)

    • PR: feat(#380): Kill Switch runtime smoke test と secret exposure scanner を追加する #482
    • Worktree: `.claude/worktrees/issue-380-session-recording-kill-switch-runtime-sm`
    • Branch: `worktree-issue-380-session-recording-kill-switch-runtime-sm`
    • Verification: 4/4 PASS (typecheck / lint / test 179 tests / build)
    • Kill Switch smoke: 5/5 fixtures PASS
    • Secret scanner: AC8–AC12 全 PASS
    • 後続: PR レビュー(pr-review-judge)→ マージ → post-merge-cleanup
  5. added 5 commits that reference this issue on May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/ai-opsarea/securitykind/implementationphase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions