fix(core): wire ShadowMemory into agent loop#4443
Merged
Merged
Conversation
cbe09e0 to
0eb1333
Compare
Add `shadow_memory: Option<ShadowMemory>` to `SecurityState`. The field is instantiated from `security.causal_ipi.shadow_memory` config at startup via a new `with_shadow_memory_config` builder method, independently of whether causal IPI itself is enabled. After every tool batch, `process_tool_result_batch` calls `record_shadow_event` which appends a `ShadowEvent` (turn index, tool names, max permission class, goal summary from the causal pre-probe) and checks `goal_drift_score()`. When `should_alert = true` a WARN log is emitted and a `GoalDrift` security event is pushed to the metrics sink. Spec 010-7 FR-001–FR-004 are now met.
Three builder-level tests verify that with_shadow_memory_config correctly leaves the field as None when disabled and sets it to Some when enabled, and that the memory starts empty after construction.
00995a0 to
c41248d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
shadow_memory: Option<ShadowMemory>field toSecurityStatewith_shadow_memory_configbuilder method inAgentBuilder; wire intoagent_setup.rsrecord_shadow_eventintier_loop.rs: called after each tool batch, emitsSecurityEventCategory::GoalDriftwhendrift.should_alertis trueCloses #4439
Notes
deviation_scorehardcoded to0.0; FR-007 coherence rating deferred (TODO comment left in code)Test plan
cargo nextest run --workspace --lib --bins— 1491 tests in zeph-core passcargo clippy --workspace -- -D warnings— cleancargo +nightly fmt --check— clean