Skip to content

feat(tools): make RiskChainAccumulator cross-turn window configurable - #6680

Merged
bug-ops merged 1 commit into
mainfrom
feat/issue-6603/risk-chain-window-config
Jul 28, 2026
Merged

feat(tools): make RiskChainAccumulator cross-turn window configurable#6680
bug-ops merged 1 commit into
mainfrom
feat/issue-6603/risk-chain-window-config

Conversation

@bug-ops

@bug-ops bug-ops commented Jul 28, 2026

Copy link
Copy Markdown
Owner

Summary

  • Replaces RiskChainAccumulator's hardcoded CROSS_TURN_WINDOW_TURNS = 3 with a real config field, [tools.shell] risk_chain_window_turns, mirroring the sibling [security] window_turns pattern in crates/zeph-config/src/security.rs.
  • RiskChainAccumulator::new now takes &ShellConfig and resolves the window internally (matching how risk_chain_threshold already works), instead of a bare parameter each of the 4 wiring call sites (runner, daemon, acp, serve) would otherwise have to remember to fill correctly.
  • Default stays at 3 (unchanged behavior for existing deployments). 0 is a documented, logged opt-out that disables cross-turn detection entirely — wire_risk_chain's tracing span now logs the resolved window_turns, plus a warn! naming RiskChainAccumulator (exfil_read_then_send / cred_then_egress) is turn-scoped and its cross-turn fallback is unwired #6561 when it's 0.
  • Adds --init wizard prompt and a --migrate-config step for existing configs.
  • Updates specs/010-security/spec.md (prose + Key Invariants) with the threat-model rationale: narrower than the sibling's default of 8 because this window feeds a hard block decision rather than a soft score, and the residual evasion (attacker controls leg spacing beyond the window) is an accepted, bounded risk — unchanged from the pre-existing fix(security): close RiskChainAccumulator cross-turn and cross-session gaps #6602 behavior.

Closes #6603

Test plan

  • cargo +nightly fmt --check
  • cargo clippy --profile ci --workspace --all-targets --features "desktop,ide,server,chat,pdf,scheduler,testing" -- -D warnings
  • cargo nextest run --config-file .github/nextest.toml --workspace --features "desktop,ide,server,chat,pdf,scheduler" --lib --bins (15149/15149 passed)
  • Rustdoc gate (RUSTFLAGS="-D warnings" RUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links" cargo doc --no-deps --workspace --features ...)
  • New tests: custom window sizes (narrower/wider/zero), zero-disables-detection, migration step idempotency, default-vs-narrow-window comparison
  • gitleaks protect --staged — no leaks
  • .local/testing/playbooks/risk-chain-accumulator.md and .local/testing/coverage-status.md updated (main repo root)
  • CHANGELOG.md updated under [Unreleased]

@github-actions github-actions Bot added enhancement New feature or request size/L Large PR (201-500 lines) documentation Improvements or additions to documentation rust Rust code changes config Configuration file changes labels Jul 28, 2026
@bug-ops
bug-ops force-pushed the feat/issue-6603/risk-chain-window-config branch from 0431e36 to c6d8366 Compare July 28, 2026 02:30
@bug-ops
bug-ops enabled auto-merge (squash) July 28, 2026 02:30
CROSS_TURN_WINDOW_TURNS was a hardcoded constant with no stated rationale
relative to the sibling `[security] window_turns` config. Expose it as
`[tools.shell] risk_chain_window_turns`, threaded through &ShellConfig
(matching risk_chain_threshold's resolution pattern) instead of a
per-call-site parameter, with --init wizard and --migrate-config support.

Default stays at 3 (unchanged behavior); 0 is a documented, logged
opt-out that disables cross-turn detection. Module docs and
specs/010-security/spec.md now state the threat-model rationale and the
accepted, bounded residual evasion window.
@bug-ops
bug-ops force-pushed the feat/issue-6603/risk-chain-window-config branch from c6d8366 to e372b60 Compare July 28, 2026 02:40
@bug-ops
bug-ops merged commit ea76d5c into main Jul 28, 2026
43 checks passed
@bug-ops
bug-ops deleted the feat/issue-6603/risk-chain-window-config branch July 28, 2026 02:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config Configuration file changes documentation Improvements or additions to documentation enhancement New feature or request rust Rust code changes size/L Large PR (201-500 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RiskChainAccumulator's cross-turn detection window is hardcoded, not configurable

1 participant