diff --git a/openpilot/starpilot/flm/offroad_daemon.py b/openpilot/starpilot/flm/offroad_daemon.py index 8f9d08d282..83586d0d34 100644 --- a/openpilot/starpilot/flm/offroad_daemon.py +++ b/openpilot/starpilot/flm/offroad_daemon.py @@ -39,7 +39,7 @@ class StatusReport: # They are historical display data, never current application or permission. fields = ('completed_route', 'vehicle', 'analysis_counts', 'recorded_tracking', 'source_sha256', 'assessment_sha256', 'recommendations', 'suggestions', 'suggestion_count', 'source_is_latest', 'latest_recording', 'skipped_routes', - 'partial_drive', 'partial_segments', 'omitted_segments') + 'partial_drive', 'partial_segments', 'omitted_segments', 'recommendation_sources') previous = {key: self.previous[key] for key in fields if key in self.previous} if previous: previous['retained_decision'] = self.previous.get('retained_decision', self.previous.get('reason', 'waiting_for_completed_drive')) @@ -165,6 +165,8 @@ class StatusReport: ][:16] details['Recorded suggestion count'] = len(recommendations) details['More recorded suggestions omitted'] = False + if 'recommendation_sources' in value: + details['Recorded suggestion sources'] = value['recommendation_sources'] proposal = value.get('suggestion') if proposal is not None: details['Full surface coordinates'] = [[n, proposal['values'][n]] for n in NAMES] diff --git a/openpilot/starpilot/flm/offroad_worker.py b/openpilot/starpilot/flm/offroad_worker.py index 49583f7c6f..1fe0cdbaf3 100644 --- a/openpilot/starpilot/flm/offroad_worker.py +++ b/openpilot/starpilot/flm/offroad_worker.py @@ -477,6 +477,87 @@ def newer_original_refusal(cache, receipt, scope, values): return None +def recent_findings(cache, results, display): + """Keep compatible provisional findings; never merge save decisions or evidence counts.""" + from openpilot.starpilot.flm.offroad_surface import route_bounds, route_values + + latest = results[0] + if latest.get('status') not in ('collecting', 'ready_for_next_drive', 'accepted_after_drive', 'rolled_back'): + return display + + def source(value): + document = cache.get(value['assessment_sha256']) + assessment = document['assessment'] + receipt = assessment['route'] + if (document['kind'] not in ('completed_assessment', 'partial_assessment') + or document['kind'] == 'partial_assessment' and value.get('partial_drive') is not True + or receipt['route_id'] != value['completed_route'] or receipt['source_sha256'] != value['source_sha256']): + raise ValueError('Source-bound recent findings required') + scope = RouteScope(**assessment['current_scope']).validate() + if receipt['cp_sha256'] != scope.cp_sha256: + raise ValueError('Recent finding vehicle identity changed') + stamp = receipt.get('completed_wall_ns', receipt.get('last_intact_wall_ns')) + if type(stamp) is not int or stamp <= 0: + raise ValueError('Original recent-drive chronology required') + return scope, document['kind'] == 'partial_assessment', stamp + + try: + current_scope, _, _ = source(latest) + current = route_values(latest['configured_values']) if 'configured_values' in latest else ( + ZERO if latest.get('saved_adjustments') == 0 else None + ) + except (KeyError, OSError, TypeError, ValueError): + return display + if current is None: + return display + compatible = [] + for index, value in enumerate(results[:MAX_CHECKPOINTS + 1]): + try: + scope, partial, stamp = source(value) + except (KeyError, OSError, TypeError, ValueError): + continue + if scope == current_scope: + compatible.append((stamp, index, partial, value)) + found, origins, blocked, seen = {}, {}, set(), set() + for _, _, partial, value in sorted(compatible, key=lambda row: (-row[0], row[1])): + if value['source_sha256'] in seen: + continue + if len(seen) >= MAX_CHECKPOINTS: + break + seen.add(value['source_sha256']) + recommendations = value.get('recommendations', ()) + if type(recommendations) not in (list, tuple): + continue + for row in recommendations: + if type(row) is not dict: + continue + name = row.get('parameter') + if (name not in NAMES or type(row.get('baseline')) not in (int, float) or row['baseline'] != current[name] + or type(row.get('reason')) is not str or len(row['reason']) > 240): + continue + target = row.get('target') + if target is None or row.get('reason') in ( + 'conflicting_recorded_candidates', 'heldout_profile_does_not_support_training_step', 'controller_checks_did_not_support_change' + ): + blocked.add(name) + continue + low, high = route_bounds(name) + if (type(target) not in (int, float) or not math.isfinite(target) or not low <= target <= high + or not 1e-12 < abs(target - current[name]) <= MAX_ROUTE_STEP + 1e-12 + or type(row.get('whole_windows')) is not int or not 0 < row['whole_windows'] < 2**63): + continue + if name in found and (found[name]['target'] - current[name]) * (target - current[name]) < 0: + blocked.add(name) + elif name not in found: + found[name] = dict(row, reason='partial_drive_provisional_only') if partial else dict(row) + origins[name] = value['completed_route'] + rows = [found[name] for name in NAMES if name in found and name not in blocked] + if rows == display.get('recommendations', []) and all(origins[row['parameter']] == display.get('completed_route') for row in rows): + return display + return dict(display, recommendations=rows, recommendation_count=len(rows), + recommendation_sources=[[row['parameter'], origins[row['parameter']]] for row in rows]) + + def reported_checkpoint(cache, results): """Display useful current-profile evidence without changing any saved decision.""" skipped = [row for row in results if row.get('route_skipped') is True] @@ -508,7 +589,7 @@ def reported_checkpoint(cache, results): if (latest.get('status') != 'collecting' or latest.get('reason') != 'more_independent_eligible_tracking_required' or has_windows(latest)): - return latest + return recent_findings(cache, results, latest) try: current_scope = scope(latest) except (KeyError, OSError, TypeError, ValueError): @@ -523,7 +604,7 @@ def reported_checkpoint(cache, results): # Recording order and input coverage choose the report, never fit quality or approval. retained = next((value for value in compatible if has_windows(value)), None) if retained is None: - return latest + return recent_findings(cache, results, latest) value = dict(latest) for key in ('completed_route', 'vehicle', 'analysis_counts', 'recorded_tracking', 'source_sha256', 'assessment_sha256', 'recommendations', 'suggestions', 'suggestion_count', 'qualification_summary'): @@ -538,7 +619,7 @@ def reported_checkpoint(cache, results): value['source_is_latest'] = False value['retained_decision'] = retained['reason'] value['latest_recording'] = {key: latest[key] for key in ('completed_route', 'reason', 'analysis_counts')} - return value # Display only: current save, application and rollback fields stay with the latest assessment. + return recent_findings(cache, results, value) # Save, application and rollback fields stay with the latest assessment. class OffroadWorker: @@ -1181,5 +1262,5 @@ class OffroadWorker: result['evidence_revision'] = self.evidence_bank.revision() self.cache.checkpoint({'input_fingerprint': self._snapshot(route), 'result': result}) self.pending_failure_data = None - return result + return recent_findings(self.cache, [result, *[row['result'] for row in self.cache.checkpoints()]], result) diff --git a/openpilot/starpilot/flm/tests/test_offroad_coordinate_policy.py b/openpilot/starpilot/flm/tests/test_offroad_coordinate_policy.py index 5229c9945c..62c403b6ea 100644 --- a/openpilot/starpilot/flm/tests/test_offroad_coordinate_policy.py +++ b/openpilot/starpilot/flm/tests/test_offroad_coordinate_policy.py @@ -1527,13 +1527,67 @@ class TestLatestUsefulDriveReport(unittest.TestCase): self.assertFalse(details['Earlier analysis shown while updating']) self.assertFalse(wire['current']['application']['applied']) - def test_new_useful_drive_without_suggestions_is_not_replaced_by_a_more_positive_report(self): + def test_new_useful_drive_keeps_its_measurements_and_recent_compatible_suggestions(self): self.latest['analysis_counts']['qualified_whole_windows'] = 4 result = self.report() self.assertEqual(result['completed_route'], self.latest['completed_route']) - self.assertEqual(result['recommendations'], []) + self.assertEqual(result['analysis_counts'], self.latest['analysis_counts']) + self.assertEqual(result['recommendations'], self.driving['recommendations']) + self.assertEqual(result['recommendation_sources'], [[r['parameter'], self.driving['completed_route']] for r in result['recommendations']]) self.assertNotIn('latest_recording', result) + def test_trial_rollback_does_not_erase_other_provisional_findings(self): + self.latest.update(status='rolled_back', reason='trial_inconclusive_drive_limit', configuration_changed=True, + configuration_state='rolled_back', configured_values=values(), saved_adjustments=0) + result = self.report() + for key in ('status', 'reason', 'configuration_changed', 'configuration_state', 'configured_values', 'saved_adjustments'): + self.assertEqual(result[key], self.latest[key]) + self.assertEqual(len(result['recommendations']), 5) + self.assertFalse(result['actual_application_proven']) + + def test_findings_accumulate_across_recent_drives_without_inflating_evidence(self): + self.latest['recommendations'] = [{'parameter': 'ff_gain_right', 'baseline': 0, 'target': -.005, + 'whole_windows': 3, 'reason': 'recorded_candidate_requires_automatic_checks'}] + self.latest['analysis_counts']['qualified_whole_windows'] = 4 + self.parked['recommendations'] = list(self.driving['recommendations']) + result = self.report() + self.assertEqual(len(result['recommendations']), 6) + self.assertEqual(result['recommendation_count'], 6) + self.assertEqual(result['analysis_counts'], self.latest['analysis_counts']) + self.assertEqual(result['recommendations'][0]['whole_windows'], 3) + self.assertTrue(all(r['whole_windows'] == 6 for r in result['recommendations'][1:])) + self.assertEqual(dict(result['recommendation_sources'])['unwind_taper_right'], self.driving['completed_route']) + + def test_conflicting_or_refused_findings_do_not_resurrect_older_suggestions(self): + self.latest['analysis_counts']['qualified_whole_windows'] = 4 + for reason in ('conflicting_recorded_candidates', 'heldout_profile_does_not_support_training_step', + 'controller_checks_did_not_support_change'): + with self.subTest(reason=reason): + self.latest['recommendations'] = [dict(self.driving['recommendations'][0], target=None, reason=reason)] + self.assertNotIn('unwind_taper_right', [r['parameter'] for r in self.report()['recommendations']]) + self.latest['recommendations'] = [dict(self.driving['recommendations'][1], target=-.005)] + self.assertNotIn('friction_threshold_low', [r['parameter'] for r in self.report()['recommendations']]) + + def test_old_targets_do_not_override_a_later_saved_setting(self): + self.latest.update(configuration_state='ready_for_next_drive', configured_values=dict.fromkeys(ROUTE_NAMES, .005), saved_adjustments=35) + self.latest['analysis_counts']['qualified_whole_windows'] = 4 + self.assertEqual(self.report()['recommendations'], []) + + def test_partial_findings_stay_partial_and_never_supply_trial_or_saved_state(self): + document = self.cache.get(self.driving['assessment_sha256']) + self.driving.update(assessment_sha256=self.cache.put(dict(document, kind='partial_assessment')), partial_drive=True, + configuration_changed=True, configuration_state='ready_for_next_drive', saved_adjustments=5) + self.latest['analysis_counts']['qualified_whole_windows'] = 4 + result = self.report() + self.assertEqual(len(result['recommendations']), 5) + self.assertTrue(all(r['reason'] == 'partial_drive_provisional_only' for r in result['recommendations'])) + self.assertEqual(result['saved_adjustments'], 0) + self.assertFalse(result['configuration_changed']) + self.assertNotIn('partial_drive', result) + self.assertNotIn('configuration_state', result) + self.driving.pop('partial_drive') + self.assertEqual(self.report()['recommendations'], []) + def test_different_vehicle_controller_baseline_epoch_or_reset_does_not_supply_findings(self): from dataclasses import replace @@ -1608,7 +1662,7 @@ class TestLatestUsefulDriveReport(unittest.TestCase): self.report() status.restore(self.cache) self.assertEqual(status.previous['completed_route'], self.latest['completed_route']) - self.assertEqual(status.previous['recommendations'], []) + self.assertEqual(status.previous['recommendations'], self.driving['recommendations']) diff --git a/openpilot/starpilot/galaxy/flm_diagnostics.py b/openpilot/starpilot/galaxy/flm_diagnostics.py index e73ca61148..ce111b7464 100644 --- a/openpilot/starpilot/galaxy/flm_diagnostics.py +++ b/openpilot/starpilot/galaxy/flm_diagnostics.py @@ -35,7 +35,7 @@ def diagnostics(report, params): 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', + 'Recorded coordinate recommendations', 'Recorded suggestion sources', 'Controller and encoder check windows', 'Automatic tune refusal reasons', 'Drive analysis is partial', 'Partial drive segments', 'Omitted recorded segments') if key in details} result['current']['skipped_drives'] = _result({'skipped_routes': details.get('Skipped recorded drives', [])})['skipped_drives'] if params is None: diff --git a/openpilot/starpilot/galaxy/tests/test_flm_review.mjs b/openpilot/starpilot/galaxy/tests/test_flm_review.mjs index 65b34eb4f0..7d5a00ff58 100644 --- a/openpilot/starpilot/galaxy/tests/test_flm_review.mjs +++ b/openpilot/starpilot/galaxy/tests/test_flm_review.mjs @@ -11,6 +11,9 @@ const idea = (parameter, target = .005) => ({ parameter, baseline: 0, target, de const route = { suggestions: [idea('highway_center_taper_max'), ...FRICTION_NAMES.slice(1).map(name => idea(name))], savedValues: null, saved: false, configurationState: null } const review = reviewModel(route) +assert.match(ideaExplanation({ ...idea('turn_in_boost_right'), earlierDrive: true }), /earlier drive with the same setup/) +assert.match(ideaExplanation({ ...idea('turn_in_boost_right'), earlierDrive: true, reason: 'partial_drive_provisional_only' }), + /earlier drive.*incomplete recording.*will not save it automatically/) assert.equal(review.count, 5) assert.equal(review.manual.length, 1) assert.equal(review.curve.length, 4) diff --git a/openpilot/starpilot/galaxy/tests/test_flm_training_results.mjs b/openpilot/starpilot/galaxy/tests/test_flm_training_results.mjs index 45eb7a4396..623e66ab58 100644 --- a/openpilot/starpilot/galaxy/tests/test_flm_training_results.mjs +++ b/openpilot/starpilot/galaxy/tests/test_flm_training_results.mjs @@ -91,6 +91,28 @@ assert.equal(priorFindings.savedValues, null) assert.equal(priorFindings.evidenceDrives, 2) assert.match(offroadCoordinateEvidence(earlierDrive, 'highway_center_taper_max'), /Earlier analyzed drive.*not saved/) assert.equal(offroadView(completed).earlierDrive, false, 'Old reports remain readable without inventing history') +const recent = structuredClone(completed) +recent.current.details['Recorded coordinate recommendations'] = [ + ['turn_in_boost_right', 0, .005, 10, 'partial_drive_provisional_only'], + ['unwind_taper_left', 0, .005, 8, 'recorded_candidate_requires_automatic_checks'], +] +recent.current.details['Recorded suggestion sources'] = [['turn_in_boost_right', 'earlier-partial-drive'], ['unwind_taper_left', 'earlier-full-drive']] +recent.current.details['Saved route configuration state'] = 'rolled_back' +assert(validTrainingResults(recent)) +assert.equal(offroadView(recent).configurationState, 'rolled_back') +assert.deepEqual(offroadView(recent).suggestions.map(r => [r.sourceRoute, r.earlierDrive]), + [['earlier-partial-drive', true], ['earlier-full-drive', true]]) +assert.equal(offroadView(recent).partial, false, 'A partial historical finding must not relabel the latest completed drive') +const allSources = structuredClone(recent) +allSources.current.details['Recorded coordinate recommendations'] = [...SURFACE_NAMES, ...FRICTION_NAMES].map(name => [name, 0, .005, 6, 'unconfirmed']) +allSources.current.details['Recorded suggestion sources'] = [...SURFACE_NAMES, ...FRICTION_NAMES].map(name => [name, 'earlier-full-drive']) +assert(validTrainingResults(allSources), 'All 35 source-bound coordinates fit the report contract') +assert.equal(offroadView(allSources).suggestions.length, 35) +for (const sources of [[['unknown', 'route']], [['turn_in_boost_right', '']], + [['turn_in_boost_right', 'route'], ['turn_in_boost_right', 'copy']], [['ff_gain_left', 'unmatched-finding']]]) { + const bad = structuredClone(recent); bad.current.details['Recorded suggestion sources'] = sources + assert.equal(offroadView(bad), null) +} for (const mutate of [d => d['Latest completed recording reviewed'] = 7, d => d['Latest completed recording reviewed'] = 'declared-drive', d => d['Findings retained from earlier drive'] = 'different-source']) { diff --git a/openpilot/starpilot/galaxy/tests/test_flm_ux_browser.mjs b/openpilot/starpilot/galaxy/tests/test_flm_ux_browser.mjs index 14f097f076..bde424d3cf 100644 --- a/openpilot/starpilot/galaxy/tests/test_flm_ux_browser.mjs +++ b/openpilot/starpilot/galaxy/tests/test_flm_ux_browser.mjs @@ -57,6 +57,17 @@ function report() { value.current.details['Recorded coordinate recommendations'][0][0] = 'unwind_taper_right' } if (scenario === 'rollback') value.current.details['Saved route configuration state'] = 'rolled_back' + if (scenario === 'recent-rollback') { + value.current.status = 'rolled_back';value.current.reason = 'trial_inconclusive_drive_limit' + Object.assign(value.current.details, { 'Analysis decision': value.current.reason, 'Saved route configuration state': 'rolled_back', + 'Recorded steering response': null, 'Full surface coordinates': rows, + 'Saved friction-curve adjustments': FRICTION_NAMES.map(name => [name, 0]) }) + const recent = [['ff_gain_right', -.005], ['turn_in_boost_right', .005], ['unwind_taper_right', .005], + ['unwind_taper_left', .005], ['center_taper_max', .006], ['center_deadband_fast_deg', .006], ...hints.slice(1)] + value.current.details['Recorded coordinate recommendations'] = recent.map(([name, target], i) => + [name, 0, target, i < 3 ? 10 : 24, i < 3 ? 'partial_drive_provisional_only' : 'recorded_candidate_requires_automatic_checks']) + value.current.details['Recorded suggestion sources'] = recent.map(([name], i) => [name, i < 3 ? 'earlier-partial-drive' : 'earlier-completed-drive']) + } if (scenario === 'incomplete') delete value.current.details['Recorded steering observations'] if (scenario === 'unknown-change') value.current.details['Automatic configuration changed'] = true assert(validTrainingResults(value), 'Browser fixtures must pass the real report validator') @@ -255,7 +266,7 @@ try { } } await viewport(416);await execute('document.documentElement.dataset.theme="dark"') - for (const name of ['none', 'empty', 'saved', 'rollback', 'conflict', 'contradictory', 'stale', 'retained', 'earlier-drive', 'wrong-car', 'incomplete', 'unknown-change']) { + for (const name of ['none', 'empty', 'saved', 'rollback', 'recent-rollback', 'conflict', 'contradictory', 'stale', 'retained', 'earlier-drive', 'wrong-car', 'incomplete', 'unknown-change']) { await change(name);await layout(`state/${name}`);await capture(name) if (name === 'retained') assert(await execute('return !/Refresh|Reconnect/.test(window.flm.review.description)&&window.flm.review.description.includes("saved tune")')) if (name === 'earlier-drive') { @@ -278,6 +289,20 @@ try { } if (name === 'stale') assert(await execute('return !/Refresh|Reconnect/.test(window.flm.review.description)&&window.flm.savedSummary==="0 saved"')) if (name === 'saved') assert.equal(await execute('return window.flm.currentApplied'), false) + if (name === 'recent-rollback') { + assert.equal(await execute('return window.flm.review.title'), 'Your previous tune was restored') + assert.equal(await execute('return window.flm.review.count'), 10) + assert.equal(await execute('return window.flm.currentApplied'), false) + const writes = requests.length + await click('[data-action=view-findings]') + assert(await execute('return window.flm.review.manual.length===6 && window.flm.review.curve.length===4')) + assert(await execute('return document.querySelector(".gx-tuner__findings").textContent.includes("SUGGESTIONS FROM RECENT DRIVING")')) + assert(await execute('return document.querySelector(".gx-tuner__idea-grid").textContent.includes("earlier drive with the same setup")')) + assert(await execute('return document.querySelector(".gx-tuner__idea-grid").textContent.includes("incomplete recording")')) + assert.equal(requests.length, writes, 'Reviewing retained suggestions must not write a tune') + await capture('rollback-ten-recent-findings') + checks.push('rollback/ten-source-bound-recent-findings/no-write') + } if (name === 'conflict') { assert.equal(await execute('return window.flm.review.count'), 4);assert(await execute('return !window.flm.review.findings.some(row=>row.target===null)')) } if (name === 'contradictory') { assert.equal(await execute('return window.flm.review.count'), 1) diff --git a/openpilot/starpilot/galaxy/web/js/flm-review.js b/openpilot/starpilot/galaxy/web/js/flm-review.js index 189e04818b..4897779475 100644 --- a/openpilot/starpilot/galaxy/web/js/flm-review.js +++ b/openpilot/starpilot/galaxy/web/js/flm-review.js @@ -17,13 +17,14 @@ export function ideaStatus(row) { export function ideaExplanation(row) { if (!isConsistentSuggestion(row)) return 'Different parts of the drive did not support the same change. Your tune was left unchanged.' + const source = row.earlierDrive ? 'From an earlier drive with the same setup. ' : '' const next = SURFACE_NAMES.includes(row.parameter) ? ' You can review the suggested value and adjust this setting manually while parked.' : ' Auto Learn will review it as more driving is recorded.' if (row.reason === 'partial_drive_provisional_only') - return 'This suggestion comes from intact sections of an incomplete recording. Auto Learn will not save it automatically.' + next + return source + 'This suggestion comes from intact sections of an incomplete recording. Auto Learn will not save it automatically.' + next if (row.reason === 'independent_support_for_frozen_training_profile') - return 'Separate parts of your drive support this suggestion. Auto Learn still needs to confirm the controller checks before saving it.' + next - return 'Your drive suggests this change, but Auto Learn needs more evidence before saving it automatically.' + next + return source + 'Separate parts of your drive support this suggestion. Auto Learn still needs to confirm the controller checks before saving it.' + next + return source + 'Your drive suggests this change, but Auto Learn needs more evidence before saving it automatically.' + next } export function reviewModel(route, historical = false, updating = false) { @@ -114,7 +115,8 @@ export function curvePointLabel(name) { } export function ideaDetails(row) { - const baseline = Number.isFinite(row.baseline) ? [{ label: 'Starting value', value: dialPercent(row.baseline) }] : [] + const baseline = [ ...(row.sourceRoute ? [{ label: 'Source drive', value: row.sourceRoute }] : []), + ...(Number.isFinite(row.baseline) ? [{ label: 'Starting value', value: dialPercent(row.baseline) }] : []) ] if (row.target === null) return [...baseline, { label: 'Suggested value', value: 'No single suggested value' }] if (row.target === undefined) return [...baseline, { label: 'Suggested change', value: (row.delta > 0 ? '+' : '') + dialPercent(row.delta) }] return [...baseline, { label: 'Suggested value', value: dialPercent(row.target) }] diff --git a/openpilot/starpilot/galaxy/web/js/flm-training-results.js b/openpilot/starpilot/galaxy/web/js/flm-training-results.js index 75c5446bf5..1933de62f0 100644 --- a/openpilot/starpilot/galaxy/web/js/flm-training-results.js +++ b/openpilot/starpilot/galaxy/web/js/flm-training-results.js @@ -54,7 +54,8 @@ export function validTrainingResults(value) { item.every(number => typeof number === 'number' && Number.isFinite(number) && Math.abs(number) <= .25) : key === 'GLOBAL source observation refusals' ? validSourceRefusals(item) : key === 'Recorded steering response' ? item === null || recordedSteeringView(item) !== null : - key === 'Recorded coordinate recommendations' ? validCoordinateRecommendations(item) : detailValue(item))) + key === 'Recorded coordinate recommendations' ? validCoordinateRecommendations(item) : + key === 'Recorded suggestion sources' ? validSuggestionSources(item) : detailValue(item))) } const labels = { collecting: "Gathering driving examples", unavailable: "Waiting for usable driving data", qualifiedFit: "Fit passed validation", qualified: "Fit passed validation", rejected: "Fit did not pass validation", @@ -287,6 +288,12 @@ export function isConsistentSuggestion(row) { 'controller_checks_did_not_support_change'].includes(row.reason) } +function validSuggestionSources(rows) { + return Array.isArray(rows) && rows.length <= 35 && new Set(rows.map(row => row?.[0])).size === rows.length && + rows.every(row => Array.isArray(row) && row.length === 2 && [...SURFACE_NAMES, ...FRICTION_NAMES].includes(row[0]) && + text(row[1], 180) && row[1].length > 0) +} + export function offroadView(report) { const details = report?.current?.details if (!record(details) || !text(details['Completed drive analyzed'], 180) || !details['Completed drive analyzed'] || @@ -299,6 +306,9 @@ export function offroadView(report) { const observed = recordedSteeringView(details['Recorded steering response']) const recommendations = details['Recorded coordinate recommendations'] if (recommendations !== undefined && !validCoordinateRecommendations(recommendations)) return null + const sources = details['Recorded suggestion sources'] ?? [] + if (!validSuggestionSources(sources) || sources.some(([name]) => !recommendations?.some(row => row[0] === name))) return null + const sourceFor = Object.fromEntries(sources) const savedCount = details['Saved route adjustment count'] const partial = details['Drive analysis is partial'] === true const partialSegments = details['Partial drive segments'] @@ -327,7 +337,9 @@ export function offroadView(report) { earlierDrive, latestRecording: earlierDrive ? latestRecording : null, suggestions: (recommendations === undefined ? rows.map(([parameter, delta, windows, qualification]) => ({ parameter, delta, windows, qualification })) : recommendations.map(([parameter, baseline, target, windows, reason]) => ({ parameter, baseline, target, - delta: target === null ? null : target - baseline, windows, reason, qualification: 'controller_native_checks_not_passed' })) + delta: target === null ? null : target - baseline, windows, reason, sourceRoute: sourceFor[parameter] ?? details['Completed drive analyzed'], + earlierDrive: sourceFor[parameter] !== undefined && sourceFor[parameter] !== details['Completed drive analyzed'], + qualification: 'controller_native_checks_not_passed' })) .filter(row => row.target === null || row.target !== { ...savedSurface, ...savedFriction }[row.parameter])).filter(isConsistentSuggestion), moreSuggestions: details['More recorded suggestions omitted'] === true } } diff --git a/openpilot/starpilot/galaxy/web/js/flm.js b/openpilot/starpilot/galaxy/web/js/flm.js index c169fec0b2..f079036582 100644 --- a/openpilot/starpilot/galaxy/web/js/flm.js +++ b/openpilot/starpilot/galaxy/web/js/flm.js @@ -340,7 +340,7 @@ export const FlmPage = {

Make sense of your tune

Review what Auto Learn found, or adjust a setting yourself.

-

SUGGESTIONS FROM COMPLETED DRIVING

{{ review.title }}

{{ review.description }}

{{ review.tone === 'saved' ? 'Saved tune' : review.count ? 'Review only' : 'No new change' }}
+

SUGGESTIONS FROM RECENT DRIVING

{{ review.title }}

{{ review.description }}

{{ review.tone === 'saved' ? 'Saved tune' : review.count ? 'Review only' : 'No new change' }}

{{ review.historical ? 'Earlier saved Auto Learn values' : offroad.configurationState === 'ready_for_next_drive' ? 'Saved for the next drive' : 'Saved Auto Learn values' }}

{{ parameterLabel(row.parameter) }}{{ dialPercent(row.value) }}

Saved does not mean applied now. The controller confirms use while driving.

{{ review.manual.length }} steering {{ review.manual.length === 1 ? 'finding' : 'findings' }} · {{ review.curve.length }} speed-range {{ review.curve.length === 1 ? 'finding' : 'findings' }}. Viewing an idea does not change your tune.

diff --git a/prebuilt.json b/prebuilt.json index 9d5b4cf7e8..1fe97ee061 100644 --- a/prebuilt.json +++ b/prebuilt.json @@ -1 +1 @@ -{"protected_inventory_sha256": "f61045d2e16299d366308f9b7fcf3a137a23438c4c387d78ddd2993a03e4619f", "schema_version": 1} +{"protected_inventory_sha256": "3f74f536c12538983d0346828b30d24caf6ae2517822c56ed4d8c7027934f0f5", "schema_version": 1}