Skip to content

Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors

Rust

fix(2.7): trust the recovery journal's data-dir ancestors; build the Cursor workspace per platform

AkitaOnRailsa42a07612d57
diff --git a/crates/ai-memory-cli/src/commands/recovery.rs b/crates/ai-memory-cli/src/commands/recovery.rs
index ee639e90..92109b7c 100644
--- a/crates/ai-memory-cli/src/commands/recovery.rs
+++ b/crates/ai-memory-cli/src/commands/recovery.rs
@@ -32,7 +32,7 @@
use std::collections::HashMap;
use std::fs::{self, File, OpenOptions};
-use std::path::{Path, PathBuf};
+use std::path::{Component, Path, PathBuf};
use std::str::FromStr as _;
use std::time::{Duration, Instant};
@@ -174,7 +174,7 @@ pub(crate) fn journal_path(data_dir: &Path) -> PathBuf {
/// only record of what the server missed).
pub(crate) fn load_journal(data_dir: &Path) -> Result<Vec<JournalEntry>> {
let path = journal_path(data_dir);
- refuse_symlink(&path)?;
+ refuse_symlink(data_dir, &path)?;
let mut file = match open_journal_read(&path) {
Ok(file) => file,
Err(error) if error.kind() == std::io::ErrorKind::NotFound => return Ok(Vec::new()),
@@ -245,7 +245,7 @@ fn mutate_journal(
) -> Result<()> {
validate_journal_entry_limit(data_dir)?;
let path = journal_path(data_dir);
- let lock = open_private_lock(&data_dir.join(JOURNAL_LOCK_FILE))?;
+ let lock = open_private_lock(data_dir, &data_dir.join(JOURNAL_LOCK_FILE))?;
lock.lock_exclusive()
.with_context(|| format!("locking {}", data_dir.join(JOURNAL_LOCK_FILE).display()))?;
let mut entries = load_journal(data_dir)?;
@@ -257,7 +257,7 @@ fn mutate_journal(
let mut rendered =
serde_json::to_vec_pretty(&journal).context("serializing the recovery journal")?;
rendered.push(b'\n');
- refuse_symlink(&path)?;
+ refuse_symlink(data_dir, &path)?;
if rendered.len() as u64 > MAX_JOURNAL_BYTES {
bail!(
"recovery journal {} would exceed the {} byte limit",
@@ -265,17 +265,17 @@ fn mutate_journal(
MAX_JOURNAL_BYTES
);
}
- write_journal_atomic(&path, &rendered)
+ write_journal_atomic(data_dir, &path, &rendered)
.with_context(|| format!("writing {}", path.display()))?;
make_private(&path)?;
Ok(())
}
-fn write_journal_atomic(path: &Path, bytes: &[u8]) -> Result<()> {
+fn write_journal_atomic(data_dir: &Path, path: &Path, bytes: &[u8]) -> Result<()> {
let parent = path
.parent()
.ok_or_else(|| anyhow!("recovery journal path has no parent"))?;
- refuse_symlink(parent)?;
+ refuse_symlink(data_dir, parent)?;
let mut temp = tempfile::Builder::new()
.prefix(".recovery-journal.")
.tempfile_in(parent)?;
@@ -284,7 +284,7 @@ fn write_journal_atomic(path: &Path, bytes: &[u8]) -> Result<()> {
temp.write_all(bytes)?;
temp.as_file().sync_data()?;
}
- refuse_symlink(path)?;
+ refuse_symlink(data_dir, path)?;
temp.persist(path).map_err(|error| error.error)?;
if let Ok(directory) = File::open(parent) {
let _ = directory.sync_all();
@@ -294,7 +294,7 @@ fn write_journal_atomic(path: &Path, bytes: &[u8]) -> Result<()> {
fn validate_journal_entry_limit(data_dir: &Path) -> Result<()> {
let path = journal_path(data_dir);
- refuse_symlink(&path)?;
+ refuse_symlink(data_dir, &path)?;
match fs::metadata(&path) {
Ok(metadata) if metadata.len() > MAX_JOURNAL_BYTES => bail!(
"recovery journal {} exceeds the {} byte limit",
@@ -318,14 +318,14 @@ fn open_journal_read(path: &Path) -> std::io::Result<File> {
options.open(path)
}
-fn open_private_lock(path: &Path) -> Result<File> {
+fn open_private_lock(data_dir: &Path, path: &Path) -> Result<File> {
if let Some(parent) = path.parent() {
- refuse_symlink(parent)?;
+ refuse_symlink(data_dir, parent)?;
crate::commands::path_util::create_private_dir(parent)
.with_context(|| format!("creating {}", parent.display()))?;
- refuse_symlink(parent)?;
+ refuse_symlink(data_dir, parent)?;
}
- refuse_symlink(path)?;
+ refuse_symlink(data_dir, path)?;
let mut options = OpenOptions::new();
options.create(true).read(true).write(true);
#[cfg(unix)]
@@ -336,29 +336,56 @@ fn open_private_lock(path: &Path) -> Result<File> {
let file = options
.open(path)
.with_context(|| format!("opening {}", path.display()))?;
- refuse_symlink(path)?;
+ refuse_symlink(data_dir, path)?;
make_private(path)?;
Ok(file)
}
-fn refuse_symlink(path: &Path) -> Result<()> {
- let mut current = PathBuf::new();
- for component in path.components() {
- current.push(component.as_os_str());
- match fs::symlink_metadata(&current) {
- Ok(metadata) if metadata.file_type().is_symlink() => {
- bail!("refusing recovery journal symlink {}", current.display());
- }
- Ok(_) => {}
- Err(error) if error.kind() == std::io::ErrorKind::NotFound => break,
- Err(error) => {
- return Err(error).with_context(|| format!("inspecting {}", current.display()));
- }
+/// Refuse a symlink at or below `data_dir` on the way to `path`.
+///
+/// The data dir is the trust root. Its ancestors are the operator's and the
+/// system's (`/var` is a symlink to `/private/var` on macOS, `/home` is often
+/// a symlink), so they are not inspected. The data dir itself, and every
+/// component inside it, must not be a symlink: that is where another local
+/// user could plant one. The comparison is lexical; canonicalizing would
+/// rewrite the ancestors this deliberately trusts.
+fn refuse_symlink(data_dir: &Path, path: &Path) -> Result<()> {
+ let relative = path.strip_prefix(data_dir).with_context(|| {
+ format!(
+ "recovery journal path {} is outside the data dir {}",
+ path.display(),
+ data_dir.display()
+ )
+ })?;
+ if !refuse_symlink_component(data_dir)? {
+ return Ok(());
+ }
+ let mut current = data_dir.to_path_buf();
+ for component in relative.components() {
+ let Component::Normal(component) = component else {
+ bail!("recovery journal path contains a non-normal component");
+ };
+ current.push(component);
+ if !refuse_symlink_component(&current)? {
+ break;
}
}
Ok(())
}
+/// Fail if `path` is a symlink; `Ok(false)` once it does not exist (nothing
+/// below a missing component can exist either).
+fn refuse_symlink_component(path: &Path) -> Result<bool> {
+ match fs::symlink_metadata(path) {
+ Ok(metadata) if metadata.file_type().is_symlink() => {
+ bail!("refusing recovery journal symlink {}", path.display());
+ }
+ Ok(_) => Ok(true),
+ Err(error) if error.kind() == std::io::ErrorKind::NotFound => Ok(false),
+ Err(error) => Err(error).with_context(|| format!("inspecting {}", path.display())),
+ }
+}
+
#[cfg(unix)]
fn make_private(path: &Path) -> Result<()> {
use std::os::unix::fs::PermissionsExt as _;
@@ -1375,6 +1402,45 @@ mod tests {
assert!(!outside.path().join(JOURNAL_FILE).exists());
}
+ /// A symlink ABOVE the data dir is the operator's or the system's (macOS
+ /// `/var` → `/private/var`): the journal works through it. The data dir
+ /// is reached here only through `link/`, and nothing inside it is a link.
+ #[cfg(unix)]
+ #[test]
+ fn a_symlinked_ancestor_of_the_data_dir_is_trusted() {
+ let temp = tempfile::tempdir().unwrap();
+ let real = temp.path().join("real");
+ fs::create_dir(&real).unwrap();
+ let link = temp.path().join("link");
+ std::os::unix::fs::symlink(&real, &link).unwrap();
+ let data_dir = link.join("data");
+ append_journal_entry(&data_dir, test_entry("ancestor", JournalKind::DegradedRun)).unwrap();
+ assert_eq!(load_journal(&data_dir).unwrap().len(), 1);
+ assert!(real.join("data").join(JOURNAL_FILE).exists());
+ }
+
+ /// The trust stops at the data dir: a link planted on the lock path
+ /// inside a data dir reached through a symlinked ancestor is still
+ /// refused, and its target is never touched.
+ #[cfg(unix)]
+ #[test]
+ fn a_symlink_inside_a_data_dir_under_a_symlinked_ancestor_is_refused() {
+ let temp = tempfile::tempdir().unwrap();
+ let real = temp.path().join("real");
+ fs::create_dir_all(real.join("data")).unwrap();
+ let link = temp.path().join("link");
+ std::os::unix::fs::symlink(&real, &link).unwrap();
+ let data_dir = link.join("data");
+ let outside = temp.path().join("outside-journal.json");
+ fs::write(&outside, b"canary").unwrap();
+ std::os::unix::fs::symlink(&outside, journal_path(&data_dir)).unwrap();
+ let error =
+ append_journal_entry(&data_dir, test_entry("planted", JournalKind::DegradedRun))
+ .unwrap_err();
+ assert!(format!("{error:#}").contains("symlink"), "{error:#}");
+ assert_eq!(fs::read(&outside).unwrap(), b"canary");
+ }
+
#[cfg(windows)]
#[test]
fn journal_acl_is_restricted_to_the_current_owner() {
diff --git a/crates/ai-memory-llm/src/cursor_agent.rs b/crates/ai-memory-llm/src/cursor_agent.rs
index e6b3c1a4..fc025a62 100644
--- a/crates/ai-memory-llm/src/cursor_agent.rs
+++ b/crates/ai-memory-llm/src/cursor_agent.rs
@@ -185,9 +185,15 @@ impl TempWorkspace {
let path = std::env::temp_dir().join(format!("ai-memory-cursor-{}", Uuid::now_v7()));
// The prompt is captured session text: keep the workspace private
// to the server's user on a shared temp directory.
- let mut builder = std::fs::DirBuilder::new();
#[cfg(unix)]
- std::os::unix::fs::DirBuilderExt::mode(&mut builder, 0o700);
+ let builder = {
+ use std::os::unix::fs::DirBuilderExt as _;
+ let mut builder = std::fs::DirBuilder::new();
+ builder.mode(0o700);
+ builder
+ };
+ #[cfg(not(unix))]
+ let builder = std::fs::DirBuilder::new();
builder.create(&path).map_err(|err| {
LlmError::UnexpectedShape(format!("creating cursor workspace: {err}"))
})?;
diff --git a/docs/security-boundaries.md b/docs/security-boundaries.md
index 2cddaa55..5838c5fa 100644
--- a/docs/security-boundaries.md
+++ b/docs/security-boundaries.md
@@ -72,7 +72,7 @@ boundary not yet built.
| 11f | Native hook executable-path integrity after self-replacement (#1027) | `ai-memory-cli/src/commands/render_shared.rs` `hook_embedded_exe_path` is the single executable resolver for every persisted native hook form (POSIX/Windows command, Windows exec, Zero, ZCode, OpenCode 2 assistant capture): it prefers an existing literal path, strips Linux's trailing ` (deleted)` procfs marker only when the stripped installed binary exists, and otherwise falls back to the platform command name. Upgrade keeps the already-loaded config and refreshes in-process | `render_shared.rs` `embedded_exe_strips_the_marker_when_the_stripped_path_exists`, `embedded_exe_preserves_a_real_file_whose_name_has_the_marker_suffix`, `embedded_exe_falls_back_when_the_resolved_path_is_missing`, `hook_embedded_exe_path_names_an_existing_file_without_marker`; `upgrade_e2e.rs` `native_upgrade_refreshes_hooks_without_a_deleted_path_or_losing_cli_data_dir` reproduces the replacement window through the shipped binary, plants the corrupt suffix, and proves refresh removes it while preserving a CLI-only data dir | STRONG on Linux reproduction plus platform-neutral resolver/render coverage; Windows path rendering remains covered by its existing command/exec tests and full Windows CI |
| 11g | Cross-project file attribution cannot bypass destination capture or server routing (#932) | `ai-memory-hooks/src/capture_policy.rs` `absolute_file_tool_paths` accepts only bounded, recognized, absolute file-tool candidates; `ai-memory-cli/src/commands/hook.rs` `file_tool_routing_cwd` requires every path to prove the same repository/marker boundary and resolves that destination before capture policy, server profile, scope hints, or spool credentials. Relative, mixed-project, unsupported, and arbitrary non-project paths keep the payload cwd | `hook.rs` `absolute_file_target_uses_destination_scope_and_capture_policy` (hostile content under the destination exclusion is never spooled; a public control is routed there), `absolute_file_target_cannot_escape_a_destination_server_profile` (unregistered destination profile drops instead of falling back to source/install default), `file_target_routing_refuses_relative_external_and_mixed_project_paths` | STRONG for native `ai-memory hook`; generated and compatibility hooks retain cwd-only routing |
| 11h | Docker-wrapper capture-policy capability (#1002) | `bin/ai-memory` routes ordinary Linux/macOS `install-hooks` and upgrade refreshes through the stable checksum-verified native host client, so the hook process executes the capture-policy boundary in 11b before spool/network. 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 | `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 | 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 symlinked path components, 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; `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 |
+| 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 |
| 12 | Network/auth posture | `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` | `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 | STRONG |
| 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 |