π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Prune infra comments
Manav Rathic48de04658fb
diff --git a/infra/copycat-db/Dockerfile b/infra/copycat-db/Dockerfileindex 922c7e8bfe..2f54b67c67 100644--- a/infra/copycat-db/Dockerfile+++ b/infra/copycat-db/Dockerfile@@ -8,19 +8,14 @@ RUN apt-get update && apt-get install -y \unzip \zstd-# Install Postgres client 15-# https://www.postgresql.org/download/linux/ubuntu/RUN /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -yRUN apt-get update && apt-get install -y postgresql-client-15-# Install SCW CLI-# Latest release: https://github.com/scaleway/scaleway-cli/releases/latestRUN \export VERSION="2.55.0" && \curl -o /usr/local/bin/scw -L "https://github.com/scaleway/scaleway-cli/releases/download/v${VERSION}/scaleway-cli_${VERSION}_linux_amd64" && \chmod +x /usr/local/bin/scw-# Install rcloneRUN curl https://rclone.org/install.sh | bashCOPY src /diff --git a/infra/copycat-db/src/backup.sh b/infra/copycat-db/src/backup.shindex e1e7023238..d2f093d86b 100755--- a/infra/copycat-db/src/backup.sh+++ b/infra/copycat-db/src/backup.sh@@ -38,11 +38,8 @@ elseexit 1fi-# Calculate an expiry time 1 month from nowEXPIRYS="$(( 30 * 24 * 60 * 60 + $NOWS ))"-# Convert it to the ISO 8601 format that SCW CLI understands-# Note that GNU date uses "-d" and an "@" to pass an epoch (macOS uses "-r").EXPIRY="$(date -Iseconds --utc --date "@$EXPIRYS")"BACKUP_INSTANCE_ID=$SCW_RDB_INSTANCE_ID@@ -95,16 +92,7 @@ fiif test "$BACKUP_MODE" = "scw-export" || test "$BACKUP_MODE" = "snapshot-scw-export"then- # We need to export a backup first after creating it, before it can be- # downloaded.- #- # Further, our backups currently take longer than the default 20 minute- # timeout for the export set by Scaleway, and end up failing:- #- # {"error":"scaleway-sdk-go: waiting for database backup failed: timeout after 20m0s"}- #- # To avoid this we need to add a custom wait here ourselves instead of using- # the convenience `--wait` flag for the export command provided by Scaleway.+ # Wait longer than Scaleway's default 20 minutes for the backup to be ready to export.BACKUP_ID=$(scw rdb backup create instance-id="$BACKUP_INSTANCE_ID" \name=$BACKUP_NAME expires-at=$EXPIRY \database-name=ente_db -o json | jq -r '.id')@@ -168,7 +156,6 @@ firclone copy --log-level INFO $BACKUP_FILE $RCLONE_DESTINATION-# Delete older backupsrclone delete --log-level INFO --min-age 30d $RCLONE_DESTINATIONset +o xtracediff --git a/infra/copycat-db/src/restore.sh b/infra/copycat-db/src/restore.shindex d7b38744fc..f67b139495 100755--- a/infra/copycat-db/src/restore.sh+++ b/infra/copycat-db/src/restore.sh@@ -5,9 +5,7 @@ set -o pipefailset -o xtraceif test -z "$1"; then- # Find the name of the latest backup.- #- # The backup file name contains the epoch, so we can just sort.+ # Backup names contain epochs, so lexical sort finds the latest.BACKUP_FILE=$(rclone lsf --files-only $RCLONE_DESTINATION \| awk '/^db-.*(\.custom|\.dumpdir\.tar\.zst)$/' \@@ -15,8 +13,6 @@ if test -z "$1"; then| tail -1)else- # If a CLI argument is provided, use that as the name of the backup file to- # restore.BACKUP_FILE="$1"fi@@ -25,10 +21,8 @@ if test -z "$BACKUP_FILE"; thenexit 1fi-# Download itrclone copy --log-level INFO "${RCLONE_DESTINATION}${BACKUP_FILE}" .-# Unpack directory-format backups so pg_restore can read BACKUP_FILE directly.if test "${BACKUP_FILE%.custom}" = "$BACKUP_FILE"; thenARCHIVE_FILE=$BACKUP_FILEzstd -dc "$BACKUP_FILE" | tar -xf -@@ -36,31 +30,14 @@ if test "${BACKUP_FILE%.custom}" = "$BACKUP_FILE"; thenrm "$ARCHIVE_FILE"fi-# Restore from it-#-# This create a database named rdb on Postgres - this is only used for the-# initial connection, the actual ente_db database will be created once the-# restore starts.-#-# Flags:-#-# * no-owner: recreates the schema using the current user, not the one that was-# used for the export.-#-# * no-privileges: skip the assignment of roles (this way we do not have to-# recreate all the users from the original database before proceeding with the-# restore)-+# `rdb` is only the initial connection; the dump creates `ente_db`.+# Restore ownership as the current user without requiring production roles.createdb rdb || truepg_restore -d rdb --create --no-privileges --no-owner --exit-on-error "$BACKUP_FILE"-# Delete any tokens that were in the backup+# Prune transient state and tokens.psql -d ente_db -c 'delete from tokens'--# Delete any push tokens that were in the backuppsql -d ente_db -c 'delete from push_tokens'--# Delete some more temporary data that might've come up in the backuppsql -d ente_db -c 'delete from queue'psql -d ente_db -c 'delete from temp_objects'diff --git a/infra/copycat-db/test.sh b/infra/copycat-db/test.shindex d4ac1b35f0..9fde57494d 100755--- a/infra/copycat-db/test.sh+++ b/infra/copycat-db/test.sh@@ -8,10 +8,6 @@ PROJECT=copycat-dbdocker rmi "ente/$PROJECT" || truedocker build --tag "ente/$PROJECT" .-# Interactively run the container.-#-# By passing "$@", we allow any arguments passed to test.sh to be forwarded to-# the image (useful for testing out things, e.g. `./test.sh sh`).docker run \--interactive --tty --rm \--env-file copycat-db.env \diff --git a/infra/experiments/logs-viewer/ente-theme.css b/infra/experiments/logs-viewer/ente-theme.cssindex 35586e65af..78922cda27 100644--- a/infra/experiments/logs-viewer/ente-theme.css+++ b/infra/experiments/logs-viewer/ente-theme.css@@ -1,65 +1,53 @@/* Ente Theme Variables based on web/packages/base/components/utils/theme.ts */:root {- /* Light theme colors */--ente-color-accent-photos: #1db954;--ente-color-accent-auth: #9610d6;--ente-color-accent-locker: #5ba8ff;- /* Background colors */--ente-background-default: #fff;--ente-background-paper: #fff;--ente-background-paper2: #fbfbfb;--ente-background-search: #f3f3f3;- /* Text colors */--ente-text-base: #000;--ente-text-muted: rgba(0, 0, 0, 0.60);--ente-text-faint: rgba(0, 0, 0, 0.50);- /* Fill colors */--ente-fill-base: #000;--ente-fill-muted: rgba(0, 0, 0, 0.12);--ente-fill-faint: rgba(0, 0, 0, 0.04);--ente-fill-faint-hover: rgba(0, 0, 0, 0.08);--ente-fill-fainter: rgba(0, 0, 0, 0.02);- /* Stroke colors */--ente-stroke-base: #000;--ente-stroke-muted: rgba(0, 0, 0, 0.24);--ente-stroke-faint: rgba(0, 0, 0, 0.12);--ente-stroke-fainter: rgba(0, 0, 0, 0.06);- /* Shadow */--ente-shadow-paper: 0px 0px 10px rgba(0, 0, 0, 0.25);--ente-shadow-menu: 0px 0px 6px rgba(0, 0, 0, 0.16), 0px 3px 6px rgba(0, 0, 0, 0.12);--ente-shadow-button: 0px 4px 4px rgba(0, 0, 0, 0.25);- /* Fixed colors */--ente-success: #1db954;--ente-warning: #ffc107;--ente-danger: #ea3f3f;--ente-danger-dark: #f53434;--ente-danger-light: #ff6565;- /* Secondary colors */--ente-secondary-main: #f5f5f5;--ente-secondary-hover: #e9e9e9;- /* Action colors */--ente-action-hover: rgba(0, 0, 0, 0.08);--ente-action-disabled: rgba(0, 0, 0, 0.50);- /* Typography */--ente-font-family: "Inter Variable", sans-serif;--ente-font-weight-regular: 500;--ente-font-weight-medium: 600;--ente-font-weight-bold: 700;- /* Border radius */--ente-border-radius: 8px;--ente-border-radius-small: 4px;- /* Spacing */--ente-spacing-xs: 4px;--ente-spacing-sm: 8px;--ente-spacing-md: 12px;@@ -67,44 +55,36 @@--ente-spacing-xl: 24px;}-/* Dark theme */@media (prefers-color-scheme: dark) {:root {- /* Background colors */--ente-background-default: #000;--ente-background-paper: #1b1b1b;--ente-background-paper2: #252525;--ente-background-search: #1b1b1b;- /* Text colors */--ente-text-base: #fff;--ente-text-muted: rgba(255, 255, 255, 0.70);--ente-text-faint: rgba(255, 255, 255, 0.50);- /* Fill colors */--ente-fill-base: #fff;--ente-fill-muted: rgba(255, 255, 255, 0.16);--ente-fill-faint: rgba(255, 255, 255, 0.12);--ente-fill-faint-hover: rgba(255, 255, 255, 0.16);--ente-fill-fainter: rgba(255, 255, 255, 0.05);- /* Stroke colors */--ente-stroke-base: #fff;--ente-stroke-muted: rgba(255, 255, 255, 0.24);--ente-stroke-faint: rgba(255, 255, 255, 0.16);--ente-stroke-fainter: rgba(255, 255, 255, 0.12);- /* Shadow */--ente-shadow-paper: 0px 2px 12px rgba(0, 0, 0, 0.75);--ente-shadow-menu: 0px 0px 6px rgba(0, 0, 0, 0.50), 0px 3px 6px rgba(0, 0, 0, 0.25);--ente-shadow-button: 0px 4px 4px rgba(0, 0, 0, 0.75);- /* Secondary colors */--ente-secondary-main: #2b2b2b;--ente-secondary-hover: #373737;- /* Action colors */--ente-action-hover: rgba(255, 255, 255, 0.16);--ente-action-disabled: rgba(255, 255, 255, 0.50);}-}\ No newline at end of file+}diff --git a/infra/experiments/logs-viewer/index.html b/infra/experiments/logs-viewer/index.htmlindex b27152ee07..5e5f13f45c 100644--- a/infra/experiments/logs-viewer/index.html+++ b/infra/experiments/logs-viewer/index.html@@ -5,24 +5,18 @@<meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Ente Log Viewer</title>- <!-- Dark Reader support --><meta name="darkreader-lock"><meta name="color-scheme" content="light dark">- <!-- Material-UI CSS --><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" /><link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" /><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@mui/material@latest/dist/index.css" />- <!-- Ente theme --><link rel="stylesheet" href="ente-theme.css">-- <!-- Custom styles --><link rel="stylesheet" href="styles.css"></head><body><div class="app">- <!-- Header --><header class="header"><div class="header-content"><h1>π Ente Log Viewer</h1>@@ -57,7 +51,6 @@</div></header>- <!-- Upload Section --><div class="upload-section" id="upload-section"><div class="upload-area" id="upload-area"><div class="upload-content">@@ -70,9 +63,7 @@</div></div>- <!-- Main Content --><div class="main-content" id="main-content" style="display: none;">- <!-- Device Info Section --><div class="device-info-section" id="device-info-section" style="display: none;"><div class="device-info-item" style="display: none;"><span class="material-icons">smartphone</span>@@ -86,7 +77,6 @@</div></div>- <!-- Search Bar --><div class="search-section"><div class="search-bar mui-search-container"><div class="mui-textfield">@@ -99,7 +89,6 @@</div></div>- <!-- Timeline Filter --><div class="timeline-section" id="timeline-section" style="display: none;"><div class="timeline-header"><span class="material-icons">timeline</span>@@ -125,21 +114,17 @@</div></div>- <!-- Active Filters --><div class="active-filters" id="active-filters" style="display: none;"><div class="filter-chips" id="filter-chips"></div></div>- <!-- Log Stats --><div class="log-stats" id="log-stats"><span id="log-count">0 logs loaded</span><span id="filtered-count"></span></div>- <!-- Log List --><div class="log-list-container"><div class="log-list" id="log-list">- <!-- Log entries will be populated here --></div><div class="loading" id="loading" style="display: none;">Loading...</div><div class="load-more" id="load-more" style="display: none;">@@ -149,7 +134,6 @@</div></div>- <!-- Filter Dialog --><div class="dialog-overlay" id="filter-dialog" style="display: none;"><div class="dialog"><div class="dialog-header">@@ -157,27 +141,21 @@<button class="close-btn" id="close-filter">β</button></div><div class="dialog-content">- <!-- Log Levels --><div class="filter-section"><h3>Log Levels</h3><div class="level-chips" id="level-chips">- <!-- Level chips will be populated here --></div></div>- <!-- Process --><div class="filter-section"><h3>Process</h3><div class="process-list" id="process-list">- <!-- Process checkboxes will be populated here --></div></div>- <!-- Loggers --><div class="filter-section"><h3>Loggers</h3><div class="logger-list" id="logger-list">- <!-- Logger checkboxes will be populated here --></div></div></div>@@ -189,7 +167,6 @@</div></div>- <!-- Analytics Dialog --><div class="dialog-overlay" id="analytics-dialog" style="display: none;"><div class="dialog"><div class="dialog-header">@@ -198,7 +175,6 @@</div><div class="dialog-content"><div id="analytics-content">- <!-- Analytics charts will be populated here --></div></div><div class="dialog-actions">@@ -207,7 +183,6 @@</div></div>- <!-- Log Detail Dialog --><div class="dialog-overlay" id="detail-dialog" style="display: none;"><div class="dialog large"><div class="dialog-header">@@ -216,7 +191,6 @@</div><div class="dialog-content"><div id="detail-content">- <!-- Log details will be populated here --></div></div><div class="dialog-actions">@@ -230,11 +204,10 @@</div></div>- <!-- Material-UI JavaScript --><script src="https://unpkg.com/react@18/umd/react.production.min.js"></script><script src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script><script src="https://unpkg.com/@mui/material@latest/umd/material-ui.production.min.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script><script src="script.js"></script></body>-</html>\ No newline at end of file+</html>diff --git a/infra/experiments/logs-viewer/script.js b/infra/experiments/logs-viewer/script.jsindex 751b43d754..87d3574452 100644--- a/infra/experiments/logs-viewer/script.js+++ b/infra/experiments/logs-viewer/script.js@@ -1,4 +1,3 @@-// Log Viewer Applicationclass LogViewer {constructor() {this.logs = [];@@ -8,7 +7,7 @@ class LogViewer {this.allLevels = new Set();this.currentFilter = {selectedLoggers: new Set(),- selectedLevels: new Set(['WARNING', 'SEVERE', 'SHOUT']), // Default to show important levels+ selectedLevels: new Set(['WARNING', 'SEVERE', 'SHOUT']),selectedProcesses: new Set(),searchQuery: '',startTime: null,@@ -19,12 +18,10 @@ class LogViewer {this.pageSize = 100;this.isLoading = false;- // Context mode statethis.isContextMode = false;this.contextTargetLog = null;this.contextLogs = [];- // Device informationthis.deviceInfo = null;this.deviceRAM = null;@@ -32,7 +29,6 @@ class LogViewer {}initializeEventListeners() {- // File uploadconst fileInput = document.getElementById('file-input');const browseBtn = document.getElementById('browse-btn');const uploadArea = document.getElementById('upload-area');@@ -40,18 +36,15 @@ class LogViewer {browseBtn.addEventListener('click', () => fileInput.click());fileInput.addEventListener('change', this.handleFileSelect.bind(this));- // Drag and dropuploadArea.addEventListener('dragover', this.handleDragOver.bind(this));uploadArea.addEventListener('drop', this.handleDrop.bind(this));uploadArea.addEventListener('dragleave', this.handleDragLeave.bind(this));- // Searchconst searchInput = document.getElementById('search-input');const clearSearch = document.getElementById('clear-search');searchInput.addEventListener('input', this.handleSearch.bind(this));clearSearch.addEventListener('click', this.clearSearch.bind(this));- // Filter dialogconst filterBtn = document.getElementById('filter-btn');const filterDialog = document.getElementById('filter-dialog');const closeFilter = document.getElementById('close-filter');@@ -65,11 +58,9 @@ class LogViewer {applyFilters.addEventListener('click', this.applyFilters.bind(this));clearFilters.addEventListener('click', this.clearAllFilters.bind(this));- // Sort buttonconst sortBtn = document.getElementById('sort-btn');sortBtn.addEventListener('click', this.toggleSort.bind(this));- // Timelineconst timelineToggle = document.getElementById('timeline-toggle');const startTime = document.getElementById('start-time');const endTime = document.getElementById('end-time');@@ -80,15 +71,11 @@ class LogViewer {endTime.addEventListener('change', this.handleTimelineChange.bind(this));resetTimeline.addEventListener('click', this.resetTimeline.bind(this));- // Other dialogsthis.setupDialogListeners();-- // Dropdownthis.setupDropdown();}setupDialogListeners() {- // Analytics dialogconst analyticsBtn = document.getElementById('analytics-btn');const analyticsDialog = document.getElementById('analytics-dialog');const closeAnalytics = document.getElementById('close-analytics');@@ -98,7 +85,6 @@ class LogViewer {closeAnalytics.addEventListener('click', this.hideAnalytics.bind(this));closeAnalyticsBtn.addEventListener('click', this.hideAnalytics.bind(this));- // Detail dialogconst detailDialog = document.getElementById('detail-dialog');const closeDetail = document.getElementById('close-detail');const closeDetailBtn = document.getElementById('close-detail-btn');@@ -110,7 +96,6 @@ class LogViewer {copyLog.addEventListener('click', this.copyLogDetail.bind(this));showContext.addEventListener('click', this.showLogContext.bind(this));- // Export and clearconst exportBtn = document.getElementById('export-btn');const clearBtn = document.getElementById('clear-btn');@@ -132,7 +117,6 @@ class LogViewer {});}- // File handlinghandleFileSelect(event) {const file = event.target.files[0];if (file) {@@ -173,7 +157,6 @@ class LogViewer {this.deviceRAM = null;let totalLogs = 0;- // Process each file in the zipfor (const [filename, zipEntry] of Object.entries(contents.files)) {if (!zipEntry.dir && filename.includes('.log')) {const content = await zipEntry.async('string');@@ -183,8 +166,6 @@ class LogViewer {}}-- // Sort logs by timestampthis.logs.sort((a, b) => {if (this.currentFilter.sortNewestFirst) {return b.timestamp - a.timestamp;@@ -193,10 +174,7 @@ class LogViewer {}});- // Extract unique valuesthis.extractUniqueValues();-- // Apply initial filters and displaythis.applyCurrentFilter();this.showMainContent();@@ -219,7 +197,6 @@ class LogViewer {const line = lines[i].trim();if (!line) continue;- // Check if this is an error detail line (starts with β€·)if (line.startsWith('β€·')) {if (currentLog) {errorDetails.push(line);@@ -228,16 +205,13 @@ class LogViewer {continue;}- // Try to parse as a log entryconst logEntry = this.parseLogLine(line);if (logEntry) {- // If we have a current log, finalize it firstif (currentLog) {this.finalizeLogEntry(currentLog, errorDetails);logs.push(currentLog);}- // Check for device info in the message (only if not already found)if (!this.deviceInfo && logEntry.message.startsWith('Device Info:')) {this.deviceInfo = logEntry.message.substring('Device Info:'.length).trim();} else if (!this.deviceRAM && logEntry.message.startsWith('Device RAM:')) {@@ -249,26 +223,20 @@ class LogViewer {errorDetails = [];isInMultilineError = false;} else if (currentLog) {- // Check if this might be an inline error continuationif (line.startsWith('Error:') || line.startsWith('Exception:') ||line.includes('Exception in') || line.includes('ErrorCode=') ||isInMultilineError) {- // This is part of error details or stack tracecurrentLog.message += '\n' + line;-- // Keep track if we're in a multi-line errorif (line.includes('Exception:') || line.includes('Error:')) {isInMultilineError = true;}} else {- // Regular message continuationcurrentLog.message += '\n' + line;}}}- // Don't forget the last logif (currentLog) {this.finalizeLogEntry(currentLog, errorDetails);logs.push(currentLog);@@ -284,11 +252,9 @@ class LogViewer {if (errorInfo.stackTrace) logEntry.stackTrace = errorInfo.stackTrace;if (errorInfo.id) logEntry.id = errorInfo.id;- // Add error details to messagelogEntry.message += '\n' + errorDetails.join('\n');}- // Post-process the log entry to extract inline errorsthis.extractInlineErrors(logEntry);}@@ -303,28 +269,22 @@ class LogViewer {const trimmed = line.trim();if (trimmed.startsWith('Error:') || trimmed.startsWith('Exception:')) {- // This is an error descriptionif (!logEntry.error) {logEntry.error = trimmed;}errorLines.push(trimmed);} else if (trimmed.startsWith('#') && (trimmed.includes('package:') || trimmed.includes('<asynchronous'))) {- // This looks like a stack trace linestackTraceLines.push(trimmed);isInStackTrace = true;} else if (isInStackTrace && (trimmed === '' || trimmed.startsWith('<') || trimmed.includes('suspension'))) {- // Continuation of stack tracestackTraceLines.push(trimmed);} else {- // Regular message linemessageLines.push(line);isInStackTrace = false;}}- // Update the log entryif (messageLines.length < lines.length) {- // We found some error/stack trace contentlogEntry.message = messageLines.join('\n').trim();if (!logEntry.stackTrace && stackTraceLines.length > 0) {@@ -334,13 +294,8 @@ class LogViewer {}parseLogLine(line) {- // Pattern: [processPrefix] [loggerName] [LEVEL] [timestamp] message- // Or: [loggerName] [LEVEL] [timestamp] message (no process prefix)-const patterns = [- // With process prefix: [bg] [ente_logging] [INFO] [2025-08-24 01:36:03.677678] message/^\[([^\]]+)\]\s*\[([^\]]+)\]\s*\[([^\]]+)\]\s*\[([^\]]+)\]\s*(.*)$/,- // Without process prefix: [ente_logging] [INFO] [2025-08-24 01:36:03.677678] message/^\[([^\]]+)\]\s*\[([^\]]+)\]\s*\[([^\]]+)\]\s*(.*)$/];@@ -350,15 +305,12 @@ class LogViewer {let processPrefix, loggerName, level, timestampStr, message;if (i === 0) {- // Pattern with process prefix[, processPrefix, loggerName, level, timestampStr, message] = match;} else {- // Pattern without process prefix[, loggerName, level, timestampStr, message] = match;processPrefix = '';}- // Parse timestampconst timestamp = this.parseTimestamp(timestampStr);if (!timestamp) continue;@@ -381,7 +333,6 @@ class LogViewer {parseTimestamp(timestampStr) {try {- // Handle format: 2025-08-24 01:36:03.677678const parts = timestampStr.match(/(\d{4}-\d{2}-\d{2})\s+(\d{2}:\d{2}:\d{2})\.?(\d+)?/);if (parts) {const [, date, time, microseconds] = parts;@@ -406,7 +357,6 @@ class LogViewer {} else if (line.startsWith('β€· id:')) {result.id = line.substring(6).trim();} else if (line.startsWith('β€· type:')) {- // Include type info in errorconst type = line.substring(8).trim();if (result.error) {result.error = `${type}: ${result.error}`;@@ -414,7 +364,6 @@ class LogViewer {result.error = type;}} else if (stackTraceLines.length > 0) {- // Additional stack trace linesstackTraceLines.push(line.replace(/^β€·\s*/, ''));}}@@ -457,7 +406,6 @@ class LogViewer {const deviceInfoText = document.getElementById('device-info-text');const deviceRAMText = document.getElementById('device-ram-text');- // Reset visibility for both itemsif (deviceInfoText) {deviceInfoText.parentElement.style.display = 'none';}@@ -487,7 +435,6 @@ class LogViewer {const timelineSection = document.getElementById('timeline-section');timelineSection.style.display = 'block';- // Set min/max for datetime inputsconst startTime = document.getElementById('start-time');const endTime = document.getElementById('end-time');@@ -508,7 +455,6 @@ class LogViewer {}}- // Search functionalityhandleSearch(event) {const query = event.target.value;const clearBtn = document.getElementById('clear-search');@@ -526,7 +472,6 @@ class LogViewer {return;}- // Parse logger:name syntaxconst loggerPattern = /logger:(\S+)/g;const matches = [...query.matchAll(loggerPattern)];@@ -535,7 +480,6 @@ class LogViewer {for (const match of matches) {const loggerPattern = match[1];if (loggerPattern.endsWith('*')) {- // Wildcard patternconst prefix = loggerPattern.slice(0, -1);for (const logger of this.allLoggers) {if (logger.startsWith(prefix)) {@@ -548,7 +492,6 @@ class LogViewer {}this.currentFilter.selectedLoggers = newLoggers;- // Remove logger patterns from search querythis.currentFilter.searchQuery = query.replace(loggerPattern, '').trim();}}@@ -561,12 +504,10 @@ class LogViewer {this.applyCurrentFilter();}- // FilteringapplyCurrentFilter() {this.filteredLogs = this.logs.filter(log => this.matchesFilter(log));- // Sort filtered logsthis.filteredLogs.sort((a, b) => {if (this.currentFilter.sortNewestFirst) {return b.timestamp - a.timestamp;@@ -583,21 +524,18 @@ class LogViewer {}matchesFilter(log) {- // Level filterif (this.currentFilter.selectedLevels.size > 0) {if (!this.currentFilter.selectedLevels.has(log.level)) {return false;}}- // Logger filterif (this.currentFilter.selectedLoggers.size > 0) {if (!this.currentFilter.selectedLoggers.has(log.loggerName)) {return false;}}- // Process filterif (this.currentFilter.selectedProcesses.size > 0) {const processName = log.processPrefix || 'Foreground';if (!this.currentFilter.selectedProcesses.has(processName)) {@@ -605,7 +543,6 @@ class LogViewer {}}- // Text searchif (this.currentFilter.searchQuery) {const query = this.currentFilter.searchQuery.toLowerCase();const searchText = `${log.message} ${log.loggerName} ${log.error || ''}`.toLowerCase();@@ -614,7 +551,6 @@ class LogViewer {}}- // Time range filterif (this.currentFilter.startTime && log.timestamp < this.currentFilter.startTime) {return false;}@@ -637,31 +573,27 @@ class LogViewer {<p>${this.logs.length === 0 ? 'Upload a ZIP file to view logs' : 'Try adjusting your filters'}</p></div>`;- this.setupInfiniteScroll(); // Still setup scroll listener+ this.setupInfiniteScroll();return;}logList.innerHTML = logsToShow.map(log => this.createLogEntryHTML(log)).join('');- // Add click listenerslogList.querySelectorAll('.log-entry').forEach((entry, index) => {entry.addEventListener('click', () => this.showLogDetail(logsToShow[index]));});this.currentOffset = logsToShow.length;- // Hide load more button since we have infinite scrollconst loadMore = document.getElementById('load-more');loadMore.style.display = 'none';- // Setup infinite scrollthis.setupInfiniteScroll();}setupInfiniteScroll() {const logList = document.getElementById('log-list');- // Remove existing scroll listener to prevent duplicatesif (this.scrollListener) {logList.removeEventListener('scroll', this.scrollListener);}@@ -669,7 +601,6 @@ class LogViewer {this.scrollListener = () => {const { scrollTop, scrollHeight, clientHeight } = logList;- // Load more when scrolled to 80% of the way downif (scrollTop + clientHeight >= scrollHeight * 0.8) {this.loadMoreLogs();}@@ -679,27 +610,22 @@ class LogViewer {}loadMoreLogs() {- // Prevent multiple simultaneous loadsif (this.isLoadingMore || this.currentOffset >= this.filteredLogs.length) {return;}this.isLoadingMore = true;- // Show loading indicatorconst loading = document.getElementById('loading');loading.style.display = 'block';- // Simulate a small delay for smooth UX (optional)setTimeout(() => {const logList = document.getElementById('log-list');const newLogsToShow = this.filteredLogs.slice(this.currentOffset, this.currentOffset + this.pageSize);- // Append new logsconst newLogsHTML = newLogsToShow.map(log => this.createLogEntryHTML(log)).join('');logList.insertAdjacentHTML('beforeend', newLogsHTML);- // Add click listeners to new entriesconst newEntries = logList.querySelectorAll('.log-entry:nth-last-child(-n+' + newLogsToShow.length + ')');newEntries.forEach((entry, index) => {const logIndex = this.currentOffset + index;@@ -794,17 +720,14 @@ class LogViewer {const chips = [];- // Level filtersfor (const level of this.currentFilter.selectedLevels) {chips.push(`<span class="filter-chip level-${level}">${level} <span class="remove" onclick="logViewer.removeFilter('level', '${level}')">β</span></span>`);}- // Logger filtersfor (const logger of this.currentFilter.selectedLoggers) {chips.push(`<span class="filter-chip">${logger} <span class="remove" onclick="logViewer.removeFilter('logger', '${logger}')">β</span></span>`);}- // Process filtersfor (const process of this.currentFilter.selectedProcesses) {const displayName = this.getProcessDisplayName(process);chips.push(`<span class="filter-chip">${displayName} <span class="remove" onclick="logViewer.removeFilter('process', '${process}')">β</span></span>`);@@ -847,7 +770,6 @@ class LogViewer {}}- // Filter DialogshowFilterDialog() {this.populateFilterDialog();document.getElementById('filter-dialog').style.display = 'flex';@@ -858,7 +780,6 @@ class LogViewer {}populateFilterDialog() {- // Populate level chipsconst levelChips = document.getElementById('level-chips');const levels = ['FINEST', 'FINER', 'FINE', 'CONFIG', 'INFO', 'WARNING', 'SEVERE', 'SHOUT'];@@ -867,14 +788,12 @@ class LogViewer {return `<div class="level-chip ${level} ${active}" data-level="${level}">${level}</div>`;}).join('');- // Add click listeners to level chipslevelChips.querySelectorAll('.level-chip').forEach(chip => {chip.addEventListener('click', () => {chip.classList.toggle('active');});});- // Populate process listconst processList = document.getElementById('process-list');const processes = Array.from(this.allProcesses).sort();@@ -889,7 +808,6 @@ class LogViewer {`;}).join('');- // Populate logger listconst loggerList = document.getElementById('logger-list');const loggers = Array.from(this.allLoggers).sort();@@ -905,27 +823,23 @@ class LogViewer {}applyFilters() {- // Get selected levelsconst selectedLevels = new Set();document.querySelectorAll('.level-chip.active').forEach(chip => {selectedLevels.add(chip.dataset.level);});- // Get selected processesconst selectedProcesses = new Set();document.querySelectorAll('#process-list input:checked').forEach(checkbox => {const process = checkbox.id.replace('process-', '');selectedProcesses.add(process);});- // Get selected loggersconst selectedLoggers = new Set();document.querySelectorAll('#logger-list input:checked').forEach(checkbox => {const logger = checkbox.id.replace('logger-', '');selectedLoggers.add(logger);});- // Update current filterthis.currentFilter.selectedLevels = selectedLevels;this.currentFilter.selectedProcesses = selectedProcesses;this.currentFilter.selectedLoggers = selectedLoggers;@@ -949,7 +863,6 @@ class LogViewer {this.hideFilterDialog();}- // Sort functionalitytoggleSort() {this.currentFilter.sortNewestFirst = !this.currentFilter.sortNewestFirst;const sortBtn = document.getElementById('sort-btn');@@ -963,7 +876,6 @@ class LogViewer {this.applyCurrentFilter();}- // Timeline functionalitytoggleTimeline() {const timelineControls = document.getElementById('timeline-controls');const timelineBtn = document.getElementById('timeline-toggle');@@ -1000,7 +912,6 @@ class LogViewer {}}- // Log detailsshowLogDetail(log) {const detailContent = document.getElementById('detail-content');@@ -1048,7 +959,6 @@ class LogViewer {if (this.currentDetailLog) {const logText = this.formatLogForExport(this.currentDetailLog);navigator.clipboard.writeText(logText).then(() => {- // Show a brief confirmationconst btn = document.getElementById('copy-log');const originalText = btn.textContent;btn.textContent = 'Copied!';@@ -1064,7 +974,6 @@ class LogViewer {this.isContextMode = true;this.contextTargetLog = this.currentDetailLog;- // Get logs around the target log (Β±50 logs)const targetIndex = this.logs.findIndex(log =>log.timestamp === this.contextTargetLog.timestamp &&log.message === this.contextTargetLog.message@@ -1077,11 +986,9 @@ class LogViewer {this.contextLogs = this.logs.slice(startIndex, endIndex);- // Update UI to show context modethis.updateContextModeUI();this.displayContextLogs();- // Close detail dialogthis.hideDetailDialog();}}@@ -1105,10 +1012,7 @@ class LogViewer {</div>`;- // Add exit context button listenerdocument.getElementById('exit-context').addEventListener('click', this.exitContextMode.bind(this));-- // Hide search and timeline sectionssearchSection.style.display = 'none';timelineSection.style.display = 'none';activeFilters.style.display = 'none';@@ -1132,12 +1036,10 @@ class LogViewer {return entryHtml;}).join('');- // Add click listenerslogList.querySelectorAll('.log-entry').forEach((entry, index) => {entry.addEventListener('click', () => this.showLogDetail(this.contextLogs[index]));});- // Scroll to target logif (targetIndex !== -1) {const targetEntry = logList.children[targetIndex];if (targetEntry) {@@ -1145,7 +1047,6 @@ class LogViewer {}}- // Update statsconst logCount = document.getElementById('log-count');logCount.textContent = `Showing context: ${this.contextLogs.length} logs around target`;}@@ -1159,11 +1060,9 @@ class LogViewer {this.displayLogs();}- // AnalyticsshowAnalytics() {const analyticsContent = document.getElementById('analytics-content');- // Calculate logger statisticsconst loggerStats = this.calculateLoggerStats();const levelStats = this.calculateLevelStats();@@ -1251,7 +1150,6 @@ class LogViewer {document.getElementById('analytics-dialog').style.display = 'none';}- // Export functionalityexportLogs() {const filteredData = this.filteredLogs.map(log => this.formatLogForExport(log)).join('\n\n');const header = `=== Ente App Logs ===@@ -1289,7 +1187,6 @@ ${'='.repeat(40)}\n\n`;URL.revokeObjectURL(url);}- // Clear logsclearLogs() {if (confirm('Are you sure you want to clear all logs? This will reload the page.')) {location.reload();@@ -1297,5 +1194,4 @@ ${'='.repeat(40)}\n\n`;}}-// Initialize the application-const logViewer = new LogViewer();\ No newline at end of file+const logViewer = new LogViewer();diff --git a/infra/experiments/logs-viewer/styles.css b/infra/experiments/logs-viewer/styles.cssindex b717279855..f08f4a04d0 100644--- a/infra/experiments/logs-viewer/styles.css+++ b/infra/experiments/logs-viewer/styles.css@@ -1,4 +1,3 @@-/* Reset and base styles */* {margin: 0;padding: 0;@@ -14,7 +13,6 @@ body {letter-spacing: -0.011em;}-/* App container */.app {min-height: 100vh;display: flex;@@ -22,7 +20,6 @@ body {background: var(--ente-background-default);}-/* Header */.header {background: var(--ente-color-accent-photos);color: white;@@ -54,7 +51,6 @@ body {align-items: center;}-/* Material-UI Enhanced Components */.header .mui-icon-btn {background: rgba(255, 255, 255, 0.1);border: none;@@ -126,7 +122,6 @@ body {border: 2px solid rgba(255, 255, 255, 0.2);}-/* Dropdown */.dropdown {position: relative;}@@ -190,7 +185,6 @@ body {opacity: 0.8;}-/* Upload Section */.upload-section {flex: 1;display: flex;@@ -261,7 +255,6 @@ body {font-size: 14px;}-/* Buttons */.primary-btn {background: var(--ente-color-accent-photos);color: white;@@ -324,7 +317,6 @@ body {filter: none;}-/* Main Content */.main-content {flex: 1;max-width: 1400px;@@ -334,7 +326,6 @@ body {background: var(--ente-background-default);}-/* Device Info Section */.device-info-section {display: flex;flex-wrap: wrap;@@ -370,7 +361,6 @@ body {font-family: 'Roboto Mono', monospace;}-/* Search Section */.search-section {margin-bottom: var(--ente-spacing-lg);}@@ -442,7 +432,6 @@ body {color: var(--ente-text-base);}-/* Timeline Section */.timeline-section {background: var(--ente-background-paper);border-radius: var(--ente-border-radius);@@ -511,7 +500,6 @@ body {font-size: 14px;}-/* Active Filters */.active-filters {margin-bottom: var(--ente-spacing-lg);}@@ -590,7 +578,6 @@ body {background: rgba(255, 255, 255, 0.2);}-/* Log Stats */.log-stats {background: var(--ente-background-paper);padding: var(--ente-spacing-lg);@@ -610,7 +597,6 @@ body {color: var(--ente-text-base);}-/* Log List */.log-list-container {background: var(--ente-background-paper);border-radius: var(--ente-border-radius);@@ -675,7 +661,6 @@ body {border-left: 4px solid var(--ente-warning);}-/* Context mode highlighting */.log-entry.highlighted {background: var(--ente-background-secondary);border: 2px solid var(--ente-color-accent-photos);@@ -697,7 +682,6 @@ body {margin-left: auto;}-/* Context header styles */.context-header {display: flex;align-items: center;@@ -820,7 +804,6 @@ body {border-left: 3px solid var(--ente-danger);}-/* Loading and Load More */.loading {text-align: center;padding: var(--ente-spacing-xl);@@ -847,7 +830,6 @@ body {100% { transform: rotate(360deg); }}-/* Dialog */.dialog-overlay {position: fixed;top: 0;@@ -947,7 +929,6 @@ body {background: var(--ente-background-paper2);}-/* Filter Dialog Enhancements */.filter-section {margin-bottom: var(--ente-spacing-xl);}@@ -1013,13 +994,11 @@ body {font-size: 14px;}-/* Specific text color overrides for light-colored level chips when active */.level-chip.active.WARNING,.level-chip.active.WARNING::after {color: #000;}-/* Simple styling for level chips in dialog - no shadows or complex effects */.log-detail-table .level-chip {padding: 4px 8px;border-radius: 12px;@@ -1053,7 +1032,6 @@ body {color: white;}-/* Level colors */.level-chip.FINEST, .level-chip.FINER, .level-chip.FINE {color: var(--ente-text-faint);}@@ -1099,7 +1077,6 @@ body {font-weight: var(--ente-font-weight-regular);}-/* Empty states */.empty-state {text-align: center;padding: 4rem 2rem;@@ -1123,7 +1100,6 @@ body {font-size: 14px;}-/* Responsive */@media (max-width: 768px) {.header-content {padding: 0;@@ -1164,7 +1140,6 @@ body {}}-/* Scrollbar styling */.log-list::-webkit-scrollbar,.process-list::-webkit-scrollbar,.logger-list::-webkit-scrollbar {@@ -1190,7 +1165,6 @@ body {background: var(--ente-stroke-muted);}-/* Focus styles for accessibility */.mui-icon-btn:focus,.mui-button:focus,.primary-btn:focus {@@ -1203,7 +1177,6 @@ body {box-shadow: 0 0 0 3px rgba(29, 185, 84, 0.1);}-/* High contrast mode support */@media (prefers-contrast: high) {.log-entry {border-bottom: 2px solid var(--ente-stroke-muted);@@ -1216,7 +1189,6 @@ body {}}-/* Dark Reader extension support */[data-darkreader-scheme="dark"] .header {background: var(--ente-color-accent-photos) !important;color: white !important;@@ -1237,7 +1209,6 @@ body {color: white !important;}-/* Dark Reader overrides for error/warning styling */[data-darkreader-scheme="dark"] .log-entry.severe {border-left-color: var(--ente-danger) !important;}@@ -1246,7 +1217,6 @@ body {border-left-color: var(--ente-warning) !important;}-/* Log Detail Dialog Styles */.log-detail-table {width: 100%;margin-top: 1rem;@@ -1327,7 +1297,6 @@ body {font-weight: var(--ente-font-weight-medium);}-/* Analytics Dialog Styles */.analytics-chart {margin-bottom: 2rem;}@@ -1395,4 +1364,4 @@ body {text-align: right;position: relative;z-index: 1;-}\ No newline at end of file+}diff --git a/infra/ml/playground/optimizations/optimize_models.py b/infra/ml/playground/optimizations/optimize_models.pyindex 13331dc64d..d7db6893d8 100644--- a/infra/ml/playground/optimizations/optimize_models.py+++ b/infra/ml/playground/optimizations/optimize_models.py@@ -95,7 +95,6 @@ def constant_scalar(producer_by_output: dict[str, onnx.NodeProto],tensor_name: str,) -> float | None:- """Return a scalar emitted by an ONNX Constant node, if present."""node = producer_by_output.get(tensor_name)if node is None or node.op_type != "Constant":return None@@ -110,7 +109,6 @@ def constant_scalar(def ensure_unique_node_names(model: onnx.ModelProto) -> None:- """Name adapter nodes inserted by ONNX's opset-version converter."""existing = {node.name for node in model.graph.node if node.name}for index, node in enumerate(model.graph.node):if node.name:@@ -126,7 +124,7 @@ def ensure_unique_node_names(model: onnx.ModelProto) -> None:def rewrite_exact_gelu(model: onnx.ModelProto) -> int:- """Collapse x/sqrt(2) -> Erf -> +1 -> *x -> *0.5 into exact GELU."""+ # Collapse x/sqrt(2) -> Erf -> +1 -> *x -> *0.5 into exact GELU.producer_by_output = {output: node for node in model.graph.node for output in node.output}@@ -215,15 +213,8 @@ def rewrite_exact_gelu(model: onnx.ModelProto) -> int:def rewrite_prelu_decompositions(model: onnx.ModelProto) -> int:- """Replace exported PReLU expressions with CoreML/WebGPU-compatible ops.-- The source graph expresses PReLU using Relu, Abs, Sub, Mul, Mul, and Add.- Abs is not supported by CoreML's documented MLProgram operator set, while- native PRelu is not supported by the WebGPU EP used on Android. The exact- equivalent below uses only operators documented by both providers:-- PReLU(x, alpha) = Relu(x) - alpha * Relu(x * -1)- """+ # CoreML does not support Abs, and Android's WebGPU EP does not support PRelu.+ # Both support this equivalent: PReLU(x, alpha) = Relu(x) - alpha * Relu(x * -1)consumers = node_consumers(model)initializers = {initializer.name: initializer for initializer in model.graph.initializer@@ -348,7 +339,7 @@ def set_batch_one(model: onnx.ModelProto) -> None:def make_implicit_conv_padding_explicit(model: onnx.ModelProto) -> int:- """Write ONNX's default zero padding explicitly for CoreML conversion."""+ # CoreML requires ONNX's default zero padding to be explicit.updated = 0for node in model.graph.node:if node.op_type != "Conv":@@ -361,7 +352,7 @@ def make_implicit_conv_padding_explicit(model: onnx.ModelProto) -> int:def remove_redundant_output_normalization(model: onnx.ModelProto) -> int:- """Remove output L2 normalization because the Rust caller repeats it."""+ # The Rust caller already performs output L2 normalization.graph_outputs = {value.name for value in model.graph.output}rewritten_nodes = []replaced = 0@@ -386,7 +377,7 @@ def remove_redundant_output_normalization(model: onnx.ModelProto) -> int:def optimize_with_ort(model: onnx.ModelProto, output_path: Path) -> onnx.ModelProto:- """Use ORT's portable basic optimizer to fold static shape subgraphs."""+ # Use only ORT's portable basic optimizations.unoptimized_path = output_path.with_suffix(".unoptimized.onnx")onnx.save(model, unoptimized_path)try:diff --git a/infra/ml/test/comparator/__init__.py b/infra/ml/test/comparator/__init__.pyindex 6d4f835561..e69de29bb2 100644--- a/infra/ml/test/comparator/__init__.py+++ b/infra/ml/test/comparator/__init__.py@@ -1 +0,0 @@-"""Parity comparison engine; import from `comparator.compare`."""diff --git a/infra/ml/test/ground_truth/__init__.py b/infra/ml/test/ground_truth/__init__.pyindex 58fb86e167..e69de29bb2 100644--- a/infra/ml/test/ground_truth/__init__.py+++ b/infra/ml/test/ground_truth/__init__.py@@ -1 +0,0 @@-"""Python ground-truth pipeline; import from the specific submodules."""diff --git a/infra/ml/test/tools/_paths.py b/infra/ml/test/tools/_paths.pyindex b54dd1837e..6a9d4cf1b6 100644--- a/infra/ml/test/tools/_paths.py+++ b/infra/ml/test/tools/_paths.py@@ -1,8 +1,3 @@-"""Path resolution shared by the parity tools.--Importing this module also puts the ML test directory on sys.path so that-sibling scripts can import the `ground_truth` and `comparator` packages.-"""from __future__ import annotationsfrom pathlib import Path@@ -10,6 +5,7 @@ import subprocessimport sysML_DIR = Path(__file__).resolve().parents[1]+# Sibling scripts import `ground_truth` and `comparator` from this directory.if str(ML_DIR) not in sys.path:sys.path.insert(0, str(ML_DIR))diff --git a/infra/ml/test/tools/_report_common.py b/infra/ml/test/tools/_report_common.pyindex 08cfd1f276..649c28f1e4 100644--- a/infra/ml/test/tools/_report_common.py+++ b/infra/ml/test/tools/_report_common.py@@ -1,8 +1,4 @@-"""Helpers shared by the parity report renderers.--Stdlib-only: the renderers are invoked with the system `python3` by-`run_ml_parity_tests.sh`.-"""+# This runs under system Python; keep it stdlib-only.from __future__ import annotationsfrom datetime import datetime, timedelta, timezonediff --git a/infra/ml/test/tools/desktop_parity_runner.js b/infra/ml/test/tools/desktop_parity_runner.jsindex 06020e0b89..b4a13b3c34 100755--- a/infra/ml/test/tools/desktop_parity_runner.js+++ b/infra/ml/test/tools/desktop_parity_runner.js@@ -1,24 +1,4 @@#!/usr/bin/env node-/**- * Desktop platform runner for the ML indexing parity suite.- *- * Run the parity corpus through the desktop build of the Rust ML pipeline- * (see [Note: ML with Rust] in the desktop app), writing results in the- * format consumed by compare_parity_outputs.py.- *- * This is invoked by run_ml_parity_tests.sh, which syncs the fixture images- * and models to local disk beforehand; this script performs no network- * access. It smoke tests the desktop specific pieces β the napi addon and- * the pinned ONNX Runtime library it loads β while the deep validation of- * the shared Rust pipeline itself lives in the ente-photos crate's- * ml_indexing integration test.- *- * The desktop build artifacts it needs are the addon in- * `desktop/rust-bindings/` (built by `node scripts/napi.js build`) and the- * ONNX Runtime library in `desktop/build/onnxruntime/` (downloaded by the- * desktop postinstall).- */-const fsp = require("node:fs/promises");const path = require("node:path");const { parseArgs } = require("node:util");@@ -51,7 +31,6 @@ const parseCLIArgs = () => {return values;};-/** Load the Rust ML addon built by desktop's `scripts/napi.js`. */const loadMLAddon = () => {const addonPath = path.join(desktopDir,@@ -61,11 +40,8 @@ const loadMLAddon = () => {return require(addonPath);};-/**- * The ONNX Runtime dynamic library downloaded by desktop's `scripts/ort.js`- * for the current architecture, located by scanning so that this script does- * not duplicate the pinned library version.- */+// Desktop's build scripts own the pinned ONNX Runtime version.+// Scan their output instead of duplicating it here.const onnxRuntimeLibraryPath = async () => {const libraryDir = path.join(desktopDir,@@ -87,11 +63,6 @@ const onnxRuntimeLibraryPath = async () => {return path.join(libraryDir, library.name);};-/**- * Resolve the models needed for indexing from the parity harness' local- * model mirror cache, which run_ml_parity_tests.sh populates (verifying- * against the SHA-256s in the asset lock) before invoking us.- */const resolveModels = async (assetLockPath, modelsDir) => {const assetLock = JSON.parse(await fsp.readFile(assetLockPath, "utf8"));@@ -156,7 +127,7 @@ const analyzeFixture = async (native, fileID, imagePath, modelPaths) => {return result;};-/** Mirror of _toParityResult in mobile's ml_parity_shared.dart. */+// Keep this result shape in sync with mobile's ml_parity_shared.dart.const toParityResult = (fileID, result, models, codeRevision, totalMS) => {const clip = result.clip;if (!clip) throw new Error(`Missing CLIP result for ${fileID}`);diff --git a/infra/ml/test/tools/parity_shell_helpers.py b/infra/ml/test/tools/parity_shell_helpers.pyindex de100e0b9e..e0604d0f09 100644--- a/infra/ml/test/tools/parity_shell_helpers.py+++ b/infra/ml/test/tools/parity_shell_helpers.py@@ -1,9 +1,5 @@#!/usr/bin/env python3-"""Stdlib-only subcommands for run_ml_parity_tests.sh.--Each subcommand was extracted from an inline python3 heredoc in the shell-script; bodies and exit codes are preserved. Runs under the system python3.-"""+# This runs under system Python; keep it stdlib-only.from __future__ import annotationsimport base64diff --git a/infra/services/grafana/grafana.nginx.conf b/infra/services/grafana/grafana.nginx.confindex ce57a3a3d7..11c10c0ea5 100644--- a/infra/services/grafana/grafana.nginx.conf+++ b/infra/services/grafana/grafana.nginx.conf@@ -1,4 +1,3 @@-# Needed for web socketsmap $http_upgrade $connection_upgrade {default upgrade;'' close;diff --git a/infra/services/help-redir/_redirects b/infra/services/help-redir/_redirectsindex e839663758..fbbd3a304c 100644--- a/infra/services/help-redir/_redirects+++ b/infra/services/help-redir/_redirects@@ -1,5 +1 @@-# Redirect all traffic from help.ente.io to ente.com/help-# Using 301 (permanent redirect)-# Splat pattern preserves the entire path-/* https://ente.com/help/:splat 301diff --git a/infra/services/listmonk/initialize-db.sh b/infra/services/listmonk/initialize-db.shindex 576c607a92..10a6705f92 100755--- a/infra/services/listmonk/initialize-db.sh+++ b/infra/services/listmonk/initialize-db.sh@@ -1,8 +1,6 @@#!/bin/sh-# This script needs to be manually run the once (and only once) before starting-# Listmonk for the first time. It uses the provided credentials to initialize-# its database.+# Run once before starting Listmonk to initialize its database.set -o errexitset -o xtracediff --git a/infra/services/listmonk/listmonk.nginx.conf b/infra/services/listmonk/listmonk.nginx.confindex 3d5e18c3f3..543df28307 100644--- a/infra/services/listmonk/listmonk.nginx.conf+++ b/infra/services/listmonk/listmonk.nginx.conf@@ -1,6 +1,3 @@-# This file gets loaded in a top level http block by the default nginx.conf-# See infra/services/nginx/README.md for more details.-server {listen 443 ssl;listen [::]:443 ssl;@@ -17,8 +14,6 @@ server {proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;- # Use HTTP/1.1 when talking to upstream- # Also, while not necessary (AFAIK), also allow websockets.proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "upgrade";diff --git a/infra/services/prometheus/prometheus.yml b/infra/services/prometheus/prometheus.ymlindex dbd319a347..f36315d08f 100644--- a/infra/services/prometheus/prometheus.yml+++ b/infra/services/prometheus/prometheus.yml@@ -1,5 +1,3 @@-# https://prometheus.io/docs/prometheus/latest/configuration/-scrape_configs:- job_name: museumstatic_configs:@@ -28,7 +26,6 @@ scrape_configs:target_label: instancereplacement: XX-HOSTNAME-# Grafana Cloudremote_write:- url: https://g/api/prom/pushbasic_auth:diff --git a/infra/services/promtail/promtail.yaml b/infra/services/promtail/promtail.yamlindex 99a2578ff6..3fa09f041b 100644--- a/infra/services/promtail/promtail.yaml+++ b/infra/services/promtail/promtail.yaml@@ -1,11 +1,6 @@-# https://grafana.com/docs/loki/latest/clients/promtail/configuration/--# We don't want Promtail's HTTP / GRPC server.server:disable: true-# Loki URL-# For Grafana Cloud, it can be found in the integrations section.clients:- url: http://loki:3100/loki/api/v1/push@@ -13,8 +8,6 @@ clients:# - Retains flexibility in file names.# - Makes adding job labels easy.# - Does not get in the way of logrotation.-#-# In addition, also scrape logs from all docker containers.scrape_configs:- job_name: museumstatic_configs:diff --git a/infra/services/sentry/config.yml b/infra/services/sentry/config.ymlindex 953a7490f4..44964ee4b0 100644--- a/infra/services/sentry/config.yml+++ b/infra/services/sentry/config.yml@@ -1,13 +1,7 @@-###############-# Mail Server #-###############-mail.host: "smtp.example.org"mail.port: 587mail.username: ""mail.password: ""mail.use-tls: true-# ...-system.url-prefix: "https://sentry.ente.com"diff --git a/infra/services/status/uptime-kuma.nginx.conf b/infra/services/status/uptime-kuma.nginx.confindex 4959e964a9..0a6d2d5e4d 100644--- a/infra/services/status/uptime-kuma.nginx.conf+++ b/infra/services/status/uptime-kuma.nginx.conf@@ -1,6 +1,3 @@-# This file gets loaded in a top level http block by the default nginx.conf-# See infra/services/nginx/README.md for more details.-server {listen 443 ssl;listen [::]:443 ssl;@@ -17,9 +14,6 @@ server {proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;- # Recommended options from Uptime Kuma Wiki for Websockets.- #- # https://github.com/louislam/uptime-kuma/wiki/Reverse-Proxy#nginxproxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "upgrade";diff --git a/infra/staff/src/vite-env.d.ts b/infra/staff/src/vite-env.d.tsindex 5c228bbe0e..6ffd93c498 100644--- a/infra/staff/src/vite-env.d.ts+++ b/infra/staff/src/vite-env.d.ts@@ -1,15 +1,6 @@-/* Type shims provided by vite, e.g. for asset imports- https://vitejs.dev/guide/features.html#client-types */-/// <reference types="vite/client" />-/** Types for the vite injected environment variables */interface ImportMetaEnv {- /**- * Override the origin (scheme://host:port) of Ente's API to connect to.- *- * Default is "https://api.ente.com".- */readonly VITE_ENTE_API_ORIGIN: string | undefined;}diff --git a/infra/staff/vite.config.ts b/infra/staff/vite.config.tsindex e3b37b3bb9..8086301628 100644--- a/infra/staff/vite.config.ts+++ b/infra/staff/vite.config.ts@@ -1,5 +1,4 @@import react from "@vitejs/plugin-react";import { defineConfig } from "vite";-// https://vitejs.dev/config/export default defineConfig({ plugins: [react()] });diff --git a/infra/workers/cast-albums/src/index.ts b/infra/workers/cast-albums/src/index.tsindex 8aa44ea1d5..f13630d961 100644--- a/infra/workers/cast-albums/src/index.ts+++ b/infra/workers/cast-albums/src/index.ts@@ -1,5 +1,3 @@-/** Proxy file and thumbnail requests for the cast web app. */-export default {async fetch(request: Request) {switch (request.method) {diff --git a/infra/workers/csp-reporter/src/index.ts b/infra/workers/csp-reporter/src/index.tsindex e34059ae97..6105ef0fb3 100644--- a/infra/workers/csp-reporter/src/index.ts+++ b/infra/workers/csp-reporter/src/index.ts@@ -1,9 +1,3 @@-/**- * Log CSP reports.- *- * See _headers in the web app source.- */-export default {async fetch(request: Request) {switch (request.method) {diff --git a/infra/workers/data-puller/src/index.ts b/infra/workers/data-puller/src/index.tsindex 8168075e1a..e6cb13d612 100644--- a/infra/workers/data-puller/src/index.ts+++ b/infra/workers/data-puller/src/index.ts@@ -1,9 +1,3 @@-/**- * Proxy requests for downloading files from object storage.- *- * Used by museum when replicating.- */-export default {async fetch(request: Request) {switch (request.method) {diff --git a/infra/workers/files/src/index.ts b/infra/workers/files/src/index.tsindex 45286f5034..ccc1720f7e 100644--- a/infra/workers/files/src/index.ts+++ b/infra/workers/files/src/index.ts@@ -1,5 +1,3 @@-/** Proxy requests for files. */-export default {async fetch(request: Request) {switch (request.method) {diff --git a/infra/workers/github-discord-notifier/src/index.ts b/infra/workers/github-discord-notifier/src/index.tsindex 7237d003d3..a82cb7d3ab 100644--- a/infra/workers/github-discord-notifier/src/index.ts+++ b/infra/workers/github-discord-notifier/src/index.ts@@ -1,9 +1,3 @@-/**- * Forward notifications from GitHub to Discord.- *- * This worker receives webhooks from GitHub, filters out the ones we don't- * need, and forwards the rest to a Discord webhook.- */export default {async fetch(request: Request, env: Env) {return handleRequest(request, env.DISCORD_WEBHOOK_URL);@@ -19,20 +13,11 @@ const handleRequest = async (request: Request, discordWebhookURL: string) => {const requestJSON = JSON.parse(requestBody);const sender = requestJSON["sender"]["login"];if (sender === "cloudflare-pages[bot]" || sender === "CLAassistant") {- // Ignore pings from CF botreturn new Response(null, { status: 200 });}- // [Note: GitHub specific Discord Webhooks]- //- // By appending `/github` to the end of the webhook URL, we can get Discord- // to automatically parse the payload sent by GitHub.- // https://discord.com/developers/docs/resources/webhook#execute-githubcompatible-webhook- //- // Note that this doesn't work for all events. And sadly, the events it- // doesn't work for get silently ignored (Discord responds with a 204).- // https://github.com/discord/discord-api-docs/issues/6203#issuecomment-1608151265-+ // Discord parses GitHub payloads sent to `/github`.+ // Unsupported events are silently dropped with a 204.const response = await fetch(`${discordWebhookURL}/github`, {method: request.method,headers: request.headers,@@ -40,30 +25,7 @@ const handleRequest = async (request: Request, discordWebhookURL: string) => {});if (response.status == 429) {- // Sometimes Discord starts returning 429 Rate Limited responses when we- // try to invoke the webhook.- //- // Retry-After: 300- // X-Ratelimit-Global: true- // X-Ratelimit-Scope: global- //- // {"message": "You are being rate limited.", "retry_after": 0.3, "global": true}- //- // This just seems to be a bug on their end, and it goes away on its own- // after a while. My best guess is that the IP of the Cloudflare Worker- // somehow gets rate limited because of someone else trying to spam from- // a worker running on the same IP. But it's a guess. I'm not sure.- //- // Ref:- // https://discord.com/developers/docs/topics/rate-limits#global-rate-limit- //- // Interestingly, this only happens for the `/github` specific webhook.- // The normal webhook still works. So as a workaround, just send a- // normal text message to the webhook when we get a 429.-- // The JSON sent by GitHub has a varied schema. This is a stop-gap- // arrangement (we shouldn't be getting 429s forever), so just try to- // see if we can extract a URL from something we recognize.+ // Discord can rate-limit `/github` while the normal webhook still works.let activityURL: string | undefined;if (requestJSON["comment"]) {activityURL = requestJSON["comment"]["html_url"];@@ -75,7 +37,6 @@ const handleRequest = async (request: Request, discordWebhookURL: string) => {activityURL = requestJSON["discussion"]["html_url"];}- // Ignore things like issue label changes.const action = requestJSON["action"];if (activityURL && ["created", "opened"].includes(action)) {diff --git a/infra/workers/health-check/src/index.ts b/infra/workers/health-check/src/index.tsindex 550585623b..fc7ac1f6dd 100644--- a/infra/workers/health-check/src/index.ts+++ b/infra/workers/health-check/src/index.ts@@ -1,5 +1,3 @@-/** Ping api.ente.com every minute and yell if it doesn't pong. */-export default {async scheduled(_, env: Env, ctx: ExecutionContext) {ctx.waitUntil(ping(env, ctx));diff --git a/infra/workers/public-albums/src/index.ts b/infra/workers/public-albums/src/index.tsindex 1ce8b921ef..082603d96d 100644--- a/infra/workers/public-albums/src/index.ts+++ b/infra/workers/public-albums/src/index.ts@@ -1,5 +1,3 @@-/** Proxy requests for files and thumbnails in public albums. */-export default {async fetch(request: Request) {switch (request.method) {diff --git a/infra/workers/sentry-reporter/src/index.ts b/infra/workers/sentry-reporter/src/index.tsindex 8223731fef..8ef6b4c59f 100644--- a/infra/workers/sentry-reporter/src/index.ts+++ b/infra/workers/sentry-reporter/src/index.ts@@ -1,16 +1,5 @@-/**- * Forward a tunneled request from our clients to our Sentry instance.- *- * The client use a Sentry "tunnel" that connects to where this worker listens.- * Requests to this tunnel endpoint contain the original crash report wrapped in- * an envelope. This worker extracts the original Sentry request from the- * envelope, forwards it our Sentry instance, and proxies back the response.- *- * It also replaces the replace the DSN in the POST body with the latest one.- * This allows us to hardcode the DSN in the clients, without needing to update- * them if the DSN changes on our self-hosted Sentry's side (e.g. if we recreate- * these projects from scratch in the Sentry instance).- */+// Known client DSNs are rewritten to the current Sentry projects.+// This lets us recreate a project without updating released clients.export default {async fetch(request: Request) {switch (request.method) {@@ -30,7 +19,6 @@ const handlePOST = async (request: Request) => {const projectId = parseInt(dsn.pathname?.slice(1)?.split("/")[0] ?? "1");- // Proxy request to Sentry ingestreturn fetch(`https://${dsn.host}/api/${projectId}/envelope/`, {method: "POST",headers: {@@ -40,10 +28,7 @@ const handlePOST = async (request: Request) => {});};-/** Parse the POST body sent by Sentry client to extract the DSN therein */const extractDSN = (body: string) => {- // The body consists of 3 lines, each a JSON string. The first line is the- // envelope header.const [envelopeHeaderString] = body.split("\n", 1);if (!envelopeHeaderString) throw new Error(`Missing DSN`);const envelopeHeader = JSON.parse(envelopeHeaderString ?? "");@@ -52,26 +37,16 @@ const extractDSN = (body: string) => {return dsn;};-/**- * If {@link originalDSNString} matches one of the known DSNs that we want to- * map, perform a textual search and replace of the DSN and public_key fields in- * the body of the request.- *- * @returns the (possibly) modified body and DSN.- */const mapDSN = (originalBody: string, originalDSNString: string) => {const originalDSN = new URL(originalDSNString);const dsnString = dsnMappings[originalDSNString];if (dsnString === undefined) {- // We don't have a mapping for this DSN, return the originals unchanged.return { body: originalBody, dsn: originalDSN };}const dsn = new URL(dsnString);- // Extract the public_key part from the URLs. We need to do two- // substitutions, first for the entire DSN, and then for the public key.const originalPublicKey = originalDSN.username;const publicKey = dsn.username;diff --git a/infra/workers/tail/src/index.ts b/infra/workers/tail/src/index.tsindex af27868f58..d27de20df6 100644--- a/infra/workers/tail/src/index.ts+++ b/infra/workers/tail/src/index.ts@@ -1,8 +1,3 @@-/**- * A tail worker that forwards all `console.log` (and siblings) to Loki.- *- * https://developers.cloudflare.com/workers/observability/logging/tail-workers/- */export default {async tail(events: TraceItem[], env: Env) {// If the tail worker itself throws an exception (it shouldn't, unless@@ -13,22 +8,9 @@ export default {} satisfies ExportedHandler<Env>;interface Env {- /** The URL of the Loki instance to push logs to. */LOKI_PUSH_URL: string;- /**- * The value of the "Basic" authorization.- *- * [Note: HTTP basic authorization in worker fetch]- *- * Usually a Loki push URL is specified with the credentials inline, say- * `http://user:pass@loki/path`. However, I cannot get that to work with the- * `fetch` inside a Cloudflare worker. Instead, the credentials need to be- * separately provided as the Authorization header of the form:- *- * Authorization: Basic ${btoa(user:pass)}- *- * The LOKI_AUTH secret is the "${btoa(user:pass)}" value.- */+ // Worker fetch does not accept credentials in the Loki URL.+ // This secret is base64-encoded `user:pass` for the Basic header.LOKI_AUTH: string;}@@ -37,23 +19,9 @@ const handleTail = async (events: TraceItem[], env: Env) => {await pushLogLine(Date.now(), JSON.stringify(event), env);};-/** Return true if the {@link event} has at least one log or exception. */const hasLogOrException = (event: TraceItem) =>event.logs.length ?? event.exceptions.length;-/**- * Send a log entry to (Grafana) Loki- *- * For more details about the protocol, see- * https://grafana.com/docs/loki/latest/reference/loki-http-api/#ingest-logs- *- * @param timestampMs Unix epoch (in milliseconds) when the event occurred.- *- * @param logLine The message to log.- *- * @param env The worker environment; we need it for the Loki URL and- * credentials.- */const pushLogLine = async (timestampMs: number, logLine: string, env: Env) =>await fetch(env.LOKI_PUSH_URL, {method: "POST",diff --git a/infra/workers/thumbnails/src/index.ts b/infra/workers/thumbnails/src/index.tsindex aad7c5e123..224bbd638a 100644--- a/infra/workers/thumbnails/src/index.ts+++ b/infra/workers/thumbnails/src/index.ts@@ -1,5 +1,3 @@-/** Proxy requests for thumbnails. */-export default {async fetch(request: Request) {switch (request.method) {diff --git a/infra/workers/uploader/src/index.ts b/infra/workers/uploader/src/index.tsindex af7572abed..8db0b3f1ed 100644--- a/infra/workers/uploader/src/index.ts+++ b/infra/workers/uploader/src/index.ts@@ -1,9 +1,3 @@-/**- * Proxy file uploads.- *- * See: https://ente.com/blog/tech/making-uploads-faster/- */-export default {async fetch(request: Request) {switch (request.method) {@@ -20,19 +14,16 @@ export default {},} satisfies ExportedHandler;-// Strict allowlist of upload destinations. Expand as needed.+// Strict allowlist of upload destinations.const ALLOWED_UPLOAD_HOSTS = new Set<string>([- // Example: Backblaze B2 S3-compatible bucket endpoint"ente-prod-eu.s3.eu-central-003.backblazeb2.com",]);const isAllowedUploadURL = (uploadURL: string) => {try {const url = new URL(uploadURL);- // Enforce HTTPS, no credentials, and an allowlisted host.if (url.protocol !== "https:") return false;if (url.username || url.password) return false;- // Only default HTTPS port; signed URLs should not need a custom port.if (url.port && url.port !== "443") return false;if (!ALLOWED_UPLOAD_HOSTS.has(url.hostname)) return false;return true;