From fc7cf1b64cbd829e10cfc57ff84901db27b9941d Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Sat, 14 Nov 2026 16:15:09 +0000 Subject: [PATCH] Keep FLM learning when review history fills up --- openpilot/starpilot/flm/offroad_cache.py | 75 ++++++++++++++- openpilot/starpilot/flm/offroad_worker.py | 5 + .../flm/tests/test_offroad_backend.py | 2 +- .../flm/tests/test_offroad_cache_retention.py | 76 +++++++++++++++ openpilot/starpilot/galaxy/flm_diagnostics.py | 76 +++++++++++++++ .../starpilot/galaxy/flm_training_results.py | 5 + openpilot/starpilot/galaxy/server.py | 9 ++ .../galaxy/tests/test_flm_diagnostics.py | 92 +++++++++++++++++++ .../galaxy/tests/test_flm_review.mjs | 6 ++ .../galaxy/web/js/flm-training-results.js | 1 + openpilot/starpilot/galaxy/web/js/flm.js | 11 ++- prebuilt.json | 2 +- 12 files changed, 350 insertions(+), 10 deletions(-) create mode 100644 openpilot/starpilot/flm/tests/test_offroad_cache_retention.py create mode 100644 openpilot/starpilot/galaxy/flm_diagnostics.py create mode 100644 openpilot/starpilot/galaxy/tests/test_flm_diagnostics.py diff --git a/openpilot/starpilot/flm/offroad_cache.py b/openpilot/starpilot/flm/offroad_cache.py index 9fd9c819cf..cf9b88d587 100644 --- a/openpilot/starpilot/flm/offroad_cache.py +++ b/openpilot/starpilot/flm/offroad_cache.py @@ -104,7 +104,7 @@ class AssessmentCache: self._write(digest + '.json', raw) return digest - def _capacity(self, size): + def _capacity(self, size, files=1): total = count = 0 for p in self.directory.iterdir(): if p.name in ('latest.json', 'inputs.json'): @@ -115,10 +115,75 @@ class AssessmentCache: if not stat.S_ISREG(s.st_mode) or s.st_uid != os.geteuid(): raise ValueError('Foreign assessment file') total += s.st_size - count += 1 - if count >= MAX_FILES or total + size > MAX_TOTAL: + # Consumed-start markers must survive retirement; they are not assessments. + count += not (p.name.startswith('trial-') and len(p.name) == 75 and not p.name[6:-5].strip('0123456789abcdef')) + if count + files > MAX_FILES or total + size > MAX_TOTAL: raise ValueError('Assessment cache full') + def retire(self, protected, *, authorized): + """Parked-only retirement of unreferenced derived documents, never trial claims.""" + self._owned() + try: + self._capacity(4 * MAX_DOCUMENT, files=4) + return 0 + except ValueError as error: + if str(error) != 'Assessment cache full': + raise + for digest in protected: + self.get(digest) + documents = {} + for path in self.directory.iterdir(): + if len(path.name) == 69 and path.suffix == '.json' and not path.stem.strip('0123456789abcdef'): + documents[path.stem] = path.lstat() + + def references(value): + if type(value) is str: + return {value} if value in documents else set() + if type(value) is dict: + return set().union(*(references(v) for v in value.values()), set()) + if type(value) is list: + return set().union(*(references(v) for v in value), set()) + return set() + + keep = references(list(protected)) | references(self.checkpoints()) + # Keep recent reports available even if newer resource failures filled the checkpoints. + ordered = sorted(documents, key=lambda name: (documents[name].st_mtime_ns, name), reverse=True) + keep.update(ordered[:MAX_CHECKPOINTS]) + pending = list(keep) + while pending: + linked = references(self.get(pending.pop())) - keep + keep.update(linked) + pending.extend(linked) + removed = 0 + for digest in reversed(ordered): + try: + self._capacity(4 * MAX_DOCUMENT, files=4) + break + except ValueError as error: + if str(error) != 'Assessment cache full': + raise + if digest in keep: + continue + self.get(digest) # Only retire intact immutable documents. + if not authorized(): + raise ValueError('Assessment retirement no longer permitted') + self._owned() + path = self.directory / (digest + '.json') + current, before = path.lstat(), documents[digest] + fields = ('st_dev', 'st_ino', 'st_mode', 'st_uid', 'st_size', 'st_mtime_ns') + if any(getattr(current, field) != getattr(before, field) for field in fields): + raise ValueError('Assessment changed before retirement') + path.unlink() + removed += 1 + if removed: + fd = os.open(self.directory, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW) + try: + os.fsync(fd) + finally: + os.close(fd) + self._capacity(4 * MAX_DOCUMENT, files=4) + return removed + def claim_trial(self, digest, session): """Durably consume one provisional start; any previous claim refuses.""" if ( @@ -133,7 +198,9 @@ class AssessmentCache: self._owned() name = 'trial-' + digest + '.json' raw = json.dumps({'analysis_sha256': digest, 'vehicle_session': session}, sort_keys=True, separators=(',', ':')).encode() - self._capacity(len(raw)) + if os.path.lexists(self.directory / name): + return False + self._capacity(len(raw), files=0) try: fd = os.open(self.directory / name, os.O_WRONLY | os.O_CREAT | os.O_EXCL | os.O_NOFOLLOW, 0o600) except FileExistsError: diff --git a/openpilot/starpilot/flm/offroad_worker.py b/openpilot/starpilot/flm/offroad_worker.py index 58ec633be8..9f4db1cdcc 100644 --- a/openpilot/starpilot/flm/offroad_worker.py +++ b/openpilot/starpilot/flm/offroad_worker.py @@ -614,6 +614,11 @@ class OffroadWorker: self.skipped_routes = [] if not self.permitted(): raise ValueError('Offroad analysis not permitted') + saved, readable = read_saved(self.params, KEY, MAX_BYTES) + if not readable: + raise ValueError('Unreadable automatic tuning history') + protected = [row['analysis_sha256'] for row in decode(saved).get(NAMESPACE, {}).values()] + self.cache.retire(protected, authorized=lambda: self.permitted() and read_saved(self.params, KEY, MAX_BYTES) == (saved, True)) self.pending_logger = logger_marker(self.params) latest = latest_route(self.params, self.root, permitted=self.permitted, inventory_only=True, on_skip=self._skip_route) if logger_marker(self.params) != self.pending_logger: diff --git a/openpilot/starpilot/flm/tests/test_offroad_backend.py b/openpilot/starpilot/flm/tests/test_offroad_backend.py index cd0b1601a8..c71079b6b6 100644 --- a/openpilot/starpilot/flm/tests/test_offroad_backend.py +++ b/openpilot/starpilot/flm/tests/test_offroad_backend.py @@ -98,7 +98,7 @@ class TestOffroadCache(unittest.TestCase): for session in ('', 'e' * 31, 'z' * 32): with self.subTest(session=session), self.assertRaises(ValueError): self.cache.claim_trial('d' * 64, session) - with patch('openpilot.starpilot.flm.offroad_cache.MAX_FILES', 0), self.assertRaises(ValueError): + with patch('openpilot.starpilot.flm.offroad_cache.MAX_TOTAL', 0), self.assertRaises(ValueError): self.cache.claim_trial('e' * 64, 'f' * 32) self.cache.directory.chmod(0o777) with self.assertRaises(ValueError): diff --git a/openpilot/starpilot/flm/tests/test_offroad_cache_retention.py b/openpilot/starpilot/flm/tests/test_offroad_cache_retention.py new file mode 100644 index 0000000000..b17bc18ef1 --- /dev/null +++ b/openpilot/starpilot/flm/tests/test_offroad_cache_retention.py @@ -0,0 +1,76 @@ +"""Retiring derived reports must never erase saved proofs or consumed starts.""" + +import os +from pathlib import Path +import tempfile +import unittest +from unittest.mock import patch + +from openpilot.starpilot.flm.offroad_cache import AssessmentCache, MAX_FILES + + +class TestCacheRetention(unittest.TestCase): + def setUp(self): + temporary = tempfile.TemporaryDirectory() + self.addCleanup(temporary.cleanup) + self.cache = AssessmentCache(Path(temporary.name) / 'cache') + + def fill(self): + return [self.cache.put({'kind': 'completed_assessment', 'unit': index}) for index in range(MAX_FILES)] + + def test_full_cache_releases_room_preserving_saved_proof_dependency_and_checkpoints(self): + linked = self.cache.put({'kind': 'next_drive_trial'}) + saved = self.cache.put({'kind': 'next_drive_outcome', 'trial_analysis_sha256': linked}) + checkpoint = self.cache.put({'kind': 'completed_assessment', 'unit': 'checkpoint'}) + self.cache.checkpoint({'input_fingerprint': 'f' * 64, 'result': {'status': 'collecting', 'reason': 'unit', 'assessment_sha256': checkpoint}}) + for index in range(MAX_FILES - 3): + self.cache.put({'kind': 'completed_assessment', 'unit': index}) + with self.assertRaisesRegex(ValueError, 'Assessment cache full'): + self.cache.put({'unit': 'new'}) + self.assertEqual(self.cache.retire([saved], authorized=lambda: True), 4) + for digest in (saved, linked, checkpoint): + self.cache.get(digest) + for index in range(4): + self.cache.put({'unit': 'new', 'index': index}) + + def test_consumed_claim_survives_retired_trial_and_does_not_consume_document_slot(self): + digests = self.fill() + self.assertTrue(self.cache.claim_trial(digests[0], 'a' * 32)) + claim = self.cache.directory / ('trial-' + digests[0] + '.json') + raw = claim.read_bytes() + self.cache.retire([], authorized=lambda: True) + self.assertFalse((self.cache.directory / (digests[0] + '.json')).exists()) + self.assertEqual(claim.read_bytes(), raw) + self.assertFalse(self.cache.claim_trial(digests[0], 'b' * 32)) + + def test_recent_documents_are_kept_and_repeated_maintenance_is_idle(self): + digests = self.fill() + for index, digest in enumerate(digests): + os.utime(self.cache.directory / (digest + '.json'), ns=(index + 1, index + 1)) + self.cache.retire([], authorized=lambda: True) + for digest in digests[-8:]: + self.cache.get(digest) + self.assertEqual(self.cache.retire([], authorized=lambda: True), 0) + + def test_permission_loss_missing_saved_proof_and_foreign_contents_preserve_files(self): + self.fill() + before = set(self.cache.directory.iterdir()) + with self.assertRaisesRegex(ValueError, 'no longer permitted'): + self.cache.retire([], authorized=lambda: False) + self.assertEqual(set(self.cache.directory.iterdir()), before) + with self.assertRaises(FileNotFoundError): + self.cache.retire(['f' * 64], authorized=lambda: True) + (self.cache.directory / 'unknown.bin').write_bytes(b'unit') + with self.assertRaisesRegex(ValueError, 'Unexpected'): + self.cache.retire([], authorized=lambda: True) + self.assertTrue(before.issubset(set(self.cache.directory.iterdir()))) + + def test_byte_limit_still_counts_consumed_markers(self): + digest = self.cache.put({'unit': True}) + self.cache.claim_trial(digest, 'a' * 32) + with patch('openpilot.starpilot.flm.offroad_cache.MAX_TOTAL', 1), self.assertRaisesRegex(ValueError, 'Assessment cache full'): + self.cache._capacity(1) + + +if __name__ == '__main__': + unittest.main() diff --git a/openpilot/starpilot/galaxy/flm_diagnostics.py b/openpilot/starpilot/galaxy/flm_diagnostics.py new file mode 100644 index 0000000000..73f0c2f6f7 --- /dev/null +++ b/openpilot/starpilot/galaxy/flm_diagnostics.py @@ -0,0 +1,76 @@ +"""Small, read-only support download; no raw routes, CarParams, GPS or credentials.""" + +import json +import re + +from openpilot.starpilot.flm.offroad_cache import AssessmentCache, directory_for_params +from openpilot.starpilot.flm.offroad_store import KEY, MAX_BYTES, NAMESPACE +from openpilot.starpilot.flm.learned_lifecycle import decode +from openpilot.starpilot.saved_source import read_saved + + +def _reason(value): + text = str(value)[:512] + text = re.sub(r'https?://\S+|/(?:data|home|Users|tmp)/\S+', '[private location]', text) + return re.sub(r'(?i)(?:token|password|secret|authorization)[=: ]+\S+', '[private credential]', text) + + +def _result(value): + result = {key: value[key] for key in ('status', 'configuration_changed', 'configuration_state', 'saved_adjustments', + 'analysis_counts', 'actual_application_proven', 'recommendation_count', 'route_skipped') if key in value} + result['reason'] = _reason(value.get('reason', 'not_reported')) + skipped = value.get('skipped_routes') + result['skipped_drives'] = [{'recording': _reason(row[0])[:180], 'reason': _reason(row[1])} + for row in (skipped[:16] if type(skipped) is list else ()) if type(row) is list and len(row) == 2] + return result + + +def diagnostics(report, params): + current = report.get('current') or {} + details = current.get('details') or {} + result = {'version': 1, 'privacy': 'No raw route data, location, VIN, dongle ID or credentials included.', + 'current': {key: current[key] for key in ('fresh', 'ageSeconds', 'enabled', 'status', 'progress', 'fit', 'application') if key in current}, + 'preference': report.get('preference'), 'history': report.get('history', []), 'checkpoints': [], 'saved_profiles': []} + result['current']['reason'] = _reason(current.get('reason', 'learner_report_unavailable')) + result['current']['analysis'] = {key: details[key] for key in ( + 'Recorded steering observations', 'Retained control windows', 'Retained tracking windows', 'Recorded drive coverage', + 'Drives in steering evidence history', 'Saved route adjustment count', 'Saved route configuration state', + 'Recorded coordinate recommendations', 'Controller and encoder check windows', 'Automatic tune refusal reasons') if key in details} + result['current']['skipped_drives'] = _result({'skipped_routes': details.get('Skipped recorded drives', [])})['skipped_drives'] + if params is None: + result['storage'] = {'status': 'unavailable'} + return result + for key in ('GitCommit', 'GitBranch'): + raw, readable = read_saved(params, key, 128) + if readable and raw is not None and re.fullmatch(rb'[\w./-]{1,128}', raw): + result[key] = raw.decode('ascii') + try: + raw, readable = read_saved(params, KEY, MAX_BYTES) + if not readable: + raise ValueError('saved_profiles_unreadable') + for row in decode(raw).get(NAMESPACE, {}).values(): + result['saved_profiles'].append({'state': row['state'], 'sequence': row['sequence'], + 'adjustments': sum(value != 0 for value in row['values'].values()), + 'evidence_drives': len(row['route_sha256s'])}) + directory = directory_for_params(params) + if not directory.exists(): + result['storage'] = {'status': 'not_created', 'documents': 0, 'bytes': 0} + else: + cache = AssessmentCache(directory) + files = list(directory.iterdir()) + result['storage'] = {'status': 'readable', 'documents': len(files), 'bytes': sum(path.lstat().st_size for path in files)} + result['checkpoints'] = [_result(row['result']) for row in cache.checkpoints()] + except (OSError, ValueError, TypeError, KeyError) as error: + result['storage'] = {'status': 'unavailable', 'reason': _reason(error)} + return result + + +def download(report, params): + def clean(value): + if type(value) is dict: + return {key: clean(item) for key, item in value.items()} + if type(value) is list: + return [clean(item) for item in value] + return _reason(value) if type(value) is str else value + + return 'starpilot-flm-logs.json', json.dumps(clean(diagnostics(report, params)), indent=2, allow_nan=False).encode() diff --git a/openpilot/starpilot/galaxy/flm_training_results.py b/openpilot/starpilot/galaxy/flm_training_results.py index 999a2a7133..4c7df8a4d1 100644 --- a/openpilot/starpilot/galaxy/flm_training_results.py +++ b/openpilot/starpilot/galaxy/flm_training_results.py @@ -53,3 +53,8 @@ class FlmTrainingResults: return {'version': 1, 'valid': True, 'enabled': choice.enabled, 'parked': parked, 'vehicle': vehicle} except (OSError, RuntimeError, AttributeError, TypeError, ValueError, OverflowError, KjException): return unknown + + def download(self): + from openpilot.starpilot.galaxy.flm_diagnostics import download + + return download(self.snapshot(), self.params) diff --git a/openpilot/starpilot/galaxy/server.py b/openpilot/starpilot/galaxy/server.py index 3261123834..c9db9e7156 100644 --- a/openpilot/starpilot/galaxy/server.py +++ b/openpilot/starpilot/galaxy/server.py @@ -1349,6 +1349,15 @@ def make_server(*, port=8082, host='127.0.0.1', monitor=None, owner=None, crashe else: if self.require_session(): self.json(200, result) + elif path == '/api/flm/logs/download': + if not self.require_session(): + return + if urlsplit(self.path).query: + self.json(400, {'error': 'Unexpected FLM log query'}) + return + filename, body = training_results_source.download() + if self.require_session(): + self.attachment(filename, body, 'application/json; charset=utf-8') elif path == '/api/flm/training-results': if not self.require_session(): return diff --git a/openpilot/starpilot/galaxy/tests/test_flm_diagnostics.py b/openpilot/starpilot/galaxy/tests/test_flm_diagnostics.py new file mode 100644 index 0000000000..59cb287f87 --- /dev/null +++ b/openpilot/starpilot/galaxy/tests/test_flm_diagnostics.py @@ -0,0 +1,92 @@ +"""Support export remains useful when learning fails, without exporting private logs.""" + +import http.client +import json +from pathlib import Path +import tempfile +import threading +from types import SimpleNamespace +import unittest +from unittest.mock import patch + +from openpilot.starpilot.flm.offroad_cache import AssessmentCache, directory_for_params +from openpilot.starpilot.galaxy.access import GalaxyAccessOwner +from openpilot.starpilot.galaxy.flm_diagnostics import download +from openpilot.starpilot.galaxy.flm_training_results import FlmTrainingResults +from openpilot.starpilot.galaxy.server import make_server + + +class TestDiagnostics(unittest.TestCase): + def test_failed_reviews_skips_counts_and_version_survive_without_private_payloads(self): + with tempfile.TemporaryDirectory() as temporary: + root = Path(temporary) + params = SimpleNamespace(get_param_path=lambda key: str(root / key)) + (root / 'GitCommit').write_text('a' * 40) + (root / 'CarParams').write_text('private-vin') + (root / 'AccessToken').write_text('private-token') + cache = AssessmentCache(directory_for_params(params)) + cache.checkpoint({'input_fingerprint': 'b' * 64, 'result': {'status': 'unavailable', 'reason': 'Assessment cache full', + 'skipped_routes': [['00000049--1b13f9d9d3', 'incomplete or trailing zstd frame']], + 'analysis_counts': {'recorded_tracking': 83433}}}) + name, body = download({'current': {'status': 'unavailable', 'reason': 'Assessment cache full', 'details': { + 'CarParams': 'private-vin', 'Recorded steering observations': 83433}}, 'history': [ + {'status': 'paused', 'reason': 'password=private-secret https://example.invalid/private-token'}]}, params) + result = json.loads(body) + self.assertEqual(name, 'starpilot-flm-logs.json') + self.assertEqual(result['GitCommit'], 'a' * 40) + self.assertEqual(result['current']['reason'], 'Assessment cache full') + self.assertEqual(result['checkpoints'][0]['skipped_drives'][0]['reason'], 'incomplete or trailing zstd frame') + self.assertEqual(result['current']['analysis']['Recorded steering observations'], 83433) + self.assertNotIn(b'private-vin', body) + self.assertNotIn(b'private-token', body) + self.assertNotIn(b'private-secret', body) + + def test_export_does_not_create_an_absent_cache_or_restore_a_tune(self): + with tempfile.TemporaryDirectory() as temporary: + root = Path(temporary) / 'params' + root.mkdir() + params = SimpleNamespace(get_param_path=lambda key: str(root / key)) + before = list(root.parent.iterdir()) + _, body = download({}, params) + self.assertEqual(json.loads(body)['storage']['status'], 'not_created') + self.assertEqual(list(root.parent.iterdir()), before) + self.assertEqual(list(root.iterdir()), []) + + def test_authenticated_attachment_and_query_refusal(self): + with tempfile.TemporaryDirectory() as temporary: + root = Path(temporary) + owner = GalaxyAccessOwner(root / 'access') + self.assertTrue(owner.configure('password123', lambda: True)) + source = FlmTrainingResults(root / 'absent-report') + server = make_server(port=0, owner=owner, training_results=source, parked=lambda: True) + thread = threading.Thread(target=server.serve_forever, kwargs={'poll_interval': .01}, daemon=True) + thread.start() + + def request(path, cookie=None, *, method='GET', body=None): + connection = http.client.HTTPConnection('127.0.0.1', server.server_port, timeout=3) + try: + headers = {'Forwarded': 'for=203.0.113.8', 'Origin': f'http://127.0.0.1:{server.server_port}', 'Content-Type': 'application/json'} + if cookie: + headers['Cookie'] = cookie + connection.request(method, path, body, headers) + response = connection.getresponse() + return response.status, dict(response.getheaders()), response.read() + finally: + connection.close() + + try: + with patch.object(source, 'download', wraps=source.download) as reader: + self.assertEqual(request('/api/flm/logs/download')[0], 401) + reader.assert_not_called() + status, headers, _ = request('/api/auth/login', method='POST', body=json.dumps({'password': 'password123'})) + self.assertEqual(status, 200) + cookie = headers['Set-Cookie'].split(';')[0] + self.assertEqual(request('/api/flm/logs/download?path=secret', cookie)[0], 400) + status, headers, body = request('/api/flm/logs/download', cookie) + self.assertEqual(status, 200) + self.assertIn('starpilot-flm-logs.json', headers['Content-Disposition']) + self.assertEqual(json.loads(body)['current']['reason'], 'learner_report_unavailable') + finally: + server.shutdown() + thread.join(timeout=2) + server.server_close() diff --git a/openpilot/starpilot/galaxy/tests/test_flm_review.mjs b/openpilot/starpilot/galaxy/tests/test_flm_review.mjs index 028ee3b4b7..7951abdcb0 100644 --- a/openpilot/starpilot/galaxy/tests/test_flm_review.mjs +++ b/openpilot/starpilot/galaxy/tests/test_flm_review.mjs @@ -35,6 +35,12 @@ assert.match(ideaExplanation({ target: null }), /did not support the same change assert.match(ideaExplanation(route.suggestions[1]), /more evidence/) assert.equal(reviewModel({ ...route, suggestions: [] }).count, 0) assert.equal(reviewModel(null).count, 0) +const failedReview = FlmPage.computed.review.call({ offroad: route, current: { status: 'unavailable', reason: 'Assessment cache full' } }) +assert.equal(failedReview.title, 'Drive review could not finish') +assert.match(failedReview.description, /latest analysis could not be saved/) +assert.doesNotMatch(failedReview.description, /No new change was saved/) +assert.match(FlmPage.template, /Latest review incomplete/) +assert.match(FlmPage.template, /v-if="!bluetooth"[^>]*href="\.\/api\/flm\/logs\/download"/) assert.equal(reviewModel({ ...route, configurationState: 'ready_for_next_drive' }).tone, 'saved') assert.equal(reviewModel({ ...route, configurationState: 'rolled_back' }).title, 'Your previous tune was restored') assert.equal(reviewModel({ ...route, saved: true }).title, 'A configuration change was reported') diff --git a/openpilot/starpilot/galaxy/web/js/flm-training-results.js b/openpilot/starpilot/galaxy/web/js/flm-training-results.js index 24bc92d687..335347329d 100644 --- a/openpilot/starpilot/galaxy/web/js/flm-training-results.js +++ b/openpilot/starpilot/galaxy/web/js/flm-training-results.js @@ -239,6 +239,7 @@ const REASONS = { accepted_target_currently_acknowledged: "The controller acknowledged the accepted correction.", } export function learningReason(reason) { + if (reason === "Assessment cache full") return "FLM ran out of space in its review history. The latest analysis could not be saved; this does not mean your saved tune was erased." if (Object.hasOwn(REASONS, reason)) return REASONS[reason] const pattern = /^observed_(understeer|oversteer|late_turn_in|early_turn_in|unwind_too_slow|unwind_too_fast|low_speed_unwillingness|center_chatter|notchy_mid_curve)_(left|right|center)$/.exec(reason) if (pattern) { diff --git a/openpilot/starpilot/galaxy/web/js/flm.js b/openpilot/starpilot/galaxy/web/js/flm.js index 8409ed8706..c169fec0b2 100644 --- a/openpilot/starpilot/galaxy/web/js/flm.js +++ b/openpilot/starpilot/galaxy/web/js/flm.js @@ -5,6 +5,7 @@ import { SettingsFeed, settingsBusy } from "./settings.js" import { GalaxySettingRow, settingControl } from "./galaxy-setting-row.js" import { PollTimer, connectionError } from "./polling.js" import { requestJson } from "./startup.js" +import { bluetoothConnection } from "./bluetooth-notice.js" import { PlotGraph, PlotsPage, chartGeometry } from "./plots.js" import { validTrainingResults, readable, detailText, surfaceRows, coordinateText, trackingView, measurementText, validTrackingValues, trackingPlotView, sourceSeconds, validLearningPreference, SURFACE_GROUPS, tunerStatus, learningReason, sourceCaptureCounts, historyTitle, offroadView, FRICTION_NAMES, offroadCoordinateEvidence, recommendationText } from "./flm-training-results.js" @@ -45,7 +46,7 @@ export const FlmPage = { components: { GxState, GxNotice, GxDialog, PlotGraph, PlotsPage, GalaxySettingRow }, props: { initialView: { type: String, default: "overview" }, mode: { type: String, required: true }, unauthorized: { type: Function, required: true }, go: { type: Function, default: path => { window.location.hash = path } } }, - data: () => ({ report: null, error: "", loading: false, request: null, receivedAt: 0, now: 0, + data: () => ({ report: null, error: "", loading: false, request: null, receivedAt: 0, now: 0, bluetooth: bluetoothConnection(), manualState: { status: "idle", data: null, pending: null, error: "" }, manualResetRequested: false, manualWrite: null, headerOffset: 88, view: "overview", group: "balance", showAllHistory: false, groups: SURFACE_GROUPS }), watch: { @@ -132,6 +133,8 @@ export const FlmPage = { description: otherVehicle ? 'These findings do not match your current vehicle. Waiting for its own completed-drive report.' : 'An analysis was reported, but it is missing information needed for a complete drive review. Waiting for the full report.' } } + if (this.current?.status === 'unavailable') return { ...result, title: 'Drive review could not finish', tone: 'neutral', + description: learningReason(this.current.reason), next: 'This is an analysis problem, not a report that your saved tune was erased. Download FLM logs in Activity for details.' } if (!this.offroad && this.current) return { ...result, title: this.state.title, description: this.state.description } return result }, @@ -316,7 +319,7 @@ export const FlmPage = {
-

COMPLETED DRIVE REVIEW

{{ review.title }}

{{ review.description }}

{{ review.count }} {{ review.count === 1 ? 'finding' : 'findings' }} ·

These suggestions come from an earlier drive. Newer driving is reviewed separately.

+

COMPLETED DRIVE REVIEW

{{ review.title }}

{{ review.description }}

These suggestions come from an earlier drive. Newer driving is reviewed separately.

STEERING RESPONSE

How your car followed the steering request

{{ trackingPlot ? 'Completed window' : offroad?.observed ? 'One recorded section · ' + recordedDuration + 's' : offroad ? 'Recorded drive' : 'Waiting for samples' }}
@@ -366,10 +369,10 @@ export const FlmPage = {
-

LEARNING ACTIVITY

What the tuner found

Reported observations
+

LEARNING ACTIVITY

What the tuner found

Download FLM logsConnect over Wi-Fi to download FLM logs.
  1. {{ historyTitle(row.status) }}

    {{ learningReason(row.reason) }}

    {{ row.time }}
-

No findings reported yet

This will show real collection, trial and rollback events as the learner reports them.

+

{{ current?.status === 'unavailable' ? 'Drive review could not finish' : 'No findings reported yet' }}

{{ current?.status === 'unavailable' ? learningReason(current.reason) : 'This will show real collection, trial and rollback events as the learner reports them.' }}

Diagnostics & source details
Legacy collector state
{{ readable(current?.status) }}
Legacy collector reason
{{ readable(current?.reason) }}
Legacy retained blocks
{{ amount(current?.progress?.blocks) }}
diff --git a/prebuilt.json b/prebuilt.json index 0b2bfe4549..636012d09e 100644 --- a/prebuilt.json +++ b/prebuilt.json @@ -1 +1 @@ -{"protected_inventory_sha256": "a2135cc530bdaa6fdb759c7641c4cca606f13e88b59244414bbb14e217e7565b", "schema_version": 1} +{"protected_inventory_sha256": "b7f4bdfcb5acb29ea8eb1776fc93b2f2a4c9d42165ce46b185399802d384eaca", "schema_version": 1}