YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix: prepare 2.7.113 Enterprise upload and Windows installer recovery (#7663)
Louis Beaumonta67b316d7a67
diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock b/apps/screenpipe-app-tauri/src-tauri/Cargo.lockindex ea4553be5..b0e792fcc 100644--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock@@ -11261,7 +11261,7 @@ dependencies = [[[package]]name = "screenpipe-app"-version = "2.7.112"+version = "2.7.113"dependencies = ["aes 0.8.4","aes-gcm 0.10.3",diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml b/apps/screenpipe-app-tauri/src-tauri/Cargo.tomlindex 9ddbdc35d..2617bfe5e 100644--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml@@ -7,7 +7,7 @@ members = ["wer-dump-helper", "windows/persistence-supervisor", "release-router-[package]name = "screenpipe-app"-version = "2.7.112"+version = "2.7.113"description = "24/7 memory for your desktop. 100% local."authors = ["you"]license = ""diff --git a/apps/screenpipe-app-tauri/src-tauri/src/enterprise/sync.rs b/apps/screenpipe-app-tauri/src-tauri/src/enterprise/sync.rsindex e89104ca2..6dad6cec2 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/enterprise/sync.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/enterprise/sync.rs@@ -641,7 +641,7 @@ pub use screenpipe_telemetry_wire::{build_jsonl, build_jsonl_with_parsed};/// Split JSONL on record boundaries for hosted ingest. Concatenating the/// returned chunks always reproduces `body` byte-for-byte; no record is/// truncated or discarded. A single record larger than the target travels in-/// its own request.+/// its own ticketed storage transfer.pub fn split_jsonl_requests(body: Vec<u8>, target_bytes: usize) -> Vec<Vec<u8>> {if body.is_empty() {return Vec::new();@@ -689,6 +689,42 @@ async fn post_jsonl_with_identity(stable_device_id: Option<&str>,backfill: bool,) -> Result<(), EnterpriseSyncError> {+ // A single retained AX record can exceed the hosted HTTP body limit even+ // after splitting the page. Keep every byte and use the same ticketed+ // storage transport as full-quality screenshots. Cursor advancement still+ // waits for completion (policy/source/checksum validation and durable ingest).+ if body.len() > HOSTED_INGEST_REQUEST_BYTES {+ use reqwest::header::HeaderMap;+ use screenpipe_sync::pipeline::{TicketedConfig, TicketedPipeline};+ #[derive(serde::Deserialize)]+ struct Source { device_id: String }+ let source: Source = serde_json::from_slice(+ body.split(|byte| *byte == b'\n').next().unwrap_or_default(),+ ).map_err(|_| EnterpriseSyncError::Ingest("invalid hosted telemetry source".into()))?;+ // Preserve the identity contract used by inline ingest: manually+ // assigned IDs and safe deferred migrations have no stable header.+ let mut identity_headers = vec![("x-license-key", license_key)];+ if let Some(stable) = stable_device_id {+ identity_headers.push(("x-screenpipe-stable-device-id", stable));+ }+ let mut headers = HeaderMap::new();+ for (key, value) in identity_headers {+ headers.insert(key, value.parse().map_err(|_| EnterpriseSyncError::Configuration(+ "invalid hosted upload identity header".into(),+ ))?);+ }+ headers.insert("x-screenpipe-ingest-transfer", "1".parse().unwrap());+ if backfill { headers.insert("x-screenpipe-backfill", "1".parse().unwrap()); }+ let ticket = serde_json::json!({"action": "ticket", "device_id": source.device_id,+ "content_length": body.len(), "sha256": screenpipe_core::sync::crypto::compute_checksum(&body)});+ let mut complete = ticket.clone();+ complete["action"] = serde_json::json!("complete");+ TicketedPipeline::new(TicketedConfig::new(url, url)+ .with_http(client.clone()).with_control_headers(headers)+ .with_pinned_upload_hosts(enterprise_upload::pinned_hosts_from_env()))+ .upload(&body, "application/x-ndjson", &ticket, &complete).await?;+ return Ok(());+ }let mut request = client.post(url).header("X-License-Key", license_key)@@ -3188,6 +3224,79 @@ pub(crate) mod tests {assert!(body.is_empty());}+ #[tokio::test]+ async fn hosted_large_record_retries_each_phase_without_advancing_or_losing_bytes() {+ use std::sync::atomic::AtomicBool;+ let _policy = crate::enterprise_policy::sync_streams_test_lock();+ struct RetainedFrame(FrameRow);+ #[async_trait::async_trait]+ impl LocalApiClient for RetainedFrame {+ async fn upload_source_id(&self) -> Result<String, EnterpriseSyncError> {+ Ok("dev-1".into())+ }+ async fn fetch_frames_since(&self, _: Option<&str>, _: u32, _: u32) -> Result<Vec<FrameRow>, EnterpriseSyncError> {+ Ok(vec![self.0.clone(), frame(26, "2026-10-16T15:21:00Z", "Fixture", "later normal marker")])+ }+ async fn fetch_audio_since(&self, _: Option<&str>, _: u32, _: u32) -> Result<Vec<AudioRow>, EnterpriseSyncError> { Ok(vec![]) }+ }+ // Operator-assigned identities and safe deferred migrations keep the+ // legacy namespace. Their full records must also make progress.+ for stable_identity in [Some("stable-device"), None] {+ for (phase, status) in [("ticket", 401), ("ticket", 403), ("ticket", 429), ("ticket", 503), ("put", 400), ("complete", 503)] {+ let control = wiremock::MockServer::start().await;+ let storage = wiremock::MockServer::start().await;+ let failing = Arc::new(AtomicBool::new(true));+ let fail = failing.clone();+ let target = format!("{}/blob", storage.uri());+ wiremock::Mock::given(wiremock::matchers::method("POST"))+ .respond_with(move |request: &wiremock::Request| {+ let json: serde_json::Value = serde_json::from_slice(&request.body).unwrap();+ let action = json["action"].as_str().unwrap_or("inline");+ if fail.load(Ordering::SeqCst) && action == phase {+ return wiremock::ResponseTemplate::new(status);+ }+ if action == "ticket" {+ wiremock::ResponseTemplate::new(200).set_body_json(serde_json::json!({+ "ok": true, "method": "PUT", "upload_url": target,+ "headers": {"Content-Type": "application/x-ndjson"}+ }))+ } else { wiremock::ResponseTemplate::new(200) }+ }).mount(&control).await;+ let fail = failing.clone();+ wiremock::Mock::given(wiremock::matchers::method("PUT"))+ .respond_with(move |_: &wiremock::Request| wiremock::ResponseTemplate::new(+ if phase == "put" && fail.load(Ordering::SeqCst) { status } else { 201 }+ )).mount(&storage).await;+ let mut row = frame(25, "2026-10-16T15:20:00Z", "Fixture", "flattened preview");+ row.accessibility_tree = Some(serde_json::json!({"role": "Edit", "text": "界".repeat(2_100_000)}));+ let local = RetainedFrame(row);+ let dir = TempDir::new().unwrap();+ let mut cfg = test_cfg(&dir, format!("{}/api/enterprise/ingest", control.uri()));+ cfg.stable_device_id = stable_identity.map(str::to_string);+ let mut cursor = Cursor { source_id: Some("dev-1".into()),+ last_frame_ts: Some("2026-10-16T15:00:00Z".into()), ..Cursor::default() };+ let http = enterprise_http_client();+ assert!(run_one_sync(&cfg, &mut cursor, &local, &http).await.is_err(), "{phase}/{status}");+ assert_eq!(cursor.last_frame_ts.as_deref(), Some("2026-10-16T15:00:00Z"));+ assert!(!cfg.cursor_path.exists());+ failing.store(false, Ordering::SeqCst);+ let report = run_one_sync(&cfg, &mut cursor, &local, &http).await.unwrap();+ assert_eq!(report.frames, 2);+ assert_eq!(Cursor::load(&cfg.cursor_path).last_frame_ts.as_deref(), Some("2026-10-16T15:21:00Z"));+ let expected = build_jsonl("dev-1", &cfg.device_label, &[local.0.clone()], &[], &[], &[], &[]);+ assert!(expected.len() > 5 * 1024 * 1024);+ for request in storage.received_requests().await.unwrap() {+ assert_eq!(request.body, expected, "storage must get the complete original JSONL");+ assert!(!request.headers.contains_key("x-license-key"));+ }+ let requests = control.received_requests().await.unwrap();+ assert!(requests.iter().all(|r| r.body.len() < HOSTED_INGEST_REQUEST_BYTES));+ assert!(requests.iter().all(|r| r.headers.contains_key("x-screenpipe-stable-device-id") == stable_identity.is_some()));+ assert!(requests.iter().any(|r| String::from_utf8_lossy(&r.body).contains("later normal marker")));+ }+ }+ }+#[test]fn hosted_ingest_split_is_byte_for_byte_lossless() {let body = b"one\ntwo-two\nthree\n".to_vec();@@ -5042,6 +5151,7 @@ pub(crate) mod tests {#[tokio::test]async fn catch_up_failure_keeps_last_acknowledged_page_for_restart() {+ let _guard = crate::enterprise_policy::sync_streams_test_lock();use std::sync::atomic::{AtomicUsize, Ordering};let calls = Arc::new(AtomicUsize::new(0));diff --git a/apps/screenpipe-app-tauri/src-tauri/src/enterprise/upload.rs b/apps/screenpipe-app-tauri/src-tauri/src/enterprise/upload.rsindex 952edcdb1..32ba850fd 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/enterprise/upload.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/enterprise/upload.rs@@ -329,7 +329,7 @@ impl DirectUploadConfig {/// `host:port` entries; whitespace and empty entries ignored. This/// repurposes the env-var channel the (dropped) encryption root keys used —/// customers already deploy MDM env vars to enterprise fleets.-fn pinned_hosts_from_env() -> Vec<String> {+pub(super) fn pinned_hosts_from_env() -> Vec<String> {std::env::var("SCREENPIPE_ENTERPRISE_UPLOAD_PINNED_HOSTS").ok().map(|raw| {diff --git a/apps/screenpipe-app-tauri/src-tauri/windows/persistence-supervisor/src/platform.rs b/apps/screenpipe-app-tauri/src-tauri/windows/persistence-supervisor/src/platform.rsindex c4ea918bf..e9973c46c 100644--- a/apps/screenpipe-app-tauri/src-tauri/windows/persistence-supervisor/src/platform.rs+++ b/apps/screenpipe-app-tauri/src-tauri/windows/persistence-supervisor/src/platform.rs@@ -2241,7 +2241,12 @@ if (($attributes -band [System.IO.FileAttributes]::Directory) -ne 0) {}$owner = $acl.Ownertry { $owner = ([System.Security.Principal.NTAccount]$owner).Translate([System.Security.Principal.SecurityIdentifier]).Value } catch {}-if ($owner -notin @('S-1-5-18', 'S-1-5-32-544')) { exit 40 }+$trustedOwners = @(+ 'S-1-5-18',+ 'S-1-5-32-544',+ 'S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464'+)+if ($owner -notin $trustedOwners) { exit 40 }$write = [System.Security.AccessControl.FileSystemRights]::WriteData -bor[System.Security.AccessControl.FileSystemRights]::CreateFiles -bor[System.Security.AccessControl.FileSystemRights]::AppendData -bor@@ -2255,7 +2260,15 @@ $write = [System.Security.AccessControl.FileSystemRights]::WriteData -borforeach ($rule in $acl.Access) {$sid = $rule.IdentityReferencetry { $sid = $sid.Translate([System.Security.Principal.SecurityIdentifier]).Value } catch { $sid = [string]$sid }- $trusted = $sid -in @('S-1-5-18', 'S-1-5-32-544')+ $trusted = $sid -in $trustedOwners+ # Program Files and ProgramData normally carry this placeholder ACE. It+ # cannot grant access to the directory itself and is substituted with the+ # trusted creator/owner only on descendants. Do not generalize this exception+ # to other inherit-only principals: they can create writable child namespaces.+ $trustedCreatorOwner = $sid -eq 'S-1-3-0' -and+ $rule.InheritanceFlags -ne [System.Security.AccessControl.InheritanceFlags]::None -and+ (($rule.PropagationFlags -band [System.Security.AccessControl.PropagationFlags]::InheritOnly) -ne 0)+ $trusted = $trusted -or $trustedCreatorOwnerif (-not $trusted -and $rule.AccessControlType -eq 'Allow' -and (($rule.FileSystemRights -band $write) -ne 0)) { exit 42 }}exit 0@@ -2420,6 +2433,52 @@ mod tests {static PROGRAM_DATA_TEST: Mutex<()> = Mutex::new(());+ fn acl_test_dir(parent: &Path, case: &str) -> PathBuf {+ let path = parent.join(format!(+ "screenpipe-acl-{case}-{}-{}",+ std::process::id(),+ SystemTime::now()+ .duration_since(UNIX_EPOCH)+ .unwrap()+ .as_nanos()+ ));+ fs::create_dir(&path).unwrap();+ path+ }++ fn remove_acl_test_dir(path: &Path) {+ let _ = run_icacls(path, &["/grant:r", "*S-1-5-32-544:(OI)(CI)F"]);+ let _ = fs::remove_dir_all(path);+ }++ fn assert_private_acl(path: &Path) {+ let script = r#"+$acl = [System.IO.Directory]::GetAccessControl($env:SCREENPIPE_ACL_TEST_PATH)+if (-not $acl.AreAccessRulesProtected) { exit 1 }+$allowed = @('S-1-5-18', 'S-1-5-32-544')+foreach ($rule in $acl.Access) {+ $sid = $rule.IdentityReference.Translate([System.Security.Principal.SecurityIdentifier]).Value+ if ($rule.IsInherited -or $sid -notin $allowed) { exit 2 }+}+"#;+ let status = Command::new("powershell.exe")+ .args([+ "-NoLogo",+ "-NoProfile",+ "-NonInteractive",+ "-Command",+ script,+ ])+ .env("SCREENPIPE_ACL_TEST_PATH", path)+ .status()+ .unwrap();+ assert!(+ status.success(),+ "unexpected effective ACL on {}",+ path.display()+ );+ }+#[test]fn service_status_accepts_stop_shutdown_and_session_changes() {let status = service_status(ServiceState::Running);@@ -2500,4 +2559,73 @@ mod tests {env::remove_var("ProgramData");}}++ #[test]+ fn default_program_files_and_protected_program_data_are_hardened() {+ let _lock = PROGRAM_DATA_TEST.lock().unwrap();+ let program_files = PathBuf::from(env::var_os("ProgramFiles").unwrap());+ let install = acl_test_dir(&program_files, "trusted-default");+ validate_trusted_acl_namespace(&install).unwrap();+ protect_private_directory(&install).unwrap();+ assert_private_acl(&install);+ remove_acl_test_dir(&install);++ let program_data = PathBuf::from(env::var_os("ProgramData").unwrap());+ let state = program_data.join(format!("screenpipe-acl-protected-{}", std::process::id()));+ create_protected_directory(&state, true).unwrap();+ validate_trusted_acl_namespace(&state).unwrap();+ assert_private_acl(&state);+ remove_acl_test_dir(&state);+ }++ #[test]+ fn writable_builtin_namespaces_are_rejected_including_inherit_only() {+ let _lock = PROGRAM_DATA_TEST.lock().unwrap();+ let parent = PathBuf::from(env::var_os("ProgramData").unwrap());+ for (case, sid, grant) in [+ ("users", "*S-1-5-32-545", "M"),+ ("everyone", "*S-1-1-0", "M"),+ ("authenticated", "*S-1-5-11", "M"),+ ("users-inherit-only", "*S-1-5-32-545", "(OI)(CI)(IO)M"),+ ("creator-owner-direct", "*S-1-3-0", "F"),+ ] {+ let path = acl_test_dir(&parent, case);+ run_icacls(&path, &["/grant", &format!("{sid}:{grant}")]).unwrap();+ assert!(+ validate_trusted_acl_namespace(&path).is_err(),+ "accepted {case}"+ );+ remove_acl_test_dir(&path);+ }+ }++ #[test]+ fn untrusted_owner_is_rejected() {+ let _lock = PROGRAM_DATA_TEST.lock().unwrap();+ let parent = PathBuf::from(env::var_os("ProgramData").unwrap());+ let path = acl_test_dir(&parent, "owner");+ let user = env::var("USERNAME").unwrap();+ run_icacls(&path, &["/setowner", &user]).unwrap();+ assert!(validate_trusted_acl_namespace(&path).is_err());+ remove_acl_test_dir(&path);+ }++ #[test]+ fn junction_is_rejected_before_acl_hardening() {+ let _lock = PROGRAM_DATA_TEST.lock().unwrap();+ let parent = PathBuf::from(env::var_os("ProgramData").unwrap());+ let target = acl_test_dir(&parent, "junction-target");+ let junction = parent.join(format!("screenpipe-acl-junction-{}", std::process::id()));+ let _ = fs::remove_dir(&junction);+ let status = Command::new("cmd.exe")+ .args(["/c", "mklink", "/J"])+ .arg(&junction)+ .arg(&target)+ .status()+ .unwrap();+ assert!(status.success());+ assert!(protect_private_directory(&junction).is_err());+ let _ = fs::remove_dir(&junction);+ remove_acl_test_dir(&target);+ }}