Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix: preserve subagent tracking across ingest filters
AkitaOnRails939d575e5217
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 22b598a0..46b56f5d 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -17,7 +17,9 @@ version in [`docs/changelog/`](docs/changelog/):to the existing `drop_tool_use_id_prefixes` and `drop_tool_names`. A droppedevent gets the same 202, `dropped_by_policy` metric and log as the otherpolicy drops, before the rate limiter, the ingest semaphore and the- sanitizer. The default drops nothing. `Config::load` checks each value+ sanitizer. Subagent classification precedes every id, name, and kind matcher,+ so a matching marked event still seeds tracking for its unmarked tail. The+ default drops nothing. `Config::load` checks each valueagainst the typed event kind and rejects unknown kinds and `session-start`and `session-end`, which open and close sessions. The motivating case is`pre-tool-use`: in one production store about 87% of those observations haddiff --git a/crates/ai-memory-cli/src/commands/serve.rs b/crates/ai-memory-cli/src/commands/serve.rsindex ae28908e..ee86d6df 100644--- a/crates/ai-memory-cli/src/commands/serve.rs+++ b/crates/ai-memory-cli/src/commands/serve.rs@@ -1610,7 +1610,7 @@ pub async fn run(config: &Config, args: ServeArgs) -> Result<()> {trusted_proxy_identity: trusted_proxy_identity_enabled(&config.auth),mid_session_routing: config.routing.mid_session,profile: config.profile.clone(),- ingest_drop_list: config.ingest.drop_list.clone(),+ ingest_drop_list: (*config.ingest.drop_list).clone(),});let workstreams = workstream_router(WorkstreamState {writer: store.writer.clone(),diff --git a/crates/ai-memory-cli/src/config.rs b/crates/ai-memory-cli/src/config.rsindex d1f304bc..8f95b87d 100644--- a/crates/ai-memory-cli/src/config.rs+++ b/crates/ai-memory-cli/src/config.rs@@ -1318,9 +1318,11 @@ pub struct IngestSettings {#[serde(default, deserialize_with = "deserialize_string_or_vec")]pub drop_events: Vec<String>,/// The validated list the hook router checks. Set by [`Config::load`];- /// never read from or written to a config file.+ /// never read from or written to a config file. Kept off the `Config`+ /// stack frame because that value is constructed in short-stack CLI+ /// entry points on Windows.#[serde(skip)]- pub drop_list: ai_memory_hooks::IngestDropList,+ pub drop_list: Box<ai_memory_hooks::IngestDropList>,}/// Client-side hook spool retry policy.@@ -2493,12 +2495,14 @@ impl Config {if let Err(message) = config.search.fts.validate() {anyhow::bail!("{message}");}- config.ingest.drop_list = ai_memory_hooks::IngestDropList::new(- config.ingest.drop_tool_use_id_prefixes.clone(),- config.ingest.drop_tool_names.clone(),- &config.ingest.drop_events,- )- .map_err(|message| anyhow::anyhow!(message))?;+ config.ingest.drop_list = Box::new(+ ai_memory_hooks::IngestDropList::new(+ config.ingest.drop_tool_use_id_prefixes.clone(),+ config.ingest.drop_tool_names.clone(),+ &config.ingest.drop_events,+ )+ .map_err(|message| anyhow::anyhow!(message))?,+ );// A4 entropy filter thresholds: reject an unusable threshold at startup// rather than silently ignoring it on the first experience pass.if let Err(message) = config@@ -5038,8 +5042,8 @@ input_token_safety_margin = {margin}.unwrap();let config = Config::load(Some(&config_path), Some(tmp.path().to_path_buf())).unwrap();assert_eq!(- config.ingest.drop_list,- ai_memory_hooks::IngestDropList::new(+ config.ingest.drop_list.as_ref(),+ &ai_memory_hooks::IngestDropList::new(vec!["toolu_plugin_".into()],vec!["mcp__noisy__poll".into()],&[]@@ -5056,8 +5060,8 @@ input_token_safety_margin = {margin}// Default: empty, so nothing is dropped.assert_eq!(- Config::default().ingest.drop_list,- ai_memory_hooks::IngestDropList::default()+ Config::default().ingest.drop_list.as_ref(),+ &ai_memory_hooks::IngestDropList::default());}@@ -5074,8 +5078,8 @@ input_token_safety_margin = {margin}// The raw value survives, and the validated list is built from it.assert_eq!(config.ingest.drop_events, vec!["pre-tool-use".to_string()]);assert_eq!(- config.ingest.drop_list,- ai_memory_hooks::IngestDropList::new(Vec::new(), Vec::new(), &["pre-tool-use".into()])+ config.ingest.drop_list.as_ref(),+ &ai_memory_hooks::IngestDropList::new(Vec::new(), Vec::new(), &["pre-tool-use".into()]).unwrap());@@ -5113,8 +5117,8 @@ input_token_safety_margin = {margin}// Default: empty, so nothing is dropped.assert_eq!(Config::default().ingest.drop_events, Vec::<String>::new());assert_eq!(- Config::default().ingest.drop_list,- ai_memory_hooks::IngestDropList::default()+ Config::default().ingest.drop_list.as_ref(),+ &ai_memory_hooks::IngestDropList::default());}diff --git a/crates/ai-memory-cli/templates/config.default.toml b/crates/ai-memory-cli/templates/config.default.tomlindex 876da8b8..b14bc942 100644--- a/crates/ai-memory-cli/templates/config.default.toml+++ b/crates/ai-memory-cli/templates/config.default.toml@@ -60,7 +60,9 @@ log_level = "info"# discards a matching PreToolUse/PostToolUse event before it is sanitized or# stored, whatever the client sends. Applies to every project on this server.# At most 64 entries per list, 128 characters each. Example: Claude Code marks-# plugin tool calls with their own tool-use id prefix.+# plugin tool calls with their own tool-use id prefix. Subagent classification+# runs first, so a matching marked event still seeds tracking that suppresses+# the subagent session's unmarked tail.# [ingest]# drop_tool_use_id_prefixes = ["toolu_plugin_"]# drop_tool_names = ["mcp__noisy__poll"]diff --git a/crates/ai-memory-hooks/src/drop_list.rs b/crates/ai-memory-hooks/src/drop_list.rsindex fc248d3a..a53b01f6 100644--- a/crates/ai-memory-hooks/src/drop_list.rs+++ b/crates/ai-memory-hooks/src/drop_list.rs@@ -4,11 +4,11 @@//! client sends: tool calls by tool-use id prefix (Claude Code marks plugin//! tool calls with their own id prefix) and tool names exactly, plus whole//! hook event kinds (`drop_events`). A matching event is acknowledged like-//! any other policy drop — the tool lists right after the client capture-//! protocol, the whole kinds right after the subagent exclusion, in both the-//! single and the batch ingress — before it reaches the rate limiter, the-//! ingest semaphore, the sanitizer or storage. The lists are read once at-//! startup and bounded, so the checks stay cheap on the hook path.+//! any other policy drop. All lists run right after the subagent exclusion in+//! both the single and the batch ingress, so a marked event always seeds tail+//! tracking before a policy matcher can drop it, and before it reaches the rate+//! limiter, the ingest semaphore, the sanitizer or storage. The lists are read+//! once at startup and bounded, so the checks stay cheap on the hook path.use crate::payload::{HookEnvelope, HookEvent};@@ -24,11 +24,9 @@ pub const MAX_DROP_ENTRY_CHARS: usize = 128;/// are read once at startup and bounded, so the checks stay cheap on the hook/// path.///-/// The two checks run at different router positions, on purpose: [`matches`]-/// (the tool id/name lists) runs right after the client capture protocol, and-/// [`matches_event_kind`] runs right after the subagent exclusion, so a-/// marked subagent event still seeds the tracking set its unmarked tail is-/// dropped against even when its kind is listed.+/// Both checks run after the subagent exclusion, so a marked subagent event+/// still seeds the tracking set its unmarked tail is dropped against even when+/// its tool id, tool name, or event kind is listed.#[derive(Debug, Clone, Default, PartialEq, Eq)]pub struct IngestDropList {tool_use_id_prefixes: Vec<String>,diff --git a/crates/ai-memory-hooks/src/router.rs b/crates/ai-memory-hooks/src/router.rsindex 5846a694..8427646f 100644--- a/crates/ai-memory-hooks/src/router.rs+++ b/crates/ai-memory-hooks/src/router.rs@@ -552,10 +552,10 @@ pub struct HookState {pub profile: ai_memory_core::profile::ProfileSettings,/// `[ingest]` drop list: tool events matching a listed tool-use id prefix/// or tool name are acknowledged and dropped before any capacity is spent- /// (#1241), checked right after the client capture protocol; events whose- /// whole kind is listed (`drop_events`, e.g. `pre-tool-use`) are dropped- /// the same way, checked right after the subagent exclusion so a marked- /// subagent event still seeds its tail tracking. Empty by default.+ /// (#1241); events whose whole kind is listed (`drop_events`, e.g.+ /// `pre-tool-use`) are dropped the same way. All matchers run after the+ /// subagent exclusion so a marked event still seeds its tail tracking.+ /// Empty by default.pub ingest_drop_list: crate::drop_list::IngestDropList,}@@ -698,44 +698,29 @@ async fn admit_hook(HookProcessingOutcome::DroppedInvalid.record(&state.ingest_metrics);return (StatusCode::ACCEPTED, "cursor draft placeholder dropped");}- // The operator's server-side tool drop list (#1241): acknowledged as a- // policy drop before the rate limiter or the semaphore, so it costs- // nothing.- if state.ingest_drop_list.matches(&env) {- HookProcessingOutcome::DroppedPolicy.record(&state.ingest_metrics);- return (StatusCode::ACCEPTED, "ingest drop list");- }// Accept-but-drop subagent captures (incl. the unmarked tail of tracked// subagent sessions) when the operator opts in. Returning 202 (not an error)// means the client treats the event as delivered and never retries/spools// it. Runs before the semaphore so a dropped event consumes no capacity.- // The auth middleware in front of `/hook` injects the request's- // [`ActorContext`] (rung 1 root, rung 2 DB user, or anonymous). We- // capture the identity it names NOW — before the spawn drops the request- // extensions — so `process()` can key the `ActiveProject` map by the- // authenticated identity when `[auto_scope] mode = per_actor` is on.- let actor = actor_identity(actor_ext);- // Captured here for the same reason as the actor: the request extensions- // are gone by the time the spawned task runs. `AuthorizedViewer` is the- // gated marker, so this is `None` whenever per-repository authorization is- // off, and captures behave exactly as they always have.+ // `AuthorizedViewer` is the gated marker, so this is `None` whenever+ // per-repository authorization is off.let viewer = viewer_ext.map(|axum::Extension(v)| v.user());- // Same reason: the skip-list header is read here, while the request- // extensions still exist, and travels with the event into `process()`.- let skip_webhooks = admission_skips(level_ext, &headers);- let actor_storage_key = actor.as_ref().map(IdentityKey::storage_key);if should_drop_subagent(&state, &env, viewer).await {HookProcessingOutcome::DroppedSubagent.record(&state.ingest_metrics);return (StatusCode::ACCEPTED, "subagent capture dropped");}- // Whole-kind drops (`[ingest] drop_events`): after the subagent exclusion,- // so a marked subagent event still seeds the tracking set its unmarked- // tail is dropped against, but before the rate limiter and the semaphore,- // so a dropped event still costs nothing.- if state.ingest_drop_list.matches_event_kind(&env) {+ // All server-side ingest matchers run after subagent classification. A+ // matching marked tool event must still seed the tracking set used to+ // suppress that subagent session's unmarked tail. Policy drops remain+ // ahead of the rate limiter and semaphore, so they cost no capacity.+ if state.ingest_drop_list.matches(&env) || state.ingest_drop_list.matches_event_kind(&env) {HookProcessingOutcome::DroppedPolicy.record(&state.ingest_metrics);return (StatusCode::ACCEPTED, "ingest drop list");}+ // Capture request extensions before the spawned processor owns the event.+ let actor = actor_identity(actor_ext);+ let actor_storage_key = actor.as_ref().map(IdentityKey::storage_key);+ let skip_webhooks = admission_skips(level_ext, &headers);let Ok(permit) = state.ingest_semaphore.clone().try_acquire_owned() else {state.ingest_metrics.record_shed_saturated();warn!("hook ingest saturated; dropping event with 429");@@ -990,16 +975,6 @@ async fn handle_hook_batch(accepted_indices.push(idx);continue;}- // Server-side tool drop list (#1241), acknowledged like a policy drop.- if state.ingest_drop_list.matches(&env) {- HookProcessingOutcome::DroppedPolicy.record(&state.ingest_metrics);- results.push(HookBatchResult {- index: idx,- outcome: HookProcessingOutcome::DroppedPolicy,- });- accepted_indices.push(idx);- continue;- }// Accept-but-drop subagent captures (see `handle_hook`): count the item// as committed so the client clears it from its spool, but do not store// it. Keeps the contiguous-prefix ack contract intact.@@ -1012,10 +987,10 @@ async fn handle_hook_batch(accepted_indices.push(idx);continue;}- // Whole-kind drops (`[ingest] drop_events`): after the subagent- // exclusion (a marked event still seeds its tail tracking), before the- // semaphore, the rate limiter and storage.- if state.ingest_drop_list.matches_event_kind(&env) {+ // All ingest matchers run after subagent classification, so a marked+ // tool event still seeds tracking even when its id, name, or kind is+ // configured for policy drop.+ if state.ingest_drop_list.matches(&env) || state.ingest_drop_list.matches_event_kind(&env) {HookProcessingOutcome::DroppedPolicy.record(&state.ingest_metrics);results.push(HookBatchResult {index: idx,@@ -10481,6 +10456,209 @@ pub(crate) mod tests {assert!(kinds.contains(&ObservationKind::UserPrompt), "{kinds:?}");}+ /// The older tool-id and tool-name lists must follow the same ordering as+ /// `drop_events`: a matching marked event seeds subagent tracking before+ /// policy matching. This covers both matchers on the single-event ingress,+ /// with an unrelated top-level session as the legitimate control.+ #[tokio::test]+ async fn marked_tool_policy_drops_seed_subagent_tracking_before_single_ingress_matching() {+ let tmp = TempDir::new().unwrap();+ let mut state = make_state(&tmp).await;+ with_drop_list(&mut state);+ let metrics = state.ingest_metrics.clone();+ let state = Arc::new(state);+ let query = |event: &str| HookQuery {+ event: event.into(),+ agent: Some("grok".into()),+ drop_subagent: Some("1".into()),+ ..Default::default()+ };++ for (session_id, tool) in [+ (+ "tool-prefix-subagent",+ serde_json::json!({+ "tool_name": "Read",+ "tool_use_id": "toolu_plugin_marked"+ }),+ ),+ (+ "tool-name-subagent",+ serde_json::json!({ "tool_name": "mcp__noisy__poll" }),+ ),+ ] {+ let mut marked = tool;+ marked["sessionId"] = session_id.into();+ marked["subagentType"] = "general-purpose".into();+ let result = admit_hook(+ state.clone(),+ query("post-tool-use"),+ None,+ None,+ None,+ HeaderMap::new(),+ marked,+ )+ .await;+ assert_eq!(+ result,+ (StatusCode::ACCEPTED, "subagent capture dropped"),+ "{session_id}: classification must seed before its tool matcher"+ );++ let result = admit_hook(+ state.clone(),+ query("user-prompt-submit"),+ None,+ None,+ None,+ HeaderMap::new(),+ serde_json::json!({ "sessionId": session_id, "prompt": "tail" }),+ )+ .await;+ assert_eq!(+ result,+ (StatusCode::ACCEPTED, "subagent capture dropped"),+ "{session_id}: the unmarked tail must remain suppressed"+ );+ assert!(+ state+ .reader+ .observations_for_session(SessionId::from_native(session_id))+ .await+ .unwrap()+ .is_empty(),+ "{session_id}: neither event may reach storage"+ );+ }++ let result = admit_hook(+ state.clone(),+ query("user-prompt-submit"),+ None,+ None,+ None,+ HeaderMap::new(),+ serde_json::json!({ "sessionId": "tool-list-top-level", "prompt": "keep" }),+ )+ .await;+ assert_eq!(result, (StatusCode::ACCEPTED, "queued"));+ let observations = wait_for_kinds(+ &state,+ "tool-list-top-level",+ &[ObservationKind::UserPrompt],+ )+ .await;+ assert_eq!(observations.len(), 1, "the top-level control is stored");+ let snapshot = metrics.snapshot();+ assert_eq!(snapshot.dropped_by_policy, 4);+ assert_eq!(snapshot.accepted, 1);+ }++ /// Batch-path sibling of the single-ingress ordering regression above.+ #[tokio::test]+ async fn marked_tool_policy_drops_seed_subagent_tracking_before_batch_matching() {+ let tmp = TempDir::new().unwrap();+ let mut state = make_state(&tmp).await;+ with_drop_list(&mut state);+ let metrics = state.ingest_metrics.clone();+ let state = Arc::new(state);+ let url = |event: &str| format!("http://h/hook?event={event}&agent=grok&drop_subagent=1");+ let items = vec![+ HookBatchItem {+ url: url("post-tool-use"),+ body: serde_json::json!({+ "sessionId": "batch-prefix-subagent",+ "subagentType": "general-purpose",+ "tool_name": "Read",+ "tool_use_id": "toolu_plugin_marked"+ }),+ },+ HookBatchItem {+ url: url("user-prompt-submit"),+ body: serde_json::json!({+ "sessionId": "batch-prefix-subagent",+ "prompt": "tail"+ }),+ },+ HookBatchItem {+ url: url("post-tool-use"),+ body: serde_json::json!({+ "sessionId": "batch-name-subagent",+ "subagentType": "general-purpose",+ "tool_name": "mcp__noisy__poll"+ }),+ },+ HookBatchItem {+ url: url("user-prompt-submit"),+ body: serde_json::json!({+ "sessionId": "batch-name-subagent",+ "prompt": "tail"+ }),+ },+ HookBatchItem {+ url: url("user-prompt-submit"),+ body: serde_json::json!({+ "sessionId": "batch-tool-list-top-level",+ "prompt": "keep"+ }),+ },+ ];++ let response = handle_hook_batch(+ State(state.clone()),+ None,+ None,+ None,+ HeaderMap::new(),+ Json(items),+ )+ .await+ .into_response();+ assert_eq!(response.status(), StatusCode::OK);+ let bytes = axum::body::to_bytes(response.into_body(), 64 * 1024)+ .await+ .unwrap();+ let ack: serde_json::Value = serde_json::from_slice(&bytes).unwrap();+ assert_eq!(ack["accepted"], 5, "{ack}");+ let outcomes: Vec<_> = ack["results"]+ .as_array()+ .unwrap()+ .iter()+ .map(|result| result["outcome"].as_str().unwrap())+ .collect();+ assert_eq!(+ outcomes,+ vec![+ "dropped_subagent",+ "dropped_subagent",+ "dropped_subagent",+ "dropped_subagent",+ "stored"+ ]+ );+ for session_id in ["batch-prefix-subagent", "batch-name-subagent"] {+ assert!(+ state+ .reader+ .observations_for_session(SessionId::from_native(session_id))+ .await+ .unwrap()+ .is_empty(),+ "{session_id}: neither event may reach storage"+ );+ }+ let observations = state+ .reader+ .observations_for_session(SessionId::from_native("batch-tool-list-top-level"))+ .await+ .unwrap();+ assert_eq!(observations.len(), 1, "the top-level control is stored");+ let snapshot = metrics.snapshot();+ assert_eq!(snapshot.dropped_by_policy, 4);+ assert_eq!(snapshot.accepted, 1);+ }+#[tokio::test]async fn drop_subagent_tracking_is_scoped_by_project() {let tmp = TempDir::new().unwrap();diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.mdindex 0974d43b..69716db7 100644--- a/docs/ARCHITECTURE.md+++ b/docs/ARCHITECTURE.md@@ -1314,11 +1314,10 @@ max_attempts = 8 # failed drain passes before dropping an event[ingest] # server-side drop list for tool events (#1241)drop_tool_use_id_prefixes = [] # e.g. ["toolu_plugin_"]: drop a tool event whose id starts sodrop_tool_names = [] # exact tool names to drop; both lists apply to every project,- # at most 64 entries of 128 characters, checked before the- # sanitizer, rate limiter and ingest semaphore+ # at most 64 entries of 128 charactersdrop_events = [] # whole hook event kinds to drop (e.g. ["pre-tool-use"]); a# matching event is acknowledged and discarded before storage,- # checked right after the subagent exclusion (a marked+ # all three lists are checked right after the subagent exclusion (a marked# subagent event still seeds its tail tracking) and before the# rate limiter, the ingest semaphore and the sanitizer.# session-start/session-end are rejected (they open/close thediff --git a/docs/security-boundaries.md b/docs/security-boundaries.mdindex 9bd0dc14..5243465e 100644--- a/docs/security-boundaries.md+++ b/docs/security-boundaries.md@@ -91,7 +91,7 @@ means the boundary is not built yet.| 11h | Docker-wrapper capture-policy capability (#1002) | `bin/ai-memory` routes ordinary Linux/macOS `install-hooks`, upgrade refreshes, and every `hook`/`hook-drain` invocation through the stable checksum-verified native host client, so the hook process executes the capture-policy boundary in 11b before spool/network; a hook config that calls the wrapper never runs in the helper container, and an unavailable client drops the event with exit 0 instead of falling back to it. Only an explicit `AI_MEMORY_HOOK_PLATFORM=posix|windows` retains the documented script compatibility path and its warning; `AI_MEMORY_NATIVE_BIN` may not point back to the wrapper. For a server initialized on the named volume, `bin/ai-memory` `refresh_volume_token` (run only by `install-hooks`) copies `/data/auth-tokens/default` (only when `/data/config.toml` names it) to an owner-only `native-runner/server-token` through the helper's stdout, and `use_volume_token` points the native client at that copy (the managed host commands and `mcp-bridge` only read it and never enter the container engine) with `AI_MEMORY_AUTH__BEARER_TOKEN_FILE`, so it is a file-sourced token (never rendered into a harness config) and never an argv; a refresh that reads no token from a reachable volume deletes the copy, and a successful full `uninstall --apply` deletes it after the container returns; a bind-mounted `AI_MEMORY_DATA_DIR` is read directly and an explicit `AI_MEMORY_AUTH_TOKEN` wins | `scripts/check-native-packaging.sh` `Checking host-launch wrapper routing`: a default allowlist install reaches the fake native client while a Docker executable that always fails proves no container fallback occurred; the explicit `posix` control reaches fake Docker and adds no native invocation; the self-referential native override is refused. `tests/wrapper_upgrade.sh` `lifecycle hook native host routing`: `hook --event session-start` and `hook-drain` reach the fake native client with the stdin payload while `docker`/`podman` stubs on PATH and in `AI_MEMORY_DOCKER` stay unused, and a non-executable `AI_MEMORY_NATIVE_BIN` exits 0 without reaching the engine; `Checking the wrapper hands host commands the volume's root bearer`: for `mcp-bridge`, `install-hooks` and `run` the fake native client receives the token file (mode 600, right content) and the token is absent from its argv; controls: a bind-mounted data dir and an explicit `AI_MEMORY_AUTH_TOKEN` make no copy and ask no container (bite: dropping the export fails the check); `Checking the host token copy goes with the volume's token and with uninstall`: a volume answering with no token removes the copy and hands none over, while an unreachable engine keeps it; a dry-run, `--only hooks` or failing `uninstall` keeps it and a successful `uninstall --apply` removes it (bite: without either removal the check fails); `auth_default_e2e.rs` `a_host_client_given_the_token_file_by_env_authenticates` (the native side of the handoff, with a no-variable control) | STRONG on the shipped Linux/macOS wrapper. Windows and remote/manual script installers remain explicitly outside capture-policy v1 || 11j | Offline recovery journal and transcript replay | `ai-memory-cli/src/commands/recovery.rs` keeps bounded locators, ordered semantic transcript digests, pre-launch cursors and persistent correlated-delivery/loss evidence in an atomic journal, refuses a symlinked data dir and any symlinked component inside it (ancestors above the data dir are trusted, so macOS `/var` → `/private/var` works), sanitizes/caps failure reasons, and bounds each replay plus the whole pass; `hook_spool` coordinates enqueue and quarantine with short filesystem locks, canonically resolves partial scope from the recorded cwd, bounds per-file reads and current global occupancy across the main spool and recovery directories, sweeps completed tombstones, and holds correlated events outside drain until replay succeeds or restores them on failure; degraded resumes use `ai-memory-workstream`'s adapter-validated delta export, whose blocking parse and baseline scans are capped by record, event-count, source-byte and serialized-byte totals; `backfill::import_exact_session` chunks by item and byte limits and requires per-item durable acknowledgements; `run.rs` journals every session launch, including explicit spool-only evidence for unsupported exporters, and journals a resumed export only after capturing its exact pre-launch cursor; `workstream.rs` `/recover/finish` retains owner/project authorization, rejects superseded runs, and validates a finished retry by durable transcript/native/cursor/exit identity without regenerating its checkpoint; validated recovery ingest keys bind session, agent, event kind and sanitized event identity until session purge | `transcript.rs` `persisted_baseline_exports_only_offline_append_and_rejects_rewrite`, parser/baseline cap and ordered-semantic digest tests; CLI `run_offline.rs` real degraded spool-only and overlap/idempotency tests; `recovery.rs` `spool_only_without_correlated_evidence_never_auto_clears`, `a_dropped_spool_event_stays_lost_on_the_next_empty_pass`, loss/time-budget tests, `symlinked_journal_and_ancestor_are_refused`, `a_symlinked_ancestor_of_the_data_dir_is_trusted`, `a_symlink_inside_a_data_dir_under_a_symlinked_ancestor_is_refused`; `hook_spool.rs` partial-scope late enqueue, completion-race, occupancy churn/active-cap, bounded-read and tombstone-sweep tests, plus interval isolation (`completed_tombstone_keeps_a_later_resume_of_the_same_session` proves a post-interval resume hook is delivered, `completing_one_recovery_interval_leaves_the_other_intervals_entries_intact` proves one interval's completion never consumes another's evidence and ambiguous entries fail closed into the main spool); `backfill.rs` `two_sequential_recovery_intervals_on_one_resumed_session_replay_exactly_once` proves the second interval's content and session-end are stored with end-of-session effects while reruns stay pure replays; `transcript.rs` `an_oversized_first_record_is_skipped_by_session_listing_caps` proves the first-record byte caps bite before allocation; store `insert_observation_ingest_dedups_on_key` rejects cross-session and changed-event preclaims; hooks `expired_run_recovery_is_owner_only_and_refuses_superseded_runs` proves changed transcript refusal and changed-checkpoint no-op | STRONG on Unix integration coverage; Unix lock opens use no-follow and atomic replacement rechecks the destination. Windows owner-only ACL/reparse and lock semantics require the PR `windows` lane || 11i | OpenCode executable probing and generated-config cleanup (#1097) | `ai-memory-cli/src/config.rs` captures the full process environment once in typed `RuntimeEnv`; `run.rs` overlays explicit `run --env` values with platform key semantics and uses that same effective environment for executable resolution, probing, and launch without rereading process environment; `opencode_dialect.rs` invokes only direct argv `--version`, caps output and time, and rejects malformed/future majors. Automatic launch skips only OpenCode on probe failure; explicit OpenCode fails. `install_hooks.rs` quarantines the incompatible sibling before reading its exact ownership markers, restores unowned content with an atomic no-replace link, and never deletes or overwrites a concurrent replacement; `install_mcp.rs` owns the shared dual-schema endpoint/token inference used by both installers, rejects conflicting generated V1/V2 entries before mutation, and migrates an alternate-major entry only when endpoint, generated shape, and absent-or-Authorization-only headers match, preserving custom headers and ambiguous entries; auto-wire migrates MCP before hooks infer from that exact config path and skips hook mutation when transition preflight fails | `run.rs` `automatic_opencode_probe_failure_keeps_another_harness_available`, `opencode_executable_probe_selects_v2_for_launch_and_autowire`, effective-child-environment PATH casing controls, fake V1/V2/env-derived-major/malformed/future/timeout executable tests, `setup-agent` V1/V2 no-probe integration controls; `install_hooks.rs` `opencode_plugin_cleanup_removes_only_exact_owned_incompatible_sibling`, `opencode_plugin_cleanup_preserves_a_concurrent_user_replacement`, `opencode_plugin_restore_moves_quarantine_when_destination_is_free`, `opencode_plugin_restore_preserves_an_existing_replacement`, `opencode_plugin_restore_does_not_replace_a_file_created_at_restore_window`, `opencode_plugin_cleanup_does_not_escape_custom_target_directory`; `install_mcp.rs` `opencode_install_reuses_owned_endpoint_and_token_across_major_transitions`, `opencode_install_refuses_conflicting_owned_transition_entries`, `opencode_install_does_not_infer_from_a_user_owned_transition_entry`, `opencode_mcp_migration_moves_only_owned_alternate_shape`, `opencode_mcp_migration_preserves_ambiguous_user_entry`, `opencode_mcp_migration_preserves_custom_headers`, `opencode_mcp_migration_accepts_only_historical_generated_headers` | STRONG for Unix process probes and platform-neutral ownership gates; exact Windows executable resolution remains covered by `run.rs` resolver tests and requires the PR `windows` label |-| 11k | Server-side ingest drop list: tool id/name lists (#1241) and whole event kinds (`[ingest] drop_events`) | `ai-memory-hooks/src/drop_list.rs` `IngestDropList`: `matches` for the tool lists (a tool-call id by prefix, a tool name exactly) and `matches_event_kind` for the whole kinds (every `[ingest] drop_events` value parsed with the typed `HookEvent::parse`; `session-start`/`session-end` and the `other` bucket rejected), both validated once in `Config::load` (tool lists: at most 64 entries of 128 printable characters each). Checked in `router.rs` `admit_hook` and the `handle_hook_batch` loop, both before the rate limiter, the ingest semaphore, the sanitizer and storage: the tool lists right after the client capture protocol, the whole kinds right after the subagent exclusion (`should_drop_subagent`), so a marked subagent event seeds the tracking set its unmarked tail is dropped against even when its kind is listed. The tool lists match only tool events and are read through the per-agent mapping `capture_policy::tool_payload_fields` that tool metadata uses (generic Claude-style fields for an agent without one; Factory Droid sends no tool-call id, so only its tool name can match; Meta Muse Code sends its provider call id in `tool_use_id`, and CodeBuddy Code Claude Code's `tool_use_id`, so both can). A drop answers 202 and counts as `dropped_by_policy`; the matched value is never logged | tool lists: `router.rs` `the_ingest_drop_list_drops_before_any_capacity_is_spent` (with the semaphore exhausted a listed event still answers 202; control: an unlisted one gets 429) and `the_ingest_drop_list_applies_to_hook_batches` (listed items acknowledged as policy drops, the unlisted item ingested); `drop_list.rs` unit tests (prefix only at the start, names only exact, non-tool events never match, bounds refused; `each_agent_is_matched_on_its_own_tool_fields` matches OpenCode `callID`, Hermes `extra.tool_call_id`, Antigravity `toolCall.name`, Muse and CodeBuddy `tool_use_id` and CodeBuddy `tool_name`, with same-agent controls kept, and fails when only the generic fields are read). Both router tests fail with `matches` forced to `false`. whole kinds: `router.rs` `the_ingest_drop_events_drops_the_named_kind_and_keeps_the_rest` (the named kind acknowledged and not stored; the pair, the prompt and a lifecycle event stored; lifecycle not dropped), `the_ingest_drop_events_drops_before_any_capacity_is_spent` (semaphore exhausted: the named kind still answers 202, a kept kind gets 429), `the_ingest_drop_events_consumes_no_rate_budget` (burst 1: kind drops spend no rate token, the source's first kept event is admitted, the second is 429), `the_ingest_drop_events_batch_reports_per_index_outcomes_and_only_stores_the_kept` (per-index `dropped_policy`/`stored` results; kept events persisted, the dropped one absent), `the_ingest_drop_events_keeps_dropping_the_unmarked_subagent_tail` and `the_ingest_drop_events_keeps_dropping_the_unmarked_subagent_tail_in_batches` (with `drop_events = ["subagent-start"]` the marked start seeds the tracking, the unmarked tail drops on both ingresses, and a non-subagent prompt is kept), `a_marked_event_of_a_dropped_kind_still_seeds_subagent_tracking` (a marked `pre-tool-use` listed in `drop_events` still seeds before it is dropped); `drop_list.rs` `drop_events_*` unit tests (kind-only matching, wire spellings, session-state and unknown kinds refused). Mutants: the kind check moved back before the subagent exclusion fails the two tail tests and the seeding test; removing the batch kind check, or its result entry, fails the batch contract test | STRONG. The list applies to every project on the server; it narrows what is stored and never widens access |+| 11k | Server-side ingest drop list: tool id/name lists (#1241) and whole event kinds (`[ingest] drop_events`) | `ai-memory-hooks/src/drop_list.rs` `IngestDropList`: `matches` for the tool lists (a tool-call id by prefix, a tool name exactly) and `matches_event_kind` for the whole kinds (every `[ingest] drop_events` value parsed with the typed `HookEvent::parse`; `session-start`/`session-end` and the `other` bucket rejected), both validated once in `Config::load` (tool lists: at most 64 entries of 128 printable characters each). Checked in `router.rs` `admit_hook` and the `handle_hook_batch` loop after the subagent exclusion (`should_drop_subagent`) and before the rate limiter, ingest semaphore, sanitizer, and storage, so a marked subagent event seeds the tracking set its unmarked tail is dropped against even when its tool id, tool name, or event kind is listed. The tool lists match only tool events and are read through the per-agent mapping `capture_policy::tool_payload_fields` that tool metadata uses. A drop answers 202 and counts as `dropped_by_policy`; the matched value is never logged | tool lists: `router.rs` `the_ingest_drop_list_drops_before_any_capacity_is_spent`, `the_ingest_drop_list_applies_to_hook_batches`, `marked_tool_policy_drops_seed_subagent_tracking_before_single_ingress_matching`, and `marked_tool_policy_drops_seed_subagent_tracking_before_batch_matching` cover capacity, batch acknowledgements, id-prefix and exact-name seeding order, unmarked tails, and stored controls; `drop_list.rs` unit tests cover bounds, exact matching, and each agent's native fields. Whole kinds: `router.rs` `the_ingest_drop_events_drops_the_named_kind_and_keeps_the_rest`, `the_ingest_drop_events_drops_before_any_capacity_is_spent`, `the_ingest_drop_events_consumes_no_rate_budget`, `the_ingest_drop_events_batch_reports_per_index_outcomes_and_only_stores_the_kept`, `the_ingest_drop_events_keeps_dropping_the_unmarked_subagent_tail`, `the_ingest_drop_events_keeps_dropping_the_unmarked_subagent_tail_in_batches`, and `a_marked_event_of_a_dropped_kind_still_seeds_subagent_tracking`; `drop_list.rs` `drop_events_*` tests cover typed matching and rejected state/unknown kinds. Moving any matcher before subagent exclusion fails its single/batch tail tests; removing either batch matcher fails its batch contract | STRONG. The list applies to every project on the server; it narrows what is stored and never widens access || 11l | Marketplace plugin front door: a plugin-launched event gets exactly the native hook's capture policy, scope and server routing, is captured once beside settings-file hooks, and sends nothing without the binary (#1166) | `plugins/*/scripts/ai-memory-hook` (rendered from `crates/ai-memory-cli/templates/plugin/ai-memory-hook.sh` by `render_plugins.rs`) has no capture logic: it only finds the binary (an `ai_memory_bin` option is honoured only as an absolute path, so a checkout cannot plant a relative one) and runs `ai-memory hook` with `AI_MEMORY_HOOK_ORIGIN=<agent>-plugin`, `hook` first so the Docker wrapper routes it, omitting `--server-url` when the option is empty (a pre-3.0 binary's usage error, exit 2 before it reads stdin, is retried once against the default local server with a stderr hint), and without a binary drains stdin, prints `{}` (guidance on `session-start` only) and exits 0; `hook.rs` `is_dropped_plugin_copy` + `plugin_origin.rs` `drops_plugin_event` drop a plugin copy when the user `settings.json` (honouring `CLAUDE_CONFIG_DIR`) or the checkout's `.claude/settings.local.json` carries an ai-memory hook for the same event (`install_hooks::hooks_file_delivers_ai_memory_event`); a Droid-launched copy (`droid-plugin`) is checked against the one file Droid reads hooks from (`~/.factory/hooks.json`, else the `hooks` key of `~/.factory/settings.json`); a Muse-launched copy (`muse-plugin`, recognized by `MUSE_PLUGIN_ID` with `MUSE_SESSION_ID`) is checked against the `hooks` key of `${XDG_CONFIG_HOME:-~/.config}/muse/settings.json`, and its subagent events are dropped; both drop a folderless session (no `cwd`, or a Claude desktop `scratch-workspaces` cwd); Codex plugin events are never de-duplicated (an untrusted settings hook is skipped silently, so dropping could lose the event); the drift test keeps every plugin hook on the native path (no `hooks/<agent>/*.sh`, no credential in any plugin file) | CLI `tests/suite/plugins.rs` through the committed launcher and the real binary: `ignore_paths_hold_through_the_plugin` (ignored path never spooled; public-file control kept), `allowlist_mode_holds_through_the_plugin` (unmarked checkout emits nothing, prompts included; marked control captured), `marker_scope_routes_plugin_events`, `server_profiles_route_plugin_events` (profile URL and token, never the plugin's URL), `a_settings_hook_for_the_same_event_drops_the_plugin_copy` (user and project settings; unwired-event and no-settings controls), `a_droid_hook_for_the_same_event_drops_the_droid_plugin_copy` (Droid `hooks.json`; no-Droid-hook, Claude-settings-only, unwired-event and folderless controls), `a_muse_hook_for_the_same_event_drops_the_muse_plugin_copy` (Muse `settings.json`; no-Muse-hook, Claude-settings-only and unwired-event controls; subagent and folderless events dropped), `plugin_origin.rs` `muse_plugin_copy_is_dropped_when_muse_settings_hooks_deliver_the_event` (a matcher-narrowed hook does not count) and `test_plugin_launcher.sh` (an inherited `MUSE_SESSION_ID` without `MUSE_PLUGIN_ID` stays `claude-code`), `folderless_sessions_are_not_captured_through_the_plugin`, `without_a_binary_nothing_is_sent_and_the_agent_is_not_blocked`, `foreign_hosts_are_attributed_or_ignored`, `committed_plugins_match_the_renderer`, `plugin_tree_carries_no_credentials`; `plugin_origin.rs` unit tests (`codex_plugin_events_are_never_deduplicated_against_settings`, `droid_settings_hooks_count_only_while_hooks_json_is_absent`, `only_a_catch_all_matcher_suppresses_the_plugin_copy`: a settings hook narrowed by a matcher never drops the plugin copy); `hook.rs` `plugin_copy_is_dropped_only_with_the_plugin_origin`; `tests/hooks/test_plugin_launcher.sh` (a relative `ai_memory_bin` planted in the checkout is never run; PATH control); `tests/e2e/claude_plugin_smoke.py` (real `claude -p`: settings hook plus plugin give one `user-prompt`) | STRONG. Verified 2026-10-13: removing the `is_dropped_plugin_copy` guard fails the de-duplication and folderless tests (and the smoke reports `user-prompt x2`); disabling the native `Drop` disposition or the allowlist gate fails the `ignore_paths` and allowlist tests through the launcher. Not covered: tool events from a live model turn (no credential in CI), Windows Git Bash, Cowork and the desktop Code tab (see `docs/design-marketplace-plugins.md`) || 12 | Network/auth posture, including auth on by default for new installs (an existing install keeps loopback no-auth until `ai-memory auth enable`) | `config.rs` loopback `DEFAULT_BIND`; `serve.rs` `validate_http_exposure`, `require_allowed_host`; `auth.rs` `require_bearer`; `serve.rs` mounts `/identity` inside the host and machine-auth gates even with web disabled; `nix/nixos-module.nix` treats only literal `127.0.0.1`/`::1` as loopback, requires exactly one secret environment source for other binds, keeps secret auth and `llm_headers` values out of the Nix store, and brackets IPv6 in `ExecStart`; new-install default: `commands/init.rs` `root_bearer_for_new_config` mints a root bearer only on a fresh data dir (no config file and no database) and only when no bearer is supplied otherwise, via `local_auth.rs` `provision_root_token` (`auth-tokens/` `0700`, file `0600`, atomic, reused when present) and records the relative `[auth].bearer_token_file`; `config.rs` `apply_bearer_token_file` reads it once (`AI_MEMORY_AUTH_TOKEN` wins, inline + file together refused, a missing or blank file leaves no bearer) and `discover_root_token` lets a packaged install's client commands use `<data_dir>/auth-tokens/default` only with no config file at the probed path, a loopback server URL and no registered `default` profile; `serve.rs` `refuse_a_missing_token_file` stops a server whose configured file holds no token; `AuthSettings::renderable_bearer_token` keeps a file-sourced token out of every renderer: `install_mcp.rs` `route_file_token` (Claude Code gets the session-aware `ai-memory mcp-bridge` entry, Codex and Prime Agent name `AI_MEMORY_AUTH_TOKEN`, every other client a `stdio_bridge_entry` that runs `mcp-bridge --no-session-id` in its documented stdio shape, Pi keeps its extension, ZCode (HTTP-only) is refused) and `mcp_bridge.rs`, which authenticates with the config-resolved bearer and connects upstream before serving stdio, so a refused token ends it with `401 Unauthorized` instead of hanging; `uninstall.rs` `mcp_entry_is_ours` / `toml_mcp_entry_targets` recognise bridge entries by `install_mcp::bridge_entry_url`; `auth_enable.rs` `rewire_clients` re-registers every client whose entry targets this server, `install_hooks.rs` (persisted to the hook credential files, never inlined, not even on the F5 persist-failure fallback), `setup_agent.rs`, `run_autowire.rs`, `setup.rs` (runs `init`, adopts the minted token in memory through `adopt_token_file`, and calls the installers with no explicit token; the rendered user unit carries none; `user_service.rs` `is_rendered_by_setup` lets `uninstall` stop and delete only a unit carrying `setup`'s identity line whose SHA-256 still matches, never a hand-written or edited one); `local_auth.rs` `seed_hook_credential` gives hooks the token through `auth-token`/`auth-header` and keeps a different stored credential; `uninstall.rs` keeps the root bearer (`server_profiles::clear_tokens` `keep`); `commands/auth_enable.rs` is the idempotent opt-in | `serve.rs` host-guard (missing→400 / forged→403), non-loopback-requires-token; `auth.rs` wrong-token 401; `serve.rs` `machine_identity_remains_authenticated_with_web_disabled_and_expired_keys` (wrong and expired keys refused, valid machine key accepted, web remains disabled); `flake.nix` `nixos-module-eval` refuses `localhost` and `0.0.0.0` without a secret source, refuses two secret sources, `settings.auth` secrets, and `settings.llm_headers`, with literal IPv4/IPv6 loopback and one-source controls; `cli/tests/suite/auth_default_e2e.rs` against the shipped binary: `a_fresh_install_requires_the_token_and_its_own_clients_still_work` (after `init`, unauthenticated `/mcp`, `/hook`, `/api/v1/projects`, `/admin/status` → 401 and `/healthz` → 200; the same requests with the token succeed; the native hook delivers with no token in its environment, `status` authenticates through config, `mcp-bridge` lists tools; the token is in neither process's `/proc/<pid>/cmdline`; after `install-hooks`, `install-mcp --apply` for every client it writes (21, by default config path under the test home), a refused ZCode install and `auth enable` twice, a scan of the whole home finds the token nowhere and a scan of the data dir finds it only in the token file and the two hook credential files), `an_existing_install_is_unchanged_until_auth_enable` (control: a pre-default install serves every route open and `status` names the fix; `auth enable` twice is idempotent, rewires Claude Code to the bridge, and after a restart the routes refuse and the hook still delivers), `a_packaged_install_with_an_external_config_wires_its_clients`, `uninstall_keeps_the_root_bearer_and_a_missing_one_stops_the_server`, `a_host_client_given_the_token_file_by_env_authenticates`; `init.rs` `a_fresh_init_mints_a_root_bearer_the_loader_reads`, `init_on_an_existing_install_does_not_turn_auth_on`, `init_with_a_supplied_bearer_mints_nothing`, `re_running_init_keeps_the_same_root_bearer`; `config.rs` `a_relative_bearer_token_file_resolves_against_the_data_dir`, `a_missing_or_blank_bearer_token_file_is_reported_not_guessed`, `the_env_token_wins_over_the_bearer_token_file`, `an_inline_bearer_and_a_bearer_token_file_together_are_refused`, `a_client_without_a_config_file_discovers_the_root_bearer`, `root_bearer_discovery_is_refused_outside_its_narrow_case` (existing config, remote URL, `default` profile, env token); `auth_default_e2e.rs` `a_session_less_bridge_serves_any_client_without_holding_the_token` (`tools/list` and a scoped `memory_query` through `mcp-bridge --no-session-id` against a fresh auth-on server, the token in neither the bridge's `/proc/<pid>/cmdline` nor its `/proc/<pid>/environ`; control: the session-aware mode still refuses to start without `CLAUDE_CODE_SESSION_ID`) and `a_bridge_without_the_token_is_refused_cleanly_not_hung` (exits promptly naming `401 Unauthorized`); `mcp_bridge.rs` `only_the_session_aware_mode_forwards_and_requires_a_session_id`, `a_session_less_upstream_config_carries_no_session_header`, `stdio_bridge_forwards_tools_and_session_header_in_both_http_modes` (control); `install_mcp.rs` `a_file_sourced_token_wires_every_client_without_entering_its_config` (every written client: no token, no header, an entry that reaches the server; ZCode refused and unwritten), `stdio_bridge_entries_follow_each_clients_documented_shape`, `inline_and_explicit_tokens_still_embed_as_before` (control); `uninstall.rs` `bridge_entries_are_recognised_by_their_upstream_url` (JSON, OpenCode array and TOML shapes; a bridge to another server and a foreign command are kept); `install_hooks.rs` `a_file_sourced_token_is_persisted_but_never_embedded`; `auth_enable.rs` `enable_twice_is_idempotent_and_leaks_the_token_into_no_harness_config` (every client pre-wired over HTTP is re-registered, ZCode reported as manual, the second run byte-identical), `enable_leaves_an_entry_for_another_server_alone`, `enable_refuses_while_a_default_profile_would_share_the_token`; `local_auth.rs` `the_root_bearer_is_owner_only`, `seeding_never_replaces_a_different_hook_credential`; `setup_e2e.rs` `setup_installs_wires_is_idempotent_and_uninstall_removes_its_unit` (one `setup --yes` in a fresh temp home: the token is in no file under the home but the token file and the two hook credential files, not in the user unit and not in `setup`'s output; the self-check's `memory_status` and a hook event authenticate through the file; `uninstall` then disables and deletes the unit once and a second `uninstall` calls nothing), `uninstall_leaves_a_unit_it_did_not_write` (adversarial: the packaged unit copied by hand is kept, no `systemctl` call); `user_service.rs` `a_foreign_or_edited_unit_is_left_alone`, `rendered_units_carry_an_identity_that_survives_only_unedited` | STRONG. Bite checks for the new-install default: with fresh-install minting disabled the fresh e2e routes answer without a token and the `init` tests fail; with `renderable_bearer_token` returning the file token, `install-mcp`, `install-hooks`, `auth enable` and the e2e scans find it in harness configs; without the `serve` refusal a server whose token file was deleted keeps running (the e2e times out on it); without the hook seeding the fresh e2e hook is refused; without `clear_tokens` `keep` uninstall deletes the root bearer; with `route_file_token` no longer choosing the stdio bridge the every-client and `auth enable` tests fail; with `auth enable` skipping the re-registration its test fails; with the session-less mode forwarding an inherited id the bridge unit test fails; without the 401 naming the refusal e2e fails; without bridge-entry recognition the uninstall test fails; with `setup` handing the token to `install-mcp` its scan finds it in `.claude.json`; with `is_rendered_by_setup` accepting any unit, the foreign-unit tests fail; with discovery removed the packaged e2e gets 401, and with each discovery guard removed the matching case of `root_bearer_discovery_is_refused_outside_its_narrow_case` fails. Residual: a hand-edited `servers.toml` that adds a `default` profile after the root bearer exists would read the root bearer as that profile's token (`server add` refuses it, `auth enable` refuses while it exists); ZCode takes only HTTP entries and is refused, so it needs a manual entry; the stdio entries for Zero, Muse Code and DeepSeek Harness follow their documented or source-level format but were not run against those clients || 12b | Managed-workstream provenance privacy, stable replay identity and server event namespace | `ai-memory-core/src/workstream.rs` `scrub_workstream_provenance`; `ai-memory-hooks/src/workstream.rs` `finish_run` reserved client-id check and `sanitize_events` before immutable segments, with `sanitize_events` and `append_boundary_events` scrubbing event/checkpoint/losses content *before* the 64 KiB cap so a cap-straddling secret is never cut into an unmatchable prefix (#1113); `ai-memory-store/src/workstream.rs` `finish_run` stable identity check and `stored_event`, scrubbing content with the explicitly supplied configured sanitizer before its 16 KiB store-boundary bound; no changes to the typed observation boundary | `store/tests/suite/workstream_provenance.rs` `workstream_provenance_is_bounded_scrubbed_and_idempotent_before_storage` (hostile and oversized source ids, unknown metadata, legitimate correlation, retry and distinct event ids), `workstream_provenance_legacy_reads_strip_secrets_and_unknown_metadata` (search and tail, malformed/oversized legacy JSON), `workstream_provenance_reused_event_id_retains_data_and_refuses_identity_change` (first indexed version retained, identity refusal and batch rollback), `workstream_provenance_replay_survives_sanitizer_changes` (new extra patterns and removal of a built-in-pattern allowlist exemption, with identity-refusal control), `workstream_provenance_replay_preserves_legacy_rows_above_bounds`, `workstream_provenance_finished_run_ignores_late_events`, `workstream_provenance_retry_with_marker_matching_pattern_is_idempotent`, `workstream_content_is_scrubbed_before_the_store_cap` (a credential straddling the 16 KiB store cap is redacted, not persisted as an unmatchable prefix; benign control verbatim; #1113); `hooks` `workstream_provenance_finish_scrubs_before_raw_segment_and_search` (custom sanitizer, immutable segment, SQL recovery and finished-run no-op), `workstream_provenance_client_cannot_use_server_event_ids` (reserved ids refused before raw writes, normal client event and server-generated checkpoint/loss controls), `finish_run_scrubs_event_content_before_the_byte_cap` and `finish_run_scrubs_boundary_events_before_the_byte_cap` (a credential straddling the 64 KiB event cap is redacted in the raw segment and never reaches the index; checkpoint/losses and benign controls; #1113); `cli/tests/suite/workstream_provenance.rs` (text/JSON and old server DTOs) | STRONG: privacy, stable-identity and reserved-namespace regressions fail with their guards bypassed; an isolated allowlist bypass fails on the unknown key, and bypassing the raw-id search authorization returns 200 where its test requires 403. No provenance is emitted in startup packets, and old raw segments are not rewritten |