Skip to content

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

fix(onboarding): require confident low-tier detection

Louis Beaumont4976a989657b
diff --git a/apps/screenpipe-app-tauri/app/onboarding/page.test.tsx b/apps/screenpipe-app-tauri/app/onboarding/page.test.tsx
index dcb72ef3f..5b2af9dc5 100644
--- a/apps/screenpipe-app-tauri/app/onboarding/page.test.tsx
+++ b/apps/screenpipe-app-tauri/app/onboarding/page.test.tsx
@@ -326,6 +326,14 @@ describe("timeline slide sequencing", () => {
);
expect(await screen.findByText("timeline choice")).toBeInTheDocument();
expect(screen.queryByText("engine")).not.toBeInTheDocument();
+ expect(mocks.capture).toHaveBeenCalledWith(
+ "onboarding_device_tier_evaluated",
+ {
+ device_tier: "low",
+ timeline_choice_eligible: true,
+ timeline_choice_policy_locked: false,
+ }
+ );
});
it.each(["mid", "high", undefined, null, "unknown", "LOW"])(
@@ -344,6 +352,16 @@ describe("timeline slide sequencing", () => {
);
expect(await screen.findByText("engine")).toBeInTheDocument();
expect(screen.queryByText("timeline choice")).not.toBeInTheDocument();
+ expect(mocks.capture).toHaveBeenCalledWith(
+ "onboarding_device_tier_evaluated",
+ {
+ device_tier: ["mid", "high"].includes(deviceTier as string)
+ ? deviceTier
+ : "unknown",
+ timeline_choice_eligible: false,
+ timeline_choice_policy_locked: false,
+ }
+ );
}
);
@@ -363,6 +381,14 @@ describe("timeline slide sequencing", () => {
);
expect(await screen.findByText("engine")).toBeInTheDocument();
expect(screen.queryByText("timeline choice")).not.toBeInTheDocument();
+ expect(mocks.capture).toHaveBeenCalledWith(
+ "onboarding_device_tier_evaluated",
+ {
+ device_tier: "low",
+ timeline_choice_eligible: false,
+ timeline_choice_policy_locked: true,
+ }
+ );
});
// The step writes disableTimeline AND disableScreenshots, so a policy owning
diff --git a/apps/screenpipe-app-tauri/app/onboarding/page.tsx b/apps/screenpipe-app-tauri/app/onboarding/page.tsx
index ddca39ed2..36b054981 100644
--- a/apps/screenpipe-app-tauri/app/onboarding/page.tsx
+++ b/apps/screenpipe-app-tauri/app/onboarding/page.tsx
@@ -155,6 +155,12 @@ export default function OnboardingPage() {
isSettingLocked("disableTimeline") || isSettingLocked("disableScreenshots");
const timelineChoiceVisible =
isConfidentLowEndDevice && !timelineChoiceLocked;
+ const deviceTierForAnalytics =
+ settings.deviceTier === "low" ||
+ settings.deviceTier === "mid" ||
+ settings.deviceTier === "high"
+ ? settings.deviceTier
+ : "unknown";
const visibleOrder = useMemo(
() => SLIDE_ORDER.filter((s) => s !== "timeline" || timelineChoiceVisible),
[timelineChoiceVisible]
@@ -306,6 +312,18 @@ export default function OnboardingPage() {
}
}
+ // This event supplies the denominator for the low-tier fork. Keep the
+ // properties low-cardinality: native analytics already has the raw CPU and
+ // RAM measurements for detector audits, while this records the exact tier
+ // and policy decision that controlled onboarding.
+ if (currentSlide === "permissions") {
+ posthog.capture("onboarding_device_tier_evaluated", {
+ device_tier: deviceTierForAnalytics,
+ timeline_choice_eligible: timelineChoiceVisible,
+ timeline_choice_policy_locked: timelineChoiceLocked,
+ });
+ }
+
// Walk SLIDE_ORDER (never the filtered list) so the index stays valid even
// for a slide that policy hides, then land on the next visible slide.
const nextSlide =
@@ -328,7 +346,10 @@ export default function OnboardingPage() {
}, [
completeOnboarding,
currentSlide,
+ deviceTierForAnalytics,
isManagedDeployment,
+ timelineChoiceLocked,
+ timelineChoiceVisible,
visibleOrder,
]);
diff --git a/crates/screenpipe-config/src/defaults.rs b/crates/screenpipe-config/src/defaults.rs
index 57bf481d7..254ce2a62 100644
--- a/crates/screenpipe-config/src/defaults.rs
+++ b/crates/screenpipe-config/src/defaults.rs
@@ -18,9 +18,9 @@ const PARAKEET_MIN_MACOS_MAJOR: u32 = 26;
pub enum DeviceTier {
/// High-end: ≥24 GB RAM and ≥8 cores (safe for parakeet ~2GB)
High,
- /// Mid-range: ≥12 GB or (≥8 GB and ≥6 cores)
+ /// Mid-range: ≥12 GB or (>8 GB and ≥6 cores)
Mid,
- /// Low-end: <8 GB or <6 cores
+ /// Low-end: hardware below the Mid threshold
Low,
}
@@ -60,29 +60,47 @@ pub fn classify_tier(ram_gb: u64, cores: u64) -> DeviceTier {
}
}
+/// Classify detected measurements without turning missing hardware data into a
+/// low-tier result. An ambiguous reading falls back to Mid, while a confirmed
+/// RAM measurement of at most 8 GB is sufficient evidence for Low regardless
+/// of whether CPU topology is available.
+fn classify_detected_tier(ram_gb: Option<u64>, cores: Option<u64>) -> DeviceTier {
+ let ram_gb = ram_gb.filter(|value| *value > 0);
+ let cores = cores.filter(|value| *value > 0);
+
+ match (ram_gb, cores) {
+ (Some(ram_gb), Some(cores)) => classify_tier(ram_gb, cores),
+ (Some(ram_gb), None) if ram_gb <= 8 => DeviceTier::Low,
+ // Missing RAM is always ambiguous because enough memory qualifies a
+ // device for Mid even with a small CPU. Likewise, 9–11 GB needs a CPU
+ // reading to distinguish Mid from Low. Fail closed for the onboarding
+ // intervention by choosing Mid in every ambiguous case.
+ _ => DeviceTier::Mid,
+ }
+}
+
/// Detect the device tier based on available RAM and CPU cores.
///
/// | Tier | Criteria |
/// |------|---------------------------------------|
/// | High | ≥24 GB RAM and ≥8 cores |
-/// | Mid | ≥12 GB or (≥8 GB and ≥6 cores) |
-/// | Low | everything else |
+/// | Mid | ≥12 GB or (>8 GB and ≥6 cores) |
+/// | Low | below Mid, with enough data to prove it |
+///
+/// Missing or ambiguous measurements fall back to Mid so callers never treat
+/// a telemetry failure as positive evidence that the device is low-end.
pub fn detect_tier() -> DeviceTier {
let mut sys = System::new();
sys.refresh_memory();
+ sys.refresh_cpu();
- let ram_gb = sys.total_memory() / (1024 * 1024 * 1024);
- let cores = sys.cpus().len() as u64;
-
- // Re-query CPU count via sysinfo's physical core count if cpus() is empty
- // (can happen before refresh_cpu)
- let cores = if cores == 0 {
- sys.physical_core_count().unwrap_or(1) as u64
- } else {
- cores
- };
+ let total_memory = sys.total_memory();
+ let ram_gb = (total_memory > 0).then_some(total_memory / (1024 * 1024 * 1024));
+ let cores = (!sys.cpus().is_empty())
+ .then_some(sys.cpus().len() as u64)
+ .or_else(|| sys.physical_core_count().map(|count| count as u64));
- classify_tier(ram_gb, cores)
+ classify_detected_tier(ram_gb, cores)
}
/// Database configuration tuned per device tier.
@@ -472,12 +490,27 @@ mod tests {
#[test]
fn classify_zero_ram_or_cores() {
- // Container edge case: sysinfo returns 0
+ // The pure classifier treats its inputs as actual measurements.
assert_eq!(classify_tier(0, 0), DeviceTier::Low);
assert_eq!(classify_tier(0, 16), DeviceTier::Low);
assert_eq!(classify_tier(32, 0), DeviceTier::Mid); // ≥12 GB → Mid even with 0 cores
}
+ #[test]
+ fn detected_tier_fails_closed_when_measurements_are_missing() {
+ assert_eq!(classify_detected_tier(None, None), DeviceTier::Mid);
+ assert_eq!(classify_detected_tier(Some(0), Some(0)), DeviceTier::Mid);
+ assert_eq!(classify_detected_tier(None, Some(2)), DeviceTier::Mid);
+ assert_eq!(classify_detected_tier(Some(10), None), DeviceTier::Mid);
+ assert_eq!(classify_detected_tier(Some(32), None), DeviceTier::Mid);
+ }
+
+ #[test]
+ fn detected_tier_accepts_ram_only_when_it_proves_low_tier() {
+ assert_eq!(classify_detected_tier(Some(8), None), DeviceTier::Low);
+ assert_eq!(classify_detected_tier(Some(10), Some(4)), DeviceTier::Low);
+ }
+
#[test]
fn db_config_default_matches_high() {
assert_eq!(DbConfig::default(), DbConfig::for_tier(DeviceTier::High));